diff --git a/node_modules/npm-package-arg/CHANGELOG.md b/node_modules/npm-package-arg/CHANGELOG.md deleted file mode 100644 index 390a3a3c4f2de..0000000000000 --- a/node_modules/npm-package-arg/CHANGELOG.md +++ /dev/null @@ -1,52 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. - -## [8.0.0](https://github.com/npm/npm-package-arg/compare/v7.0.0...v8.0.0) (2019-12-15) - - -### ⚠ BREAKING CHANGES - -* Dropping support for node 6 and 8. It'll probably -still work on those versions, but they are no longer supported or -tested, since npm v7 is moving away from them. - -* drop support for node 6 and 8 ([ba85e68](https://github.com/npm/npm-package-arg/commit/ba85e68555d6270f672c3d59da17672f744d0376)) - - -# [7.0.0](https://github.com/npm/npm-package-arg/compare/v6.1.1...v7.0.0) (2019-11-11) - - -### deps - -* bump hosted-git-info to 3.0.2 ([68a4fc3](https://github.com/npm/npm-package-arg/commit/68a4fc3)), closes [/github.com/npm/hosted-git-info/pull/38#issuecomment-520243803](https://github.com//github.com/npm/hosted-git-info/pull/38/issues/issuecomment-520243803) - - -### BREAKING CHANGES - -* this drops support for ancient node versions. - - - - -## [6.1.1](https://github.com/npm/npm-package-arg/compare/v6.1.0...v6.1.1) (2019-08-21) - - -### Bug Fixes - -* preserve drive letter on windows git file:// urls ([3909203](https://github.com/npm/npm-package-arg/commit/3909203)) - - - - -# [6.1.0](https://github.com/npm/npm-package-arg/compare/v6.0.0...v6.1.0) (2018-04-10) - - -### Bug Fixes - -* **git:** Fix gitRange for git+ssh for private git ([#33](https://github.com/npm/npm-package-arg/issues/33)) ([647a0b3](https://github.com/npm/npm-package-arg/commit/647a0b3)) - - -### Features - -* **alias:** add `npm:` registry alias spec ([#34](https://github.com/npm/npm-package-arg/issues/34)) ([ab99f8e](https://github.com/npm/npm-package-arg/commit/ab99f8e)) diff --git a/node_modules/npm-package-arg/npa.js b/node_modules/npm-package-arg/npa.js index 6018dd608ed33..3a01d4d907192 100644 --- a/node_modules/npm-package-arg/npa.js +++ b/node_modules/npm-package-arg/npa.js @@ -3,16 +3,12 @@ module.exports = npa module.exports.resolve = resolve module.exports.Result = Result -let url -let HostedGit -let semver -let path_ -function path () { - if (!path_) path_ = require('path') - return path_ -} -let validatePackageName -let os +const url = require('url') +const HostedGit = require('hosted-git-info') +const semver = require('semver') +const path = require('path') +const validatePackageName = require('validate-npm-package-name') +const { homedir } = require('os') const isWindows = process.platform === 'win32' || global.FAKE_WINDOWS const hasSlashes = isWindows ? /\\|[/]/ : /[/]/ @@ -24,33 +20,30 @@ function npa (arg, where) { let name let spec if (typeof arg === 'object') { - if (arg instanceof Result && (!where || where === arg.where)) { + if (arg instanceof Result && (!where || where === arg.where)) return arg - } else if (arg.name && arg.rawSpec) { + else if (arg.name && arg.rawSpec) return npa.resolve(arg.name, arg.rawSpec, where || arg.where) - } else { + else return npa(arg.raw, where || arg.where) - } } const nameEndsAt = arg[0] === '@' ? arg.slice(1).indexOf('@') + 1 : arg.indexOf('@') const namePart = nameEndsAt > 0 ? arg.slice(0, nameEndsAt) : arg - if (isURL.test(arg)) { + if (isURL.test(arg)) spec = arg - } else if (isGit.test(arg)) { + else if (isGit.test(arg)) spec = `git+ssh://${arg}` - } else if (namePart[0] !== '@' && (hasSlashes.test(namePart) || isFilename.test(namePart))) { + else if (namePart[0] !== '@' && (hasSlashes.test(namePart) || isFilename.test(namePart))) spec = arg - } else if (nameEndsAt > 0) { + else if (nameEndsAt > 0) { name = namePart spec = arg.slice(nameEndsAt + 1) } else { - if (!validatePackageName) validatePackageName = require('validate-npm-package-name') const valid = validatePackageName(arg) - if (valid.validForOldPackages) { + if (valid.validForOldPackages) name = arg - } else { + else spec = arg - } } return resolve(name, spec, where, arg) } @@ -62,27 +55,29 @@ function resolve (name, spec, where, arg) { raw: arg, name: name, rawSpec: spec, - fromArgument: arg != null + fromArgument: arg != null, }) - if (name) res.setName(name) + if (name) + res.setName(name) - if (spec && (isFilespec.test(spec) || /^file:/i.test(spec))) { + if (spec && (isFilespec.test(spec) || /^file:/i.test(spec))) return fromFile(res, where) - } else if (spec && /^npm:/i.test(spec)) { + else if (spec && /^npm:/i.test(spec)) return fromAlias(res, where) - } - if (!HostedGit) HostedGit = require('hosted-git-info') - const hosted = HostedGit.fromUrl(spec, { noGitPlus: true, noCommittish: true }) - if (hosted) { + + const hosted = HostedGit.fromUrl(spec, { + noGitPlus: true, + noCommittish: true, + }) + if (hosted) return fromHostedGit(res, hosted) - } else if (spec && isURL.test(spec)) { + else if (spec && isURL.test(spec)) return fromURL(res) - } else if (spec && (hasSlashes.test(spec) || isFilename.test(spec))) { + else if (spec && (hasSlashes.test(spec) || isFilename.test(spec))) return fromFile(res, where) - } else { + else return fromRegistry(res) - } } function invalidPackageName (name, valid) { @@ -100,29 +95,29 @@ function Result (opts) { this.type = opts.type this.registry = opts.registry this.where = opts.where - if (opts.raw == null) { + if (opts.raw == null) this.raw = opts.name ? opts.name + '@' + opts.rawSpec : opts.rawSpec - } else { + else this.raw = opts.raw - } + this.name = undefined this.escapedName = undefined this.scope = undefined this.rawSpec = opts.rawSpec == null ? '' : opts.rawSpec this.saveSpec = opts.saveSpec this.fetchSpec = opts.fetchSpec - if (opts.name) this.setName(opts.name) + if (opts.name) + this.setName(opts.name) this.gitRange = opts.gitRange this.gitCommittish = opts.gitCommittish this.hosted = opts.hosted } Result.prototype.setName = function (name) { - if (!validatePackageName) validatePackageName = require('validate-npm-package-name') const valid = validatePackageName(name) - if (!valid.validForOldPackages) { + if (!valid.validForOldPackages) throw invalidPackageName(name, valid) - } + this.name = name this.scope = name[0] === '@' ? name.slice(0, name.indexOf('/')) : undefined // scoped packages in couch must have slash url-encoded, e.g. @foo%2Fbar @@ -132,9 +127,11 @@ Result.prototype.setName = function (name) { Result.prototype.toString = function () { const full = [] - if (this.name != null && this.name !== '') full.push(this.name) + if (this.name != null && this.name !== '') + full.push(this.name) const spec = this.saveSpec || this.fetchSpec || this.rawSpec - if (spec != null && spec !== '') full.push(spec) + if (spec != null && spec !== '') + full.push(spec) return full.length ? full.join('@') : this.raw } @@ -148,45 +145,47 @@ function setGitCommittish (res, committish) { if (committish != null && committish.length >= 7 && committish.slice(0, 7) === 'semver:') { res.gitRange = decodeURIComponent(committish.slice(7)) res.gitCommittish = null - } else { + } else res.gitCommittish = committish === '' ? null : committish - } + return res } const isAbsolutePath = /^[/]|^[A-Za-z]:/ function resolvePath (where, spec) { - if (isAbsolutePath.test(spec)) return spec - return path().resolve(where, spec) + if (isAbsolutePath.test(spec)) + return spec + return path.resolve(where, spec) } function isAbsolute (dir) { - if (dir[0] === '/') return true - if (/^[A-Za-z]:/.test(dir)) return true + if (dir[0] === '/') + return true + if (/^[A-Za-z]:/.test(dir)) + return true return false } function fromFile (res, where) { - if (!where) where = process.cwd() + if (!where) + where = process.cwd() res.type = isFilename.test(res.rawSpec) ? 'file' : 'directory' res.where = where const spec = res.rawSpec.replace(/\\/g, '/') .replace(/^file:[/]*([A-Za-z]:)/, '$1') // drive name paths on windows - .replace(/^file:(?:[/]*([~./]))?/, '$1') + .replace(/^file:(?:[/]*(~\/|\.*\/|[/]))?/, '$1') if (/^~[/]/.test(spec)) { // this is needed for windows and for file:~/foo/bar - if (!os) os = require('os') - res.fetchSpec = resolvePath(os.homedir(), spec.slice(2)) + res.fetchSpec = resolvePath(homedir(), spec.slice(2)) res.saveSpec = 'file:' + spec } else { res.fetchSpec = resolvePath(where, spec) - if (isAbsolute(spec)) { + if (isAbsolute(spec)) res.saveSpec = 'file:' + spec - } else { - res.saveSpec = 'file:' + path().relative(where, res.fetchSpec) - } + else + res.saveSpec = 'file:' + path.relative(where, res.fetchSpec) } return res } @@ -217,12 +216,12 @@ function matchGitScp (spec) { const matched = spec.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i) return matched && !matched[1].match(/:[0-9]+\/?.*$/i) && { fetchSpec: matched[1], - gitCommittish: matched[2] == null ? null : matched[2] + gitCommittish: matched[2] == null ? null : matched[2], } } function fromURL (res) { - if (!url) url = require('url') + // eslint-disable-next-line node/no-deprecated-api const urlparse = url.parse(res.rawSpec) res.saveSpec = res.rawSpec // check the protocol, and then see if it's git or not @@ -233,9 +232,10 @@ function fromURL (res) { case 'git+rsync:': case 'git+ftp:': case 'git+file:': - case 'git+ssh:': + case 'git+ssh:': { res.type = 'git' - const match = urlparse.protocol === 'git+ssh:' && matchGitScp(res.rawSpec) + const match = urlparse.protocol === 'git+ssh:' ? matchGitScp(res.rawSpec) + : null if (match) { setGitCommittish(res, match.gitCommittish) res.fetchSpec = match.fetchSpec @@ -251,6 +251,7 @@ function fromURL (res) { res.fetchSpec = url.format(urlparse) } break + } case 'http:': case 'https:': res.type = 'remote' @@ -266,12 +267,12 @@ function fromURL (res) { function fromAlias (res, where) { const subSpec = npa(res.rawSpec.substr(4), where) - if (subSpec.type === 'alias') { + if (subSpec.type === 'alias') throw new Error('nested aliases not supported') - } - if (!subSpec.registry) { + + if (!subSpec.registry) throw new Error('aliases only work for registry deps') - } + res.subSpec = subSpec res.registry = true res.type = 'alias' @@ -282,22 +283,21 @@ function fromAlias (res, where) { function fromRegistry (res) { res.registry = true - const spec = res.rawSpec === '' ? 'latest' : res.rawSpec + const spec = res.rawSpec === '' ? 'latest' : res.rawSpec.trim() // no save spec for registry components as we save based on the fetched // version, not on the argument so this can't compute that. res.saveSpec = null res.fetchSpec = spec - if (!semver) semver = require('semver') const version = semver.valid(spec, true) const range = semver.validRange(spec, true) - if (version) { + if (version) res.type = 'version' - } else if (range) { + else if (range) res.type = 'range' - } else { - if (encodeURIComponent(spec) !== spec) { + else { + if (encodeURIComponent(spec) !== spec) throw invalidTagName(spec) - } + res.type = 'tag' } return res diff --git a/node_modules/npm-package-arg/package.json b/node_modules/npm-package-arg/package.json index ed3b364442c2c..a237928943ccb 100644 --- a/node_modules/npm-package-arg/package.json +++ b/node_modules/npm-package-arg/package.json @@ -1,6 +1,6 @@ { "name": "npm-package-arg", - "version": "8.1.2", + "version": "8.1.4", "description": "Parse the things that can be arguments to `npm install`", "main": "npa.js", "directories": { @@ -15,14 +15,20 @@ "validate-npm-package-name": "^3.0.0" }, "devDependencies": { - "tap": "^14.11.0" + "@npmcli/lint": "^1.0.1", + "tap": "^15.0.9" }, "scripts": { "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "test": "tap", - "snap": "tap" + "snap": "tap", + "npmclilint": "npmcli-lint", + "lint": "npm run npmclilint -- \"*.*js\" \"test/**/*.*js\"", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint --", + "postsnap": "npm run lintfix --" }, "repository": { "type": "git", diff --git a/package-lock.json b/package-lock.json index f2e24facf80fc..a9be6db018103 100644 --- a/package-lock.json +++ b/package-lock.json @@ -124,7 +124,7 @@ "node-gyp": "^7.1.2", "nopt": "^5.0.0", "npm-audit-report": "^2.1.5", - "npm-package-arg": "^8.1.2", + "npm-package-arg": "^8.1.4", "npm-pick-manifest": "^6.1.1", "npm-profile": "^5.0.3", "npm-registry-fetch": "^10.1.2", @@ -5456,9 +5456,9 @@ "inBundle": true }, "node_modules/npm-package-arg": { - "version": "8.1.2", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.2.tgz", - "integrity": "sha512-6Eem455JsSMJY6Kpd3EyWE+n5hC+g9bSyHr9K9U2zqZb7+02+hObQ2c0+8iDk/mNF+8r1MhY44WypKJAkySIYA==", + "version": "8.1.4", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.4.tgz", + "integrity": "sha512-xLokoCFqj/rPdr3LvcdDL6Kj6ipXGEDHD/QGpzwU6/pibYUOXmp5DBmg76yukFyx4ZDbrXNOTn+BPyd8TD4Jlw==", "inBundle": true, "dependencies": { "hosted-git-info": "^4.0.1", @@ -14314,9 +14314,9 @@ "integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==" }, "npm-package-arg": { - "version": "8.1.2", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.2.tgz", - "integrity": "sha512-6Eem455JsSMJY6Kpd3EyWE+n5hC+g9bSyHr9K9U2zqZb7+02+hObQ2c0+8iDk/mNF+8r1MhY44WypKJAkySIYA==", + "version": "8.1.4", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.4.tgz", + "integrity": "sha512-xLokoCFqj/rPdr3LvcdDL6Kj6ipXGEDHD/QGpzwU6/pibYUOXmp5DBmg76yukFyx4ZDbrXNOTn+BPyd8TD4Jlw==", "requires": { "hosted-git-info": "^4.0.1", "semver": "^7.3.4", diff --git a/package.json b/package.json index 7f870a76bcff9..715ab61a522c8 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "node-gyp": "^7.1.2", "nopt": "^5.0.0", "npm-audit-report": "^2.1.5", - "npm-package-arg": "^8.1.2", + "npm-package-arg": "^8.1.4", "npm-pick-manifest": "^6.1.1", "npm-profile": "^5.0.3", "npm-registry-fetch": "^10.1.2",