diff --git a/.github/workflows/ci-docs.yml b/.github/workflows/ci-npmcli-docs.yml similarity index 97% rename from .github/workflows/ci-docs.yml rename to .github/workflows/ci-npmcli-docs.yml index ef583ed2332a7..5a9f064a15144 100644 --- a/.github/workflows/ci-docs.yml +++ b/.github/workflows/ci-npmcli-docs.yml @@ -1,6 +1,6 @@ # This file is automatically added by @npmcli/template-oss. Do not edit. -name: CI - docs +name: CI - @npmcli/docs on: workflow_dispatch: @@ -119,7 +119,7 @@ jobs: - name: Add Problem Matcher run: echo "::add-matcher::.github/matchers/tap.json" - name: Test - run: node . test --ignore-scripts -w docs + run: node . test --ignore-scripts -w @npmcli/docs - name: Check Git Status if: matrix && matrix.platform.os != 'windows-latest' run: node scripts/git-dirty.js diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index 84ee3e0b11d53..7be55f3cf2a0d 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -119,6 +119,7 @@ graph LR; npm-->npmcli-arborist["@npmcli/arborist"]; npm-->npmcli-ci-detect["@npmcli/ci-detect"]; npm-->npmcli-config["@npmcli/config"]; + npm-->npmcli-docs["@npmcli/docs"]; npm-->npmcli-eslint-config["@npmcli/eslint-config"]; npm-->npmcli-fs["@npmcli/fs"]; npm-->npmcli-git["@npmcli/git"]; @@ -192,6 +193,10 @@ graph LR; npmcli-config-->proc-log; npmcli-config-->read-package-json-fast; npmcli-config-->semver; + npmcli-docs-->ignore-walk; + npmcli-docs-->npmcli-eslint-config["@npmcli/eslint-config"]; + npmcli-docs-->npmcli-fs["@npmcli/fs"]; + npmcli-docs-->npmcli-template-oss["@npmcli/template-oss"]; npmcli-fs-->semver; npmcli-git-->npm-pick-manifest; npmcli-git-->npmcli-promise-spawn["@npmcli/promise-spawn"]; @@ -387,18 +392,6 @@ graph LR; detab-->repeat-string; dezalgo-->asap; dezalgo-->wrappy; - docs-->cmark-gfm; - docs-->front-matter; - docs-->ignore-walk; - docs-->jsdom; - docs-->marked-man; - docs-->mdx-js-mdx["@mdx-js/mdx"]; - docs-->mkdirp; - docs-->npmcli-eslint-config["@npmcli/eslint-config"]; - docs-->npmcli-fs["@npmcli/fs"]; - docs-->npmcli-template-oss["@npmcli/template-oss"]; - docs-->tap; - docs-->yaml; domexception-->webidl-conversions; encoding-->iconv-lite; end-of-stream-->once; @@ -700,7 +693,6 @@ graph LR; npm-->cli-columns; npm-->cli-table3; npm-->columnify; - npm-->docs; npm-->fastest-levenshtein; npm-->fs-minipass; npm-->glob; @@ -744,6 +736,7 @@ graph LR; npm-->npmcli-arborist["@npmcli/arborist"]; npm-->npmcli-ci-detect["@npmcli/ci-detect"]; npm-->npmcli-config["@npmcli/config"]; + npm-->npmcli-docs["@npmcli/docs"]; npm-->npmcli-eslint-config["@npmcli/eslint-config"]; npm-->npmcli-fs["@npmcli/fs"]; npm-->npmcli-git["@npmcli/git"]; @@ -850,6 +843,19 @@ graph LR; npmcli-config-->semver; npmcli-config-->walk-up-path; npmcli-disparity-colors-->ansi-styles; + npmcli-docs-->cmark-gfm; + npmcli-docs-->front-matter; + npmcli-docs-->ignore-walk; + npmcli-docs-->isaacs-string-locale-compare["@isaacs/string-locale-compare"]; + npmcli-docs-->jsdom; + npmcli-docs-->marked-man; + npmcli-docs-->mdx-js-mdx["@mdx-js/mdx"]; + npmcli-docs-->mkdirp; + npmcli-docs-->npmcli-eslint-config["@npmcli/eslint-config"]; + npmcli-docs-->npmcli-fs["@npmcli/fs"]; + npmcli-docs-->npmcli-template-oss["@npmcli/template-oss"]; + npmcli-docs-->tap; + npmcli-docs-->yaml; npmcli-fs-->gar-promisify["@gar/promisify"]; npmcli-fs-->semver; npmcli-git-->lru-cache; @@ -1105,6 +1111,6 @@ packages higher up the chain. - pacote, libnpmaccess, libnpmhook, libnpmorg, libnpmsearch, libnpmteam, npm-profile - npm-registry-fetch, libnpmversion - @npmcli/git, make-fetch-happen, @npmcli/config, init-package-json - - @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, @npmcli/run-script, read-package-json, @npmcli/query, readdir-scoped-modules, promzard - - npm-bundled, read-package-json-fast, @npmcli/fs, unique-filename, @npmcli/promise-spawn, npm-install-checks, npm-package-arg, npm-packlist, normalize-package-data, @npmcli/package-json, bin-links, nopt, npmlog, parse-conflict-json, dezalgo, read - - npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, semver, @npmcli/move-file, fs-minipass, infer-owner, ssri, unique-slug, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, ignore-walk, minipass-fetch, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, wrappy, treeverse, @npmcli/eslint-config, @npmcli/template-oss, minify-registry-metadata, @npmcli/disparity-colors, @npmcli/ci-detect, mute-stream, ini, npm-audit-report, npm-user-validate \ No newline at end of file + - @npmcli/docs, @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, @npmcli/run-script, read-package-json, @npmcli/query, readdir-scoped-modules, promzard + - @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, @npmcli/promise-spawn, npm-install-checks, npm-package-arg, npm-packlist, normalize-package-data, @npmcli/package-json, bin-links, nopt, npmlog, parse-conflict-json, dezalgo, read + - semver, ignore-walk, @npmcli/eslint-config, @npmcli/template-oss, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, @npmcli/move-file, fs-minipass, infer-owner, ssri, unique-slug, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, minipass-fetch, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, wrappy, treeverse, minify-registry-metadata, @npmcli/disparity-colors, @npmcli/ci-detect, mute-stream, ini, npm-audit-report, npm-user-validate \ No newline at end of file diff --git a/docs/.gitignore b/docs/.gitignore index 7a856de40189d..79af2bfcaa4d8 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -14,7 +14,6 @@ !/lib/ !/LICENSE* !/map.js -!/nav.yml !/package.json !/README* !/scripts/ diff --git a/docs/bin/build.js b/docs/bin/build.js index ce98be0f87b46..80ce0a63490ff 100644 --- a/docs/bin/build.js +++ b/docs/bin/build.js @@ -1,16 +1,9 @@ -const { resolve, join } = require('path') const run = require('../lib/build.js') - -const rootDir = resolve(__dirname, '..') +const { paths } = require('../lib/index') run({ verify: true, - content: join(rootDir, 'lib', 'content'), - template: join(rootDir, 'lib', 'template.html'), - nav: join(rootDir, 'nav.yml'), - man: resolve(rootDir, '..', 'man'), - html: join(rootDir, 'output'), - md: join(rootDir, 'content'), + ...paths, }) .then((res) => console.log(`Wrote ${res.length} files`)) .catch((err) => { diff --git a/docs/lib/build.js b/docs/lib/build.js index b6eb0dec774e2..d2c97b07c93e7 100644 --- a/docs/lib/build.js +++ b/docs/lib/build.js @@ -6,9 +6,7 @@ const parseFrontMatter = require('front-matter') const mdx = require('@mdx-js/mdx') const checkNav = require('./check-nav.js') -const transform = require('./transform.js') - -const DOC_EXT = '.md' +const { DOC_EXT, ...transform } = require('./index.js') const mkDirs = async (paths) => { const uniqDirs = [...new Set(paths.map((p) => dirname(p)))] @@ -63,7 +61,6 @@ const run = async ({ content, verify, template, nav, man, html, md }) => { github_branch: 'latest', github_path: 'docs/content', }, - docExt: DOC_EXT, frontmatter, template: templateFile, }) @@ -80,7 +77,6 @@ const run = async ({ content, verify, template, nav, man, html, md }) => { if (data.section) { const manSrc = applyTransforms(transformedSrc, [ - transform.placeholders, transform.helpLinks, transform.man, ]) diff --git a/docs/nav.yml b/docs/lib/content/nav.yml similarity index 100% rename from docs/nav.yml rename to docs/lib/content/nav.yml diff --git a/docs/lib/index.js b/docs/lib/index.js new file mode 100644 index 0000000000000..fb295e2a10a57 --- /dev/null +++ b/docs/lib/index.js @@ -0,0 +1,169 @@ +const marked = require('marked-man') +const localeCompare = require('@isaacs/string-locale-compare')('en') +const { join, basename, resolve } = require('path') +const transformHTML = require('./transform-html.js') +const { version } = require('../../lib/npm.js') +const { aliases } = require('../../lib/utils/cmd-list') +const { shorthands, definitions } = require('../../lib/utils/config/index.js') + +const DOC_EXT = '.md' + +const TAGS = { + CONFIG: '', + USAGE: '', + SHORTHANDS: '', +} + +const assertPlaceholder = (src, path, placeholder) => { + if (!src.includes(placeholder)) { + throw new Error( + `Cannot replace ${placeholder} in ${path} due to missing placeholder` + ) + } + return placeholder +} + +const getCommandByDoc = (docFile, docExt) => { + // Grab the command name from the *.md filename + // NOTE: We cannot use the name property command file because in the case of + // `npx` the file being used is `lib/commands/exec.js` + const name = basename(docFile, docExt).replace('npm-', '') + + if (name === 'npm') { + return { + name, + params: null, + usage: 'npm', + } + } + + // special case for `npx`: + // `npx` is not technically a command in and of itself, + // so it just needs the usage of npm exex + const srcName = name === 'npx' ? 'exec' : name + const { params, usage = [''] } = require(`../../lib/commands/${srcName}`) + const usagePrefix = name === 'npx' ? 'npx' : `npm ${name}` + + return { + name, + params: name === 'npx' ? null : params, + usage: usage.map(u => `${usagePrefix} ${u}`.trim()).join('\n'), + } +} + +const replaceVersion = (src) => src.replace(/@VERSION@/g, version) + +const replaceUsage = (src, { path }) => { + const replacer = assertPlaceholder(src, path, TAGS.USAGE) + const { usage, name } = getCommandByDoc(path, DOC_EXT) + + const synopsis = ['```bash', usage] + + const cmdAliases = Object.keys(aliases).reduce((p, c) => { + if (aliases[c] === name) { + p.push(c) + } + return p + }, []) + + if (cmdAliases.length === 1) { + synopsis.push('') + synopsis.push(`alias: ${cmdAliases[0]}`) + } else if (cmdAliases.length > 1) { + synopsis.push('') + synopsis.push(`aliases: ${cmdAliases.join(', ')}`) + } + + synopsis.push('```') + + return src.replace(replacer, synopsis.join('\n')) +} + +const replaceParams = (src, { path }) => { + const { params } = getCommandByDoc(path, DOC_EXT) + const replacer = params && assertPlaceholder(src, path, TAGS.CONFIG) + + if (!params) { + return src + } + + const paramsConfig = params.map((n) => definitions[n].describe()) + + return src.replace(replacer, paramsConfig.join('\n\n')) +} + +const replaceConfig = (src, { path }) => { + const replacer = assertPlaceholder(src, path, TAGS.CONFIG) + + // sort not-deprecated ones to the top + /* istanbul ignore next - typically already sorted in the definitions file, + * but this is here so that our help doc will stay consistent if we decide + * to move them around. */ + const sort = ([keya, { deprecated: depa }], [keyb, { deprecated: depb }]) => { + return depa && !depb ? 1 + : !depa && depb ? -1 + : localeCompare(keya, keyb) + } + + const allConfig = Object.entries(definitions).sort(sort) + .map(([_, def]) => def.describe()) + .join('\n\n') + + return src.replace(replacer, allConfig) +} + +const replaceShorthands = (src, { path }) => { + const replacer = assertPlaceholder(src, path, TAGS.SHORTHANDS) + + const sh = Object.entries(shorthands) + .sort(([shorta, expansiona], [shortb, expansionb]) => + // sort by what they're short FOR + localeCompare(expansiona.join(' '), expansionb.join(' ')) || localeCompare(shorta, shortb) + ) + .map(([short, expansion]) => { + // XXX: this is incorrect. we have multicharacter flags like `-iwr` that + // can only be set with a single dash + const dash = short.length === 1 ? '-' : '--' + return `* \`${dash}${short}\`: \`${expansion.join(' ')}\`` + }) + + return src.replace(replacer, sh.join('\n')) +} + +const replaceHelpLinks = (src) => { + const replacer = (_, p1) => 'npm help ' + p1.replace(/npm /, '') + return src + .replace(/\[([^\]]+)\]\(\/commands\/([^)]+)\)/g, replacer) + .replace(/\[([^\]]+)\]\(\/configuring-npm\/([^)]+)\)/g, replacer) + .replace(/\[([^\]]+)\]\(\/using-npm\/([^)]+)\)/g, replacer) +} + +const transformMan = (src, { data }) => + marked(`# ${data.title}(${data.section}) - ${data.description}\n\n${src}`) + +const manPath = (name, { data }) => join(`man${data.section}`, `${name}.${data.section}`) + +const transformMd = (src, { frontmatter }) => ['---', frontmatter, '---', '', src].join('\n') + +module.exports = { + DOC_EXT, + TAGS, + paths: { + content: resolve(__dirname, 'content'), + nav: resolve(__dirname, 'content', 'nav.yml'), + template: resolve(__dirname, 'template.html'), + man: resolve(__dirname, '..', '..', 'man'), + html: resolve(__dirname, '..', 'output'), + md: resolve(__dirname, '..', 'content'), + }, + usage: replaceUsage, + params: replaceParams, + config: replaceConfig, + shorthands: replaceShorthands, + version: replaceVersion, + helpLinks: replaceHelpLinks, + man: transformMan, + manPath: manPath, + md: transformMd, + html: transformHTML, +} diff --git a/docs/lib/npm.js b/docs/lib/npm.js deleted file mode 100644 index 9fe18ecac62fc..0000000000000 --- a/docs/lib/npm.js +++ /dev/null @@ -1,44 +0,0 @@ -const { basename } = require('path') -const { definitions, shorthands, describeAll } = require('../../lib/utils/config/index.js') -const { aliases } = require('../../lib/utils/cmd-list') -const { version } = require('../../lib/npm.js') - -const describeParams = (params) => params.map((name) => definitions[name].describe()) - -const getCommandByDoc = (docFile, docExt) => { - // Grab the command name from the *.md filename - // NOTE: We cannot use the name property command file because in the case of - // `npx` the file being used is `lib/commands/exec.js` - const name = basename(docFile, docExt).replace('npm-', '') - - if (name === 'npm') { - return { - name, - params: null, - usage: 'npm', - } - } - - // special case for `npx`: - // `npx` is not technically a command in and of itself, - // so it just needs the usage of npm exex - const srcName = name === 'npx' ? 'exec' : name - const { params, usage = [''] } = require(`../../lib/commands/${srcName}`) - const usagePrefix = name === 'npx' ? 'npx' : `npm ${name}` - - return { - name, - params: name === 'npx' ? null : params, - usage: usage.map(u => `${usagePrefix} ${u}`.trim()).join('\n'), - } -} - -module.exports = { - definitions, - shorthands, - aliases, - version, - describeParams, - describeAll, - getCommandByDoc, -} diff --git a/docs/lib/transform.js b/docs/lib/transform.js deleted file mode 100644 index 081d0fa266af2..0000000000000 --- a/docs/lib/transform.js +++ /dev/null @@ -1,111 +0,0 @@ -const marked = require('marked-man') -const { join } = require('path') -const NPM = require('./npm.js') -const transformHTML = require('./transform-html.js') - -const TAGS = { - CONFIG: '', - USAGE: '', - SHORTHANDS: '', -} - -const assertPlaceholder = (src, path, placeholder) => { - if (!src.includes(placeholder)) { - throw new Error( - `Cannot replace ${placeholder} in ${path} due to missing placeholder` - ) - } - return placeholder -} - -const replaceVersion = (src) => src.replace(/@VERSION@/g, NPM.version) - -const removePlaceholders = (src) => src.replace(/^$/gm, '') - -const replaceUsage = (src, { path, docExt }) => { - const replacer = assertPlaceholder(src, path, TAGS.USAGE) - const { usage, name } = NPM.getCommandByDoc(path, docExt) - - const synopsis = ['```bash', usage] - - const cmdAliases = Object.keys(NPM.aliases).reduce((p, c) => { - if (NPM.aliases[c] === name) { - p.push(c) - } - return p - }, []) - - if (cmdAliases.length === 1) { - synopsis.push('') - synopsis.push(`alias: ${cmdAliases[0]}`) - } else if (cmdAliases.length > 1) { - synopsis.push('') - synopsis.push(`aliases: ${cmdAliases.join(', ')}`) - } - - synopsis.push('```') - - return src.replace(replacer, synopsis.join('\n')) -} - -const replaceParams = (src, { path, docExt }) => { - const { params } = NPM.getCommandByDoc(path, docExt) - const replacer = params && assertPlaceholder(src, path, TAGS.CONFIG) - - if (!params) { - return src - } - - return src.replace(replacer, NPM.describeParams(params).join('\n\n')) -} - -const replaceConfig = (src, { path }) => { - const replacer = assertPlaceholder(src, path, TAGS.CONFIG) - return src.replace(replacer, NPM.describeAll()) -} - -const replaceShorthands = (src, { path }) => { - const replacer = assertPlaceholder(src, path, TAGS.SHORTHANDS) - - const shorthands = Object.entries(NPM.shorthands) - .sort(([shorta, expansiona], [shortb, expansionb]) => { - // sort by what they're short FOR - return expansiona.join(' ').localeCompare(expansionb.join(' '), 'en') || - shorta.localeCompare(shortb, 'en') - }) - .map(([short, expansion]) => { - const dash = short.length === 1 ? '-' : '--' - return `* \`${dash}${short}\`: \`${expansion.join(' ')}\`` - }) - - return src.replace(replacer, shorthands.join('\n')) -} - -const replaceHelpLinks = (src) => { - const replacer = (_, p1) => 'npm help ' + p1.replace(/npm /, '') - return src - .replace(/\[([^\]]+)\]\(\/commands\/([^)]+)\)/g, replacer) - .replace(/\[([^\]]+)\]\(\/configuring-npm\/([^)]+)\)/g, replacer) - .replace(/\[([^\]]+)\]\(\/using-npm\/([^)]+)\)/g, replacer) -} - -const transformMan = (src, { data }) => - marked(`# ${data.title}(${data.section}) - ${data.description}\n\n${src}`) - -const manPath = (name, { data }) => join(`man${data.section}`, `${name}.${data.section}`) - -const transformMd = (src, { frontmatter }) => ['---', frontmatter, '---', '', src].join('\n') - -module.exports = { - usage: replaceUsage, - params: replaceParams, - config: replaceConfig, - version: replaceVersion, - shorthands: replaceShorthands, - helpLinks: replaceHelpLinks, - placeholders: removePlaceholders, - man: transformMan, - manPath: manPath, - md: transformMd, - html: transformHTML, -} diff --git a/docs/package.json b/docs/package.json index 9645f740110f1..eebafb07ef0c9 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,8 +1,9 @@ { - "name": "docs", + "name": "@npmcli/docs", "description": "The npm cli documentation", "version": "1.0.0", "private": true, + "main": "lib/index.js", "scripts": { "lint": "eslint \"**/*.js\"", "postlint": "template-oss-check", @@ -19,6 +20,7 @@ "directory": "docs" }, "dependencies": { + "@isaacs/string-locale-compare": "^1.1.0", "@mdx-js/mdx": "^1.6.22", "@npmcli/fs": "^2.1.0", "cmark-gfm": "^0.9.0", @@ -38,9 +40,7 @@ "license": "ISC", "files": [ "bin/", - "lib/", - "content/", - "nav.yml" + "lib/" ], "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" @@ -54,13 +54,6 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "distPaths": [ - "content/", - "nav.yml" - ], - "allowPaths": [ - "/nav.yml" - ], "ciVersions": "latest", "engines": "^14.17.0 || ^16.13.0 || >=18.0.0", "version": "4.5.0", diff --git a/docs/test/index.js b/docs/test/index.js index a78514be1e78f..8452428212519 100644 --- a/docs/test/index.js +++ b/docs/test/index.js @@ -1,10 +1,7 @@ const t = require('tap') -const { resolve, join } = require('path') +const { join } = require('path') const walk = require('ignore-walk') - -const CONTENT_DIR = resolve(__dirname, '..', 'lib', 'content') -const NAV = resolve(__dirname, '..', 'nav.yml') -const TEMPLATE = resolve(__dirname, '..', 'lib', 'template.html') +const { paths: { content: CONTENT_DIR, nav: NAV, template: TEMPLATE } } = require('../lib/index.js') const testBuildDocs = async (t, { verify, ...opts } = {}) => { const mockedBuild = require('../lib/build.js') diff --git a/lib/commands/completion.js b/lib/commands/completion.js index c24fb050dcb34..7571a1442cf98 100644 --- a/lib/commands/completion.js +++ b/lib/commands/completion.js @@ -33,9 +33,9 @@ const fs = require('@npmcli/fs') const nopt = require('nopt') const { definitions, shorthands } = require('../utils/config/index.js') -const { aliases, cmdList, plumbing } = require('../utils/cmd-list.js') +const { aliases, commands, plumbing } = require('../utils/cmd-list.js') const aliasNames = Object.keys(aliases) -const fullList = cmdList.concat(aliasNames).filter(c => !plumbing.includes(c)) +const fullList = commands.concat(aliasNames).filter(c => !plumbing.includes(c)) const configNames = Object.keys(definitions) const shorthandNames = Object.keys(shorthands) const allConfs = configNames.concat(shorthandNames) diff --git a/lib/commands/publish.js b/lib/commands/publish.js index 1f281a0bb1d4f..23323a174ed89 100644 --- a/lib/commands/publish.js +++ b/lib/commands/publish.js @@ -16,7 +16,7 @@ const { getContents, logTar } = require('../utils/tar.js') // keys that npm supports in .npmrc files and elsewhere. We *may* want to // revisit this at some point, and have a minimal set that's a SemVer-major // change that ought to get a RFC written on it. -const flatten = require('../utils/config/flatten.js') +const { flatten } = require('../utils/config/index.js') // this is the only case in the CLI where we want to use the old full slow // 'read-package-json' module, because we want to pull in all the defaults and diff --git a/lib/commands/unpublish.js b/lib/commands/unpublish.js index 968bcf8018958..268c8c3daedbb 100644 --- a/lib/commands/unpublish.js +++ b/lib/commands/unpublish.js @@ -6,7 +6,7 @@ const path = require('path') const util = require('util') const readJson = util.promisify(require('read-package-json')) -const flatten = require('../utils/config/flatten.js') +const { flatten } = require('../utils/config/index.js') const getIdentity = require('../utils/get-identity.js') const log = require('../utils/log-shim') const otplease = require('../utils/otplease.js') diff --git a/lib/utils/cmd-list.js b/lib/utils/cmd-list.js index 6fffde32a5ee2..03fe8ed07c930 100644 --- a/lib/utils/cmd-list.js +++ b/lib/utils/cmd-list.js @@ -1,4 +1,5 @@ const abbrev = require('abbrev') +const localeCompare = require('@isaacs/string-locale-compare')('en') // plumbing should not have any aliases const aliases = { @@ -68,8 +69,7 @@ const aliases = { } // these are filenames in . -// Keep these sorted so that lib/utils/npm-usage.js outputs in order -const cmdList = [ +const commands = [ 'access', 'adduser', 'audit', @@ -135,14 +135,16 @@ const cmdList = [ 'version', 'view', 'whoami', -] +].sort(localeCompare) const plumbing = ['help-search'] -const abbrevs = abbrev(cmdList.concat(Object.keys(aliases))) +const allCommands = [...commands, ...plumbing].sort(localeCompare) +const abbrevs = abbrev(commands.concat(Object.keys(aliases))) module.exports = { abbrevs, aliases, - cmdList, + commands, plumbing, + allCommands, } diff --git a/lib/utils/config/describe-all.js b/lib/utils/config/describe-all.js deleted file mode 100644 index 6480dec7c997c..0000000000000 --- a/lib/utils/config/describe-all.js +++ /dev/null @@ -1,17 +0,0 @@ -const definitions = require('./definitions.js') -const localeCompare = require('@isaacs/string-locale-compare')('en') -const describeAll = () => { - // sort not-deprecated ones to the top - /* istanbul ignore next - typically already sorted in the definitions file, - * but this is here so that our help doc will stay consistent if we decide - * to move them around. */ - const sort = ([keya, { deprecated: depa }], [keyb, { deprecated: depb }]) => { - return depa && !depb ? 1 - : !depa && depb ? -1 - : localeCompare(keya, keyb) - } - return Object.entries(definitions).sort(sort) - .map(([key, def]) => def.describe()) - .join('\n\n') -} -module.exports = describeAll diff --git a/lib/utils/config/flatten.js b/lib/utils/config/flatten.js deleted file mode 100644 index 588d05bf0d77d..0000000000000 --- a/lib/utils/config/flatten.js +++ /dev/null @@ -1,33 +0,0 @@ -// use the defined flattening function, and copy over any scoped -// registries and registry-specific "nerfdart" configs verbatim -// -// TODO: make these getters so that we only have to make dirty -// the thing that changed, and then flatten the fields that -// could have changed when a config.set is called. -// -// TODO: move nerfdart auth stuff into a nested object that -// is only passed along to paths that end up calling npm-registry-fetch. -const definitions = require('./definitions.js') -const flatten = (obj, flat = {}) => { - for (const [key, val] of Object.entries(obj)) { - const def = definitions[key] - if (def && def.flatten) { - def.flatten(key, obj, flat) - } else if (/@.*:registry$/i.test(key) || /^\/\//.test(key)) { - flat[key] = val - } - } - - // XXX make this the bin/npm-cli.js file explicitly instead - // otherwise using npm programmatically is a bit of a pain. - flat.npmBin = require.main ? require.main.filename - : /* istanbul ignore next - not configurable property */ undefined - flat.nodeBin = process.env.NODE || process.execPath - - // XXX should this be sha512? is it even relevant? - flat.hashAlgorithm = 'sha1' - - return flat -} - -module.exports = flatten diff --git a/lib/utils/config/index.js b/lib/utils/config/index.js index b0ad24d7ee12f..d393aec2297d2 100644 --- a/lib/utils/config/index.js +++ b/lib/utils/config/index.js @@ -1,6 +1,35 @@ -const flatten = require('./flatten.js') const definitions = require('./definitions.js') -const describeAll = require('./describe-all.js') + +// use the defined flattening function, and copy over any scoped +// registries and registry-specific "nerfdart" configs verbatim +// +// TODO: make these getters so that we only have to make dirty +// the thing that changed, and then flatten the fields that +// could have changed when a config.set is called. +// +// TODO: move nerfdart auth stuff into a nested object that +// is only passed along to paths that end up calling npm-registry-fetch. +const flatten = (obj, flat = {}) => { + for (const [key, val] of Object.entries(obj)) { + const def = definitions[key] + if (def && def.flatten) { + def.flatten(key, obj, flat) + } else if (/@.*:registry$/i.test(key) || /^\/\//.test(key)) { + flat[key] = val + } + } + + // XXX make this the bin/npm-cli.js file explicitly instead + // otherwise using npm programmatically is a bit of a pain. + flat.npmBin = require.main ? require.main.filename + : /* istanbul ignore next - not configurable property */ undefined + flat.nodeBin = process.env.NODE || process.execPath + + // XXX should this be sha512? is it even relevant? + flat.hashAlgorithm = 'sha1' + + return flat +} // aliases where they get expanded into a completely different thing // these are NOT supported in the environment or npmrc files, only @@ -26,30 +55,24 @@ const shorthands = { readonly: ['--read-only'], reg: ['--registry'], iwr: ['--include-workspace-root'], -} - -for (const [key, { short }] of Object.entries(definitions)) { - if (!short) { - continue - } - // can be either an array or string - for (const s of [].concat(short)) { - shorthands[s] = [`--${key}`] - } + ...Object.entries(definitions).reduce((acc, [key, { short = [] }]) => { + // can be either an array or string + for (const s of [].concat(short)) { + acc[s] = [`--${key}`] + } + return acc + }, {}), } module.exports = { get defaults () { // NB: 'default' is a reserved word - return Object.entries(definitions).map(([key, { default: def }]) => { - return [key, def] - }).reduce((defaults, [key, def]) => { - defaults[key] = def - return defaults + return Object.entries(definitions).reduce((acc, [key, { default: d }]) => { + acc[key] = d + return acc }, {}) }, definitions, flatten, shorthands, - describeAll, } diff --git a/lib/utils/did-you-mean.js b/lib/utils/did-you-mean.js index b859abaaf5d23..10b33d5f83a08 100644 --- a/lib/utils/did-you-mean.js +++ b/lib/utils/did-you-mean.js @@ -1,10 +1,10 @@ const { distance } = require('fastest-levenshtein') const readJson = require('read-package-json-fast') -const { cmdList } = require('./cmd-list.js') +const { commands } = require('./cmd-list.js') const didYouMean = async (npm, path, scmd) => { // const cmd = await npm.cmd(str) - const close = cmdList.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 && scmd !== cmd) + const close = commands.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 && scmd !== cmd) let best = [] for (const str of close) { const cmd = await npm.cmd(str) diff --git a/lib/utils/npm-usage.js b/lib/utils/npm-usage.js index 431995ecf0bae..947a3073bc5ff 100644 --- a/lib/utils/npm-usage.js +++ b/lib/utils/npm-usage.js @@ -1,10 +1,18 @@ const { dirname } = require('path') -const { cmdList } = require('./cmd-list') -const localeCompare = require('@isaacs/string-locale-compare')('en') +const { commands } = require('./cmd-list') + +const COL_MAX = 60 +const COL_MIN = 24 +const COL_GUTTER = 16 +const INDENT = 4 + +const indent = (repeat = INDENT) => ' '.repeat(repeat) +const indentNewline = (repeat) => `\n${indent(repeat)}` module.exports = async (npm) => { - const usesBrowser = npm.config.get('viewer') === 'browser' - ? ' (in a browser)' : '' + const browser = npm.config.get('viewer') === 'browser' ? ' (in a browser)' : '' + const allCommands = npm.config.get('long') ? await cmdUsages(npm) : cmdNames() + return `npm Usage: @@ -15,14 +23,14 @@ npm test run this project's tests npm run run the script named npm -h quick help on npm -l display usage info for all commands -npm help search for help on ${usesBrowser} -npm help npm more involved overview${usesBrowser} +npm help search for help on ${browser} +npm help npm more involved overview${browser} All commands: -${await allCommands(npm)} +${allCommands} Specify configs in the ini-formatted file: - ${npm.config.get('userconfig')} +${indent() + npm.config.get('userconfig')} or on the command line via: npm --key=value More configuration info: npm help config @@ -31,21 +39,14 @@ Configuration fields: npm help 7 config npm@${npm.version} ${dirname(dirname(__dirname))}` } -const allCommands = async (npm) => { - if (npm.config.get('long')) { - return usages(npm) - } - return ('\n ' + wrap(cmdList)) -} - -const wrap = (arr) => { +const cmdNames = () => { const out = [''] - const line = !process.stdout.columns ? 60 - : Math.min(60, Math.max(process.stdout.columns - 16, 24)) + const line = !process.stdout.columns ? COL_MAX + : Math.min(COL_MAX, Math.max(process.stdout.columns - COL_GUTTER, COL_MIN)) let l = 0 - for (const c of arr) { + for (const c of commands) { if (out[l].length + c.length + 2 < line) { out[l] += ', ' + c } else { @@ -53,20 +54,23 @@ const wrap = (arr) => { out[l] = c } } - return out.join('\n ').slice(2) + + return indentNewline() + out.join(indentNewline()).slice(2) } -const usages = async (npm) => { +const cmdUsages = async (npm) => { // return a string of : let maxLen = 0 const set = [] - for (const c of cmdList) { - const cmd = await npm.cmd(c) - set.push([c, cmd.usage]) + for (const c of commands) { + const { usage } = await npm.cmd(c) + set.push([c, usage.split('\n')]) maxLen = Math.max(maxLen, c.length) } - return set.sort(([a], [b]) => localeCompare(a, b)) - .map(([c, usage]) => `\n ${c}${' '.repeat(maxLen - c.length + 1)}${ - (usage.split('\n').join('\n' + ' '.repeat(maxLen + 5)))}`) - .join('\n') + + return set.map(([name, usageLines]) => { + const gutter = indent(maxLen - name.length + 1) + const usage = usageLines.join(indentNewline(INDENT + maxLen + 1)) + return indentNewline() + name + gutter + usage + }).join('\n') } diff --git a/package-lock.json b/package-lock.json index c41f1ddcefd56..82ada3a693a7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -168,6 +168,7 @@ "npx": "bin/npx-cli.js" }, "devDependencies": { + "@npmcli/docs": "^1.0.0", "@npmcli/eslint-config": "^3.1.0", "@npmcli/git": "^3.0.2", "@npmcli/promise-spawn": "^3.0.0", @@ -183,9 +184,11 @@ } }, "docs": { + "name": "@npmcli/docs", "version": "1.0.0", "license": "ISC", "dependencies": { + "@isaacs/string-locale-compare": "^1.1.0", "@mdx-js/mdx": "^1.6.22", "@npmcli/fs": "^2.1.0", "cmark-gfm": "^0.9.0", @@ -1187,8 +1190,9 @@ }, "node_modules/@isaacs/string-locale-compare": { "version": "1.1.0", - "inBundle": true, - "license": "ISC" + "resolved": "https://registry.npmjs.org/@isaacs/string-locale-compare/-/string-locale-compare-1.1.0.tgz", + "integrity": "sha512-SQ7Kzhh9+D+ZW9MA0zkYv3VXhIDNx+LzM6EJ+/65I3QY+enU6Itte7E5XX7EWrqLW2FN4n06GWzBnPoC3th2aQ==", + "inBundle": true }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", @@ -2053,6 +2057,10 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/@npmcli/docs": { + "resolved": "docs", + "link": true + }, "node_modules/@npmcli/eslint-config": { "version": "3.1.0", "dev": true, @@ -3981,10 +3989,6 @@ "node": ">=0.10.0" } }, - "node_modules/docs": { - "resolved": "docs", - "link": true - }, "node_modules/doctrine": { "version": "3.0.0", "dev": true, @@ -14117,7 +14121,9 @@ "dev": true }, "@isaacs/string-locale-compare": { - "version": "1.1.0" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@isaacs/string-locale-compare/-/string-locale-compare-1.1.0.tgz", + "integrity": "sha512-SQ7Kzhh9+D+ZW9MA0zkYv3VXhIDNx+LzM6EJ+/65I3QY+enU6Itte7E5XX7EWrqLW2FN4n06GWzBnPoC3th2aQ==" }, "@istanbuljs/load-nyc-config": { "version": "1.1.0", @@ -14809,6 +14815,24 @@ "ansi-styles": "^4.3.0" } }, + "@npmcli/docs": { + "version": "file:docs", + "requires": { + "@isaacs/string-locale-compare": "^1.1.0", + "@mdx-js/mdx": "^1.6.22", + "@npmcli/eslint-config": "^3.1.0", + "@npmcli/fs": "^2.1.0", + "@npmcli/template-oss": "4.5.0", + "cmark-gfm": "^0.9.0", + "front-matter": "^4.0.2", + "ignore-walk": "^5.0.1", + "jsdom": "^18.1.0", + "marked-man": "^0.7.0", + "mkdirp": "^1.0.4", + "tap": "^16.0.1", + "yaml": "^1.10.2" + } + }, "@npmcli/eslint-config": { "version": "3.1.0", "dev": true, @@ -16029,23 +16053,6 @@ "version": "0.6.2", "dev": true }, - "docs": { - "version": "file:docs", - "requires": { - "@mdx-js/mdx": "^1.6.22", - "@npmcli/eslint-config": "^3.1.0", - "@npmcli/fs": "^2.1.0", - "@npmcli/template-oss": "4.5.0", - "cmark-gfm": "^0.9.0", - "front-matter": "^4.0.2", - "ignore-walk": "^5.0.1", - "jsdom": "^18.1.0", - "marked-man": "^0.7.0", - "mkdirp": "^1.0.4", - "tap": "^16.0.1", - "yaml": "^1.10.2" - } - }, "doctrine": { "version": "3.0.0", "dev": true, diff --git a/package.json b/package.json index 1299a35ae2405..54ee6daa6d47f 100644 --- a/package.json +++ b/package.json @@ -205,6 +205,7 @@ "write-file-atomic" ], "devDependencies": { + "@npmcli/docs": "^1.0.0", "@npmcli/eslint-config": "^3.1.0", "@npmcli/git": "^3.0.2", "@npmcli/promise-spawn": "^3.0.0", @@ -223,9 +224,7 @@ "test": "tap", "test-all": "node . run test -ws -iwr --if-present", "snap": "tap", - "postsnap": "npm test -w docs", - "docs": "npm run build -w docs", - "prepack": "npm run docs", + "prepack": "npm run build -w docs", "test:nocleanup": "NO_TEST_CLEANUP=1 node . run test --", "sudotest": "sudo node . run run test --", "sudotest:nocleanup": "sudo NO_TEST_CLEANUP=1 node . run test --", diff --git a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs b/tap-snapshots/test/lib/docs.js.test.cjs similarity index 60% rename from tap-snapshots/test/lib/utils/config/definitions.js.test.cjs rename to tap-snapshots/test/lib/docs.js.test.cjs index 92a8e6222320c..8fc025f600fdb 100644 --- a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs +++ b/tap-snapshots/test/lib/docs.js.test.cjs @@ -5,164 +5,558 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/lib/utils/config/definitions.js TAP > all config keys 1`] = ` +exports[`test/lib/docs.js TAP command list > abbrevs 1`] = ` +Object { + "ac": "access", + "acc": "access", + "acce": "access", + "acces": "access", + "access": "access", + "add": "add", + "add-": "add-user", + "add-u": "add-user", + "add-us": "add-user", + "add-use": "add-user", + "add-user": "add-user", + "addu": "adduser", + "addus": "adduser", + "adduse": "adduser", + "adduser": "adduser", + "aud": "audit", + "audi": "audit", + "audit": "audit", + "aut": "author", + "auth": "author", + "autho": "author", + "author": "author", + "b": "bugs", + "bu": "bugs", + "bug": "bugs", + "bugs": "bugs", + "c": "c", + "ca": "cache", + "cac": "cache", + "cach": "cache", + "cache": "cache", + "ci": "ci", + "cit": "cit", + "clean-install": "clean-install", + "clean-install-": "clean-install-test", + "clean-install-t": "clean-install-test", + "clean-install-te": "clean-install-test", + "clean-install-tes": "clean-install-test", + "clean-install-test": "clean-install-test", + "com": "completion", + "comp": "completion", + "compl": "completion", + "comple": "completion", + "complet": "completion", + "completi": "completion", + "completio": "completion", + "completion": "completion", + "con": "config", + "conf": "config", + "confi": "config", + "config": "config", + "cr": "create", + "cre": "create", + "crea": "create", + "creat": "create", + "create": "create", + "dd": "ddp", + "ddp": "ddp", + "ded": "dedupe", + "dedu": "dedupe", + "dedup": "dedupe", + "dedupe": "dedupe", + "dep": "deprecate", + "depr": "deprecate", + "depre": "deprecate", + "deprec": "deprecate", + "depreca": "deprecate", + "deprecat": "deprecate", + "deprecate": "deprecate", + "dif": "diff", + "diff": "diff", + "dist-tag": "dist-tag", + "dist-tags": "dist-tags", + "docs": "docs", + "doct": "doctor", + "docto": "doctor", + "doctor": "doctor", + "ed": "edit", + "edi": "edit", + "edit": "edit", + "exe": "exec", + "exec": "exec", + "expla": "explain", + "explai": "explain", + "explain": "explain", + "explo": "explore", + "explor": "explore", + "explore": "explore", + "find": "find", + "find-": "find-dupes", + "find-d": "find-dupes", + "find-du": "find-dupes", + "find-dup": "find-dupes", + "find-dupe": "find-dupes", + "find-dupes": "find-dupes", + "fu": "fund", + "fun": "fund", + "fund": "fund", + "g": "get", + "ge": "get", + "get": "get", + "he": "help", + "hel": "help", + "help": "help", + "hl": "hlep", + "hle": "hlep", + "hlep": "hlep", + "hom": "home", + "home": "home", + "hoo": "hook", + "hook": "hook", + "i": "i", + "ic": "ic", + "in": "in", + "inf": "info", + "info": "info", + "ini": "init", + "init": "init", + "inn": "innit", + "inni": "innit", + "innit": "innit", + "ins": "ins", + "inst": "inst", + "insta": "insta", + "instal": "instal", + "install": "install", + "install-ci": "install-ci-test", + "install-ci-": "install-ci-test", + "install-ci-t": "install-ci-test", + "install-ci-te": "install-ci-test", + "install-ci-tes": "install-ci-test", + "install-ci-test": "install-ci-test", + "install-cl": "install-clean", + "install-cle": "install-clean", + "install-clea": "install-clean", + "install-clean": "install-clean", + "install-t": "install-test", + "install-te": "install-test", + "install-tes": "install-test", + "install-test": "install-test", + "isnt": "isnt", + "isnta": "isnta", + "isntal": "isntal", + "isntall": "isntall", + "isntall-": "isntall-clean", + "isntall-c": "isntall-clean", + "isntall-cl": "isntall-clean", + "isntall-cle": "isntall-clean", + "isntall-clea": "isntall-clean", + "isntall-clean": "isntall-clean", + "iss": "issues", + "issu": "issues", + "issue": "issues", + "issues": "issues", + "it": "it", + "la": "la", + "lin": "link", + "link": "link", + "lis": "list", + "list": "list", + "ll": "ll", + "ln": "ln", + "logi": "login", + "login": "login", + "logo": "logout", + "logou": "logout", + "logout": "logout", + "ls": "ls", + "og": "ogr", + "ogr": "ogr", + "or": "org", + "org": "org", + "ou": "outdated", + "out": "outdated", + "outd": "outdated", + "outda": "outdated", + "outdat": "outdated", + "outdate": "outdated", + "outdated": "outdated", + "ow": "owner", + "own": "owner", + "owne": "owner", + "owner": "owner", + "pa": "pack", + "pac": "pack", + "pack": "pack", + "pi": "ping", + "pin": "ping", + "ping": "ping", + "pk": "pkg", + "pkg": "pkg", + "pre": "prefix", + "pref": "prefix", + "prefi": "prefix", + "prefix": "prefix", + "pro": "profile", + "prof": "profile", + "profi": "profile", + "profil": "profile", + "profile": "profile", + "pru": "prune", + "prun": "prune", + "prune": "prune", + "pu": "publish", + "pub": "publish", + "publ": "publish", + "publi": "publish", + "publis": "publish", + "publish": "publish", + "q": "query", + "qu": "query", + "que": "query", + "quer": "query", + "query": "query", + "r": "r", + "rb": "rb", + "reb": "rebuild", + "rebu": "rebuild", + "rebui": "rebuild", + "rebuil": "rebuild", + "rebuild": "rebuild", + "rem": "remove", + "remo": "remove", + "remov": "remove", + "remove": "remove", + "rep": "repo", + "repo": "repo", + "res": "restart", + "rest": "restart", + "resta": "restart", + "restar": "restart", + "restart": "restart", + "rm": "rm", + "ro": "root", + "roo": "root", + "root": "root", + "rum": "rum", + "run": "run", + "run-": "run-script", + "run-s": "run-script", + "run-sc": "run-script", + "run-scr": "run-script", + "run-scri": "run-script", + "run-scrip": "run-script", + "run-script": "run-script", + "s": "s", + "se": "se", + "sea": "search", + "sear": "search", + "searc": "search", + "search": "search", + "set": "set", + "sho": "show", + "show": "show", + "shr": "shrinkwrap", + "shri": "shrinkwrap", + "shrin": "shrinkwrap", + "shrink": "shrinkwrap", + "shrinkw": "shrinkwrap", + "shrinkwr": "shrinkwrap", + "shrinkwra": "shrinkwrap", + "shrinkwrap": "shrinkwrap", + "si": "sit", + "sit": "sit", + "star": "star", + "stars": "stars", + "start": "start", + "sto": "stop", + "stop": "stop", + "t": "t", + "tea": "team", + "team": "team", + "tes": "test", + "test": "test", + "to": "token", + "tok": "token", + "toke": "token", + "token": "token", + "ts": "tst", + "tst": "tst", + "ud": "udpate", + "udp": "udpate", + "udpa": "udpate", + "udpat": "udpate", + "udpate": "udpate", + "un": "un", + "uni": "uninstall", + "unin": "uninstall", + "unins": "uninstall", + "uninst": "uninstall", + "uninsta": "uninstall", + "uninstal": "uninstall", + "uninstall": "uninstall", + "unl": "unlink", + "unli": "unlink", + "unlin": "unlink", + "unlink": "unlink", + "unp": "unpublish", + "unpu": "unpublish", + "unpub": "unpublish", + "unpubl": "unpublish", + "unpubli": "unpublish", + "unpublis": "unpublish", + "unpublish": "unpublish", + "uns": "unstar", + "unst": "unstar", + "unsta": "unstar", + "unstar": "unstar", + "up": "up", + "upd": "update", + "upda": "update", + "updat": "update", + "update": "update", + "upg": "upgrade", + "upgr": "upgrade", + "upgra": "upgrade", + "upgrad": "upgrade", + "upgrade": "upgrade", + "ur": "urn", + "urn": "urn", + "v": "v", + "veri": "verison", + "veris": "verison", + "veriso": "verison", + "verison": "verison", + "vers": "version", + "versi": "version", + "versio": "version", + "version": "version", + "vi": "view", + "vie": "view", + "view": "view", + "who": "whoami", + "whoa": "whoami", + "whoam": "whoami", + "whoami": "whoami", + "why": "why", + "x": "x", +} +` + +exports[`test/lib/docs.js TAP command list > aliases 1`] = ` +Object { + "add": "install", + "add-user": "adduser", + "author": "owner", + "c": "config", + "cit": "install-ci-test", + "clean-install": "ci", + "clean-install-test": "cit", + "create": "init", + "ddp": "dedupe", + "dist-tags": "dist-tag", + "find": "search", + "hlep": "help", + "home": "docs", + "i": "install", + "ic": "ci", + "in": "install", + "info": "view", + "innit": "init", + "ins": "install", + "inst": "install", + "insta": "install", + "instal": "install", + "install-clean": "ci", + "isnt": "install", + "isnta": "install", + "isntal": "install", + "isntall": "install", + "isntall-clean": "ci", + "issues": "bugs", + "it": "install-test", + "la": "ll", + "list": "ls", + "ln": "link", + "ogr": "org", + "r": "uninstall", + "rb": "rebuild", + "remove": "uninstall", + "rm": "uninstall", + "rum": "run-script", + "run": "run-script", + "s": "search", + "se": "search", + "show": "view", + "sit": "cit", + "t": "test", + "tst": "test", + "udpate": "update", + "un": "uninstall", + "unlink": "uninstall", + "up": "update", + "upgrade": "update", + "urn": "run-script", + "v": "view", + "verison": "version", + "why": "explain", + "x": "exec", +} +` + +exports[`test/lib/docs.js TAP command list > allCommands 1`] = ` Array [ - "_auth", "access", - "all", - "allow-same-version", - "also", + "adduser", "audit", - "audit-level", - "auth-type", - "before", - "bin-links", - "browser", - "ca", + "bugs", "cache", - "cache-max", - "cache-min", - "cafile", - "call", - "cert", - "ci-name", - "cidr", - "color", - "commit-hooks", - "depth", - "description", - "dev", + "ci", + "completion", + "config", + "dedupe", + "deprecate", "diff", - "diff-ignore-all-space", - "diff-name-only", - "diff-no-prefix", - "diff-dst-prefix", - "diff-src-prefix", - "diff-text", - "diff-unified", - "dry-run", - "editor", - "engine-strict", - "fetch-retries", - "fetch-retry-factor", - "fetch-retry-maxtimeout", - "fetch-retry-mintimeout", - "fetch-timeout", - "force", - "foreground-scripts", - "format-package-lock", + "dist-tag", + "docs", + "doctor", + "edit", + "exec", + "explain", + "explore", + "find-dupes", "fund", - "git", - "git-tag-version", - "global", - "global-style", - "globalconfig", - "heading", - "https-proxy", - "if-present", - "ignore-scripts", - "include", - "include-staged", - "include-workspace-root", - "init-author-email", - "init-author-name", - "init-author-url", - "init-license", - "init-module", - "init-version", - "init.author.email", - "init.author.name", - "init.author.url", - "init.license", - "init.module", - "init.version", - "install-links", - "json", - "key", - "legacy-bundling", - "legacy-peer-deps", + "get", + "help", + "help-search", + "hook", + "init", + "install", + "install-ci-test", + "install-test", "link", - "local-address", - "location", - "lockfile-version", - "loglevel", - "logs-dir", - "logs-max", - "long", - "maxsockets", - "message", - "node-options", - "node-version", - "noproxy", - "npm-version", - "offline", - "omit", - "omit-lockfile-registry-resolved", - "only", - "optional", - "otp", - "package", - "package-lock", - "package-lock-only", - "pack-destination", - "parseable", - "prefer-offline", - "prefer-online", + "ll", + "login", + "logout", + "ls", + "org", + "outdated", + "owner", + "pack", + "ping", + "pkg", "prefix", - "preid", - "production", - "progress", - "proxy", - "read-only", - "rebuild-bundle", - "registry", - "replace-registry-host", - "save", - "save-bundle", - "save-dev", - "save-exact", - "save-optional", - "save-peer", - "save-prefix", - "save-prod", - "scope", - "script-shell", - "searchexclude", - "searchlimit", - "searchopts", - "searchstaleness", - "shell", + "profile", + "prune", + "publish", + "query", + "rebuild", + "repo", + "restart", + "root", + "run-script", + "search", + "set", "shrinkwrap", - "sign-git-commit", - "sign-git-tag", - "strict-peer-deps", - "strict-ssl", - "tag", - "tag-version-prefix", - "timing", - "tmp", - "umask", - "unicode", - "update-notifier", - "usage", - "user-agent", - "userconfig", + "star", + "stars", + "start", + "stop", + "team", + "test", + "token", + "uninstall", + "unpublish", + "unstar", + "update", "version", - "versions", - "viewer", - "which", - "workspace", - "workspaces", - "workspaces-update", - "yes", + "view", + "whoami", +] +` + +exports[`test/lib/docs.js TAP command list > commands 1`] = ` +Array [ + "access", + "adduser", + "audit", + "bugs", + "cache", + "ci", + "completion", + "config", + "dedupe", + "deprecate", + "diff", + "dist-tag", + "docs", + "doctor", + "edit", + "exec", + "explain", + "explore", + "find-dupes", + "fund", + "get", + "help", + "hook", + "init", + "install", + "install-ci-test", + "install-test", + "link", + "ll", + "login", + "logout", + "ls", + "org", + "outdated", + "owner", + "pack", + "ping", + "pkg", + "prefix", + "profile", + "prune", + "publish", + "query", + "rebuild", + "repo", + "restart", + "root", + "run-script", + "search", + "set", + "shrinkwrap", + "star", + "stars", + "start", + "stop", + "team", + "test", + "token", + "uninstall", + "unpublish", + "unstar", + "update", + "version", + "view", + "whoami", ] ` -exports[`test/lib/utils/config/definitions.js TAP > all config keys that are shared to flatOptions 1`] = ` -Array [] +exports[`test/lib/docs.js TAP command list > plumbing 1`] = ` +Array [ + "help-search", +] ` -exports[`test/lib/utils/config/definitions.js TAP > config description for _auth 1`] = ` +exports[`test/lib/docs.js TAP config > all definitions 1`] = ` #### \`_auth\` * Default: null @@ -175,9 +569,7 @@ registries you will need to scope it like "//other-registry.tld/:_auth" Warning: This should generally not be set via a command-line option. It is safer to use a registry-provided authentication bearer token stored in the ~/.npmrc file by running \`npm login\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for access 1`] = ` #### \`access\` * Default: 'public' for new packages, existing packages it will not change the @@ -193,9 +585,7 @@ Note: This defaults to not changing the current access level for existing packages. Specifying a value of \`restricted\` or \`public\` during publish will change the access for an existing package the same way that \`npm access set status\` would. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for all 1`] = ` #### \`all\` * Default: false @@ -204,9 +594,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for all 1 When running \`npm outdated\` and \`npm ls\`, setting \`--all\` will show all outdated or installed packages, rather than only those directly depended upon by the current project. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for allow-same-version 1`] = ` #### \`allow-same-version\` * Default: false @@ -214,19 +602,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for allow Prevents throwing an error when \`npm version\` is used to set the new version to the same value as the current version. -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for also 1`] = ` -#### \`also\` -* Default: null -* Type: null, "dev", or "development" -* DEPRECATED: Please use --include=dev instead. - -When set to \`dev\` or \`development\`, this is an alias for \`--include=dev\`. -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for audit 1`] = ` #### \`audit\` * Default: true @@ -236,9 +612,7 @@ When "true" submit audit reports alongside the current npm command to the default registry and all registries configured for scopes. See the documentation for [\`npm audit\`](/commands/npm-audit) for details on what is submitted. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for audit-level 1`] = ` #### \`audit-level\` * Default: null @@ -246,18 +620,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for audit The minimum level of vulnerability for \`npm audit\` to exit with a non-zero exit code. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for auth-type 1`] = ` #### \`auth-type\` * Default: "web" * Type: "legacy" or "web" What authentication strategy to use with \`login\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for before 1`] = ` #### \`before\` * Default: null @@ -272,9 +642,7 @@ If the requested version is a \`dist-tag\` and the given tag does not pass the \`--before\` filter, the most recent version less than or equal to that tag will be used. For example, \`foo@latest\` might install \`foo@1.2\` even though \`latest\` is \`2.0\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for bin-links 1`] = ` #### \`bin-links\` * Default: true @@ -286,9 +654,7 @@ executables. Set to false to have it not do this. This can be used to work around the fact that some file systems don't support symlinks, even on ostensibly Unix systems. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for browser 1`] = ` #### \`browser\` * Default: OS X: \`"open"\`, Windows: \`"start"\`, Others: \`"xdg-open"\` @@ -300,9 +666,7 @@ Set to \`false\` to suppress browser behavior and instead print urls to terminal. Set to \`true\` to use default system URL opener. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for ca 1`] = ` #### \`ca\` * Default: null @@ -328,38 +692,14 @@ ca[]="..." \`\`\` See also the \`strict-ssl\` config. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for cache 1`] = ` #### \`cache\` * Default: Windows: \`%LocalAppData%\\npm-cache\`, Posix: \`~/.npm\` * Type: Path The location of npm's cache directory. -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for cache-max 1`] = ` -#### \`cache-max\` - -* Default: Infinity -* Type: Number -* DEPRECATED: This option has been deprecated in favor of \`--prefer-online\` - -\`--cache-max=0\` is an alias for \`--prefer-online\` -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for cache-min 1`] = ` -#### \`cache-min\` - -* Default: 0 -* Type: Number -* DEPRECATED: This option has been deprecated in favor of \`--prefer-offline\`. - -\`--cache-min=9999 (or bigger)\` is an alias for \`--prefer-offline\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for cafile 1`] = ` #### \`cafile\` * Default: null @@ -368,9 +708,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for cafil A path to a file containing one or multiple Certificate Authority signing certificates. Similar to the \`ca\` setting, but allows for multiple CA's, as well as for the CA information to be stored in a file on disk. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for call 1`] = ` #### \`call\` * Default: "" @@ -383,9 +721,7 @@ custom command to be run along with the installed packages. npm exec --package yo --package generator-node --call "yo node" \`\`\` -` -exports[`test/lib/utils/config/definitions.js TAP > config description for cert 1`] = ` #### \`cert\` * Default: null @@ -402,9 +738,7 @@ cert="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----" It is _not_ the path to a certificate file, though you can set a registry-scoped "certfile" path like "//other-registry.tld/:certfile=/path/to/cert.pem". -` -exports[`test/lib/utils/config/definitions.js TAP > config description for ci-name 1`] = ` #### \`ci-name\` * Default: The name of the current CI system, or \`null\` when not on a known CI @@ -414,9 +748,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for ci-na The name of a continuous integration system. If not set explicitly, npm will detect the current CI environment using the [\`@npmcli/ci-detect\`](http://npm.im/@npmcli/ci-detect) module. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for cidr 1`] = ` #### \`cidr\` * Default: null @@ -424,9 +756,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for cidr This is a list of CIDR address to be used when configuring limited access tokens with the \`npm token create\` command. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for color 1`] = ` #### \`color\` * Default: true unless the NO_COLOR environ is set to something other than '0' @@ -434,18 +764,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for color If false, never shows colors. If \`"always"\` then always shows colors. If true, then only prints color codes for tty file descriptors. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for commit-hooks 1`] = ` #### \`commit-hooks\` * Default: true * Type: Boolean Run git commit hooks when using the \`npm version\` command. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for depth 1`] = ` #### \`depth\` * Default: \`Infinity\` if \`--all\` is set, otherwise \`1\` @@ -455,64 +781,42 @@ The depth to go when recursing packages for \`npm ls\`. If not set, \`npm ls\` will show only the immediate dependencies of the root project. If \`--all\` is set, then npm will show all dependencies by default. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for description 1`] = ` #### \`description\` * Default: true * Type: Boolean Show the description in \`npm search\` -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for dev 1`] = ` -#### \`dev\` - -* Default: false -* Type: Boolean -* DEPRECATED: Please use --include=dev instead. -Alias for \`--include=dev\`. -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for diff 1`] = ` #### \`diff\` * Default: * Type: String (can be set multiple times) Define arguments to compare in \`npm diff\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for diff-dst-prefix 1`] = ` #### \`diff-dst-prefix\` * Default: "b/" * Type: String Destination prefix to be used in \`npm diff\` output. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for diff-ignore-all-space 1`] = ` #### \`diff-ignore-all-space\` * Default: false * Type: Boolean Ignore whitespace when comparing lines in \`npm diff\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for diff-name-only 1`] = ` #### \`diff-name-only\` * Default: false * Type: Boolean Prints only filenames when using \`npm diff\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for diff-no-prefix 1`] = ` #### \`diff-no-prefix\` * Default: false @@ -522,36 +826,28 @@ Do not show any source or destination prefix in \`npm diff\` output. Note: this causes \`npm diff\` to ignore the \`--diff-src-prefix\` and \`--diff-dst-prefix\` configs. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for diff-src-prefix 1`] = ` #### \`diff-src-prefix\` * Default: "a/" * Type: String Source prefix to be used in \`npm diff\` output. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for diff-text 1`] = ` #### \`diff-text\` * Default: false * Type: Boolean Treat all files as text in \`npm diff\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for diff-unified 1`] = ` #### \`diff-unified\` * Default: 3 * Type: Number The number of lines of context to print in \`npm diff\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for dry-run 1`] = ` #### \`dry-run\` * Default: false @@ -564,9 +860,7 @@ commands that modify your local installation, eg, \`install\`, \`update\`, Note: This is NOT honored by other network related commands, eg \`dist-tags\`, \`owner\`, etc. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for editor 1`] = ` #### \`editor\` * Default: The EDITOR or VISUAL environment variables, or 'notepad.exe' on @@ -574,9 +868,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for edito * Type: String The command to run for \`npm edit\` and \`npm config edit\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for engine-strict 1`] = ` #### \`engine-strict\` * Default: false @@ -587,9 +879,7 @@ installing) any package that claims to not be compatible with the current Node.js version. This can be overridden by setting the \`--force\` flag. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for fetch-retries 1`] = ` #### \`fetch-retries\` * Default: 2 @@ -600,18 +890,14 @@ from the registry. npm will retry idempotent read requests to the registry in the case of network failures or 5xx HTTP errors. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for fetch-retry-factor 1`] = ` #### \`fetch-retry-factor\` * Default: 10 * Type: Number The "factor" config for the \`retry\` module to use when fetching packages. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for fetch-retry-maxtimeout 1`] = ` #### \`fetch-retry-maxtimeout\` * Default: 60000 (1 minute) @@ -619,9 +905,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for fetch The "maxTimeout" config for the \`retry\` module to use when fetching packages. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for fetch-retry-mintimeout 1`] = ` #### \`fetch-retry-mintimeout\` * Default: 10000 (10 seconds) @@ -629,18 +913,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for fetch The "minTimeout" config for the \`retry\` module to use when fetching packages. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for fetch-timeout 1`] = ` #### \`fetch-timeout\` * Default: 300000 (5 minutes) * Type: Number The maximum amount of time to wait for HTTP requests to complete. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for force 1`] = ` #### \`force\` * Default: false @@ -666,9 +946,7 @@ mistakes, unnecessary performance degradation, and malicious input. If you don't have a clear idea of what you want to do, it is strongly recommended that you do not use this option! -` -exports[`test/lib/utils/config/definitions.js TAP > config description for foreground-scripts 1`] = ` #### \`foreground-scripts\` * Default: false @@ -680,9 +958,7 @@ input, output, and error with the main npm process. Note that this will generally make installs run slower, and be much noisier, but can be useful for debugging. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for format-package-lock 1`] = ` #### \`format-package-lock\` * Default: true @@ -690,9 +966,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for forma Format \`package-lock.json\` or \`npm-shrinkwrap.json\` as a human readable file. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for fund 1`] = ` #### \`fund\` * Default: true @@ -701,9 +975,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for fund When "true" displays the message at the end of each \`npm install\` acknowledging the number of dependencies looking for funding. See [\`npm fund\`](/commands/npm-fund) for details. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for git 1`] = ` #### \`git\` * Default: "git" @@ -711,9 +983,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for git 1 The command to use for git commands. If git is installed on the computer, but is not in the \`PATH\`, then set this to the full path to the git binary. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for git-tag-version 1`] = ` #### \`git-tag-version\` * Default: true @@ -721,9 +991,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for git-t Tag the commit when using the \`npm version\` command. Setting this to false results in no commit being made at all. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for global 1`] = ` #### \`global\` * Default: false @@ -737,9 +1005,7 @@ folder instead of the current working directory. See of the current working directory. * bin files are linked to \`{prefix}/bin\` * man pages are linked to \`{prefix}/share/man\` -` -exports[`test/lib/utils/config/definitions.js TAP > config description for global-style 1`] = ` #### \`global-style\` * Default: false @@ -751,9 +1017,7 @@ direct dependencies will show in \`node_modules\` and everything they depend on will be flattened in their \`node_modules\` folders. This obviously will eliminate some deduping. If used with \`legacy-bundling\`, \`legacy-bundling\` will be preferred. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for globalconfig 1`] = ` #### \`globalconfig\` * Default: The global --prefix setting plus 'etc/npmrc'. For example, @@ -761,18 +1025,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for globa * Type: Path The config file to read for global config options. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for heading 1`] = ` #### \`heading\` * Default: "npm" * Type: String The string that starts all the debugging log output. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for https-proxy 1`] = ` #### \`https-proxy\` * Default: null @@ -782,9 +1042,7 @@ A proxy to use for outgoing https requests. If the \`HTTPS_PROXY\` or \`https_proxy\` or \`HTTP_PROXY\` or \`http_proxy\` environment variables are set, proxy settings will be honored by the underlying \`make-fetch-happen\` library. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for if-present 1`] = ` #### \`if-present\` * Default: false @@ -798,9 +1056,7 @@ running scripts that may only apply for some builds in an otherwise generic CI setup. This value is not exported to the environment for child processes. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for ignore-scripts 1`] = ` #### \`ignore-scripts\` * Default: false @@ -812,9 +1068,7 @@ Note that commands explicitly intended to run a particular script, such as \`npm start\`, \`npm stop\`, \`npm restart\`, \`npm test\`, and \`npm run-script\` will still run their intended script if \`ignore-scripts\` is set, but they will *not* run any pre- or post-scripts. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for include 1`] = ` #### \`include\` * Default: @@ -826,9 +1080,7 @@ This is the inverse of \`--omit=\`. Dependency types specified in \`--include\` will not be omitted, regardless of the order in which omit/include are specified on the command-line. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for include-staged 1`] = ` #### \`include-staged\` * Default: false @@ -838,9 +1090,7 @@ Allow installing "staged" published packages, as defined by [npm RFC PR #92](https://github.com/npm/rfcs/pull/92). This is experimental, and not implemented by the npm public registry. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for include-workspace-root 1`] = ` #### \`include-workspace-root\` * Default: false @@ -853,27 +1103,21 @@ all workspaces via the \`workspaces\` flag, will cause npm to operate only on the specified workspaces, and not on the root project. This value is not exported to the environment for child processes. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for init-author-email 1`] = ` #### \`init-author-email\` * Default: "" * Type: String The value \`npm init\` should use by default for the package author's email. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for init-author-name 1`] = ` #### \`init-author-name\` * Default: "" * Type: String The value \`npm init\` should use by default for the package author's name. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for init-author-url 1`] = ` #### \`init-author-url\` * Default: "" @@ -881,18 +1125,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for init- The value \`npm init\` should use by default for the package author's homepage. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for init-license 1`] = ` #### \`init-license\` * Default: "ISC" * Type: String The value \`npm init\` should use by default for the package license. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for init-module 1`] = ` #### \`init-module\` * Default: "~/.npm-init.js" @@ -902,9 +1142,7 @@ A module that will be loaded by the \`npm init\` command. See the documentation for the [init-package-json](https://github.com/npm/init-package-json) module for more information, or [npm init](/commands/npm-init). -` -exports[`test/lib/utils/config/definitions.js TAP > config description for init-version 1`] = ` #### \`init-version\` * Default: "1.0.0" @@ -912,80 +1150,16 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for init- The value that \`npm init\` should use by default for the package version number, if not already set in package.json. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for init.author.email 1`] = ` -#### \`init.author.email\` +#### \`install-links\` -* Default: "" -* Type: String -* DEPRECATED: Use \`--init-author-email\` instead. - -Alias for \`--init-author-email\` -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for init.author.name 1`] = ` -#### \`init.author.name\` - -* Default: "" -* Type: String -* DEPRECATED: Use \`--init-author-name\` instead. - -Alias for \`--init-author-name\` -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for init.author.url 1`] = ` -#### \`init.author.url\` - -* Default: "" -* Type: "" or URL -* DEPRECATED: Use \`--init-author-url\` instead. - -Alias for \`--init-author-url\` -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for init.license 1`] = ` -#### \`init.license\` - -* Default: "ISC" -* Type: String -* DEPRECATED: Use \`--init-license\` instead. - -Alias for \`--init-license\` -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for init.module 1`] = ` -#### \`init.module\` - -* Default: "~/.npm-init.js" -* Type: Path -* DEPRECATED: Use \`--init-module\` instead. - -Alias for \`--init-module\` -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for init.version 1`] = ` -#### \`init.version\` - -* Default: "1.0.0" -* Type: SemVer string -* DEPRECATED: Use \`--init-version\` instead. - -Alias for \`--init-version\` -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for install-links 1`] = ` -#### \`install-links\` - -* Default: true -* Type: Boolean +* Default: true +* Type: Boolean When set file: protocol dependencies will be packed and installed as regular dependencies instead of creating a symlink. This option has no effect on workspaces. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for json 1`] = ` #### \`json\` * Default: false @@ -997,9 +1171,7 @@ Whether or not to output JSON data, rather than the normal output. saving them to your \`package.json\`. Not supported by all npm commands. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for key 1`] = ` #### \`key\` * Default: null @@ -1014,9 +1186,7 @@ key="-----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY-----" It is _not_ the path to a key file, though you can set a registry-scoped "keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem". -` -exports[`test/lib/utils/config/definitions.js TAP > config description for legacy-bundling 1`] = ` #### \`legacy-bundling\` * Default: false @@ -1026,9 +1196,7 @@ Causes npm to install the package such that versions of npm prior to 1.4, such as the one included with node 0.8, can install the package. This eliminates all automatic deduping. If used with \`global-style\` this option will be preferred. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for legacy-peer-deps 1`] = ` #### \`legacy-peer-deps\` * Default: false @@ -1046,18 +1214,14 @@ This differs from \`--omit=peer\`, in that \`--omit=peer\` will avoid unpacking Use of \`legacy-peer-deps\` is not recommended, as it will not enforce the \`peerDependencies\` contract that meta-dependencies may rely on. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for link 1`] = ` #### \`link\` * Default: false * Type: Boolean Used with \`npm ls\`, limiting output to only those packages that are linked. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for local-address 1`] = ` #### \`local-address\` * Default: null @@ -1065,9 +1229,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for local The IP address of the local interface to use when making connections to the npm registry. Must be IPv4 in versions of Node prior to 0.12. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for location 1`] = ` #### \`location\` * Default: "user" unless \`--global\` is passed, which will also set this value @@ -1084,9 +1246,7 @@ instead of the current working directory. See of the current working directory. * bin files are linked to \`{prefix}/bin\` * man pages are linked to \`{prefix}/share/man\` -` -exports[`test/lib/utils/config/definitions.js TAP > config description for lockfile-version 1`] = ` #### \`lockfile-version\` * Default: Version 3 if no lockfile, auto-converting v1 lockfiles to v3, @@ -1108,9 +1268,7 @@ determinism and interoperability, at the expense of more bytes on disk. 3: Only the new lockfile information introduced in npm version 7. Smaller on disk than lockfile version 2, but not interoperable with older npm versions. Ideal if all users are on npm version 7 and higher. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for loglevel 1`] = ` #### \`loglevel\` * Default: "notice" @@ -1124,9 +1282,7 @@ Any logs of a higher level than the setting are shown. The default is "notice". See also the \`foreground-scripts\` config. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for logs-dir 1`] = ` #### \`logs-dir\` * Default: A directory named \`_logs\` inside the cache @@ -1134,9 +1290,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for logs- The location of npm's log directory. See [\`npm logging\`](/using-npm/logging) for more information. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for logs-max 1`] = ` #### \`logs-max\` * Default: 10 @@ -1145,18 +1299,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for logs- The maximum number of log files to store. If set to 0, no log files will be written for the current run. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for long 1`] = ` #### \`long\` * Default: false * Type: Boolean Show extended information in \`ls\`, \`search\`, and \`help-search\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for maxsockets 1`] = ` #### \`maxsockets\` * Default: 15 @@ -1164,9 +1314,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for maxso The maximum number of connections to use per origin (protocol/host/port combination). -` -exports[`test/lib/utils/config/definitions.js TAP > config description for message 1`] = ` #### \`message\` * Default: "%s" @@ -1175,9 +1323,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for messa Commit message which is used by \`npm version\` when creating version commit. Any "%s" in the message will be replaced with the version number. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for node-options 1`] = ` #### \`node-options\` * Default: null @@ -1186,18 +1332,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for node- Options to pass through to Node.js via the \`NODE_OPTIONS\` environment variable. This does not impact how npm itself is executed but it does impact how lifecycle scripts are called. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for node-version 1`] = ` #### \`node-version\` * Default: Node.js \`process.version\` value * Type: SemVer string The node version to use when checking a package's \`engines\` setting. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for noproxy 1`] = ` #### \`noproxy\` * Default: The value of the NO_PROXY environment variable @@ -1206,18 +1348,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for nopro Domain extensions that should bypass any proxies. Also accepts a comma-delimited string. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for npm-version 1`] = ` #### \`npm-version\` * Default: Output of \`npm --version\` * Type: SemVer string The npm version to use when checking a package's \`engines\` setting. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for offline 1`] = ` #### \`offline\` * Default: false @@ -1225,9 +1363,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for offli Force offline mode: no network requests will be done during install. To allow the CLI to fill in missing cache data, see \`--prefer-offline\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for omit 1`] = ` #### \`omit\` * Default: 'dev' if the \`NODE_ENV\` environment variable is set to @@ -1245,9 +1381,7 @@ it will be included. If the resulting omit list includes \`'dev'\`, then the \`NODE_ENV\` environment variable will be set to \`'production'\` for all lifecycle scripts. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for omit-lockfile-registry-resolved 1`] = ` #### \`omit-lockfile-registry-resolved\` * Default: false @@ -1257,32 +1391,7 @@ This option causes npm to create lock files without a \`resolved\` key for registry dependencies. Subsequent installs will need to resolve tarball endpoints with the configured registry, likely resulting in a longer install time. -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for only 1`] = ` -#### \`only\` - -* Default: null -* Type: null, "prod", or "production" -* DEPRECATED: Use \`--omit=dev\` to omit dev dependencies from the install. - -When set to \`prod\` or \`production\`, this is an alias for \`--omit=dev\`. -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for optional 1`] = ` -#### \`optional\` - -* Default: null -* Type: null or Boolean -* DEPRECATED: Use \`--omit=optional\` to exclude optional dependencies, or - \`--include=optional\` to include them. - -Default value does install optional deps unless otherwise omitted. - -Alias for --include=optional or --omit=optional -` -exports[`test/lib/utils/config/definitions.js TAP > config description for otp 1`] = ` #### \`otp\` * Default: null @@ -1293,27 +1402,21 @@ when publishing or changing package permissions with \`npm access\`. If not set, and a registry response fails with a challenge for a one-time password, npm will prompt on the command line for one. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for pack-destination 1`] = ` #### \`pack-destination\` * Default: "." * Type: String Directory in which \`npm pack\` will save tarballs. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for package 1`] = ` #### \`package\` * Default: * Type: String (can be set multiple times) The package or packages to install for [\`npm exec\`](/commands/npm-exec) -` -exports[`test/lib/utils/config/definitions.js TAP > config description for package-lock 1`] = ` #### \`package-lock\` * Default: true @@ -1323,9 +1426,7 @@ If set to false, then ignore \`package-lock.json\` files when installing. This will also prevent _writing_ \`package-lock.json\` if \`save\` is true. This configuration does not affect \`npm ci\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for package-lock-only 1`] = ` #### \`package-lock-only\` * Default: false @@ -1339,9 +1440,7 @@ instead of checking \`node_modules\` and downloading dependencies. For \`list\` this means the output will be based on the tree described by the \`package-lock.json\`, rather than the contents of \`node_modules\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for parseable 1`] = ` #### \`parseable\` * Default: false @@ -1349,9 +1448,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for parse Output parseable results from commands that write to standard output. For \`npm search\`, this will be tab-separated table format. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for prefer-offline 1`] = ` #### \`prefer-offline\` * Default: false @@ -1360,9 +1457,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for prefe If true, staleness checks for cached data will be bypassed, but missing data will be requested from the server. To force full offline mode, use \`--offline\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for prefer-online 1`] = ` #### \`prefer-online\` * Default: false @@ -1370,9 +1465,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for prefe If true, staleness checks for cached data will be forced, making the CLI look for updates immediately even for fresh package data. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for prefix 1`] = ` #### \`prefix\` * Default: In global mode, the folder where the node executable is installed. @@ -1382,9 +1475,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for prefi The location to install global items. If set on the command line, then it forces non-global commands to run in the specified folder. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for preid 1`] = ` #### \`preid\` * Default: "" @@ -1392,19 +1483,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for preid The "prerelease identifier" to use as a prefix for the "prerelease" part of a semver. Like the \`rc\` in \`1.2.0-rc.8\`. -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for production 1`] = ` -#### \`production\` - -* Default: null -* Type: null or Boolean -* DEPRECATED: Use \`--omit=dev\` instead. -Alias for \`--omit=dev\` -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for progress 1`] = ` #### \`progress\` * Default: \`true\` unless running in a known CI system @@ -1414,9 +1493,7 @@ When set to \`true\`, npm will display a progress bar during time intensive operations, if \`process.stderr\` is a TTY. Set to \`false\` to suppress the progress bar. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for proxy 1`] = ` #### \`proxy\` * Default: null @@ -1425,9 +1502,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for proxy A proxy to use for outgoing http requests. If the \`HTTP_PROXY\` or \`http_proxy\` environment variables are set, proxy settings will be honored by the underlying \`request\` library. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for read-only 1`] = ` #### \`read-only\` * Default: false @@ -1435,27 +1510,21 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for read- This is used to mark a token as unable to publish when configuring limited access tokens with the \`npm token create\` command. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for rebuild-bundle 1`] = ` #### \`rebuild-bundle\` * Default: true * Type: Boolean Rebuild bundled dependencies after installation. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for registry 1`] = ` #### \`registry\` * Default: "https://registry.npmjs.org/" * Type: URL The base URL of the npm registry. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for replace-registry-host 1`] = ` #### \`replace-registry-host\` * Default: "npmjs" @@ -1470,9 +1539,7 @@ registry (https://registry.npmjs.org) to the configured registry. If set to registry host with the configured host every time. You may also specify a bare hostname (e.g., "registry.npmjs.org"). -` -exports[`test/lib/utils/config/definitions.js TAP > config description for save 1`] = ` #### \`save\` * Default: \`true\` unless when using \`npm update\` where it defaults to \`false\` @@ -1484,9 +1551,7 @@ When used with the \`npm rm\` command, removes the dependency from \`package.json\`. Will also prevent writing to \`package-lock.json\` if set to \`false\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for save-bundle 1`] = ` #### \`save-bundle\` * Default: false @@ -1497,18 +1562,14 @@ If a package would be saved at install time by the use of \`--save\`, \`bundleDependencies\` list. Ignored if \`--save-peer\` is set, since peerDependencies cannot be bundled. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for save-dev 1`] = ` #### \`save-dev\` * Default: false * Type: Boolean Save installed packages to a package.json file as \`devDependencies\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for save-exact 1`] = ` #### \`save-exact\` * Default: false @@ -1516,27 +1577,21 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for save- Dependencies saved to package.json will be configured with an exact version rather than using npm's default semver range operator. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for save-optional 1`] = ` #### \`save-optional\` * Default: false * Type: Boolean Save installed packages to a package.json file as \`optionalDependencies\`. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for save-peer 1`] = ` #### \`save-peer\` * Default: false * Type: Boolean Save installed packages to a package.json file as \`peerDependencies\` -` -exports[`test/lib/utils/config/definitions.js TAP > config description for save-prefix 1`] = ` #### \`save-prefix\` * Default: "^" @@ -1549,9 +1604,7 @@ For example if a package has version \`1.2.3\`, by default its version is set to \`^1.2.3\` which allows minor upgrades for that package, but after \`npm config set save-prefix='~'\` it would be set to \`~1.2.3\` which only allows patch upgrades. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for save-prod 1`] = ` #### \`save-prod\` * Default: false @@ -1563,9 +1616,7 @@ you want to move it to be a non-optional production dependency. This is the default behavior if \`--save\` is true, and neither \`--save-dev\` or \`--save-optional\` are true. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for scope 1`] = ` #### \`scope\` * Default: the scope of the current project, if any, or "" @@ -1595,9 +1646,7 @@ This will also cause \`npm init\` to create a scoped package. npm init --scope=@foo --yes \`\`\` -` -exports[`test/lib/utils/config/definitions.js TAP > config description for script-shell 1`] = ` #### \`script-shell\` * Default: '/bin/sh' on POSIX systems, 'cmd.exe' on Windows @@ -1605,18 +1654,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for scrip The shell to use for scripts run with the \`npm exec\`, \`npm run\` and \`npm init \` commands. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for searchexclude 1`] = ` #### \`searchexclude\` * Default: "" * Type: String Space-separated options that limit the results from search. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for searchlimit 1`] = ` #### \`searchlimit\` * Default: 20 @@ -1624,18 +1669,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for searc Number of items to limit search results to. Will not apply at all to legacy searches. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for searchopts 1`] = ` #### \`searchopts\` * Default: "" * Type: String Space-separated options that are always passed to search. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for searchstaleness 1`] = ` #### \`searchstaleness\` * Default: 900 @@ -1643,9 +1684,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for searc The age of the cache, in seconds, before another registry request is made if using legacy search endpoint. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for shell 1`] = ` #### \`shell\` * Default: SHELL environment variable, or "bash" on Posix, or "cmd.exe" on @@ -1653,19 +1692,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for shell * Type: String The shell to run for the \`npm explore\` command. -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for shrinkwrap 1`] = ` -#### \`shrinkwrap\` - -* Default: true -* Type: Boolean -* DEPRECATED: Use the --package-lock setting instead. - -Alias for --package-lock -` -exports[`test/lib/utils/config/definitions.js TAP > config description for sign-git-commit 1`] = ` #### \`sign-git-commit\` * Default: false @@ -1676,9 +1703,7 @@ version using \`-S\` to add a signature. Note that git requires you to have set up GPG keys in your git configs for this to work properly. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for sign-git-tag 1`] = ` #### \`sign-git-tag\` * Default: false @@ -1689,9 +1714,7 @@ If set to true, then the \`npm version\` command will tag the version using Note that git requires you to have set up GPG keys in your git configs for this to work properly. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for strict-peer-deps 1`] = ` #### \`strict-peer-deps\` * Default: false @@ -1710,9 +1733,7 @@ the range set in their package's \`peerDependencies\` object. When such and override is performed, a warning is printed, explaining the conflict and the packages involved. If \`--strict-peer-deps\` is set, then this warning is treated as a failure. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for strict-ssl 1`] = ` #### \`strict-ssl\` * Default: true @@ -1722,9 +1743,7 @@ Whether or not to do SSL key validation when making requests to the registry via https. See also the \`ca\` config. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for tag 1`] = ` #### \`tag\` * Default: "latest" @@ -1738,9 +1757,7 @@ command, if no explicit tag is given. When used by the \`npm diff\` command, this is the tag used to fetch the tarball that will be compared with the local files by default. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for tag-version-prefix 1`] = ` #### \`tag-version-prefix\` * Default: "v" @@ -1753,9 +1770,7 @@ it to the empty string: \`""\`. Because other tools may rely on the convention that npm version tags look like \`v1.0.0\`, _only use this property if it is absolutely necessary_. In particular, use care when overriding this setting for public packages. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for timing 1`] = ` #### \`timing\` * Default: false @@ -1766,23 +1781,7 @@ cache or \`logs-dir\`. The file name ends with \`-timing.json\`. You can quickly view it with this [json](https://npm.im/json) command line: \`cat ~/.npm/_logs/*-timing.json | npm exec -- json -g\`. -` - -exports[`test/lib/utils/config/definitions.js TAP > config description for tmp 1`] = ` -#### \`tmp\` - -* Default: The value returned by the Node.js \`os.tmpdir()\` method - -* Type: Path -* DEPRECATED: This setting is no longer used. npm stores temporary files in a - special location in the cache, and they are managed by - [\`cacache\`](http://npm.im/cacache). - -Historically, the location where temporary files were stored. No longer -relevant. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for umask 1`] = ` #### \`umask\` * Default: 0 @@ -1802,9 +1801,7 @@ rather adds the \`--umask\` config to it. Thus, the effective default umask value on most POSIX systems is 0o22, meaning that folders and executables are created with a mode of 0o755 and other files are created with a mode of 0o644. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for unicode 1`] = ` #### \`unicode\` * Default: false on windows, true on mac/unix systems with a unicode locale, @@ -1813,9 +1810,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for unico When set to true, npm uses unicode characters in the tree output. When false, it uses ascii characters instead of unicode glyphs. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for update-notifier 1`] = ` #### \`update-notifier\` * Default: true @@ -1823,18 +1818,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for updat Set to false to suppress the update notification when using an older version of npm than the latest. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for usage 1`] = ` #### \`usage\` * Default: false * Type: Boolean Show short usage output about the command specified. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for user-agent 1`] = ` #### \`user-agent\` * Default: "npm/{npm-version} node/{node-version} {platform} {arch} @@ -1852,9 +1843,7 @@ their actual counterparts: are set. * \`{ci}\` - The value of the \`ci-name\` config, if set, prefixed with \`ci/\`, or an empty string if \`ci-name\` is empty. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for userconfig 1`] = ` #### \`userconfig\` * Default: "~/.npmrc" @@ -1865,9 +1854,7 @@ The location of user-level configuration settings. This may be overridden by the \`npm_config_userconfig\` environment variable or the \`--userconfig\` command line option, but may _not_ be overridden by settings in the \`globalconfig\` file. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for version 1`] = ` #### \`version\` * Default: false @@ -1876,9 +1863,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for versi If true, output the npm version and exit successfully. Only relevant when specified explicitly on the command line. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for versions 1`] = ` #### \`versions\` * Default: false @@ -1889,9 +1874,7 @@ the version in the current working directory's \`package.json\` file if one exists, and exit successfully. Only relevant when specified explicitly on the command line. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for viewer 1`] = ` #### \`viewer\` * Default: "man" on Posix, "browser" on Windows @@ -1900,18 +1883,14 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for viewe The program to use to view help content. Set to \`"browser"\` to view html help content in the default web browser. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for which 1`] = ` #### \`which\` * Default: null * Type: null or Number If there are multiple funding sources, which 1-indexed source URL to open. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for workspace 1`] = ` #### \`workspace\` * Default: @@ -1933,9 +1912,7 @@ workspace which does not yet exist, to create the folder and set it up as a brand new workspace within the project. This value is not exported to the environment for child processes. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for workspaces 1`] = ` #### \`workspaces\` * Default: null @@ -1953,9 +1930,7 @@ other things (test, exec, publish, etc.) will operate on the root project, _unless_ one or more workspaces are specified in the \`workspace\` config. This value is not exported to the environment for child processes. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for workspaces-update 1`] = ` #### \`workspaces-update\` * Default: true @@ -1963,9 +1938,7 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for works If set to true, the npm cli will run an update after operations that may possibly change the workspaces installed to the \`node_modules\` folder. -` -exports[`test/lib/utils/config/definitions.js TAP > config description for yes 1`] = ` #### \`yes\` * Default: null @@ -1973,4 +1946,1436 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for yes 1 Automatically answer "yes" to any prompts that npm might print on the command line. + +#### \`also\` + +* Default: null +* Type: null, "dev", or "development" +* DEPRECATED: Please use --include=dev instead. + +When set to \`dev\` or \`development\`, this is an alias for \`--include=dev\`. + +#### \`cache-max\` + +* Default: Infinity +* Type: Number +* DEPRECATED: This option has been deprecated in favor of \`--prefer-online\` + +\`--cache-max=0\` is an alias for \`--prefer-online\` + +#### \`cache-min\` + +* Default: 0 +* Type: Number +* DEPRECATED: This option has been deprecated in favor of \`--prefer-offline\`. + +\`--cache-min=9999 (or bigger)\` is an alias for \`--prefer-offline\`. + +#### \`dev\` + +* Default: false +* Type: Boolean +* DEPRECATED: Please use --include=dev instead. + +Alias for \`--include=dev\`. + +#### \`init.author.email\` + +* Default: "" +* Type: String +* DEPRECATED: Use \`--init-author-email\` instead. + +Alias for \`--init-author-email\` + +#### \`init.author.name\` + +* Default: "" +* Type: String +* DEPRECATED: Use \`--init-author-name\` instead. + +Alias for \`--init-author-name\` + +#### \`init.author.url\` + +* Default: "" +* Type: "" or URL +* DEPRECATED: Use \`--init-author-url\` instead. + +Alias for \`--init-author-url\` + +#### \`init.license\` + +* Default: "ISC" +* Type: String +* DEPRECATED: Use \`--init-license\` instead. + +Alias for \`--init-license\` + +#### \`init.module\` + +* Default: "~/.npm-init.js" +* Type: Path +* DEPRECATED: Use \`--init-module\` instead. + +Alias for \`--init-module\` + +#### \`init.version\` + +* Default: "1.0.0" +* Type: SemVer string +* DEPRECATED: Use \`--init-version\` instead. + +Alias for \`--init-version\` + +#### \`only\` + +* Default: null +* Type: null, "prod", or "production" +* DEPRECATED: Use \`--omit=dev\` to omit dev dependencies from the install. + +When set to \`prod\` or \`production\`, this is an alias for \`--omit=dev\`. + +#### \`optional\` + +* Default: null +* Type: null or Boolean +* DEPRECATED: Use \`--omit=optional\` to exclude optional dependencies, or + \`--include=optional\` to include them. + +Default value does install optional deps unless otherwise omitted. + +Alias for --include=optional or --omit=optional + +#### \`production\` + +* Default: null +* Type: null or Boolean +* DEPRECATED: Use \`--omit=dev\` instead. + +Alias for \`--omit=dev\` + +#### \`shrinkwrap\` + +* Default: true +* Type: Boolean +* DEPRECATED: Use the --package-lock setting instead. + +Alias for --package-lock + +#### \`tmp\` + +* Default: The value returned by the Node.js \`os.tmpdir()\` method + +* Type: Path +* DEPRECATED: This setting is no longer used. npm stores temporary files in a + special location in the cache, and they are managed by + [\`cacache\`](http://npm.im/cacache). + +Historically, the location where temporary files were stored. No longer +relevant. +` + +exports[`test/lib/docs.js TAP config > all keys 1`] = ` +Array [ + "_auth", + "access", + "all", + "allow-same-version", + "also", + "audit", + "audit-level", + "auth-type", + "before", + "bin-links", + "browser", + "ca", + "cache", + "cache-max", + "cache-min", + "cafile", + "call", + "cert", + "ci-name", + "cidr", + "color", + "commit-hooks", + "depth", + "description", + "dev", + "diff", + "diff-ignore-all-space", + "diff-name-only", + "diff-no-prefix", + "diff-dst-prefix", + "diff-src-prefix", + "diff-text", + "diff-unified", + "dry-run", + "editor", + "engine-strict", + "fetch-retries", + "fetch-retry-factor", + "fetch-retry-maxtimeout", + "fetch-retry-mintimeout", + "fetch-timeout", + "force", + "foreground-scripts", + "format-package-lock", + "fund", + "git", + "git-tag-version", + "global", + "global-style", + "globalconfig", + "heading", + "https-proxy", + "if-present", + "ignore-scripts", + "include", + "include-staged", + "include-workspace-root", + "init-author-email", + "init-author-name", + "init-author-url", + "init-license", + "init-module", + "init-version", + "init.author.email", + "init.author.name", + "init.author.url", + "init.license", + "init.module", + "init.version", + "install-links", + "json", + "key", + "legacy-bundling", + "legacy-peer-deps", + "link", + "local-address", + "location", + "lockfile-version", + "loglevel", + "logs-dir", + "logs-max", + "long", + "maxsockets", + "message", + "node-options", + "node-version", + "noproxy", + "npm-version", + "offline", + "omit", + "omit-lockfile-registry-resolved", + "only", + "optional", + "otp", + "package", + "package-lock", + "package-lock-only", + "pack-destination", + "parseable", + "prefer-offline", + "prefer-online", + "prefix", + "preid", + "production", + "progress", + "proxy", + "read-only", + "rebuild-bundle", + "registry", + "replace-registry-host", + "save", + "save-bundle", + "save-dev", + "save-exact", + "save-optional", + "save-peer", + "save-prefix", + "save-prod", + "scope", + "script-shell", + "searchexclude", + "searchlimit", + "searchopts", + "searchstaleness", + "shell", + "shrinkwrap", + "sign-git-commit", + "sign-git-tag", + "strict-peer-deps", + "strict-ssl", + "tag", + "tag-version-prefix", + "timing", + "tmp", + "umask", + "unicode", + "update-notifier", + "usage", + "user-agent", + "userconfig", + "version", + "versions", + "viewer", + "which", + "workspace", + "workspaces", + "workspaces-update", + "yes", +] +` + +exports[`test/lib/docs.js TAP config > keys that are flattened 1`] = ` +Array [ + "_auth", + "access", + "all", + "allow-same-version", + "also", + "audit", + "audit-level", + "auth-type", + "before", + "bin-links", + "browser", + "ca", + "cache", + "cache-max", + "cache-min", + "cafile", + "call", + "cert", + "ci-name", + "cidr", + "color", + "commit-hooks", + "depth", + "description", + "dev", + "diff", + "diff-ignore-all-space", + "diff-name-only", + "diff-no-prefix", + "diff-dst-prefix", + "diff-src-prefix", + "diff-text", + "diff-unified", + "dry-run", + "editor", + "engine-strict", + "fetch-retries", + "fetch-retry-factor", + "fetch-retry-maxtimeout", + "fetch-retry-mintimeout", + "fetch-timeout", + "force", + "foreground-scripts", + "format-package-lock", + "fund", + "git", + "git-tag-version", + "global", + "global-style", + "globalconfig", + "heading", + "https-proxy", + "if-present", + "ignore-scripts", + "include", + "include-staged", + "include-workspace-root", + "install-links", + "json", + "key", + "legacy-bundling", + "legacy-peer-deps", + "local-address", + "location", + "lockfile-version", + "loglevel", + "maxsockets", + "message", + "node-version", + "noproxy", + "npm-version", + "offline", + "omit", + "omit-lockfile-registry-resolved", + "only", + "optional", + "otp", + "package", + "package-lock", + "package-lock-only", + "pack-destination", + "parseable", + "prefer-offline", + "prefer-online", + "preid", + "production", + "progress", + "proxy", + "read-only", + "rebuild-bundle", + "registry", + "replace-registry-host", + "save", + "save-bundle", + "save-dev", + "save-exact", + "save-optional", + "save-peer", + "save-prefix", + "save-prod", + "scope", + "script-shell", + "searchexclude", + "searchlimit", + "searchopts", + "searchstaleness", + "shell", + "shrinkwrap", + "sign-git-commit", + "sign-git-tag", + "strict-peer-deps", + "strict-ssl", + "tag", + "tag-version-prefix", + "umask", + "user-agent", + "workspace", + "workspaces", + "workspaces-update", +] +` + +exports[`test/lib/docs.js TAP config > keys that are not flattened 1`] = ` +Array [ + "init-author-email", + "init-author-name", + "init-author-url", + "init-license", + "init-module", + "init-version", + "init.author.email", + "init.author.name", + "init.author.url", + "init.license", + "init.module", + "init.version", + "link", + "logs-dir", + "logs-max", + "long", + "node-options", + "prefix", + "timing", + "tmp", + "unicode", + "update-notifier", + "usage", + "userconfig", + "version", + "versions", + "viewer", + "which", + "yes", +] +` + +exports[`test/lib/docs.js TAP shorthands > docs 1`] = ` +* \`-a\`: \`--all\` +* \`--enjoy-by\`: \`--before\` +* \`-c\`: \`--call\` +* \`--desc\`: \`--description\` +* \`-f\`: \`--force\` +* \`-g\`: \`--global\` +* \`--iwr\`: \`--include-workspace-root\` +* \`-L\`: \`--location\` +* \`-d\`: \`--loglevel info\` +* \`-s\`: \`--loglevel silent\` +* \`--silent\`: \`--loglevel silent\` +* \`--ddd\`: \`--loglevel silly\` +* \`--dd\`: \`--loglevel verbose\` +* \`--verbose\`: \`--loglevel verbose\` +* \`-q\`: \`--loglevel warn\` +* \`--quiet\`: \`--loglevel warn\` +* \`-l\`: \`--long\` +* \`-m\`: \`--message\` +* \`--local\`: \`--no-global\` +* \`-n\`: \`--no-yes\` +* \`--no\`: \`--no-yes\` +* \`-p\`: \`--parseable\` +* \`--porcelain\`: \`--parseable\` +* \`-C\`: \`--prefix\` +* \`--readonly\`: \`--read-only\` +* \`--reg\`: \`--registry\` +* \`-S\`: \`--save\` +* \`-B\`: \`--save-bundle\` +* \`-D\`: \`--save-dev\` +* \`-E\`: \`--save-exact\` +* \`-O\`: \`--save-optional\` +* \`-P\`: \`--save-prod\` +* \`-?\`: \`--usage\` +* \`-h\`: \`--usage\` +* \`-H\`: \`--usage\` +* \`--help\`: \`--usage\` +* \`-v\`: \`--version\` +* \`-w\`: \`--workspace\` +* \`--ws\`: \`--workspaces\` +* \`-y\`: \`--yes\` +` + +exports[`test/lib/docs.js TAP usage > access 1`] = ` +\`json\` +\`otp\` +\`registry\` + +\`\`\`bash +npm access list packages [|| [] +npm access list collaborators [ []] +npm access get status [] +npm access set status=public|private [] +npm access set mfa=none|publish|automation [] +npm access grant [] +npm access revoke [] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > adduser 1`] = ` +\`registry\` +\`scope\` +\`auth-type\` + +\`\`\`bash +npm adduser + +alias: add-user +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > audit 1`] = ` +\`audit-level\` +\`dry-run\` +\`force\` +\`json\` +\`package-lock-only\` +\`omit\` +\`foreground-scripts\` +\`ignore-scripts\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm audit [fix|signatures] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > bugs 1`] = ` +\`browser\` +\`registry\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` + +\`\`\`bash +npm bugs [ [ ...]] + +alias: issues +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > cache 1`] = ` +\`cache\` + +\`\`\`bash +npm cache add +npm cache clean [] +npm cache ls [@] +npm cache verify +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > ci 1`] = ` +\`save\` +\`save-exact\` +\`global\` +\`global-style\` +\`legacy-bundling\` +\`omit\` +\`strict-peer-deps\` +\`package-lock\` +\`foreground-scripts\` +\`ignore-scripts\` +\`audit\` +\`bin-links\` +\`fund\` +\`dry-run\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm ci + +aliases: clean-install, ic, install-clean, isntall-clean +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > completion 1`] = ` +NO PARAMS + +\`\`\`bash +npm completion +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > config 1`] = ` +\`json\` +\`global\` +\`editor\` +\`location\` +\`long\` + +\`\`\`bash +npm config set = [= ...] +npm config get [ [ ...]] +npm config delete [ ...] +npm config list [--json] +npm config edit + +alias: c +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > dedupe 1`] = ` +\`global-style\` +\`legacy-bundling\` +\`strict-peer-deps\` +\`package-lock\` +\`omit\` +\`ignore-scripts\` +\`audit\` +\`bin-links\` +\`fund\` +\`dry-run\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm dedupe + +alias: ddp +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > deprecate 1`] = ` +\`registry\` +\`otp\` + +\`\`\`bash +npm deprecate +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > diff 1`] = ` +\`diff\` +\`diff-name-only\` +\`diff-unified\` +\`diff-ignore-all-space\` +\`diff-no-prefix\` +\`diff-src-prefix\` +\`diff-dst-prefix\` +\`diff-text\` +\`global\` +\`tag\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` + +\`\`\`bash +npm diff [...] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > dist-tag 1`] = ` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` + +\`\`\`bash +npm dist-tag add [] +npm dist-tag rm +npm dist-tag ls [] + +alias: dist-tags +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > docs 1`] = ` +\`browser\` +\`registry\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` + +\`\`\`bash +npm docs [ [ ...]] + +alias: home +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > doctor 1`] = ` +\`registry\` + +\`\`\`bash +npm doctor +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > edit 1`] = ` +\`editor\` + +\`\`\`bash +npm edit [/...] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > exec 1`] = ` +\`package\` +\`call\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` + +\`\`\`bash +npm exec -- [@] [args...] +npm exec --package=[@] -- [args...] +npm exec -c ' [args...]' +npm exec --package=foo -c ' [args...]' + +alias: x +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > explain 1`] = ` +\`json\` +\`workspace\` + +\`\`\`bash +npm explain + +alias: why +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > explore 1`] = ` +\`shell\` + +\`\`\`bash +npm explore [ -- ] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > find-dupes 1`] = ` +\`global-style\` +\`legacy-bundling\` +\`strict-peer-deps\` +\`package-lock\` +\`omit\` +\`ignore-scripts\` +\`audit\` +\`bin-links\` +\`fund\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm find-dupes +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > fund 1`] = ` +\`json\` +\`browser\` +\`unicode\` +\`workspace\` +\`which\` + +\`\`\`bash +npm fund [] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > get 1`] = ` +NO PARAMS + +\`\`\`bash +npm get [ ...] (See \`npm config\`) +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > help 1`] = ` +\`viewer\` + +\`\`\`bash +npm help [] + +alias: hlep +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > help-search 1`] = ` +\`long\` + +\`\`\`bash +npm help-search +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > hook 1`] = ` +\`registry\` +\`otp\` + +\`\`\`bash +npm hook add [--type=] +npm hook ls [pkg] +npm hook rm +npm hook update +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > init 1`] = ` +\`yes\` +\`force\` +\`scope\` +\`workspace\` +\`workspaces\` +\`workspaces-update\` +\`include-workspace-root\` + +\`\`\`bash +npm init (same as \`npx ) +npm init <@scope> (same as \`npx <@scope>/create\`) + +aliases: create, innit +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > install 1`] = ` +\`save\` +\`save-exact\` +\`global\` +\`global-style\` +\`legacy-bundling\` +\`omit\` +\`strict-peer-deps\` +\`package-lock\` +\`foreground-scripts\` +\`ignore-scripts\` +\`audit\` +\`bin-links\` +\`fund\` +\`dry-run\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm install [ ...] + +aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > install-ci-test 1`] = ` +\`save\` +\`save-exact\` +\`global\` +\`global-style\` +\`legacy-bundling\` +\`omit\` +\`strict-peer-deps\` +\`package-lock\` +\`foreground-scripts\` +\`ignore-scripts\` +\`audit\` +\`bin-links\` +\`fund\` +\`dry-run\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm install-ci-test + +alias: cit +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > install-test 1`] = ` +\`save\` +\`save-exact\` +\`global\` +\`global-style\` +\`legacy-bundling\` +\`omit\` +\`strict-peer-deps\` +\`package-lock\` +\`foreground-scripts\` +\`ignore-scripts\` +\`audit\` +\`bin-links\` +\`fund\` +\`dry-run\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm install-test [ ...] + +alias: it +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > link 1`] = ` +\`save\` +\`save-exact\` +\`global\` +\`global-style\` +\`legacy-bundling\` +\`strict-peer-deps\` +\`package-lock\` +\`omit\` +\`ignore-scripts\` +\`audit\` +\`bin-links\` +\`fund\` +\`dry-run\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm link [] + +alias: ln +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > ll 1`] = ` +\`all\` +\`json\` +\`long\` +\`parseable\` +\`global\` +\`depth\` +\`omit\` +\`link\` +\`package-lock-only\` +\`unicode\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm ll [[<@scope>/] ...] + +alias: la +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > login 1`] = ` +\`registry\` +\`scope\` +\`auth-type\` + +\`\`\`bash +npm login +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > logout 1`] = ` +\`registry\` +\`scope\` + +\`\`\`bash +npm logout +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > ls 1`] = ` +\`all\` +\`json\` +\`long\` +\`parseable\` +\`global\` +\`depth\` +\`omit\` +\`link\` +\`package-lock-only\` +\`unicode\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm ls + +alias: list +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > npm 1`] = ` +NO PARAMS + +\`\`\`bash +npm +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > npx 1`] = ` +NO PARAMS + +\`\`\`bash +npx -- [@] [args...] +npx --package=[@] -- [args...] +npx -c ' [args...]' +npx --package=foo -c ' [args...]' +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > org 1`] = ` +\`registry\` +\`otp\` +\`json\` +\`parseable\` + +\`\`\`bash +npm org set orgname username [developer | admin | owner] +npm org rm orgname username +npm org ls orgname [] + +alias: ogr +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > outdated 1`] = ` +\`all\` +\`json\` +\`long\` +\`parseable\` +\`global\` +\`workspace\` + +\`\`\`bash +npm outdated [ ...] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > owner 1`] = ` +\`registry\` +\`otp\` +\`workspace\` +\`workspaces\` + +\`\`\`bash +npm owner add +npm owner rm +npm owner ls + +alias: author +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > pack 1`] = ` +\`dry-run\` +\`json\` +\`pack-destination\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` + +\`\`\`bash +npm pack +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > ping 1`] = ` +\`registry\` + +\`\`\`bash +npm ping +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > pkg 1`] = ` +\`force\` +\`json\` +\`workspace\` +\`workspaces\` + +\`\`\`bash +npm pkg set = [= ...] +npm pkg get [ [ ...]] +npm pkg delete [ ...] +npm pkg set [[].= ...] +npm pkg set [[].= ...] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > prefix 1`] = ` +\`global\` + +\`\`\`bash +npm prefix [-g] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > profile 1`] = ` +\`registry\` +\`json\` +\`parseable\` +\`otp\` + +\`\`\`bash +npm profile enable-2fa [auth-only|auth-and-writes] +npm profile disable-2fa +npm profile get [] +npm profile set +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > prune 1`] = ` +\`omit\` +\`dry-run\` +\`json\` +\`foreground-scripts\` +\`ignore-scripts\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm prune [[<@scope>/]...] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > publish 1`] = ` +\`tag\` +\`access\` +\`dry-run\` +\`otp\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` + +\`\`\`bash +npm publish +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > query 1`] = ` +\`global\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` + +\`\`\`bash +npm query +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > rebuild 1`] = ` +\`global\` +\`bin-links\` +\`foreground-scripts\` +\`ignore-scripts\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm rebuild [] ...] + +alias: rb +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > repo 1`] = ` +\`browser\` +\`registry\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` + +\`\`\`bash +npm repo [ [ ...]] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > restart 1`] = ` +\`ignore-scripts\` +\`script-shell\` + +\`\`\`bash +npm restart [-- ] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > root 1`] = ` +\`global\` + +\`\`\`bash +npm root +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > run-script 1`] = ` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`if-present\` +\`ignore-scripts\` +\`foreground-scripts\` +\`script-shell\` + +\`\`\`bash +npm run-script [-- ] + +aliases: run, rum, urn +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > search 1`] = ` +\`long\` +\`json\` +\`color\` +\`parseable\` +\`description\` +\`searchopts\` +\`searchexclude\` +\`registry\` +\`prefer-online\` +\`prefer-offline\` +\`offline\` + +\`\`\`bash +npm search [search terms ...] + +aliases: find, s, se +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > set 1`] = ` +NO PARAMS + +\`\`\`bash +npm set = [= ...] (See \`npm config\`) +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > shrinkwrap 1`] = ` +NO PARAMS + +\`\`\`bash +npm shrinkwrap +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > star 1`] = ` +\`registry\` +\`unicode\` +\`otp\` + +\`\`\`bash +npm star [...] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > stars 1`] = ` +\`registry\` + +\`\`\`bash +npm stars [] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > start 1`] = ` +\`ignore-scripts\` +\`script-shell\` + +\`\`\`bash +npm start [-- ] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > stop 1`] = ` +\`ignore-scripts\` +\`script-shell\` + +\`\`\`bash +npm stop [-- ] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > team 1`] = ` +\`registry\` +\`otp\` +\`parseable\` +\`json\` + +\`\`\`bash +npm team create [--otp ] +npm team destroy [--otp ] +npm team add [--otp ] +npm team rm [--otp ] +npm team ls | +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > test 1`] = ` +\`ignore-scripts\` +\`script-shell\` + +\`\`\`bash +npm test [-- ] + +aliases: tst, t +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > token 1`] = ` +\`read-only\` +\`cidr\` +\`registry\` +\`otp\` + +\`\`\`bash +npm token list +npm token revoke +npm token create [--read-only] [--cidr=list] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > uninstall 1`] = ` +\`save\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm uninstall [<@scope>/]... + +aliases: unlink, remove, rm, r, un +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > unpublish 1`] = ` +\`dry-run\` +\`force\` +\`workspace\` +\`workspaces\` + +\`\`\`bash +npm unpublish [] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > unstar 1`] = ` +\`registry\` +\`unicode\` +\`otp\` + +\`\`\`bash +npm unstar [...] +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > update 1`] = ` +\`save\` +\`global\` +\`global-style\` +\`legacy-bundling\` +\`omit\` +\`strict-peer-deps\` +\`package-lock\` +\`foreground-scripts\` +\`ignore-scripts\` +\`audit\` +\`bin-links\` +\`fund\` +\`dry-run\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` +\`install-links\` + +\`\`\`bash +npm update [...] + +aliases: up, upgrade, udpate +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > version 1`] = ` +\`allow-same-version\` +\`commit-hooks\` +\`git-tag-version\` +\`json\` +\`preid\` +\`sign-git-tag\` +\`workspace\` +\`workspaces\` +\`workspaces-update\` +\`include-workspace-root\` + +\`\`\`bash +npm version [ | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git] + +alias: verison +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > view 1`] = ` +\`json\` +\`workspace\` +\`workspaces\` +\`include-workspace-root\` + +\`\`\`bash +npm view [] [[.subfield]...] + +aliases: info, show, v +\`\`\` +` + +exports[`test/lib/docs.js TAP usage > whoami 1`] = ` +\`registry\` + +\`\`\`bash +npm whoami +\`\`\` ` diff --git a/tap-snapshots/test/lib/load-all-commands.js.test.cjs b/tap-snapshots/test/lib/load-all-commands.js.test.cjs deleted file mode 100644 index e3d3d02fc4395..0000000000000 --- a/tap-snapshots/test/lib/load-all-commands.js.test.cjs +++ /dev/null @@ -1,984 +0,0 @@ -/* IMPORTANT - * This snapshot file is auto-generated, but designed for humans. - * It should be checked into source control and tracked carefully. - * Re-generate by setting TAP_SNAPSHOT=1 and running tests. - * Make sure to inspect the output below. Do not ignore changes! - */ -'use strict' -exports[`test/lib/load-all-commands.js TAP load each command access > must match snapshot 1`] = ` -Set access level on published packages - -Usage: -npm access list packages [|| [] -npm access list collaborators [ []] -npm access get status [] -npm access set status=public|private [] -npm access set mfa=none|publish|automation [] -npm access grant [] -npm access revoke [] - -Options: -[--json] [--otp ] [--registry ] - -Run "npm help access" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command adduser > must match snapshot 1`] = ` -Add a registry user account - -Usage: -npm adduser - -Options: -[--registry ] [--scope <@scope>] [--auth-type ] - -alias: add-user - -Run "npm help adduser" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command audit > must match snapshot 1`] = ` -Run a security audit - -Usage: -npm audit [fix|signatures] - -Options: -[--audit-level ] [--dry-run] [-f|--force] -[--json] [--package-lock-only] -[--omit [--omit ...]] -[--foreground-scripts] [--ignore-scripts] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -Run "npm help audit" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command bugs > must match snapshot 1`] = ` -Report bugs for a package in a web browser - -Usage: -npm bugs [ [ ...]] - -Options: -[--no-browser|--browser ] [--registry ] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] - -alias: issues - -Run "npm help bugs" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command cache > must match snapshot 1`] = ` -Manipulates packages cache - -Usage: -npm cache add -npm cache clean [] -npm cache ls [@] -npm cache verify - -Options: -[--cache ] - -Run "npm help cache" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command ci > must match snapshot 1`] = ` -Clean install a project - -Usage: -npm ci - -Options: -[-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] -[-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling] -[--omit [--omit ...]] -[--strict-peer-deps] [--no-package-lock] [--foreground-scripts] -[--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -aliases: clean-install, ic, install-clean, isntall-clean - -Run "npm help ci" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command completion > must match snapshot 1`] = ` -Tab Completion for npm - -Usage: -npm completion - -Run "npm help completion" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command config > must match snapshot 1`] = ` -Manage the npm configuration files - -Usage: -npm config set = [= ...] -npm config get [ [ ...]] -npm config delete [ ...] -npm config list [--json] -npm config edit - -Options: -[--json] [-g|--global] [--editor ] [-L|--location ] -[-l|--long] - -alias: c - -Run "npm help config" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command dedupe > must match snapshot 1`] = ` -Reduce duplication in the package tree - -Usage: -npm dedupe - -Options: -[--global-style] [--legacy-bundling] [--strict-peer-deps] [--no-package-lock] -[--omit [--omit ...]] [--ignore-scripts] -[--no-audit] [--no-bin-links] [--no-fund] [--dry-run] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -alias: ddp - -Run "npm help dedupe" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command deprecate > must match snapshot 1`] = ` -Deprecate a version of a package - -Usage: -npm deprecate - -Options: -[--registry ] [--otp ] - -Run "npm help deprecate" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command diff > must match snapshot 1`] = ` -The registry diff command - -Usage: -npm diff [...] - -Options: -[--diff [--diff ...]] [--diff-name-only] -[--diff-unified ] [--diff-ignore-all-space] [--diff-no-prefix] -[--diff-src-prefix ] [--diff-dst-prefix ] [--diff-text] [-g|--global] -[--tag ] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] - -Run "npm help diff" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command dist-tag > must match snapshot 1`] = ` -Modify package distribution tags - -Usage: -npm dist-tag add [] -npm dist-tag rm -npm dist-tag ls [] - -Options: -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] - -alias: dist-tags - -Run "npm help dist-tag" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command docs > must match snapshot 1`] = ` -Open documentation for a package in a web browser - -Usage: -npm docs [ [ ...]] - -Options: -[--no-browser|--browser ] [--registry ] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] - -alias: home - -Run "npm help docs" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command doctor > must match snapshot 1`] = ` -Check your npm environment - -Usage: -npm doctor - -Options: -[--registry ] - -Run "npm help doctor" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command edit > must match snapshot 1`] = ` -Edit an installed package - -Usage: -npm edit [/...] - -Options: -[--editor ] - -Run "npm help edit" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command exec > must match snapshot 1`] = ` -Run a command from a local or remote npm package - -Usage: -npm exec -- [@] [args...] -npm exec --package=[@] -- [args...] -npm exec -c ' [args...]' -npm exec --package=foo -c ' [args...]' - -Options: -[--package [--package ...]] [-c|--call ] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] - -alias: x - -Run "npm help exec" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command explain > must match snapshot 1`] = ` -Explain installed packages - -Usage: -npm explain - -Options: -[--json] [-w|--workspace [-w|--workspace ...]] - -alias: why - -Run "npm help explain" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command explore > must match snapshot 1`] = ` -Browse an installed package - -Usage: -npm explore [ -- ] - -Options: -[--shell ] - -Run "npm help explore" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command find-dupes > must match snapshot 1`] = ` -Find duplication in the package tree - -Usage: -npm find-dupes - -Options: -[--global-style] [--legacy-bundling] [--strict-peer-deps] [--no-package-lock] -[--omit [--omit ...]] [--ignore-scripts] -[--no-audit] [--no-bin-links] [--no-fund] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -Run "npm help find-dupes" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command fund > must match snapshot 1`] = ` -Retrieve funding information - -Usage: -npm fund [] - -Options: -[--json] [--no-browser|--browser ] [--unicode] -[-w|--workspace [-w|--workspace ...]] -[--which ] - -Run "npm help fund" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command get > must match snapshot 1`] = ` -Get a value from the npm configuration - -Usage: -npm get [ ...] (See \`npm config\`) - -Run "npm help get" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command help > must match snapshot 1`] = ` -Get help on npm - -Usage: -npm help [] - -Options: -[--viewer ] - -alias: hlep - -Run "npm help help" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command help-search > must match snapshot 1`] = ` -Search npm help documentation - -Usage: -npm help-search - -Options: -[-l|--long] - -Run "npm help help-search" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command hook > must match snapshot 1`] = ` -Manage registry hooks - -Usage: -npm hook add [--type=] -npm hook ls [pkg] -npm hook rm -npm hook update - -Options: -[--registry ] [--otp ] - -Run "npm help hook" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command init > must match snapshot 1`] = ` -Create a package.json file - -Usage: -npm init (same as \`npx ) -npm init <@scope> (same as \`npx <@scope>/create\`) - -Options: -[-y|--yes] [-f|--force] [--scope <@scope>] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--no-workspaces-update] [--include-workspace-root] - -aliases: create, innit - -Run "npm help init" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command install > must match snapshot 1`] = ` -Install a package - -Usage: -npm install [ ...] - -Options: -[-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] -[-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling] -[--omit [--omit ...]] -[--strict-peer-deps] [--no-package-lock] [--foreground-scripts] -[--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall - -Run "npm help install" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command install-ci-test > must match snapshot 1`] = ` -Install a project with a clean slate and run tests - -Usage: -npm install-ci-test - -Options: -[-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] -[-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling] -[--omit [--omit ...]] -[--strict-peer-deps] [--no-package-lock] [--foreground-scripts] -[--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -alias: cit - -Run "npm help install-ci-test" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command install-test > must match snapshot 1`] = ` -Install package(s) and run tests - -Usage: -npm install-test [ ...] - -Options: -[-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] -[-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling] -[--omit [--omit ...]] -[--strict-peer-deps] [--no-package-lock] [--foreground-scripts] -[--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -alias: it - -Run "npm help install-test" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command link > must match snapshot 1`] = ` -Symlink a package folder - -Usage: -npm link [] - -Options: -[-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] -[-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling] -[--strict-peer-deps] [--no-package-lock] -[--omit [--omit ...]] [--ignore-scripts] -[--no-audit] [--no-bin-links] [--no-fund] [--dry-run] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -alias: ln - -Run "npm help link" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command ll > must match snapshot 1`] = ` -List installed packages - -Usage: -npm ll [[<@scope>/] ...] - -Options: -[-a|--all] [--json] [-l|--long] [-p|--parseable] [-g|--global] [--depth ] -[--omit [--omit ...]] [--link] -[--package-lock-only] [--unicode] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -alias: la - -Run "npm help ll" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command login > must match snapshot 1`] = ` -Login to a registry user account - -Usage: -npm login - -Options: -[--registry ] [--scope <@scope>] [--auth-type ] - -Run "npm help login" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command logout > must match snapshot 1`] = ` -Log out of the registry - -Usage: -npm logout - -Options: -[--registry ] [--scope <@scope>] - -Run "npm help logout" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command ls > must match snapshot 1`] = ` -List installed packages - -Usage: -npm ls - -Options: -[-a|--all] [--json] [-l|--long] [-p|--parseable] [-g|--global] [--depth ] -[--omit [--omit ...]] [--link] -[--package-lock-only] [--unicode] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -alias: list - -Run "npm help ls" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command org > must match snapshot 1`] = ` -Manage orgs - -Usage: -npm org set orgname username [developer | admin | owner] -npm org rm orgname username -npm org ls orgname [] - -Options: -[--registry ] [--otp ] [--json] [-p|--parseable] - -alias: ogr - -Run "npm help org" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command outdated > must match snapshot 1`] = ` -Check for outdated packages - -Usage: -npm outdated [ ...] - -Options: -[-a|--all] [--json] [-l|--long] [-p|--parseable] [-g|--global] -[-w|--workspace [-w|--workspace ...]] - -Run "npm help outdated" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command owner > must match snapshot 1`] = ` -Manage package owners - -Usage: -npm owner add -npm owner rm -npm owner ls - -Options: -[--registry ] [--otp ] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] - -alias: author - -Run "npm help owner" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command pack > must match snapshot 1`] = ` -Create a tarball from a package - -Usage: -npm pack - -Options: -[--dry-run] [--json] [--pack-destination ] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] - -Run "npm help pack" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command ping > must match snapshot 1`] = ` -Ping npm registry - -Usage: -npm ping - -Options: -[--registry ] - -Run "npm help ping" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command pkg > must match snapshot 1`] = ` -Manages your package.json - -Usage: -npm pkg set = [= ...] -npm pkg get [ [ ...]] -npm pkg delete [ ...] -npm pkg set [[].= ...] -npm pkg set [[].= ...] - -Options: -[-f|--force] [--json] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] - -Run "npm help pkg" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command prefix > must match snapshot 1`] = ` -Display prefix - -Usage: -npm prefix [-g] - -Options: -[-g|--global] - -Run "npm help prefix" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command profile > must match snapshot 1`] = ` -Change settings on your registry profile - -Usage: -npm profile enable-2fa [auth-only|auth-and-writes] -npm profile disable-2fa -npm profile get [] -npm profile set - -Options: -[--registry ] [--json] [-p|--parseable] [--otp ] - -Run "npm help profile" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command prune > must match snapshot 1`] = ` -Remove extraneous packages - -Usage: -npm prune [[<@scope>/]...] - -Options: -[--omit [--omit ...]] [--dry-run] -[--json] [--foreground-scripts] [--ignore-scripts] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -Run "npm help prune" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command publish > must match snapshot 1`] = ` -Publish a package - -Usage: -npm publish - -Options: -[--tag ] [--access ] [--dry-run] [--otp ] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] - -Run "npm help publish" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command query > must match snapshot 1`] = ` -Retrieve a filtered list of packages - -Usage: -npm query - -Options: -[-g|--global] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] - -Run "npm help query" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command rebuild > must match snapshot 1`] = ` -Rebuild a package - -Usage: -npm rebuild [] ...] - -Options: -[-g|--global] [--no-bin-links] [--foreground-scripts] [--ignore-scripts] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -alias: rb - -Run "npm help rebuild" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command repo > must match snapshot 1`] = ` -Open package repository page in the browser - -Usage: -npm repo [ [ ...]] - -Options: -[--no-browser|--browser ] [--registry ] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] - -Run "npm help repo" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command restart > must match snapshot 1`] = ` -Restart a package - -Usage: -npm restart [-- ] - -Options: -[--ignore-scripts] [--script-shell ] - -Run "npm help restart" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command root > must match snapshot 1`] = ` -Display npm root - -Usage: -npm root - -Options: -[-g|--global] - -Run "npm help root" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command run-script > must match snapshot 1`] = ` -Run arbitrary package scripts - -Usage: -npm run-script [-- ] - -Options: -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--if-present] [--ignore-scripts] -[--foreground-scripts] [--script-shell ] - -aliases: run, rum, urn - -Run "npm help run-script" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command search > must match snapshot 1`] = ` -Search for packages - -Usage: -npm search [search terms ...] - -Options: -[-l|--long] [--json] [--color|--no-color|--color always] [-p|--parseable] -[--no-description] [--searchopts ] [--searchexclude ] -[--registry ] [--prefer-online] [--prefer-offline] [--offline] - -aliases: find, s, se - -Run "npm help search" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command set > must match snapshot 1`] = ` -Set a value in the npm configuration - -Usage: -npm set = [= ...] (See \`npm config\`) - -Run "npm help set" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command shrinkwrap > must match snapshot 1`] = ` -Lock down dependency versions for publication - -Usage: -npm shrinkwrap - -Run "npm help shrinkwrap" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command star > must match snapshot 1`] = ` -Mark your favorite packages - -Usage: -npm star [...] - -Options: -[--registry ] [--unicode] [--otp ] - -Run "npm help star" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command stars > must match snapshot 1`] = ` -View packages marked as favorites - -Usage: -npm stars [] - -Options: -[--registry ] - -Run "npm help stars" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command start > must match snapshot 1`] = ` -Start a package - -Usage: -npm start [-- ] - -Options: -[--ignore-scripts] [--script-shell ] - -Run "npm help start" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command stop > must match snapshot 1`] = ` -Stop a package - -Usage: -npm stop [-- ] - -Options: -[--ignore-scripts] [--script-shell ] - -Run "npm help stop" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command team > must match snapshot 1`] = ` -Manage organization teams and team memberships - -Usage: -npm team create [--otp ] -npm team destroy [--otp ] -npm team add [--otp ] -npm team rm [--otp ] -npm team ls | - -Options: -[--registry ] [--otp ] [-p|--parseable] [--json] - -Run "npm help team" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command test > must match snapshot 1`] = ` -Test a package - -Usage: -npm test [-- ] - -Options: -[--ignore-scripts] [--script-shell ] - -aliases: tst, t - -Run "npm help test" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command token > must match snapshot 1`] = ` -Manage your authentication tokens - -Usage: -npm token list -npm token revoke -npm token create [--read-only] [--cidr=list] - -Options: -[--read-only] [--cidr [--cidr ...]] [--registry ] -[--otp ] - -Run "npm help token" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command uninstall > must match snapshot 1`] = ` -Remove a package - -Usage: -npm uninstall [<@scope>/]... - -Options: -[-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -aliases: unlink, remove, rm, r, un - -Run "npm help uninstall" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command unpublish > must match snapshot 1`] = ` -Remove a package from the registry - -Usage: -npm unpublish [] - -Options: -[--dry-run] [-f|--force] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] - -Run "npm help unpublish" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command unstar > must match snapshot 1`] = ` -Remove an item from your favorite packages - -Usage: -npm unstar [...] - -Options: -[--registry ] [--unicode] [--otp ] - -Run "npm help unstar" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command update > must match snapshot 1`] = ` -Update packages - -Usage: -npm update [...] - -Options: -[-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] -[-g|--global] [--global-style] [--legacy-bundling] -[--omit [--omit ...]] -[--strict-peer-deps] [--no-package-lock] [--foreground-scripts] -[--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] [--no-install-links] - -aliases: up, upgrade, udpate - -Run "npm help update" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command version > must match snapshot 1`] = ` -Bump a package version - -Usage: -npm version [ | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git] - -Options: -[--allow-same-version] [--no-commit-hooks] [--no-git-tag-version] [--json] -[--preid prerelease-id] [--sign-git-tag] -[-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--no-workspaces-update] [--include-workspace-root] - -alias: verison - -Run "npm help version" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command view > must match snapshot 1`] = ` -View registry info - -Usage: -npm view [] [[.subfield]...] - -Options: -[--json] [-w|--workspace [-w|--workspace ...]] -[-ws|--workspaces] [--include-workspace-root] - -aliases: info, show, v - -Run "npm help view" for more info -` - -exports[`test/lib/load-all-commands.js TAP load each command whoami > must match snapshot 1`] = ` -Display npm username - -Usage: -npm whoami - -Options: -[--registry ] - -Run "npm help whoami" for more info -` diff --git a/tap-snapshots/test/lib/npm.js.test.cjs b/tap-snapshots/test/lib/npm.js.test.cjs index 35a5ee4da3e64..f3fa607f6d4e4 100644 --- a/tap-snapshots/test/lib/npm.js.test.cjs +++ b/tap-snapshots/test/lib/npm.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/lib/npm.js TAP usage basic usage > must match snapshot 1`] = ` +exports[`test/lib/npm.js TAP basic usage > must match snapshot 1`] = ` npm Usage: @@ -21,988 +21,10 @@ npm help npm more involved overview All commands: - access, adduser, audit, bugs, cache, ci, completion, - config, dedupe, deprecate, diff, dist-tag, docs, doctor, - edit, exec, explain, explore, find-dupes, fund, get, help, - hook, init, install, install-ci-test, install-test, link, - ll, login, logout, ls, org, outdated, owner, pack, ping, - pkg, prefix, profile, prune, publish, query, rebuild, repo, - restart, root, run-script, search, set, shrinkwrap, star, - stars, start, stop, team, test, token, uninstall, unpublish, - unstar, update, version, view, whoami + Specify configs in the ini-formatted file: - /some/config/file/.npmrc -or on the command line via: npm --key=value - -More configuration info: npm help config -Configuration fields: npm help 7 config - -npm@{VERSION} {BASEDIR} -` - -exports[`test/lib/npm.js TAP usage set process.stdout.columns columns=0 > must match snapshot 1`] = ` -npm - -Usage: - -npm install install all the dependencies in your project -npm install add the dependency to your project -npm test run this project's tests -npm run run the script named -npm -h quick help on -npm -l display usage info for all commands -npm help search for help on -npm help npm more involved overview - -All commands: - - access, adduser, audit, bugs, cache, ci, completion, - config, dedupe, deprecate, diff, dist-tag, docs, doctor, - edit, exec, explain, explore, find-dupes, fund, get, help, - hook, init, install, install-ci-test, install-test, link, - ll, login, logout, ls, org, outdated, owner, pack, ping, - pkg, prefix, profile, prune, publish, query, rebuild, repo, - restart, root, run-script, search, set, shrinkwrap, star, - stars, start, stop, team, test, token, uninstall, unpublish, - unstar, update, version, view, whoami - -Specify configs in the ini-formatted file: - /some/config/file/.npmrc -or on the command line via: npm --key=value - -More configuration info: npm help config -Configuration fields: npm help 7 config - -npm@{VERSION} {BASEDIR} -` - -exports[`test/lib/npm.js TAP usage set process.stdout.columns columns=90 > must match snapshot 1`] = ` -npm - -Usage: - -npm install install all the dependencies in your project -npm install add the dependency to your project -npm test run this project's tests -npm run run the script named -npm -h quick help on -npm -l display usage info for all commands -npm help search for help on -npm help npm more involved overview - -All commands: - - access, adduser, audit, bugs, cache, ci, completion, - config, dedupe, deprecate, diff, dist-tag, docs, doctor, - edit, exec, explain, explore, find-dupes, fund, get, help, - hook, init, install, install-ci-test, install-test, link, - ll, login, logout, ls, org, outdated, owner, pack, ping, - pkg, prefix, profile, prune, publish, query, rebuild, repo, - restart, root, run-script, search, set, shrinkwrap, star, - stars, start, stop, team, test, token, uninstall, unpublish, - unstar, update, version, view, whoami - -Specify configs in the ini-formatted file: - /some/config/file/.npmrc -or on the command line via: npm --key=value - -More configuration info: npm help config -Configuration fields: npm help 7 config - -npm@{VERSION} {BASEDIR} -` - -exports[`test/lib/npm.js TAP usage with browser > must match snapshot 1`] = ` -npm - -Usage: - -npm install install all the dependencies in your project -npm install add the dependency to your project -npm test run this project's tests -npm run run the script named -npm -h quick help on -npm -l display usage info for all commands -npm help search for help on (in a browser) -npm help npm more involved overview (in a browser) - -All commands: - - access, adduser, audit, bugs, cache, ci, completion, - config, dedupe, deprecate, diff, dist-tag, docs, doctor, - edit, exec, explain, explore, find-dupes, fund, get, help, - hook, init, install, install-ci-test, install-test, link, - ll, login, logout, ls, org, outdated, owner, pack, ping, - pkg, prefix, profile, prune, publish, query, rebuild, repo, - restart, root, run-script, search, set, shrinkwrap, star, - stars, start, stop, team, test, token, uninstall, unpublish, - unstar, update, version, view, whoami - -Specify configs in the ini-formatted file: - /some/config/file/.npmrc -or on the command line via: npm --key=value - -More configuration info: npm help config -Configuration fields: npm help 7 config - -npm@{VERSION} {BASEDIR} -` - -exports[`test/lib/npm.js TAP usage with long > must match snapshot 1`] = ` -npm - -Usage: - -npm install install all the dependencies in your project -npm install add the dependency to your project -npm test run this project's tests -npm run run the script named -npm -h quick help on -npm -l display usage info for all commands -npm help search for help on -npm help npm more involved overview - -All commands: - - access Set access level on published packages - - Usage: - npm access list packages [|| [] - npm access list collaborators [ []] - npm access get status [] - npm access set status=public|private [] - npm access set mfa=none|publish|automation [] - npm access grant [] - npm access revoke [] - - Options: - [--json] [--otp ] [--registry ] - - Run "npm help access" for more info - - adduser Add a registry user account - - Usage: - npm adduser - - Options: - [--registry ] [--scope <@scope>] [--auth-type ] - - alias: add-user - - Run "npm help adduser" for more info - - audit Run a security audit - - Usage: - npm audit [fix|signatures] - - Options: - [--audit-level ] [--dry-run] [-f|--force] - [--json] [--package-lock-only] - [--omit [--omit ...]] - [--foreground-scripts] [--ignore-scripts] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - Run "npm help audit" for more info - - bugs Report bugs for a package in a web browser - - Usage: - npm bugs [ [ ...]] - - Options: - [--no-browser|--browser ] [--registry ] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] - - alias: issues - - Run "npm help bugs" for more info - - cache Manipulates packages cache - - Usage: - npm cache add - npm cache clean [] - npm cache ls [@] - npm cache verify - - Options: - [--cache ] - - Run "npm help cache" for more info - - ci Clean install a project - - Usage: - npm ci - - Options: - [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] - [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling] - [--omit [--omit ...]] - [--strict-peer-deps] [--no-package-lock] [--foreground-scripts] - [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - aliases: clean-install, ic, install-clean, isntall-clean - - Run "npm help ci" for more info - - completion Tab Completion for npm - - Usage: - npm completion - - Run "npm help completion" for more info - - config Manage the npm configuration files - - Usage: - npm config set = [= ...] - npm config get [ [ ...]] - npm config delete [ ...] - npm config list [--json] - npm config edit - - Options: - [--json] [-g|--global] [--editor ] [-L|--location ] - [-l|--long] - - alias: c - - Run "npm help config" for more info - - dedupe Reduce duplication in the package tree - - Usage: - npm dedupe - - Options: - [--global-style] [--legacy-bundling] [--strict-peer-deps] [--no-package-lock] - [--omit [--omit ...]] [--ignore-scripts] - [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - alias: ddp - - Run "npm help dedupe" for more info - - deprecate Deprecate a version of a package - - Usage: - npm deprecate - - Options: - [--registry ] [--otp ] - - Run "npm help deprecate" for more info - - diff The registry diff command - - Usage: - npm diff [...] - - Options: - [--diff [--diff ...]] [--diff-name-only] - [--diff-unified ] [--diff-ignore-all-space] [--diff-no-prefix] - [--diff-src-prefix ] [--diff-dst-prefix ] [--diff-text] [-g|--global] - [--tag ] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] - - Run "npm help diff" for more info - - dist-tag Modify package distribution tags - - Usage: - npm dist-tag add [] - npm dist-tag rm - npm dist-tag ls [] - - Options: - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] - - alias: dist-tags - - Run "npm help dist-tag" for more info - - docs Open documentation for a package in a web browser - - Usage: - npm docs [ [ ...]] - - Options: - [--no-browser|--browser ] [--registry ] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] - - alias: home - - Run "npm help docs" for more info - - doctor Check your npm environment - - Usage: - npm doctor - - Options: - [--registry ] - - Run "npm help doctor" for more info - - edit Edit an installed package - - Usage: - npm edit [/...] - - Options: - [--editor ] - - Run "npm help edit" for more info - - exec Run a command from a local or remote npm package - - Usage: - npm exec -- [@] [args...] - npm exec --package=[@] -- [args...] - npm exec -c ' [args...]' - npm exec --package=foo -c ' [args...]' - - Options: - [--package [--package ...]] [-c|--call ] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] - - alias: x - - Run "npm help exec" for more info - - explain Explain installed packages - - Usage: - npm explain - - Options: - [--json] [-w|--workspace [-w|--workspace ...]] - - alias: why - - Run "npm help explain" for more info - - explore Browse an installed package - - Usage: - npm explore [ -- ] - - Options: - [--shell ] - - Run "npm help explore" for more info - - find-dupes Find duplication in the package tree - - Usage: - npm find-dupes - - Options: - [--global-style] [--legacy-bundling] [--strict-peer-deps] [--no-package-lock] - [--omit [--omit ...]] [--ignore-scripts] - [--no-audit] [--no-bin-links] [--no-fund] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - Run "npm help find-dupes" for more info - - fund Retrieve funding information - - Usage: - npm fund [] - - Options: - [--json] [--no-browser|--browser ] [--unicode] - [-w|--workspace [-w|--workspace ...]] - [--which ] - - Run "npm help fund" for more info - - get Get a value from the npm configuration - - Usage: - npm get [ ...] (See \`npm config\`) - - Run "npm help get" for more info - - help Get help on npm - - Usage: - npm help [] - - Options: - [--viewer ] - - alias: hlep - - Run "npm help help" for more info - - hook Manage registry hooks - - Usage: - npm hook add [--type=] - npm hook ls [pkg] - npm hook rm - npm hook update - - Options: - [--registry ] [--otp ] - - Run "npm help hook" for more info - - init Create a package.json file - - Usage: - npm init (same as \`npx ) - npm init <@scope> (same as \`npx <@scope>/create\`) - - Options: - [-y|--yes] [-f|--force] [--scope <@scope>] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--no-workspaces-update] [--include-workspace-root] - - aliases: create, innit - - Run "npm help init" for more info - - install Install a package - - Usage: - npm install [ ...] - - Options: - [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] - [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling] - [--omit [--omit ...]] - [--strict-peer-deps] [--no-package-lock] [--foreground-scripts] - [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall - - Run "npm help install" for more info - - install-ci-test Install a project with a clean slate and run tests - - Usage: - npm install-ci-test - - Options: - [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] - [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling] - [--omit [--omit ...]] - [--strict-peer-deps] [--no-package-lock] [--foreground-scripts] - [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - alias: cit - - Run "npm help install-ci-test" for more info - - install-test Install package(s) and run tests - - Usage: - npm install-test [ ...] - - Options: - [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] - [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling] - [--omit [--omit ...]] - [--strict-peer-deps] [--no-package-lock] [--foreground-scripts] - [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - alias: it - - Run "npm help install-test" for more info - - link Symlink a package folder - - Usage: - npm link [] - - Options: - [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] - [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling] - [--strict-peer-deps] [--no-package-lock] - [--omit [--omit ...]] [--ignore-scripts] - [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - alias: ln - - Run "npm help link" for more info - - ll List installed packages - - Usage: - npm ll [[<@scope>/] ...] - - Options: - [-a|--all] [--json] [-l|--long] [-p|--parseable] [-g|--global] [--depth ] - [--omit [--omit ...]] [--link] - [--package-lock-only] [--unicode] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - alias: la - - Run "npm help ll" for more info - - login Login to a registry user account - - Usage: - npm login - - Options: - [--registry ] [--scope <@scope>] [--auth-type ] - - Run "npm help login" for more info - - logout Log out of the registry - - Usage: - npm logout - - Options: - [--registry ] [--scope <@scope>] - - Run "npm help logout" for more info - - ls List installed packages - - Usage: - npm ls - - Options: - [-a|--all] [--json] [-l|--long] [-p|--parseable] [-g|--global] [--depth ] - [--omit [--omit ...]] [--link] - [--package-lock-only] [--unicode] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - alias: list - - Run "npm help ls" for more info - - org Manage orgs - - Usage: - npm org set orgname username [developer | admin | owner] - npm org rm orgname username - npm org ls orgname [] - - Options: - [--registry ] [--otp ] [--json] [-p|--parseable] - - alias: ogr - - Run "npm help org" for more info - - outdated Check for outdated packages - - Usage: - npm outdated [ ...] - - Options: - [-a|--all] [--json] [-l|--long] [-p|--parseable] [-g|--global] - [-w|--workspace [-w|--workspace ...]] - - Run "npm help outdated" for more info - - owner Manage package owners - - Usage: - npm owner add - npm owner rm - npm owner ls - - Options: - [--registry ] [--otp ] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] - - alias: author - - Run "npm help owner" for more info - - pack Create a tarball from a package - - Usage: - npm pack - - Options: - [--dry-run] [--json] [--pack-destination ] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] - - Run "npm help pack" for more info - - ping Ping npm registry - - Usage: - npm ping - - Options: - [--registry ] - - Run "npm help ping" for more info - - pkg Manages your package.json - - Usage: - npm pkg set = [= ...] - npm pkg get [ [ ...]] - npm pkg delete [ ...] - npm pkg set [[].= ...] - npm pkg set [[].= ...] - - Options: - [-f|--force] [--json] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] - - Run "npm help pkg" for more info - - prefix Display prefix - - Usage: - npm prefix [-g] - - Options: - [-g|--global] - - Run "npm help prefix" for more info - - profile Change settings on your registry profile - - Usage: - npm profile enable-2fa [auth-only|auth-and-writes] - npm profile disable-2fa - npm profile get [] - npm profile set - - Options: - [--registry ] [--json] [-p|--parseable] [--otp ] - - Run "npm help profile" for more info - - prune Remove extraneous packages - - Usage: - npm prune [[<@scope>/]...] - - Options: - [--omit [--omit ...]] [--dry-run] - [--json] [--foreground-scripts] [--ignore-scripts] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - Run "npm help prune" for more info - - publish Publish a package - - Usage: - npm publish - - Options: - [--tag ] [--access ] [--dry-run] [--otp ] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] - - Run "npm help publish" for more info - - query Retrieve a filtered list of packages - - Usage: - npm query - - Options: - [-g|--global] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] - - Run "npm help query" for more info - - rebuild Rebuild a package - - Usage: - npm rebuild [] ...] - - Options: - [-g|--global] [--no-bin-links] [--foreground-scripts] [--ignore-scripts] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - alias: rb - - Run "npm help rebuild" for more info - - repo Open package repository page in the browser - - Usage: - npm repo [ [ ...]] - - Options: - [--no-browser|--browser ] [--registry ] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] - - Run "npm help repo" for more info - - restart Restart a package - - Usage: - npm restart [-- ] - - Options: - [--ignore-scripts] [--script-shell ] - - Run "npm help restart" for more info - - root Display npm root - - Usage: - npm root - - Options: - [-g|--global] - - Run "npm help root" for more info - - run-script Run arbitrary package scripts - - Usage: - npm run-script [-- ] - - Options: - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--if-present] [--ignore-scripts] - [--foreground-scripts] [--script-shell ] - - aliases: run, rum, urn - - Run "npm help run-script" for more info - - search Search for packages - - Usage: - npm search [search terms ...] - - Options: - [-l|--long] [--json] [--color|--no-color|--color always] [-p|--parseable] - [--no-description] [--searchopts ] [--searchexclude ] - [--registry ] [--prefer-online] [--prefer-offline] [--offline] - - aliases: find, s, se - - Run "npm help search" for more info - - set Set a value in the npm configuration - - Usage: - npm set = [= ...] (See \`npm config\`) - - Run "npm help set" for more info - - shrinkwrap Lock down dependency versions for publication - - Usage: - npm shrinkwrap - - Run "npm help shrinkwrap" for more info - - star Mark your favorite packages - - Usage: - npm star [...] - - Options: - [--registry ] [--unicode] [--otp ] - - Run "npm help star" for more info - - stars View packages marked as favorites - - Usage: - npm stars [] - - Options: - [--registry ] - - Run "npm help stars" for more info - - start Start a package - - Usage: - npm start [-- ] - - Options: - [--ignore-scripts] [--script-shell ] - - Run "npm help start" for more info - - stop Stop a package - - Usage: - npm stop [-- ] - - Options: - [--ignore-scripts] [--script-shell ] - - Run "npm help stop" for more info - - team Manage organization teams and team memberships - - Usage: - npm team create [--otp ] - npm team destroy [--otp ] - npm team add [--otp ] - npm team rm [--otp ] - npm team ls | - - Options: - [--registry ] [--otp ] [-p|--parseable] [--json] - - Run "npm help team" for more info - - test Test a package - - Usage: - npm test [-- ] - - Options: - [--ignore-scripts] [--script-shell ] - - aliases: tst, t - - Run "npm help test" for more info - - token Manage your authentication tokens - - Usage: - npm token list - npm token revoke - npm token create [--read-only] [--cidr=list] - - Options: - [--read-only] [--cidr [--cidr ...]] [--registry ] - [--otp ] - - Run "npm help token" for more info - - uninstall Remove a package - - Usage: - npm uninstall [<@scope>/]... - - Options: - [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - aliases: unlink, remove, rm, r, un - - Run "npm help uninstall" for more info - - unpublish Remove a package from the registry - - Usage: - npm unpublish [] - - Options: - [--dry-run] [-f|--force] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] - - Run "npm help unpublish" for more info - - unstar Remove an item from your favorite packages - - Usage: - npm unstar [...] - - Options: - [--registry ] [--unicode] [--otp ] - - Run "npm help unstar" for more info - - update Update packages - - Usage: - npm update [...] - - Options: - [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle] - [-g|--global] [--global-style] [--legacy-bundling] - [--omit [--omit ...]] - [--strict-peer-deps] [--no-package-lock] [--foreground-scripts] - [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] [--no-install-links] - - aliases: up, upgrade, udpate - - Run "npm help update" for more info - - version Bump a package version - - Usage: - npm version [ | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git] - - Options: - [--allow-same-version] [--no-commit-hooks] [--no-git-tag-version] [--json] - [--preid prerelease-id] [--sign-git-tag] - [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--no-workspaces-update] [--include-workspace-root] - - alias: verison - - Run "npm help version" for more info - - view View registry info - - Usage: - npm view [] [[.subfield]...] - - Options: - [--json] [-w|--workspace [-w|--workspace ...]] - [-ws|--workspaces] [--include-workspace-root] - - aliases: info, show, v - - Run "npm help view" for more info - - whoami Display npm username - - Usage: - npm whoami - - Options: - [--registry ] - - Run "npm help whoami" for more info - -Specify configs in the ini-formatted file: - /some/config/file/.npmrc + {BASEDIR}/test/lib/tap-testdir-npm-basic-usage/home/.npmrc or on the command line via: npm --key=value More configuration info: npm help config diff --git a/tap-snapshots/test/lib/utils/cmd-list.js.test.cjs b/tap-snapshots/test/lib/utils/cmd-list.js.test.cjs deleted file mode 100644 index 574b0855bc456..0000000000000 --- a/tap-snapshots/test/lib/utils/cmd-list.js.test.cjs +++ /dev/null @@ -1,479 +0,0 @@ -/* IMPORTANT - * This snapshot file is auto-generated, but designed for humans. - * It should be checked into source control and tracked carefully. - * Re-generate by setting TAP_SNAPSHOT=1 and running tests. - * Make sure to inspect the output below. Do not ignore changes! - */ -'use strict' -exports[`test/lib/utils/cmd-list.js TAP > must match snapshot 1`] = ` -Object { - "abbrevs": Object { - "ac": "access", - "acc": "access", - "acce": "access", - "acces": "access", - "access": "access", - "add": "add", - "add-": "add-user", - "add-u": "add-user", - "add-us": "add-user", - "add-use": "add-user", - "add-user": "add-user", - "addu": "adduser", - "addus": "adduser", - "adduse": "adduser", - "adduser": "adduser", - "aud": "audit", - "audi": "audit", - "audit": "audit", - "aut": "author", - "auth": "author", - "autho": "author", - "author": "author", - "b": "bugs", - "bu": "bugs", - "bug": "bugs", - "bugs": "bugs", - "c": "c", - "ca": "cache", - "cac": "cache", - "cach": "cache", - "cache": "cache", - "ci": "ci", - "cit": "cit", - "clean-install": "clean-install", - "clean-install-": "clean-install-test", - "clean-install-t": "clean-install-test", - "clean-install-te": "clean-install-test", - "clean-install-tes": "clean-install-test", - "clean-install-test": "clean-install-test", - "com": "completion", - "comp": "completion", - "compl": "completion", - "comple": "completion", - "complet": "completion", - "completi": "completion", - "completio": "completion", - "completion": "completion", - "con": "config", - "conf": "config", - "confi": "config", - "config": "config", - "cr": "create", - "cre": "create", - "crea": "create", - "creat": "create", - "create": "create", - "dd": "ddp", - "ddp": "ddp", - "ded": "dedupe", - "dedu": "dedupe", - "dedup": "dedupe", - "dedupe": "dedupe", - "dep": "deprecate", - "depr": "deprecate", - "depre": "deprecate", - "deprec": "deprecate", - "depreca": "deprecate", - "deprecat": "deprecate", - "deprecate": "deprecate", - "dif": "diff", - "diff": "diff", - "dist-tag": "dist-tag", - "dist-tags": "dist-tags", - "docs": "docs", - "doct": "doctor", - "docto": "doctor", - "doctor": "doctor", - "ed": "edit", - "edi": "edit", - "edit": "edit", - "exe": "exec", - "exec": "exec", - "expla": "explain", - "explai": "explain", - "explain": "explain", - "explo": "explore", - "explor": "explore", - "explore": "explore", - "find": "find", - "find-": "find-dupes", - "find-d": "find-dupes", - "find-du": "find-dupes", - "find-dup": "find-dupes", - "find-dupe": "find-dupes", - "find-dupes": "find-dupes", - "fu": "fund", - "fun": "fund", - "fund": "fund", - "g": "get", - "ge": "get", - "get": "get", - "he": "help", - "hel": "help", - "help": "help", - "hl": "hlep", - "hle": "hlep", - "hlep": "hlep", - "hom": "home", - "home": "home", - "hoo": "hook", - "hook": "hook", - "i": "i", - "ic": "ic", - "in": "in", - "inf": "info", - "info": "info", - "ini": "init", - "init": "init", - "inn": "innit", - "inni": "innit", - "innit": "innit", - "ins": "ins", - "inst": "inst", - "insta": "insta", - "instal": "instal", - "install": "install", - "install-ci": "install-ci-test", - "install-ci-": "install-ci-test", - "install-ci-t": "install-ci-test", - "install-ci-te": "install-ci-test", - "install-ci-tes": "install-ci-test", - "install-ci-test": "install-ci-test", - "install-cl": "install-clean", - "install-cle": "install-clean", - "install-clea": "install-clean", - "install-clean": "install-clean", - "install-t": "install-test", - "install-te": "install-test", - "install-tes": "install-test", - "install-test": "install-test", - "isnt": "isnt", - "isnta": "isnta", - "isntal": "isntal", - "isntall": "isntall", - "isntall-": "isntall-clean", - "isntall-c": "isntall-clean", - "isntall-cl": "isntall-clean", - "isntall-cle": "isntall-clean", - "isntall-clea": "isntall-clean", - "isntall-clean": "isntall-clean", - "iss": "issues", - "issu": "issues", - "issue": "issues", - "issues": "issues", - "it": "it", - "la": "la", - "lin": "link", - "link": "link", - "lis": "list", - "list": "list", - "ll": "ll", - "ln": "ln", - "logi": "login", - "login": "login", - "logo": "logout", - "logou": "logout", - "logout": "logout", - "ls": "ls", - "og": "ogr", - "ogr": "ogr", - "or": "org", - "org": "org", - "ou": "outdated", - "out": "outdated", - "outd": "outdated", - "outda": "outdated", - "outdat": "outdated", - "outdate": "outdated", - "outdated": "outdated", - "ow": "owner", - "own": "owner", - "owne": "owner", - "owner": "owner", - "pa": "pack", - "pac": "pack", - "pack": "pack", - "pi": "ping", - "pin": "ping", - "ping": "ping", - "pk": "pkg", - "pkg": "pkg", - "pre": "prefix", - "pref": "prefix", - "prefi": "prefix", - "prefix": "prefix", - "pro": "profile", - "prof": "profile", - "profi": "profile", - "profil": "profile", - "profile": "profile", - "pru": "prune", - "prun": "prune", - "prune": "prune", - "pu": "publish", - "pub": "publish", - "publ": "publish", - "publi": "publish", - "publis": "publish", - "publish": "publish", - "q": "query", - "qu": "query", - "que": "query", - "quer": "query", - "query": "query", - "r": "r", - "rb": "rb", - "reb": "rebuild", - "rebu": "rebuild", - "rebui": "rebuild", - "rebuil": "rebuild", - "rebuild": "rebuild", - "rem": "remove", - "remo": "remove", - "remov": "remove", - "remove": "remove", - "rep": "repo", - "repo": "repo", - "res": "restart", - "rest": "restart", - "resta": "restart", - "restar": "restart", - "restart": "restart", - "rm": "rm", - "ro": "root", - "roo": "root", - "root": "root", - "rum": "rum", - "run": "run", - "run-": "run-script", - "run-s": "run-script", - "run-sc": "run-script", - "run-scr": "run-script", - "run-scri": "run-script", - "run-scrip": "run-script", - "run-script": "run-script", - "s": "s", - "se": "se", - "sea": "search", - "sear": "search", - "searc": "search", - "search": "search", - "set": "set", - "sho": "show", - "show": "show", - "shr": "shrinkwrap", - "shri": "shrinkwrap", - "shrin": "shrinkwrap", - "shrink": "shrinkwrap", - "shrinkw": "shrinkwrap", - "shrinkwr": "shrinkwrap", - "shrinkwra": "shrinkwrap", - "shrinkwrap": "shrinkwrap", - "si": "sit", - "sit": "sit", - "star": "star", - "stars": "stars", - "start": "start", - "sto": "stop", - "stop": "stop", - "t": "t", - "tea": "team", - "team": "team", - "tes": "test", - "test": "test", - "to": "token", - "tok": "token", - "toke": "token", - "token": "token", - "ts": "tst", - "tst": "tst", - "ud": "udpate", - "udp": "udpate", - "udpa": "udpate", - "udpat": "udpate", - "udpate": "udpate", - "un": "un", - "uni": "uninstall", - "unin": "uninstall", - "unins": "uninstall", - "uninst": "uninstall", - "uninsta": "uninstall", - "uninstal": "uninstall", - "uninstall": "uninstall", - "unl": "unlink", - "unli": "unlink", - "unlin": "unlink", - "unlink": "unlink", - "unp": "unpublish", - "unpu": "unpublish", - "unpub": "unpublish", - "unpubl": "unpublish", - "unpubli": "unpublish", - "unpublis": "unpublish", - "unpublish": "unpublish", - "uns": "unstar", - "unst": "unstar", - "unsta": "unstar", - "unstar": "unstar", - "up": "up", - "upd": "update", - "upda": "update", - "updat": "update", - "update": "update", - "upg": "upgrade", - "upgr": "upgrade", - "upgra": "upgrade", - "upgrad": "upgrade", - "upgrade": "upgrade", - "ur": "urn", - "urn": "urn", - "v": "v", - "veri": "verison", - "veris": "verison", - "veriso": "verison", - "verison": "verison", - "vers": "version", - "versi": "version", - "versio": "version", - "version": "version", - "vi": "view", - "vie": "view", - "view": "view", - "who": "whoami", - "whoa": "whoami", - "whoam": "whoami", - "whoami": "whoami", - "why": "why", - "x": "x", - }, - "aliases": Object { - "add": "install", - "add-user": "adduser", - "author": "owner", - "c": "config", - "cit": "install-ci-test", - "clean-install": "ci", - "clean-install-test": "cit", - "create": "init", - "ddp": "dedupe", - "dist-tags": "dist-tag", - "find": "search", - "hlep": "help", - "home": "docs", - "i": "install", - "ic": "ci", - "in": "install", - "info": "view", - "innit": "init", - "ins": "install", - "inst": "install", - "insta": "install", - "instal": "install", - "install-clean": "ci", - "isnt": "install", - "isnta": "install", - "isntal": "install", - "isntall": "install", - "isntall-clean": "ci", - "issues": "bugs", - "it": "install-test", - "la": "ll", - "list": "ls", - "ln": "link", - "ogr": "org", - "r": "uninstall", - "rb": "rebuild", - "remove": "uninstall", - "rm": "uninstall", - "rum": "run-script", - "run": "run-script", - "s": "search", - "se": "search", - "show": "view", - "sit": "cit", - "t": "test", - "tst": "test", - "udpate": "update", - "un": "uninstall", - "unlink": "uninstall", - "up": "update", - "upgrade": "update", - "urn": "run-script", - "v": "view", - "verison": "version", - "why": "explain", - "x": "exec", - }, - "cmdList": Array [ - "access", - "adduser", - "audit", - "bugs", - "cache", - "ci", - "completion", - "config", - "dedupe", - "deprecate", - "diff", - "dist-tag", - "docs", - "doctor", - "edit", - "exec", - "explain", - "explore", - "find-dupes", - "fund", - "get", - "help", - "hook", - "init", - "install", - "install-ci-test", - "install-test", - "link", - "ll", - "login", - "logout", - "ls", - "org", - "outdated", - "owner", - "pack", - "ping", - "pkg", - "prefix", - "profile", - "prune", - "publish", - "query", - "rebuild", - "repo", - "restart", - "root", - "run-script", - "search", - "set", - "shrinkwrap", - "star", - "stars", - "start", - "stop", - "team", - "test", - "token", - "uninstall", - "unpublish", - "unstar", - "update", - "version", - "view", - "whoami", - ], - "plumbing": Array [ - "help-search", - ], -} -` diff --git a/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs b/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs deleted file mode 100644 index 0a079b297c5d1..0000000000000 --- a/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs +++ /dev/null @@ -1,1525 +0,0 @@ -/* IMPORTANT - * This snapshot file is auto-generated, but designed for humans. - * It should be checked into source control and tracked carefully. - * Re-generate by setting TAP_SNAPSHOT=1 and running tests. - * Make sure to inspect the output below. Do not ignore changes! - */ -'use strict' -exports[`test/lib/utils/config/describe-all.js TAP > must match snapshot 1`] = ` -#### \`_auth\` - -* Default: null -* Type: null or String - -A basic-auth string to use when authenticating against the npm registry. -This will ONLY be used to authenticate against the npm registry. For other -registries you will need to scope it like "//other-registry.tld/:_auth" - -Warning: This should generally not be set via a command-line option. It is -safer to use a registry-provided authentication bearer token stored in the -~/.npmrc file by running \`npm login\`. - -#### \`access\` - -* Default: 'public' for new packages, existing packages it will not change the - current level -* Type: null, "restricted", or "public" - -If do not want your scoped package to be publicly viewable (and installable) -set \`--access=restricted\`. - -Unscoped packages can not be set to \`restricted\`. - -Note: This defaults to not changing the current access level for existing -packages. Specifying a value of \`restricted\` or \`public\` during publish will -change the access for an existing package the same way that \`npm access set -status\` would. - -#### \`all\` - -* Default: false -* Type: Boolean - -When running \`npm outdated\` and \`npm ls\`, setting \`--all\` will show all -outdated or installed packages, rather than only those directly depended -upon by the current project. - -#### \`allow-same-version\` - -* Default: false -* Type: Boolean - -Prevents throwing an error when \`npm version\` is used to set the new version -to the same value as the current version. - -#### \`audit\` - -* Default: true -* Type: Boolean - -When "true" submit audit reports alongside the current npm command to the -default registry and all registries configured for scopes. See the -documentation for [\`npm audit\`](/commands/npm-audit) for details on what is -submitted. - -#### \`audit-level\` - -* Default: null -* Type: null, "info", "low", "moderate", "high", "critical", or "none" - -The minimum level of vulnerability for \`npm audit\` to exit with a non-zero -exit code. - -#### \`auth-type\` - -* Default: "web" -* Type: "legacy" or "web" - -What authentication strategy to use with \`login\`. - -#### \`before\` - -* Default: null -* Type: null or Date - -If passed to \`npm install\`, will rebuild the npm tree such that only -versions that were available **on or before** the \`--before\` time get -installed. If there's no versions available for the current set of direct -dependencies, the command will error. - -If the requested version is a \`dist-tag\` and the given tag does not pass the -\`--before\` filter, the most recent version less than or equal to that tag -will be used. For example, \`foo@latest\` might install \`foo@1.2\` even though -\`latest\` is \`2.0\`. - -#### \`bin-links\` - -* Default: true -* Type: Boolean - -Tells npm to create symlinks (or \`.cmd\` shims on Windows) for package -executables. - -Set to false to have it not do this. This can be used to work around the -fact that some file systems don't support symlinks, even on ostensibly Unix -systems. - -#### \`browser\` - -* Default: OS X: \`"open"\`, Windows: \`"start"\`, Others: \`"xdg-open"\` -* Type: null, Boolean, or String - -The browser that is called by npm commands to open websites. - -Set to \`false\` to suppress browser behavior and instead print urls to -terminal. - -Set to \`true\` to use default system URL opener. - -#### \`ca\` - -* Default: null -* Type: null or String (can be set multiple times) - -The Certificate Authority signing certificate that is trusted for SSL -connections to the registry. Values should be in PEM format (Windows calls -it "Base-64 encoded X.509 (.CER)") with newlines replaced by the string -"\\n". For example: - -\`\`\`ini -ca="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----" -\`\`\` - -Set to \`null\` to only allow "known" registrars, or to a specific CA cert to -trust only that specific signing authority. - -Multiple CAs can be trusted by specifying an array of certificates: - -\`\`\`ini -ca[]="..." -ca[]="..." -\`\`\` - -See also the \`strict-ssl\` config. - -#### \`cache\` - -* Default: Windows: \`%LocalAppData%\\npm-cache\`, Posix: \`~/.npm\` -* Type: Path - -The location of npm's cache directory. - -#### \`cafile\` - -* Default: null -* Type: Path - -A path to a file containing one or multiple Certificate Authority signing -certificates. Similar to the \`ca\` setting, but allows for multiple CA's, as -well as for the CA information to be stored in a file on disk. - -#### \`call\` - -* Default: "" -* Type: String - -Optional companion option for \`npm exec\`, \`npx\` that allows for specifying a -custom command to be run along with the installed packages. - -\`\`\`bash -npm exec --package yo --package generator-node --call "yo node" -\`\`\` - - -#### \`cert\` - -* Default: null -* Type: null or String - -A client certificate to pass when accessing the registry. Values should be -in PEM format (Windows calls it "Base-64 encoded X.509 (.CER)") with -newlines replaced by the string "\\n". For example: - -\`\`\`ini -cert="-----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE-----" -\`\`\` - -It is _not_ the path to a certificate file, though you can set a -registry-scoped "certfile" path like -"//other-registry.tld/:certfile=/path/to/cert.pem". - -#### \`ci-name\` - -* Default: The name of the current CI system, or \`null\` when not on a known CI - platform. -* Type: null or String - -The name of a continuous integration system. If not set explicitly, npm will -detect the current CI environment using the -[\`@npmcli/ci-detect\`](http://npm.im/@npmcli/ci-detect) module. - -#### \`cidr\` - -* Default: null -* Type: null or String (can be set multiple times) - -This is a list of CIDR address to be used when configuring limited access -tokens with the \`npm token create\` command. - -#### \`color\` - -* Default: true unless the NO_COLOR environ is set to something other than '0' -* Type: "always" or Boolean - -If false, never shows colors. If \`"always"\` then always shows colors. If -true, then only prints color codes for tty file descriptors. - -#### \`commit-hooks\` - -* Default: true -* Type: Boolean - -Run git commit hooks when using the \`npm version\` command. - -#### \`depth\` - -* Default: \`Infinity\` if \`--all\` is set, otherwise \`1\` -* Type: null or Number - -The depth to go when recursing packages for \`npm ls\`. - -If not set, \`npm ls\` will show only the immediate dependencies of the root -project. If \`--all\` is set, then npm will show all dependencies by default. - -#### \`description\` - -* Default: true -* Type: Boolean - -Show the description in \`npm search\` - -#### \`diff\` - -* Default: -* Type: String (can be set multiple times) - -Define arguments to compare in \`npm diff\`. - -#### \`diff-dst-prefix\` - -* Default: "b/" -* Type: String - -Destination prefix to be used in \`npm diff\` output. - -#### \`diff-ignore-all-space\` - -* Default: false -* Type: Boolean - -Ignore whitespace when comparing lines in \`npm diff\`. - -#### \`diff-name-only\` - -* Default: false -* Type: Boolean - -Prints only filenames when using \`npm diff\`. - -#### \`diff-no-prefix\` - -* Default: false -* Type: Boolean - -Do not show any source or destination prefix in \`npm diff\` output. - -Note: this causes \`npm diff\` to ignore the \`--diff-src-prefix\` and -\`--diff-dst-prefix\` configs. - -#### \`diff-src-prefix\` - -* Default: "a/" -* Type: String - -Source prefix to be used in \`npm diff\` output. - -#### \`diff-text\` - -* Default: false -* Type: Boolean - -Treat all files as text in \`npm diff\`. - -#### \`diff-unified\` - -* Default: 3 -* Type: Number - -The number of lines of context to print in \`npm diff\`. - -#### \`dry-run\` - -* Default: false -* Type: Boolean - -Indicates that you don't want npm to make any changes and that it should -only report what it would have done. This can be passed into any of the -commands that modify your local installation, eg, \`install\`, \`update\`, -\`dedupe\`, \`uninstall\`, as well as \`pack\` and \`publish\`. - -Note: This is NOT honored by other network related commands, eg \`dist-tags\`, -\`owner\`, etc. - -#### \`editor\` - -* Default: The EDITOR or VISUAL environment variables, or 'notepad.exe' on - Windows, or 'vim' on Unix systems -* Type: String - -The command to run for \`npm edit\` and \`npm config edit\`. - -#### \`engine-strict\` - -* Default: false -* Type: Boolean - -If set to true, then npm will stubbornly refuse to install (or even consider -installing) any package that claims to not be compatible with the current -Node.js version. - -This can be overridden by setting the \`--force\` flag. - -#### \`fetch-retries\` - -* Default: 2 -* Type: Number - -The "retries" config for the \`retry\` module to use when fetching packages -from the registry. - -npm will retry idempotent read requests to the registry in the case of -network failures or 5xx HTTP errors. - -#### \`fetch-retry-factor\` - -* Default: 10 -* Type: Number - -The "factor" config for the \`retry\` module to use when fetching packages. - -#### \`fetch-retry-maxtimeout\` - -* Default: 60000 (1 minute) -* Type: Number - -The "maxTimeout" config for the \`retry\` module to use when fetching -packages. - -#### \`fetch-retry-mintimeout\` - -* Default: 10000 (10 seconds) -* Type: Number - -The "minTimeout" config for the \`retry\` module to use when fetching -packages. - -#### \`fetch-timeout\` - -* Default: 300000 (5 minutes) -* Type: Number - -The maximum amount of time to wait for HTTP requests to complete. - -#### \`force\` - -* Default: false -* Type: Boolean - -Removes various protections against unfortunate side effects, common -mistakes, unnecessary performance degradation, and malicious input. - -* Allow clobbering non-npm files in global installs. -* Allow the \`npm version\` command to work on an unclean git repository. -* Allow deleting the cache folder with \`npm cache clean\`. -* Allow installing packages that have an \`engines\` declaration requiring a - different version of npm. -* Allow installing packages that have an \`engines\` declaration requiring a - different version of \`node\`, even if \`--engine-strict\` is enabled. -* Allow \`npm audit fix\` to install modules outside your stated dependency - range (including SemVer-major changes). -* Allow unpublishing all versions of a published package. -* Allow conflicting peerDependencies to be installed in the root project. -* Implicitly set \`--yes\` during \`npm init\`. -* Allow clobbering existing values in \`npm pkg\` -* Allow unpublishing of entire packages (not just a single version). - -If you don't have a clear idea of what you want to do, it is strongly -recommended that you do not use this option! - -#### \`foreground-scripts\` - -* Default: false -* Type: Boolean - -Run all build scripts (ie, \`preinstall\`, \`install\`, and \`postinstall\`) -scripts for installed packages in the foreground process, sharing standard -input, output, and error with the main npm process. - -Note that this will generally make installs run slower, and be much noisier, -but can be useful for debugging. - -#### \`format-package-lock\` - -* Default: true -* Type: Boolean - -Format \`package-lock.json\` or \`npm-shrinkwrap.json\` as a human readable -file. - -#### \`fund\` - -* Default: true -* Type: Boolean - -When "true" displays the message at the end of each \`npm install\` -acknowledging the number of dependencies looking for funding. See [\`npm -fund\`](/commands/npm-fund) for details. - -#### \`git\` - -* Default: "git" -* Type: String - -The command to use for git commands. If git is installed on the computer, -but is not in the \`PATH\`, then set this to the full path to the git binary. - -#### \`git-tag-version\` - -* Default: true -* Type: Boolean - -Tag the commit when using the \`npm version\` command. Setting this to false -results in no commit being made at all. - -#### \`global\` - -* Default: false -* Type: Boolean - -Operates in "global" mode, so that packages are installed into the \`prefix\` -folder instead of the current working directory. See -[folders](/configuring-npm/folders) for more on the differences in behavior. - -* packages are installed into the \`{prefix}/lib/node_modules\` folder, instead - of the current working directory. -* bin files are linked to \`{prefix}/bin\` -* man pages are linked to \`{prefix}/share/man\` - -#### \`global-style\` - -* Default: false -* Type: Boolean - -Causes npm to install the package into your local \`node_modules\` folder with -the same layout it uses with the global \`node_modules\` folder. Only your -direct dependencies will show in \`node_modules\` and everything they depend -on will be flattened in their \`node_modules\` folders. This obviously will -eliminate some deduping. If used with \`legacy-bundling\`, \`legacy-bundling\` -will be preferred. - -#### \`globalconfig\` - -* Default: The global --prefix setting plus 'etc/npmrc'. For example, - '/usr/local/etc/npmrc' -* Type: Path - -The config file to read for global config options. - -#### \`heading\` - -* Default: "npm" -* Type: String - -The string that starts all the debugging log output. - -#### \`https-proxy\` - -* Default: null -* Type: null or URL - -A proxy to use for outgoing https requests. If the \`HTTPS_PROXY\` or -\`https_proxy\` or \`HTTP_PROXY\` or \`http_proxy\` environment variables are set, -proxy settings will be honored by the underlying \`make-fetch-happen\` -library. - -#### \`if-present\` - -* Default: false -* Type: Boolean - -If true, npm will not exit with an error code when \`run-script\` is invoked -for a script that isn't defined in the \`scripts\` section of \`package.json\`. -This option can be used when it's desirable to optionally run a script when -it's present and fail if the script fails. This is useful, for example, when -running scripts that may only apply for some builds in an otherwise generic -CI setup. - -This value is not exported to the environment for child processes. - -#### \`ignore-scripts\` - -* Default: false -* Type: Boolean - -If true, npm does not run scripts specified in package.json files. - -Note that commands explicitly intended to run a particular script, such as -\`npm start\`, \`npm stop\`, \`npm restart\`, \`npm test\`, and \`npm run-script\` -will still run their intended script if \`ignore-scripts\` is set, but they -will *not* run any pre- or post-scripts. - -#### \`include\` - -* Default: -* Type: "prod", "dev", "optional", or "peer" (can be set multiple times) - -Option that allows for defining which types of dependencies to install. - -This is the inverse of \`--omit=\`. - -Dependency types specified in \`--include\` will not be omitted, regardless of -the order in which omit/include are specified on the command-line. - -#### \`include-staged\` - -* Default: false -* Type: Boolean - -Allow installing "staged" published packages, as defined by [npm RFC PR -#92](https://github.com/npm/rfcs/pull/92). - -This is experimental, and not implemented by the npm public registry. - -#### \`include-workspace-root\` - -* Default: false -* Type: Boolean - -Include the workspace root when workspaces are enabled for a command. - -When false, specifying individual workspaces via the \`workspace\` config, or -all workspaces via the \`workspaces\` flag, will cause npm to operate only on -the specified workspaces, and not on the root project. - -This value is not exported to the environment for child processes. - -#### \`init-author-email\` - -* Default: "" -* Type: String - -The value \`npm init\` should use by default for the package author's email. - -#### \`init-author-name\` - -* Default: "" -* Type: String - -The value \`npm init\` should use by default for the package author's name. - -#### \`init-author-url\` - -* Default: "" -* Type: "" or URL - -The value \`npm init\` should use by default for the package author's -homepage. - -#### \`init-license\` - -* Default: "ISC" -* Type: String - -The value \`npm init\` should use by default for the package license. - -#### \`init-module\` - -* Default: "~/.npm-init.js" -* Type: Path - -A module that will be loaded by the \`npm init\` command. See the -documentation for the -[init-package-json](https://github.com/npm/init-package-json) module for -more information, or [npm init](/commands/npm-init). - -#### \`init-version\` - -* Default: "1.0.0" -* Type: SemVer string - -The value that \`npm init\` should use by default for the package version -number, if not already set in package.json. - -#### \`install-links\` - -* Default: true -* Type: Boolean - -When set file: protocol dependencies will be packed and installed as regular -dependencies instead of creating a symlink. This option has no effect on -workspaces. - -#### \`json\` - -* Default: false -* Type: Boolean - -Whether or not to output JSON data, rather than the normal output. - -* In \`npm pkg set\` it enables parsing set values with JSON.parse() before - saving them to your \`package.json\`. - -Not supported by all npm commands. - -#### \`key\` - -* Default: null -* Type: null or String - -A client key to pass when accessing the registry. Values should be in PEM -format with newlines replaced by the string "\\n". For example: - -\`\`\`ini -key="-----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY-----" -\`\`\` - -It is _not_ the path to a key file, though you can set a registry-scoped -"keyfile" path like "//other-registry.tld/:keyfile=/path/to/key.pem". - -#### \`legacy-bundling\` - -* Default: false -* Type: Boolean - -Causes npm to install the package such that versions of npm prior to 1.4, -such as the one included with node 0.8, can install the package. This -eliminates all automatic deduping. If used with \`global-style\` this option -will be preferred. - -#### \`legacy-peer-deps\` - -* Default: false -* Type: Boolean - -Causes npm to completely ignore \`peerDependencies\` when building a package -tree, as in npm versions 3 through 6. - -If a package cannot be installed because of overly strict \`peerDependencies\` -that collide, it provides a way to move forward resolving the situation. - -This differs from \`--omit=peer\`, in that \`--omit=peer\` will avoid unpacking -\`peerDependencies\` on disk, but will still design a tree such that -\`peerDependencies\` _could_ be unpacked in a correct place. - -Use of \`legacy-peer-deps\` is not recommended, as it will not enforce the -\`peerDependencies\` contract that meta-dependencies may rely on. - -#### \`link\` - -* Default: false -* Type: Boolean - -Used with \`npm ls\`, limiting output to only those packages that are linked. - -#### \`local-address\` - -* Default: null -* Type: IP Address - -The IP address of the local interface to use when making connections to the -npm registry. Must be IPv4 in versions of Node prior to 0.12. - -#### \`location\` - -* Default: "user" unless \`--global\` is passed, which will also set this value - to "global" -* Type: "global", "user", or "project" - -When passed to \`npm config\` this refers to which config file to use. - -When set to "global" mode, packages are installed into the \`prefix\` folder -instead of the current working directory. See -[folders](/configuring-npm/folders) for more on the differences in behavior. - -* packages are installed into the \`{prefix}/lib/node_modules\` folder, instead - of the current working directory. -* bin files are linked to \`{prefix}/bin\` -* man pages are linked to \`{prefix}/share/man\` - -#### \`lockfile-version\` - -* Default: Version 3 if no lockfile, auto-converting v1 lockfiles to v3, - otherwise maintain current lockfile version. -* Type: null, 1, 2, 3, "1", "2", or "3" - -Set the lockfile format version to be used in package-lock.json and -npm-shrinkwrap-json files. Possible options are: - -1: The lockfile version used by npm versions 5 and 6. Lacks some data that -is used during the install, resulting in slower and possibly less -deterministic installs. Prevents lockfile churn when interoperating with -older npm versions. - -2: The default lockfile version used by npm version 7 and 8. Includes both -the version 1 lockfile data and version 3 lockfile data, for maximum -determinism and interoperability, at the expense of more bytes on disk. - -3: Only the new lockfile information introduced in npm version 7. Smaller on -disk than lockfile version 2, but not interoperable with older npm versions. -Ideal if all users are on npm version 7 and higher. - -#### \`loglevel\` - -* Default: "notice" -* Type: "silent", "error", "warn", "notice", "http", "timing", "info", - "verbose", or "silly" - -What level of logs to report. All logs are written to a debug log, with the -path to that file printed if the execution of a command fails. - -Any logs of a higher level than the setting are shown. The default is -"notice". - -See also the \`foreground-scripts\` config. - -#### \`logs-dir\` - -* Default: A directory named \`_logs\` inside the cache -* Type: null or Path - -The location of npm's log directory. See [\`npm logging\`](/using-npm/logging) -for more information. - -#### \`logs-max\` - -* Default: 10 -* Type: Number - -The maximum number of log files to store. - -If set to 0, no log files will be written for the current run. - -#### \`long\` - -* Default: false -* Type: Boolean - -Show extended information in \`ls\`, \`search\`, and \`help-search\`. - -#### \`maxsockets\` - -* Default: 15 -* Type: Number - -The maximum number of connections to use per origin (protocol/host/port -combination). - -#### \`message\` - -* Default: "%s" -* Type: String - -Commit message which is used by \`npm version\` when creating version commit. - -Any "%s" in the message will be replaced with the version number. - -#### \`node-options\` - -* Default: null -* Type: null or String - -Options to pass through to Node.js via the \`NODE_OPTIONS\` environment -variable. This does not impact how npm itself is executed but it does impact -how lifecycle scripts are called. - -#### \`node-version\` - -* Default: Node.js \`process.version\` value -* Type: SemVer string - -The node version to use when checking a package's \`engines\` setting. - -#### \`noproxy\` - -* Default: The value of the NO_PROXY environment variable -* Type: String (can be set multiple times) - -Domain extensions that should bypass any proxies. - -Also accepts a comma-delimited string. - -#### \`npm-version\` - -* Default: Output of \`npm --version\` -* Type: SemVer string - -The npm version to use when checking a package's \`engines\` setting. - -#### \`offline\` - -* Default: false -* Type: Boolean - -Force offline mode: no network requests will be done during install. To -allow the CLI to fill in missing cache data, see \`--prefer-offline\`. - -#### \`omit\` - -* Default: 'dev' if the \`NODE_ENV\` environment variable is set to - 'production', otherwise empty. -* Type: "dev", "optional", or "peer" (can be set multiple times) - -Dependency types to omit from the installation tree on disk. - -Note that these dependencies _are_ still resolved and added to the -\`package-lock.json\` or \`npm-shrinkwrap.json\` file. They are just not -physically installed on disk. - -If a package type appears in both the \`--include\` and \`--omit\` lists, then -it will be included. - -If the resulting omit list includes \`'dev'\`, then the \`NODE_ENV\` environment -variable will be set to \`'production'\` for all lifecycle scripts. - -#### \`omit-lockfile-registry-resolved\` - -* Default: false -* Type: Boolean - -This option causes npm to create lock files without a \`resolved\` key for -registry dependencies. Subsequent installs will need to resolve tarball -endpoints with the configured registry, likely resulting in a longer install -time. - -#### \`otp\` - -* Default: null -* Type: null or String - -This is a one-time password from a two-factor authenticator. It's needed -when publishing or changing package permissions with \`npm access\`. - -If not set, and a registry response fails with a challenge for a one-time -password, npm will prompt on the command line for one. - -#### \`pack-destination\` - -* Default: "." -* Type: String - -Directory in which \`npm pack\` will save tarballs. - -#### \`package\` - -* Default: -* Type: String (can be set multiple times) - -The package or packages to install for [\`npm exec\`](/commands/npm-exec) - -#### \`package-lock\` - -* Default: true -* Type: Boolean - -If set to false, then ignore \`package-lock.json\` files when installing. This -will also prevent _writing_ \`package-lock.json\` if \`save\` is true. - -This configuration does not affect \`npm ci\`. - -#### \`package-lock-only\` - -* Default: false -* Type: Boolean - -If set to true, the current operation will only use the \`package-lock.json\`, -ignoring \`node_modules\`. - -For \`update\` this means only the \`package-lock.json\` will be updated, -instead of checking \`node_modules\` and downloading dependencies. - -For \`list\` this means the output will be based on the tree described by the -\`package-lock.json\`, rather than the contents of \`node_modules\`. - -#### \`parseable\` - -* Default: false -* Type: Boolean - -Output parseable results from commands that write to standard output. For -\`npm search\`, this will be tab-separated table format. - -#### \`prefer-offline\` - -* Default: false -* Type: Boolean - -If true, staleness checks for cached data will be bypassed, but missing data -will be requested from the server. To force full offline mode, use -\`--offline\`. - -#### \`prefer-online\` - -* Default: false -* Type: Boolean - -If true, staleness checks for cached data will be forced, making the CLI -look for updates immediately even for fresh package data. - -#### \`prefix\` - -* Default: In global mode, the folder where the node executable is installed. - In local mode, the nearest parent folder containing either a package.json - file or a node_modules folder. -* Type: Path - -The location to install global items. If set on the command line, then it -forces non-global commands to run in the specified folder. - -#### \`preid\` - -* Default: "" -* Type: String - -The "prerelease identifier" to use as a prefix for the "prerelease" part of -a semver. Like the \`rc\` in \`1.2.0-rc.8\`. - -#### \`progress\` - -* Default: \`true\` unless running in a known CI system -* Type: Boolean - -When set to \`true\`, npm will display a progress bar during time intensive -operations, if \`process.stderr\` is a TTY. - -Set to \`false\` to suppress the progress bar. - -#### \`proxy\` - -* Default: null -* Type: null, false, or URL - -A proxy to use for outgoing http requests. If the \`HTTP_PROXY\` or -\`http_proxy\` environment variables are set, proxy settings will be honored -by the underlying \`request\` library. - -#### \`read-only\` - -* Default: false -* Type: Boolean - -This is used to mark a token as unable to publish when configuring limited -access tokens with the \`npm token create\` command. - -#### \`rebuild-bundle\` - -* Default: true -* Type: Boolean - -Rebuild bundled dependencies after installation. - -#### \`registry\` - -* Default: "https://registry.npmjs.org/" -* Type: URL - -The base URL of the npm registry. - -#### \`replace-registry-host\` - -* Default: "npmjs" -* Type: "npmjs", "never", "always", or String - -Defines behavior for replacing the registry host in a lockfile with the -configured registry. - -The default behavior is to replace package dist URLs from the default -registry (https://registry.npmjs.org) to the configured registry. If set to -"never", then use the registry value. If set to "always", then replace the -registry host with the configured host every time. - -You may also specify a bare hostname (e.g., "registry.npmjs.org"). - -#### \`save\` - -* Default: \`true\` unless when using \`npm update\` where it defaults to \`false\` -* Type: Boolean - -Save installed packages to a \`package.json\` file as dependencies. - -When used with the \`npm rm\` command, removes the dependency from -\`package.json\`. - -Will also prevent writing to \`package-lock.json\` if set to \`false\`. - -#### \`save-bundle\` - -* Default: false -* Type: Boolean - -If a package would be saved at install time by the use of \`--save\`, -\`--save-dev\`, or \`--save-optional\`, then also put it in the -\`bundleDependencies\` list. - -Ignored if \`--save-peer\` is set, since peerDependencies cannot be bundled. - -#### \`save-dev\` - -* Default: false -* Type: Boolean - -Save installed packages to a package.json file as \`devDependencies\`. - -#### \`save-exact\` - -* Default: false -* Type: Boolean - -Dependencies saved to package.json will be configured with an exact version -rather than using npm's default semver range operator. - -#### \`save-optional\` - -* Default: false -* Type: Boolean - -Save installed packages to a package.json file as \`optionalDependencies\`. - -#### \`save-peer\` - -* Default: false -* Type: Boolean - -Save installed packages to a package.json file as \`peerDependencies\` - -#### \`save-prefix\` - -* Default: "^" -* Type: String - -Configure how versions of packages installed to a package.json file via -\`--save\` or \`--save-dev\` get prefixed. - -For example if a package has version \`1.2.3\`, by default its version is set -to \`^1.2.3\` which allows minor upgrades for that package, but after \`npm -config set save-prefix='~'\` it would be set to \`~1.2.3\` which only allows -patch upgrades. - -#### \`save-prod\` - -* Default: false -* Type: Boolean - -Save installed packages into \`dependencies\` specifically. This is useful if -a package already exists in \`devDependencies\` or \`optionalDependencies\`, but -you want to move it to be a non-optional production dependency. - -This is the default behavior if \`--save\` is true, and neither \`--save-dev\` -or \`--save-optional\` are true. - -#### \`scope\` - -* Default: the scope of the current project, if any, or "" -* Type: String - -Associate an operation with a scope for a scoped registry. - -Useful when logging in to or out of a private registry: - -\`\`\` -# log in, linking the scope to the custom registry -npm login --scope=@mycorp --registry=https://registry.mycorp.com - -# log out, removing the link and the auth token -npm logout --scope=@mycorp -\`\`\` - -This will cause \`@mycorp\` to be mapped to the registry for future -installation of packages specified according to the pattern -\`@mycorp/package\`. - -This will also cause \`npm init\` to create a scoped package. - -\`\`\` -# accept all defaults, and create a package named "@foo/whatever", -# instead of just named "whatever" -npm init --scope=@foo --yes -\`\`\` - - -#### \`script-shell\` - -* Default: '/bin/sh' on POSIX systems, 'cmd.exe' on Windows -* Type: null or String - -The shell to use for scripts run with the \`npm exec\`, \`npm run\` and \`npm -init \` commands. - -#### \`searchexclude\` - -* Default: "" -* Type: String - -Space-separated options that limit the results from search. - -#### \`searchlimit\` - -* Default: 20 -* Type: Number - -Number of items to limit search results to. Will not apply at all to legacy -searches. - -#### \`searchopts\` - -* Default: "" -* Type: String - -Space-separated options that are always passed to search. - -#### \`searchstaleness\` - -* Default: 900 -* Type: Number - -The age of the cache, in seconds, before another registry request is made if -using legacy search endpoint. - -#### \`shell\` - -* Default: SHELL environment variable, or "bash" on Posix, or "cmd.exe" on - Windows -* Type: String - -The shell to run for the \`npm explore\` command. - -#### \`sign-git-commit\` - -* Default: false -* Type: Boolean - -If set to true, then the \`npm version\` command will commit the new package -version using \`-S\` to add a signature. - -Note that git requires you to have set up GPG keys in your git configs for -this to work properly. - -#### \`sign-git-tag\` - -* Default: false -* Type: Boolean - -If set to true, then the \`npm version\` command will tag the version using -\`-s\` to add a signature. - -Note that git requires you to have set up GPG keys in your git configs for -this to work properly. - -#### \`strict-peer-deps\` - -* Default: false -* Type: Boolean - -If set to \`true\`, and \`--legacy-peer-deps\` is not set, then _any_ -conflicting \`peerDependencies\` will be treated as an install failure, even -if npm could reasonably guess the appropriate resolution based on non-peer -dependency relationships. - -By default, conflicting \`peerDependencies\` deep in the dependency graph will -be resolved using the nearest non-peer dependency specification, even if -doing so will result in some packages receiving a peer dependency outside -the range set in their package's \`peerDependencies\` object. - -When such and override is performed, a warning is printed, explaining the -conflict and the packages involved. If \`--strict-peer-deps\` is set, then -this warning is treated as a failure. - -#### \`strict-ssl\` - -* Default: true -* Type: Boolean - -Whether or not to do SSL key validation when making requests to the registry -via https. - -See also the \`ca\` config. - -#### \`tag\` - -* Default: "latest" -* Type: String - -If you ask npm to install a package and don't tell it a specific version, -then it will install the specified tag. - -Also the tag that is added to the package@version specified by the \`npm tag\` -command, if no explicit tag is given. - -When used by the \`npm diff\` command, this is the tag used to fetch the -tarball that will be compared with the local files by default. - -#### \`tag-version-prefix\` - -* Default: "v" -* Type: String - -If set, alters the prefix used when tagging a new version when performing a -version increment using \`npm-version\`. To remove the prefix altogether, set -it to the empty string: \`""\`. - -Because other tools may rely on the convention that npm version tags look -like \`v1.0.0\`, _only use this property if it is absolutely necessary_. In -particular, use care when overriding this setting for public packages. - -#### \`timing\` - -* Default: false -* Type: Boolean - -If true, writes timing information to a process specific json file in the -cache or \`logs-dir\`. The file name ends with \`-timing.json\`. - -You can quickly view it with this [json](https://npm.im/json) command line: -\`cat ~/.npm/_logs/*-timing.json | npm exec -- json -g\`. - -#### \`umask\` - -* Default: 0 -* Type: Octal numeric string in range 0000..0777 (0..511) - -The "umask" value to use when setting the file creation mode on files and -folders. - -Folders and executables are given a mode which is \`0o777\` masked against -this value. Other files are given a mode which is \`0o666\` masked against -this value. - -Note that the underlying system will _also_ apply its own umask value to -files and folders that are created, and npm does not circumvent this, but -rather adds the \`--umask\` config to it. - -Thus, the effective default umask value on most POSIX systems is 0o22, -meaning that folders and executables are created with a mode of 0o755 and -other files are created with a mode of 0o644. - -#### \`unicode\` - -* Default: false on windows, true on mac/unix systems with a unicode locale, - as defined by the \`LC_ALL\`, \`LC_CTYPE\`, or \`LANG\` environment variables. -* Type: Boolean - -When set to true, npm uses unicode characters in the tree output. When -false, it uses ascii characters instead of unicode glyphs. - -#### \`update-notifier\` - -* Default: true -* Type: Boolean - -Set to false to suppress the update notification when using an older version -of npm than the latest. - -#### \`usage\` - -* Default: false -* Type: Boolean - -Show short usage output about the command specified. - -#### \`user-agent\` - -* Default: "npm/{npm-version} node/{node-version} {platform} {arch} - workspaces/{workspaces} {ci}" -* Type: String - -Sets the User-Agent request header. The following fields are replaced with -their actual counterparts: - -* \`{npm-version}\` - The npm version in use -* \`{node-version}\` - The Node.js version in use -* \`{platform}\` - The value of \`process.platform\` -* \`{arch}\` - The value of \`process.arch\` -* \`{workspaces}\` - Set to \`true\` if the \`workspaces\` or \`workspace\` options - are set. -* \`{ci}\` - The value of the \`ci-name\` config, if set, prefixed with \`ci/\`, or - an empty string if \`ci-name\` is empty. - -#### \`userconfig\` - -* Default: "~/.npmrc" -* Type: Path - -The location of user-level configuration settings. - -This may be overridden by the \`npm_config_userconfig\` environment variable -or the \`--userconfig\` command line option, but may _not_ be overridden by -settings in the \`globalconfig\` file. - -#### \`version\` - -* Default: false -* Type: Boolean - -If true, output the npm version and exit successfully. - -Only relevant when specified explicitly on the command line. - -#### \`versions\` - -* Default: false -* Type: Boolean - -If true, output the npm version as well as node's \`process.versions\` map and -the version in the current working directory's \`package.json\` file if one -exists, and exit successfully. - -Only relevant when specified explicitly on the command line. - -#### \`viewer\` - -* Default: "man" on Posix, "browser" on Windows -* Type: String - -The program to use to view help content. - -Set to \`"browser"\` to view html help content in the default web browser. - -#### \`which\` - -* Default: null -* Type: null or Number - -If there are multiple funding sources, which 1-indexed source URL to open. - -#### \`workspace\` - -* Default: -* Type: String (can be set multiple times) - -Enable running a command in the context of the configured workspaces of the -current project while filtering by running only the workspaces defined by -this configuration option. - -Valid values for the \`workspace\` config are either: - -* Workspace names -* Path to a workspace directory -* Path to a parent workspace directory (will result in selecting all - workspaces within that folder) - -When set for the \`npm init\` command, this may be set to the folder of a -workspace which does not yet exist, to create the folder and set it up as a -brand new workspace within the project. - -This value is not exported to the environment for child processes. - -#### \`workspaces\` - -* Default: null -* Type: null or Boolean - -Set to true to run the command in the context of **all** configured -workspaces. - -Explicitly setting this to false will cause commands like \`install\` to -ignore workspaces altogether. When not set explicitly: - -- Commands that operate on the \`node_modules\` tree (install, update, etc.) -will link workspaces into the \`node_modules\` folder. - Commands that do -other things (test, exec, publish, etc.) will operate on the root project, -_unless_ one or more workspaces are specified in the \`workspace\` config. - -This value is not exported to the environment for child processes. - -#### \`workspaces-update\` - -* Default: true -* Type: Boolean - -If set to true, the npm cli will run an update after operations that may -possibly change the workspaces installed to the \`node_modules\` folder. - -#### \`yes\` - -* Default: null -* Type: null or Boolean - -Automatically answer "yes" to any prompts that npm might print on the -command line. - -#### \`also\` - -* Default: null -* Type: null, "dev", or "development" -* DEPRECATED: Please use --include=dev instead. - -When set to \`dev\` or \`development\`, this is an alias for \`--include=dev\`. - -#### \`cache-max\` - -* Default: Infinity -* Type: Number -* DEPRECATED: This option has been deprecated in favor of \`--prefer-online\` - -\`--cache-max=0\` is an alias for \`--prefer-online\` - -#### \`cache-min\` - -* Default: 0 -* Type: Number -* DEPRECATED: This option has been deprecated in favor of \`--prefer-offline\`. - -\`--cache-min=9999 (or bigger)\` is an alias for \`--prefer-offline\`. - -#### \`dev\` - -* Default: false -* Type: Boolean -* DEPRECATED: Please use --include=dev instead. - -Alias for \`--include=dev\`. - -#### \`init.author.email\` - -* Default: "" -* Type: String -* DEPRECATED: Use \`--init-author-email\` instead. - -Alias for \`--init-author-email\` - -#### \`init.author.name\` - -* Default: "" -* Type: String -* DEPRECATED: Use \`--init-author-name\` instead. - -Alias for \`--init-author-name\` - -#### \`init.author.url\` - -* Default: "" -* Type: "" or URL -* DEPRECATED: Use \`--init-author-url\` instead. - -Alias for \`--init-author-url\` - -#### \`init.license\` - -* Default: "ISC" -* Type: String -* DEPRECATED: Use \`--init-license\` instead. - -Alias for \`--init-license\` - -#### \`init.module\` - -* Default: "~/.npm-init.js" -* Type: Path -* DEPRECATED: Use \`--init-module\` instead. - -Alias for \`--init-module\` - -#### \`init.version\` - -* Default: "1.0.0" -* Type: SemVer string -* DEPRECATED: Use \`--init-version\` instead. - -Alias for \`--init-version\` - -#### \`only\` - -* Default: null -* Type: null, "prod", or "production" -* DEPRECATED: Use \`--omit=dev\` to omit dev dependencies from the install. - -When set to \`prod\` or \`production\`, this is an alias for \`--omit=dev\`. - -#### \`optional\` - -* Default: null -* Type: null or Boolean -* DEPRECATED: Use \`--omit=optional\` to exclude optional dependencies, or - \`--include=optional\` to include them. - -Default value does install optional deps unless otherwise omitted. - -Alias for --include=optional or --omit=optional - -#### \`production\` - -* Default: null -* Type: null or Boolean -* DEPRECATED: Use \`--omit=dev\` instead. - -Alias for \`--omit=dev\` - -#### \`shrinkwrap\` - -* Default: true -* Type: Boolean -* DEPRECATED: Use the --package-lock setting instead. - -Alias for --package-lock - -#### \`tmp\` - -* Default: The value returned by the Node.js \`os.tmpdir()\` method - -* Type: Path -* DEPRECATED: This setting is no longer used. npm stores temporary files in a - special location in the cache, and they are managed by - [\`cacache\`](http://npm.im/cacache). - -Historically, the location where temporary files were stored. No longer -relevant. -` diff --git a/tap-snapshots/test/lib/utils/config/index.js.test.cjs b/tap-snapshots/test/lib/utils/config/index.js.test.cjs deleted file mode 100644 index 78055d5bc720b..0000000000000 --- a/tap-snapshots/test/lib/utils/config/index.js.test.cjs +++ /dev/null @@ -1,139 +0,0 @@ -/* IMPORTANT - * This snapshot file is auto-generated, but designed for humans. - * It should be checked into source control and tracked carefully. - * Re-generate by setting TAP_SNAPSHOT=1 and running tests. - * Make sure to inspect the output below. Do not ignore changes! - */ -'use strict' -exports[`test/lib/utils/config/index.js TAP > shorthands 1`] = ` -Object { - "?": Array [ - "--usage", - ], - "a": Array [ - "--all", - ], - "B": Array [ - "--save-bundle", - ], - "c": Array [ - "--call", - ], - "C": Array [ - "--prefix", - ], - "d": Array [ - "--loglevel", - "info", - ], - "D": Array [ - "--save-dev", - ], - "dd": Array [ - "--loglevel", - "verbose", - ], - "ddd": Array [ - "--loglevel", - "silly", - ], - "desc": Array [ - "--description", - ], - "E": Array [ - "--save-exact", - ], - "enjoy-by": Array [ - "--before", - ], - "f": Array [ - "--force", - ], - "g": Array [ - "--global", - ], - "h": Array [ - "--usage", - ], - "H": Array [ - "--usage", - ], - "help": Array [ - "--usage", - ], - "iwr": Array [ - "--include-workspace-root", - ], - "l": Array [ - "--long", - ], - "L": Array [ - "--location", - ], - "local": Array [ - "--no-global", - ], - "m": Array [ - "--message", - ], - "n": Array [ - "--no-yes", - ], - "no": Array [ - "--no-yes", - ], - "O": Array [ - "--save-optional", - ], - "p": Array [ - "--parseable", - ], - "P": Array [ - "--save-prod", - ], - "porcelain": Array [ - "--parseable", - ], - "q": Array [ - "--loglevel", - "warn", - ], - "quiet": Array [ - "--loglevel", - "warn", - ], - "readonly": Array [ - "--read-only", - ], - "reg": Array [ - "--registry", - ], - "s": Array [ - "--loglevel", - "silent", - ], - "S": Array [ - "--save", - ], - "silent": Array [ - "--loglevel", - "silent", - ], - "v": Array [ - "--version", - ], - "verbose": Array [ - "--loglevel", - "verbose", - ], - "w": Array [ - "--workspace", - ], - "ws": Array [ - "--workspaces", - ], - "y": Array [ - "--yes", - ], -} -` diff --git a/test/lib/docs.js b/test/lib/docs.js new file mode 100644 index 0000000000000..a906b9bba6997 --- /dev/null +++ b/test/lib/docs.js @@ -0,0 +1,62 @@ +const t = require('tap') +const { join, resolve, basename, extname } = require('path') +const fs = require('@npmcli/fs') +const localeCompare = require('@isaacs/string-locale-compare')('en') +const docs = require('@npmcli/docs') +const { definitions } = require('../../lib/utils/config/index.js') +const cmdList = require('../../lib/utils/cmd-list.js') + +t.test('command list', async t => { + for (const [key, value] of Object.entries(cmdList)) { + t.matchSnapshot(value, key) + } +}) + +t.test('shorthands', async t => { + t.matchSnapshot(docs.shorthands(docs.TAGS.SHORTHANDS, {}), 'docs') +}) + +t.test('config', async t => { + const keys = Object.keys(definitions) + const flat = Object.entries(definitions).filter(([_, d]) => d.flatten).map(([k]) => k) + const notFlat = keys.filter(k => !flat.includes(k)) + t.matchSnapshot(keys, 'all keys') + t.matchSnapshot(flat, 'keys that are flattened') + t.matchSnapshot(notFlat, 'keys that are not flattened') + t.matchSnapshot(docs.config(docs.TAGS.CONFIG, {}), 'all definitions') +}) + +t.test('usage', async t => { + const readdir = async (dir, ext) => { + const files = await fs.readdir(dir) + return files.filter(f => extname(f) === ext).map(f => basename(f, ext)).sort(localeCompare) + } + + const fsCommands = await readdir(resolve(__dirname, '../../lib/commands'), '.js') + const docsCommands = await readdir(join(docs.paths.content, 'commands'), docs.DOC_EXT) + + // XXX: These extra commands exist as js files but not as docs pages + const allDocs = docsCommands.concat(['get', 'set', 'll']).map(n => n.replace('npm-', '')) + + // ensure that the list of js files in commands, docs files, and the command list + // are all in sync. eg, this will error if a command is removed but not its docs file + t.strictSame(fsCommands, cmdList.allCommands, 'command list and fs are the same') + t.strictSame( + allDocs.filter(f => !['npm', 'npx'].includes(f)).sort(localeCompare), + cmdList.allCommands, + 'command list and docs files are the same' + ) + + // use the list of files from the docs since those include the special cases + // for the bare npm and npx usage + for (const cmd of allDocs) { + const usage = docs.usage(docs.TAGS.USAGE, { path: cmd }) + const params = docs.params(docs.TAGS.CONFIG, { path: cmd }) + .split('\n') + .filter(l => l.startsWith('#### ')) + .map(l => l.replace('#### ', '')) + .join('\n') + + t.matchSnapshot(`${params || 'NO PARAMS'}\n\n${usage}`, cmd) + } +}) diff --git a/test/lib/load-all-commands.js b/test/lib/load-all-commands.js index 34773bba04662..e6c4710936bec 100644 --- a/test/lib/load-all-commands.js +++ b/test/lib/load-all-commands.js @@ -5,12 +5,10 @@ const t = require('tap') const util = require('util') const { load: loadMockNpm } = require('../fixtures/mock-npm.js') -const { cmdList, plumbing } = require('../../lib/utils/cmd-list.js') -const allCmds = [...cmdList, ...plumbing] +const { allCommands } = require('../../lib/utils/cmd-list.js') t.test('load each command', async t => { - t.plan(allCmds.length) - for (const cmd of allCmds.sort((a, b) => a.localeCompare(b, 'en'))) { + for (const cmd of allCommands) { t.test(cmd, async t => { const { npm, outputs } = await loadMockNpm(t, { config: { usage: true }, @@ -33,9 +31,6 @@ t.test('load each command', async t => { t.match(impl.usage, cmd, 'usage contains the command') await npm.exec(cmd, []) t.match(outputs[0][0], impl.usage, 'usage is what is output') - // This ties usage to a snapshot so we have to re-run snap if usage - // changes, which rebuilds the man pages - t.matchSnapshot(outputs[0][0]) }) } }) diff --git a/test/lib/npm.js b/test/lib/npm.js index 2bf7f426db409..d05b458408129 100644 --- a/test/lib/npm.js +++ b/test/lib/npm.js @@ -1,9 +1,11 @@ const t = require('tap') const { resolve, dirname, join } = require('path') +const fs = require('@npmcli/fs') const { load: loadMockNpm } = require('../fixtures/mock-npm.js') const mockGlobals = require('../fixtures/mock-globals') -const fs = require('@npmcli/fs') +const pkg = require('../../package.json') +const { commands } = require('../../lib/utils/cmd-list.js') // delete this so that we don't have configs from the fact that it // is being run by 'npm test' @@ -48,7 +50,6 @@ t.test('not yet loaded', async t => { t.throws(() => npm.config.set('foo', 'bar')) t.throws(() => npm.config.get('foo')) t.same(logs, []) - t.end() }) t.test('npm.load', async t => { @@ -502,7 +503,6 @@ t.test('timings', async t => { t.notOk(npm.unfinishedTimers.has('foo'), 'foo timer is gone') t.notOk(npm.unfinishedTimers.has('bar'), 'bar timer is gone') t.match(npm.finishedTimers, { foo: Number, bar: Number, npm: Number }) - t.end() }) t.test('writes timings file', async t => { @@ -571,7 +571,6 @@ t.test('output clears progress and console.logs the message', async t => { t.match(logs, [['hello']]) t.match(errors, [['error']]) - t.end() }) t.test('aliases and typos', async t => { @@ -681,60 +680,96 @@ t.test('implicit workspace accept', async t => { await t.rejects(mock.npm.exec('org', []), /.*Usage/) }) +t.test('basic usage', async t => { + t.cleanSnapshot = str => str + .split(dirname(dirname(__dirname))).join('{BASEDIR}') + .split(pkg.version).join('{VERSION}') + + // snapshot basic usage without commands since commands get snapshotted + // in other tests. the rest of the tests here assert that we are generating + // usage output that looks correct w/r/t spacing, width, and config values + const { npm } = await loadMockNpm(t, { + mocks: { + '../../lib/utils/cmd-list.js': { commands: [] }, + }, + }) + + t.matchSnapshot(await npm.usage) +}) + t.test('usage', async t => { - const { npm } = await loadMockNpm(t) - t.afterEach(() => { + const { npm } = await loadMockNpm(t) + + t.beforeEach(() => { npm.config.set('viewer', null) npm.config.set('long', false) npm.config.set('userconfig', '/some/config/file/.npmrc') }) - const { dirname } = require('path') - const basedir = dirname(dirname(__dirname)) - t.cleanSnapshot = str => str.split(basedir).join('{BASEDIR}') - .split(require('../../package.json').version).join('{VERSION}') - - npm.config.set('viewer', null) - npm.config.set('long', false) - npm.config.set('userconfig', '/some/config/file/.npmrc') - - t.test('basic usage', async t => { - t.matchSnapshot(await npm.usage) - t.end() - }) - + t.test('with browser', async t => { + const usage = await npm.usage npm.config.set('viewer', 'browser') - t.matchSnapshot(await npm.usage) - t.end() + const browserUsage = await npm.usage + t.notMatch(usage, '(in a browser)') + t.match(browserUsage, '(in a browser)') }) - t.test('with long', async t => { + t.test('includes commands', async t => { + const usage = await npm.usage npm.config.set('long', true) - t.matchSnapshot(await npm.usage) - t.end() + const longUsage = await npm.usage + + const lastCmd = commands[commands.length - 1] + for (const cmd of commands) { + const isLast = cmd === lastCmd + const shortCmd = new RegExp(`\\s${cmd}${isLast ? '\\n' : ',[\\s\\n]'}`) + const longCmd = new RegExp(`^\\s+${cmd}\\s+\\w.*\n\\s+Usage:\\n`, 'm') + + t.match(usage, shortCmd, `usage includes ${cmd}`) + t.notMatch(usage, longCmd, `usage does not include long ${cmd}`) + + t.match(longUsage, longCmd, `long usage includes ${cmd}`) + if (!isLast) { + // long usage includes false positives for the last command since it is + // not followed by a comma + t.notMatch(longUsage, shortCmd, `long usage does not include short ${cmd}`) + } + } }) t.test('set process.stdout.columns', async t => { - const { columns } = process.stdout - t.teardown(() => { - Object.defineProperty(process.stdout, 'columns', { - value: columns, - enumerable: true, - configurable: true, - writable: true, - }) - }) - const cases = [0, 90] - for (const cols of cases) { - t.test(`columns=${cols}`, async t => { - Object.defineProperty(process.stdout, 'columns', { - value: cols, - enumerable: true, - configurable: true, - writable: true, - }) - t.matchSnapshot(await npm.usage) - }) + const colUsage = async (cols) => { + const usages = [] + for (const col of cols) { + mockGlobals(t, { 'process.stdout.columns': col }) + const usage = await npm.usage + usages.push(usage) + } + return usages } + + t.test('max size', async t => { + const usages = await colUsage([0, 76, 90, 100]) + t.equal(usages.filter(Boolean).length, 4) + t.equal(new Set([...usages]).size, 1) + }) + + t.test('across max boundary', async t => { + const usages = await colUsage([75, 76]) + t.equal(usages.filter(Boolean).length, 2) + t.equal(new Set([...usages]).size, 2) + }) + + t.test('min size', async t => { + const usages = await colUsage([1, 10, 24, 40]) + t.equal(usages.filter(Boolean).length, 4) + t.equal(new Set([...usages]).size, 1) + }) + + t.test('different cols within min/max', async t => { + const usages = await colUsage([40, 41]) + t.equal(usages.filter(Boolean).length, 2) + t.equal(new Set([...usages]).size, 2) + }) }) }) diff --git a/test/lib/utils/cmd-list.js b/test/lib/utils/cmd-list.js deleted file mode 100644 index 8e936946b9938..0000000000000 --- a/test/lib/utils/cmd-list.js +++ /dev/null @@ -1,4 +0,0 @@ -const t = require('tap') -const cmdList = require('../../../lib/utils/cmd-list.js') -// just snapshot it so we are made aware if it changes unexpectedly -t.matchSnapshot(cmdList) diff --git a/test/lib/utils/config/definitions.js b/test/lib/utils/config/definitions.js index 200ee9e5536d1..4b0f502b816ce 100644 --- a/test/lib/utils/config/definitions.js +++ b/test/lib/utils/config/definitions.js @@ -5,33 +5,22 @@ const mockGlobals = require('../../../fixtures/mock-globals') // have to fake the node version, or else it'll only pass on this one mockGlobals(t, { 'process.version': 'v14.8.0', 'process.env.NODE_ENV': undefined }) -// also fake the npm version, so that it doesn't get reset every time -const pkg = require('../../../../package.json') +const mockDefs = (mocks = {}) => t.mock('../../../../lib/utils/config/definitions.js', mocks) -// this is a pain to keep typing -const defpath = '../../../../lib/utils/config/definitions.js' +const isWin = (isWindows) => ({ '../../../../lib/utils/is-windows.js': { isWindows } }) -const definitions = require(defpath) - -// Tie the definitions to a snapshot so that if they change we are forced to -// update snapshots, which rebuilds the docs -for (const key of Object.keys(definitions)) { - t.matchSnapshot(definitions[key].describe(), `config description for ${key}`) -} - -const isWin = '../../../../lib/utils/is-windows.js' - -// snapshot these just so we note when they change -t.matchSnapshot(Object.keys(definitions), 'all config keys') -t.matchSnapshot(Object.keys(definitions).filter(d => d.flatten), - 'all config keys that are shared to flatOptions') - -t.equal(definitions['npm-version'].default, pkg.version, 'npm-version default') -t.equal(definitions['node-version'].default, process.version, 'node-version default') +t.test('node and npm versions', t => { + const definitions = mockDefs() + const pkg = require('../../../../package.json') + t.equal(definitions['npm-version'].default, pkg.version, 'npm-version default') + t.equal(definitions['node-version'].default, process.version, 'node-version default') + t.end() +}) t.test('basic flattening function camelCases from css-case', t => { const flat = {} const obj = { 'prefer-online': true } + const definitions = mockDefs() definitions['prefer-online'].flatten('prefer-online', obj, flat) t.strictSame(flat, { preferOnline: true }) t.end() @@ -40,25 +29,21 @@ t.test('basic flattening function camelCases from css-case', t => { t.test('editor', t => { t.test('has EDITOR and VISUAL, use EDITOR', t => { mockGlobals(t, { 'process.env': { EDITOR: 'vim', VISUAL: 'mate' } }) - const defs = t.mock(defpath) + const defs = mockDefs() t.equal(defs.editor.default, 'vim') t.end() }) t.test('has VISUAL but no EDITOR, use VISUAL', t => { mockGlobals(t, { 'process.env': { EDITOR: undefined, VISUAL: 'mate' } }) - const defs = t.mock(defpath) + const defs = mockDefs() t.equal(defs.editor.default, 'mate') t.end() }) t.test('has neither EDITOR nor VISUAL, system specific', t => { mockGlobals(t, { 'process.env': { EDITOR: undefined, VISUAL: undefined } }) - const defsWin = t.mock(defpath, { - [isWin]: { isWindows: true }, - }) + const defsWin = mockDefs(isWin(true)) t.equal(defsWin.editor.default, 'notepad.exe') - const defsNix = t.mock(defpath, { - [isWin]: { isWindows: false }, - }) + const defsNix = mockDefs(isWin(false)) t.equal(defsNix.editor.default, 'vi') t.end() }) @@ -68,28 +53,20 @@ t.test('editor', t => { t.test('shell', t => { t.test('windows, env.ComSpec then cmd.exe', t => { mockGlobals(t, { 'process.env.ComSpec': 'command.com' }) - const defsComSpec = t.mock(defpath, { - [isWin]: { isWindows: true }, - }) + const defsComSpec = mockDefs(isWin(true)) t.equal(defsComSpec.shell.default, 'command.com') mockGlobals(t, { 'process.env.ComSpec': undefined }) - const defsNoComSpec = t.mock(defpath, { - [isWin]: { isWindows: true }, - }) + const defsNoComSpec = mockDefs(isWin(true)) t.equal(defsNoComSpec.shell.default, 'cmd') t.end() }) t.test('nix, SHELL then sh', t => { mockGlobals(t, { 'process.env.SHELL': '/usr/local/bin/bash' }) - const defsShell = t.mock(defpath, { - [isWin]: { isWindows: false }, - }) + const defsShell = mockDefs(isWin(false)) t.equal(defsShell.shell.default, '/usr/local/bin/bash') mockGlobals(t, { 'process.env.SHELL': undefined }) - const defsNoShell = t.mock(defpath, { - [isWin]: { isWindows: false }, - }) + const defsNoShell = mockDefs(isWin(false)) t.equal(defsNoShell.shell.default, 'sh') t.end() }) @@ -106,7 +83,7 @@ t.test('local-address allowed types', t => { eth69: [{ address: 'no place like home' }], }), } - const defs = t.mock(defpath, { os }) + const defs = mockDefs({ os }) t.same(defs['local-address'].type, [ null, '127.0.0.1', @@ -121,7 +98,7 @@ t.test('local-address allowed types', t => { throw new Error('no network interfaces for some reason') }, } - const defs = t.mock(defpath, { os }) + const defs = mockDefs({ os }) t.same(defs['local-address'].type, [null]) t.end() }) @@ -133,44 +110,38 @@ t.test('unicode allowed?', t => { setGlobal({ LC_ALL: 'utf8', LC_CTYPE: 'UTF-8', LANG: 'Unicode utf-8' }) - const lcAll = t.mock(defpath) + const lcAll = mockDefs() t.equal(lcAll.unicode.default, true) setGlobal({ LC_ALL: 'no unicode for youUUUU!' }) - const noLcAll = t.mock(defpath) + const noLcAll = mockDefs() t.equal(noLcAll.unicode.default, false) setGlobal({ LC_ALL: undefined }) - const lcCtype = t.mock(defpath) + const lcCtype = mockDefs() t.equal(lcCtype.unicode.default, true) setGlobal({ LC_CTYPE: 'something other than unicode version 8' }) - const noLcCtype = t.mock(defpath) + const noLcCtype = mockDefs() t.equal(noLcCtype.unicode.default, false) setGlobal({ LC_CTYPE: undefined }) - const lang = t.mock(defpath) + const lang = mockDefs() t.equal(lang.unicode.default, true) setGlobal({ LANG: 'ISO-8859-1' }) - const noLang = t.mock(defpath) + const noLang = mockDefs() t.equal(noLang.unicode.default, false) t.end() }) t.test('cache', t => { mockGlobals(t, { 'process.env.LOCALAPPDATA': 'app/data/local' }) - const defsWinLocalAppData = t.mock(defpath, { - [isWin]: { isWindows: true }, - }) + const defsWinLocalAppData = mockDefs(isWin(true)) t.equal(defsWinLocalAppData.cache.default, 'app/data/local/npm-cache') mockGlobals(t, { 'process.env.LOCALAPPDATA': undefined }) - const defsWinNoLocalAppData = t.mock(defpath, { - [isWin]: { isWindows: true }, - }) + const defsWinNoLocalAppData = mockDefs(isWin(true)) t.equal(defsWinNoLocalAppData.cache.default, '~/npm-cache') - const defsNix = t.mock(defpath, { - [isWin]: { isWindows: false }, - }) + const defsNix = mockDefs(isWin(false)) t.equal(defsNix.cache.default, '~/.npm') const flat = {} @@ -189,12 +160,12 @@ t.test('flatteners that populate flat.omit array', t => { // ignored if setting is not dev or development obj.also = 'ignored' - definitions.also.flatten('also', obj, flat) + mockDefs().also.flatten('also', obj, flat) t.strictSame(obj, { also: 'ignored', omit: [], include: [] }, 'nothing done') t.strictSame(flat, { omit: [] }, 'nothing done') obj.also = 'development' - definitions.also.flatten('also', obj, flat) + mockDefs().also.flatten('also', obj, flat) t.strictSame(obj, { also: 'development', omit: [], @@ -204,7 +175,7 @@ t.test('flatteners that populate flat.omit array', t => { obj.omit = ['dev', 'optional'] obj.include = [] - definitions.also.flatten('also', obj, flat) + mockDefs().also.flatten('also', obj, flat) t.strictSame(obj, { also: 'development', omit: ['optional'], @@ -217,10 +188,10 @@ t.test('flatteners that populate flat.omit array', t => { t.test('include', t => { const flat = {} const obj = { include: ['dev'] } - definitions.include.flatten('include', obj, flat) + mockDefs().include.flatten('include', obj, flat) t.strictSame(flat, { omit: [] }, 'not omitting anything') obj.omit = ['optional', 'dev'] - definitions.include.flatten('include', obj, flat) + mockDefs().include.flatten('include', obj, flat) t.strictSame(flat, { omit: ['optional'] }, 'only omitting optional') t.end() }) @@ -228,11 +199,11 @@ t.test('flatteners that populate flat.omit array', t => { t.test('omit', t => { const flat = {} const obj = { include: ['dev'], omit: ['dev', 'optional'] } - definitions.omit.flatten('omit', obj, flat) + mockDefs().omit.flatten('omit', obj, flat) t.strictSame(flat, { omit: ['optional'] }, 'do not omit what is included') mockGlobals(t, { 'process.env.NODE_ENV': 'production' }) - const defProdEnv = t.mock(defpath) + const defProdEnv = mockDefs() t.strictSame(defProdEnv.omit.default, ['dev'], 'omit dev in production') t.end() }) @@ -240,16 +211,16 @@ t.test('flatteners that populate flat.omit array', t => { t.test('only', t => { const flat = {} const obj = { only: 'asdf' } - definitions.only.flatten('only', obj, flat) + mockDefs().only.flatten('only', obj, flat) t.strictSame(flat, { omit: [] }, 'ignored if value is not production') obj.only = 'prod' - definitions.only.flatten('only', obj, flat) + mockDefs().only.flatten('only', obj, flat) t.strictSame(flat, { omit: ['dev'] }, 'omit dev when --only=prod') obj.include = ['dev'] flat.omit = [] - definitions.only.flatten('only', obj, flat) + mockDefs().only.flatten('only', obj, flat) t.strictSame(flat, { omit: [] }, 'do not omit when included') t.end() @@ -259,7 +230,7 @@ t.test('flatteners that populate flat.omit array', t => { const flat = {} const obj = { optional: null } - definitions.optional.flatten('optional', obj, flat) + mockDefs().optional.flatten('optional', obj, flat) t.strictSame(obj, { optional: null, omit: [], @@ -268,7 +239,7 @@ t.test('flatteners that populate flat.omit array', t => { t.strictSame(flat, { omit: [] }, 'do nothing by default') obj.optional = true - definitions.optional.flatten('optional', obj, flat) + mockDefs().optional.flatten('optional', obj, flat) t.strictSame(obj, { omit: [], optional: true, @@ -278,7 +249,7 @@ t.test('flatteners that populate flat.omit array', t => { delete obj.include obj.optional = false - definitions.optional.flatten('optional', obj, flat) + mockDefs().optional.flatten('optional', obj, flat) t.strictSame(obj, { omit: ['optional'], optional: false, @@ -292,7 +263,7 @@ t.test('flatteners that populate flat.omit array', t => { t.test('production', t => { const flat = {} const obj = { production: true } - definitions.production.flatten('production', obj, flat) + mockDefs().production.flatten('production', obj, flat) t.strictSame(obj, { production: true, omit: ['dev'], @@ -303,7 +274,7 @@ t.test('flatteners that populate flat.omit array', t => { delete obj.omit obj.production = false delete flat.omit - definitions.production.flatten('production', obj, flat) + mockDefs().production.flatten('production', obj, flat) t.strictSame(obj, { production: false, include: ['dev'], @@ -313,7 +284,7 @@ t.test('flatteners that populate flat.omit array', t => { obj.production = true obj.include = ['dev'] - definitions.production.flatten('production', obj, flat) + mockDefs().production.flatten('production', obj, flat) t.strictSame(obj, { production: true, include: ['dev'], @@ -327,7 +298,7 @@ t.test('flatteners that populate flat.omit array', t => { t.test('dev', t => { const flat = {} const obj = { dev: true } - definitions.dev.flatten('dev', obj, flat) + mockDefs().dev.flatten('dev', obj, flat) t.strictSame(obj, { dev: true, omit: [], @@ -342,10 +313,10 @@ t.test('flatteners that populate flat.omit array', t => { t.test('cache-max', t => { const flat = {} const obj = { 'cache-max': 10342 } - definitions['cache-max'].flatten('cache-max', obj, flat) + mockDefs()['cache-max'].flatten('cache-max', obj, flat) t.strictSame(flat, {}, 'no effect if not <= 0') obj['cache-max'] = 0 - definitions['cache-max'].flatten('cache-max', obj, flat) + mockDefs()['cache-max'].flatten('cache-max', obj, flat) t.strictSame(flat, { preferOnline: true }, 'preferOnline if <= 0') t.end() }) @@ -353,10 +324,10 @@ t.test('cache-max', t => { t.test('cache-min', t => { const flat = {} const obj = { 'cache-min': 123 } - definitions['cache-min'].flatten('cache-min', obj, flat) + mockDefs()['cache-min'].flatten('cache-min', obj, flat) t.strictSame(flat, {}, 'no effect if not >= 9999') obj['cache-min'] = 9999 - definitions['cache-min'].flatten('cache-min', obj, flat) + mockDefs()['cache-min'].flatten('cache-min', obj, flat) t.strictSame(flat, { preferOffline: true }, 'preferOffline if >=9999') t.end() }) @@ -367,44 +338,44 @@ t.test('color', t => { const flat = {} const obj = { color: 'always' } - definitions.color.flatten('color', obj, flat) + mockDefs().color.flatten('color', obj, flat) t.strictSame(flat, { color: true, logColor: true }, 'true when --color=always') obj.color = false - definitions.color.flatten('color', obj, flat) + mockDefs().color.flatten('color', obj, flat) t.strictSame(flat, { color: false, logColor: false }, 'true when --no-color') setTTY('stdout', false) setTTY('stderr', false) obj.color = true - definitions.color.flatten('color', obj, flat) + mockDefs().color.flatten('color', obj, flat) t.strictSame(flat, { color: false, logColor: false }, 'no color when stdout not tty') setTTY('stdout', true) - definitions.color.flatten('color', obj, flat) + mockDefs().color.flatten('color', obj, flat) t.strictSame(flat, { color: true, logColor: false }, '--color turns on color when stdout is tty') setTTY('stdout', false) obj.color = true - definitions.color.flatten('color', obj, flat) + mockDefs().color.flatten('color', obj, flat) t.strictSame(flat, { color: false, logColor: false }, 'no color when stderr not tty') setTTY('stderr', true) - definitions.color.flatten('color', obj, flat) + mockDefs().color.flatten('color', obj, flat) t.strictSame(flat, { color: false, logColor: true }, '--color turns on color when stderr is tty') setTTY('stderr', false) const setColor = (value) => mockGlobals(t, { 'process.env.NO_COLOR': value }) setColor(undefined) - const defsAllowColor = t.mock(defpath) + const defsAllowColor = mockDefs() t.equal(defsAllowColor.color.default, true, 'default true when no NO_COLOR env') setColor('0') - const defsNoColor0 = t.mock(defpath) + const defsNoColor0 = mockDefs() t.equal(defsNoColor0.color.default, true, 'default true when no NO_COLOR=0') setColor('1') - const defsNoColor1 = t.mock(defpath) + const defsNoColor1 = mockDefs() t.equal(defsNoColor1.color.default, false, 'default false when no NO_COLOR=1') t.end() @@ -418,19 +389,19 @@ t.test('progress', t => { const flat = {} - definitions.progress.flatten('progress', {}, flat) + mockDefs().progress.flatten('progress', {}, flat) t.strictSame(flat, { progress: false }) setEnv({ tty: true, term: 'notdumb' }) - definitions.progress.flatten('progress', { progress: true }, flat) + mockDefs().progress.flatten('progress', { progress: true }, flat) t.strictSame(flat, { progress: true }) setEnv({ tty: false, term: 'notdumb' }) - definitions.progress.flatten('progress', { progress: true }, flat) + mockDefs().progress.flatten('progress', { progress: true }, flat) t.strictSame(flat, { progress: false }) setEnv({ tty: true, term: 'dumb' }) - definitions.progress.flatten('progress', { progress: true }, flat) + mockDefs().progress.flatten('progress', { progress: true }, flat) t.strictSame(flat, { progress: false }) t.end() @@ -449,7 +420,7 @@ t.test('retry options', t => { const msg = `${config} -> retry.${option}` const flat = {} obj[config] = 99 - definitions[config].flatten(config, obj, flat) + mockDefs()[config].flatten(config, obj, flat) t.strictSame(flat, { retry: { [option]: 99 } }, msg) delete obj[config] } @@ -477,14 +448,14 @@ t.test('search options', t => { const msg = `${config} -> search.${option}` const flat = {} obj[config] = vals[option] - definitions[config].flatten(config, obj, flat) + mockDefs()[config].flatten(config, obj, flat) t.strictSame(flat, { search: { limit: 20, [option]: vals[option] } }, msg) delete obj[config] } const flat = {} obj.searchopts = 'a=b&b=c' - definitions.searchopts.flatten('searchopts', obj, flat) + mockDefs().searchopts.flatten('searchopts', obj, flat) t.strictSame(flat, { search: { limit: 20, @@ -502,7 +473,7 @@ t.test('search options', t => { t.test('noProxy - array', t => { const obj = { noproxy: ['1.2.3.4,2.3.4.5', '3.4.5.6'] } const flat = {} - definitions.noproxy.flatten('noproxy', obj, flat) + mockDefs().noproxy.flatten('noproxy', obj, flat) t.strictSame(flat, { noProxy: '1.2.3.4,2.3.4.5,3.4.5.6' }) t.end() }) @@ -510,7 +481,7 @@ t.test('noProxy - array', t => { t.test('noProxy - string', t => { const obj = { noproxy: '1.2.3.4,2.3.4.5,3.4.5.6' } const flat = {} - definitions.noproxy.flatten('noproxy', obj, flat) + mockDefs().noproxy.flatten('noproxy', obj, flat) t.strictSame(flat, { noProxy: '1.2.3.4,2.3.4.5,3.4.5.6' }) t.end() }) @@ -518,7 +489,7 @@ t.test('noProxy - string', t => { t.test('maxSockets', t => { const obj = { maxsockets: 123 } const flat = {} - definitions.maxsockets.flatten('maxsockets', obj, flat) + mockDefs().maxsockets.flatten('maxsockets', obj, flat) t.strictSame(flat, { maxSockets: 123 }) t.end() }) @@ -526,11 +497,11 @@ t.test('maxSockets', t => { t.test('scope', t => { const obj = { scope: 'asdf' } const flat = {} - definitions.scope.flatten('scope', obj, flat) + mockDefs().scope.flatten('scope', obj, flat) t.strictSame(flat, { scope: '@asdf', projectScope: '@asdf' }, 'prepend @ if needed') obj.scope = '@asdf' - definitions.scope.flatten('scope', obj, flat) + mockDefs().scope.flatten('scope', obj, flat) t.strictSame(flat, { scope: '@asdf', projectScope: '@asdf' }, 'leave untouched if has @') t.end() @@ -539,10 +510,10 @@ t.test('scope', t => { t.test('strictSSL', t => { const obj = { 'strict-ssl': false } const flat = {} - definitions['strict-ssl'].flatten('strict-ssl', obj, flat) + mockDefs()['strict-ssl'].flatten('strict-ssl', obj, flat) t.strictSame(flat, { strictSSL: false }) obj['strict-ssl'] = true - definitions['strict-ssl'].flatten('strict-ssl', obj, flat) + mockDefs()['strict-ssl'].flatten('strict-ssl', obj, flat) t.strictSame(flat, { strictSSL: true }) t.end() }) @@ -550,18 +521,18 @@ t.test('strictSSL', t => { t.test('shrinkwrap/package-lock', t => { const obj = { shrinkwrap: false } const flat = {} - definitions.shrinkwrap.flatten('shrinkwrap', obj, flat) + mockDefs().shrinkwrap.flatten('shrinkwrap', obj, flat) t.strictSame(flat, { packageLock: false }) obj.shrinkwrap = true - definitions.shrinkwrap.flatten('shrinkwrap', obj, flat) + mockDefs().shrinkwrap.flatten('shrinkwrap', obj, flat) t.strictSame(flat, { packageLock: true }) delete obj.shrinkwrap obj['package-lock'] = false - definitions['package-lock'].flatten('package-lock', obj, flat) + mockDefs()['package-lock'].flatten('package-lock', obj, flat) t.strictSame(flat, { packageLock: false }) obj['package-lock'] = true - definitions['package-lock'].flatten('package-lock', obj, flat) + mockDefs()['package-lock'].flatten('package-lock', obj, flat) t.strictSame(flat, { packageLock: true }) t.end() @@ -570,13 +541,13 @@ t.test('shrinkwrap/package-lock', t => { t.test('scriptShell', t => { const obj = { 'script-shell': null } const flat = {} - definitions['script-shell'].flatten('script-shell', obj, flat) + mockDefs()['script-shell'].flatten('script-shell', obj, flat) t.ok(Object.prototype.hasOwnProperty.call(flat, 'scriptShell'), 'should set it to undefined explicitly') t.strictSame(flat, { scriptShell: undefined }, 'no other fields') obj['script-shell'] = 'asdf' - definitions['script-shell'].flatten('script-shell', obj, flat) + mockDefs()['script-shell'].flatten('script-shell', obj, flat) t.strictSame(flat, { scriptShell: 'asdf' }, 'sets if not falsey') t.end() @@ -585,7 +556,7 @@ t.test('scriptShell', t => { t.test('defaultTag', t => { const obj = { tag: 'next' } const flat = {} - definitions.tag.flatten('tag', obj, flat) + mockDefs().tag.flatten('tag', obj, flat) t.strictSame(flat, { defaultTag: 'next' }) t.end() }) @@ -593,7 +564,7 @@ t.test('defaultTag', t => { t.test('timeout', t => { const obj = { 'fetch-timeout': 123 } const flat = {} - definitions['fetch-timeout'].flatten('fetch-timeout', obj, flat) + mockDefs()['fetch-timeout'].flatten('fetch-timeout', obj, flat) t.strictSame(flat, { timeout: 123 }) t.end() }) @@ -602,16 +573,16 @@ t.test('saveType', t => { t.test('save-prod', t => { const obj = { 'save-prod': false } const flat = {} - definitions['save-prod'].flatten('save-prod', obj, flat) + mockDefs()['save-prod'].flatten('save-prod', obj, flat) t.strictSame(flat, {}, 'no effect if false and missing') flat.saveType = 'prod' - definitions['save-prod'].flatten('save-prod', obj, flat) + mockDefs()['save-prod'].flatten('save-prod', obj, flat) t.strictSame(flat, {}, 'remove if false and set to prod') flat.saveType = 'dev' - definitions['save-prod'].flatten('save-prod', obj, flat) + mockDefs()['save-prod'].flatten('save-prod', obj, flat) t.strictSame(flat, { saveType: 'dev' }, 'ignore if false and not already prod') obj['save-prod'] = true - definitions['save-prod'].flatten('save-prod', obj, flat) + mockDefs()['save-prod'].flatten('save-prod', obj, flat) t.strictSame(flat, { saveType: 'prod' }, 'set to prod if true') t.end() }) @@ -619,17 +590,17 @@ t.test('saveType', t => { t.test('save-dev', t => { const obj = { 'save-dev': false } const flat = {} - definitions['save-dev'].flatten('save-dev', obj, flat) + mockDefs()['save-dev'].flatten('save-dev', obj, flat) t.strictSame(flat, {}, 'no effect if false and missing') flat.saveType = 'dev' - definitions['save-dev'].flatten('save-dev', obj, flat) + mockDefs()['save-dev'].flatten('save-dev', obj, flat) t.strictSame(flat, {}, 'remove if false and set to dev') flat.saveType = 'prod' obj['save-dev'] = false - definitions['save-dev'].flatten('save-dev', obj, flat) + mockDefs()['save-dev'].flatten('save-dev', obj, flat) t.strictSame(flat, { saveType: 'prod' }, 'ignore if false and not already dev') obj['save-dev'] = true - definitions['save-dev'].flatten('save-dev', obj, flat) + mockDefs()['save-dev'].flatten('save-dev', obj, flat) t.strictSame(flat, { saveType: 'dev' }, 'set to dev if true') t.end() }) @@ -637,16 +608,16 @@ t.test('saveType', t => { t.test('save-bundle', t => { const obj = { 'save-bundle': true } const flat = {} - definitions['save-bundle'].flatten('save-bundle', obj, flat) + mockDefs()['save-bundle'].flatten('save-bundle', obj, flat) t.strictSame(flat, { saveBundle: true }, 'set the saveBundle flag') obj['save-bundle'] = false - definitions['save-bundle'].flatten('save-bundle', obj, flat) + mockDefs()['save-bundle'].flatten('save-bundle', obj, flat) t.strictSame(flat, { saveBundle: false }, 'unset the saveBundle flag') obj['save-bundle'] = true obj['save-peer'] = true - definitions['save-bundle'].flatten('save-bundle', obj, flat) + mockDefs()['save-bundle'].flatten('save-bundle', obj, flat) t.strictSame(flat, { saveBundle: false }, 'false if save-peer is set') t.end() @@ -655,27 +626,27 @@ t.test('saveType', t => { t.test('save-peer', t => { const obj = { 'save-peer': false } const flat = {} - definitions['save-peer'].flatten('save-peer', obj, flat) + mockDefs()['save-peer'].flatten('save-peer', obj, flat) t.strictSame(flat, {}, 'no effect if false and not yet set') obj['save-peer'] = true - definitions['save-peer'].flatten('save-peer', obj, flat) + mockDefs()['save-peer'].flatten('save-peer', obj, flat) t.strictSame(flat, { saveType: 'peer' }, 'set saveType to peer if unset') flat.saveType = 'optional' - definitions['save-peer'].flatten('save-peer', obj, flat) + mockDefs()['save-peer'].flatten('save-peer', obj, flat) t.strictSame(flat, { saveType: 'peerOptional' }, 'set to peerOptional if optional already') - definitions['save-peer'].flatten('save-peer', obj, flat) + mockDefs()['save-peer'].flatten('save-peer', obj, flat) t.strictSame(flat, { saveType: 'peerOptional' }, 'no effect if already peerOptional') obj['save-peer'] = false - definitions['save-peer'].flatten('save-peer', obj, flat) + mockDefs()['save-peer'].flatten('save-peer', obj, flat) t.strictSame(flat, { saveType: 'optional' }, 'switch peerOptional to optional if false') obj['save-peer'] = false flat.saveType = 'peer' - definitions['save-peer'].flatten('save-peer', obj, flat) + mockDefs()['save-peer'].flatten('save-peer', obj, flat) t.strictSame(flat, {}, 'remove saveType if peer and setting false') t.end() @@ -684,26 +655,26 @@ t.test('saveType', t => { t.test('save-optional', t => { const obj = { 'save-optional': false } const flat = {} - definitions['save-optional'].flatten('save-optional', obj, flat) + mockDefs()['save-optional'].flatten('save-optional', obj, flat) t.strictSame(flat, {}, 'no effect if false and not yet set') obj['save-optional'] = true - definitions['save-optional'].flatten('save-optional', obj, flat) + mockDefs()['save-optional'].flatten('save-optional', obj, flat) t.strictSame(flat, { saveType: 'optional' }, 'set saveType to optional if unset') flat.saveType = 'peer' - definitions['save-optional'].flatten('save-optional', obj, flat) + mockDefs()['save-optional'].flatten('save-optional', obj, flat) t.strictSame(flat, { saveType: 'peerOptional' }, 'set to peerOptional if peer already') - definitions['save-optional'].flatten('save-optional', obj, flat) + mockDefs()['save-optional'].flatten('save-optional', obj, flat) t.strictSame(flat, { saveType: 'peerOptional' }, 'no effect if already peerOptional') obj['save-optional'] = false - definitions['save-optional'].flatten('save-optional', obj, flat) + mockDefs()['save-optional'].flatten('save-optional', obj, flat) t.strictSame(flat, { saveType: 'peer' }, 'switch peerOptional to peer if false') flat.saveType = 'optional' - definitions['save-optional'].flatten('save-optional', obj, flat) + mockDefs()['save-optional'].flatten('save-optional', obj, flat) t.strictSame(flat, {}, 'remove saveType if optional and setting false') t.end() @@ -729,13 +700,13 @@ YYYY\r const obj = {} const flat = {} - definitions.cafile.flatten('cafile', obj, flat) + mockDefs().cafile.flatten('cafile', obj, flat) t.strictSame(flat, {}, 'no effect if no cafile set') obj.cafile = resolve(path, 'no/cafile/here') - definitions.cafile.flatten('cafile', obj, flat) + mockDefs().cafile.flatten('cafile', obj, flat) t.strictSame(flat, {}, 'no effect if cafile not found') obj.cafile = cafile - definitions.cafile.flatten('cafile', obj, flat) + mockDefs().cafile.flatten('cafile', obj, flat) t.strictSame(flat, { ca: [ '-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----', @@ -744,7 +715,7 @@ YYYY\r }) t.test('error other than ENOENT gets thrown', t => { const poo = new Error('poo') - const defnReadFileThrows = t.mock(defpath, { + const defnReadFileThrows = mockDefs({ fs: { ...require('fs'), readFileSync: () => { @@ -760,10 +731,10 @@ YYYY\r }) t.test('detect CI', t => { - const defnNoCI = t.mock(defpath, { + const defnNoCI = mockDefs({ '@npmcli/ci-detect': () => false, }) - const defnCIFoo = t.mock(defpath, { + const defnCIFoo = mockDefs({ '@npmcli/ci-detect': () => 'foo', }) t.equal(defnNoCI['ci-name'].default, null, 'null when not in CI') @@ -773,39 +744,39 @@ t.test('detect CI', t => { t.test('user-agent', t => { const obj = { - 'user-agent': definitions['user-agent'].default, + 'user-agent': mockDefs()['user-agent'].default, 'npm-version': '1.2.3', 'node-version': '9.8.7', } const flat = {} const expectNoCI = `npm/1.2.3 node/9.8.7 ` + `${process.platform} ${process.arch} workspaces/false` - definitions['user-agent'].flatten('user-agent', obj, flat) + mockDefs()['user-agent'].flatten('user-agent', obj, flat) t.equal(flat.userAgent, expectNoCI) t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated') obj['ci-name'] = 'foo' - obj['user-agent'] = definitions['user-agent'].default + obj['user-agent'] = mockDefs()['user-agent'].default const expectCI = `${expectNoCI} ci/foo` - definitions['user-agent'].flatten('user-agent', obj, flat) + mockDefs()['user-agent'].flatten('user-agent', obj, flat) t.equal(flat.userAgent, expectCI) t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated') delete obj['ci-name'] obj.workspaces = true - obj['user-agent'] = definitions['user-agent'].default + obj['user-agent'] = mockDefs()['user-agent'].default const expectWorkspaces = expectNoCI.replace('workspaces/false', 'workspaces/true') - definitions['user-agent'].flatten('user-agent', obj, flat) + mockDefs()['user-agent'].flatten('user-agent', obj, flat) t.equal(flat.userAgent, expectWorkspaces) t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated') delete obj.workspaces obj.workspace = ['foo'] - obj['user-agent'] = definitions['user-agent'].default - definitions['user-agent'].flatten('user-agent', obj, flat) + obj['user-agent'] = mockDefs()['user-agent'].default + mockDefs()['user-agent'].flatten('user-agent', obj, flat) t.equal(flat.userAgent, expectWorkspaces) t.equal(process.env.npm_config_user_agent, flat.userAgent, 'npm_user_config environment is set') t.not(obj['user-agent'], flat.userAgent, 'config user-agent template is not translated') @@ -818,10 +789,10 @@ t.test('save-prefix', t => { 'save-prefix': '~1.2.3', } const flat = {} - definitions['save-prefix'] + mockDefs()['save-prefix'] .flatten('save-prefix', { ...obj, 'save-exact': true }, flat) t.strictSame(flat, { savePrefix: '' }) - definitions['save-prefix'] + mockDefs()['save-prefix'] .flatten('save-prefix', { ...obj, 'save-exact': false }, flat) t.strictSame(flat, { savePrefix: '~1.2.3' }) t.end() @@ -833,10 +804,10 @@ t.test('save-exact', t => { 'save-prefix': '~1.2.3', } const flat = {} - definitions['save-exact'] + mockDefs()['save-exact'] .flatten('save-exact', { ...obj, 'save-exact': true }, flat) t.strictSame(flat, { savePrefix: '' }) - definitions['save-exact'] + mockDefs()['save-exact'] .flatten('save-exact', { ...obj, 'save-exact': false }, flat) t.strictSame(flat, { savePrefix: '~1.2.3' }) t.end() @@ -849,8 +820,8 @@ t.test('location', t => { } const flat = {} // the global flattener is what sets location, so run that - definitions.global.flatten('global', obj, flat) - definitions.location.flatten('location', obj, flat) + mockDefs().global.flatten('global', obj, flat) + mockDefs().location.flatten('location', obj, flat) // global = true sets location in both places to global t.strictSame(flat, { global: true, location: 'global' }) // location here is still 'user' because flattening doesn't modify the object @@ -861,8 +832,8 @@ t.test('location', t => { delete flat.global delete flat.location - definitions.global.flatten('global', obj, flat) - definitions.location.flatten('location', obj, flat) + mockDefs().global.flatten('global', obj, flat) + mockDefs().location.flatten('location', obj, flat) // global = false leaves location unaltered t.strictSame(flat, { global: false, location: 'user' }) t.strictSame(obj, { global: false, location: 'user' }) @@ -876,16 +847,16 @@ t.test('package-lock-only', t => { } const flat = {} - definitions['package-lock-only'].flatten('package-lock-only', obj, flat) - definitions['package-lock'].flatten('package-lock', obj, flat) + mockDefs()['package-lock-only'].flatten('package-lock-only', obj, flat) + mockDefs()['package-lock'].flatten('package-lock', obj, flat) t.strictSame(flat, { packageLock: true, packageLockOnly: true }) obj['package-lock-only'] = false delete flat.packageLock delete flat.packageLockOnly - definitions['package-lock-only'].flatten('package-lock-only', obj, flat) - definitions['package-lock'].flatten('package-lock', obj, flat) + mockDefs()['package-lock-only'].flatten('package-lock-only', obj, flat) + mockDefs()['package-lock'].flatten('package-lock', obj, flat) t.strictSame(flat, { packageLock: false, packageLockOnly: false }) t.end() }) @@ -893,10 +864,10 @@ t.test('package-lock-only', t => { t.test('workspaces', t => { const obj = { workspaces: true, - 'user-agent': definitions['user-agent'].default, + 'user-agent': mockDefs()['user-agent'].default, } const flat = {} - definitions.workspaces.flatten('workspaces', obj, flat) + mockDefs().workspaces.flatten('workspaces', obj, flat) t.match(flat.userAgent, /workspaces\/true/) t.end() }) @@ -904,10 +875,10 @@ t.test('workspaces', t => { t.test('workspace', t => { const obj = { workspace: ['workspace-a'], - 'user-agent': definitions['user-agent'].default, + 'user-agent': mockDefs()['user-agent'].default, } const flat = {} - definitions.workspace.flatten('workspaces', obj, flat) + mockDefs().workspace.flatten('workspaces', obj, flat) t.match(flat.userAgent, /workspaces\/true/) t.end() }) @@ -915,23 +886,23 @@ t.test('workspace', t => { t.test('workspaces derived', t => { const obj = { workspaces: ['a'], - 'user-agent': definitions['user-agent'].default, + 'user-agent': mockDefs()['user-agent'].default, } const flat = {} - definitions.workspaces.flatten('workspaces', obj, flat) + mockDefs().workspaces.flatten('workspaces', obj, flat) t.equal(flat.workspacesEnabled, true) obj.workspaces = null - definitions.workspaces.flatten('workspaces', obj, flat) + mockDefs().workspaces.flatten('workspaces', obj, flat) t.equal(flat.workspacesEnabled, true) obj.workspaces = false - definitions.workspaces.flatten('workspaces', obj, flat) + mockDefs().workspaces.flatten('workspaces', obj, flat) t.equal(flat.workspacesEnabled, false) t.end() }) t.test('lockfile version', t => { const flat = {} - definitions['lockfile-version'].flatten('lockfile-version', { + mockDefs()['lockfile-version'].flatten('lockfile-version', { 'lockfile-version': '3', }, flat) t.match(flat.lockfileVersion, 3, 'flattens to a number') @@ -940,7 +911,7 @@ t.test('lockfile version', t => { t.test('loglevel silent', t => { const flat = {} - definitions.loglevel.flatten('loglevel', { + mockDefs().loglevel.flatten('loglevel', { loglevel: 'silent', }, flat) t.match(flat.silent, true, 'flattens to assign silent') diff --git a/test/lib/utils/config/describe-all.js b/test/lib/utils/config/describe-all.js deleted file mode 100644 index 814d92ac95970..0000000000000 --- a/test/lib/utils/config/describe-all.js +++ /dev/null @@ -1,6 +0,0 @@ -const t = require('tap') -const describeAll = require('../../../../lib/utils/config/describe-all.js') -// this basically ends up being a duplicate of the helpdoc dumped into -// a snapshot, but it verifies that we get the same help output on every -// platform where we run CI. -t.matchSnapshot(describeAll()) diff --git a/test/lib/utils/config/flatten.js b/test/lib/utils/config/flatten.js deleted file mode 100644 index 7e13563920888..0000000000000 --- a/test/lib/utils/config/flatten.js +++ /dev/null @@ -1,38 +0,0 @@ -const t = require('tap') -const flatten = require('../../../../lib/utils/config/flatten.js') - -require.main.filename = '/path/to/npm' -delete process.env.NODE -process.execPath = '/path/to/node' - -const obj = { - 'save-exact': true, - 'save-prefix': 'ignored', - 'save-dev': true, - '@foobar:registry': 'https://foo.bar.com/', - '//foo.bar.com:_authToken': 'foobarbazquuxasdf', - userconfig: '/path/to/.npmrc', -} - -const flat = flatten(obj) -t.strictSame(flat, { - saveType: 'dev', - savePrefix: '', - '@foobar:registry': 'https://foo.bar.com/', - '//foo.bar.com:_authToken': 'foobarbazquuxasdf', - npmBin: '/path/to/npm', - nodeBin: '/path/to/node', - hashAlgorithm: 'sha1', -}) - -// now flatten something else on top of it. -process.env.NODE = '/usr/local/bin/node.exe' -flatten({ 'save-dev': false }, flat) -t.strictSame(flat, { - savePrefix: '', - '@foobar:registry': 'https://foo.bar.com/', - '//foo.bar.com:_authToken': 'foobarbazquuxasdf', - npmBin: '/path/to/npm', - nodeBin: '/usr/local/bin/node.exe', - hashAlgorithm: 'sha1', -}) diff --git a/test/lib/utils/config/index.js b/test/lib/utils/config/index.js index 75d72e784fd89..90931a96d7aa2 100644 --- a/test/lib/utils/config/index.js +++ b/test/lib/utils/config/index.js @@ -1,24 +1,63 @@ const t = require('tap') const config = require('../../../../lib/utils/config/index.js') -const flatten = require('../../../../lib/utils/config/flatten.js') const definitions = require('../../../../lib/utils/config/definitions.js') -const describeAll = require('../../../../lib/utils/config/describe-all.js') -t.matchSnapshot(config.shorthands, 'shorthands') +const mockGlobals = require('../../../fixtures/mock-globals.js') -// just spot check a few of these to show that we got defaults assembled -t.match(config.defaults, { - registry: definitions.registry.default, - 'init-module': definitions['init-module'].default, +t.test('defaults', t => { + // just spot check a few of these to show that we got defaults assembled + t.match(config.defaults, { + registry: definitions.registry.default, + 'init-module': definitions['init-module'].default, + }) + + // is a getter, so changes are reflected + definitions.registry.default = 'https://example.com' + t.strictSame(config.defaults.registry, 'https://example.com') + + t.end() }) -// is a getter, so changes are reflected -definitions.registry.default = 'https://example.com' -t.strictSame(config.defaults.registry, 'https://example.com') +t.test('flatten', t => { + // cant use mockGlobals since its not a configurable property + require.main.filename = '/path/to/npm' + mockGlobals(t, { process: { execPath: '/path/to/node', 'env.NODE': undefined } }) + + const obj = { + 'save-exact': true, + 'save-prefix': 'ignored', + 'save-dev': true, + '@foobar:registry': 'https://foo.bar.com/', + '//foo.bar.com:_authToken': 'foobarbazquuxasdf', + userconfig: '/path/to/.npmrc', + } + + const flat = config.flatten(obj) + + t.strictSame(flat, { + saveType: 'dev', + savePrefix: '', + '@foobar:registry': 'https://foo.bar.com/', + '//foo.bar.com:_authToken': 'foobarbazquuxasdf', + npmBin: '/path/to/npm', + nodeBin: '/path/to/node', + hashAlgorithm: 'sha1', + }) + + mockGlobals(t, { + 'process.env.NODE': '/usr/local/bin/node.exe', + }) + + // now flatten something else on top of it. + config.flatten({ 'save-dev': false }, flat) + + t.strictSame(flat, { + savePrefix: '', + '@foobar:registry': 'https://foo.bar.com/', + '//foo.bar.com:_authToken': 'foobarbazquuxasdf', + npmBin: '/path/to/npm', + nodeBin: '/usr/local/bin/node.exe', + hashAlgorithm: 'sha1', + }) -t.strictSame(config, { - defaults: config.defaults, - shorthands: config.shorthands, - flatten, - definitions, - describeAll, + t.end() })