Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-04-13 20:20:22 +0300
committerGar <gar+gh@danger.computer>2021-04-13 20:20:22 +0300
commit42965fdfa08072e2b172d777569900522de63802 (patch)
tree8a2cb59696dae1a9123a56f5f6738aecd3db7cb5 /node_modules
parent90b61eda9b41af108ed69fc0c43a522a92745047 (diff)
libnpmversion@1.1.1
Diffstat (limited to 'node_modules')
-rw-r--r--node_modules/@npmcli/git/lib/clone.js100
-rw-r--r--node_modules/@npmcli/git/lib/env.js33
-rw-r--r--node_modules/@npmcli/git/lib/find.js18
-rw-r--r--node_modules/@npmcli/git/lib/index.js2
-rw-r--r--node_modules/@npmcli/git/lib/is-clean.js6
-rw-r--r--node_modules/@npmcli/git/lib/lines-to-revs.js52
-rw-r--r--node_modules/@npmcli/git/lib/opts.js9
-rw-r--r--node_modules/@npmcli/git/lib/revs.js16
-rw-r--r--node_modules/@npmcli/git/lib/spawn.js28
-rw-r--r--node_modules/@npmcli/git/lib/utils.js16
-rw-r--r--node_modules/@npmcli/git/lib/which.js14
-rw-r--r--node_modules/@npmcli/git/package.json24
-rw-r--r--node_modules/libnpmversion/package.json8
13 files changed, 183 insertions, 143 deletions
diff --git a/node_modules/@npmcli/git/lib/clone.js b/node_modules/@npmcli/git/lib/clone.js
index 3c50a05cf..0b88c79f3 100644
--- a/node_modules/@npmcli/git/lib/clone.js
+++ b/node_modules/@npmcli/git/lib/clone.js
@@ -15,16 +15,18 @@ const shallowHosts = new Set([
'gist.github.com',
'gitlab.com',
'bitbucket.com',
- 'bitbucket.org',
+ 'bitbucket.org'
])
-const { parse } = require('url')
+// 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 revs = require('./revs.js')
const spawn = require('./spawn.js')
+const { isWindows, escapePath } = require('./utils.js')
const pickManifest = require('npm-pick-manifest')
-const { promisify } = require('util')
const fs = require('fs')
const mkdirp = require('mkdirp')
@@ -38,38 +40,56 @@ module.exports = (repo, ref = 'HEAD', target = null, /* istanbul ignore next */
opts
))
-const maybeShallow = (repo, opts) =>
- opts.gitShallow === false || opts.gitShallow ? opts.gitShallow
- : shallowHosts.has(parse(repo).host)
-
-const isWindows = opts => (opts.fakePlatform || process.platform) === 'win32'
+const maybeShallow = (repo, opts) => {
+ if (opts.gitShallow === false || opts.gitShallow) {
+ return opts.gitShallow
+ }
+ return shallowHosts.has(parse(repo).host)
+}
const defaultTarget = (repo, /* istanbul ignore next */ cwd = process.cwd()) =>
- resolve(cwd, basename(repo.replace(/[\/\\]?\.git$/, '')))
-
-const clone = (repo, revs, ref, revDoc, target, opts) =>
- !revDoc ? unresolved(repo, ref, target, opts)
- : revDoc.sha === revs.refs.HEAD.sha ? plain(repo, revDoc, target, opts)
- : revDoc.type === 'tag' || revDoc.type === 'branch'
- ? branch(repo, revDoc, target, opts)
- : other(repo, revDoc, target, opts)
+ resolve(cwd, basename(repo.replace(/[/\\]?\.git$/, '')))
+
+const clone = (repo, revs, ref, revDoc, target, opts) => {
+ if (!revDoc) {
+ return unresolved(repo, ref, target, opts)
+ }
+ if (revDoc.sha === revs.refs.HEAD.sha) {
+ return plain(repo, revDoc, target, opts)
+ }
+ if (revDoc.type === 'tag' || revDoc.type === 'branch') {
+ return branch(repo, revDoc, target, opts)
+ }
+ return other(repo, revDoc, target, opts)
+}
const resolveRef = (revs, ref, opts) => {
const { spec = {} } = opts
ref = spec.gitCommittish || ref
- return !revs ? /* istanbul ignore next - will fail anyway, can't pull */ null
- : spec.gitRange ? pickManifest(revs, spec.gitRange, opts)
- : !ref ? revs.refs.HEAD
- : revs.refs[ref] ? revs.refs[ref]
- : revs.shas[ref] ? revs.refs[revs.shas[ref][0]]
- : null
+ /* istanbul ignore next - will fail anyway, can't pull */
+ if (!revs) {
+ return null
+ }
+ if (spec.gitRange) {
+ return pickManifest(revs, spec.gitRange, opts)
+ }
+ if (!ref) {
+ return revs.refs.HEAD
+ }
+ if (revs.refs[ref]) {
+ return revs.refs[ref]
+ }
+ if (revs.shas[ref]) {
+ return revs.refs[revs.shas[ref][0]]
+ }
+ return null
}
// pull request or some other kind of advertised ref
const other = (repo, revDoc, target, opts) => {
const shallow = maybeShallow(repo, opts)
- const fetchOrigin = [ 'fetch', 'origin', revDoc.rawRef ]
+ const fetchOrigin = ['fetch', 'origin', revDoc.rawRef]
.concat(shallow ? ['--depth=1'] : [])
const git = (args) => spawn(args, { ...opts, cwd: target })
@@ -92,13 +112,11 @@ const branch = (repo, revDoc, target, opts) => {
'-b',
revDoc.ref,
repo,
- target,
- '--recurse-submodules',
+ escapePath(target, opts),
+ '--recurse-submodules'
]
- if (maybeShallow(repo, opts))
- args.push('--depth=1')
- if (isWindows(opts))
- args.push('--config', 'core.longpaths=true')
+ if (maybeShallow(repo, opts)) { args.push('--depth=1') }
+ if (isWindows(opts)) { args.push('--config', 'core.longpaths=true') }
return spawn(args, opts).then(() => revDoc.sha)
}
@@ -107,31 +125,33 @@ const plain = (repo, revDoc, target, opts) => {
const args = [
'clone',
repo,
- target,
+ escapePath(target, opts),
'--recurse-submodules'
]
- if (maybeShallow(repo, opts))
- args.push('--depth=1')
- if (isWindows(opts))
- args.push('--config', 'core.longpaths=true')
+ if (maybeShallow(repo, opts)) { args.push('--depth=1') }
+ if (isWindows(opts)) { args.push('--config', 'core.longpaths=true') }
return spawn(args, opts).then(() => revDoc.sha)
}
-const updateSubmodules = (target, opts) => new Promise(res =>
- fs.stat(target + '/.gitmodules', er => res(er ? null
- : spawn([
+const updateSubmodules = (target, opts) => new Promise(resolve =>
+ fs.stat(target + '/.gitmodules', er => {
+ if (er) {
+ return resolve(null)
+ }
+ return resolve(spawn([
'submodule',
'update',
'-q',
'--init',
'--recursive'
- ], { ...opts, cwd: target }))))
+ ], { ...opts, cwd: target }))
+ }))
const unresolved = (repo, ref, target, opts) => {
// can't do this one shallowly, because the ref isn't advertised
// but we can avoid checking out the working dir twice, at least
const lp = isWindows(opts) ? ['--config', 'core.longpaths=true'] : []
- const cloneArgs = ['clone', '--mirror', '-q', repo, target + '/.git']
+ const cloneArgs = ['clone', '--mirror', '-q', repo, escapePath(target + '/.git', opts)]
const git = (args) => spawn(args, { ...opts, cwd: target })
return mkdirp(target)
.then(() => git(cloneArgs.concat(lp)))
@@ -139,5 +159,5 @@ const unresolved = (repo, ref, target, opts) => {
.then(() => git(['checkout', ref]))
.then(() => updateSubmodules(target, opts))
.then(() => git(['rev-parse', '--revs-only', 'HEAD']))
- .then(({stdout}) => stdout.trim())
+ .then(({ stdout }) => stdout.trim())
}
diff --git a/node_modules/@npmcli/git/lib/env.js b/node_modules/@npmcli/git/lib/env.js
deleted file mode 100644
index 87787cdbe..000000000
--- a/node_modules/@npmcli/git/lib/env.js
+++ /dev/null
@@ -1,33 +0,0 @@
-const uniqueFilename = require('unique-filename')
-const { join } = require('path')
-const {tmpdir} = require('os')
-
-const goodEnvVars = new Set([
- 'GIT_ASKPASS',
- 'GIT_EXEC_PATH',
- 'GIT_PROXY_COMMAND',
- 'GIT_SSH',
- 'GIT_SSH_COMMAND',
- 'GIT_SSL_CAINFO',
- 'GIT_SSL_NO_VERIFY'
-])
-
-// memoize
-let gitEnv
-
-module.exports = () => {
- if (gitEnv)
- return gitEnv
-
- // we set the template dir to an empty folder to give git less to do
- const tmpDir = join(tmpdir(), 'npmcli-git-template-tmp')
- const tmpName = uniqueFilename(tmpDir, 'git-clone')
- return gitEnv = Object.keys(process.env).reduce((gitEnv, k) => {
- if (goodEnvVars.has(k) || !k.startsWith('GIT_'))
- gitEnv[k] = process.env[k]
- return gitEnv
- }, {
- GIT_ASKPASS: 'echo',
- GIT_TEMPLATE_DIR: tmpName
- })
-}
diff --git a/node_modules/@npmcli/git/lib/find.js b/node_modules/@npmcli/git/lib/find.js
index 2d2ad3086..d58f01dbc 100644
--- a/node_modules/@npmcli/git/lib/find.js
+++ b/node_modules/@npmcli/git/lib/find.js
@@ -1,7 +1,15 @@
const is = require('./is.js')
const { dirname } = require('path')
-const check = (cwd, prev) => is({ cwd }).then(isGit =>
- isGit ? cwd
- : cwd === prev ? null
- : check(dirname(cwd), cwd))
-module.exports = ({ cwd = process.cwd() } = {}) => check(cwd)
+
+module.exports = async ({ cwd = process.cwd() } = {}) => {
+ if (await is({ cwd })) {
+ return cwd
+ }
+ while (cwd !== dirname(cwd)) {
+ cwd = dirname(cwd)
+ if (await is({ cwd })) {
+ return cwd
+ }
+ }
+ return null
+}
diff --git a/node_modules/@npmcli/git/lib/index.js b/node_modules/@npmcli/git/lib/index.js
index 7088792a1..50fd889b8 100644
--- a/node_modules/@npmcli/git/lib/index.js
+++ b/node_modules/@npmcli/git/lib/index.js
@@ -4,5 +4,5 @@ module.exports = {
spawn: require('./spawn.js'),
is: require('./is.js'),
find: require('./find.js'),
- isClean: require('./is-clean.js'),
+ isClean: require('./is-clean.js')
}
diff --git a/node_modules/@npmcli/git/lib/is-clean.js b/node_modules/@npmcli/git/lib/is-clean.js
index 19f8049e0..182373be9 100644
--- a/node_modules/@npmcli/git/lib/is-clean.js
+++ b/node_modules/@npmcli/git/lib/is-clean.js
@@ -1,6 +1,6 @@
const spawn = require('./spawn.js')
module.exports = (opts = {}) =>
- spawn([ 'status', '--porcelain=v1', '-uno' ], opts)
- .then(res => res.stdout.trim().split(/\r?\n+/)
- .map(l => l.trim()).filter(l => l).length ? false : true)
+ spawn(['status', '--porcelain=v1', '-uno'], opts)
+ .then(res => !res.stdout.trim().split(/\r?\n+/)
+ .map(l => l.trim()).filter(l => l).length)
diff --git a/node_modules/@npmcli/git/lib/lines-to-revs.js b/node_modules/@npmcli/git/lib/lines-to-revs.js
index 524e67243..9f879ca24 100644
--- a/node_modules/@npmcli/git/lib/lines-to-revs.js
+++ b/node_modules/@npmcli/git/lib/lines-to-revs.js
@@ -7,7 +7,7 @@ module.exports = lines => finish(lines.reduce(linesToRevsReducer, {
versions: {},
'dist-tags': {},
refs: {},
- shas: {},
+ shas: {}
}))
const finish = revs => distTags(shaList(peelTags(revs)))
@@ -15,16 +15,16 @@ const finish = revs => distTags(shaList(peelTags(revs)))
// We can check out shallow clones on specific SHAs if we have a ref
const shaList = revs => {
Object.keys(revs.refs).forEach(ref => {
- doc = revs.refs[ref]
- if (revs.shas[doc.sha])
- revs.shas[doc.sha].push(ref)
- else
+ const doc = revs.refs[ref]
+ if (!revs.shas[doc.sha]) {
revs.shas[doc.sha] = [ref]
+ } else {
+ revs.shas[doc.sha].push(ref)
+ }
})
return revs
}
-
// Replace any tags with their ^{} counterparts, if those exist
const peelTags = revs => {
Object.keys(revs.refs).filter(ref => ref.endsWith('^{}')).forEach(ref => {
@@ -48,30 +48,38 @@ const distTags = revs => {
// 'latest' branch if one exists and is a version,
// or HEAD if not.
const ver = revs.versions[v]
- if (revs.refs.latest && ver.sha === revs.refs.latest.sha)
+ if (revs.refs.latest && ver.sha === revs.refs.latest.sha) {
revs['dist-tags'].latest = v
- else if (ver.sha === HEAD.sha) {
+ } else if (ver.sha === HEAD.sha) {
revs['dist-tags'].HEAD = v
- if (!revs.refs.latest)
- revs['dist-tags'].latest = v
+ if (!revs.refs.latest) { revs['dist-tags'].latest = v }
}
})
return revs
}
-const refType = ref =>
- ref.startsWith('refs/tags/') ? 'tag'
- : ref.startsWith('refs/heads/') ? 'branch'
- : ref.startsWith('refs/pull/') ? 'pull'
- : ref === 'HEAD' ? 'head'
- // Could be anything, ignore for now
- : /* istanbul ignore next */ 'other'
+const refType = ref => {
+ if (ref.startsWith('refs/tags/')) {
+ return 'tag'
+ }
+ if (ref.startsWith('refs/heads/')) {
+ return 'branch'
+ }
+ if (ref.startsWith('refs/pull/')) {
+ return 'pull'
+ }
+ if (ref === 'HEAD') {
+ return 'head'
+ }
+ // Could be anything, ignore for now
+ /* istanbul ignore next */
+ return 'other'
+}
// return the doc, or null if we should ignore it.
const lineToRevDoc = line => {
const split = line.trim().split(/\s+/, 2)
- if (split.length < 2)
- return null
+ if (split.length < 2) { return null }
const sha = split[0].trim()
const rawRef = split[1].trim()
@@ -114,8 +122,7 @@ const lineToRevDoc = line => {
const linesToRevsReducer = (revs, line) => {
const doc = lineToRevDoc(line)
- if (!doc)
- return revs
+ if (!doc) { return revs }
revs.refs[doc.ref] = doc
revs.refs[doc.rawRef] = doc
@@ -125,8 +132,9 @@ const linesToRevsReducer = (revs, line) => {
// which is a pretty common pattern.
const match = !doc.ref.endsWith('^{}') &&
doc.ref.match(/v?(\d+\.\d+\.\d+(?:[-+].+)?)$/)
- if (match && semver.valid(match[1], true))
+ if (match && semver.valid(match[1], true)) {
revs.versions[semver.clean(match[1], true)] = doc
+ }
}
return revs
diff --git a/node_modules/@npmcli/git/lib/opts.js b/node_modules/@npmcli/git/lib/opts.js
index 7da4801a6..6db9e9abe 100644
--- a/node_modules/@npmcli/git/lib/opts.js
+++ b/node_modules/@npmcli/git/lib/opts.js
@@ -1,6 +1,11 @@
-const gitEnv = require('./env.js')
+// Values we want to set if they're not already defined by the end user
+// This defaults to accepting new ssh host key fingerprints
+const gitEnv = {
+ GIT_ASKPASS: 'echo',
+ GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new'
+}
module.exports = (opts = {}) => ({
stdioString: true,
...opts,
- env: opts.env || gitEnv(),
+ env: opts.env || { ...gitEnv, ...process.env }
})
diff --git a/node_modules/@npmcli/git/lib/revs.js b/node_modules/@npmcli/git/lib/revs.js
index 574473187..81059594f 100644
--- a/node_modules/@npmcli/git/lib/revs.js
+++ b/node_modules/@npmcli/git/lib/revs.js
@@ -4,21 +4,25 @@ const LRU = require('lru-cache')
const revsCache = new LRU({
max: 100,
- maxAge: 5 * 60 * 1000,
+ maxAge: 5 * 60 * 1000
})
const linesToRevs = require('./lines-to-revs.js')
-module.exports = (repo, opts = {}) => {
+module.exports = async (repo, opts = {}) => {
if (!opts.noGitRevCache) {
const cached = revsCache.get(repo)
- if (cached)
- return Promise.resolve(cached)
+ if (cached) {
+ return cached
+ }
}
return pinflight(`ls-remote:${repo}`, () =>
spawn(['ls-remote', repo], opts)
- .then(({stdout}) => linesToRevs(stdout.trim().split('\n')))
- .then(revs => (revsCache.set(repo, revs), revs))
+ .then(({ stdout }) => linesToRevs(stdout.trim().split('\n')))
+ .then(revs => {
+ revsCache.set(repo, revs)
+ return revs
+ })
)
}
diff --git a/node_modules/@npmcli/git/lib/spawn.js b/node_modules/@npmcli/git/lib/spawn.js
index 3c3a943fe..cee3a7baf 100644
--- a/node_modules/@npmcli/git/lib/spawn.js
+++ b/node_modules/@npmcli/git/lib/spawn.js
@@ -8,26 +8,30 @@ const procLog = require('./proc-log.js')
module.exports = (gitArgs, opts = {}) => {
const gitPath = whichGit(opts)
- if (gitPath instanceof Error)
- return Promise.reject(gitPath)
+ if (gitPath instanceof Error) { return Promise.reject(gitPath) }
const log = opts.log || procLog
+ let retry = opts.retry
+ if (retry === null || retry === undefined) {
+ retry = {
+ retries: opts.fetchRetries || 2,
+ factor: opts.fetchRetryFactor || 10,
+ maxTimeout: opts.fetchRetryMaxtimeout || 60000,
+ minTimeout: opts.fetchRetryMintimeout || 1000
+ }
+ }
return promiseRetry((retry, number) => {
- if (number !== 1)
+ if (number !== 1) {
log.silly('pacote', `Retrying git command: ${
gitArgs.join(' ')} attempt # ${number}`)
+ }
return spawn(gitPath, gitArgs, makeOpts(opts))
.catch(er => {
- if (shouldRetry(er.stderr, number))
- retry(er)
- else
+ if (!shouldRetry(er.stderr, number)) {
throw er
+ }
+ retry(er)
})
- }, opts.retry !== null && opts.retry !== undefined ? opts.retry : {
- retries: opts.fetchRetries || 2,
- factor: opts.fetchRetryFactor || 10,
- maxTimeout: opts.fetchRetryMaxtimeout || 60000,
- minTimeout: opts.fetchRetryMintimeout || 1000,
- })
+ }, retry)
}
diff --git a/node_modules/@npmcli/git/lib/utils.js b/node_modules/@npmcli/git/lib/utils.js
new file mode 100644
index 000000000..82610a73a
--- /dev/null
+++ b/node_modules/@npmcli/git/lib/utils.js
@@ -0,0 +1,16 @@
+const { basename } = require('path')
+
+const isWindows = opts => (opts.fakePlatform || process.platform) === 'win32'
+
+// wrap the target in quotes for Windows when using cmd(.exe) as a shell to
+// avoid clone failures for paths with spaces
+const escapePath = (gitPath, opts) => {
+ const isCmd = opts.shell && (basename(opts.shell.toLowerCase(), '.exe') === 'cmd')
+ if (isWindows(opts) && isCmd && !gitPath.startsWith('"')) {
+ return `"${gitPath}"`
+ }
+ return gitPath
+}
+
+exports.escapePath = escapePath
+exports.isWindows = isWindows
diff --git a/node_modules/@npmcli/git/lib/which.js b/node_modules/@npmcli/git/lib/which.js
index 9e82d391a..d4e113126 100644
--- a/node_modules/@npmcli/git/lib/which.js
+++ b/node_modules/@npmcli/git/lib/which.js
@@ -1,3 +1,4 @@
+const { escapePath } = require('./utils.js')
const which = require('which')
let gitPath
@@ -5,7 +6,12 @@ try {
gitPath = which.sync('git')
} catch (e) {}
-module.exports = (opts = {}) =>
- opts.git ||
- opts.git !== false && gitPath ||
- Object.assign(new Error('No git binary found in $PATH'), { code: 'ENOGIT' })
+module.exports = (opts = {}) => {
+ if (opts.git) {
+ return opts.git
+ }
+ if (!gitPath || opts.git === false) {
+ return Object.assign(new Error('No git binary found in $PATH'), { code: 'ENOGIT' })
+ }
+ return escapePath(gitPath, opts)
+}
diff --git a/node_modules/@npmcli/git/package.json b/node_modules/@npmcli/git/package.json
index 0e01efaf2..c949936f8 100644
--- a/node_modules/@npmcli/git/package.json
+++ b/node_modules/@npmcli/git/package.json
@@ -1,6 +1,6 @@
{
"name": "@npmcli/git",
- "version": "2.0.6",
+ "version": "2.0.7",
"main": "lib/index.js",
"files": [
"lib/*.js"
@@ -13,11 +13,13 @@
"author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)",
"license": "ISC",
"scripts": {
- "test": "tap",
- "snap": "tap",
- "preversion": "npm test",
+ "lint": "standard",
+ "lint:fix": "standard --fix",
"postversion": "npm publish",
- "prepublishOnly": "git push origin --follow-tags"
+ "prepublishOnly": "git push origin --follow-tags",
+ "preversion": "npm test",
+ "snap": "tap",
+ "test": "tap"
},
"tap": {
"check-coverage": true,
@@ -25,17 +27,17 @@
},
"devDependencies": {
"slash": "^3.0.0",
- "tap": "^14.10.6"
+ "standard": "^16.0.3",
+ "tap": "^14.11.0"
},
"dependencies": {
- "@npmcli/promise-spawn": "^1.1.0",
+ "@npmcli/promise-spawn": "^1.3.2",
"lru-cache": "^6.0.0",
- "mkdirp": "^1.0.3",
- "npm-pick-manifest": "^6.0.0",
+ "mkdirp": "^1.0.4",
+ "npm-pick-manifest": "^6.1.1",
"promise-inflight": "^1.0.1",
"promise-retry": "^2.0.1",
- "semver": "^7.3.2",
- "unique-filename": "^1.1.1",
+ "semver": "^7.3.5",
"which": "^2.0.2"
}
}
diff --git a/node_modules/libnpmversion/package.json b/node_modules/libnpmversion/package.json
index 30d94c7a1..574fc6e70 100644
--- a/node_modules/libnpmversion/package.json
+++ b/node_modules/libnpmversion/package.json
@@ -1,6 +1,6 @@
{
"name": "libnpmversion",
- "version": "1.1.0",
+ "version": "1.1.1",
"main": "lib/index.js",
"files": [
"lib/*.js"
@@ -28,10 +28,10 @@
"tap": "^14.11.0"
},
"dependencies": {
- "@npmcli/git": "^2.0.6",
- "@npmcli/run-script": "^1.8.3",
+ "@npmcli/git": "^2.0.7",
+ "@npmcli/run-script": "^1.8.4",
"json-parse-even-better-errors": "^2.3.1",
- "semver": "^7.3.4",
+ "semver": "^7.3.5",
"stringify-package": "^1.0.1"
}
}