dependency-cruiser
Advanced tools
Comparing version 2.0.2 to 2.1.0
{ | ||
"name": "dependency-cruiser", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.", | ||
@@ -38,3 +38,3 @@ "bin": { | ||
"coffee-script": "1.12.4", | ||
"eslint": "3.17.1", | ||
"eslint": "3.18.0", | ||
"eslint-plugin-security": "1.3.0", | ||
@@ -59,3 +59,3 @@ "intercept-stdout": "0.1.2", | ||
"acorn": "4.0.11", | ||
"ajv": "4.11.4", | ||
"ajv": "4.11.5", | ||
"chalk": "1.1.3", | ||
@@ -62,0 +62,0 @@ "commander": "2.9.0", |
@@ -100,3 +100,4 @@ # Dependency cruiser ![Dependency cruiser](https://raw.githubusercontent.com/sverweij/dependency-cruiser/master/doc/assets/ZKH-Dependency-recolored-160.png) | ||
- [Output format](./doc/output-format.md) | ||
- [Adding support for other alt-js languages](./doc/faq.md) | ||
- [Adding support for other alt-js languages](./doc/faq.md#how-do-i-add-support-for-my-favorite-alt-js-language) | ||
- [Adding other output formats](./doc/faq.md#how-do-i-add-a-new-output-format) | ||
- Other things | ||
@@ -103,0 +104,0 @@ - [Road map](https://github.com/sverweij/dependency-cruiser/projects/1) |
@@ -21,2 +21,8 @@ { | ||
},{ | ||
"name": "no-deprecated-npm", | ||
"comment": "These npm modules are deprecated - find an alternative.", | ||
"severity": "warn", | ||
"from": {}, | ||
"to": { "dependencyTypes": ["deprecated"] } | ||
},{ | ||
"name": "not-to-unresolvable", | ||
@@ -23,0 +29,0 @@ "comment": "Don't allow dependencies on modules dependency-cruiser can't resolve to files on disk (which probably means they don't exist)", |
@@ -93,3 +93,3 @@ { | ||
"type": "boolean", | ||
"description": "Whether or not this is a node.js core module" | ||
"description": "Whether or not this is a node.js core module - deprecated in favor of dependencyType === core" | ||
}, | ||
@@ -188,3 +188,4 @@ "dependencyTypes": { | ||
"unknown", | ||
"undetermined" | ||
"undetermined", | ||
"deprecated" | ||
] | ||
@@ -191,0 +192,0 @@ }, |
"use strict"; | ||
const resolve = require('resolve'); | ||
const resolve = require("resolve"); | ||
const getPackageJson = require("./getPackageJson"); | ||
@@ -12,2 +13,12 @@ const npm2depType = { | ||
function dependencyIsDeprecated(pModule, pBaseDir) { | ||
let lRetval = false; | ||
let lPackageJson = getPackageJson(pModule, pBaseDir); | ||
if (Boolean(lPackageJson)){ | ||
lRetval = lPackageJson.hasOwnProperty("deprecated"); | ||
} | ||
return lRetval; | ||
} | ||
function determineNpmDependencyTypes(pModuleName, pPackageDeps) { | ||
@@ -25,7 +36,7 @@ let lRetval = ["npm-unknown"]; | ||
} | ||
return lRetval; | ||
} | ||
module.exports = (pDependency, pModuleName, pPackageDeps) => { | ||
module.exports = (pDependency, pModuleName, pPackageDeps, pBaseDir) => { | ||
let lRetval = ["undetermined"]; | ||
@@ -36,3 +47,3 @@ | ||
} else if (resolve.isCore(pModuleName)) { | ||
// this 'resolve.isCOre' business seems duplicate (it's already in | ||
// this 'resolve.isCore' business seems duplicate (it's already in | ||
// the passed object as `coreModule`- determined by the resolve-AMD or | ||
@@ -51,2 +62,7 @@ // resolve-commonJS module). I want to deprecate the `coreModule` | ||
lRetval = determineNpmDependencyTypes(pModuleName.split("/")[0], pPackageDeps); | ||
if (dependencyIsDeprecated(pModuleName, pBaseDir)) { | ||
lRetval.push("deprecated"); | ||
} | ||
} | ||
@@ -53,0 +69,0 @@ |
@@ -9,2 +9,26 @@ "use strict"; | ||
/** | ||
* resolves the module name of the pDependency to a file on disk. | ||
* | ||
* @param {object} pDependency an object with a moduleName and the moduleSystem | ||
* according to which this is a dependency | ||
* @param {string} pBaseDir the directory to consider as base (or 'root') | ||
* for resolved files. | ||
* @param {string} pFileDir the directory of the file the dependency was | ||
* detected in | ||
* @return {object} an object with as attributes: | ||
* - resolved: a string representing the pDependency | ||
* resolved to a file on disk (or the pDependency | ||
* name itself when it could not be resolved) | ||
* - coreModule: true the dependency is a (node) | ||
* core module - false in all other cases | ||
* (deprecated over dependencyType === 'core') | ||
* - followable: true when it is worthwhile to | ||
* follow dependencies of this dependency ( | ||
* typically not true for .json) | ||
* - couldNotResolve: true if it was not possible | ||
* to resolve the dependency to a file on disk | ||
* - dependencyTypes: an array of dependencyTypes | ||
* | ||
*/ | ||
module.exports = (pDependency, pBaseDir, pFileDir) => { | ||
@@ -11,0 +35,0 @@ if (isRelativeModuleName(pDependency.moduleName)){ |
@@ -25,3 +25,3 @@ "use strict"; | ||
lRetval = JSON.parse( | ||
fs.readFileSync(`${pBaseDir}${path.sep}package.json`, 'utf8') | ||
fs.readFileSync(path.join(pBaseDir, 'package.json'), 'utf8') | ||
); | ||
@@ -28,0 +28,0 @@ } catch (e) { |
@@ -44,3 +44,4 @@ "use strict"; | ||
pModuleName, | ||
readPackageDeps(pBaseDir) | ||
readPackageDeps(pBaseDir), | ||
pFileDir | ||
) | ||
@@ -47,0 +48,0 @@ } |
@@ -49,3 +49,4 @@ "use strict"; | ||
pModuleName, | ||
readPackageDeps(pBaseDir) | ||
readPackageDeps(pBaseDir), | ||
pFileDir | ||
) | ||
@@ -52,0 +53,0 @@ } |
@@ -5,2 +5,19 @@ "use strict"; | ||
/** | ||
* Transpiles the string pFile with the transpiler configured for extension | ||
* pExtension (e.g. for extension ".ts" transpiles ) - if a supported version | ||
* for it is available. | ||
* | ||
* Returns the string pFile in all other cases | ||
* | ||
* @see section "supportedTranspilers" in [package.json](../../../package.json) | ||
* for supported versions of transpilers | ||
* @see [meta.js](meta.js) for the extension -> transpiler mapping | ||
* | ||
* @param {string} pExtension extension of the file to transpile | ||
* @param {string} pFile the contents of the file to transpile | ||
* @return {string} the transpiled version of the file (or the file | ||
* itself when the function could not find a | ||
* transpiler matching pExtension | ||
*/ | ||
module.exports = (pExtension, pFile) => { | ||
@@ -7,0 +24,0 @@ const lWrapper = meta.getWrapper(pExtension); |
@@ -27,5 +27,20 @@ "use strict"; | ||
/** | ||
* returns the wrapper module configured for the extension pExtension. | ||
* | ||
* returns the javascript wrapper if there's no wrapper module configured | ||
* for the extension. | ||
* | ||
* @param {string} pExtension the extension (e.g. ".ts", ".js", ".litcoffee") | ||
* @returns {module} the module | ||
*/ | ||
module.exports.getWrapper = | ||
pExtension => extension2wrapper[pExtension] || javaScriptWrap; | ||
/** | ||
* all supported extensions and whether or not it is supported | ||
* in the current environment | ||
* | ||
* @type {array} | ||
*/ | ||
module.exports.allExtensions = | ||
@@ -40,2 +55,8 @@ Object.keys(extension2wrapper) | ||
/** | ||
* an array of extensions that are 'scannable' (have a valid transpiler | ||
* available for) in the current environemnt. | ||
* | ||
* @type {array} | ||
*/ | ||
module.exports.scannableExtensions = | ||
@@ -47,2 +68,9 @@ Object.keys(extension2wrapper) | ||
/** | ||
* returns an array of supported transpilers, whith for each transpiler: | ||
* - the version (range) supported | ||
* - whether or not it is available in the current environment | ||
* | ||
* @returns {array} an array of supported transpilers | ||
*/ | ||
module.exports.getAvailableTranspilers = | ||
@@ -49,0 +77,0 @@ () => |
@@ -5,2 +5,14 @@ "use strict"; | ||
/** | ||
* returns the (resolved) module identified by pModuleName: | ||
* - if it is available, and | ||
* - it satisfies the semantic version range specified by pSemVer | ||
* | ||
* returns false in all other cases | ||
* | ||
* @param {string} pModuleName the name of the module to resolve | ||
* @param {string} pSemVer (optional) a semantic version (range) | ||
* @return {object} the (resolved) module identified by pModuleName | ||
* or false | ||
*/ | ||
module.exports = (pModuleName, pSemVer) => { | ||
@@ -7,0 +19,0 @@ let lRetval = false; |
@@ -107,2 +107,23 @@ "use strict"; | ||
/** | ||
* If pValidate equals true, validates the pFrom and pTo | ||
* dependency pair against the given ruleset pRuleSet | ||
* | ||
* @param {Boolean} pValidate whether or not to validate at all | ||
* @param {object} pRuleSet a ruleset (adhering to | ||
* [the ruleset schema](jsonschema.json)) | ||
* @param {object} pFrom The from part of the dependency | ||
* @param {object} pTo The 'to' part of the dependency | ||
* @return {object} an object with as attributes: | ||
* - valid: (boolean) true if the relation | ||
* between pTo and pFalse is valid (as far as the | ||
* given ruleset is concerend). false in all other | ||
* cases. | ||
* - rule (only when the relation between pFrom and | ||
* pTo was false): | ||
* - name: the name (from the ruleset) of the | ||
* violated rule | ||
* - severity: the severity of that rule - as per | ||
* the ruleset | ||
*/ | ||
module.exports = (pValidate, pRuleSet, pFrom, pTo) => { | ||
@@ -109,0 +130,0 @@ if (!pValidate) { |
@@ -126,3 +126,4 @@ { | ||
"unknown", | ||
"undetermined" | ||
"undetermined", | ||
"deprecated" | ||
] | ||
@@ -129,0 +130,0 @@ } |
@@ -27,2 +27,11 @@ "use strict"; | ||
/** | ||
* 'Normalizes' the given rule set pRuleSet by adding default values for | ||
* attributes that are optional and not present in the rule set; in casu: | ||
* - rule name (default 'unnamed') | ||
* - severity (default 'warn') | ||
* | ||
* @param {object} pRuleSet [description] | ||
* @return {object} [description] | ||
*/ | ||
module.exports = (pRuleSet) => { | ||
@@ -29,0 +38,0 @@ if (pRuleSet.hasOwnProperty("allowed")){ |
@@ -6,2 +6,14 @@ "use strict"; | ||
/** | ||
* For the given ruleset pRuleSetJSON: | ||
* - checks whether it is valid (and throws errors when it isn't) | ||
* - normalizes the ruleset (by using default values for non-filled out optional | ||
* fields) | ||
* | ||
* ... and returns it as an object | ||
* | ||
* @param {object} pRuleSetJSON The to be validated ruleset (you can both pass | ||
* an object or JSON as a string) | ||
* @return {object} The validated & normalized rule set | ||
*/ | ||
module.exports = pRuleSetJSON => | ||
@@ -8,0 +20,0 @@ normalizeRuleSet( |
@@ -37,2 +37,13 @@ "use strict"; | ||
/** | ||
* Returns the passed ruleset pRuleSet when it is valid. | ||
* Throws an Error in all other cases. | ||
* | ||
* Validations: | ||
* - the ruleset adheres to the [rule set json schema](jsonschema.json) | ||
* - any regular expression in the rule set is 'safe' (~= won't be too slow) | ||
* | ||
* @param {object} pRuleSet The ruleset to validate | ||
* @return {object} The ruleset as passed | ||
*/ | ||
module.exports = (pRuleSet) => { | ||
@@ -39,0 +50,0 @@ validateAgainstSchema(ruleSchema, pRuleSet); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126769
54
2197
126
11
+ Addedajv@4.11.5(transitive)
- Removedajv@4.11.4(transitive)
Updatedajv@4.11.5