Skip to content

Commit c608512

Browse files
authored
fix: ignore integrity values for git dependencies (#4468)
This updates [email protected] and @npmcli/[email protected]
1 parent 6b68c1a commit c608512

File tree

16 files changed

+115
-84
lines changed

16 files changed

+115
-84
lines changed

node_modules/@npmcli/run-script/lib/make-spawn-args.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint camelcase: "off" */
22
const isWindows = require('./is-windows.js')
33
const setPATH = require('./set-path.js')
4-
const {resolve} = require('path')
4+
const { resolve } = require('path')
55
const npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js')
66

77
const makeSpawnArgs = options => {

node_modules/@npmcli/run-script/lib/package-envs.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ const envVal = val => Array.isArray(val) ? val.map(v => envVal(v)).join('\n\n')
66

77
const packageEnvs = (env, vals, prefix) => {
88
for (const [key, val] of Object.entries(vals)) {
9-
if (val === undefined)
9+
if (val === undefined) {
1010
continue
11-
else if (val && !Array.isArray(val) && typeof val === 'object')
11+
} else if (val && !Array.isArray(val) && typeof val === 'object') {
1212
packageEnvs(env, val, `${prefix}${key}_`)
13-
else
13+
} else {
1414
env[`${prefix}${key}`] = envVal(val)
15+
}
1516
}
1617
return env
1718
}

node_modules/@npmcli/run-script/lib/run-script-pkg.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,28 @@ const runScriptPkg = async options => {
2626
signalTimeout = 500,
2727
} = options
2828

29-
const {scripts = {}, gypfile} = pkg
29+
const { scripts = {}, gypfile } = pkg
3030
let cmd = null
31-
if (options.cmd)
31+
if (options.cmd) {
3232
cmd = options.cmd
33-
else if (pkg.scripts && pkg.scripts[event])
33+
} else if (pkg.scripts && pkg.scripts[event]) {
3434
cmd = pkg.scripts[event] + args.map(a => ` ${JSON.stringify(a)}`).join('')
35-
else if ( // If there is no preinstall or install script, default to rebuilding node-gyp packages.
35+
} else if (
36+
// If there is no preinstall or install script, default to rebuilding node-gyp packages.
3637
event === 'install' &&
3738
!scripts.install &&
3839
!scripts.preinstall &&
3940
gypfile !== false &&
4041
await isNodeGypPackage(path)
41-
)
42+
) {
4243
cmd = defaultGypInstallScript
43-
else if (event === 'start' && await isServerPackage(path))
44+
} else if (event === 'start' && await isServerPackage(path)) {
4445
cmd = 'node server.js' + args.map(a => ` ${JSON.stringify(a)}`).join('')
46+
}
4547

46-
if (!cmd)
48+
if (!cmd) {
4749
return { code: 0, signal: null }
50+
}
4851

4952
if (stdio === 'inherit' && banner !== false) {
5053
// we're dumping to the parent's stdout, so print the banner
@@ -66,11 +69,13 @@ const runScriptPkg = async options => {
6669
path,
6770
})
6871

69-
if (stdio === 'inherit')
72+
if (stdio === 'inherit') {
7073
signalManager.add(p.process)
74+
}
7175

72-
if (p.stdin)
76+
if (p.stdin) {
7377
p.stdin.end()
78+
}
7479

7580
return p.catch(er => {
7681
const { signal } = er
@@ -80,8 +85,9 @@ const runScriptPkg = async options => {
8085
// this also keeps the node process open long enough to actually
8186
// get the signal, rather than terminating gracefully.
8287
return new Promise((res, rej) => setTimeout(() => rej(er), signalTimeout))
83-
} else
88+
} else {
8489
throw er
90+
}
8591
})
8692
}
8793

node_modules/@npmcli/run-script/lib/run-script.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const isServerPackage = require('./is-server-package.js')
55

66
const runScript = options => {
77
validateOptions(options)
8-
const {pkg, path} = options
8+
const { pkg, path } = options
99
return pkg ? runScriptPkg(options)
10-
: rpj(path + '/package.json').then(pkg => runScriptPkg({...options, pkg}))
10+
: rpj(path + '/package.json').then(pkg => runScriptPkg({ ...options, pkg }))
1111
}
1212

1313
module.exports = Object.assign(runScript, { isServerPackage })

node_modules/@npmcli/run-script/lib/set-path.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {resolve, dirname} = require('path')
1+
const { resolve, dirname } = require('path')
22
const isWindows = require('./is-windows.js')
33
// the path here is relative, even though it does not need to be
44
// in order to make the posix tests pass in windows
@@ -34,8 +34,9 @@ const setPATH = (projectPath, env) => {
3434
// npm or arborist or whoever to just provide that by putting it in
3535
// the PATH environ, since that's preserved anyway.
3636
for (const key of Object.keys(env)) {
37-
if (/^path$/i.test(key))
37+
if (/^path$/i.test(key)) {
3838
env[key] = pathVal
39+
}
3940
}
4041

4142
return env

node_modules/@npmcli/run-script/lib/signal-manager.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let handlersInstalled = false
33

44
const forwardedSignals = [
55
'SIGINT',
6-
'SIGTERM'
6+
'SIGTERM',
77
]
88

99
const handleSignal = signal => {
@@ -30,8 +30,9 @@ const cleanupListeners = () => {
3030

3131
const add = proc => {
3232
runningProcs.add(proc)
33-
if (!handlersInstalled)
33+
if (!handlersInstalled) {
3434
setupListeners()
35+
}
3536

3637
proc.once('exit', () => {
3738
runningProcs.delete(proc)
@@ -42,5 +43,5 @@ const add = proc => {
4243
module.exports = {
4344
add,
4445
handleSignal,
45-
forwardedSignals
46+
forwardedSignals,
4647
}
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const validateOptions = options => {
2-
if (typeof options !== 'object' || !options)
2+
if (typeof options !== 'object' || !options) {
33
throw new TypeError('invalid options object provided to runScript')
4+
}
45

56
const {
67
event,
@@ -12,20 +13,27 @@ const validateOptions = options => {
1213
cmd,
1314
} = options
1415

15-
if (!event || typeof event !== 'string')
16+
if (!event || typeof event !== 'string') {
1617
throw new TypeError('valid event not provided to runScript')
17-
if (!path || typeof path !== 'string')
18+
}
19+
if (!path || typeof path !== 'string') {
1820
throw new TypeError('valid path not provided to runScript')
19-
if (scriptShell !== undefined && typeof scriptShell !== 'string')
21+
}
22+
if (scriptShell !== undefined && typeof scriptShell !== 'string') {
2023
throw new TypeError('invalid scriptShell option provided to runScript')
21-
if (typeof env !== 'object' || !env)
24+
}
25+
if (typeof env !== 'object' || !env) {
2226
throw new TypeError('invalid env option provided to runScript')
23-
if (typeof stdio !== 'string' && !Array.isArray(stdio))
27+
}
28+
if (typeof stdio !== 'string' && !Array.isArray(stdio)) {
2429
throw new TypeError('invalid stdio option provided to runScript')
25-
if (!Array.isArray(args) || args.some(a => typeof a !== 'string'))
30+
}
31+
if (!Array.isArray(args) || args.some(a => typeof a !== 'string')) {
2632
throw new TypeError('invalid args option provided to runScript')
27-
if (cmd !== undefined && typeof cmd !== 'string')
33+
}
34+
if (cmd !== undefined && typeof cmd !== 'string') {
2835
throw new TypeError('invalid cmd option provided to runScript')
36+
}
2937
}
3038

3139
module.exports = validateOptions
Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,51 @@
11
{
22
"name": "@npmcli/run-script",
3-
"version": "2.0.0",
3+
"version": "3.0.0",
44
"description": "Run a lifecycle script for a package (descendant of npm-lifecycle)",
5-
"author": "Isaac Z. Schlueter <[email protected]> (https://izs.me)",
5+
"author": "GitHub Inc.",
66
"license": "ISC",
77
"scripts": {
88
"test": "tap",
99
"preversion": "npm test",
1010
"postversion": "npm publish",
1111
"prepublishOnly": "git push origin --follow-tags",
1212
"eslint": "eslint",
13-
"lint": "npm run eslint -- \"lib/**/*.js\"",
14-
"lintfix": "npm run lint -- --fix"
13+
"lint": "eslint '**/*.js'",
14+
"lintfix": "npm run lint -- --fix",
15+
"postlint": "npm-template-check",
16+
"template-copy": "npm-template-copy --force",
17+
"snap": "tap",
18+
"posttest": "npm run lint"
1519
},
1620
"tap": {
1721
"check-coverage": true,
1822
"coverage-map": "map.js"
1923
},
2024
"devDependencies": {
21-
"eslint": "^7.19.0",
22-
"eslint-plugin-import": "^2.22.1",
23-
"eslint-plugin-node": "^11.1.0",
24-
"eslint-plugin-promise": "^4.2.1",
25-
"eslint-plugin-standard": "^5.0.0",
26-
"minipass": "^3.1.1",
25+
"@npmcli/template-oss": "^2.7.1",
26+
"minipass": "^3.1.6",
2727
"require-inject": "^1.4.4",
2828
"tap": "^15.0.4"
2929
},
3030
"dependencies": {
31-
"@npmcli/node-gyp": "^1.0.2",
31+
"@npmcli/node-gyp": "^1.0.3",
3232
"@npmcli/promise-spawn": "^1.3.2",
33-
"node-gyp": "^8.2.0",
34-
"read-package-json-fast": "^2.0.1"
33+
"node-gyp": "^8.4.1",
34+
"read-package-json-fast": "^2.0.3"
3535
},
3636
"files": [
37-
"lib/**/*.js",
38-
"lib/node-gyp-bin"
37+
"bin",
38+
"lib"
3939
],
4040
"main": "lib/run-script.js",
4141
"repository": {
4242
"type": "git",
4343
"url": "git+https://github.com/npm/run-script.git"
44+
},
45+
"engines": {
46+
"node": "^12.13.0 || ^14.15.0 || >=16"
47+
},
48+
"templateOSS": {
49+
"version": "2.7.1"
4450
}
4551
}

node_modules/pacote/lib/git.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ const addGitPlus = url => url && `git+${url}`.replace(/^(git\+)+/, 'git+')
3838
class GitFetcher extends Fetcher {
3939
constructor (spec, opts) {
4040
super(spec, opts)
41+
42+
// we never want to compare integrity for git dependencies: npm/rfcs#525
43+
if (this.opts.integrity) {
44+
delete this.opts.integrity
45+
log.warn(`skipping integrity check for git dependency ${this.spec.fetchSpec}`)
46+
}
47+
4148
this.resolvedRef = null
4249
if (this.spec.hosted) {
4350
this.from = this.spec.hosted.shortcut({ noCommittish: false })
@@ -194,7 +201,6 @@ class GitFetcher extends Fetcher {
194201
[_tarballFromResolved] () {
195202
const stream = new Minipass()
196203
stream.resolved = this.resolved
197-
stream.integrity = this.integrity
198204
stream.from = this.from
199205

200206
// check it out and then shell out to the DirFetcher tarball packer
@@ -304,7 +310,6 @@ class GitFetcher extends Fetcher {
304310
this[_readPackageJson](dir + '/package.json')
305311
.then(mani => this.package = {
306312
...mani,
307-
_integrity: this.integrity && String(this.integrity),
308313
_resolved: this.resolved,
309314
_from: this.from,
310315
}))

node_modules/pacote/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pacote",
3-
"version": "13.0.2",
3+
"version": "13.0.3",
44
"description": "JavaScript package downloader",
55
"author": "GitHub Inc.",
66
"bin": {
@@ -43,7 +43,7 @@
4343
"@npmcli/git": "^3.0.0",
4444
"@npmcli/installed-package-contents": "^1.0.7",
4545
"@npmcli/promise-spawn": "^1.2.0",
46-
"@npmcli/run-script": "^2.0.0",
46+
"@npmcli/run-script": "^3.0.0",
4747
"cacache": "^15.3.0",
4848
"chownr": "^2.0.0",
4949
"fs-minipass": "^2.1.0",

0 commit comments

Comments
 (0)