diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index 92b0b85846804..1ddd85b3d411d 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -86,6 +86,7 @@ graph LR; normalize-package-data-->semver; npm-->abbrev; npm-->cacache; + npm-->fs-minipass; npm-->hosted-git-info; npm-->ini; npm-->init-package-json; @@ -115,6 +116,7 @@ graph LR; npm-->npmcli-fs["@npmcli/fs"]; npm-->npmcli-map-workspaces["@npmcli/map-workspaces"]; npm-->npmcli-package-json["@npmcli/package-json"]; + npm-->npmcli-promise-spawn["@npmcli/promise-spawn"]; npm-->npmcli-run-script["@npmcli/run-script"]; npm-->npmcli-template-oss["@npmcli/template-oss"]; npm-->npmlog; @@ -342,7 +344,9 @@ graph LR; libnpmdiff-->tar; libnpmexec-->bin-links; libnpmexec-->chalk; + libnpmexec-->minify-registry-metadata; libnpmexec-->mkdirp-infer-owner; + libnpmexec-->mkdirp; libnpmexec-->npm-package-arg; libnpmexec-->npmcli-arborist["@npmcli/arborist"]; libnpmexec-->npmcli-ci-detect["@npmcli/ci-detect"]; @@ -472,6 +476,7 @@ graph LR; npm-->columnify; npm-->docs; npm-->fastest-levenshtein; + npm-->fs-minipass; npm-->glob; npm-->graceful-fs; npm-->hosted-git-info; @@ -493,6 +498,7 @@ graph LR; npm-->libnpmversion; npm-->licensee; npm-->make-fetch-happen; + npm-->minimatch; npm-->minipass-pipeline; npm-->minipass; npm-->mkdirp-infer-owner; @@ -515,6 +521,7 @@ graph LR; npm-->npmcli-fs["@npmcli/fs"]; npm-->npmcli-map-workspaces["@npmcli/map-workspaces"]; npm-->npmcli-package-json["@npmcli/package-json"]; + npm-->npmcli-promise-spawn["@npmcli/promise-spawn"]; npm-->npmcli-run-script["@npmcli/run-script"]; npm-->npmcli-template-oss["@npmcli/template-oss"]; npm-->npmlog; diff --git a/docs/.eslintrc.local.json b/docs/.eslintrc.local.json new file mode 100644 index 0000000000000..ed467baedee00 --- /dev/null +++ b/docs/.eslintrc.local.json @@ -0,0 +1 @@ +{ "rules": { "import/no-extraneous-dependencies": "off" } } diff --git a/docs/package.json b/docs/package.json index ba913b1ea6844..98fe8becd8318 100644 --- a/docs/package.json +++ b/docs/package.json @@ -21,7 +21,7 @@ }, "devDependencies": { "@mdx-js/mdx": "^1.6.22", - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/fs": "^2.1.0", "@npmcli/promise-spawn": "^3.0.0", "@npmcli/template-oss": "3.5.0", diff --git a/lib/commands/audit.js b/lib/commands/audit.js index 779bc22fc6aaf..6ec870f03a8a5 100644 --- a/lib/commands/audit.js +++ b/lib/commands/audit.js @@ -178,11 +178,12 @@ class VerifySignatures { let name = edge.name try { name = npa(edge.spec).subSpec.name - } catch (_) { + } catch { + // leave it as edge.name } try { return npa(`${name}@${edge.spec}`) - } catch (_) { + } catch { // Skip packages with invalid spec } } diff --git a/lib/commands/edit.js b/lib/commands/edit.js index 0256f4f3a6f01..67ac32e017184 100644 --- a/lib/commands/edit.js +++ b/lib/commands/edit.js @@ -58,11 +58,16 @@ class Edit extends BaseCommand { } const [bin, ...args] = this.npm.config.get('editor').split(/\s+/) const editor = cp.spawn(bin, [...args, dir], { stdio: 'inherit' }) - editor.on('exit', (code) => { + editor.on('exit', async (code) => { if (code) { return reject(new Error(`editor process exited with code: ${code}`)) } - this.npm.exec('rebuild', [dir]).catch(reject).then(resolve) + try { + await this.npm.exec('rebuild', [dir]) + } catch (err) { + reject(err) + } + resolve() }) }) }) diff --git a/lib/commands/org.js b/lib/commands/org.js index 599b4b9c8758a..f49556c8d6a19 100644 --- a/lib/commands/org.js +++ b/lib/commands/org.js @@ -50,7 +50,7 @@ class Org extends BaseCommand { }) } - set (org, user, role, opts) { + async set (org, user, role, opts) { role = role || 'developer' if (!org) { throw new Error('First argument `orgname` is required.') @@ -67,27 +67,26 @@ class Org extends BaseCommand { ) } - return liborg.set(org, user, role, opts).then(memDeets => { - if (opts.json) { - this.npm.output(JSON.stringify(memDeets, null, 2)) - } else if (opts.parseable) { - this.npm.output(['org', 'orgsize', 'user', 'role'].join('\t')) - this.npm.output( - [memDeets.org.name, memDeets.org.size, memDeets.user, memDeets.role].join('\t') - ) - } else if (!this.npm.silent) { - this.npm.output( - `Added ${memDeets.user} as ${memDeets.role} to ${memDeets.org.name}. You now have ${ + const memDeets = await liborg.set(org, user, role, opts) + if (opts.json) { + this.npm.output(JSON.stringify(memDeets, null, 2)) + } else if (opts.parseable) { + this.npm.output(['org', 'orgsize', 'user', 'role'].join('\t')) + this.npm.output( + [memDeets.org.name, memDeets.org.size, memDeets.user, memDeets.role].join('\t') + ) + } else if (!this.npm.silent) { + this.npm.output( + `Added ${memDeets.user} as ${memDeets.role} to ${memDeets.org.name}. You now have ${ memDeets.org.size } member${memDeets.org.size === 1 ? '' : 's'} in this org.` - ) - } + ) + } - return memDeets - }) + return memDeets } - rm (org, user, opts) { + async rm (org, user, opts) { if (!org) { throw new Error('First argument `orgname` is required.') } @@ -96,68 +95,62 @@ class Org extends BaseCommand { throw new Error('Second argument `username` is required.') } - return liborg - .rm(org, user, opts) - .then(() => { - return liborg.ls(org, opts) - }) - .then(roster => { - user = user.replace(/^[~@]?/, '') - org = org.replace(/^[~@]?/, '') - const userCount = Object.keys(roster).length - if (opts.json) { - this.npm.output( - JSON.stringify({ - user, - org, - userCount, - deleted: true, - }) - ) - } else if (opts.parseable) { - this.npm.output(['user', 'org', 'userCount', 'deleted'].join('\t')) - this.npm.output([user, org, userCount, true].join('\t')) - } else if (!this.npm.silent) { - this.npm.output( - `Successfully removed ${user} from ${org}. You now have ${userCount} member${ - userCount === 1 ? '' : 's' - } in this org.` - ) - } - }) + await liborg.rm(org, user, opts) + const roster = await liborg.ls(org, opts) + user = user.replace(/^[~@]?/, '') + org = org.replace(/^[~@]?/, '') + const userCount = Object.keys(roster).length + if (opts.json) { + this.npm.output( + JSON.stringify({ + user, + org, + userCount, + deleted: true, + }) + ) + } else if (opts.parseable) { + this.npm.output(['user', 'org', 'userCount', 'deleted'].join('\t')) + this.npm.output([user, org, userCount, true].join('\t')) + } else if (!this.npm.silent) { + this.npm.output( + `Successfully removed ${user} from ${org}. You now have ${userCount} member${ + userCount === 1 ? '' : 's' + } in this org.` + ) + } } - ls (org, user, opts) { + async ls (org, user, opts) { if (!org) { throw new Error('First argument `orgname` is required.') } - return liborg.ls(org, opts).then(roster => { - if (user) { - const newRoster = {} - if (roster[user]) { - newRoster[user] = roster[user] - } - - roster = newRoster + let roster = await liborg.ls(org, opts) + if (user) { + const newRoster = {} + if (roster[user]) { + newRoster[user] = roster[user] } - if (opts.json) { - this.npm.output(JSON.stringify(roster, null, 2)) - } else if (opts.parseable) { - this.npm.output(['user', 'role'].join('\t')) - Object.keys(roster).forEach(user => { - this.npm.output([user, roster[user]].join('\t')) + + roster = newRoster + } + if (opts.json) { + this.npm.output(JSON.stringify(roster, null, 2)) + } else if (opts.parseable) { + this.npm.output(['user', 'role'].join('\t')) + Object.keys(roster).forEach(user => { + this.npm.output([user, roster[user]].join('\t')) + }) + } else if (!this.npm.silent) { + const table = new Table({ head: ['user', 'role'] }) + Object.keys(roster) + .sort() + .forEach(user => { + table.push([user, roster[user]]) }) - } else if (!this.npm.silent) { - const table = new Table({ head: ['user', 'role'] }) - Object.keys(roster) - .sort() - .forEach(user => { - table.push([user, roster[user]]) - }) - this.npm.output(table.toString()) - } - }) + this.npm.output(table.toString()) + } } } module.exports = Org diff --git a/lib/commands/outdated.js b/lib/commands/outdated.js index 042b776f71e0d..9e2060658ed72 100644 --- a/lib/commands/outdated.js +++ b/lib/commands/outdated.js @@ -196,6 +196,7 @@ class Outdated extends ArboristWorkspaceCmd { try { alias = npa(edge.spec).subSpec } catch (err) { + // ignore errors, no alias } const spec = npa(alias ? alias.name : edge.name) const node = edge.to || edge diff --git a/lib/commands/token.js b/lib/commands/token.js index cf3b8cbee53a4..de8e61101d8ac 100644 --- a/lib/commands/token.js +++ b/lib/commands/token.js @@ -140,32 +140,27 @@ class Token extends BaseCommand { const cidr = conf.cidr const readonly = conf.readOnly - return readUserInfo - .password() - .then(password => { - const validCIDR = this.validateCIDRList(cidr) - log.info('token', 'creating') - return pulseTillDone.withPromise( - otplease(this.npm, conf, conf => { - return profile.createToken(password, readonly, validCIDR, conf) - }) - ) - }) - .then(result => { - delete result.key - delete result.updated - if (conf.json) { - this.npm.output(JSON.stringify(result)) - } else if (conf.parseable) { - Object.keys(result).forEach(k => this.npm.output(k + '\t' + result[k])) - } else { - const table = new Table() - for (const k of Object.keys(result)) { - table.push({ [chalk.bold(k)]: String(result[k]) }) - } - this.npm.output(table.toString()) - } + const password = await readUserInfo.password() + const validCIDR = this.validateCIDRList(cidr) + log.info('token', 'creating') + const result = await pulseTillDone.withPromise( + otplease(this.npm, conf, conf => { + return profile.createToken(password, readonly, validCIDR, conf) }) + ) + delete result.key + delete result.updated + if (conf.json) { + this.npm.output(JSON.stringify(result)) + } else if (conf.parseable) { + Object.keys(result).forEach(k => this.npm.output(k + '\t' + result[k])) + } else { + const table = new Table() + for (const k of Object.keys(result)) { + table.push({ [chalk.bold(k)]: String(result[k]) }) + } + this.npm.output(table.toString()) + } } config () { diff --git a/lib/npm.js b/lib/npm.js index 66111cab89a84..b116ec5cc68a4 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -112,6 +112,7 @@ class Npm extends EventEmitter { // this is async but we dont await it, since its ok if it doesnt // finish before the command finishes running. it uses command and argv // so it must be initiated here, after the command name is set + // eslint-disable-next-line promise/catch-or-return updateNotifier(this).then((msg) => (this.updateNotification = msg)) // Options are prefixed by a hyphen-minus (-, \u2d). @@ -173,16 +174,15 @@ class Npm extends EventEmitter { async load () { if (!this.#loadPromise) { - this.#loadPromise = this.time('npm:load', () => this[_load]().catch(er => er).then((er) => { - this.loadErr = er - if (!er) { - if (this.config.get('force')) { - log.warn('using --force', 'Recommended protections disabled.') - } - } else { + this.#loadPromise = this.time('npm:load', async () => { + await this[_load]().catch((er) => { + this.loadErr = er throw er + }) + if (this.config.get('force')) { + log.warn('using --force', 'Recommended protections disabled.') } - })) + }) } return this.#loadPromise } @@ -229,7 +229,9 @@ class Npm extends EventEmitter { const node = this.time('npm:load:whichnode', () => { try { return which.sync(process.argv[0]) - } catch {} // TODO should we throw here? + } catch { + // TODO should we throw here? + } }) if (node && node.toUpperCase() !== process.execPath.toUpperCase()) { diff --git a/lib/utils/queryable.js b/lib/utils/queryable.js index ceb06bdccd103..7c5bb7fe87baf 100644 --- a/lib/utils/queryable.js +++ b/lib/utils/queryable.js @@ -148,7 +148,9 @@ const setter = ({ data, key, value, force }) => { let maybeIndex = Number.NaN try { maybeIndex = Number(_key) - } catch (err) {} + } catch { + // leave it NaN + } if (!Number.isNaN(maybeIndex)) { _key = maybeIndex } diff --git a/node_modules/.gitignore b/node_modules/.gitignore index aa43a2716ee15..bf2a67651159b 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -59,6 +59,7 @@ __pycache__ /@npmcli/eslint-config /@npmcli/template-oss /@types/hast +/@types/json5 /@types/mdast /@types/parse5 /@types/unist @@ -73,6 +74,8 @@ __pycache__ /arg /argparse /array-find-index +/array-includes +/array.prototype.flat /asn1 /assert-plus /async-hook-domain @@ -137,13 +140,18 @@ __pycache__ /ecc-jsbn /end-of-stream /es-abstract +/es-shim-unscopables /es-to-primitive /es6-error /escape-string-regexp /escodegen /eslint +/eslint-import-resolver-node +/eslint-module-utils /eslint-plugin-es +/eslint-plugin-import /eslint-plugin-node +/eslint-plugin-promise /eslint-scope /eslint-utils /eslint-visitor-keys @@ -164,6 +172,7 @@ __pycache__ /file-uri-to-path /fill-range /find-cache-dir +/find-up /findit /flat-cache /flatted @@ -178,7 +187,9 @@ __pycache__ /fs-exists-cached /fsevents /function-loop +/function.prototype.name /functional-red-black-tree +/functions-have-names /gensync /get-caller-file /get-intrinsic @@ -192,6 +203,7 @@ __pycache__ /har-schema /har-validator /has-bigints +/has-property-descriptors /has-symbols /has-tostringtag /hasha @@ -263,6 +275,7 @@ __pycache__ /levn /libtap /licensee +/locate-path /lodash /lodash.clonedeep /lodash.flattendeep @@ -304,13 +317,18 @@ __pycache__ /object-keys /object.assign /object.getownpropertydescriptors +/object.values /optionator /own-or /own-or-env +/p-limit +/p-locate +/p-try /package-hash /parent-module /parse-entities /parse5 +/path-exists /path-key /path-parse /performance-now @@ -331,6 +349,7 @@ __pycache__ /rc /read-package-tree /readdirp +/regexp.prototype.flags /regexpp /release-zalgo /remark-footnotes @@ -368,6 +387,7 @@ __pycache__ /state-toggle /string.prototype.trimend /string.prototype.trimstart +/strip-bom /strip-json-comments /style-to-object /supports-preserve-symlinks-flag @@ -389,6 +409,7 @@ __pycache__ /trivial-deferred /trough /ts-node +/tsconfig-paths /tunnel-agent /tweetnacl /type-check diff --git a/package-lock.json b/package-lock.json index 613148fdaea98..ce443bce578ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@npmcli/fs", "@npmcli/map-workspaces", "@npmcli/package-json", + "@npmcli/promise-spawn", "@npmcli/run-script", "abbrev", "archy", @@ -25,6 +26,7 @@ "cli-table3", "columnify", "fastest-levenshtein", + "fs-minipass", "glob", "graceful-fs", "hosted-git-info", @@ -44,6 +46,7 @@ "libnpmteam", "libnpmversion", "make-fetch-happen", + "minimatch", "minipass", "minipass-pipeline", "mkdirp", @@ -164,9 +167,12 @@ "npx": "bin/npx-cli.js" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", + "@npmcli/promise-spawn": "^3.0.0", "@npmcli/template-oss": "3.5.0", + "fs-minipass": "^2.1.0", "licensee": "^8.2.0", + "minimatch": "^5.1.0", "nock": "^13.2.4", "spawk": "^1.7.1", "tap": "^16.0.1" @@ -180,7 +186,7 @@ "license": "ISC", "devDependencies": { "@mdx-js/mdx": "^1.6.22", - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/fs": "^2.1.0", "@npmcli/promise-spawn": "^3.0.0", "@npmcli/template-oss": "3.5.0", @@ -578,19 +584,20 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "1.2.1", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.0.tgz", + "integrity": "sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==", "dev": true, - "license": "MIT", "peer": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.3.1", - "globals": "^13.9.0", + "espree": "^9.3.2", + "globals": "^13.15.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "engines": { @@ -599,8 +606,9 @@ }, "node_modules/@eslint/eslintrc/node_modules/argparse": { "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true, - "license": "Python-2.0", "peer": true }, "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { @@ -615,9 +623,10 @@ } }, "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.13.0", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, - "license": "MIT", "peer": true, "dependencies": { "type-fest": "^0.20.2" @@ -631,8 +640,9 @@ }, "node_modules/@eslint/eslintrc/node_modules/js-yaml": { "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, - "license": "MIT", "peer": true, "dependencies": { "argparse": "^2.0.1" @@ -656,8 +666,9 @@ }, "node_modules/@eslint/eslintrc/node_modules/type-fest": { "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true, - "license": "(MIT OR CC0-1.0)", "peer": true, "engines": { "node": ">=10" @@ -897,9 +908,9 @@ } }, "node_modules/@npmcli/eslint-config": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@npmcli/eslint-config/-/eslint-config-3.0.1.tgz", - "integrity": "sha512-a5tr7iOeVePL/GOZyFNbG0+dUH0H2QYHmrRGCOE7y+qA7OrMDDOiHe/Wt1PiSDo+Y9IxNKuxhj6TY01Hq56QKg==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@npmcli/eslint-config/-/eslint-config-3.1.0.tgz", + "integrity": "sha512-t+FYG0KSpEAfz7CUHW/S2V/01bRuFCXmBxRBrhV9mp01qFXtrKa3IgBhmxM0uQ18v2YBT4+5r4P/Xn3mxB33IA==", "dev": true, "dependencies": { "which": "^2.0.2" @@ -908,11 +919,13 @@ "lint": "bin/index.js" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" }, "peerDependencies": { - "eslint": ">= 8", - "eslint-plugin-node": "^11.1.0" + "eslint": "^8.13.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^6.0.0" } }, "node_modules/@npmcli/fs": { @@ -1128,6 +1141,13 @@ "@types/unist": "*" } }, + "node_modules/@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true, + "peer": true + }, "node_modules/@types/mdast": { "version": "3.0.10", "dev": true, @@ -1178,8 +1198,9 @@ }, "node_modules/acorn-jsx": { "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, - "license": "MIT", "peer": true, "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" @@ -1336,6 +1357,45 @@ "node": ">=0.10.0" } }, + "node_modules/array-includes": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.5.tgz", + "integrity": "sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ==", + "dev": true, + "peer": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5", + "get-intrinsic": "^1.1.1", + "is-string": "^1.0.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flat": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.0.tgz", + "integrity": "sha512-12IUEkHsAhA4DY5s0FPgNXIdc8VRSqD9Zp78a5au9abH/SOBrsp082JOWFNTjkMozh8mqcdiKuaLGhPeYztxSw==", + "dev": true, + "peer": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.2", + "es-shim-unscopables": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/asap": { "version": "2.0.6", "inBundle": true, @@ -1676,8 +1736,9 @@ }, "node_modules/callsites": { "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true, - "license": "MIT", "peer": true, "engines": { "node": ">=6" @@ -2178,14 +2239,19 @@ } }, "node_modules/define-properties": { - "version": "1.1.3", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz", + "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==", "dev": true, - "license": "MIT", "dependencies": { - "object-keys": "^1.0.12" + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" }, "engines": { "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/delayed-stream": { @@ -2330,30 +2396,34 @@ "license": "MIT" }, "node_modules/es-abstract": { - "version": "1.19.2", + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.1.tgz", + "integrity": "sha512-WEm2oBhfoI2sImeM4OF2zE2V3BYdSF+KnSi9Sidz51fQHd7+JuF8Xgcj9/0o+OWeIeIS/MiuNnlruQrJf16GQA==", "dev": true, - "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", + "function.prototype.name": "^1.1.5", "get-intrinsic": "^1.1.1", "get-symbol-description": "^1.0.0", "has": "^1.0.3", + "has-property-descriptors": "^1.0.0", "has-symbols": "^1.0.3", "internal-slot": "^1.0.3", "is-callable": "^1.2.4", "is-negative-zero": "^2.0.2", "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.1", + "is-shared-array-buffer": "^1.0.2", "is-string": "^1.0.7", "is-weakref": "^1.0.2", "object-inspect": "^1.12.0", "object-keys": "^1.1.1", "object.assign": "^4.1.2", - "string.prototype.trimend": "^1.0.4", - "string.prototype.trimstart": "^1.0.4", - "unbox-primitive": "^1.0.1" + "regexp.prototype.flags": "^1.4.3", + "string.prototype.trimend": "^1.0.5", + "string.prototype.trimstart": "^1.0.5", + "unbox-primitive": "^1.0.2" }, "engines": { "node": ">= 0.4" @@ -2362,6 +2432,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/es-shim-unscopables": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", + "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", + "dev": true, + "peer": true, + "dependencies": { + "has": "^1.0.3" + } + }, "node_modules/es-to-primitive": { "version": "1.2.1", "dev": true, @@ -2472,12 +2552,13 @@ } }, "node_modules/eslint": { - "version": "8.12.0", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.20.0.tgz", + "integrity": "sha512-d4ixhz5SKCa1D6SCPrivP7yYVi7nyD6A4vs6HIAul9ujBzcEmZVM3/0NN/yu5nKhmO1wjp5xQ46iRfmDGlOviA==", "dev": true, - "license": "MIT", "peer": true, "dependencies": { - "@eslint/eslintrc": "^1.2.1", + "@eslint/eslintrc": "^1.3.0", "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -2488,14 +2569,14 @@ "eslint-scope": "^7.1.1", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", + "espree": "^9.3.2", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", "functional-red-black-tree": "^1.0.1", "glob-parent": "^6.0.1", - "globals": "^13.6.0", + "globals": "^13.15.0", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", @@ -2504,7 +2585,7 @@ "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", "regexpp": "^3.2.0", @@ -2523,6 +2604,51 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-import-resolver-node": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz", + "integrity": "sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==", + "dev": true, + "peer": true, + "dependencies": { + "debug": "^3.2.7", + "resolve": "^1.20.0" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "peer": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-module-utils": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz", + "integrity": "sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==", + "dev": true, + "peer": true, + "dependencies": { + "debug": "^3.2.7", + "find-up": "^2.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/eslint-module-utils/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "peer": true, + "dependencies": { + "ms": "^2.1.1" + } + }, "node_modules/eslint-plugin-es": { "version": "3.0.1", "dev": true, @@ -2542,6 +2668,88 @@ "eslint": ">=4.19.1" } }, + "node_modules/eslint-plugin-import": { + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", + "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==", + "dev": true, + "peer": true, + "dependencies": { + "array-includes": "^3.1.4", + "array.prototype.flat": "^1.2.5", + "debug": "^2.6.9", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.6", + "eslint-module-utils": "^2.7.3", + "has": "^1.0.3", + "is-core-module": "^2.8.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.values": "^1.1.5", + "resolve": "^1.22.0", + "tsconfig-paths": "^3.14.1" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" + } + }, + "node_modules/eslint-plugin-import/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "peer": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "peer": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/eslint-plugin-import/node_modules/doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "peer": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eslint-plugin-import/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "peer": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/eslint-plugin-import/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true, + "peer": true + }, "node_modules/eslint-plugin-node": { "version": "11.1.0", "dev": true, @@ -2595,6 +2803,19 @@ "semver": "bin/semver.js" } }, + "node_modules/eslint-plugin-promise": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.0.0.tgz", + "integrity": "sha512-7GPezalm5Bfi/E22PnQxDWH2iW9GTvAlUNTztemeHb6c1BniSyoeTrM87JkC0wYdi6aQrZX9p2qEiAno8aTcbw==", + "dev": true, + "peer": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, "node_modules/eslint-scope": { "version": "7.1.1", "dev": true, @@ -2634,8 +2855,9 @@ }, "node_modules/eslint-visitor-keys": { "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true, - "license": "Apache-2.0", "peer": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -2698,9 +2920,10 @@ } }, "node_modules/eslint/node_modules/globals": { - "version": "13.13.0", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, - "license": "MIT", "peer": true, "dependencies": { "type-fest": "^0.20.2" @@ -2739,8 +2962,9 @@ }, "node_modules/eslint/node_modules/type-fest": { "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true, - "license": "(MIT OR CC0-1.0)", "peer": true, "engines": { "node": ">=10" @@ -2750,13 +2974,14 @@ } }, "node_modules/espree": { - "version": "9.3.1", + "version": "9.3.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.2.tgz", + "integrity": "sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA==", "dev": true, - "license": "BSD-2-Clause", "peer": true, "dependencies": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", + "acorn": "^8.7.1", + "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -2764,9 +2989,10 @@ } }, "node_modules/espree/node_modules/acorn": { - "version": "8.7.0", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz", + "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==", "dev": true, - "license": "MIT", "peer": true, "bin": { "acorn": "bin/acorn" @@ -2996,6 +3222,19 @@ "node": ">=8" } }, + "node_modules/find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ==", + "dev": true, + "peer": true, + "dependencies": { + "locate-path": "^2.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/findit": { "version": "2.0.0", "dev": true, @@ -3126,8 +3365,9 @@ }, "node_modules/fs-minipass": { "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", "inBundle": true, - "license": "ISC", "dependencies": { "minipass": "^3.0.0" }, @@ -3163,12 +3403,39 @@ "integrity": "sha512-ktIR+O6i/4h+j/ZhZJNdzeI4i9lEPeEK6UPR2EVyTVBqOwcU3Za9xYKLH64ZR9HmcROyRrOkizNyjjtWJzDDkQ==", "dev": true }, + "node_modules/function.prototype.name": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz", + "integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.0", + "functions-have-names": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/functional-red-black-tree": { "version": "1.0.1", "dev": true, "license": "MIT", "peer": true }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/gauge": { "version": "4.0.4", "inBundle": true, @@ -3364,9 +3631,10 @@ } }, "node_modules/has-bigints": { - "version": "1.0.1", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", "dev": true, - "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -3379,6 +3647,18 @@ "node": ">=8" } }, + "node_modules/has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/has-symbols": { "version": "1.0.3", "dev": true, @@ -3667,8 +3947,9 @@ }, "node_modules/import-fresh": { "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, - "license": "MIT", "peer": true, "dependencies": { "parent-module": "^1.0.0", @@ -3799,8 +4080,9 @@ }, "node_modules/is-bigint": { "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", + "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", "dev": true, - "license": "MIT", "dependencies": { "has-bigints": "^1.0.1" }, @@ -3821,8 +4103,9 @@ }, "node_modules/is-boolean-object": { "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", + "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", "dev": true, - "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "has-tostringtag": "^1.0.0" @@ -3974,9 +4257,10 @@ } }, "node_modules/is-number-object": { - "version": "1.0.6", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", "dev": true, - "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" }, @@ -4016,9 +4300,13 @@ } }, "node_modules/is-shared-array-buffer": { - "version": "1.0.1", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", "dev": true, - "license": "MIT", + "dependencies": { + "call-bind": "^1.0.2" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -4562,6 +4850,20 @@ "semver": "bin/semver.js" } }, + "node_modules/locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA==", + "dev": true, + "peer": true, + "dependencies": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/lodash": { "version": "4.17.21", "dev": true, @@ -4775,8 +5077,9 @@ }, "node_modules/minify-registry-metadata": { "version": "2.2.0", - "dev": true, - "license": "ISC" + "resolved": "https://registry.npmjs.org/minify-registry-metadata/-/minify-registry-metadata-2.2.0.tgz", + "integrity": "sha512-kBVcTfDnYx9nL1U+6l6drCrZHPlkEoniLLud//nXxXvJAx0D7P4IHU2vkcCrLozoAPomiIX/CzaEXFm1CmT/8A==", + "dev": true }, "node_modules/minimatch": { "version": "5.1.0", @@ -4891,8 +5194,9 @@ }, "node_modules/mkdirp": { "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", "inBundle": true, - "license": "MIT", "bin": { "mkdirp": "bin/cmd.js" }, @@ -5522,6 +5826,24 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/object.values": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.5.tgz", + "integrity": "sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg==", + "dev": true, + "peer": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/once": { "version": "1.4.0", "inBundle": true, @@ -5570,6 +5892,32 @@ "own-or": "^1.0.0" } }, + "node_modules/p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "peer": true, + "dependencies": { + "p-try": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg==", + "dev": true, + "peer": true, + "dependencies": { + "p-limit": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/p-map": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", @@ -5585,6 +5933,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww==", + "dev": true, + "peer": true, + "engines": { + "node": ">=4" + } + }, "node_modules/package-hash": { "version": "4.0.0", "dev": true, @@ -5636,8 +5994,9 @@ }, "node_modules/parent-module": { "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, - "license": "MIT", "peer": true, "dependencies": { "callsites": "^3.0.0" @@ -5681,6 +6040,16 @@ "dev": true, "license": "MIT" }, + "node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", + "dev": true, + "peer": true, + "engines": { + "node": ">=4" + } + }, "node_modules/path-is-absolute": { "version": "1.0.1", "inBundle": true, @@ -6232,6 +6601,23 @@ "node": ">=8.10.0" } }, + "node_modules/regexp.prototype.flags": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz", + "integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "functions-have-names": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/regexpp": { "version": "3.2.0", "dev": true, @@ -6435,8 +6821,9 @@ }, "node_modules/resolve-from": { "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, - "license": "MIT", "peer": true, "engines": { "node": ">=4" @@ -6923,24 +7310,28 @@ } }, "node_modules/string.prototype.trimend": { - "version": "1.0.4", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz", + "integrity": "sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog==", "dev": true, - "license": "MIT", "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/string.prototype.trimstart": { - "version": "1.0.4", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz", + "integrity": "sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg==", "dev": true, - "license": "MIT", "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -6957,10 +7348,21 @@ "node": ">=8" } }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "peer": true, + "engines": { + "node": ">=4" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, - "license": "MIT", "peer": true, "engines": { "node": ">=8" @@ -9290,6 +9692,32 @@ "node": ">=0.3.1" } }, + "node_modules/tsconfig-paths": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", + "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", + "dev": true, + "peer": true, + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.1", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "node_modules/tsconfig-paths/node_modules/json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "peer": true, + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, "node_modules/tunnel-agent": { "version": "0.6.0", "dev": true, @@ -9356,13 +9784,14 @@ } }, "node_modules/unbox-primitive": { - "version": "1.0.1", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "dev": true, - "license": "MIT", "dependencies": { - "function-bind": "^1.1.1", - "has-bigints": "^1.0.1", - "has-symbols": "^1.0.2", + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", "which-boxed-primitive": "^1.0.2" }, "funding": { @@ -9763,8 +10192,9 @@ }, "node_modules/which-boxed-primitive": { "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", "dev": true, - "license": "MIT", "dependencies": { "is-bigint": "^1.0.1", "is-boolean-object": "^1.1.0", @@ -10039,7 +10469,7 @@ "version": "1.0.0", "license": "ISC", "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/promise-spawn": "^3.0.0", "@npmcli/template-oss": "3.5.0", "minify-registry-metadata": "^2.2.0", @@ -10097,7 +10527,7 @@ "arborist": "bin/index.js" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "benchmark": "^2.1.4", "chalk": "^4.1.0", @@ -10120,7 +10550,7 @@ "npm-registry-fetch": "^13.0.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "nock": "^13.2.4", "tap": "^16.0.1" @@ -10143,7 +10573,7 @@ "tar": "^6.1.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "tap": "^16.0.1" }, @@ -10171,9 +10601,11 @@ "walk-up-path": "^1.0.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "bin-links": "^3.0.0", + "minify-registry-metadata": "^2.2.0", + "mkdirp": "^1.0.4", "tap": "^16.0.1" }, "engines": { @@ -10187,7 +10619,7 @@ "@npmcli/arborist": "^5.0.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "tap": "^16.0.1" }, @@ -10203,7 +10635,7 @@ "npm-registry-fetch": "^13.0.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "nock": "^13.2.4", "tap": "^16.0.1" @@ -10220,7 +10652,7 @@ "npm-registry-fetch": "^13.0.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "minipass": "^3.1.1", "nock": "^13.2.4", @@ -10239,7 +10671,7 @@ "pacote": "^13.6.1" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "nock": "^13.0.7", "tap": "^16.0.1" @@ -10259,7 +10691,7 @@ "ssri": "^9.0.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "libnpmpack": "^4.0.0", "lodash.clonedeep": "^4.5.0", @@ -10277,7 +10709,7 @@ "npm-registry-fetch": "^13.0.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "nock": "^13.2.4", "tap": "^16.0.1" @@ -10294,7 +10726,7 @@ "npm-registry-fetch": "^13.0.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "nock": "^13.2.4", "tap": "^16.0.1" @@ -10314,7 +10746,7 @@ "semver": "^7.3.7" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "require-inject": "^1.4.4", "tap": "^16.0.1" diff --git a/package.json b/package.json index f631c9f0683b2..e86e488926e04 100644 --- a/package.json +++ b/package.json @@ -135,6 +135,7 @@ "@npmcli/fs", "@npmcli/map-workspaces", "@npmcli/package-json", + "@npmcli/promise-spawn", "@npmcli/run-script", "abbrev", "archy", @@ -145,6 +146,7 @@ "cli-table3", "columnify", "fastest-levenshtein", + "fs-minipass", "glob", "graceful-fs", "hosted-git-info", @@ -164,6 +166,7 @@ "libnpmteam", "libnpmversion", "make-fetch-happen", + "minimatch", "minipass", "minipass-pipeline", "mkdirp", @@ -201,9 +204,12 @@ "write-file-atomic" ], "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", + "@npmcli/promise-spawn": "^3.0.0", "@npmcli/template-oss": "3.5.0", + "fs-minipass": "^2.1.0", "licensee": "^8.2.0", + "minimatch": "^5.1.0", "nock": "^13.2.4", "spawk": "^1.7.1", "tap": "^16.0.1" diff --git a/scripts/bundle-and-gitignore-deps.js b/scripts/bundle-and-gitignore-deps.js index 93d8d89617eb4..cdfa0c3bcff3b 100644 --- a/scripts/bundle-and-gitignore-deps.js +++ b/scripts/bundle-and-gitignore-deps.js @@ -8,7 +8,10 @@ const bundle = [] const arb = new Arborist({ path: resolve(__dirname, '..') }) const shouldIgnore = [] +// disabling to get linting to pass, this file is going away soon +// eslint-disable-next-line arb.loadVirtual().then(tree => { + // eslint-disable-next-line for (const node of tree.children.values()) { const has = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key) const nonProdWorkspace = diff --git a/scripts/dependency-graph.js b/scripts/dependency-graph.js index 318b9f39b4292..1f18307582fd0 100644 --- a/scripts/dependency-graph.js +++ b/scripts/dependency-graph.js @@ -168,7 +168,9 @@ const iterate = function (node, dependedBy, annotations, onlyOurs) { main().then(() => { process.exit(0) + return 0 }).catch(err => { console.error(err) process.exit(1) + return 1 }) diff --git a/smoke-tests/package.json b/smoke-tests/package.json index b06404681e347..40e794e82e03c 100644 --- a/smoke-tests/package.json +++ b/smoke-tests/package.json @@ -20,7 +20,7 @@ "directory": "smoke-tests" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/promise-spawn": "^3.0.0", "@npmcli/template-oss": "3.5.0", "minify-registry-metadata": "^2.2.0", diff --git a/test/lib/commands/shrinkwrap.js b/test/lib/commands/shrinkwrap.js index e3fc1f9356705..812a9e23ec7f6 100644 --- a/test/lib/commands/shrinkwrap.js +++ b/test/lib/commands/shrinkwrap.js @@ -13,7 +13,9 @@ t.formatSnapshot = obj => (k, v) => { try { return JSON.parse(v) - } catch {} + } catch { + // leave invalid JSON as a string + } return v }, 2 diff --git a/workspaces/arborist/bin/index.js b/workspaces/arborist/bin/index.js index 0c1e98445341f..ff356fafab7c3 100755 --- a/workspaces/arborist/bin/index.js +++ b/workspaces/arborist/bin/index.js @@ -99,6 +99,7 @@ for (const file of commandFiles) { if (bin.loglevel !== 'silent') { console[process.exitCode ? 'error' : 'log'](r) } + return r }) } } diff --git a/workspaces/arborist/lib/arborist/build-ideal-tree.js b/workspaces/arborist/lib/arborist/build-ideal-tree.js index 945bae56b63de..31a4e8c821a8c 100644 --- a/workspaces/arborist/lib/arborist/build-ideal-tree.js +++ b/workspaces/arborist/lib/arborist/build-ideal-tree.js @@ -378,6 +378,7 @@ Try using the package name instead, e.g: this.idealTree = tree this.virtualTree = null process.emit('timeEnd', 'idealTree:init') + return tree }) } @@ -531,12 +532,12 @@ Try using the package name instead, e.g: // This returns a promise because we might not have the name yet, // and need to call pacote.manifest to find the name. - [_add] (tree, { add, saveType = null, saveBundle = false }) { + async [_add] (tree, { add, saveType = null, saveBundle = false }) { // get the name for each of the specs in the list. // ie, doing `foo@bar` we just return foo // but if it's a url or git, we don't know the name until we // fetch it and look in its manifest. - return Promise.all(add.map(async rawSpec => { + const resolvedAdd = await Promise.all(add.map(async rawSpec => { // We do NOT provide the path to npa here, because user-additions // need to be resolved relative to the CWD the user is in. const spec = await this[_retrieveSpecName](npa(rawSpec)) @@ -544,17 +545,16 @@ Try using the package name instead, e.g: .then(spec => this[_followSymlinkPath](spec)) spec.tree = tree return spec - })).then(add => { - this[_resolvedAdd].push(...add) - // now add is a list of spec objects with names. - // find a home for each of them! - addRmPkgDeps.add({ - pkg: tree.package, - add, - saveBundle, - saveType, - path: this.path, - }) + })) + this[_resolvedAdd].push(...resolvedAdd) + // now resolvedAdd is a list of spec objects with names. + // find a home for each of them! + addRmPkgDeps.add({ + pkg: tree.package, + add: resolvedAdd, + saveBundle, + saveType, + path: this.path, }) } @@ -781,17 +781,18 @@ This is a one-time fix-up, please be patient... const spec = npa.resolve(name, id, dirname(path)) const t = `idealTree:inflate:${location}` this.addTracker(t) - await pacote.manifest(spec, { - ...this.options, - resolved: resolved, - integrity: integrity, - fullMetadata: false, - }).then(mani => { + try { + const mani = await pacote.manifest(spec, { + ...this.options, + resolved: resolved, + integrity: integrity, + fullMetadata: false, + }) node.package = { ...mani, _id: `${mani.name}@${mani.version}` } - }).catch((er) => { + } catch (er) { const warning = `Could not fetch metadata for ${name}@${id}` log.warn(heading, warning, er) - }) + } this.finishTracker(t) }) } diff --git a/workspaces/arborist/lib/arborist/load-actual.js b/workspaces/arborist/lib/arborist/load-actual.js index bca7cef9476ff..7ab65f5b00d8b 100644 --- a/workspaces/arborist/lib/arborist/load-actual.js +++ b/workspaces/arborist/lib/arborist/load-actual.js @@ -347,6 +347,7 @@ module.exports = cls => class ActualLoader extends cls { // node_modules hierarchy, then load that node as well. return this[_loadFSTree](link.target).then(() => link) } else if (target.then) { + // eslint-disable-next-line promise/catch-or-return target.then(node => link.target = node) } diff --git a/workspaces/arborist/lib/arborist/rebuild.js b/workspaces/arborist/lib/arborist/rebuild.js index e9b79031ef427..7e97984c06aa7 100644 --- a/workspaces/arborist/lib/arborist/rebuild.js +++ b/workspaces/arborist/lib/arborist/rebuild.js @@ -359,6 +359,9 @@ module.exports = cls => class Builder extends cls { pkg, path, event, + // I do not know why this needs to be on THIS line but refactoring + // this function would be quite a process + // eslint-disable-next-line promise/always-return cmd: args && args[args.length - 1], env, code, diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index 7663a3a342cc6..0c9026f5e4d1e 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -69,7 +69,6 @@ const _symlink = Symbol('symlink') const _warnDeprecated = Symbol('warnDeprecated') const _loadBundlesAndUpdateTrees = Symbol.for('loadBundlesAndUpdateTrees') const _submitQuickAudit = Symbol('submitQuickAudit') -const _awaitQuickAudit = Symbol('awaitQuickAudit') const _unpackNewModules = Symbol.for('unpackNewModules') const _moveContents = Symbol.for('moveContents') const _moveBackRetiredUnchanged = Symbol.for('moveBackRetiredUnchanged') @@ -156,7 +155,8 @@ module.exports = cls => class Reifier extends cls { await this[_reifyPackages]() await this[_saveIdealTree](options) await this[_copyIdealToActual]() - await this[_awaitQuickAudit]() + // This is a very bad pattern and I can't wait to stop doing it + this.auditReport = await this.auditReport this.finishTracker('reify') process.emit('timeEnd', 'reify') @@ -531,12 +531,12 @@ module.exports = cls => class Reifier extends cls { const targets = [...roots, ...Object.keys(this[_retiredPaths])] const unlinks = targets .map(path => rimraf(path).catch(er => failures.push([path, er]))) - return promiseAllRejectLate(unlinks) - .then(() => { - if (failures.length) { - log.warn('cleanup', 'Failed to remove some directories', failures) - } - }) + return promiseAllRejectLate(unlinks).then(() => { + // eslint-disable-next-line promise/always-return + if (failures.length) { + log.warn('cleanup', 'Failed to remove some directories', failures) + } + }) .then(() => process.emit('timeEnd', 'reify:rollback:createSparse')) .then(() => this[_rollbackRetireShallowNodes](er)) } @@ -592,21 +592,21 @@ module.exports = cls => class Reifier extends cls { this.addTracker('reify', node.name, node.location) const { npmVersion, nodeVersion } = this.options - const p = Promise.resolve() - .then(async () => { - // when we reify an optional node, check the engine and platform - // first. be sure to ignore the --force and --engine-strict flags, - // since we always want to skip any optional packages we can't install. - // these checks throwing will result in a rollback and removal - // of the mismatches - if (node.optional) { - checkEngine(node.package, npmVersion, nodeVersion, false) - checkPlatform(node.package, false) - } - await this[_checkBins](node) - await this[_extractOrLink](node) - await this[_warnDeprecated](node) - }) + const p = Promise.resolve().then(async () => { + // when we reify an optional node, check the engine and platform + // first. be sure to ignore the --force and --engine-strict flags, + // since we always want to skip any optional packages we can't install. + // these checks throwing will result in a rollback and removal + // of the mismatches + // eslint-disable-next-line promise/always-return + if (node.optional) { + checkEngine(node.package, npmVersion, nodeVersion, false) + checkPlatform(node.package, false) + } + await this[_checkBins](node) + await this[_extractOrLink](node) + await this[_warnDeprecated](node) + }) return this[_handleOptionalFailure](node, p) .then(() => { @@ -916,9 +916,10 @@ module.exports = cls => class Reifier extends cls { } } - [_submitQuickAudit] () { + async [_submitQuickAudit] () { if (this.options.audit === false) { - return this.auditReport = null + this.auditReport = null + return } // we submit the quick audit at this point in the process, as soon as @@ -940,16 +941,10 @@ module.exports = cls => class Reifier extends cls { ) } - this.auditReport = AuditReport.load(tree, options) - .then(res => { - process.emit('timeEnd', 'reify:audit') - this.auditReport = res - }) - } - - // return the promise if we're waiting for it, or the replaced result - [_awaitQuickAudit] () { - return this.auditReport + this.auditReport = AuditReport.load(tree, options).then(res => { + process.emit('timeEnd', 'reify:audit') + return res + }) } // ok! actually unpack stuff into their target locations! @@ -1126,7 +1121,7 @@ module.exports = cls => class Reifier extends cls { // remove the retired folders, and any deleted nodes // If this fails, there isn't much we can do but tell the user about it. // Thankfully, it's pretty unlikely that it'll fail, since rimraf is a tank. - [_removeTrash] () { + async [_removeTrash] () { process.emit('time', 'reify:trash') const promises = [] const failures = [] @@ -1136,12 +1131,11 @@ module.exports = cls => class Reifier extends cls { promises.push(rm(path)) } - return promiseAllRejectLate(promises).then(() => { - if (failures.length) { - log.warn('cleanup', 'Failed to remove some directories', failures) - } - }) - .then(() => process.emit('timeEnd', 'reify:trash')) + await promiseAllRejectLate(promises) + if (failures.length) { + log.warn('cleanup', 'Failed to remove some directories', failures) + } + process.emit('timeEnd', 'reify:trash') } // last but not least, we save the ideal tree metadata to the package-lock @@ -1302,7 +1296,9 @@ module.exports = cls => class Reifier extends cls { if (semver.subset(edge.spec, node.version)) { return false } - } catch {} + } catch { + // ignore errors + } } return true } diff --git a/workspaces/arborist/lib/audit-report.js b/workspaces/arborist/lib/audit-report.js index 9bef84686f4b4..387919f610829 100644 --- a/workspaces/arborist/lib/audit-report.js +++ b/workspaces/arborist/lib/audit-report.js @@ -175,7 +175,9 @@ class AuditReport extends Map { } else { // calculate a metavuln, if necessary const calc = this.calculator.calculate(dep.packageName, advisory) + // eslint-disable-next-line promise/always-return p.push(calc.then(meta => { + // eslint-disable-next-line promise/always-return if (meta.testVersion(dep.version, spec)) { advisories.add(meta) } diff --git a/workspaces/arborist/lib/link.js b/workspaces/arborist/lib/link.js index 6fed063772b6a..d58c6e2375099 100644 --- a/workspaces/arborist/lib/link.js +++ b/workspaces/arborist/lib/link.js @@ -66,6 +66,7 @@ class Link extends Node { // can set to a promise during an async tree build operation // wait until then to assign it. this[_target] = target + // eslint-disable-next-line promise/always-return, promise/catch-or-return target.then(node => { this[_target] = null this.target = node diff --git a/workspaces/arborist/lib/node.js b/workspaces/arborist/lib/node.js index 8ec90ff3c8495..60ce3eda0eb42 100644 --- a/workspaces/arborist/lib/node.js +++ b/workspaces/arborist/lib/node.js @@ -564,7 +564,8 @@ class Node { // this allows us to do new Node({...}) and then set the root later. // just make the assignment so we don't lose it, and move on. if (!this.path || !root.realpath || !root.path) { - return this[_root] = root + this[_root] = root + return } // temporarily become a root node diff --git a/workspaces/arborist/lib/shrinkwrap.js b/workspaces/arborist/lib/shrinkwrap.js index e2180fd4c8076..d5448bbcba927 100644 --- a/workspaces/arborist/lib/shrinkwrap.js +++ b/workspaces/arborist/lib/shrinkwrap.js @@ -184,34 +184,32 @@ const assertNoNewer = async (path, data, lockTime, dir = path, seen = null) => { ? Promise.resolve([{ name: 'node_modules', isDirectory: () => true }]) : readdir(parent, { withFileTypes: true }) - return children.catch(() => []) - .then(ents => Promise.all(ents.map(async ent => { - const child = resolve(parent, ent.name) - if (ent.isDirectory() && !/^\./.test(ent.name)) { - await assertNoNewer(path, data, lockTime, child, seen) - } else if (ent.isSymbolicLink()) { - const target = resolve(parent, await readlink(child)) - const tstat = await stat(target).catch( - /* istanbul ignore next - windows */ () => null) - seen.add(relpath(path, child)) - /* istanbul ignore next - windows cannot do this */ - if (tstat && tstat.isDirectory() && !seen.has(relpath(path, target))) { - await assertNoNewer(path, data, lockTime, target, seen) - } - } - }))) - .then(() => { - if (dir !== path) { - return + const ents = await children.catch(() => []) + await Promise.all(ents.map(async ent => { + const child = resolve(parent, ent.name) + if (ent.isDirectory() && !/^\./.test(ent.name)) { + await assertNoNewer(path, data, lockTime, child, seen) + } else if (ent.isSymbolicLink()) { + const target = resolve(parent, await readlink(child)) + const tstat = await stat(target).catch( + /* istanbul ignore next - windows */ () => null) + seen.add(relpath(path, child)) + /* istanbul ignore next - windows cannot do this */ + if (tstat && tstat.isDirectory() && !seen.has(relpath(path, target))) { + await assertNoNewer(path, data, lockTime, target, seen) } + } + })) + if (dir !== path) { + return + } - // assert that all the entries in the lockfile were seen - for (const loc of new Set(Object.keys(data.packages))) { - if (!seen.has(loc)) { - throw 'missing from node_modules: ' + loc - } - } - }) + // assert that all the entries in the lockfile were seen + for (const loc of new Set(Object.keys(data.packages))) { + if (!seen.has(loc)) { + throw 'missing from node_modules: ' + loc + } + } } const _awaitingUpdate = Symbol('_awaitingUpdate') @@ -261,7 +259,9 @@ class Shrinkwrap { s.lockfileVersion = json.lockfileVersion } } - } catch (e) {} + } catch { + // ignore errors + } return s } @@ -442,7 +442,7 @@ class Shrinkwrap { this.newline = newline !== undefined ? newline : this.newline } - load () { + async load () { // we don't need to load package-lock.json except for top of tree nodes, // only npm-shrinkwrap.json. return this[_maybeRead]().then(([sw, lock, yarn]) => { @@ -464,7 +464,9 @@ class Shrinkwrap { // ignore invalid yarn data. we'll likely clobber it later anyway. try { this.yarnLock.parse(yarn) - } catch (_) {} + } catch { + // ignore errors + } } return data ? parseJSON(data) : {} @@ -515,8 +517,10 @@ class Shrinkwrap { !(lock.lockfileVersion >= 2) && !lock.requires // load old lockfile deps into the packages listing + // eslint-disable-next-line promise/always-return if (lock.dependencies && !lock.packages) { return rpj(this.path + '/package.json').then(pkg => pkg, er => ({})) + // eslint-disable-next-line promise/always-return .then(pkg => { this[_loadAll]('', null, this.data) this[_fixDependencies](pkg) diff --git a/workspaces/arborist/lib/signal-handling.js b/workspaces/arborist/lib/signal-handling.js index 0afbb05dcfc64..18841d944ffe7 100644 --- a/workspaces/arborist/lib/signal-handling.js +++ b/workspaces/arborist/lib/signal-handling.js @@ -19,7 +19,9 @@ const setup = fn => { for (const sig of signals) { try { process.removeListener(sig, sigListeners[sig]) - } catch (er) {} + } catch { + // ignore errors + } } process.removeListener('beforeExit', onBeforeExit) sigListeners.loaded = false @@ -62,7 +64,9 @@ const setup = fn => { process.setMaxListeners(length + 1) } process.on(sig, sigListeners[sig]) - } catch (er) {} + } catch { + // ignore errors + } } sigListeners.loaded = true diff --git a/workspaces/arborist/lib/spec-from-lock.js b/workspaces/arborist/lib/spec-from-lock.js index 789741976269d..49b53c8f6aaca 100644 --- a/workspaces/arborist/lib/spec-from-lock.js +++ b/workspaces/arborist/lib/spec-from-lock.js @@ -21,10 +21,12 @@ const specFromLock = (name, lock, where) => { if (lock.resolved) { return npa.resolve(name, lock.resolved, where) } - } catch (_) { } + } catch { + // ignore errors + } try { return npa.resolve(name, lock.version, where) - } catch (_) { + } catch { return {} } } diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json index 86e36e486c880..124cb6650ce00 100644 --- a/workspaces/arborist/package.json +++ b/workspaces/arborist/package.json @@ -41,7 +41,7 @@ "walk-up-path": "^1.0.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "benchmark": "^2.1.4", "chalk": "^4.1.0", diff --git a/workspaces/arborist/scripts/benchmark.js b/workspaces/arborist/scripts/benchmark.js index f6b2b02942981..f4d26871b5ecb 100644 --- a/workspaces/arborist/scripts/benchmark.js +++ b/workspaces/arborist/scripts/benchmark.js @@ -151,7 +151,7 @@ const suite = new Suite({ } }, - onComplete () { + async onComplete () { rimraf.sync(lastBenchmark) mkdirp.sync(resolve(__dirname, 'benchmark/saved')) // always save with sha @@ -168,12 +168,13 @@ const suite = new Suite({ } linkSync(saveThis, lastBenchmark) - teardown().then(() => Promise.all([ + await teardown() + await Promise.all([ registryServer.stop(), new Promise((res, rej) => { rimraf(this.cache, er => er ? rej(er) : res()) }), - ])) + ]) }, }) diff --git a/workspaces/arborist/scripts/benchmark/reify.js b/workspaces/arborist/scripts/benchmark/reify.js index b826533d0006d..f477cfbd19f29 100644 --- a/workspaces/arborist/scripts/benchmark/reify.js +++ b/workspaces/arborist/scripts/benchmark/reify.js @@ -49,10 +49,9 @@ const suite = async (suite, { registry, cache }) => { version: '1.0.0', dependencies, })) - await arb.reify().then(() => { - // grab this so we can make setup faster - packageLock = require(resolve(path, 'package-lock.json')) - }) + await arb.reify() + // grab this so we can make setup faster + packageLock = require(resolve(path, 'package-lock.json')) } // just reify them all fast. we'll remove the bits we don't want later. @@ -96,14 +95,13 @@ const suite = async (suite, { registry, cache }) => { rimraf.sync(resolve(path, 'cache')) } }, - fn (d) { - new Arborist({ + async fn (d) { + await new Arborist({ path, registry, cache: /no-cache/.test(path) ? resolve(path, 'cache') : cache, - }).reify().then(() => d.resolve(), er => { - throw er - }) + }).reify() + d.resolve() }, }) } diff --git a/workspaces/arborist/test/arborist/build-ideal-tree.js b/workspaces/arborist/test/arborist/build-ideal-tree.js index 0aadd7adf815f..87783086b65c3 100644 --- a/workspaces/arborist/test/arborist/build-ideal-tree.js +++ b/workspaces/arborist/test/arborist/build-ideal-tree.js @@ -1080,7 +1080,7 @@ t.test('pathologically nested dependency cycle', async t => { resolve(fixtures, 'pathological-dep-nesting-cycle'))) }) -t.test('resolve file deps from cwd', t => { +t.test('resolve file deps from cwd', async t => { const cwd = process.cwd() t.teardown(() => process.chdir(cwd)) const path = t.testdir({ @@ -1094,17 +1094,16 @@ t.test('resolve file deps from cwd', t => { path: resolve(path, 'global'), ...OPT, }) - return arb.buildIdealTree({ + const tree = await arb.buildIdealTree({ path: `${path}/local`, add: ['child-1.2.3.tgz'], global: true, - }).then(tree => { - const resolved = `file:${resolve(fixturedir, 'child-1.2.3.tgz')}` - t.equal(normalizePath(tree.children.get('child').resolved), normalizePath(resolved)) }) + const resolved = `file:${resolve(fixturedir, 'child-1.2.3.tgz')}` + t.equal(normalizePath(tree.children.get('child').resolved), normalizePath(resolved)) }) -t.test('resolve links in global mode', t => { +t.test('resolve links in global mode', async t => { const cwd = process.cwd() t.teardown(() => process.chdir(cwd)) const path = t.testdir({ @@ -1127,13 +1126,12 @@ t.test('resolve links in global mode', t => { global: true, path: resolve(path, 'global'), }) - return arb.buildIdealTree({ + const tree = await arb.buildIdealTree({ add: ['file:../../linked-dep'], global: true, - }).then(tree => { - const resolved = 'file:../../linked-dep' - t.equal(tree.children.get('linked-dep').resolved, resolved) }) + const resolved = 'file:../../linked-dep' + t.equal(tree.children.get('linked-dep').resolved, resolved) }) t.test('dont get confused if root matches duped metadep', async t => { diff --git a/workspaces/arborist/test/arborist/load-actual.js b/workspaces/arborist/test/arborist/load-actual.js index 72ab5e60fbf38..9c2c8bf1cd4b8 100644 --- a/workspaces/arborist/test/arborist/load-actual.js +++ b/workspaces/arborist/test/arborist/load-actual.js @@ -170,34 +170,34 @@ t.test('shake out Link target timing issue', t => { t.matchSnapshot(tree, 'loaded tree')) }) -t.test('broken json', t => - loadActual(resolve(fixtures, 'bad')).then(d => { - t.ok(d.errors.length, 'Got an error object') - t.equal(d.errors[0] && d.errors[0].code, 'EJSONPARSE') - t.ok(d, 'Got a tree') - })) +t.test('broken json', async t => { + const d = await loadActual(resolve(fixtures, 'bad')) + t.ok(d.errors.length, 'Got an error object') + t.equal(d.errors[0] && d.errors[0].code, 'EJSONPARSE') + t.ok(d, 'Got a tree') +}) -t.test('missing json does not obscure deeper errors', t => - loadActual(resolve(fixtures, 'empty')).then(d => { - t.match(d, { errors: [{ code: 'ENOENT' }] }, - 'Error reading json of top level') - t.match(d.children.get('foo'), { errors: [{ code: 'EJSONPARSE' }] }, - 'Error parsing JSON of child node') - })) +t.test('missing json does not obscure deeper errors', async t => { + const d = await loadActual(resolve(fixtures, 'empty')) + t.match(d, { errors: [{ code: 'ENOENT' }] }, + 'Error reading json of top level') + t.match(d.children.get('foo'), { errors: [{ code: 'EJSONPARSE' }] }, + 'Error parsing JSON of child node') +}) t.test('missing folder', t => t.rejects(loadActual(resolve(fixtures, 'does-not-exist')), { code: 'ENOENT', })) -t.test('missing symlinks', t => - loadActual(resolve(fixtures, 'badlink')).then(d => { - t.equal(d.children.size, 2, 'both broken children are included') - t.match(d.children.get('foo'), { errors: [{ code: 'ELOOP' }] }, - 'foo has error') - t.match(d.children.get('bar'), { errors: [{ code: 'ENOENT' }] }, - 'bar has error') - })) +t.test('missing symlinks', async t => { + const d = await loadActual(resolve(fixtures, 'badlink')) + t.equal(d.children.size, 2, 'both broken children are included') + t.match(d.children.get('foo'), { errors: [{ code: 'ELOOP' }] }, + 'foo has error') + t.match(d.children.get('bar'), { errors: [{ code: 'ENOENT' }] }, + 'bar has error') +}) t.test('load from a hidden lockfile', async (t) => { const tree = await loadActual(resolve(fixtures, 'hidden-lockfile')) diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index db5a9c1fe1af6..01945f7136c41 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -232,6 +232,7 @@ t.test('omit peer deps', t => { } const lock = require(tree.path + '/package-lock.json') + // eslint-disable-next-line promise/always-return for (const [loc, meta] of Object.entries(lock.packages)) { if (meta.peer) { t.throws(() => fs.statSync(resolve(path, loc)), 'peer not reified') @@ -240,6 +241,7 @@ t.test('omit peer deps', t => { } } }) + // eslint-disable-next-line promise/always-return .then(() => { process.removeListener('time', onTime) process.removeListener('timeEnd', onTimeEnd) @@ -335,15 +337,15 @@ t.test('omit optional dep', t => { const ignoreScripts = true const arb = newArb({ path, ignoreScripts }) - return arb.reify({ omit: ['optional'] }) - .then(tree => { - t.equal(tree.children.get('fsevents'), undefined, 'no fsevents in tree') - t.throws(() => fs.statSync(path + '/node_modules/fsevents'), 'no fsevents unpacked') - t.match(require(path + '/package-lock.json').dependencies.fsevents, { - dev: true, - optional: true, - }, 'fsevents present in lockfile') - }) + // eslint-disable-next-line promise/always-return + return arb.reify({ omit: ['optional'] }).then(tree => { + t.equal(tree.children.get('fsevents'), undefined, 'no fsevents in tree') + t.throws(() => fs.statSync(path + '/node_modules/fsevents'), 'no fsevents unpacked') + t.match(require(path + '/package-lock.json').dependencies.fsevents, { + dev: true, + optional: true, + }, 'fsevents present in lockfile') + }) .then(() => t.ok(arb.diff, 'has a diff tree')) }) @@ -737,6 +739,7 @@ t.test('rollbacks', { buffered: false }, t => { return t.rejects(a.reify({ update: ['@isaacs/testing-bundledeps-parent'], }).then(tree => 'it worked'), new Error('poop')) + // eslint-disable-next-line promise/always-return .then(() => { const warnings = check() t.equal(warnings.length, 2) @@ -858,6 +861,7 @@ t.test('rollbacks', { buffered: false }, t => { return t.resolveMatchSnapshot(a.reify({ update: ['@isaacs/testing-bundledeps-parent'], save: false, + // eslint-disable-next-line promise/always-return }).then(tree => printTree(tree))).then(() => { const warnings = check() t.equal(warnings.length, 2) @@ -1019,6 +1023,7 @@ t.test('saving the ideal tree', t => { // NB: these are all going to be marked as extraneous, because we're // skipping the actual buildIdealTree step that flags them properly return a[kSaveIdealTree]({}) + // eslint-disable-next-line promise/always-return }).then(saved => { t.ok(saved, 'true, because it was saved') t.matchSnapshot(require(path + '/package-lock.json'), 'lock after save') @@ -1159,12 +1164,10 @@ t.test('workspaces', t => { t.test('reify simple-workspaces', t => t.resolveMatchSnapshot(printReified(fixture(t, 'workspaces-simple')), 'should reify simple workspaces')) - t.test('reify workspaces lockfile', t => { + t.test('reify workspaces lockfile', async t => { const path = fixture(t, 'workspaces-simple') - reify(path).then(() => { - t.matchSnapshot(require(path + '/package-lock.json'), 'should lock workspaces config') - t.end() - }) + await reify(path) + t.matchSnapshot(require(path + '/package-lock.json'), 'should lock workspaces config') }) t.test('reify workspaces bin files', t => { @@ -1195,20 +1198,16 @@ t.test('workspaces', t => { 'should not clean up entire nm folder for no reason' )) - t.test('add new workspaces dep', t => { + t.test('add new workspaces dep', async t => { const path = fixture(t, 'workspaces-add-new-dep') - reify(path).then(() => { - t.matchSnapshot(require(path + '/package-lock.json'), 'should update package-lock with new added dep') - t.end() - }) + await reify(path) + t.matchSnapshot(require(path + '/package-lock.json'), 'should update package-lock with new added dep') }) - t.test('root as-a-workspace', t => { + t.test('root as-a-workspace', async t => { const path = fixture(t, 'workspaces-root-linked') - reify(path).then(() => { - t.matchSnapshot(require(path + '/package-lock.json'), 'should produce expected package-lock file') - t.end() - }) + await reify(path) + t.matchSnapshot(require(path + '/package-lock.json'), 'should produce expected package-lock file') }) t.end() diff --git a/workspaces/arborist/test/shrinkwrap.js b/workspaces/arborist/test/shrinkwrap.js index 07178062e3a40..46f8ceccff915 100644 --- a/workspaces/arborist/test/shrinkwrap.js +++ b/workspaces/arborist/test/shrinkwrap.js @@ -54,31 +54,31 @@ t.test('load and change lockfileVersion', async t => { t.equal(v3Data.dependencies, undefined, 'v3 data does not have dependencies') }) -t.test('load and then reset gets empty lockfile', t => - Shrinkwrap.load({ path: fixture }).then(sw => { - sw.reset() - t.strictSame(sw.data, { - lockfileVersion: 2, - requires: true, - dependencies: {}, - packages: {}, - }) - t.equal(sw.loadedFromDisk, true) - t.equal(sw.filename, resolve(fixture, 'package-lock.json')) - })) +t.test('load and then reset gets empty lockfile', async t => { + const sw = await Shrinkwrap.load({ path: fixture }) + sw.reset() + t.strictSame(sw.data, { + lockfileVersion: 2, + requires: true, + dependencies: {}, + packages: {}, + }) + t.equal(sw.loadedFromDisk, true) + t.equal(sw.filename, resolve(fixture, 'package-lock.json')) +}) -t.test('starting out with a reset lockfile is an empty lockfile', t => - Shrinkwrap.reset({ path: fixture }).then(sw => { - t.strictSame(sw.data, { - lockfileVersion: 2, - requires: true, - dependencies: {}, - packages: {}, - }) - t.equal(sw.originalLockfileVersion, 2) - t.equal(sw.loadedFromDisk, true) - t.equal(sw.filename, resolve(fixture, 'package-lock.json')) - })) +t.test('starting out with a reset lockfile is an empty lockfile', async t => { + const sw = await Shrinkwrap.reset({ path: fixture }) + t.strictSame(sw.data, { + lockfileVersion: 2, + requires: true, + dependencies: {}, + packages: {}, + }) + t.equal(sw.originalLockfileVersion, 2) + t.equal(sw.loadedFromDisk, true) + t.equal(sw.filename, resolve(fixture, 'package-lock.json')) +}) t.test('reset in a bad dir gets an empty lockfile with no lockfile version', async t => { const nullLockDir = t.testdir({ @@ -109,103 +109,103 @@ t.test('reset in a bad dir gets an empty lockfile with no lockfile version', asy t.equal(swNullLock.loadedFromDisk, true) }) -t.test('loading in bad dir gets empty lockfile', t => - Shrinkwrap.load({ path: 'path/which/does/not/exist' }).then(sw => { - t.strictSame(sw.data, { - lockfileVersion: 2, - requires: true, - dependencies: {}, - packages: {}, - }) - t.equal(sw.loadedFromDisk, false) - })) +t.test('loading in bad dir gets empty lockfile', async t => { + const sw = await Shrinkwrap.load({ path: 'path/which/does/not/exist' }) + t.strictSame(sw.data, { + lockfileVersion: 2, + requires: true, + dependencies: {}, + packages: {}, + }) + t.equal(sw.loadedFromDisk, false) +}) -t.test('failure to parse json gets empty lockfile', t => - Shrinkwrap.load({ path: badJsonFixture }).then(sw => { - t.strictSame(sw.data, { - lockfileVersion: 2, - requires: true, - dependencies: {}, - packages: {}, - }) - t.equal(sw.loadedFromDisk, false) - })) +t.test('failure to parse json gets empty lockfile', async t => { + const sw = await Shrinkwrap.load({ path: badJsonFixture }) + t.strictSame(sw.data, { + lockfileVersion: 2, + requires: true, + dependencies: {}, + packages: {}, + }) + t.equal(sw.loadedFromDisk, false) +}) -t.test('loading in empty dir gets empty lockfile', t => - Shrinkwrap.load({ path: emptyFixture }).then(sw => { - t.strictSame(sw.data, { - lockfileVersion: 2, - requires: true, - dependencies: {}, - packages: {}, - }) - t.equal(sw.loadedFromDisk, false) - // update with an empty node, set name to node name, not package name - const root = new Node({ - path: emptyFixture, - realpath: emptyFixture, - }) - root.peer = false - root.dev = false - root.devOptional = false - root.optional = false - root.extraneous = false - sw.add(root) - t.strictSame(sw.commit(), { - name: 'empty', - lockfileVersion: 2, - requires: true, - packages: {}, - }) - })) +t.test('loading in empty dir gets empty lockfile', async t => { + const sw = await Shrinkwrap.load({ path: emptyFixture }) + t.strictSame(sw.data, { + lockfileVersion: 2, + requires: true, + dependencies: {}, + packages: {}, + }) + t.equal(sw.loadedFromDisk, false) + // update with an empty node, set name to node name, not package name + const root = new Node({ + path: emptyFixture, + realpath: emptyFixture, + }) + root.peer = false + root.dev = false + root.devOptional = false + root.optional = false + root.extraneous = false + sw.add(root) + t.strictSame(sw.commit(), { + name: 'empty', + lockfileVersion: 2, + requires: true, + packages: {}, + }) +}) -t.test('look up from locks and such', t => - new Shrinkwrap({ path: fixture }).load().then(m => { - t.strictSame(m.get(''), { - name: 'a', - version: '1.2.3', - dependencies: { - abbrev: '^1.1.1', - 'full-git-url': 'git+https://github.com/isaacs/abbrev-js.git', - ghshort: 'github:isaacs/abbrev-js', - old: 'npm:abbrev@^1.0.3', - pinned: 'npm:abbrev@^1.1.1', - reg: 'npm:abbrev@^1.1.1', - remote: 'https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz', - symlink: 'file:./abbrev-link-target', - tarball: 'file:abbrev-1.1.1.tgz', - bundler: '1.2.3', - }, - }, 'root metadata') - t.match(m.data, { - lockfileVersion: 2, - requires: true, - dependencies: Object, - packages: Object, - }) - t.equal(m.loadedFromDisk, true) - t.matchSnapshot(m.get('node_modules/abbrev'), 'basic package') +t.test('look up from locks and such', async t => { + const m = await new Shrinkwrap({ path: fixture }).load() + t.strictSame(m.get(''), { + name: 'a', + version: '1.2.3', + dependencies: { + abbrev: '^1.1.1', + 'full-git-url': 'git+https://github.com/isaacs/abbrev-js.git', + ghshort: 'github:isaacs/abbrev-js', + old: 'npm:abbrev@^1.0.3', + pinned: 'npm:abbrev@^1.1.1', + reg: 'npm:abbrev@^1.1.1', + remote: 'https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz', + symlink: 'file:./abbrev-link-target', + tarball: 'file:abbrev-1.1.1.tgz', + bundler: '1.2.3', + }, + }, 'root metadata') + t.match(m.data, { + lockfileVersion: 2, + requires: true, + dependencies: Object, + packages: Object, + }) + t.equal(m.loadedFromDisk, true) + t.matchSnapshot(m.get('node_modules/abbrev'), 'basic package') + t.matchSnapshot(m.get( + 'node_modules/abbrev/node_modules/@scope/name/node_modules/@otherscope/othername', 'scoped package')) + t.matchSnapshot(m.get('package/not/found'), 'not found') + + t.matchSnapshot(m.get('node_modules/old/node_modules/notfound'), 'fall off the dep tree') + + t.test('lockfile', t => { + const p = m.data.packages + m.data.packages = {} + t.matchSnapshot(m.get('node_modules/abbrev'), 'basic pkg, from lock') + t.matchSnapshot(m.data.packages, 'saved fetched metadata back to packages section') t.matchSnapshot(m.get( 'node_modules/abbrev/node_modules/@scope/name/node_modules/@otherscope/othername', 'scoped package')) t.matchSnapshot(m.get('package/not/found'), 'not found') - - t.matchSnapshot(m.get('node_modules/old/node_modules/notfound'), 'fall off the dep tree') - - t.test('lockfile', t => { - const p = m.data.packages - m.data.packages = {} - t.matchSnapshot(m.get('node_modules/abbrev'), 'basic pkg, from lock') - t.matchSnapshot(m.data.packages, 'saved fetched metadata back to packages section') - t.matchSnapshot(m.get( - 'node_modules/abbrev/node_modules/@scope/name/node_modules/@otherscope/othername', 'scoped package')) - t.matchSnapshot(m.get('package/not/found'), 'not found') - t.matchSnapshot(m.get('node_modules/full-git-url'), 'full git') - t.matchSnapshot(m.get('node_modules/symlink'), 'symlink') - t.matchSnapshot(m.get('node_modules/unhosted-git'), 'unhosted git') - m.data.packages = p - t.end() - }) - })) + t.matchSnapshot(m.get('node_modules/full-git-url'), 'full git') + t.matchSnapshot(m.get('node_modules/symlink'), 'symlink') + t.matchSnapshot(m.get('node_modules/unhosted-git'), 'unhosted git') + m.data.packages = p + t.end() + }) +}) t.test('load a shrinkwrap with some dev and optional flags', t => Shrinkwrap.load({ path: depTypesFixture }).then(m => @@ -616,39 +616,38 @@ t.test('saving dependency-free shrinkwrap object', t => { t.test('write the shrinkwrap back to disk', t => { const dir = t.testdir({}) - t.test('just read and write back', t => - Shrinkwrap.load({ path: fixture }).then(s => { - s.filename = dir + '/test-shrinkwrap.json' - return s.save().then(() => - t.strictSame(require(s.filename), s.data, 'saved json matches data')) - })) - t.test('write back with pending changes', t => - Shrinkwrap.load({ path: fixture }).then(s => { - const dir = t.testdir({}) - s.filename = dir + '/test-shrinkwrap-with-changes.json' - const node = new Node({ - path: fixture + '/node_modules/newthing', - pkg: { - name: 'newthing', - version: '1.2.3', - }, - }) - s.add(node) - const preCommit = JSON.parse(JSON.stringify(s.data)) - const postCommit = s.commit() - t.notSame(postCommit, preCommit, 'committing changes the data') - // delete and re-add to put us back in the pre-commit state - s.delete(node.location) - s.add(node) - return s.save().then(() => { - t.strictSame(s.data, postCommit, 'committed changes to data') - t.strictSame(require(s.filename), s.data, 'saved json matches data') - }) - })) + t.test('just read and write back', async t => { + const s = await Shrinkwrap.load({ path: fixture }) + s.filename = dir + '/test-shrinkwrap.json' + await s.save() + t.strictSame(require(s.filename), s.data, 'saved json matches data') + }) + t.test('write back with pending changes', async t => { + const s = await Shrinkwrap.load({ path: fixture }) + const dir = t.testdir({}) + s.filename = dir + '/test-shrinkwrap-with-changes.json' + const node = new Node({ + path: fixture + '/node_modules/newthing', + pkg: { + name: 'newthing', + version: '1.2.3', + }, + }) + s.add(node) + const preCommit = JSON.parse(JSON.stringify(s.data)) + const postCommit = s.commit() + t.notSame(postCommit, preCommit, 'committing changes the data') + // delete and re-add to put us back in the pre-commit state + s.delete(node.location) + s.add(node) + await s.save() + t.strictSame(s.data, postCommit, 'committed changes to data') + t.strictSame(require(s.filename), s.data, 'saved json matches data') + }) t.end() }) -t.test('load shrinkwrap if no package-lock.json present', t => { +t.test('load shrinkwrap if no package-lock.json present', async t => { const dir = t.testdir({ 'npm-shrinkwrap.json': JSON.stringify({ lockfileVersion: 1, @@ -656,41 +655,39 @@ t.test('load shrinkwrap if no package-lock.json present', t => { version: '1.2.3', }), }) - return Promise.all([ - Shrinkwrap.load({ path: dir, shrinkwrapOnly: true }).then(s => - t.equal(s.type, 'npm-shrinkwrap.json', 'loaded with swonly')), - Shrinkwrap.reset({ path: dir, shrinkwrapOnly: true }).then(s => - t.equal(s.type, 'npm-shrinkwrap.json', 'loaded fresh')), - Shrinkwrap.load({ path: dir }).then(s => - t.equal(s.type, 'npm-shrinkwrap.json', 'loaded without swonly')), - Shrinkwrap.reset({ path: dir }).then(s => - t.equal(s.type, 'npm-shrinkwrap.json', 'loaded fresh without swonly')), - ]) + let s + s = await Shrinkwrap.load({ path: dir, shrinkwrapOnly: true }) + t.equal(s.type, 'npm-shrinkwrap.json', 'loaded with swonly') + s = await Shrinkwrap.reset({ path: dir, shrinkwrapOnly: true }) + t.equal(s.type, 'npm-shrinkwrap.json', 'loaded fresh') + s = await Shrinkwrap.load({ path: dir }) + t.equal(s.type, 'npm-shrinkwrap.json', 'loaded without swonly') + s = await Shrinkwrap.reset({ path: dir }) + t.equal(s.type, 'npm-shrinkwrap.json', 'loaded fresh without swonly') }) -t.test('load yarn.lock file if present', t => - Shrinkwrap.load({ path: yarnFixture }).then(s => { - t.type(s.yarnLock, YarnLock, 'loaded a yarn lock file') - t.not(s.yarnLock.entries.size, 0, 'got some entries') - })) +t.test('load yarn.lock file if present', async t => { + const s = await Shrinkwrap.load({ path: yarnFixture }) + t.type(s.yarnLock, YarnLock, 'loaded a yarn lock file') + t.not(s.yarnLock.entries.size, 0, 'got some entries') +}) -t.test('save yarn lock if loaded', t => - Shrinkwrap.load({ path: yarnFixture }).then(s => { - s.path = t.testdir() - s.filename = s.path + '/package-lock.json' - return s.save() - .then(() => Shrinkwrap.load({ path: s.path })) - .then(ss => t.strictSame(s.yarnLock, ss.yarnLock)) - })) +t.test('save yarn lock if loaded', async t => { + const s = await Shrinkwrap.load({ path: yarnFixture }) + s.path = t.testdir() + s.filename = s.path + '/package-lock.json' + await s.save() + const ss = await Shrinkwrap.load({ path: s.path }) + t.strictSame(s.yarnLock, ss.yarnLock) +}) -t.test('ignore yarn lock file parse errors', t => { +t.test('ignore yarn lock file parse errors', async t => { const dir = t.testdir({ 'yarn.lock': 'this is not a yarn lock file!', }) - return Shrinkwrap.load({ path: dir }).then(s => { - t.type(s.yarnLock, YarnLock, 'got a yarn lock object because a yarn lock exists') - t.equal(s.yarnLock.entries.size, 0, 'did not get any entries out of it') - }) + const s = await Shrinkwrap.load({ path: dir }) + t.type(s.yarnLock, YarnLock, 'got a yarn lock object because a yarn lock exists') + t.equal(s.yarnLock.entries.size, 0, 'did not get any entries out of it') }) t.test('load a resolution from yarn.lock if we dont have our own', async t => { @@ -811,38 +808,38 @@ t.test('handle missing dependencies object without borking', t => { t.end() }) -t.test('load a hidden lockfile', t => { +t.test('load a hidden lockfile', async t => { // ensure the hidden lockfile is newer than the contents // otherwise this can fail on a fresh checkout. fs.utimesSync(resolve(hiddenLockfileFixture, hidden), new Date(), new Date()) - return Shrinkwrap.load({ + const s = await Shrinkwrap.load({ path: hiddenLockfileFixture, hiddenLockfile: true, - }).then(s => { - t.matchSnapshot(s.data) - // make sure it does not add to the dependencies block when a new - // node is added. - s.data.dependencies = {} - s.add(new Node({ - path: hiddenLockfileFixture + '/node_modules/foo', - pkg: { - name: 'foo', - version: '1.2.3', - _integrity: 'sha512-deadbeef', - _resolved: 'https://registry.npmjs.org/foo/-/foo-1.2.3.tgz', - }, - })) - t.strictSame(s.data.dependencies, {}, 'did not add to legacy data') - const data = s.commit() - t.equal(data.packages[''], undefined, 'no root entry') - t.equal(data.dependencies, undefined, 'deleted legacy metadata') }) + t.matchSnapshot(s.data) + // make sure it does not add to the dependencies block when a new + // node is added. + s.data.dependencies = {} + s.add(new Node({ + path: hiddenLockfileFixture + '/node_modules/foo', + pkg: { + name: 'foo', + version: '1.2.3', + _integrity: 'sha512-deadbeef', + _resolved: 'https://registry.npmjs.org/foo/-/foo-1.2.3.tgz', + }, + })) + t.strictSame(s.data.dependencies, {}, 'did not add to legacy data') + const data = s.commit() + t.equal(data.packages[''], undefined, 'no root entry') + t.equal(data.dependencies, undefined, 'deleted legacy metadata') }) -t.test('load a fresh hidden lockfile', t => Shrinkwrap.reset({ - path: hiddenLockfileFixture, - hiddenLockfile: true, -}).then(sw => { +t.test('load a fresh hidden lockfile', async t => { + const sw = await Shrinkwrap.reset({ + path: hiddenLockfileFixture, + hiddenLockfile: true, + }) t.strictSame(sw.data, { lockfileVersion: 3, requires: true, @@ -851,7 +848,7 @@ t.test('load a fresh hidden lockfile', t => Shrinkwrap.reset({ }) t.equal(sw.loadedFromDisk, true) t.equal(sw.filename, resolve(hiddenLockfileFixture, hidden)) -})) +}) t.test('hidden lockfile only used if up to date', async t => { const lockdata = require(resolve(hiddenLockfileFixture, hidden)) @@ -1188,18 +1185,19 @@ t.test('loadActual tests', t => { roots.push('tap-with-yarn-lock') - t.plan(roots.length) - roots.forEach(root => { + for (const root of roots) { const path = resolve(fixtures, root) - t.test(root, t => new Arborist({ path }).loadActual().then(tree => { + t.test(root, async t => { + const tree = await new Arborist({ path }).loadActual() const shrinkwrap = tree.meta.commit() t.matchSnapshot(shrinkwrap, 'shrinkwrap data') if (tree.meta.yarnLock) { const yarnLock = tree.meta.yarnLock.toString() t.matchSnapshot(yarnLock, 'yarn.lock data') } - })) - }) + }) + } + t.end() }) t.test('set integrity because location and resolved match', async t => { diff --git a/workspaces/arborist/test/yarn-lock.js b/workspaces/arborist/test/yarn-lock.js index 06c16556c2384..402afb717e004 100644 --- a/workspaces/arborist/test/yarn-lock.js +++ b/workspaces/arborist/test/yarn-lock.js @@ -86,11 +86,13 @@ t.test('load a yarn lock from an actual tree', t => { resolve(__dirname, 'fixtures/install-types'), resolve(__dirname, 'fixtures/links-all-over'), ] - fixtures.forEach(fixture => t.test(basename(fixture), t => - new Arborist({ path: fixture }).loadActual().then(tree => { + for (const fixture of fixtures) { + t.test(basename(fixture), async t => { + const tree = await new Arborist({ path: fixture }).loadActual() const y = YarnLock.fromTree(tree) t.matchSnapshot(y.toString(), 'yarn.lock from a package tree') - }))) + }) + } t.end() }) diff --git a/workspaces/libnpmaccess/package.json b/workspaces/libnpmaccess/package.json index 55ad695b29d1c..ca1ee7055b3ab 100644 --- a/workspaces/libnpmaccess/package.json +++ b/workspaces/libnpmaccess/package.json @@ -19,7 +19,7 @@ "template-oss-apply": "template-oss-apply --force" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "nock": "^13.2.4", "tap": "^16.0.1" diff --git a/workspaces/libnpmaccess/test/index.js b/workspaces/libnpmaccess/test/index.js index 7417ab56233c3..689788d5269f7 100644 --- a/workspaces/libnpmaccess/test/index.js +++ b/workspaces/libnpmaccess/test/index.js @@ -10,127 +10,96 @@ const OPTS = { registry: REG, } -t.test('access public', t => { +t.test('access public', async t => { tnock(t, REG).post( '/-/package/%40foo%2Fbar/access', { access: 'public' } ).reply(200) - return access.public('@foo/bar', OPTS).then(ret => { - t.same(ret, true, 'request succeeded') - }) + await t.resolves(access.public('@foo/bar', OPTS)) }) -t.test('access public - failure', t => { +t.test('access public - failure', async t => { tnock(t, REG).post( '/-/package/%40foo%2Fbar/access', { access: 'public' } ).reply(418) - return access.public('@foo/bar', OPTS) - .catch(err => { - t.equal(err.statusCode, 418, 'fails with code from registry') - }) + await t.rejects( + access.public('@foo/bar', OPTS), + { statusCode: 418 }, + 'fails with code from registry' + ) }) -t.test('access restricted', t => { +t.test('access restricted', async t => { tnock(t, REG).post( '/-/package/%40foo%2Fbar/access', { access: 'restricted' } ).reply(200) - return access.restricted('@foo/bar', OPTS).then(ret => { - t.same(ret, true, 'request succeeded') - }) + await t.resolves(access.restricted('@foo/bar', OPTS)) }) -t.test('access restricted - failure', t => { +t.test('access restricted - failure', async t => { tnock(t, REG).post( '/-/package/%40foo%2Fbar/access', { access: 'restricted' } ).reply(418) - return access.restricted('@foo/bar', OPTS) - .catch(err => { - t.equal(err.statusCode, 418, 'fails with code from registry') - }) + await t.rejects( + access.restricted('@foo/bar', OPTS), + { statusCode: 418 }, + 'fails with code from registry') }) -t.test('access 2fa-required', t => { +t.test('access 2fa-required', async t => { tnock(t, REG).post('/-/package/%40foo%2Fbar/access', { publish_requires_tfa: true, }).reply(200, { ok: true }) - return access.tfaRequired('@foo/bar', OPTS).then(ret => { - t.same(ret, true, 'request succeeded') - }) + await t.resolves(access.tfaRequired('@foo/bar', OPTS)) }) -t.test('access 2fa-not-required', t => { +t.test('access 2fa-not-required', async t => { tnock(t, REG).post('/-/package/%40foo%2Fbar/access', { publish_requires_tfa: false, }).reply(200, { ok: true }) - return access.tfaNotRequired('@foo/bar', OPTS).then(ret => { - t.same(ret, true, 'request succeeded') - }) + await t.resolves(access.tfaNotRequired('@foo/bar', OPTS)) }) -t.test('access grant basic read-write', t => { +t.test('access grant basic read-write', async t => { tnock(t, REG).put('/-/team/myorg/myteam/package', { package: '@foo/bar', permissions: 'read-write', }).reply(201) - return access.grant( - '@foo/bar', 'myorg:myteam', 'read-write', OPTS - ).then(ret => { - t.same(ret, true, 'request succeeded') - }) + await t.resolves(access.grant('@foo/bar', 'myorg:myteam', 'read-write', OPTS)) }) -t.test('access grant basic read-only', t => { +t.test('access grant basic read-only', async t => { tnock(t, REG).put('/-/team/myorg/myteam/package', { package: '@foo/bar', permissions: 'read-only', }).reply(201) - return access.grant( - '@foo/bar', 'myorg:myteam', 'read-only', OPTS - ).then(ret => { - t.same(ret, true, 'request succeeded') - }) + await t.resolves(access.grant('@foo/bar', 'myorg:myteam', 'read-only', OPTS)) }) -t.test('access grant bad perm', t => { - return access.grant( - '@foo/bar', 'myorg:myteam', 'unknown', OPTS - ).then(ret => { - throw new Error('should not have succeeded') - }, err => { - t.match( - err.message, - /must be.*read-write.*read-only/, - 'only read-write and read-only are accepted' - ) - }) +t.test('access grant bad perm', async t => { + await t.rejects( + access.grant('@foo/bar', 'myorg:myteam', 'unknown', OPTS), + { message: /must be.*read-write.*read-only/ }, + 'only read-write and read-only are accepted' + ) }) -t.test('access grant no entity', t => { - return access.grant( - '@foo/bar', undefined, 'read-write', OPTS - ).then(ret => { - throw new Error('should not have succeeded') - }, err => { - t.match( - err.message, - /Expected string/, - 'passing undefined entity gives useful error' - ) - }) +t.test('access grant no entity', async t => { + await t.rejects( + access.grant('@foo/bar', undefined, 'read-write', OPTS), + { message: /Expected string/ }, + 'passing undefined entity gives useful error' + ) }) -t.test('access grant basic unscoped', t => { +t.test('access grant basic unscoped', async t => { tnock(t, REG).put('/-/team/myorg/myteam/package', { package: 'bar', permissions: 'read-write', }).reply(201) - return access.grant( - 'bar', 'myorg:myteam', 'read-write', OPTS - ).then(ret => { - t.same(ret, true, 'request succeeded') - }) + await t.resolves(access.grant('bar', 'myorg:myteam', 'read-write', OPTS)) }) -t.test('access grant no opts passed', t => { +t.test('access grant no opts passed', async t => { // NOTE: mocking real url, because no opts variable means `registry` value // will be defauled to real registry url tnock(t, 'https://registry.npmjs.org') @@ -139,31 +108,24 @@ t.test('access grant no opts passed', t => { permissions: 'read-write', }) .reply(201) - return access.grant('bar', 'myorg:myteam', 'read-write') - .then(ret => { - t.equal(ret, true, 'request succeeded') - }) + await t.resolves(access.grant('bar', 'myorg:myteam', 'read-write')) }) -t.test('access revoke basic', t => { +t.test('access revoke basic', async t => { tnock(t, REG).delete('/-/team/myorg/myteam/package', { package: '@foo/bar', }).reply(200) - return access.revoke('@foo/bar', 'myorg:myteam', OPTS).then(ret => { - t.same(ret, true, 'request succeeded') - }) + await t.resolves(access.revoke('@foo/bar', 'myorg:myteam', OPTS)) }) -t.test('access revoke basic unscoped', t => { +t.test('access revoke basic unscoped', async t => { tnock(t, REG).delete('/-/team/myorg/myteam/package', { package: 'bar', }).reply(200, { accessChanged: true }) - return access.revoke('bar', 'myorg:myteam', OPTS).then(ret => { - t.same(ret, true, 'request succeeded') - }) + await t.resolves(access.revoke('bar', 'myorg:myteam', OPTS)) }) -t.test('access revoke no opts passed', t => { +t.test('access revoke no opts passed', async t => { // NOTE: mocking real url, because no opts variable means `registry` value // will be defauled to real registry url tnock(t, 'https://registry.npmjs.org') @@ -171,13 +133,10 @@ t.test('access revoke no opts passed', t => { package: 'bar', }) .reply(201) - return access.revoke('bar', 'myorg:myteam') - .then(ret => { - t.equal(ret, true, 'request succeeded') - }) + await t.resolves(access.revoke('bar', 'myorg:myteam')) }) -t.test('ls-packages on team', t => { +t.test('ls-packages on team', async t => { const serverPackages = { '@foo/bar': 'write', '@foo/util': 'read', @@ -191,12 +150,11 @@ t.test('ls-packages on team', t => { tnock(t, REG).get( '/-/team/myorg/myteam/package?format=cli' ).reply(200, serverPackages) - return access.lsPackages('myorg:myteam', OPTS).then(data => { - t.same(data, clientPackages, 'got client package info') - }) + const data = await access.lsPackages('myorg:myteam', OPTS) + t.same(data, clientPackages, 'got client package info') }) -t.test('ls-packages on org', t => { +t.test('ls-packages on org', async t => { const serverPackages = { '@foo/bar': 'write', '@foo/util': 'read', @@ -210,12 +168,11 @@ t.test('ls-packages on org', t => { tnock(t, REG).get( '/-/org/myorg/package?format=cli' ).reply(200, serverPackages) - return access.lsPackages('myorg', OPTS).then(data => { - t.same(data, clientPackages, 'got client package info') - }) + const data = await access.lsPackages('myorg', OPTS) + t.same(data, clientPackages, 'got client package info') }) -t.test('ls-packages on user', t => { +t.test('ls-packages on user', async t => { const serverPackages = { '@foo/bar': 'write', '@foo/util': 'read', @@ -229,43 +186,39 @@ t.test('ls-packages on user', t => { const srv = tnock(t, REG) srv.get('/-/org/myuser/package?format=cli').reply(404, { error: 'not found' }) srv.get('/-/user/myuser/package?format=cli').reply(200, serverPackages) - return access.lsPackages('myuser', OPTS).then(data => { - t.same(data, clientPackages, 'got client package info') - }) + const data = await access.lsPackages('myuser', OPTS) + t.same(data, clientPackages, 'got client package info') }) -t.test('ls-packages error on team', t => { +t.test('ls-packages error on team', async t => { tnock(t, REG).get('/-/team/myorg/myteam/package?format=cli').reply(404) - return access.lsPackages('myorg:myteam', OPTS).then( - () => { - throw new Error('should not have succeeded') - }, - err => t.equal(err.code, 'E404', 'spit out 404 directly if team provided') + await t.rejects( + access.lsPackages('myorg:myteam', OPTS), + { code: 'E404' }, + 'spit out 404 directly if team provided' ) }) -t.test('ls-packages error on user', t => { +t.test('ls-packages error on user', async t => { const srv = tnock(t, REG) srv.get('/-/org/myuser/package?format=cli').reply(404, { error: 'not found' }) srv.get('/-/user/myuser/package?format=cli').reply(404, { error: 'not found' }) - return access.lsPackages('myuser', OPTS).then( - () => { - throw new Error('should not have succeeded') - }, - err => t.equal(err.code, 'E404', 'spit out 404 if both reqs fail') + await t.rejects( + access.lsPackages('myuser', OPTS), + { code: 'E404' }, + 'spit out 404 if both reqs fail' ) }) -t.test('ls-packages bad response', t => { +t.test('ls-packages bad response', async t => { tnock(t, REG).get( '/-/team/myorg/myteam/package?format=cli' ).reply(200, JSON.stringify(null)) - return access.lsPackages('myorg:myteam', OPTS).then(data => { - t.same(data, null, 'succeeds with null') - }) + const data = await access.lsPackages('myorg:myteam', OPTS) + t.same(data, null, 'succeeds with null') }) -t.test('ls-packages stream', t => { +t.test('ls-packages stream', async t => { const serverPackages = { '@foo/bar': 'write', '@foo/util': 'read', @@ -279,14 +232,11 @@ t.test('ls-packages stream', t => { tnock(t, REG).get( '/-/team/myorg/myteam/package?format=cli' ).reply(200, serverPackages) - return access.lsPackages.stream('myorg:myteam', OPTS) - .collect() - .then(data => { - t.same(data, clientPackages, 'got streamed client package info') - }) + const data = await access.lsPackages.stream('myorg:myteam', OPTS).collect() + t.same(data, clientPackages, 'got streamed client package info') }) -t.test('ls-packages stream no opts', t => { +t.test('ls-packages stream no opts', async t => { const serverPackages = { '@foo/bar': 'write', '@foo/util': 'read', @@ -302,14 +252,11 @@ t.test('ls-packages stream no opts', t => { tnock(t, 'https://registry.npmjs.org') .get('/-/team/myorg/myteam/package?format=cli') .reply(200, serverPackages) - return access.lsPackages.stream('myorg:myteam') - .collect() - .then(data => { - t.same(data, clientPackages, 'got streamed client package info') - }) + const data = await access.lsPackages.stream('myorg:myteam').collect() + t.same(data, clientPackages, 'got streamed client package info') }) -t.test('ls-collaborators', t => { +t.test('ls-collaborators', async t => { const serverCollaborators = { 'myorg:myteam': 'write', 'myorg:anotherteam': 'read', @@ -323,12 +270,11 @@ t.test('ls-collaborators', t => { tnock(t, REG).get( '/-/package/%40foo%2Fbar/collaborators?format=cli' ).reply(200, serverCollaborators) - return access.lsCollaborators('@foo/bar', OPTS).then(data => { - t.same(data, clientCollaborators, 'got collaborators') - }) + const data = await access.lsCollaborators('@foo/bar', OPTS) + t.same(data, clientCollaborators, 'got collaborators') }) -t.test('ls-collaborators stream', t => { +t.test('ls-collaborators stream', async t => { const serverCollaborators = { 'myorg:myteam': 'write', 'myorg:anotherteam': 'read', @@ -342,14 +288,11 @@ t.test('ls-collaborators stream', t => { tnock(t, REG).get( '/-/package/%40foo%2Fbar/collaborators?format=cli' ).reply(200, serverCollaborators) - return access.lsCollaborators.stream('@foo/bar', OPTS) - .collect() - .then(data => { - t.same(data, clientCollaborators, 'got collaborators') - }) + const data = await access.lsCollaborators.stream('@foo/bar', OPTS).collect() + t.same(data, clientCollaborators, 'got collaborators') }) -t.test('ls-collaborators w/scope', t => { +t.test('ls-collaborators w/scope', async t => { const serverCollaborators = { 'myorg:myteam': 'write', 'myorg:anotherteam': 'read', @@ -363,12 +306,11 @@ t.test('ls-collaborators w/scope', t => { tnock(t, REG).get( '/-/package/%40foo%2Fbar/collaborators?format=cli&user=zkat' ).reply(200, serverCollaborators) - return access.lsCollaborators('@foo/bar', 'zkat', OPTS).then(data => { - t.same(data, clientCollaborators, 'got collaborators') - }) + const data = await access.lsCollaborators('@foo/bar', 'zkat', OPTS) + t.same(data, clientCollaborators, 'got collaborators') }) -t.test('ls-collaborators w/o scope', t => { +t.test('ls-collaborators w/o scope', async t => { const serverCollaborators = { 'myorg:myteam': 'write', 'myorg:anotherteam': 'read', @@ -382,36 +324,33 @@ t.test('ls-collaborators w/o scope', t => { tnock(t, REG).get( '/-/package/bar/collaborators?format=cli&user=zkat' ).reply(200, serverCollaborators) - return access.lsCollaborators('bar', 'zkat', OPTS).then(data => { - t.same(data, clientCollaborators, 'got collaborators') - }) + const data = await access.lsCollaborators('bar', 'zkat', OPTS) + t.same(data, clientCollaborators, 'got collaborators') }) -t.test('ls-collaborators bad response', t => { +t.test('ls-collaborators bad response', async t => { tnock(t, REG).get( '/-/package/%40foo%2Fbar/collaborators?format=cli' ).reply(200, JSON.stringify(null)) - return access.lsCollaborators('@foo/bar', null, OPTS).then(data => { - t.same(data, null, 'succeeds with null') - }) + const data = await access.lsCollaborators('@foo/bar', null, OPTS) + t.same(data, null, 'succeeds with null') }) -t.test('error on non-registry specs', t => { - const resolve = () => { - throw new Error('should not succeed') - } - const reject = err => t.match( - err.message, /spec.*must be a registry spec/, 'registry spec required' - ) - return Promise.all([ - access.public('githubusername/reponame').then(resolve, reject), - access.restricted('foo/bar').then(resolve, reject), - access.grant('foo/bar', 'myorg', 'myteam', 'read-only').then(resolve, reject), - access.revoke('foo/bar', 'myorg', 'myteam').then(resolve, reject), - access.lsCollaborators('foo/bar').then(resolve, reject), - access.tfaRequired('foo/bar').then(resolve, reject), - access.tfaNotRequired('foo/bar').then(resolve, reject), - ]) +t.test('error on non-registry specs', async t => { + await t.rejects(access.public('githubusername/reponame'), + /spec.*must be a registry spec/, 'registry spec required') + await t.rejects(access.restricted('foo/bar'), + /spec.*must be a registry spec/, 'registry spec required') + await t.rejects(access.grant('foo/bar', 'myorg', 'myteam', 'read-only'), + /spec.*must be a registry spec/, 'registry spec required') + await t.rejects(access.revoke('foo/bar', 'myorg', 'myteam'), + /spec.*must be a registry spec/, 'registry spec required') + await t.rejects(access.lsCollaborators('foo/bar'), + /spec.*must be a registry spec/, 'registry spec required') + await t.rejects(access.tfaRequired('foo/bar'), + /spec.*must be a registry spec/, 'registry spec required') + await t.rejects(access.tfaNotRequired('foo/bar'), + /spec.*must be a registry spec/, 'registry spec required') }) t.test('edit', t => { diff --git a/workspaces/libnpmdiff/package.json b/workspaces/libnpmdiff/package.json index 814629dd2e295..d0e92f42c94f2 100644 --- a/workspaces/libnpmdiff/package.json +++ b/workspaces/libnpmdiff/package.json @@ -45,7 +45,7 @@ "template-oss-apply": "template-oss-apply --force" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "tap": "^16.0.1" }, diff --git a/workspaces/libnpmdiff/test/tarball.js b/workspaces/libnpmdiff/test/tarball.js index b0a507c84cdd1..cb61556286879 100644 --- a/workspaces/libnpmdiff/test/tarball.js +++ b/workspaces/libnpmdiff/test/tarball.js @@ -11,7 +11,7 @@ const tarball = require('../lib/tarball.js') const json = (obj) => `${JSON.stringify(obj, null, 2)}\n` -t.test('returns a tarball from node_modules', t => { +t.test('returns a tarball from node_modules', async t => { t.plan(2) const path = t.testdir({ @@ -33,22 +33,21 @@ t.test('returns a tarball from node_modules', t => { process.chdir(_cwd) }) - tarball({ bin: { a: 'index.js' }, _resolved: resolve(path, 'node_modules/a') }, { where: path }) - .then(res => { - tar.list({ - filter: p => { - t.match( - p, - /package.json|index.js/, - 'should return tarball with expected files' - ) - }, - }) - .on('error', e => { - throw e - }) - .end(res) - }) + const res = await tarball( + { bin: { a: 'index.js' }, _resolved: resolve(path, 'node_modules/a') }, + { where: path } + ) + tar.list({ + filter: p => { + t.match( + p, + /package.json|index.js/, + 'should return tarball with expected files' + ) + }, + }).on('error', e => { + throw e + }).end(res) }) t.test('node_modules folder within a linked dir', async t => { diff --git a/workspaces/libnpmexec/package.json b/workspaces/libnpmexec/package.json index 4de7259071fd2..e7640d66f0999 100644 --- a/workspaces/libnpmexec/package.json +++ b/workspaces/libnpmexec/package.json @@ -49,9 +49,11 @@ "files": "test/*.js" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "bin-links": "^3.0.0", + "minify-registry-metadata": "^2.2.0", + "mkdirp": "^1.0.4", "tap": "^16.0.1" }, "dependencies": { diff --git a/workspaces/libnpmexec/test/run-script.js b/workspaces/libnpmexec/test/run-script.js index 9e0db1367fed1..40b31ebdf2b19 100644 --- a/workspaces/libnpmexec/test/run-script.js +++ b/workspaces/libnpmexec/test/run-script.js @@ -55,7 +55,7 @@ t.test('no package.json', t => { runScript(baseOpts) }) -t.test('colorized interactive mode msg', t => { +t.test('colorized interactive mode msg', async t => { t.plan(2) const runScript = t.mock('../lib/run-script.js', { @@ -67,7 +67,7 @@ t.test('colorized interactive mode msg', t => { }) const OUTPUT = [] - runScript({ + await runScript({ ...baseOpts, output: msg => { OUTPUT.push(msg) @@ -75,15 +75,10 @@ t.test('colorized interactive mode msg', t => { runPath: '/foo/', color: true, }) - .then(() => { - t.matchSnapshot(OUTPUT.join('\n'), 'should print colorized output') - }) - .catch(err => { - throw err - }) + t.matchSnapshot(OUTPUT.join('\n'), 'should print colorized output') }) -t.test('no color interactive mode msg', t => { +t.test('no color interactive mode msg', async t => { t.plan(2) const runScript = t.mock('../lib/run-script.js', { @@ -95,19 +90,14 @@ t.test('no color interactive mode msg', t => { }) const OUTPUT = [] - runScript({ + await runScript({ ...baseOpts, output: msg => { OUTPUT.push(msg) }, runPath: '/foo/', }) - .then(() => { - t.matchSnapshot(OUTPUT.join('\n'), 'should print non-colorized output') - }) - .catch(err => { - throw err - }) + t.matchSnapshot(OUTPUT.join('\n'), 'should print non-colorized output') }) t.test('no tty', t => { diff --git a/workspaces/libnpmfund/package.json b/workspaces/libnpmfund/package.json index 7dd3e1b648474..aa2186148e353 100644 --- a/workspaces/libnpmfund/package.json +++ b/workspaces/libnpmfund/package.json @@ -44,7 +44,7 @@ "template-oss-apply": "template-oss-apply --force" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "tap": "^16.0.1" }, diff --git a/workspaces/libnpmhook/package.json b/workspaces/libnpmhook/package.json index 2f76b52f8e1be..a26338262e96b 100644 --- a/workspaces/libnpmhook/package.json +++ b/workspaces/libnpmhook/package.json @@ -39,7 +39,7 @@ "npm-registry-fetch": "^13.0.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "nock": "^13.2.4", "tap": "^16.0.1" diff --git a/workspaces/libnpmorg/package.json b/workspaces/libnpmorg/package.json index 280fa5339ca53..852aa69e3a3f3 100644 --- a/workspaces/libnpmorg/package.json +++ b/workspaces/libnpmorg/package.json @@ -30,7 +30,7 @@ "lib/" ], "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "minipass": "^3.1.1", "nock": "^13.2.4", diff --git a/workspaces/libnpmorg/test/index.js b/workspaces/libnpmorg/test/index.js index ecdda07c06aca..bbe4ff4fcd02a 100644 --- a/workspaces/libnpmorg/test/index.js +++ b/workspaces/libnpmorg/test/index.js @@ -11,7 +11,7 @@ const OPTS = { } const REG = 'https://registry.npmjs.org/' -test('set', t => { +test('set', async t => { const memDeets = { org: { name: 'myorg', @@ -27,13 +27,11 @@ test('set', t => { }) .reply(201, memDeets) - return org.set('myorg', 'myuser', 'admin', OPTS) - .then(res => { - t.same(res, memDeets, 'got a membership details object back') - }) + const res = await org.set('myorg', 'myuser', 'admin', OPTS) + t.same(res, memDeets, 'got a membership details object back') }) -test('optional role for set', t => { +test('optional role for set', async t => { const memDeets = { org: { name: 'myorg', @@ -45,57 +43,48 @@ test('optional role for set', t => { tnock(t, OPTS.registry).put('/-/org/myorg/user', { user: 'myuser', }).reply(201, memDeets) - return org.set('myorg', 'myuser', OPTS).then(res => { - t.same(res, memDeets, 'got a membership details object back') - }) + const res = await org.set('myorg', 'myuser', OPTS) + t.same(res, memDeets, 'got a membership details object back') }) -test('rm with no options', t => { +test('rm with no options', async t => { tnock(t, REG).delete('/-/org/myorg/user', { user: 'myuser', }).reply(204) - return org.rm('myorg', 'myuser').then(() => { - t.ok(true, 'request succeeded') - }) + await t.resolves(org.rm('myorg', 'myuser')) }) -test('rm', t => { +test('rm', async t => { tnock(t, OPTS.registry).delete('/-/org/myorg/user', { user: 'myuser', }).reply(204) - return org.rm('myorg', 'myuser', OPTS) - .then(ret => { - t.equal(ret, null, 'null return value') - t.ok(true, 'request succeeded') - }) + const ret = await org.rm('myorg', 'myuser', OPTS) + t.equal(ret, null, 'null return value') }) -test('ls with no options', t => { +test('ls with no options', async t => { const roster = { zkat: 'developer', iarna: 'admin', isaacs: 'owner', } tnock(t, REG).get('/-/org/myorg/user').reply(200, roster) - return org.ls('myorg').then(res => { - t.same(res, roster, 'got back a roster') - }) + const res = await org.ls('myorg') + t.same(res, roster, 'got back a roster') }) -test('ls', t => { +test('ls', async t => { const roster = { zkat: 'developer', iarna: 'admin', isaacs: 'owner', } tnock(t, OPTS.registry).get('/-/org/myorg/user').reply(200, roster) - return org.ls('myorg', OPTS).then(res => { - t.same(res, roster, 'got back a roster') - }) + const res = await org.ls('myorg', OPTS) + t.same(res, roster, 'got back a roster') }) -test('ls stream with no options', t => { - t.plan(2) +test('ls stream with no options', async t => { const roster = { zkat: 'developer', iarna: 'admin', @@ -105,14 +94,11 @@ test('ls stream with no options', t => { tnock(t, REG).get('/-/org/myorg/user').reply(200, roster) const result = org.ls.stream('myorg') t.ok(Minipass.isStream(result), 'returns a stream') - return result.collect() - .then(res => { - t.same(res, rosterArr, 'got back a roster, in entries format') - }) + const res = await result.collect() + t.same(res, rosterArr, 'got back a roster, in entries format') }) -test('ls stream', t => { - t.plan(2) +test('ls stream', async t => { const roster = { zkat: 'developer', iarna: 'admin', @@ -122,8 +108,6 @@ test('ls stream', t => { tnock(t, OPTS.registry).get('/-/org/myorg/user').reply(200, roster) const result = org.ls.stream('myorg', OPTS) t.ok(Minipass.isStream(result), 'returns a stream') - return result.collect() - .then(res => { - t.same(res, rosterArr, 'got back a roster, in entries format') - }) + const res = await result.collect() + t.same(res, rosterArr, 'got back a roster, in entries format') }) diff --git a/workspaces/libnpmpack/package.json b/workspaces/libnpmpack/package.json index 86bec9ff1d618..c1303e37eb8aa 100644 --- a/workspaces/libnpmpack/package.json +++ b/workspaces/libnpmpack/package.json @@ -25,7 +25,7 @@ "template-oss-apply": "template-oss-apply --force" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "nock": "^13.0.7", "tap": "^16.0.1" diff --git a/workspaces/libnpmpublish/package.json b/workspaces/libnpmpublish/package.json index 9d1f9de5c5e20..c561b86b9ea71 100644 --- a/workspaces/libnpmpublish/package.json +++ b/workspaces/libnpmpublish/package.json @@ -27,7 +27,7 @@ "template-oss-apply": "template-oss-apply --force" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "libnpmpack": "^4.0.0", "lodash.clonedeep": "^4.5.0", diff --git a/workspaces/libnpmsearch/package.json b/workspaces/libnpmsearch/package.json index dc28a374b21ec..12b62afc91a14 100644 --- a/workspaces/libnpmsearch/package.json +++ b/workspaces/libnpmsearch/package.json @@ -28,7 +28,7 @@ "template-oss-apply": "template-oss-apply --force" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "nock": "^13.2.4", "tap": "^16.0.1" diff --git a/workspaces/libnpmsearch/test/index.js b/workspaces/libnpmsearch/test/index.js index 8512ecb0f18f5..dd54949dae613 100644 --- a/workspaces/libnpmsearch/test/index.js +++ b/workspaces/libnpmsearch/test/index.js @@ -12,7 +12,7 @@ const REG = OPTS.registry const NPM_REG = 'https://registry.npmjs.org/' const search = require('../lib/index.js') -test('basic test no options', t => { +test('basic test no options', async t => { const query = qs.stringify({ text: 'oo', size: 20, @@ -27,18 +27,17 @@ test('basic test no options', t => { { package: { name: 'foo', version: '2.0.0' } }, ], }) - return search('oo').then(results => { - t.match(results, [{ - name: 'cool', - version: '1.0.0', - }, { - name: 'foo', - version: '2.0.0', - }], 'got back an array of search results') - }) + const results = await search('oo') + t.match(results, [{ + name: 'cool', + version: '1.0.0', + }, { + name: 'foo', + version: '2.0.0', + }], 'got back an array of search results') }) -test('basic test', t => { +test('basic test', async t => { const query = qs.stringify({ text: 'oo', size: 20, @@ -53,18 +52,17 @@ test('basic test', t => { { package: { name: 'foo', version: '2.0.0' } }, ], }) - return search('oo', OPTS).then(results => { - t.match(results, [{ - name: 'cool', - version: '1.0.0', - }, { - name: 'foo', - version: '2.0.0', - }], 'got back an array of search results') - }) + const results = await search('oo', OPTS) + t.match(results, [{ + name: 'cool', + version: '1.0.0', + }, { + name: 'foo', + version: '2.0.0', + }], 'got back an array of search results') }) -test('basic test supports nested options', t => { +test('basic test supports nested options', async t => { const query = qs.stringify({ text: 'oo', size: 20, @@ -82,18 +80,17 @@ test('basic test supports nested options', t => { // this test is to ensure we don't break the nested opts parameter // that the cli supplies when a user passes --searchopts= - return search('oo', { ...OPTS, opts: { from: 1 } }).then(results => { - t.match(results, [{ - name: 'cool', - version: '1.0.0', - }, { - name: 'foo', - version: '2.0.0', - }], 'got back an array of search results') - }) + const results = await search('oo', { ...OPTS, opts: { from: 1 } }) + t.match(results, [{ + name: 'cool', + version: '1.0.0', + }, { + name: 'foo', + version: '2.0.0', + }], 'got back an array of search results') }) -test('search.stream', t => { +test('search.stream', async t => { const query = qs.stringify({ text: 'oo', size: 20, @@ -108,18 +105,17 @@ test('search.stream', t => { { package: { name: 'foo', version: '2.0.0' } }, ], }) - return search.stream('oo', OPTS).collect().then(results => { - t.match(results, [{ - name: 'cool', - version: '1.0.0', - }, { - name: 'foo', - version: '2.0.0', - }], 'has a stream-based API function with identical results') - }) + const results = await search.stream('oo', OPTS).collect() + t.match(results, [{ + name: 'cool', + version: '1.0.0', + }, { + name: 'foo', + version: '2.0.0', + }], 'has a stream-based API function with identical results') }) -test('accepts a limit option', t => { +test('accepts a limit option', async t => { const query = qs.stringify({ text: 'oo', size: 3, @@ -136,12 +132,11 @@ test('accepts a limit option', t => { { package: { name: 'cool', version: '1.0.0' } }, ], }) - return search('oo', { ...OPTS, limit: 3 }).then(results => { - t.equal(results.length, 4, 'returns more results if endpoint does so') - }) + const results = await search('oo', { ...OPTS, limit: 3 }) + t.equal(results.length, 4, 'returns more results if endpoint does so') }) -test('accepts a from option', t => { +test('accepts a from option', async t => { const query = qs.stringify({ text: 'oo', size: 20, @@ -158,12 +153,11 @@ test('accepts a from option', t => { { package: { name: 'cool', version: '1.0.0' } }, ], }) - return search('oo', { ...OPTS, from: 1 }).then(results => { - t.equal(results.length, 4, 'returns more results if endpoint does so') - }) + const results = await search('oo', { ...OPTS, from: 1 }) + t.equal(results.length, 4, 'returns more results if endpoint does so') }) -test('accepts quality/mainenance/popularity options', t => { +test('accepts quality/mainenance/popularity options', async t => { const query = qs.stringify({ text: 'oo', size: 20, @@ -180,17 +174,16 @@ test('accepts quality/mainenance/popularity options', t => { { package: { name: 'cool', version: '1.0.0' } }, ], }) - return search('oo', { + const results = await search('oo', { ...OPTS, quality: 1, popularity: 2, maintenance: 3, - }).then(results => { - t.equal(results.length, 4, 'returns more results if endpoint does so') }) + t.equal(results.length, 4, 'returns more results if endpoint does so') }) -test('sortBy: quality', t => { +test('sortBy: quality', async t => { const query = qs.stringify({ text: 'oo', size: 20, @@ -207,15 +200,14 @@ test('sortBy: quality', t => { { package: { name: 'cool', version: '1.0.0' } }, ], }) - return search('oo', { + const results = await search('oo', { ...OPTS, sortBy: 'quality', - }).then(results => { - t.equal(results.length, 4, 'returns more results if endpoint does so') }) + t.equal(results.length, 4, 'returns more results if endpoint does so') }) -test('sortBy: popularity', t => { +test('sortBy: popularity', async t => { const query = qs.stringify({ text: 'oo', size: 20, @@ -232,15 +224,14 @@ test('sortBy: popularity', t => { { package: { name: 'cool', version: '1.0.0' } }, ], }) - return search('oo', { + const results = await search('oo', { ...OPTS, sortBy: 'popularity', - }).then(results => { - t.equal(results.length, 4, 'returns more results if endpoint does so') }) + t.equal(results.length, 4, 'returns more results if endpoint does so') }) -test('sortBy: maintenance', t => { +test('sortBy: maintenance', async t => { const query = qs.stringify({ text: 'oo', size: 20, @@ -257,15 +248,14 @@ test('sortBy: maintenance', t => { { package: { name: 'cool', version: '1.0.0' } }, ], }) - return search('oo', { + const results = await search('oo', { ...OPTS, sortBy: 'maintenance', - }).then(results => { - t.equal(results.length, 4, 'returns more results if endpoint does so') }) + t.equal(results.length, 4, 'returns more results if endpoint does so') }) -test('sortBy: optimal', t => { +test('sortBy: optimal', async t => { const query = qs.stringify({ text: 'oo', size: 20, @@ -282,15 +272,14 @@ test('sortBy: optimal', t => { { package: { name: 'cool', version: '1.0.0' } }, ], }) - return search('oo', { + const results = await search('oo', { ...OPTS, sortBy: 'optimal', - }).then(results => { - t.equal(results.length, 4, 'returns more results if endpoint does so') }) + t.equal(results.length, 4, 'returns more results if endpoint does so') }) -test('detailed format', t => { +test('detailed format', async t => { const query = qs.stringify({ text: 'oo', size: 20, @@ -328,16 +317,15 @@ test('detailed format', t => { tnock(t, REG).get(`/-/v1/search?${query}`).once().reply(200, { objects: results, }) - return search('oo', { + const res = await search('oo', { ...OPTS, sortBy: 'maintenance', detailed: true, - }).then(res => { - t.same(res, results, 'return full-format results with opts.detailed') }) + t.same(res, results, 'return full-format results with opts.detailed') }) -test('space-separates and URI-encodes multiple search params', t => { +test('space-separates and URI-encodes multiple search params', async t => { const query = qs.stringify({ text: 'foo bar:baz quux?=', size: 1, @@ -348,13 +336,11 @@ test('space-separates and URI-encodes multiple search params', t => { }).replace(/%20/g, '+') tnock(t, REG).get(`/-/v1/search?${query}`).reply(200, { objects: [] }) - return search(['foo', 'bar:baz', 'quux?='], { + await t.resolves(search(['foo', 'bar:baz', 'quux?='], { ...OPTS, limit: 1, quality: 1, popularity: 2, maintenance: 3, - }).then( - () => t.ok(true, 'sent parameters correctly urlencoded') - ) + })) }) diff --git a/workspaces/libnpmteam/package.json b/workspaces/libnpmteam/package.json index 569678b5d864a..54fdab0a6c9b8 100644 --- a/workspaces/libnpmteam/package.json +++ b/workspaces/libnpmteam/package.json @@ -18,7 +18,7 @@ "template-oss-apply": "template-oss-apply --force" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "nock": "^13.2.4", "tap": "^16.0.1" diff --git a/workspaces/libnpmteam/test/index.js b/workspaces/libnpmteam/test/index.js index 6e0b92976a215..fd02666e014f6 100644 --- a/workspaces/libnpmteam/test/index.js +++ b/workspaces/libnpmteam/test/index.js @@ -10,249 +10,198 @@ const OPTS = { registry: REG, } -test('create', t => { +test('create', async t => { tnock(t, REG).put( '/-/org/foo/team', { name: 'cli' } ).reply(201, { name: 'cli' }) - return team.create('@foo:cli', OPTS).then(ret => { - t.same(ret, { name: 'cli' }, 'request succeeded') - }) + const ret = await team.create('@foo:cli', OPTS) + t.same(ret, { name: 'cli' }, 'request succeeded') }) -test('create - no options', t => { +test('create - no options', async t => { // NOTE: mocking real url, because no opts variable means `registry` value // will be defauled to real registry url in `npm-registry-fetch` tnock(t, 'https://registry.npmjs.org') .put('/-/org/foo/team', { name: 'cli' }) .reply(201, { name: 'cli' }) - return team.create('@foo:cli') - .then(ret => { - t.same(ret, { name: 'cli' }) - }) + const ret = await team.create('@foo:cli') + t.same(ret, { name: 'cli' }) }) -test('create bad entity name', t => { - return team.create('go away', OPTS).then( - () => { - throw new Error('should not succeed') - }, - err => { - t.ok(err, 'error on bad entity name') - } - ) +test('create bad entity name', async t => { + await t.rejects(team.create('go away', OPTS)) }) -test('create empty entity', t => { - return team.create(undefined, OPTS).then( - () => { - throw new Error('should not succeed') - }, - err => { - t.ok(err, 'error on bad entity name') - } - ) +test('create empty entity', async t => { + await t.rejects(team.create(undefined, OPTS)) }) -test('create w/ description', t => { +test('create w/ description', async t => { tnock(t, REG).put('/-/org/foo/team', { name: 'cli', description: 'just some cool folx', }).reply(201, { name: 'cli' }) - return team.create('@foo:cli', { + const ret = await team.create('@foo:cli', { ...OPTS, description: 'just some cool folx', - }).then(ret => { - t.same(ret, { name: 'cli' }, 'no desc in return') }) + t.same(ret, { name: 'cli' }, 'no desc in return') }) -test('destroy', t => { +test('destroy', async t => { tnock(t, REG).delete( '/-/team/foo/cli' ).reply(204, {}) - return team.destroy('@foo:cli', OPTS).then(ret => { - t.same(ret, {}, 'request succeeded') - }) + const ret = await team.destroy('@foo:cli', OPTS) + t.same(ret, {}, 'request succeeded') }) -test('destroy - no options', t => { +test('destroy - no options', async t => { // NOTE: mocking real url, because no opts variable means `registry` value // will be defauled to real registry url in `npm-registry-fetch` tnock(t, 'https://registry.npmjs.org') .delete('/-/team/foo/cli') .reply(204, {}) - return team.destroy('@foo:cli').then(ret => { - t.same(ret, {}, 'request succeeded') - }) + const ret = await team.destroy('@foo:cli') + t.same(ret, {}, 'request succeeded') }) -test('add', t => { +test('add', async t => { tnock(t, REG).put( '/-/team/foo/cli/user', { user: 'zkat' } ).reply(201, {}) - return team.add('zkat', '@foo:cli', OPTS).then(ret => { - t.same(ret, {}, 'request succeeded') - }) + const ret = await team.add('zkat', '@foo:cli', OPTS) + t.same(ret, {}, 'request succeeded') }) -test('add - no options', t => { +test('add - no options', async t => { // NOTE: mocking real url, because no opts variable means `registry` value // will be defauled to real registry url in `npm-registry-fetch` tnock(t, 'https://registry.npmjs.org') .put('/-/team/foo/cli/user', { user: 'zkat' }) .reply(201, {}) - return team.add('zkat', '@foo:cli').then(ret => { - t.same(ret, {}, 'request succeeded') - }) + const ret = await team.add('zkat', '@foo:cli') + t.same(ret, {}, 'request succeeded') }) -test('rm', t => { +test('rm', async t => { tnock(t, REG).delete( '/-/team/foo/cli/user', { user: 'zkat' } ).reply(204, {}) - return team.rm('zkat', '@foo:cli', OPTS).then(ret => { - t.same(ret, {}, 'request succeeded') - }) + const ret = await team.rm('zkat', '@foo:cli', OPTS) + t.same(ret, {}, 'request succeeded') }) -test('rm - no options', t => { +test('rm - no options', async t => { // NOTE: mocking real url, because no opts variable means `registry` value // will be defauled to real registry url in `npm-registry-fetch` tnock(t, 'https://registry.npmjs.org') .delete('/-/team/foo/cli/user', { user: 'zkat' }) .reply(204, {}) - return team.rm('zkat', '@foo:cli').then(ret => { - t.same(ret, {}, 'request succeeded') - }) + const ret = await team.rm('zkat', '@foo:cli') + t.same(ret, {}, 'request succeeded') }) -test('lsTeams', t => { +test('lsTeams', async t => { tnock(t, REG).get( '/-/org/foo/team?format=cli' ).reply(200, ['foo:bar', 'foo:cli']) - return team.lsTeams('foo', OPTS).then(ret => { - t.same(ret, ['foo:bar', 'foo:cli'], 'got teams') - }) + const ret = await team.lsTeams('foo', OPTS) + t.same(ret, ['foo:bar', 'foo:cli'], 'got teams') }) -test('lsTeams - no options', t => { +test('lsTeams - no options', async t => { // NOTE: mocking real url, because no opts variable means `registry` value // will be defauled to real registry url in `npm-registry-fetch` tnock(t, 'https://registry.npmjs.org') .get('/-/org/foo/team?format=cli') .reply(200, ['foo:bar', 'foo:cli']) - return team.lsTeams('foo').then(ret => { - t.same(ret, ['foo:bar', 'foo:cli'], 'got teams') - }) + const ret = await team.lsTeams('foo') + t.same(ret, ['foo:bar', 'foo:cli'], 'got teams') }) -test('lsTeams error', t => { +test('lsTeams error', async t => { tnock(t, REG).get( '/-/org/foo/team?format=cli' ).reply(500) - return team.lsTeams('foo', OPTS).then( - () => { - throw new Error('should not succeed') - }, - err => { - t.equal(err.code, 'E500', 'got error code') - } + await t.rejects( + team.lsTeams('foo', OPTS), + { code: 'E500' } ) }) -test('lsTeams.stream', t => { +test('lsTeams.stream', async t => { tnock(t, REG).get( '/-/org/foo/team?format=cli' ).reply(200, ['foo:bar', 'foo:cli']) - return team.lsTeams.stream('foo', OPTS) - .collect() - .then(ret => { - t.same(ret, ['foo:bar', 'foo:cli'], 'got teams') - }) + const ret = await team.lsTeams.stream('foo', OPTS).collect() + t.same(ret, ['foo:bar', 'foo:cli'], 'got teams') }) -test('lsTeams.stream - no options', t => { +test('lsTeams.stream - no options', async t => { // NOTE: mocking real url, because no opts variable means `registry` value // will be defauled to real registry url in `npm-registry-fetch` tnock(t, 'https://registry.npmjs.org') .get('/-/org/foo/team?format=cli') .reply(200, ['foo:bar', 'foo:cli']) - return team.lsTeams.stream('foo') - .collect() - .then(ret => { - t.same(ret, ['foo:bar', 'foo:cli'], 'got teams') - }) + const ret = await team.lsTeams.stream('foo').collect() + t.same(ret, ['foo:bar', 'foo:cli'], 'got teams') }) -test('lsUsers', t => { +test('lsUsers', async t => { tnock(t, REG).get( '/-/team/foo/cli/user?format=cli' ).reply(500) - return team.lsUsers('@foo:cli', OPTS).then( - () => { - throw new Error('should not succeed') - }, - err => { - t.equal(err.code, 'E500', 'got error code') - } + await t.rejects( + team.lsUsers('@foo:cli', OPTS), + { code: 'E500' } ) }) -test('lsUsers - no options', t => { +test('lsUsers - no options', async t => { // NOTE: mocking real url, because no opts variable means `registry` value // will be defauled to real registry url in `npm-registry-fetch` tnock(t, 'https://registry.npmjs.org') .get('/-/team/foo/cli/user?format=cli') .reply(500) - return team.lsUsers('@foo:cli').then( - () => { - throw new Error('should not succeed') - }, - err => { - t.equal(err.code, 'E500', 'got error code') - } + await t.rejects( + team.lsUsers('@foo:cli'), + { code: 'E500' } ) }) -test('lsUsers error', t => { +test('lsUsers error', async t => { tnock(t, REG).get( '/-/team/foo/cli/user?format=cli' ).reply(200, ['iarna', 'zkat']) - return team.lsUsers('@foo:cli', OPTS).then(ret => { - t.same(ret, ['iarna', 'zkat'], 'got team members') - }) + const ret = await team.lsUsers('@foo:cli', OPTS) + t.same(ret, ['iarna', 'zkat'], 'got team members') }) -test('lsUsers.stream', t => { +test('lsUsers.stream', async t => { tnock(t, REG).get( '/-/team/foo/cli/user?format=cli' ).reply(200, ['iarna', 'zkat']) - return team.lsUsers.stream('@foo:cli', OPTS) - .collect() - .then(ret => { - t.same(ret, ['iarna', 'zkat'], 'got team members') - }) + const ret = await team.lsUsers.stream('@foo:cli', OPTS).collect() + t.same(ret, ['iarna', 'zkat'], 'got team members') }) -test('lsUsers.stream - no options', t => { +test('lsUsers.stream - no options', async t => { // NOTE: mocking real url, because no opts variable means `registry` value // will be defauled to real registry url in `npm-registry-fetch` tnock(t, 'https://registry.npmjs.org') .get('/-/team/foo/cli/user?format=cli') .reply(200, ['iarna', 'zkat']) - return team.lsUsers.stream('@foo:cli') - .collect() - .then(ret => { - t.same(ret, ['iarna', 'zkat'], 'got team members') - }) + const ret = await team.lsUsers.stream('@foo:cli').collect() + t.same(ret, ['iarna', 'zkat'], 'got team members') }) test('edit', t => { diff --git a/workspaces/libnpmversion/lib/version.js b/workspaces/libnpmversion/lib/version.js index 12be89b040df7..f14b95e3233f0 100644 --- a/workspaces/libnpmversion/lib/version.js +++ b/workspaces/libnpmversion/lib/version.js @@ -90,7 +90,9 @@ module.exports = async (newversion, opts) => { } await writeJson(lock, sw) haveLocks.push(lock) - } catch (er) {} + } catch { + // ignore errors + } } if (!ignoreScripts) { diff --git a/workspaces/libnpmversion/package.json b/workspaces/libnpmversion/package.json index c5c1a0398bb16..bf24cc3878ffe 100644 --- a/workspaces/libnpmversion/package.json +++ b/workspaces/libnpmversion/package.json @@ -30,7 +30,7 @@ "coverage-map": "map.js" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", + "@npmcli/eslint-config": "^3.1.0", "@npmcli/template-oss": "3.5.0", "require-inject": "^1.4.4", "tap": "^16.0.1" diff --git a/workspaces/libnpmversion/test/enforce-clean.js b/workspaces/libnpmversion/test/enforce-clean.js index d96fb09ffa594..3badf47ea5bc4 100644 --- a/workspaces/libnpmversion/test/enforce-clean.js +++ b/workspaces/libnpmversion/test/enforce-clean.js @@ -21,48 +21,42 @@ const enforceClean = requireInject('../lib/enforce-clean.js', { const warnings = [] -t.test('clean, ok', t => - t.resolveMatch(enforceClean({ cwd: 'clean' }), true) - .then(() => t.strictSame(warnings, [])) - .then(() => { - warnings.length = 0 - })) +t.afterEach(() => { + warnings.length = 0 +}) -t.test('unclean, no force, throws', t => - t.rejects(enforceClean({ cwd: 'unclean' })) - .then(() => t.strictSame(warnings, [])) - .then(() => { - warnings.length = 0 - })) +t.test('clean, ok', async t => { + await t.resolveMatch(enforceClean({ cwd: 'clean' }), true) + t.strictSame(warnings, []) +}) -t.test('unclean, forced, no throw', t => - t.resolveMatch(enforceClean({ cwd: 'unclean', force: true }), true) - .then(() => t.strictSame(warnings, [ - [ - 'version', - 'Git working directory not clean, proceeding forcefully.', - ], - ])) - .then(() => { - warnings.length = 0 - })) +t.test('unclean, no force, throws', async t => { + await t.rejects(enforceClean({ cwd: 'unclean' })) + t.strictSame(warnings, []) +}) -t.test('nogit, return false, no throw', t => - t.resolveMatch(enforceClean({ cwd: 'nogit' }), false) - .then(() => t.strictSame(warnings, [ - [ - 'version', - 'This is a Git checkout, but the git command was not found.', - 'npm could not create a Git tag for this release!', - ], - ])) - .then(() => { - warnings.length = 0 - })) +t.test('unclean, forced, no throw', async t => { + await t.resolveMatch(enforceClean({ cwd: 'unclean', force: true }), true) + t.strictSame(warnings, [ + [ + 'version', + 'Git working directory not clean, proceeding forcefully.', + ], + ]) +}) -t.test('other error, throw it', t => - t.rejects(enforceClean({ cwd: 'error' }), new Error('poop')) - .then(() => t.strictSame(warnings, [])) - .then(() => { - warnings.length = 0 - })) +t.test('nogit, return false, no throw', async t => { + await t.resolveMatch(enforceClean({ cwd: 'nogit' }), false) + t.strictSame(warnings, [ + [ + 'version', + 'This is a Git checkout, but the git command was not found.', + 'npm could not create a Git tag for this release!', + ], + ]) +}) + +t.test('other error, throw it', async t => { + await t.rejects(enforceClean({ cwd: 'error' }), new Error('poop')) + t.strictSame(warnings, []) +})