Comparing version 8.3.1 to 9.0.0
@@ -11,22 +11,18 @@ #!/usr/bin/env node | ||
program | ||
.arguments('<filename>') | ||
.version(version) | ||
.usage('[options] <filename>') | ||
.option('--es6-mixedImports') | ||
.option('-t, --type <type>', 'The type of content being passed in. Useful if you want to use a non-js detective') | ||
.parse(process.argv); | ||
.option('--es6-mixed-imports', 'Fetch all dependendies from a file that contains both CJS and ES6 imports') | ||
.option('-t, --type <type>', 'The type of content being passed in. Useful if you want to use a non-JS detective') | ||
.parse(); | ||
const content = fs.readFileSync(program.args[0], 'utf8'); | ||
const cliOptions = program.opts(); | ||
const options = { | ||
es6: {} | ||
es6: { | ||
mixedImports: Boolean(cliOptions.es6MixedImports) | ||
}, | ||
type: cliOptions.type | ||
}; | ||
if (program.es6MixedImports) { | ||
options.es6.mixedImports = true; | ||
} | ||
const content = fs.readFileSync(program.args[0], 'utf8'); | ||
if (program.type) { | ||
options.type = program.type; | ||
} | ||
console.log(precinct(content, options).join('\n')); |
23
index.js
@@ -5,4 +5,4 @@ 'use strict'; | ||
const path = require('path'); | ||
const { debuglog } = require('util'); | ||
const debug = require('debug')('precinct'); | ||
const getModuleType = require('module-definition'); | ||
@@ -21,2 +21,3 @@ const Walker = require('node-source-walk'); | ||
const debug = debuglog('precinct'); | ||
const natives = process.binding('natives'); | ||
@@ -33,2 +34,4 @@ | ||
function precinct(content, options = {}) { | ||
debug('options given: %o', options); | ||
let dependencies = []; | ||
@@ -38,10 +41,2 @@ let ast; | ||
// Legacy form backCompat where type was the second parameter | ||
if (typeof options === 'string') { | ||
type = options; | ||
options = {}; | ||
} | ||
debug('options given: %o', options); | ||
// We assume we're dealing with a JS file | ||
@@ -112,2 +107,4 @@ if (!type && typeof content !== 'object') { | ||
break; | ||
default: | ||
// nothing | ||
} | ||
@@ -143,6 +140,3 @@ | ||
precinct.paperwork = (filename, options = {}) => { | ||
options = { | ||
includeCore: true, | ||
...options | ||
}; | ||
options = { includeCore: true, ...options }; | ||
@@ -160,6 +154,5 @@ const fileSystem = options.fileSystem || fs; | ||
type = 'commonjs'; | ||
} | ||
// We need to sniff the JS module to find its type, not by extension | ||
// Other possible types pass through normally | ||
else if (ext !== '.js' && ext !== '.jsx') { | ||
} else if (ext !== '.js' && ext !== '.jsx') { | ||
debug('paperwork: stripping the dot from the extension to serve as the type'); | ||
@@ -166,0 +159,0 @@ type = ext.replace('.', ''); |
{ | ||
"name": "precinct", | ||
"version": "8.3.1", | ||
"version": "9.0.0", | ||
"description": "Unleash the detectives", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "jscs index.js test/index.js", | ||
"lint": "eslint index.js test/index.js", | ||
"mocha": "mocha test/index.js", | ||
"test": "npm run lint && npm run mocha" | ||
"test": "npm run lint && npm run mocha", | ||
"test:ci": "c8 npm run mocha" | ||
}, | ||
@@ -34,3 +35,3 @@ "bin": { | ||
"engines": { | ||
"node": "^10.13 || ^12 || >=14" | ||
"node": "^12.20.0 || ^14.14.0 || >=16.0.0" | ||
}, | ||
@@ -43,23 +44,22 @@ "files": [ | ||
"dependencies": { | ||
"commander": "^2.20.3", | ||
"debug": "^4.3.3", | ||
"detective-amd": "^3.1.0", | ||
"detective-cjs": "^3.1.1", | ||
"detective-es6": "^2.2.1", | ||
"commander": "^9.1.0", | ||
"detective-amd": "^4.0.1", | ||
"detective-cjs": "^4.0.0", | ||
"detective-es6": "^3.0.0", | ||
"detective-less": "^1.0.2", | ||
"detective-postcss": "^4.0.0", | ||
"detective-sass": "^3.0.1", | ||
"detective-scss": "^2.0.1", | ||
"detective-stylus": "^1.0.0", | ||
"detective-typescript": "^7.0.0", | ||
"module-definition": "^3.3.1", | ||
"node-source-walk": "^4.2.0" | ||
"detective-postcss": "^6.0.1", | ||
"detective-sass": "^4.0.1", | ||
"detective-scss": "^3.0.0", | ||
"detective-stylus": "^2.0.0", | ||
"detective-typescript": "^9.0.0", | ||
"module-definition": "^4.0.0", | ||
"node-source-walk": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"jscs": "^3.0.7", | ||
"jscs-preset-mrjoelkemp": "^2.0.0", | ||
"mocha": "^8.4.0", | ||
"rewire": "^5.0.0", | ||
"sinon": "^9.2.4" | ||
"c8": "^7.11.0", | ||
"eslint": "^8.11.0", | ||
"mocha": "^9.2.2", | ||
"rewire": "^6.0.0", | ||
"sinon": "^13.0.1" | ||
} | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
9765
12
92
168
1
+ Added@typescript-eslint/types@5.62.0(transitive)
+ Added@typescript-eslint/typescript-estree@5.62.0(transitive)
+ Added@typescript-eslint/visitor-keys@5.62.0(transitive)
+ Addedast-module-types@4.0.0(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommander@9.5.0(transitive)
+ Addeddetective-amd@4.2.0(transitive)
+ Addeddetective-cjs@4.1.0(transitive)
+ Addeddetective-es6@3.0.1(transitive)
+ Addeddetective-postcss@6.1.3(transitive)
+ Addeddetective-sass@4.1.3(transitive)
+ Addeddetective-scss@3.1.1(transitive)
+ Addeddetective-stylus@2.0.1(transitive)
+ Addeddetective-typescript@9.1.1(transitive)
+ Addedeslint-visitor-keys@3.4.3(transitive)
+ Addedget-amd-module-type@4.1.0(transitive)
+ Addedis-url-superb@4.0.0(transitive)
+ Addedmodule-definition@4.1.0(transitive)
+ Addednode-source-walk@5.0.2(transitive)
+ Addedpostcss-values-parser@6.0.2(transitive)
+ Addedquote-unquote@1.0.0(transitive)
+ Addedtypescript@4.9.5(transitive)
- Removeddebug@^4.3.3
- Removed@typescript-eslint/types@4.33.0(transitive)
- Removed@typescript-eslint/typescript-estree@4.33.0(transitive)
- Removed@typescript-eslint/visitor-keys@4.33.0(transitive)
- Removedast-module-types@2.7.13.0.0(transitive)
- Removedcommander@2.20.3(transitive)
- Removeddetective-amd@3.1.2(transitive)
- Removeddetective-cjs@3.1.3(transitive)
- Removeddetective-es6@2.2.2(transitive)
- Removeddetective-postcss@4.0.0(transitive)
- Removeddetective-sass@3.0.2(transitive)
- Removeddetective-scss@2.0.2(transitive)
- Removeddetective-stylus@1.0.3(transitive)
- Removeddetective-typescript@7.0.2(transitive)
- Removedeslint-visitor-keys@2.1.0(transitive)
- Removedflatten@1.0.3(transitive)
- Removedget-amd-module-type@3.0.2(transitive)
- Removedindexes-of@1.0.1(transitive)
- Removedmodule-definition@3.4.0(transitive)
- Removedpostcss-values-parser@2.0.1(transitive)
- Removedtypescript@3.9.10(transitive)
- Removeduniq@1.0.1(transitive)
Updatedcommander@^9.1.0
Updateddetective-amd@^4.0.1
Updateddetective-cjs@^4.0.0
Updateddetective-es6@^3.0.0
Updateddetective-postcss@^6.0.1
Updateddetective-sass@^4.0.1
Updateddetective-scss@^3.0.0
Updateddetective-stylus@^2.0.0
Updateddetective-typescript@^9.0.0
Updatedmodule-definition@^4.0.0
Updatednode-source-walk@^5.0.0