From 0f23c3378c991b2a482463ce7f700829a3752940 Mon Sep 17 00:00:00 2001 From: Gar Date: Tue, 5 Apr 2022 13:00:27 -0700 Subject: [PATCH] deps: @npmcli/run-script@3.0.2 --- .../@npmcli/run-script/lib/run-script.js | 3 +- .../@npmcli/run-script/lib/set-path.js | 2 +- .../@npmcli/node-gyp/lib/index.js | 14 ++++ .../@npmcli/node-gyp/package.json | 45 +++++++++++ .../@npmcli/promise-spawn/LICENSE | 15 ++++ .../@npmcli/promise-spawn/lib/index.js | 75 +++++++++++++++++++ .../@npmcli/promise-spawn/package.json | 48 ++++++++++++ node_modules/@npmcli/run-script/package.json | 30 ++++---- package-lock.json | 56 +++++++++++--- 9 files changed, 263 insertions(+), 25 deletions(-) create mode 100644 node_modules/@npmcli/run-script/node_modules/@npmcli/node-gyp/lib/index.js create mode 100644 node_modules/@npmcli/run-script/node_modules/@npmcli/node-gyp/package.json create mode 100644 node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/LICENSE create mode 100644 node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/lib/index.js create mode 100644 node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/package.json diff --git a/node_modules/@npmcli/run-script/lib/run-script.js b/node_modules/@npmcli/run-script/lib/run-script.js index 6bb4a2e666a20..e9d18261a2c1f 100644 --- a/node_modules/@npmcli/run-script/lib/run-script.js +++ b/node_modules/@npmcli/run-script/lib/run-script.js @@ -7,7 +7,8 @@ const runScript = options => { validateOptions(options) const { pkg, path } = options return pkg ? runScriptPkg(options) - : rpj(path + '/package.json').then(pkg => runScriptPkg({ ...options, pkg })) + : rpj(path + '/package.json') + .then(readPackage => runScriptPkg({ ...options, pkg: readPackage })) } module.exports = Object.assign(runScript, { isServerPackage }) diff --git a/node_modules/@npmcli/run-script/lib/set-path.js b/node_modules/@npmcli/run-script/lib/set-path.js index d5f8707efc84f..07671f44579dc 100644 --- a/node_modules/@npmcli/run-script/lib/set-path.js +++ b/node_modules/@npmcli/run-script/lib/set-path.js @@ -12,7 +12,7 @@ const setPATH = (projectPath, env) => { const delimiter = isWindows ? ';' : ':' const PATH = Object.keys(env).filter(p => /^path$/i.test(p) && env[p]) .map(p => env[p].split(delimiter)) - .reduce((set, p) => set.concat(p.filter(p => !set.includes(p))), []) + .reduce((set, p) => set.concat(p.filter(concatted => !set.includes(concatted))), []) .join(delimiter) const pathArr = [] diff --git a/node_modules/@npmcli/run-script/node_modules/@npmcli/node-gyp/lib/index.js b/node_modules/@npmcli/run-script/node_modules/@npmcli/node-gyp/lib/index.js new file mode 100644 index 0000000000000..cdf18560e0ca2 --- /dev/null +++ b/node_modules/@npmcli/run-script/node_modules/@npmcli/node-gyp/lib/index.js @@ -0,0 +1,14 @@ +const util = require('util') +const fs = require('fs') +const { stat } = fs.promises || { stat: util.promisify(fs.stat) } + +async function isNodeGypPackage (path) { + return await stat(`${path}/binding.gyp`) + .then(st => st.isFile()) + .catch(() => false) +} + +module.exports = { + isNodeGypPackage, + defaultGypInstallScript: 'node-gyp rebuild', +} diff --git a/node_modules/@npmcli/run-script/node_modules/@npmcli/node-gyp/package.json b/node_modules/@npmcli/run-script/node_modules/@npmcli/node-gyp/package.json new file mode 100644 index 0000000000000..04eeec8ff808c --- /dev/null +++ b/node_modules/@npmcli/run-script/node_modules/@npmcli/node-gyp/package.json @@ -0,0 +1,45 @@ +{ + "name": "@npmcli/node-gyp", + "version": "2.0.0", + "description": "Tools for dealing with node-gyp packages", + "scripts": { + "test": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "prepublishOnly": "git push origin --follow-tags", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force", + "lintfix": "npm run lint -- --fix", + "snap": "tap", + "posttest": "npm run lint" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/node-gyp.git" + }, + "keywords": [ + "npm", + "cli", + "node-gyp" + ], + "files": [ + "bin/", + "lib/" + ], + "main": "lib/index.js", + "author": "GitHub Inc.", + "license": "ISC", + "devDependencies": { + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", + "tap": "^16.0.1" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" + } +} diff --git a/node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/LICENSE b/node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/LICENSE new file mode 100644 index 0000000000000..8f90f96f4c6c5 --- /dev/null +++ b/node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) npm, Inc. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE NPM DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE NPM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, +OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. diff --git a/node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/lib/index.js b/node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/lib/index.js new file mode 100644 index 0000000000000..84ddc83d10bab --- /dev/null +++ b/node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/lib/index.js @@ -0,0 +1,75 @@ +const { spawn } = require('child_process') +const inferOwner = require('infer-owner') + +const isPipe = (stdio = 'pipe', fd) => + stdio === 'pipe' || stdio === null ? true + : Array.isArray(stdio) ? isPipe(stdio[fd], fd) + : false + +// 'extra' object is for decorating the error a bit more +const promiseSpawn = (cmd, args, opts = {}, extra = {}) => { + const cwd = opts.cwd || process.cwd() + const isRoot = process.getuid && process.getuid() === 0 + const { uid, gid } = isRoot ? inferOwner.sync(cwd) : {} + return promiseSpawnUid(cmd, args, { + ...opts, + cwd, + uid, + gid, + }, extra) +} + +const stdioResult = (stdout, stderr, { stdioString, stdio }) => + stdioString ? { + stdout: isPipe(stdio, 1) ? Buffer.concat(stdout).toString() : null, + stderr: isPipe(stdio, 2) ? Buffer.concat(stderr).toString() : null, + } + : { + stdout: isPipe(stdio, 1) ? Buffer.concat(stdout) : null, + stderr: isPipe(stdio, 2) ? Buffer.concat(stderr) : null, + } + +const promiseSpawnUid = (cmd, args, opts, extra) => { + let proc + const p = new Promise((res, rej) => { + proc = spawn(cmd, args, opts) + const stdout = [] + const stderr = [] + const reject = er => rej(Object.assign(er, { + cmd, + args, + ...stdioResult(stdout, stderr, opts), + ...extra, + })) + proc.on('error', reject) + if (proc.stdout) { + proc.stdout.on('data', c => stdout.push(c)).on('error', reject) + proc.stdout.on('error', er => reject(er)) + } + if (proc.stderr) { + proc.stderr.on('data', c => stderr.push(c)).on('error', reject) + proc.stderr.on('error', er => reject(er)) + } + proc.on('close', (code, signal) => { + const result = { + cmd, + args, + code, + signal, + ...stdioResult(stdout, stderr, opts), + ...extra, + } + if (code || signal) { + rej(Object.assign(new Error('command failed'), result)) + } else { + res(result) + } + }) + }) + + p.stdin = proc.stdin + p.process = proc + return p +} + +module.exports = promiseSpawn diff --git a/node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/package.json b/node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/package.json new file mode 100644 index 0000000000000..4521b56d50560 --- /dev/null +++ b/node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn/package.json @@ -0,0 +1,48 @@ +{ + "name": "@npmcli/promise-spawn", + "version": "3.0.0", + "files": [ + "bin/", + "lib/" + ], + "main": "./lib/index.js", + "description": "spawn processes the way the npm cli likes to do", + "repository": { + "type": "git", + "url": "https://github.com/npm/promise-spawn.git" + }, + "author": "GitHub Inc.", + "license": "ISC", + "scripts": { + "test": "tap", + "snap": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "prepublishOnly": "git push origin --follow-tags", + "lint": "eslint \"**/*.js\"", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint", + "postsnap": "npm run lintfix --", + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force" + }, + "tap": { + "check-coverage": true + }, + "devDependencies": { + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", + "minipass": "^3.1.1", + "tap": "^16.0.1" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" + }, + "dependencies": { + "infer-owner": "^1.0.4" + } +} diff --git a/node_modules/@npmcli/run-script/package.json b/node_modules/@npmcli/run-script/package.json index 3f29f97113e53..733b27e44a1b8 100644 --- a/node_modules/@npmcli/run-script/package.json +++ b/node_modules/@npmcli/run-script/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/run-script", - "version": "3.0.1", + "version": "3.0.2", "description": "Run a lifecycle script for a package (descendant of npm-lifecycle)", "author": "GitHub Inc.", "license": "ISC", @@ -10,42 +10,44 @@ "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "eslint": "eslint", - "lint": "eslint '**/*.js'", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", - "postlint": "npm-template-check", - "template-copy": "npm-template-copy --force", + "postlint": "template-oss-check", "snap": "tap", - "posttest": "npm run lint" + "posttest": "npm run lint", + "template-oss-apply": "template-oss-apply --force" }, "tap": { "check-coverage": true, "coverage-map": "map.js" }, "devDependencies": { - "@npmcli/template-oss": "^2.9.1", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", "minipass": "^3.1.6", "require-inject": "^1.4.4", - "tap": "^15.1.6" + "tap": "^16.0.1" }, "dependencies": { - "@npmcli/node-gyp": "^1.0.3", - "@npmcli/promise-spawn": "^1.3.2", + "@npmcli/node-gyp": "^2.0.0", + "@npmcli/promise-spawn": "^3.0.0", "node-gyp": "^9.0.0", "read-package-json-fast": "^2.0.3" }, "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "main": "lib/run-script.js", "repository": { "type": "git", - "url": "git+https://github.com/npm/run-script.git" + "url": "https://github.com/npm/run-script.git" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "templateOSS": { - "version": "2.9.1" + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/package-lock.json b/package-lock.json index 7db145aa06987..509e35da07db3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -993,7 +993,6 @@ }, "node_modules/@npmcli/node-gyp": { "version": "1.0.3", - "inBundle": true, "license": "ISC" }, "node_modules/@npmcli/package-json": { @@ -1018,17 +1017,39 @@ } }, "node_modules/@npmcli/run-script": { - "version": "3.0.1", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-3.0.2.tgz", + "integrity": "sha512-vdjD/PMBl+OX9j9C9irx5sCCIKfp2PWkpPNH9zxvlJAfSZ3Qp5aU412v+O3PFJl3R1PFNwuyChCqHg4ma6ci2Q==", "inBundle": true, - "license": "ISC", "dependencies": { - "@npmcli/node-gyp": "^1.0.3", - "@npmcli/promise-spawn": "^1.3.2", + "@npmcli/node-gyp": "^2.0.0", + "@npmcli/promise-spawn": "^3.0.0", "node-gyp": "^9.0.0", "read-package-json-fast": "^2.0.3" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/@npmcli/run-script/node_modules/@npmcli/node-gyp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/node-gyp/-/node-gyp-2.0.0.tgz", + "integrity": "sha512-doNI35wIe3bBaEgrlPfdJPaCpUR89pJWep4Hq3aRdh6gKazIVWfs0jHttvSSoq47ZXgC7h73kDsUl8AoIQUB+A==", + "inBundle": true, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/@npmcli/run-script/node_modules/@npmcli/promise-spawn": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-3.0.0.tgz", + "integrity": "sha512-s9SgS+p3a9Eohe68cSI3fi+hpcZUmXq5P7w0kMlAsWVtR7XbK3ptkZqKT2cK1zLDObJ3sR+8P59sJE0w/KTL1g==", + "inBundle": true, + "dependencies": { + "infer-owner": "^1.0.4" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, "node_modules/@npmcli/template-oss": { @@ -10438,12 +10459,29 @@ } }, "@npmcli/run-script": { - "version": "3.0.1", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-3.0.2.tgz", + "integrity": "sha512-vdjD/PMBl+OX9j9C9irx5sCCIKfp2PWkpPNH9zxvlJAfSZ3Qp5aU412v+O3PFJl3R1PFNwuyChCqHg4ma6ci2Q==", "requires": { - "@npmcli/node-gyp": "^1.0.3", - "@npmcli/promise-spawn": "^1.3.2", + "@npmcli/node-gyp": "^2.0.0", + "@npmcli/promise-spawn": "^3.0.0", "node-gyp": "^9.0.0", "read-package-json-fast": "^2.0.3" + }, + "dependencies": { + "@npmcli/node-gyp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/node-gyp/-/node-gyp-2.0.0.tgz", + "integrity": "sha512-doNI35wIe3bBaEgrlPfdJPaCpUR89pJWep4Hq3aRdh6gKazIVWfs0jHttvSSoq47ZXgC7h73kDsUl8AoIQUB+A==" + }, + "@npmcli/promise-spawn": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-3.0.0.tgz", + "integrity": "sha512-s9SgS+p3a9Eohe68cSI3fi+hpcZUmXq5P7w0kMlAsWVtR7XbK3ptkZqKT2cK1zLDObJ3sR+8P59sJE0w/KTL1g==", + "requires": { + "infer-owner": "^1.0.4" + } + } } }, "@npmcli/template-oss": {