diff --git a/node_modules/@npmcli/query/lib/index.js b/node_modules/@npmcli/query/lib/index.js index a0d29280ffe9b..3986baeacc3c2 100644 --- a/node_modules/@npmcli/query/lib/index.js +++ b/node_modules/@npmcli/query/lib/index.js @@ -60,14 +60,28 @@ const fixupAttr = astNode => { if (attributeAstNode.value === ':attr') { const appendParts = fixupAttr(attributeAstNode) properties.push(arrayDelimiter, ...appendParts.lookupProperties) - matcher.attribute = appendParts.attributeMatcher.attribute + matcher.qualifiedAttribute = appendParts.attributeMatcher.qualifiedAttribute matcher.operator = appendParts.attributeMatcher.operator matcher.value = appendParts.attributeMatcher.value + + // backwards compatibility + matcher.attribute = appendParts.attributeMatcher.attribute + + if (appendParts.attributeMatcher.insensitive) { + matcher.insensitive = true + } } else { - matcher.attribute = attributeAstNode.qualifiedAttribute + matcher.qualifiedAttribute = attributeAstNode.qualifiedAttribute matcher.operator = attributeAstNode.operator || '' matcher.value = attributeAstNode.value + // backwards compatibility + matcher.attribute = attributeAstNode.qualifiedAttribute + + if (attributeAstNode.insensitive) { + matcher.insensitive = true + } + if (attributeAstNode.type !== 'attribute') { throw Object.assign( new Error('`:attr` pseudo-class expects an attribute matcher as the last value'), diff --git a/node_modules/@npmcli/query/package.json b/node_modules/@npmcli/query/package.json index 6fa6e340fac10..f7f656233e73f 100644 --- a/node_modules/@npmcli/query/package.json +++ b/node_modules/@npmcli/query/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/query", - "version": "1.0.1", + "version": "1.1.0", "description": "npm query parser and tools", "main": "lib/index.js", "scripts": { @@ -50,6 +50,7 @@ "tap": "^16.2.0" }, "dependencies": { + "npm-package-arg": "^9.1.0", "postcss-selector-parser": "^6.0.10", "semver": "^7.3.7" }, diff --git a/node_modules/npm-package-arg/lib/npa.js b/node_modules/npm-package-arg/lib/npa.js index cc1eddaec74b4..61fee0783ecc7 100644 --- a/node_modules/npm-package-arg/lib/npa.js +++ b/node_modules/npm-package-arg/lib/npa.js @@ -9,6 +9,7 @@ const semver = require('semver') const path = global.FAKE_WINDOWS ? require('path').win32 : require('path') const validatePackageName = require('validate-npm-package-name') const { homedir } = require('os') +const log = require('proc-log') const isWindows = process.platform === 'win32' || global.FAKE_WINDOWS const hasSlashes = isWindows ? /\\|[/]/ : /[/]/ @@ -120,6 +121,7 @@ function Result (opts) { } this.gitRange = opts.gitRange this.gitCommittish = opts.gitCommittish + this.gitSubdir = opts.gitSubdir this.hosted = opts.hosted } @@ -155,11 +157,45 @@ Result.prototype.toJSON = function () { } function setGitCommittish (res, committish) { - if (committish != null && committish.length >= 7 && committish.slice(0, 7) === 'semver:') { - res.gitRange = decodeURIComponent(committish.slice(7)) + if (!committish) { res.gitCommittish = null - } else { - res.gitCommittish = committish === '' ? null : committish + return res + } + + // for each :: separated item: + for (const part of committish.split('::')) { + // if the item has no : the n it is a commit-ish + if (!part.includes(':')) { + if (res.gitRange) { + throw new Error('cannot override existing semver range with a committish') + } + if (res.gitCommittish) { + throw new Error('cannot override existing committish with a second committish') + } + res.gitCommittish = part + continue + } + // split on name:value + const [name, value] = part.split(':') + // if name is semver do semver lookup of ref or tag + if (name === 'semver') { + if (res.gitCommittish) { + throw new Error('cannot override existing committish with a semver range') + } + if (res.gitRange) { + throw new Error('cannot override existing semver range with a second semver range') + } + res.gitRange = decodeURIComponent(value) + continue + } + if (name === 'path') { + if (res.gitSubdir) { + throw new Error('cannot override existing path with a second path') + } + res.gitSubdir = `/${value}` + continue + } + log.warn('npm-package-arg', `ignoring unknown key "${name}"`) } return res diff --git a/node_modules/npm-package-arg/package.json b/node_modules/npm-package-arg/package.json index 457f1d8a2f83d..b9729db5d4f14 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": "9.0.2", + "version": "9.1.0", "description": "Parse the things that can be arguments to `npm install`", "main": "./lib/npa.js", "directories": { @@ -12,12 +12,13 @@ ], "dependencies": { "hosted-git-info": "^5.0.0", + "proc-log": "^2.0.1", "semver": "^7.3.5", "validate-npm-package-name": "^4.0.0" }, "devDependencies": { "@npmcli/eslint-config": "^3.0.1", - "@npmcli/template-oss": "3.2.1", + "@npmcli/template-oss": "3.5.0", "tap": "^16.0.1" }, "scripts": { @@ -52,6 +53,6 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "3.2.1" + "version": "3.5.0" } } diff --git a/package-lock.json b/package-lock.json index 605d1a6dab4d9..a31b3476fde3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1042,10 +1042,11 @@ } }, "node_modules/@npmcli/query": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@npmcli/query/-/query-1.0.1.tgz", - "integrity": "sha512-EcRKJ+SxFeCOByE8PnZAVMXqaXm8D+jjIEJD8MbAkPc11MI8XWNKnSL4EzAmygMhvaXMc7OUBCCv9oziUvD09w==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@npmcli/query/-/query-1.1.0.tgz", + "integrity": "sha512-MQWugz9zqVS3w3ccaC3tN6oruM9W8sLPahdUu6No85Rn3EIppMYISdxnxDnYuQbVO1YVaa2kkWJ/jixCWZ59tg==", "dependencies": { + "npm-package-arg": "^9.1.0", "postcss-selector-parser": "^6.0.10", "semver": "^7.3.7" }, @@ -5149,12 +5150,13 @@ "license": "ISC" }, "node_modules/npm-package-arg": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-9.0.2.tgz", - "integrity": "sha512-v/miORuX8cndiOheW8p2moNuPJ7QhcFh9WGlTorruG8hXSA23vMTEp5hTCmDxic0nD8KHhj/NQgFuySD3GYY3g==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-9.1.0.tgz", + "integrity": "sha512-4J0GL+u2Nh6OnhvUKXRr2ZMG4lR8qtLp+kv7UiV00Y+nGiSxtttCyIRHCt5L5BNkXQld/RceYItau3MDOoGiBw==", "inBundle": true, "dependencies": { "hosted-git-info": "^5.0.0", + "proc-log": "^2.0.1", "semver": "^7.3.5", "validate-npm-package-name": "^4.0.0" }, @@ -10039,7 +10041,7 @@ "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^2.0.0", "@npmcli/package-json": "^2.0.0", - "@npmcli/query": "^1.0.1", + "@npmcli/query": "^1.1.0", "@npmcli/run-script": "^4.1.3", "bin-links": "^3.0.0", "cacache": "^16.0.6", diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json index 6f9b4b2d31823..d9d531fbd7d7b 100644 --- a/workspaces/arborist/package.json +++ b/workspaces/arborist/package.json @@ -11,7 +11,7 @@ "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^2.0.0", "@npmcli/package-json": "^2.0.0", - "@npmcli/query": "^1.0.1", + "@npmcli/query": "^1.1.0", "@npmcli/run-script": "^4.1.3", "bin-links": "^3.0.0", "cacache": "^16.0.6",