npq 3.11.1 → 3.11.3
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/bin/npq-hero.js +5 -3
- package/bin/npq.js +5 -3
- package/lib/helpers/cliSpinner.js +2 -0
- package/lib/helpers/cliSupportHandler.js +0 -3
- package/lib/helpers/packageRepoUtils.js +1 -1
- package/lib/helpers/promiseThrottler.js +2 -0
- package/lib/helpers/reportResults.js +4 -1
- package/lib/helpers/sourcePackages.js +2 -0
- package/lib/marshall.js +0 -1
- package/lib/marshalls/age.marshall.js +0 -2
- package/lib/marshalls/author.marshall.js +1 -1
- package/lib/marshalls/constants.js +2 -0
- package/lib/marshalls/index.js +0 -1
- package/lib/marshalls/newbin.marshall.js +3 -1
- package/lib/marshalls/provenance.marshall.js +0 -1
- package/lib/marshalls/repo.marshall.js +1 -1
- package/lib/marshalls/scripts.marshall.js +1 -1
- package/lib/marshalls/signatures.marshall.js +0 -1
- package/lib/marshalls/snyk.marshall.js +1 -1
- package/lib/marshalls/typosquatting.marshall.js +0 -2
- package/lib/packageManager.js +0 -1
- package/package.json +19 -124
- package/scripts/build.js +2 -0
- package/scripts/postinstall.js +2 -0
- package/scripts/preuninstall.js +2 -0
- package/scripts/scriptHelpers.js +2 -0
package/bin/npq-hero.js
CHANGED
|
@@ -71,7 +71,6 @@ marshall
|
|
|
71
71
|
})
|
|
72
72
|
.then((result) => {
|
|
73
73
|
if (result && result.countErrors > 0) {
|
|
74
|
-
// eslint-disable-next-line no-console
|
|
75
74
|
console.log()
|
|
76
75
|
return cliPrompt.prompt({
|
|
77
76
|
name: 'install',
|
|
@@ -80,7 +79,6 @@ marshall
|
|
|
80
79
|
})
|
|
81
80
|
} else {
|
|
82
81
|
if (result && result.countWarnings > 0) {
|
|
83
|
-
// eslint-disable-next-line no-console
|
|
84
82
|
console.log()
|
|
85
83
|
return cliPrompt.autoContinue({
|
|
86
84
|
name: 'install',
|
|
@@ -93,7 +91,11 @@ marshall
|
|
|
93
91
|
return { install: true }
|
|
94
92
|
})
|
|
95
93
|
.then((status) => {
|
|
96
|
-
if (
|
|
94
|
+
if (
|
|
95
|
+
status &&
|
|
96
|
+
Object.prototype.hasOwnProperty.call(status, 'install') &&
|
|
97
|
+
status.install === true
|
|
98
|
+
) {
|
|
97
99
|
pkgMgr.process(PACKAGE_MANAGER_TOOL)
|
|
98
100
|
}
|
|
99
101
|
})
|
package/bin/npq.js
CHANGED
|
@@ -97,7 +97,6 @@ Promise.resolve()
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
if (result && result.countErrors > 0) {
|
|
100
|
-
// eslint-disable-next-line no-console
|
|
101
100
|
console.log()
|
|
102
101
|
return cliPrompt.prompt({
|
|
103
102
|
name: 'install',
|
|
@@ -106,7 +105,6 @@ Promise.resolve()
|
|
|
106
105
|
})
|
|
107
106
|
} else {
|
|
108
107
|
if (result && result.countWarnings > 0) {
|
|
109
|
-
// eslint-disable-next-line no-console
|
|
110
108
|
console.log()
|
|
111
109
|
return cliPrompt.autoContinue({
|
|
112
110
|
name: 'install',
|
|
@@ -119,7 +117,11 @@ Promise.resolve()
|
|
|
119
117
|
return { install: true }
|
|
120
118
|
})
|
|
121
119
|
.then((status) => {
|
|
122
|
-
if (
|
|
120
|
+
if (
|
|
121
|
+
status &&
|
|
122
|
+
Object.prototype.hasOwnProperty.call(status, 'install') &&
|
|
123
|
+
status.install === true
|
|
124
|
+
) {
|
|
123
125
|
pkgMgr.process(cliArgs.packageManager)
|
|
124
126
|
}
|
|
125
127
|
})
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const { styleText } = require('node:util')
|
|
4
4
|
|
|
5
|
-
// eslint-disable-next-line security/detect-child-process
|
|
6
5
|
const childProcess = require('child_process')
|
|
7
6
|
const semver = require('semver')
|
|
8
7
|
|
|
@@ -20,10 +19,8 @@ function isEnvSupport() {
|
|
|
20
19
|
|
|
21
20
|
function noSupportError(failFast) {
|
|
22
21
|
if (isInteractiveTerminal()) {
|
|
23
|
-
// eslint-disable-next-line no-console
|
|
24
22
|
console.error(styleText('red', 'error:'), 'npq suppressed due to old node version')
|
|
25
23
|
} else {
|
|
26
|
-
// eslint-disable-next-line no-console
|
|
27
24
|
console.error('error: npq suppressed due to old node version')
|
|
28
25
|
}
|
|
29
26
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
1
3
|
const { styleText } = require('node:util')
|
|
2
4
|
const { marshallCategories } = require('../marshalls/constants')
|
|
3
5
|
const { isInteractiveTerminal } = require('./cliSupportHandler')
|
|
@@ -12,7 +14,7 @@ function getTerminalWidth() {
|
|
|
12
14
|
const [columns] = process.stdout.getWindowSize()
|
|
13
15
|
return columns
|
|
14
16
|
}
|
|
15
|
-
} catch
|
|
17
|
+
} catch {
|
|
16
18
|
// Fallback if terminal size detection fails
|
|
17
19
|
}
|
|
18
20
|
return 80 // Default fallback width
|
|
@@ -25,6 +27,7 @@ function getTerminalWidth() {
|
|
|
25
27
|
*/
|
|
26
28
|
function getDisplayLength(str) {
|
|
27
29
|
// Remove ANSI escape sequences to get actual character count
|
|
30
|
+
// eslint-disable-next-line no-control-regex
|
|
28
31
|
return str.replace(/\u001b\[[0-9;]*m/g, '').length
|
|
29
32
|
}
|
|
30
33
|
|
package/lib/marshall.js
CHANGED
|
@@ -21,7 +21,6 @@ class Marshall extends BaseMarshall {
|
|
|
21
21
|
|
|
22
22
|
validate(pkg) {
|
|
23
23
|
let packageData = null
|
|
24
|
-
let ageDateDiff = null
|
|
25
24
|
return this.packageRepoUtils
|
|
26
25
|
.getPackageInfo(pkg.packageName)
|
|
27
26
|
.then((data) => {
|
|
@@ -30,7 +29,6 @@ class Marshall extends BaseMarshall {
|
|
|
30
29
|
const pkgCreatedDate = data.time.created
|
|
31
30
|
const dateDiff = Date.now() - Date.parse(pkgCreatedDate)
|
|
32
31
|
|
|
33
|
-
ageDateDiff = dateDiff
|
|
34
32
|
if (dateDiff < PACKAGE_AGE_THRESHOLD) {
|
|
35
33
|
throw new Error(
|
|
36
34
|
`Detected a newly published package (created < ${PACKAGE_AGE_THRESHOLD} days) act carefully`
|
|
@@ -48,7 +48,7 @@ class Marshall extends BaseMarshall {
|
|
|
48
48
|
|
|
49
49
|
// Agree with Colin on keeping email regex simple: https://colinhacks.com/essays/reasonable-email-regex
|
|
50
50
|
const emailRegex =
|
|
51
|
-
/^(?!\.)(?!.*\.\.)([a-z0-9_'
|
|
51
|
+
/^(?!\.)(?!.*\.\.)([a-z0-9_'+\-.]*)[a-z0-9_'+-]@([a-z0-9][a-z0-9-]*\.)+[a-z]{2,}$/i
|
|
52
52
|
if (!emailRegex.test(npmUser.email)) {
|
|
53
53
|
throw new Error('The publishing user has no valid email address')
|
|
54
54
|
}
|
package/lib/marshalls/index.js
CHANGED
|
@@ -55,7 +55,9 @@ class NewBinMarshall extends BaseMarshall {
|
|
|
55
55
|
previousVersionData.name || pkg.packageName
|
|
56
56
|
)
|
|
57
57
|
|
|
58
|
-
const newBinaries = Object.keys(newBin).filter(
|
|
58
|
+
const newBinaries = Object.keys(newBin).filter(
|
|
59
|
+
(key) => !Object.prototype.hasOwnProperty.call(oldBin, key)
|
|
60
|
+
)
|
|
59
61
|
|
|
60
62
|
if (newBinaries.length > 0) {
|
|
61
63
|
newBinaries.forEach((binaryName) => {
|
|
@@ -188,7 +188,6 @@ class Marshall extends BaseMarshall {
|
|
|
188
188
|
const registryKeysEndpoint = '/-/npm/v1/keys'
|
|
189
189
|
|
|
190
190
|
const registryKeysUrl = `${registryHost}${registryKeysEndpoint}`
|
|
191
|
-
// eslint-disable-next-line no-undef
|
|
192
191
|
return fetch(registryKeysUrl)
|
|
193
192
|
.then((response) => {
|
|
194
193
|
return response.json()
|
|
@@ -30,7 +30,7 @@ class Marshall extends BaseMarshall {
|
|
|
30
30
|
try {
|
|
31
31
|
urlStructure = new URL(lastVersionData.repository.url)
|
|
32
32
|
urlOfGitRepository = new URL(`https://${urlStructure.host}${urlStructure.pathname}`)
|
|
33
|
-
} catch
|
|
33
|
+
} catch {
|
|
34
34
|
throw new Warning('No valid repository is associated with the package')
|
|
35
35
|
}
|
|
36
36
|
return fetch(urlOfGitRepository.href).catch(() => {
|
|
@@ -39,7 +39,7 @@ class Marshall extends BaseMarshall {
|
|
|
39
39
|
blacklistScripts.forEach((scriptName) => {
|
|
40
40
|
if (
|
|
41
41
|
packageScripts &&
|
|
42
|
-
|
|
42
|
+
Object.prototype.hasOwnProperty.call(packageScripts, scriptName) &&
|
|
43
43
|
packageScripts[scriptName].length > 0
|
|
44
44
|
) {
|
|
45
45
|
throw new Error(
|
|
@@ -63,7 +63,6 @@ class Marshall extends BaseMarshall {
|
|
|
63
63
|
const registryKeysEndpoint = '/-/npm/v1/keys'
|
|
64
64
|
|
|
65
65
|
const registryKeysUrl = `${registryHost}${registryKeysEndpoint}`
|
|
66
|
-
// eslint-disable-next-line no-undef
|
|
67
66
|
return fetch(registryKeysUrl)
|
|
68
67
|
.then((response) => {
|
|
69
68
|
return response.json()
|
|
@@ -23,7 +23,6 @@ class Marshall extends BaseMarshall {
|
|
|
23
23
|
validate(pkg) {
|
|
24
24
|
let levenshteinDistance = null
|
|
25
25
|
let similarPackages = []
|
|
26
|
-
let packageFoundInTopPackages = false
|
|
27
26
|
return new Promise((resolve, reject) => {
|
|
28
27
|
// If package is within an allow-list
|
|
29
28
|
if (this.packageRepoUtils.isPackageInAllowList(pkg.packageName)) {
|
|
@@ -34,7 +33,6 @@ class Marshall extends BaseMarshall {
|
|
|
34
33
|
// If the package to be installed is itself found within the Top Packages dataset
|
|
35
34
|
// then we don't report on it
|
|
36
35
|
if (pkg.packageName === popularPackageNameInRepository) {
|
|
37
|
-
packageFoundInTopPackages = true
|
|
38
36
|
return resolve([])
|
|
39
37
|
}
|
|
40
38
|
|
package/lib/packageManager.js
CHANGED
package/package.json
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npq",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.3",
|
|
4
4
|
"description": "marshall your npm/npm package installs with high quality and class 🎖",
|
|
5
5
|
"bin": {
|
|
6
6
|
"npq": "./bin/npq.js",
|
|
7
7
|
"npq-hero": "./bin/npq-hero.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"lint": "eslint
|
|
10
|
+
"lint": "eslint && npm run lint:lockfile",
|
|
11
11
|
"lint:lockfile": "lockfile-lint --path package-lock.json --type npm --validate-https --allowed-hosts npm npm",
|
|
12
|
-
"
|
|
12
|
+
"fix": "eslint --fix",
|
|
13
|
+
"test": "jest",
|
|
13
14
|
"build": "node scripts/build.js",
|
|
14
|
-
"test:watch": "
|
|
15
|
-
"coverage:view": "opn coverage/lcov-report/index.html",
|
|
15
|
+
"test:watch": "jest --watch",
|
|
16
16
|
"commit": "git-cz",
|
|
17
17
|
"format": "prettier --config .prettierrc.js --write \"**/*.js\"",
|
|
18
|
-
"docs": "npm run docs:code && npm run docs:api",
|
|
19
|
-
"docs:api": "doxdox \"*.js\" --layout bootstrap --output docs/index.html",
|
|
20
|
-
"docs:code": "docco \"*.js\" --output docs/code",
|
|
21
18
|
"semantic-release": "npx semantic-release",
|
|
22
19
|
"#postinstall": "node scripts/postinstall.js",
|
|
23
20
|
"#preuninstall": "node scripts/preuninstall.js",
|
|
24
|
-
"prepare": "husky
|
|
21
|
+
"prepare": "husky || true"
|
|
25
22
|
},
|
|
26
23
|
"engines": {
|
|
27
24
|
"node": ">=20.13.0"
|
|
@@ -47,65 +44,26 @@
|
|
|
47
44
|
},
|
|
48
45
|
"dependencies": {
|
|
49
46
|
"fastest-levenshtein": "^1.0.16",
|
|
50
|
-
"npm-package-arg": "^
|
|
51
|
-
"pacote": "^
|
|
47
|
+
"npm-package-arg": "^13.0.0",
|
|
48
|
+
"pacote": "^21.0.0",
|
|
52
49
|
"semver": "^7.7.2"
|
|
53
50
|
},
|
|
54
51
|
"devDependencies": {
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"@babel/runtime": "^7.28.2",
|
|
59
|
-
"@babel/types": "^7.28.2",
|
|
60
|
-
"@commitlint/cli": "^17.8.1",
|
|
61
|
-
"@commitlint/config-angular": "^17.8.1",
|
|
52
|
+
"@commitlint/cli": "^19.8.1",
|
|
53
|
+
"@commitlint/config-angular": "^19.8.1",
|
|
54
|
+
"@eslint/js": "^9.32.0",
|
|
62
55
|
"commitizen": "^4.3.1",
|
|
63
|
-
"cross-env": "^10.0.0",
|
|
64
56
|
"cz-conventional-changelog": "^3.3.0",
|
|
65
|
-
"eslint": "^
|
|
66
|
-
"eslint-plugin-
|
|
67
|
-
"eslint-plugin-
|
|
68
|
-
"
|
|
69
|
-
"husky": "^
|
|
70
|
-
"jest": "^
|
|
71
|
-
"lint-staged": "^
|
|
57
|
+
"eslint": "^9.32.0",
|
|
58
|
+
"eslint-plugin-n": "^17.21.3",
|
|
59
|
+
"eslint-plugin-security": "^3.0.1",
|
|
60
|
+
"globals": "^16.3.0",
|
|
61
|
+
"husky": "^9.1.7",
|
|
62
|
+
"jest": "^30.0.5",
|
|
63
|
+
"lint-staged": "^16.1.4",
|
|
72
64
|
"lockfile-lint": "^4.14.1",
|
|
73
65
|
"prettier": "^3.6.2"
|
|
74
66
|
},
|
|
75
|
-
"jest": {
|
|
76
|
-
"testEnvironment": "node",
|
|
77
|
-
"verbose": true,
|
|
78
|
-
"notify": false,
|
|
79
|
-
"collectCoverage": true,
|
|
80
|
-
"coverageThreshold": {
|
|
81
|
-
"global": {
|
|
82
|
-
"branches": 75,
|
|
83
|
-
"functions": 75,
|
|
84
|
-
"lines": 75,
|
|
85
|
-
"statements": 75
|
|
86
|
-
},
|
|
87
|
-
"scripts/*": {
|
|
88
|
-
"branches": 60,
|
|
89
|
-
"functions": 90,
|
|
90
|
-
"lines": 80,
|
|
91
|
-
"statements": 80
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
"testMatch": [
|
|
95
|
-
"**/__tests__/**/*.test.js"
|
|
96
|
-
],
|
|
97
|
-
"testPathIgnorePatterns": [
|
|
98
|
-
"/__tests__/__fixtures__/*"
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
|
-
"babel": {
|
|
102
|
-
"presets": [
|
|
103
|
-
"@babel/env"
|
|
104
|
-
],
|
|
105
|
-
"plugins": [
|
|
106
|
-
"@babel/plugin-transform-runtime"
|
|
107
|
-
]
|
|
108
|
-
},
|
|
109
67
|
"config": {
|
|
110
68
|
"commitizen": {
|
|
111
69
|
"path": "./node_modules/cz-conventional-changelog"
|
|
@@ -119,72 +77,9 @@
|
|
|
119
77
|
"lint-staged": {
|
|
120
78
|
"**/*.js": [
|
|
121
79
|
"npm run format",
|
|
122
|
-
"npm run lint"
|
|
123
|
-
"git add"
|
|
80
|
+
"npm run lint"
|
|
124
81
|
]
|
|
125
82
|
},
|
|
126
|
-
"eslintConfig": {
|
|
127
|
-
"env": {
|
|
128
|
-
"node": true,
|
|
129
|
-
"es6": true,
|
|
130
|
-
"jest": true
|
|
131
|
-
},
|
|
132
|
-
"plugins": [
|
|
133
|
-
"node",
|
|
134
|
-
"security"
|
|
135
|
-
],
|
|
136
|
-
"extends": [
|
|
137
|
-
"plugin:node/recommended",
|
|
138
|
-
"plugin:security/recommended"
|
|
139
|
-
],
|
|
140
|
-
"rules": {
|
|
141
|
-
"semi": "off",
|
|
142
|
-
"no-process-exit": "off",
|
|
143
|
-
"node/no-unsupported-features": "off",
|
|
144
|
-
"node/no-unpublished-require": "off",
|
|
145
|
-
"security/detect-non-literal-fs-filename": "warn",
|
|
146
|
-
"security/detect-unsafe-regex": "warn",
|
|
147
|
-
"security/detect-buffer-noassert": "error",
|
|
148
|
-
"security/detect-child-process": "warn",
|
|
149
|
-
"security/detect-disable-mustache-escape": "error",
|
|
150
|
-
"security/detect-eval-with-expression": "error",
|
|
151
|
-
"security/detect-no-csrf-before-method-override": "error",
|
|
152
|
-
"security/detect-non-literal-regexp": "error",
|
|
153
|
-
"security/detect-non-literal-require": "warn",
|
|
154
|
-
"security/detect-object-injection": "off",
|
|
155
|
-
"security/detect-possible-timing-attacks": "error",
|
|
156
|
-
"security/detect-pseudoRandomBytes": "error",
|
|
157
|
-
"node/no-unsupported-features/node-builtins": [
|
|
158
|
-
"error",
|
|
159
|
-
{
|
|
160
|
-
"version": ">=18.17.0",
|
|
161
|
-
"ignores": []
|
|
162
|
-
}
|
|
163
|
-
],
|
|
164
|
-
"node/no-unsupported-features/es-syntax": [
|
|
165
|
-
"error",
|
|
166
|
-
{
|
|
167
|
-
"version": ">=18.17.0",
|
|
168
|
-
"ignores": []
|
|
169
|
-
}
|
|
170
|
-
]
|
|
171
|
-
},
|
|
172
|
-
"overrides": [
|
|
173
|
-
{
|
|
174
|
-
"files": [
|
|
175
|
-
"__tests__/*"
|
|
176
|
-
],
|
|
177
|
-
"rules": {
|
|
178
|
-
"node/no-unsupported-features/es-syntax": "off"
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
],
|
|
182
|
-
"parserOptions": {
|
|
183
|
-
"ecmaFeatures": {
|
|
184
|
-
"impliedStrict": true
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
83
|
"release": {
|
|
189
84
|
"branches": [
|
|
190
85
|
"main"
|
package/scripts/build.js
CHANGED
package/scripts/postinstall.js
CHANGED
package/scripts/preuninstall.js
CHANGED