From 3fbc4f173bad54dbe52524a133cf18794b5c53f2 Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Mon, 1 Mar 2021 11:38:43 -0500 Subject: [PATCH] deps: upgrade npm to 7.6.0 --- deps/npm/.npmignore | 1 + deps/npm/AUTHORS | 2 + deps/npm/CHANGELOG.md | 35 +- .../docs/content/commands/npm-unpublish.md | 2 +- deps/npm/docs/content/using-npm/developers.md | 4 +- deps/npm/docs/dockhand.js | 97 +++- deps/npm/docs/output/commands/npm-ls.html | 2 +- .../docs/output/commands/npm-unpublish.html | 2 +- deps/npm/docs/output/commands/npm.html | 2 +- .../npm/docs/output/using-npm/developers.html | 6 +- deps/npm/lib/access.js | 14 +- deps/npm/lib/adduser.js | 4 +- deps/npm/lib/audit.js | 8 +- deps/npm/lib/bin.js | 3 +- deps/npm/lib/bugs.js | 3 +- deps/npm/lib/cache.js | 6 +- deps/npm/lib/ci.js | 3 +- deps/npm/lib/completion.js | 24 +- deps/npm/lib/config.js | 10 +- deps/npm/lib/dedupe.js | 3 +- deps/npm/lib/deprecate.js | 20 +- deps/npm/lib/diff.js | 3 +- deps/npm/lib/dist-tag.js | 6 +- deps/npm/lib/docs.js | 3 +- deps/npm/lib/doctor.js | 3 +- deps/npm/lib/exec.js | 4 +- deps/npm/lib/explain.js | 3 +- deps/npm/lib/find-dupes.js | 3 +- deps/npm/lib/get.js | 3 +- deps/npm/lib/help-search.js | 3 +- deps/npm/lib/help.js | 35 +- deps/npm/lib/hook.js | 4 +- deps/npm/lib/init.js | 3 +- deps/npm/lib/install.js | 11 +- deps/npm/lib/link.js | 9 +- deps/npm/lib/ll.js | 7 +- deps/npm/lib/logout.js | 3 +- deps/npm/lib/org.js | 8 +- deps/npm/lib/outdated.js | 3 +- deps/npm/lib/owner.js | 39 +- deps/npm/lib/pack.js | 3 +- deps/npm/lib/ping.js | 3 +- deps/npm/lib/prefix.js | 3 +- deps/npm/lib/profile.js | 10 +- deps/npm/lib/prune.js | 3 +- deps/npm/lib/publish.js | 3 +- deps/npm/lib/repo.js | 3 +- deps/npm/lib/root.js | 3 +- deps/npm/lib/run-script.js | 6 +- deps/npm/lib/search.js | 3 +- deps/npm/lib/set-script.js | 3 +- deps/npm/lib/set.js | 16 +- deps/npm/lib/shrinkwrap.js | 3 +- deps/npm/lib/star.js | 3 +- deps/npm/lib/stars.js | 3 +- deps/npm/lib/team.js | 8 +- deps/npm/lib/token.js | 8 +- deps/npm/lib/unpublish.js | 6 +- deps/npm/lib/unstar.js | 4 +- .../lib/utils/completion/installed-deep.js | 6 +- .../lib/utils/completion/installed-shallow.js | 5 +- deps/npm/lib/utils/completion/none.js | 2 - deps/npm/lib/utils/explain-dep.js | 8 +- deps/npm/lib/utils/lifecycle-cmd.js | 3 +- deps/npm/lib/version.js | 9 +- deps/npm/lib/view.js | 8 +- deps/npm/lib/whoami.js | 3 +- deps/npm/man/man1/npm-access.1 | 2 +- deps/npm/man/man1/npm-adduser.1 | 2 +- deps/npm/man/man1/npm-audit.1 | 2 +- deps/npm/man/man1/npm-bin.1 | 2 +- deps/npm/man/man1/npm-bugs.1 | 2 +- deps/npm/man/man1/npm-cache.1 | 2 +- deps/npm/man/man1/npm-ci.1 | 2 +- deps/npm/man/man1/npm-completion.1 | 2 +- deps/npm/man/man1/npm-config.1 | 2 +- deps/npm/man/man1/npm-dedupe.1 | 2 +- deps/npm/man/man1/npm-deprecate.1 | 2 +- deps/npm/man/man1/npm-diff.1 | 2 +- deps/npm/man/man1/npm-dist-tag.1 | 2 +- deps/npm/man/man1/npm-docs.1 | 2 +- deps/npm/man/man1/npm-doctor.1 | 2 +- deps/npm/man/man1/npm-edit.1 | 2 +- deps/npm/man/man1/npm-exec.1 | 2 +- deps/npm/man/man1/npm-explain.1 | 2 +- deps/npm/man/man1/npm-explore.1 | 2 +- deps/npm/man/man1/npm-fund.1 | 2 +- deps/npm/man/man1/npm-help-search.1 | 2 +- deps/npm/man/man1/npm-help.1 | 2 +- deps/npm/man/man1/npm-hook.1 | 2 +- deps/npm/man/man1/npm-init.1 | 2 +- deps/npm/man/man1/npm-install-ci-test.1 | 2 +- deps/npm/man/man1/npm-install-test.1 | 2 +- deps/npm/man/man1/npm-install.1 | 2 +- deps/npm/man/man1/npm-link.1 | 2 +- deps/npm/man/man1/npm-logout.1 | 2 +- deps/npm/man/man1/npm-ls.1 | 4 +- deps/npm/man/man1/npm-org.1 | 2 +- deps/npm/man/man1/npm-outdated.1 | 2 +- deps/npm/man/man1/npm-owner.1 | 2 +- deps/npm/man/man1/npm-pack.1 | 2 +- deps/npm/man/man1/npm-ping.1 | 2 +- deps/npm/man/man1/npm-prefix.1 | 2 +- deps/npm/man/man1/npm-profile.1 | 2 +- deps/npm/man/man1/npm-prune.1 | 2 +- deps/npm/man/man1/npm-publish.1 | 2 +- deps/npm/man/man1/npm-rebuild.1 | 2 +- deps/npm/man/man1/npm-repo.1 | 2 +- deps/npm/man/man1/npm-restart.1 | 2 +- deps/npm/man/man1/npm-root.1 | 2 +- deps/npm/man/man1/npm-run-script.1 | 2 +- deps/npm/man/man1/npm-search.1 | 2 +- deps/npm/man/man1/npm-set-script.1 | 2 +- deps/npm/man/man1/npm-shrinkwrap.1 | 2 +- deps/npm/man/man1/npm-star.1 | 2 +- deps/npm/man/man1/npm-stars.1 | 2 +- deps/npm/man/man1/npm-start.1 | 2 +- deps/npm/man/man1/npm-stop.1 | 2 +- deps/npm/man/man1/npm-team.1 | 2 +- deps/npm/man/man1/npm-test.1 | 2 +- deps/npm/man/man1/npm-token.1 | 2 +- deps/npm/man/man1/npm-uninstall.1 | 2 +- deps/npm/man/man1/npm-unpublish.1 | 4 +- deps/npm/man/man1/npm-unstar.1 | 2 +- deps/npm/man/man1/npm-update.1 | 2 +- deps/npm/man/man1/npm-version.1 | 2 +- deps/npm/man/man1/npm-view.1 | 2 +- deps/npm/man/man1/npm-whoami.1 | 2 +- deps/npm/man/man1/npm.1 | 4 +- deps/npm/man/man1/npx.1 | 2 +- deps/npm/man/man5/folders.5 | 2 +- deps/npm/man/man5/install.5 | 2 +- deps/npm/man/man5/npm-shrinkwrap-json.5 | 2 +- deps/npm/man/man5/npmrc.5 | 2 +- deps/npm/man/man5/package-json.5 | 2 +- deps/npm/man/man5/package-lock-json.5 | 2 +- deps/npm/man/man5/package-locks.5 | 200 ------- deps/npm/man/man5/shrinkwrap-json.5 | 32 -- deps/npm/man/man7/config.7 | 2 +- deps/npm/man/man7/developers.7 | 6 +- deps/npm/man/man7/disputes.7 | 149 ----- deps/npm/man/man7/orgs.7 | 2 +- deps/npm/man/man7/registry.7 | 2 +- deps/npm/man/man7/removal.7 | 2 +- deps/npm/man/man7/scope.7 | 2 +- deps/npm/man/man7/scripts.7 | 2 +- deps/npm/man/man7/semver.7 | 510 ------------------ deps/npm/man/man7/workspaces.7 | 2 +- .../@npmcli/arborist/lib/arborist/index.js | 2 + .../@npmcli/arborist/lib/shrinkwrap.js | 24 +- .../@npmcli/arborist/lib/tracker.js | 5 +- .../@npmcli/arborist/package.json | 17 +- deps/npm/package.json | 4 +- .../test-lib-utils-explain-dep.js-TAP.test.js | 22 + deps/npm/test/lib/access.js | 45 +- deps/npm/test/lib/audit.js | 33 +- deps/npm/test/lib/bugs.js | 8 - deps/npm/test/lib/cache.js | 12 +- deps/npm/test/lib/completion.js | 93 ++-- deps/npm/test/lib/config.js | 36 +- deps/npm/test/lib/deprecate.js | 29 +- deps/npm/test/lib/dist-tag.js | 36 +- deps/npm/test/lib/docs.js | 8 - deps/npm/test/lib/help.js | 13 +- deps/npm/test/lib/install.js | 74 +-- deps/npm/test/lib/link.js | 31 +- deps/npm/test/lib/load-all-commands.js | 7 +- deps/npm/test/lib/ls.js | 15 + deps/npm/test/lib/org.js | 11 +- deps/npm/test/lib/owner.js | 66 +-- deps/npm/test/lib/profile.js | 47 +- deps/npm/test/lib/repo.js | 8 - deps/npm/test/lib/restart.js | 1 - deps/npm/test/lib/run-script.js | 48 +- deps/npm/test/lib/set-script.js | 1 - deps/npm/test/lib/start.js | 1 - deps/npm/test/lib/stop.js | 1 - deps/npm/test/lib/team.js | 65 +-- deps/npm/test/lib/token.js | 21 +- deps/npm/test/lib/unpublish.js | 16 +- .../lib/utils/completion/installed-deep.js | 125 ++--- .../lib/utils/completion/installed-shallow.js | 49 +- deps/npm/test/lib/utils/completion/none.js | 6 - deps/npm/test/lib/utils/explain-dep.js | 17 + deps/npm/test/lib/utils/lifecycle-cmd.js | 1 - deps/npm/test/lib/version.js | 14 +- deps/npm/test/lib/view.js | 22 +- 187 files changed, 819 insertions(+), 1812 deletions(-) delete mode 100644 deps/npm/lib/utils/completion/none.js delete mode 100644 deps/npm/man/man5/package-locks.5 delete mode 100644 deps/npm/man/man5/shrinkwrap-json.5 delete mode 100644 deps/npm/man/man7/disputes.7 delete mode 100644 deps/npm/man/man7/semver.7 delete mode 100644 deps/npm/test/lib/utils/completion/none.js diff --git a/deps/npm/.npmignore b/deps/npm/.npmignore index b90057457893ba..d1b1fde3d4e0d0 100644 --- a/deps/npm/.npmignore +++ b/deps/npm/.npmignore @@ -16,6 +16,7 @@ node_modules/npm-registry-mock # don't need these in the npm package. html/*.png +docs/nav.yml # don't ignore .npmignore files # these are used in some tests. diff --git a/deps/npm/AUTHORS b/deps/npm/AUTHORS index 3032e1e5459d36..e58d1dffaeaf1d 100644 --- a/deps/npm/AUTHORS +++ b/deps/npm/AUTHORS @@ -753,3 +753,5 @@ Alexander Riccio RA80533 <32469082+RA80533@users.noreply.github.com> Ikko Ashimine MrBrain295 <66077254+MrBrain295@users.noreply.github.com> +kumavis +Christof Lemke diff --git a/deps/npm/CHANGELOG.md b/deps/npm/CHANGELOG.md index 9e76a074739e51..22e6018f0a86c7 100644 --- a/deps/npm/CHANGELOG.md +++ b/deps/npm/CHANGELOG.md @@ -1,4 +1,37 @@ -## v7.5.6 (2021-02-22 +## v7.6.0 (2021-02-25) + +### FEATURES + +* [`983d218f7`](https://github.com/npm/cli/commit/983d218f7e68e3c7866f2efa23ea2aff7ff3881e) + [#2750](https://github.com/npm/cli/issues/2750) + feat(explain): mark when dependency is bundled + ([@kumavis](https://github.com/kumavis)) + +### DEPENDENCIES + +* [`b9fa7e32a`](https://github.com/npm/cli/commit/b9fa7e32a63a3dc3a4865865c4ca737c862b9cf2) + chore(package-lock): resetdeps and `eslint@7.20.0` + ([@wraithgar](https://github.com/wraithgar)) +* [`28d036ae9`](https://github.com/npm/cli/commit/28d036ae9179f742bd0518e558a54f014a7a895e) + `arborist@2.2.5` + * fix: hidden lockfiles were not respected on Node v10.0-10.12 + +### DOCUMENTATION + +* [`ba1adef42`](https://github.com/npm/cli/commit/ba1adef4292123e87e26b59e0c6fd6f5ff1fe775) + [#2760](https://github.com/npm/cli/issues/2760) + chore(docs): capitalize all Instaces of "package" + ([@MrBrain295](https://github.com/MrBrain295)) +* [`8bfa05fa1`](https://github.com/npm/cli/commit/8bfa05fa1dfd4a64381c7ec750df6d174724e8c1) + [#2775](https://github.com/npm/cli/issues/2775) + chore(docs): add navigation configuration + ([@ethomson](https://github.com/ethomson)) +* [`238e474a4`](https://github.com/npm/cli/commit/238e474a48ddecc33c76eb3d2c4d0642cfe8829a) + [#2778](https://github.com/npm/cli/issues/2778) + chore(docs):update unpublish cooldown + ([@christoflemke](https://github.com/christoflemke)) + +## v7.5.6 (2021-02-22) ### BUG FIXES diff --git a/deps/npm/docs/content/commands/npm-unpublish.md b/deps/npm/docs/content/commands/npm-unpublish.md index e9d6e9045c6f9e..14813e94341f52 100644 --- a/deps/npm/docs/content/commands/npm-unpublish.md +++ b/deps/npm/docs/content/commands/npm-unpublish.md @@ -42,7 +42,7 @@ versions then the registry will remove the root package entry entirely. Even if you unpublish a package version, that specific name and version combination can never be reused. In order to publish the package again, you must use a new version number. If you unpublish the entire package, -you may not publish any new versions of that package until 24 hours have +you may not publish any new versions of that package until 28 days have passed. ### See Also diff --git a/deps/npm/docs/content/using-npm/developers.md b/deps/npm/docs/content/using-npm/developers.md index 627ce7c7073c68..a76808ca675e61 100644 --- a/deps/npm/docs/content/using-npm/developers.md +++ b/deps/npm/docs/content/using-npm/developers.md @@ -93,7 +93,7 @@ You can use `npm init` in the root of your package in order to get you started with a pretty basic package.json file. See [`npm init`](/commands/npm-init) for more info. -### Keeping files *out* of your package +### Keeping files *out* of your Package Use a `.npmignore` file to keep stuff out of your package. If there's no `.npmignore` file, but there *is* a `.gitignore` file, then npm will ignore @@ -210,7 +210,7 @@ and then follow the prompts. This is documented better in [npm adduser](/commands/npm-adduser). -### Publish your package +### Publish your Package This part's easy. In the root of your folder, do this: diff --git a/deps/npm/docs/dockhand.js b/deps/npm/docs/dockhand.js index ae68e3fbb830c7..7f2c90dae9b09b 100644 --- a/deps/npm/docs/dockhand.js +++ b/deps/npm/docs/dockhand.js @@ -19,7 +19,12 @@ const template = fs.readFileSync('template.html').toString(); const run = async function() { try { - await walk(inputRoot); + const navPaths = await getNavigationPaths(); + const fsPaths = await renderFilesystemPaths(); + + if (!ensureNavigationComplete(navPaths, fsPaths)) { + process.exit(1); + } } catch (error) { console.error(error); @@ -28,7 +33,85 @@ const run = async function() { run(); -async function walk(root, dirRelative) { +function ensureNavigationComplete(navPaths, fsPaths) { + const unmatchedNav = { }, unmatchedFs = { }; + + for (const navPath of navPaths) { + unmatchedNav[navPath] = true; + } + + for (let fsPath of fsPaths) { + fsPath = '/' + fsPath.replace(/\.md$/, ""); + + if (unmatchedNav[fsPath]) { + delete unmatchedNav[fsPath]; + } + else { + unmatchedFs[fsPath] = true; + } + } + + const missingNav = Object.keys(unmatchedNav).sort(); + const missingFs = Object.keys(unmatchedFs).sort() + + if (missingNav.length > 0 || missingFs.length > 0) { + let message = "Error: documentation navigation (nav.yml) does not match filesystem.\n"; + + if (missingNav.length > 0) { + message += "\nThe following path(s) exist on disk but are not present in nav.yml:\n\n"; + + for (const nav of missingNav) { + message += ` ${nav}\n`; + } + } + + if (missingNav.length > 0 && missingFs.length > 0) { + message += "\nThe following path(s) exist in nav.yml but are not present on disk:\n\n"; + + for (const fs of missingFs) { + message += ` ${fs}\n`; + } + } + + message += "\nUpdate nav.yml to ensure that all files are listed in the appropriate place."; + + console.error(message); + + return false; + } + + return true; +} + +function getNavigationPaths() { + const navFilename = path.join(docsRoot, 'nav.yml'); + const nav = yaml.parse(fs.readFileSync(navFilename).toString(), 'utf8'); + + return walkNavigation(nav); +} + +function walkNavigation(entries) { + const paths = [ ] + + for (const entry of entries) { + if (entry.children) { + paths.push(... walkNavigation(entry.children)); + } + else { + paths.push(entry.url); + } + } + + return paths; +} + +async function renderFilesystemPaths() { + return await walkFilesystem(inputRoot); +} + +async function walkFilesystem(root, dirRelative) { + const paths = [ ] + const dirPath = dirRelative ? path.join(root, dirRelative) : root; const children = fs.readdirSync(dirPath); @@ -37,15 +120,18 @@ async function walk(root, dirRelative) { const childPath = path.join(root, childRelative); if (fs.lstatSync(childPath).isDirectory()) { - await walk(root, childRelative); + paths.push(... await walkFilesystem(root, childRelative)); } else { - await translate(childRelative); + await renderFile(childRelative); + paths.push(childRelative); } } + + return paths; } -async function translate(childPath) { +async function renderFile(childPath) { const inputPath = path.join(inputRoot, childPath); if (!inputPath.match(/\.md$/)) { @@ -119,7 +205,6 @@ async function translate(childPath) { console.log(`warning: unknown token '${token}' in ${inputPath}`); return ''; } - console.log(key); return key; }); diff --git a/deps/npm/docs/output/commands/npm-ls.html b/deps/npm/docs/output/commands/npm-ls.html index f4cfc919c07029..aaa6f3ea28ca98 100644 --- a/deps/npm/docs/output/commands/npm-ls.html +++ b/deps/npm/docs/output/commands/npm-ls.html @@ -159,7 +159,7 @@

Description

the results to only the paths to the packages named. Note that nested packages will also show the paths to the specified packages. For example, running npm ls promzard in npm’s source tree will show:

-
npm@7.5.6 /path/to/npm
+
npm@7.6.0 /path/to/npm
 └─┬ init-package-json@0.0.4
   └── promzard@0.1.5
 
diff --git a/deps/npm/docs/output/commands/npm-unpublish.html b/deps/npm/docs/output/commands/npm-unpublish.html index 75751d3408cfa1..3ec254a109d470 100644 --- a/deps/npm/docs/output/commands/npm-unpublish.html +++ b/deps/npm/docs/output/commands/npm-unpublish.html @@ -166,7 +166,7 @@

Description

Even if you unpublish a package version, that specific name and version combination can never be reused. In order to publish the package again, you must use a new version number. If you unpublish the entire package, -you may not publish any new versions of that package until 24 hours have +you may not publish any new versions of that package until 28 days have passed.

See Also

You can use npm init in the root of your package in order to get you started with a pretty basic package.json file. See npm init for more info.

-

Keeping files out of your package

+

Keeping files out of your Package

Use a .npmignore file to keep stuff out of your package. If there’s no .npmignore file, but there is a .gitignore file, then npm will ignore the stuff matched by the .gitignore file. If you want to include @@ -310,7 +310,7 @@

Create a User Account

and then follow the prompts.

This is documented better in npm adduser.

-

Publish your package

+

Publish your Package

This part’s easy. In the root of your folder, do this:

npm publish
 
diff --git a/deps/npm/lib/access.js b/deps/npm/lib/access.js index 8a372d90cb55cd..10b1e21e0c5d7e 100644 --- a/deps/npm/lib/access.js +++ b/deps/npm/lib/access.js @@ -59,17 +59,17 @@ const access = async ([cmd, ...args], cb) => { return fn(args, { ...npm.flatOptions }) } -const completion = function (opts, cb) { - var argv = opts.conf.argv.remain +const completion = async (opts) => { + const argv = opts.conf.argv.remain if (argv.length === 2) - return cb(null, subcommands) + return subcommands switch (argv[2]) { case 'grant': if (argv.length === 3) - return cb(null, ['read-only', 'read-write']) + return ['read-only', 'read-write'] else - return cb(null, []) + return [] case 'public': case 'restricted': @@ -79,9 +79,9 @@ const completion = function (opts, cb) { case '2fa-required': case '2fa-not-required': case 'revoke': - return cb(null, []) + return [] default: - return cb(new Error(argv[2] + ' not recognized')) + throw new Error(argv[2] + ' not recognized') } } diff --git a/deps/npm/lib/adduser.js b/deps/npm/lib/adduser.js index b6c3321745667c..c68c2b80f8790b 100644 --- a/deps/npm/lib/adduser.js +++ b/deps/npm/lib/adduser.js @@ -15,8 +15,6 @@ const usage = usageUtil( 'npm adduser [--registry=url] [--scope=@orgname] [--always-auth]' ) -const completion = require('./utils/completion/none.js') - const cmd = (args, cb) => adduser(args).then(() => cb()).catch(cb) const getRegistry = ({ scope, registry }) => { @@ -74,4 +72,4 @@ const adduser = async (args) => { output(message) } -module.exports = Object.assign(cmd, { completion, usage }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/audit.js b/deps/npm/lib/audit.js index cb8ab5b3a43f5d..1b31401b1a6b0b 100644 --- a/deps/npm/lib/audit.js +++ b/deps/npm/lib/audit.js @@ -38,17 +38,17 @@ const usage = usageUtil( '[--force|--package-lock-only|--dry-run|--production|--only=(dev|prod)]' ) -const completion = (opts, cb) => { +const completion = async (opts) => { const argv = opts.conf.argv.remain if (argv.length === 2) - return cb(null, ['fix']) + return ['fix'] switch (argv[2]) { case 'fix': - return cb(null, []) + return [] default: - return cb(new Error(argv[2] + ' not recognized')) + throw new Error(argv[2] + ' not recognized') } } diff --git a/deps/npm/lib/bin.js b/deps/npm/lib/bin.js index 1d776365c2f45d..e627ce22f13a68 100644 --- a/deps/npm/lib/bin.js +++ b/deps/npm/lib/bin.js @@ -1,7 +1,6 @@ const npm = require('./npm.js') const output = require('./utils/output.js') const usageUtil = require('./utils/usage.js') -const completion = require('./utils/completion/none.js') const PATH = require('./utils/path.js') const cmd = (args, cb) => bin(args).then(() => cb()).catch(cb) const usage = usageUtil('bin', 'npm bin [-g]') @@ -11,4 +10,4 @@ const bin = async (args, cb) => { if (npm.flatOptions.global && !PATH.includes(b)) console.error('(not in PATH env variable)') } -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/bugs.js b/deps/npm/lib/bugs.js index 012f39efbd3408..09856313ce883e 100644 --- a/deps/npm/lib/bugs.js +++ b/deps/npm/lib/bugs.js @@ -7,7 +7,6 @@ const npm = require('./npm.js') const hostedFromMani = require('./utils/hosted-git-info-from-manifest.js') const usage = usageUtil('bugs', 'npm bugs []') -const completion = require('./utils/completion/none.js') const cmd = (args, cb) => bugs(args).then(() => cb()).catch(cb) @@ -44,4 +43,4 @@ const getBugs = async pkg => { await openUrl(url, `${mani.name} bug list available at the following URL`) } -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/cache.js b/deps/npm/lib/cache.js index 30d6aef863ac29..7b84353b4a19b6 100644 --- a/deps/npm/lib/cache.js +++ b/deps/npm/lib/cache.js @@ -19,17 +19,17 @@ const usage = usageUtil('cache', '\nnpm cache verify' ) -const completion = (opts, cb) => { +const completion = async (opts) => { const argv = opts.conf.argv.remain if (argv.length === 2) - return cb(null, ['add', 'clean', 'verify']) + return ['add', 'clean', 'verify'] // TODO - eventually... switch (argv[2]) { case 'verify': case 'clean': case 'add': - return cb(null, []) + return [] } } diff --git a/deps/npm/lib/ci.js b/deps/npm/lib/ci.js index 80b9dbb2236487..51c165accef7a6 100644 --- a/deps/npm/lib/ci.js +++ b/deps/npm/lib/ci.js @@ -11,7 +11,6 @@ const npm = require('./npm.js') const usageUtil = require('./utils/usage.js') const usage = usageUtil('ci', 'npm ci') -const completion = require('./utils/completion/none.js') const cmd = (args, cb) => ci().then(() => cb()).catch(cb) @@ -76,4 +75,4 @@ const ci = async () => { await reifyFinish(arb) } -module.exports = Object.assign(cmd, { completion, usage }) +module.exports = Object.assign(cmd, {usage}) diff --git a/deps/npm/lib/completion.js b/deps/npm/lib/completion.js index bdea338ff2c4b9..b31867d988a69a 100644 --- a/deps/npm/lib/completion.js +++ b/deps/npm/lib/completion.js @@ -28,8 +28,6 @@ // one per line for the shell completion method to consume in IFS=$'\n' mode // as an array. // -// TODO: make all the implementation completion methods promise-returning -// instead of callback-taking. const npm = require('./npm.js') const { types, shorthands } = require('./utils/config.js') @@ -52,9 +50,9 @@ const { promisify } = require('util') const cmd = (args, cb) => compl(args).then(() => cb()).catch(cb) // completion for the completion command -const completion = async (opts, cb) => { +const completion = async (opts) => { if (opts.w > 2) - return cb() + return const { resolve } = require('path') const [bashExists, zshExists] = await Promise.all([ @@ -68,7 +66,7 @@ const completion = async (opts, cb) => { if (bashExists) out.push(['>>', '~/.bashrc']) - cb(null, out) + return out } const compl = async args => { @@ -121,18 +119,16 @@ const compl = async args => { raw: args, } - const wrap = getWrap(opts) - if (partialWords.slice(0, -1).indexOf('--') === -1) { if (word.charAt(0) === '-') - return wrap(configCompl(opts)) + return wrap(opts, configCompl(opts)) if (words[w - 1] && words[w - 1].charAt(0) === '-' && !isFlag(words[w - 1])) { // awaiting a value for a non-bool config. // don't even try to do this for now - return wrap(configValueCompl(opts)) + return wrap(opts, configValueCompl(opts)) } } @@ -146,7 +142,7 @@ const compl = async args => { // check if there's a command already. const cmd = parsed.argv.remain[1] if (!cmd) - return wrap(cmdCompl(opts)) + return wrap(opts, cmdCompl(opts)) Object.keys(parsed).forEach(k => npm.config.set(k, parsed[k])) @@ -155,10 +151,8 @@ const compl = async args => { // otherwise, do nothing const impl = npm.commands[cmd] if (impl && impl.completion) { - // XXX promisify all the cmd.completion functions - return await new Promise((res, rej) => { - impl.completion(opts, (er, comps) => er ? rej(er) : res(wrap(comps))) - }) + const comps = await impl.completion(opts) + return wrap(opts, comps) } } @@ -215,7 +209,7 @@ const escape = w => !/\s+/.test(w) ? w // If any of the items are arrays, then join them with a space. // Ie, returning ['a', 'b c', ['d', 'e']] would allow it to expand // to: 'a', 'b c', or 'd' 'e' -const getWrap = opts => compls => { +const wrap = (opts, compls) => { if (!Array.isArray(compls)) compls = compls ? [compls] : [] diff --git a/deps/npm/lib/config.js b/deps/npm/lib/config.js index b32cf3359d33b4..e4da296de8f88a 100644 --- a/deps/npm/lib/config.js +++ b/deps/npm/lib/config.js @@ -26,7 +26,7 @@ const usage = usageUtil( const cmd = (args, cb) => config(args).then(() => cb()).catch(cb) -const completion = (opts, cb) => { +const completion = async (opts) => { const argv = opts.conf.argv.remain if (argv[1] !== 'config') argv.unshift('config') @@ -36,7 +36,7 @@ const completion = (opts, cb) => { if (opts.partialWord !== 'l') cmds.push('list') - return cb(null, cmds) + return cmds } const action = argv[2] @@ -44,19 +44,19 @@ const completion = (opts, cb) => { case 'set': // todo: complete with valid values, if possible. if (argv.length > 3) - return cb(null, []) + return [] // fallthrough /* eslint no-fallthrough:0 */ case 'get': case 'delete': case 'rm': - return cb(null, Object.keys(types)) + return Object.keys(types) case 'edit': case 'list': case 'ls': default: - return cb(null, []) + return [] } } diff --git a/deps/npm/lib/dedupe.js b/deps/npm/lib/dedupe.js index 5e455192bcab0a..2211fcac8b4819 100644 --- a/deps/npm/lib/dedupe.js +++ b/deps/npm/lib/dedupe.js @@ -5,7 +5,6 @@ const usageUtil = require('./utils/usage.js') const reifyFinish = require('./utils/reify-finish.js') const usage = usageUtil('dedupe', 'npm dedupe') -const completion = require('./utils/completion/none.js') const cmd = (args, cb) => dedupe(args).then(() => cb()).catch(cb) @@ -27,4 +26,4 @@ const dedupe = async (args) => { await reifyFinish(arb) } -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/deprecate.js b/deps/npm/lib/deprecate.js index e049986452b793..42d099b544e31d 100644 --- a/deps/npm/lib/deprecate.js +++ b/deps/npm/lib/deprecate.js @@ -17,19 +17,17 @@ const usage = usageUtil( 'npm deprecate [@] ' ) -const completion = (opts, cb) => { +const completion = async (opts) => { if (opts.conf.argv.remain.length > 1) - return cb(null, []) + return [] - return getIdentity(npm.flatOptions).then((username) => { - return libaccess.lsPackages(username, npm.flatOptions).then((packages) => { - return Object.keys(packages) - .filter((name) => packages[name] === 'write' && - (opts.conf.argv.remain.length === 0 || - name.startsWith(opts.conf.argv.remain[0])) - ) - }) - }).then((list) => cb(null, list), (err) => cb(err)) + const username = await getIdentity(npm.flatOptions) + const packages = await libaccess.lsPackages(username, npm.flatOptions) + return Object.keys(packages) + .filter((name) => + packages[name] === 'write' && + (opts.conf.argv.remain.length === 0 || + name.startsWith(opts.conf.argv.remain[0]))) } const cmd = (args, cb) => diff --git a/deps/npm/lib/diff.js b/deps/npm/lib/diff.js index af6760106e0065..9ef5a78a20ce9e 100644 --- a/deps/npm/lib/diff.js +++ b/deps/npm/lib/diff.js @@ -11,7 +11,6 @@ const pickManifest = require('npm-pick-manifest') const npm = require('./npm.js') const usageUtil = require('./utils/usage.js') const output = require('./utils/output.js') -const completion = require('./utils/completion/none.js') const readLocalPkg = require('./utils/read-local-package.js') const usage = usageUtil( @@ -263,4 +262,4 @@ const findVersionsByPackageName = async (specs) => { }) } -module.exports = Object.assign(cmd, { completion, usage }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/dist-tag.js b/deps/npm/lib/dist-tag.js index ae4b33ce864122..e958bb75442229 100644 --- a/deps/npm/lib/dist-tag.js +++ b/deps/npm/lib/dist-tag.js @@ -16,14 +16,14 @@ const usage = usageUtil( '\nnpm dist-tag ls []' ) -const completion = function (opts, cb) { +const completion = async (opts) => { const argv = opts.conf.argv.remain if (argv.length === 2) - return cb(null, ['add', 'rm', 'ls']) + return ['add', 'rm', 'ls'] switch (argv[2]) { default: - return cb() + return [] } } diff --git a/deps/npm/lib/docs.js b/deps/npm/lib/docs.js index b6a3df7f70fe99..fa0adb3d373091 100644 --- a/deps/npm/lib/docs.js +++ b/deps/npm/lib/docs.js @@ -7,7 +7,6 @@ const npm = require('./npm.js') const hostedFromMani = require('./utils/hosted-git-info-from-manifest.js') const usage = usageUtil('docs', 'npm docs [ [ ...]]') -const completion = require('./utils/completion/none.js') const cmd = (args, cb) => docs(args).then(() => cb()).catch(cb) @@ -37,4 +36,4 @@ const getDocs = async pkg => { await openUrl(url, `${mani.name} docs available at the following URL`) } -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/doctor.js b/deps/npm/lib/doctor.js index f42b19fa686b7e..e149aec1286d54 100644 --- a/deps/npm/lib/doctor.js +++ b/deps/npm/lib/doctor.js @@ -4,7 +4,6 @@ const chalk = require('chalk') const ansiTrim = require('./utils/ansi-trim.js') const table = require('text-table') const output = require('./utils/output.js') -const completion = require('./utils/completion/none.js') const usageUtil = require('./utils/usage.js') const usage = usageUtil('doctor', 'npm doctor') const { resolve } = require('path') @@ -285,4 +284,4 @@ const doctor = async args => { throw 'Some problems found. See above for recommendations.' } -module.exports = Object.assign(cmd, { completion, usage }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/exec.js b/deps/npm/lib/exec.js index e90ec0866e4dd7..dab65c23a37b27 100644 --- a/deps/npm/lib/exec.js +++ b/deps/npm/lib/exec.js @@ -21,8 +21,6 @@ const usage = usageUtil('exec', '-c --call= (may not be mixed with positional arguments)' ) -const completion = require('./utils/completion/installed-shallow.js') - const { promisify } = require('util') const read = promisify(require('read')) @@ -284,4 +282,4 @@ const getHash = packages => .digest('hex') .slice(0, 16) -module.exports = Object.assign(cmd, { completion, usage }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/explain.js b/deps/npm/lib/explain.js index 9176f2e6c2473a..a0a4427bccf2cc 100644 --- a/deps/npm/lib/explain.js +++ b/deps/npm/lib/explain.js @@ -30,7 +30,7 @@ const explain = async (args) => { const expls = [] for (const node of nodes) { - const { extraneous, dev, optional, devOptional, peer } = node + const { extraneous, dev, optional, devOptional, peer, inBundle } = node const expl = node.explain() if (extraneous) expl.extraneous = true @@ -39,6 +39,7 @@ const explain = async (args) => { expl.optional = optional expl.devOptional = devOptional expl.peer = peer + expl.bundled = inBundle } expls.push(expl) } diff --git a/deps/npm/lib/find-dupes.js b/deps/npm/lib/find-dupes.js index 95791637821446..19e7ea6a7c8cc5 100644 --- a/deps/npm/lib/find-dupes.js +++ b/deps/npm/lib/find-dupes.js @@ -3,7 +3,6 @@ const dedupe = require('./dedupe.js') const usageUtil = require('./utils/usage.js') const usage = usageUtil('find-dupes', 'npm find-dupes') -const completion = require('./utils/completion/none.js') const cmd = (args, cb) => dedupe({ dryRun: true }, cb) -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/get.js b/deps/npm/lib/get.js index ab2141e35721ae..8a416027d7fbaa 100644 --- a/deps/npm/lib/get.js +++ b/deps/npm/lib/get.js @@ -1,4 +1,5 @@ const npm = require('./npm.js') +const config = require('./config.js') const usageUtil = require('./utils/usage.js') const usage = usageUtil( @@ -6,7 +7,7 @@ const usage = usageUtil( 'npm get [ ...] (See `npm config`)' ) -const completion = npm.commands.config.completion +const completion = config.completion const cmd = (args, cb) => npm.commands.config(['get'].concat(args), cb) diff --git a/deps/npm/lib/help-search.js b/deps/npm/lib/help-search.js index d2a1818060b21b..b1847350480439 100644 --- a/deps/npm/lib/help-search.js +++ b/deps/npm/lib/help-search.js @@ -11,7 +11,6 @@ const didYouMean = require('./utils/did-you-mean.js') const { cmdList } = require('./utils/cmd-list.js') const usage = usageUtil('help-search', 'npm help-search ') -const completion = require('./utils/completion/none.js') const npmUsage = require('./utils/npm-usage.js') @@ -201,4 +200,4 @@ const formatResults = (args, results) => { return finalOut.trim() } -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/help.js b/deps/npm/lib/help.js index f6996166542f9b..6f215c76c1ead0 100644 --- a/deps/npm/lib/help.js +++ b/deps/npm/lib/help.js @@ -1,10 +1,24 @@ module.exports = help -help.completion = function (opts, cb) { +help.completion = async (opts) => { if (opts.conf.argv.remain.length > 2) - return cb(null, []) - getSections(cb) + return [] + const g = path.resolve(__dirname, '../man/man[0-9]/*.[0-9]') + const files = await new Promise((resolve, reject) => { + glob(g, function (er, files) { + if (er) + return reject(er) + resolve(files) + }) + }) + + return Object.keys(files.reduce(function (acc, file) { + file = path.basename(file).replace(/\.[0-9]+$/, '') + file = file.replace(/^npm-/, '') + acc[file] = true + return acc + }, { help: true })) } const npmUsage = require('./utils/npm-usage.js') @@ -175,18 +189,3 @@ function htmlMan (man) { } return 'file://' + path.resolve(__dirname, '..', 'docs', 'output', sect, f + '.html') } - -function getSections (cb) { - const g = path.resolve(__dirname, '../man/man[0-9]/*.[0-9]') - glob(g, function (er, files) { - if (er) - return cb(er) - - cb(null, Object.keys(files.reduce(function (acc, file) { - file = path.basename(file).replace(/\.[0-9]+$/, '') - file = file.replace(/^npm-/, '') - acc[file] = true - return acc - }, { help: true }))) - }) -} diff --git a/deps/npm/lib/hook.js b/deps/npm/lib/hook.js index e0e15243e03a58..7d69ccbf2aa4c1 100644 --- a/deps/npm/lib/hook.js +++ b/deps/npm/lib/hook.js @@ -13,8 +13,6 @@ const usage = usageUtil('hook', [ 'npm hook update ', ].join('\n')) -const completion = require('./utils/completion/none.js') - const cmd = (args, cb) => hook(args).then(() => cb()).catch(cb) const hook = async (args) => otplease(npm.flatOptions, opts => { @@ -127,4 +125,4 @@ const hookName = (hook) => { return target } -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/init.js b/deps/npm/lib/init.js index 60ea52e1674911..a029779f89638f 100644 --- a/deps/npm/lib/init.js +++ b/deps/npm/lib/init.js @@ -3,7 +3,6 @@ const npa = require('npm-package-arg') const npm = require('./npm.js') const usageUtil = require('./utils/usage.js') -const completion = require('./utils/completion/none.js') const output = require('./utils/output.js') const usage = usageUtil( @@ -86,4 +85,4 @@ const init = async args => { }) } -module.exports = Object.assign(cmd, { completion, usage }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js index d4ee7047f746fd..5f0137db1ceacb 100644 --- a/deps/npm/lib/install.js +++ b/deps/npm/lib/install.js @@ -81,14 +81,14 @@ const usage = usageUtil( '[--save-prod|--save-dev|--save-optional|--save-peer] [--save-exact] [--no-save]' ) -const completion = async (opts, cb) => { +const completion = async (opts) => { const { partialWord } = opts // install can complete to a folder with a package.json, or any package. // if it has a slash, then it's gotta be a folder // if it starts with https?://, then just give up, because it's a url if (/^https?:\/\//.test(partialWord)) { // do not complete to URLs - return cb(null, []) + return [] } if (/\//.test(partialWord)) { @@ -126,19 +126,18 @@ const completion = async (opts, cb) => { const match = matches.filter(el => !el || el.isPackage).pop() if (match) { // Success - only one match and it is a package dir - return cb(null, [match.fullPath]) + return [match.fullPath] } else { // no matches - return cb(null, []) + return [] } } catch (er) { - return cb(null, []) // invalid dir: no matching + return [] // invalid dir: no matching } } // Note: there used to be registry completion here, // but it stopped making sense somewhere around // 50,000 packages on the registry - cb() } module.exports = Object.assign(cmd, { usage, completion }) diff --git a/deps/npm/lib/link.js b/deps/npm/lib/link.js index 84f36ada662016..0bb3d87b5e7d48 100644 --- a/deps/npm/lib/link.js +++ b/deps/npm/lib/link.js @@ -1,4 +1,6 @@ -const { readdir } = require('fs') +const fs = require('fs') +const util = require('util') +const readdir = util.promisify(fs.readdir) const { resolve } = require('path') const Arborist = require('@npmcli/arborist') @@ -10,9 +12,10 @@ const npm = require('./npm.js') const usageUtil = require('./utils/usage.js') const reifyFinish = require('./utils/reify-finish.js') -const completion = (opts, cb) => { +const completion = async (opts) => { const dir = npm.globalDir - readdir(dir, (er, files) => cb(er, files.filter(f => !/^[._-]/.test(f)))) + const files = await readdir(dir) + return files.filter(f => !/^[._-]/.test(f)) } const usage = usageUtil( diff --git a/deps/npm/lib/ll.js b/deps/npm/lib/ll.js index ada260e32936a4..1d5a6217da9c79 100644 --- a/deps/npm/lib/ll.js +++ b/deps/npm/lib/ll.js @@ -1,6 +1,9 @@ const { usage, completion } = require('./ls.js') const npm = require('./npm.js') -module.exports = Object.assign((args, cb) => { + +const cmd = (args, cb) => { npm.config.set('long', true) return npm.commands.ls(args, cb) -}, { usage, completion }) +} + +module.exports = Object.assign(cmd, { usage, completion }) diff --git a/deps/npm/lib/logout.js b/deps/npm/lib/logout.js index ba2eb92fee853f..d2762c1ba3e5fa 100644 --- a/deps/npm/lib/logout.js +++ b/deps/npm/lib/logout.js @@ -4,7 +4,6 @@ const getAuth = require('npm-registry-fetch/auth.js') const npmFetch = require('npm-registry-fetch') const npm = require('./npm.js') const usageUtil = require('./utils/usage.js') -const completion = require('./utils/completion/none.js') const usage = usageUtil( 'logout', @@ -42,4 +41,4 @@ const logout = async (args) => { await npm.config.save('user') } -module.exports = Object.assign(cmd, { completion, usage }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/org.js b/deps/npm/lib/org.js index b7af3f3a3022a0..aa9c97d497bbfb 100644 --- a/deps/npm/lib/org.js +++ b/deps/npm/lib/org.js @@ -13,19 +13,19 @@ org.usage = 'npm org rm orgname username\n' + 'npm org ls orgname []' -org.completion = function (opts, cb) { +org.completion = async (opts) => { var argv = opts.conf.argv.remain if (argv.length === 2) - return cb(null, org.subcommands) + return org.subcommands switch (argv[2]) { case 'ls': case 'add': case 'rm': case 'set': - return cb(null, []) + return [] default: - return cb(new Error(argv[2] + ' not recognized')) + throw new Error(argv[2] + ' not recognized') } } diff --git a/deps/npm/lib/outdated.js b/deps/npm/lib/outdated.js index f9a3fed8c10d48..c10f63a12e3a27 100644 --- a/deps/npm/lib/outdated.js +++ b/deps/npm/lib/outdated.js @@ -17,7 +17,6 @@ const ansiTrim = require('./utils/ansi-trim.js') const usage = usageUtil('outdated', 'npm outdated [[<@scope>/] ...]' ) -const completion = require('./utils/completion/none.js') function cmd (args, cb) { outdated(args) @@ -287,4 +286,4 @@ function makeJSON (list, opts) { return JSON.stringify(out, null, 2) } -module.exports = Object.assign(cmd, { completion, usage }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/owner.js b/deps/npm/lib/owner.js index 0bfb0a6a5464a6..6dce3ec70f3965 100644 --- a/deps/npm/lib/owner.js +++ b/deps/npm/lib/owner.js @@ -16,18 +16,16 @@ const usage = usageUtil( '\nnpm owner ls [<@scope>/]' ) -const completion = function (opts, cb) { +const completion = async (opts) => { const argv = opts.conf.argv.remain if (argv.length > 3) - return cb(null, []) + return [] if (argv[1] !== 'owner') argv.unshift('owner') - if (argv.length === 2) { - var subs = ['add', 'rm', 'ls'] - return cb(null, subs) - } + if (argv.length === 2) + return ['add', 'rm', 'ls'] // reaches registry in order to autocomplete rm if (argv[2] === 'rm') { @@ -35,25 +33,16 @@ const completion = function (opts, cb) { ...npm.flatOptions, fullMetadata: true, } - readLocalPkg() - .then(pkgName => { - if (!pkgName) - return null - - const spec = npa(pkgName) - return pacote.packument(spec, opts) - }) - .then(data => { - if (data && data.maintainers && data.maintainers.length) - return data.maintainers.map(m => m.name) - - return [] - }) - .then(owners => { - return cb(null, owners) - }) - } else - cb(null, []) + const pkgName = await readLocalPkg() + if (!pkgName) + return [] + + const spec = npa(pkgName) + const data = await pacote.packument(spec, opts) + if (data && data.maintainers && data.maintainers.length) + return data.maintainers.map(m => m.name) + } + return [] } const UsageError = () => diff --git a/deps/npm/lib/pack.js b/deps/npm/lib/pack.js index 7a5c2edabcff99..ff906cc2bd5a13 100644 --- a/deps/npm/lib/pack.js +++ b/deps/npm/lib/pack.js @@ -10,7 +10,6 @@ const { getContents, logTar } = require('./utils/tar.js') const writeFile = util.promisify(require('fs').writeFile) const output = require('./utils/output.js') -const completion = require('./utils/completion/none.js') const usageUtil = require('./utils/usage.js') const usage = usageUtil('pack', 'npm pack [[<@scope>/]...] [--dry-run]') @@ -47,4 +46,4 @@ const pack_ = async (arg, opts) => { return pkgContents } -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/ping.js b/deps/npm/lib/ping.js index 7762be6d29aa4b..efa22631033c91 100644 --- a/deps/npm/lib/ping.js +++ b/deps/npm/lib/ping.js @@ -4,7 +4,6 @@ const output = require('./utils/output.js') const usageUtil = require('./utils/usage.js') const usage = usageUtil('ping', 'npm ping\nping registry') -const completion = require('./utils/completion/none.js') const cmd = (args, cb) => ping(args).then(() => cb()).catch(cb) const pingUtil = require('./utils/ping.js') @@ -25,4 +24,4 @@ const ping = async args => { log.notice('PONG', `${JSON.stringify(details, null, 2)}`) } -module.exports = Object.assign(cmd, { completion, usage }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/prefix.js b/deps/npm/lib/prefix.js index 0a991447346d64..d108b9d423afd5 100644 --- a/deps/npm/lib/prefix.js +++ b/deps/npm/lib/prefix.js @@ -1,8 +1,7 @@ const npm = require('./npm.js') const output = require('./utils/output.js') const usageUtil = require('./utils/usage.js') -const completion = require('./utils/completion/none.js') const cmd = (args, cb) => prefix(args).then(() => cb()).catch(cb) const usage = usageUtil('prefix', 'npm prefix [-g]') const prefix = async (args, cb) => output(npm.prefix) -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/profile.js b/deps/npm/lib/profile.js index 24f026ce85ec48..3727ac0c8bdd41 100644 --- a/deps/npm/lib/profile.js +++ b/deps/npm/lib/profile.js @@ -20,25 +20,25 @@ const usage = usageUtil( 'npm profile set ' ) -const completion = (opts, cb) => { +const completion = async (opts) => { var argv = opts.conf.argv.remain const subcommands = ['enable-2fa', 'disable-2fa', 'get', 'set'] if (!argv[2]) - return cb(null, subcommands) + return subcommands switch (argv[2]) { case 'enable-2fa': case 'enable-tfa': - return cb(null, ['auth-and-writes', 'auth-only']) + return ['auth-and-writes', 'auth-only'] case 'disable-2fa': case 'disable-tfa': case 'get': case 'set': - return cb(null, []) + return [] default: - return cb(new Error(argv[2] + ' not recognized')) + throw new Error(argv[2] + ' not recognized') } } diff --git a/deps/npm/lib/prune.js b/deps/npm/lib/prune.js index ea6ed4108aba28..228fd3eebb1786 100644 --- a/deps/npm/lib/prune.js +++ b/deps/npm/lib/prune.js @@ -8,7 +8,6 @@ const reifyFinish = require('./utils/reify-finish.js') const usage = usageUtil('prune', 'npm prune [[<@scope>/]...] [--production]' ) -const completion = require('./utils/completion/none.js') const cmd = (args, cb) => prune().then(() => cb()).catch(cb) @@ -22,4 +21,4 @@ const prune = async () => { await reifyFinish(arb) } -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/publish.js b/deps/npm/lib/publish.js index 3e8df0076efa22..5ec66d42fa9a7c 100644 --- a/deps/npm/lib/publish.js +++ b/deps/npm/lib/publish.js @@ -18,7 +18,6 @@ const { getContents, logTar } = require('./utils/tar.js') // defaults and metadata, like git sha's and default scripts and all that. const readJson = util.promisify(require('read-package-json')) -const completion = require('./utils/completion/none.js') const usageUtil = require('./utils/usage.js') const usage = usageUtil('publish', 'npm publish [] [--tag ] [--access ] [--dry-run]' + @@ -137,4 +136,4 @@ const publish_ = async (arg, opts) => { return pkgContents } -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/repo.js b/deps/npm/lib/repo.js index 2dc3bcb1b846f6..e9074dca68d7ce 100644 --- a/deps/npm/lib/repo.js +++ b/deps/npm/lib/repo.js @@ -8,7 +8,6 @@ const hostedFromMani = require('./utils/hosted-git-info-from-manifest.js') const { URL } = require('url') const usage = usageUtil('repo', 'npm repo [ [ ...]]') -const completion = require('./utils/completion/none.js') const cmd = (args, cb) => repo(args).then(() => cb()).catch(cb) @@ -69,4 +68,4 @@ const unknownHostedUrl = url => { } } -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/root.js b/deps/npm/lib/root.js index 27e357655c3c01..631aef83867d1e 100644 --- a/deps/npm/lib/root.js +++ b/deps/npm/lib/root.js @@ -1,8 +1,7 @@ const npm = require('./npm.js') const output = require('./utils/output.js') const usageUtil = require('./utils/usage.js') -const completion = require('./utils/completion/none.js') const cmd = (args, cb) => root(args).then(() => cb()).catch(cb) const usage = usageUtil('root', 'npm root [-g]') const root = async (args, cb) => output(npm.dir) -module.exports = Object.assign(cmd, { usage, completion }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/run-script.js b/deps/npm/lib/run-script.js index 8e24a8a44e99d6..4dfb854cad9fa1 100644 --- a/deps/npm/lib/run-script.js +++ b/deps/npm/lib/run-script.js @@ -14,16 +14,14 @@ const usage = usageUtil( 'npm run-script [-- ]' ) -const completion = async (opts, cb) => { +const completion = async (opts) => { const argv = opts.conf.argv.remain if (argv.length === 2) { // find the script name const json = resolve(npm.localPrefix, 'package.json') const { scripts = {} } = await readJson(json).catch(er => ({})) - return cb(null, Object.keys(scripts)) + return Object.keys(scripts) } - // otherwise nothing to do, just let the system handle it - return cb() } const cmd = (args, cb) => { diff --git a/deps/npm/lib/search.js b/deps/npm/lib/search.js index a3d806d2f1507e..3f8fd99fb8ad87 100644 --- a/deps/npm/lib/search.js +++ b/deps/npm/lib/search.js @@ -8,7 +8,6 @@ const packageFilter = require('./search/package-filter.js') const npm = require('./npm.js') const output = require('./utils/output.js') const usageUtil = require('./utils/usage.js') -const completion = require('./utils/completion/none.js') const usage = usageUtil( 'search', @@ -86,4 +85,4 @@ function prepareExcludes (searchexclude) { .filter(s => s) } -module.exports = Object.assign(cmd, { completion, usage }) +module.exports = Object.assign(cmd, { usage }) diff --git a/deps/npm/lib/set-script.js b/deps/npm/lib/set-script.js index f655c221078942..7bac6eca50604e 100644 --- a/deps/npm/lib/set-script.js +++ b/deps/npm/lib/set-script.js @@ -3,7 +3,6 @@ const usageUtil = require('./utils/usage.js') const { localPrefix } = require('./npm.js') const fs = require('fs') const usage = usageUtil('set-script', 'npm set-script [