npq 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/npq.mov +0 -0
- package/.github/npq.mp4 +0 -0
- package/.github/npq.png +0 -0
- package/.github/workflows/main.yml +2 -2
- package/README.md +18 -9
- package/__tests__/__fixtures__/test.marshall.js +5 -6
- package/__tests__/cli.test.js +110 -0
- package/__tests__/cliPrompt.test.js +409 -0
- package/__tests__/marshalls.base.test.js +1 -1
- package/__tests__/marshalls.classMethods.test.js +11 -14
- package/__tests__/marshalls.expiredDomains.test.js +2 -2
- package/__tests__/marshalls.provenance.test.js +181 -4
- package/__tests__/marshalls.repo.test.js +6 -6
- package/__tests__/marshalls.signatures.test.js +0 -4
- package/__tests__/marshalls.snyk.test.js +294 -0
- package/__tests__/marshalls.tasks.test.js +48 -24
- package/__tests__/marshalls.typosquatting.test.js +16 -9
- package/__tests__/marshalls.version-maturity.test.js +6 -6
- package/__tests__/packageRepoUtils.test.js +4 -4
- package/__tests__/reportResults.test.js +772 -0
- package/__tests__/scripts.test.js +2 -2
- package/bin/npq-hero.js +70 -20
- package/bin/npq.js +113 -21
- package/lib/cli.js +127 -24
- package/lib/helpers/cliPrompt.js +97 -0
- package/lib/helpers/cliSpinner.js +104 -0
- package/lib/helpers/cliSupportHandler.js +50 -7
- package/lib/helpers/packageRepoUtils.js +7 -2
- package/lib/helpers/promiseThrottler.js +96 -0
- package/lib/helpers/reportResults.js +304 -0
- package/lib/helpers/sourcePackages.js +36 -0
- package/lib/marshall.js +42 -65
- package/lib/marshalls/age.marshall.js +4 -3
- package/lib/marshalls/author.marshall.js +38 -9
- package/lib/marshalls/baseMarshall.js +9 -17
- package/lib/marshalls/deprecation.marshall.js +43 -0
- package/lib/marshalls/downloads.marshall.js +3 -3
- package/lib/marshalls/expiredDomains.marshall.js +7 -5
- package/lib/marshalls/index.js +110 -80
- package/lib/marshalls/license.marshall.js +3 -3
- package/lib/marshalls/newbin.marshall.js +1 -2
- package/lib/marshalls/provenance.marshall.js +152 -33
- package/lib/marshalls/repo.marshall.js +8 -7
- package/lib/marshalls/scripts.marshall.js +1 -1
- package/lib/marshalls/signatures.marshall.js +26 -2
- package/lib/marshalls/snyk.marshall.js +61 -15
- package/lib/marshalls/typosquatting.marshall.js +8 -5
- package/lib/marshalls/version-maturity.marshall.js +4 -4
- package/lib/marshallsDecomissioned/readme.marshall.js +2 -2
- package/package.json +16 -19
- package/scripts/postinstall.js +10 -11
- package/lib/cliCommons.js +0 -80
package/scripts/postinstall.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
|
-
const
|
|
3
|
-
const inquirer = require('inquirer')
|
|
2
|
+
const { styleText } = require('node:util')
|
|
4
3
|
const semver = require('semver')
|
|
5
4
|
|
|
5
|
+
const cliPrompt = require('../lib/helpers/cliPrompt.js')
|
|
6
6
|
const helpers = require('./scriptHelpers')
|
|
7
7
|
|
|
8
8
|
const runPostInstall = async () => {
|
|
@@ -35,24 +35,23 @@ const runPostInstall = async () => {
|
|
|
35
35
|
console.log(
|
|
36
36
|
'To do that, we can alias npm and yarn to npq, so that e.g. `npm install <package>` will first use npq to verify the package and prompt you if it finds any issues.'
|
|
37
37
|
)
|
|
38
|
-
const answers = await
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
])
|
|
38
|
+
const answers = await cliPrompt.prompt({
|
|
39
|
+
name: 'install',
|
|
40
|
+
message: `Do you want to add ${shellConfig.name} aliases for npm and yarn?`,
|
|
41
|
+
default: true
|
|
42
|
+
})
|
|
43
|
+
|
|
45
44
|
if (answers.install) {
|
|
46
45
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
47
46
|
await fs.promises.appendFile(shellConfig.profilePath, shellConfig.aliases)
|
|
48
|
-
console.log(
|
|
47
|
+
console.log(styleText('green', '✔'), 'Reload your shell profile to use npq!')
|
|
49
48
|
}
|
|
50
49
|
} catch (err) {
|
|
51
50
|
if (err.isTtyError) {
|
|
52
51
|
// Could not render inquirer prompt; abort auto-install
|
|
53
52
|
return
|
|
54
53
|
}
|
|
55
|
-
console.error(
|
|
54
|
+
console.error(styleText('red', 'Failed to add aliases: '), err)
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
|
package/lib/cliCommons.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const npa = require('npm-package-arg')
|
|
2
|
-
class cliCommons {
|
|
3
|
-
static getInstallCommand() {
|
|
4
|
-
return {
|
|
5
|
-
command: 'install [package...]',
|
|
6
|
-
aliases: [
|
|
7
|
-
'i',
|
|
8
|
-
'add',
|
|
9
|
-
'isntall',
|
|
10
|
-
'in',
|
|
11
|
-
'ins',
|
|
12
|
-
'inst',
|
|
13
|
-
'insta',
|
|
14
|
-
'instal',
|
|
15
|
-
'isnt',
|
|
16
|
-
'isnta',
|
|
17
|
-
'isntal'
|
|
18
|
-
],
|
|
19
|
-
desc: 'install a package',
|
|
20
|
-
handler: (argv) => {
|
|
21
|
-
if (argv && argv.package) {
|
|
22
|
-
for (let i = 0; i < argv.package.length; i++) {
|
|
23
|
-
const parsedPackage = npa(argv.package[i])
|
|
24
|
-
const versionModifier =
|
|
25
|
-
parsedPackage.fetchSpec === '*' ? 'latest' : parsedPackage.fetchSpec
|
|
26
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
27
|
-
argv.package[i] = `${parsedPackage.name}@${versionModifier}`
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static getOptions() {
|
|
35
|
-
return {
|
|
36
|
-
S: {
|
|
37
|
-
alias: ['save', 'save-prod', 'save-optional', 'save-bundle'],
|
|
38
|
-
type: 'boolean'
|
|
39
|
-
},
|
|
40
|
-
g: {
|
|
41
|
-
alias: 'global',
|
|
42
|
-
type: 'boolean'
|
|
43
|
-
},
|
|
44
|
-
P: {
|
|
45
|
-
alias: ['save-prod', 'peer'],
|
|
46
|
-
type: 'boolean'
|
|
47
|
-
},
|
|
48
|
-
D: {
|
|
49
|
-
alias: ['save-dev', 'dev'],
|
|
50
|
-
type: 'boolean'
|
|
51
|
-
},
|
|
52
|
-
O: {
|
|
53
|
-
alias: ['save-optional', 'optional'],
|
|
54
|
-
type: 'boolean'
|
|
55
|
-
},
|
|
56
|
-
E: {
|
|
57
|
-
alias: ['save-exact', 'exact'],
|
|
58
|
-
type: 'boolean'
|
|
59
|
-
},
|
|
60
|
-
B: {
|
|
61
|
-
alias: 'save-bundle',
|
|
62
|
-
type: 'boolean'
|
|
63
|
-
},
|
|
64
|
-
T: {
|
|
65
|
-
alias: 'tilde',
|
|
66
|
-
type: 'boolean'
|
|
67
|
-
},
|
|
68
|
-
nosave: {
|
|
69
|
-
alias: 'no-save',
|
|
70
|
-
type: 'boolean'
|
|
71
|
-
},
|
|
72
|
-
'dry-run': {
|
|
73
|
-
alias: 'dry-run',
|
|
74
|
-
type: 'boolean'
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
module.exports = cliCommons
|