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-06-02 20:43:03 +0300
committerGar <gar+gh@danger.computer>2021-06-02 20:57:05 +0300
commit54de5c6a4cd593bbbe364132f3f7348586441b31 (patch)
tree408a4cecd90cf74f9cfd4e050139186dd3c6c3ff /node_modules/npm-package-arg
parente864bd3ce8e8467e0f8ebb499dc2daf06143bc33 (diff)
npm-package-arg@8.1.4
* fix: trim whitespace from fetchSpec * fix: handle file: when root directory begins with a special character
Diffstat (limited to 'node_modules/npm-package-arg')
-rw-r--r--node_modules/npm-package-arg/CHANGELOG.md52
-rw-r--r--node_modules/npm-package-arg/npa.js144
-rw-r--r--node_modules/npm-package-arg/package.json12
3 files changed, 81 insertions, 127 deletions
diff --git a/node_modules/npm-package-arg/CHANGELOG.md b/node_modules/npm-package-arg/CHANGELOG.md
deleted file mode 100644
index 390a3a3c4..000000000
--- 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))
-
-<a name="7.0.0"></a>
-# [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.
-
-
-
-<a name="6.1.1"></a>
-## [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))
-
-
-
-<a name="6.1.0"></a>
-# [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 6018dd608..3a01d4d90 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 ed3b36444..a23792894 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",