Comparing version 1.1.0 to 1.2.0
@@ -14,3 +14,3 @@ "use strict"; | ||
var _minimatch = _interopRequireDefault(require("minimatch")); | ||
var _multimatch = _interopRequireDefault(require("multimatch")); | ||
@@ -50,5 +50,3 @@ var _ignore = _interopRequireDefault(require("ignore")); | ||
function isIgnored(ignoreMatches, dependency) { | ||
const match = _lodash.default.partial(_minimatch.default, dependency); | ||
return ignoreMatches.some(match); | ||
return Boolean((0, _multimatch.default)(dependency, ignoreMatches).length); | ||
} | ||
@@ -55,0 +53,0 @@ |
@@ -14,22 +14,50 @@ "use strict"; | ||
var _nodeSassTildeImporter = _interopRequireDefault(require("node-sass-tilde-importer")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _utils = require("../utils"); | ||
const sass = require('sass'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function unixSlashes(packagePath) { | ||
return packagePath.replace(/\\/g, '/'); | ||
} | ||
const sass = (0, _utils.tryRequire)('node-sass'); | ||
function removeNodeModulesOrTildaFromPath(packagePath) { | ||
const nodeModulesIndex = packagePath.indexOf('node_modules/'); | ||
async function parseSASS(filename, deps, rootDir) { | ||
const { | ||
stats | ||
} = sass.renderSync({ | ||
file: filename, | ||
includePaths: [_path.default.dirname(filename)], | ||
importer: _nodeSassTildeImporter.default | ||
}); | ||
const result = (0, _lodash.default)(stats.includedFiles).map(file => _path.default.relative(rootDir, file)).filter(file => file.indexOf('node_modules') >= 0) // refer to node_modules | ||
.map(file => file.replace(/\\/g, '/')) // normalize paths in Windows | ||
.map(file => file.substring(file.indexOf('node_modules/') + 'node_modules/'.length)) // avoid heading slash | ||
.map(_requirePackageName.default).uniq().value(); | ||
if (nodeModulesIndex > -1) { | ||
return packagePath.substring(nodeModulesIndex + 'node_modules/'.length); | ||
} | ||
if (packagePath.indexOf(`~`) === 0) { | ||
return packagePath.substring(1); | ||
} | ||
return packagePath; | ||
} | ||
async function parseSASS(filename) { | ||
const includedFiles = []; | ||
let sassDetails = {}; | ||
try { | ||
// sass processor does not respect the custom importer | ||
sassDetails = sass.renderSync({ | ||
file: filename, | ||
includePaths: [_path.default.dirname(filename)], | ||
importer: [function importer(url) { | ||
includedFiles.push(url); | ||
return { | ||
contents: ` | ||
h1 { | ||
font-size: 40px; | ||
}` | ||
}; | ||
}] | ||
}); | ||
} catch (e) { | ||
sassDetails.stats = { | ||
includedFiles | ||
}; | ||
} | ||
const result = (0, _lodash.default)(sassDetails.stats.includedFiles).filter(packagePath => packagePath !== filename).map(unixSlashes).map(removeNodeModulesOrTildaFromPath).map(_requirePackageName.default).uniq().filter(x => x).value(); | ||
return result; | ||
@@ -36,0 +64,0 @@ } |
@@ -20,14 +20,43 @@ "use strict"; | ||
function findStringPlugins(pluginElementsArray) { | ||
return pluginElementsArray.filter(e => e.type === 'StringLiteral').map(e => e.value); | ||
} | ||
function findResolvePlugins(pluginElementsArray) { | ||
return pluginElementsArray.filter(e => e.type === 'ObjectExpression').map(e => e.properties).reduce((acc, props) => acc.concat(props), []).filter(resolvePropCandidate => resolvePropCandidate.key.value === 'resolve' && resolvePropCandidate.value && resolvePropCandidate.value.type === 'StringLiteral').map(resolveProp => resolveProp.value.value); | ||
} | ||
function findNestedPlugins(pluginElementsArray) { | ||
return pluginElementsArray.filter(e => e.type === 'ObjectExpression').map(e => e.properties).reduce((acc, props) => acc.concat(props), []).filter(optionsPropCandidate => optionsPropCandidate && optionsPropCandidate.key && optionsPropCandidate.key.value === 'options' && optionsPropCandidate.value && optionsPropCandidate.value.type === 'ObjectExpression') // eslint-disable-next-line no-use-before-define | ||
.map(optionsNode => findPluginsInObjectExpression(optionsNode.value)).reduce((deps, dep) => deps.concat(dep), []); | ||
} | ||
function findPluginsInObjectExpression(node) { | ||
const dependencies = []; | ||
node.properties.forEach(prop => { | ||
if (prop.value.type === 'ArrayExpression' && (prop.key.name === 'plugins' || prop.key.value === 'plugins')) { | ||
const vals = []; | ||
vals.push(...findResolvePlugins(prop.value.elements)); | ||
vals.push(...findStringPlugins(prop.value.elements)); | ||
vals.push(...findNestedPlugins(prop.value.elements)); | ||
dependencies.push(...vals); | ||
} | ||
}); | ||
return dependencies; | ||
} | ||
/** | ||
* | ||
* | ||
* @param {Object} node Root node of the gatsby.config.js file | ||
* | ||
*/ | ||
function parseConfigModuleExports(node) { | ||
// node.left must be assigning to module.exports | ||
if (node && node.type === 'AssignmentExpression' && node.left.type === 'MemberExpression' && node.left.object && node.left.object.type === 'Identifier' && node.left.object.name === 'module' && node.left.property && node.left.property.type === 'Identifier' && node.left.property.name === 'exports') { | ||
const config = {}; | ||
node.right.properties.forEach(prop => { | ||
if (prop.value.type === 'ArrayExpression' && prop.key.name === 'plugins') { | ||
const vals = []; | ||
prop.value.elements.filter(e => e.type === 'StringLiteral').forEach(e => vals.push(e.value)); | ||
config[prop.key.name] = vals; | ||
} | ||
}); | ||
return config; | ||
const plugins = findPluginsInObjectExpression(node.right); | ||
return { | ||
plugins | ||
}; | ||
} | ||
@@ -34,0 +63,0 @@ |
{ | ||
"name": "depcheck", | ||
"version": "v1.1.0", | ||
"version": "1.2.0", | ||
"description": "Check dependencies in your node module", | ||
@@ -62,5 +62,5 @@ "main": "dist/index.js", | ||
"json5": "^2.1.3", | ||
"lodash": "^4.17.15", | ||
"lodash": "^4.17.19", | ||
"minimatch": "^3.0.4", | ||
"node-sass-tilde-importer": "^1.0.2", | ||
"multimatch": "^4.0.0", | ||
"please-upgrade-node": "^3.2.0", | ||
@@ -70,2 +70,3 @@ "readdirp": "^3.4.0", | ||
"resolve": "^1.17.0", | ||
"sass": "^1.26.10", | ||
"vue-template-compiler": "^2.6.11", | ||
@@ -94,3 +95,3 @@ "yargs": "^15.4.0" | ||
"fs-extra": "^9.0.1", | ||
"mocha": "^8.0.1", | ||
"mocha": "^8.1.1", | ||
"node-sass": "^4.14.1", | ||
@@ -97,0 +98,0 @@ "nyc": "^15.1.0", |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
195463
2423
0
20
+ Addedmultimatch@^4.0.0
+ Addedsass@^1.26.10
+ Added@parcel/watcher@2.5.0(transitive)
+ Added@parcel/watcher-android-arm64@2.5.0(transitive)
+ Added@parcel/watcher-darwin-arm64@2.5.0(transitive)
+ Added@parcel/watcher-darwin-x64@2.5.0(transitive)
+ Added@parcel/watcher-freebsd-x64@2.5.0(transitive)
+ Added@parcel/watcher-linux-arm-glibc@2.5.0(transitive)
+ Added@parcel/watcher-linux-arm-musl@2.5.0(transitive)
+ Added@parcel/watcher-linux-arm64-glibc@2.5.0(transitive)
+ Added@parcel/watcher-linux-arm64-musl@2.5.0(transitive)
+ Added@parcel/watcher-linux-x64-glibc@2.5.0(transitive)
+ Added@parcel/watcher-linux-x64-musl@2.5.0(transitive)
+ Added@parcel/watcher-win32-arm64@2.5.0(transitive)
+ Added@parcel/watcher-win32-ia32@2.5.0(transitive)
+ Added@parcel/watcher-win32-x64@2.5.0(transitive)
+ Added@types/minimatch@3.0.5(transitive)
+ Addedarray-differ@3.0.0(transitive)
+ Addedarray-union@2.1.0(transitive)
+ Addedarrify@2.0.1(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedchokidar@4.0.3(transitive)
+ Addeddetect-libc@1.0.3(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedimmutable@5.0.3(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedmultimatch@4.0.0(transitive)
+ Addednode-addon-api@7.1.1(transitive)
+ Addedreaddirp@4.0.2(transitive)
+ Addedsass@1.83.1(transitive)
+ Addedsource-map-js@1.2.1(transitive)
+ Addedto-regex-range@5.0.1(transitive)
- Removednode-sass-tilde-importer@^1.0.2
- Removedfind-parent-dir@0.3.1(transitive)
- Removednode-sass-tilde-importer@1.0.2(transitive)
Updatedlodash@^4.17.19