diff --git a/node_modules/@npmcli/git/lib/clone.js b/node_modules/@npmcli/git/lib/clone.js index ac5f86b14494c..3f165dd70e380 100644 --- a/node_modules/@npmcli/git/lib/clone.js +++ b/node_modules/@npmcli/git/lib/clone.js @@ -20,9 +20,9 @@ const shallowHosts = new Set([ // we have to use url.parse until we add the same shim that hosted-git-info has // to handle scp:// urls const { parse } = require('url') // eslint-disable-line node/no-deprecated-api -const { basename, resolve } = require('path') +const path = require('path') -const revs = require('./revs.js') +const getRevs = require('./revs.js') const spawn = require('./spawn.js') const { isWindows } = require('./utils.js') @@ -31,7 +31,7 @@ const fs = require('fs') const mkdirp = require('mkdirp') module.exports = (repo, ref = 'HEAD', target = null, opts = {}) => - revs(repo, opts).then(revs => clone( + getRevs(repo, opts).then(revs => clone( repo, revs, ref, @@ -48,7 +48,7 @@ const maybeShallow = (repo, opts) => { } const defaultTarget = (repo, /* istanbul ignore next */ cwd = process.cwd()) => - resolve(cwd, basename(repo.replace(/[/\\]?\.git$/, ''))) + path.resolve(cwd, path.basename(repo.replace(/[/\\]?\.git$/, ''))) const clone = (repo, revs, ref, revDoc, target, opts) => { if (!revDoc) { diff --git a/node_modules/@npmcli/git/lib/lines-to-revs.js b/node_modules/@npmcli/git/lib/lines-to-revs.js index 3cf3778fe9178..6bd7e7a4c1531 100644 --- a/node_modules/@npmcli/git/lib/lines-to-revs.js +++ b/node_modules/@npmcli/git/lib/lines-to-revs.js @@ -98,19 +98,19 @@ const lineToRevDoc = line => { // ignore the pointer. // For now, though, we have to save both, because some tags // don't have peels, if they were not annotated. - const ref = rawRef.substr('refs/tags/'.length) + const ref = rawRef.slice('refs/tags/'.length) return { sha, ref, rawRef, type } } if (type === 'branch') { - const ref = rawRef.substr('refs/heads/'.length) + const ref = rawRef.slice('refs/heads/'.length) return { sha, ref, rawRef, type } } if (type === 'pull') { // NB: merged pull requests installable with #pull/123/merge // for the merged pr, or #pull/123 for the PR head - const ref = rawRef.substr('refs/'.length).replace(/\/head$/, '') + const ref = rawRef.slice('refs/'.length).replace(/\/head$/, '') return { sha, ref, rawRef, type } } diff --git a/node_modules/@npmcli/git/lib/spawn.js b/node_modules/@npmcli/git/lib/spawn.js index 40972a509caa5..7098d7b872942 100644 --- a/node_modules/@npmcli/git/lib/spawn.js +++ b/node_modules/@npmcli/git/lib/spawn.js @@ -17,16 +17,16 @@ module.exports = (gitArgs, opts = {}) => { ? gitArgs : ['--no-replace-objects', ...gitArgs] - let retry = opts.retry - if (retry === null || retry === undefined) { - retry = { + let retryOpts = opts.retry + if (retryOpts === null || retryOpts === undefined) { + retryOpts = { retries: opts.fetchRetries || 2, factor: opts.fetchRetryFactor || 10, maxTimeout: opts.fetchRetryMaxtimeout || 60000, minTimeout: opts.fetchRetryMintimeout || 1000, } } - return promiseRetry((retry, number) => { + return promiseRetry((retryFn, number) => { if (number !== 1) { log.silly('git', `Retrying git command: ${ args.join(' ')} attempt # ${number}`) @@ -38,7 +38,7 @@ module.exports = (gitArgs, opts = {}) => { if (!gitError.shouldRetry(number)) { throw gitError } - retry(gitError) + retryFn(gitError) }) - }, retry) + }, retryOpts) } diff --git a/node_modules/@npmcli/git/node_modules/@npmcli/promise-spawn/LICENSE b/node_modules/@npmcli/git/node_modules/@npmcli/promise-spawn/LICENSE new file mode 100644 index 0000000000000..8f90f96f4c6c5 --- /dev/null +++ b/node_modules/@npmcli/git/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/git/node_modules/@npmcli/promise-spawn/lib/index.js b/node_modules/@npmcli/git/node_modules/@npmcli/promise-spawn/lib/index.js new file mode 100644 index 0000000000000..84ddc83d10bab --- /dev/null +++ b/node_modules/@npmcli/git/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/git/node_modules/@npmcli/promise-spawn/package.json b/node_modules/@npmcli/git/node_modules/@npmcli/promise-spawn/package.json new file mode 100644 index 0000000000000..4521b56d50560 --- /dev/null +++ b/node_modules/@npmcli/git/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/git/package.json b/node_modules/@npmcli/git/package.json index 02cd37fa225ad..08525ae99e8ec 100644 --- a/node_modules/@npmcli/git/package.json +++ b/node_modules/@npmcli/git/package.json @@ -1,44 +1,43 @@ { "name": "@npmcli/git", - "version": "3.0.0", + "version": "3.0.1", "main": "lib/index.js", "files": [ - "bin", - "lib" + "bin/", + "lib/" ], "description": "a util for spawning git from npm CLI contexts", "repository": { "type": "git", - "url": "git+https://github.com/npm/git" + "url": "https://github.com/npm/git.git" }, "author": "GitHub Inc.", "license": "ISC", "scripts": { - "lint": "eslint '**/*.js'", - "lint:fix": "standard --fix", + "lint": "eslint \"**/*.js\"", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "preversion": "npm test", "snap": "tap", "test": "tap", "posttest": "npm run lint", - "postlint": "npm-template-check", - "template-copy": "npm-template-copy --force", - "lintfix": "npm run lint -- --fix" + "postlint": "template-oss-check", + "lintfix": "npm run lint -- --fix", + "template-oss-apply": "template-oss-apply --force" }, "tap": { "check-coverage": true, "coverage-map": "map.js" }, "devDependencies": { - "@npmcli/template-oss": "^2.7.1", + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", "slash": "^3.0.0", - "standard": "^16.0.3", - "tap": "^15.1.6" + "tap": "^16.0.1" }, "dependencies": { - "@npmcli/promise-spawn": "^1.3.2", - "lru-cache": "^7.3.1", + "@npmcli/promise-spawn": "^3.0.0", + "lru-cache": "^7.4.4", "mkdirp": "^1.0.4", "npm-pick-manifest": "^7.0.0", "proc-log": "^2.0.0", @@ -48,10 +47,11 @@ "which": "^2.0.2" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "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.", "windowsCI": false, - "version": "2.7.1" + "version": "3.2.2" } } diff --git a/package-lock.json b/package-lock.json index 8a824022a4f46..7db145aa06987 100644 --- a/package-lock.json +++ b/package-lock.json @@ -881,12 +881,13 @@ } }, "node_modules/@npmcli/git": { - "version": "3.0.0", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-3.0.1.tgz", + "integrity": "sha512-UU85F/T+F1oVn3IsB/L6k9zXIMpXBuUBE25QDH0SsURwT6IOBqkC7M16uqo2vVZIyji3X1K4XH9luip7YekH1A==", "inBundle": true, - "license": "ISC", "dependencies": { - "@npmcli/promise-spawn": "^1.3.2", - "lru-cache": "^7.3.1", + "@npmcli/promise-spawn": "^3.0.0", + "lru-cache": "^7.4.4", "mkdirp": "^1.0.4", "npm-pick-manifest": "^7.0.0", "proc-log": "^2.0.0", @@ -896,7 +897,19 @@ "which": "^2.0.2" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/@npmcli/git/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/installed-package-contents": { @@ -10329,10 +10342,12 @@ } }, "@npmcli/git": { - "version": "3.0.0", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-3.0.1.tgz", + "integrity": "sha512-UU85F/T+F1oVn3IsB/L6k9zXIMpXBuUBE25QDH0SsURwT6IOBqkC7M16uqo2vVZIyji3X1K4XH9luip7YekH1A==", "requires": { - "@npmcli/promise-spawn": "^1.3.2", - "lru-cache": "^7.3.1", + "@npmcli/promise-spawn": "^3.0.0", + "lru-cache": "^7.4.4", "mkdirp": "^1.0.4", "npm-pick-manifest": "^7.0.0", "proc-log": "^2.0.0", @@ -10340,6 +10355,16 @@ "promise-retry": "^2.0.1", "semver": "^7.3.5", "which": "^2.0.2" + }, + "dependencies": { + "@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/installed-package-contents": {