diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b79f775d350dd..6cbf5d3a40ee9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,9 @@ jobs: # Run the installer script - name: Install dependencies - run: node . install + run: | + node . install --ignore-scripts --no-audit + node . rebuild # Run the tests, but not if we're just gonna do coveralls later anyway - name: Run Tap tests diff --git a/AUTHORS b/AUTHORS index 2fa73c4ff081f..bda59af7eebcd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -726,3 +726,4 @@ Gareth Jones Jake Champion takenspc iraj +Michele Azzolari diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a22376cbc3dd..737562a876909 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,36 @@ +## 7.0.7 (2020-10-30) + +### BUG FIXES + +* [`3990b422d`](https://github.com/npm/cli/commit/3990b422d3ff63c54d96b61596bdb8f26a45ca7b) + [#2067](https://github.com/npm/cli/pull/2067) + use sh as default unix shell, not bash + ([@isaacs](https://github.com/isaacs)) +* [`81d6ceef6`](https://github.com/npm/cli/commit/81d6ceef6947e46355eb3ddb05a73da50870dfc1) + [#1975](https://github.com/npm/cli/issues/1975) + fix npm exec on folders missing package.json + ([@ruyadorno](https://github.com/ruyadorno)) +* [`2a680e91a`](https://github.com/npm/cli/commit/2a680e91a2be1f3f03a6fbd946f74628ee1cb370) + [#2083](https://github.com/npm/cli/pull/2083) + delete the contents of `node_modules` only in `npm ci` + ([@nlf](https://github.com/nlf)) +* [`2636fe1f4`](https://github.com/npm/cli/commit/2636fe1f45383cb1b6fc164564dc49318815db37) + [#2086](https://github.com/npm/cli/pull/2086) + disable banner output if loglevel is silent in `npm run-script` + ([@macno](https://github.com/macno)) + +### DEPENDENCIES + +* [`4156f053e`](https://github.com/npm/cli/commit/4156f053ee8712a4b53a210e62fba1e6562ba43a) + `@npmcli/run-script@1.7.4` + * restore the default `npm start` script +* [`1900ae9ad`](https://github.com/npm/cli/commit/1900ae9adecd227dd6f8b49de61a99c978ba89cf) + `@npmcli/promise-spawn@1.3.2` + * fix errors when processing scripts as root +* [`8cb0c166c`](https://github.com/npm/cli/commit/8cb0c166ccc019146a7a94d13c12723f001d2551) + `@npmcli/arborist@1.0.6` + * make sure missing bin links get set on reify + ## 7.0.6 (2020-10-27) ### BUG FIXES diff --git a/Makefile b/Makefile index 76880dd220faf..83046c59aca9b 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SHELL = bash PUBLISHTAG = $(shell node scripts/publish-tag.js) BRANCH = $(shell git rev-parse --abbrev-ref HEAD) -markdowns = $(shell find docs -name '*.md' | grep -v 'index') README.md +markdowns = $(shell find docs -name '*.md' | grep -v 'index') # these docs have the @VERSION@ tag in them, so they have to be rebuilt # whenever the package.json is touched, in case the version changed. @@ -14,8 +14,7 @@ version_mandocs = $(shell grep -rl '@VERSION@' docs/content \ cli_mandocs = $(shell find docs/content/commands -name '*.md' \ |sed 's|.md|.1|g' \ - |sed 's|docs/content/commands/|man/man1/|g' ) \ - man/man1/npm-README.1 + |sed 's|docs/content/commands/|man/man1/|g' ) files_mandocs = $(shell find docs/content/configuring-npm -name '*.md' \ |sed 's|.md|.5|g' \ @@ -29,63 +28,29 @@ mandocs = $(cli_mandocs) $(files_mandocs) $(misc_mandocs) all: docs -latest: - @echo "Installing latest published npm" - @echo "Use 'make install' or 'make link' to install the code" - @echo "in this folder that you're looking at right now." - node bin/npm-cli.js install -g -f npm ${NPMOPTS} - -install: all - node bin/npm-cli.js install -g -f ${NPMOPTS} $(shell node bin/npm-cli.js pack | tail -1) - -# backwards compat -dev: install - -link: uninstall - node bin/npm-cli.js link -f - -clean: markedclean marked-manclean docs-clean - rm -rf npmrc - node bin/npm-cli.js cache clean --force - -uninstall: - node bin/npm-cli.js rm npm -g -f +docs: mandocs htmldocs -mandocs: $(mandocs) +mandocs: dev-deps $(mandocs) $(version_mandocs): package.json -htmldocs: +htmldocs: dev-deps + node bin/npm-cli.js rebuild cd docs && node dockhand.js >&2 -docs: mandocs htmldocs - -markedclean: - rm -rf node_modules/marked node_modules/.bin/marked .building_marked - -marked-manclean: - rm -rf node_modules/marked-man node_modules/.bin/marked-man .building_marked-man +clean: docs-clean gitclean docsclean: docs-clean + docs-clean: - rm -rf \ - .building_marked \ - .building_marked-man \ - man \ - docs/node_modules \ - docs/output \ - docs/.cache - -## build-time tools for the documentation -build-doc-tools := node_modules/.bin/marked \ - node_modules/.bin/marked-man - -# use `npm install marked-man` for this to work. -man/man1/npm-README.1: README.md scripts/docs-build.js $(build-doc-tools) - @[ -d man/man1 ] || mkdir -p man/man1 - node scripts/docs-build.js $< $@ + rm -rf man -man/man1/%.1: docs/content/commands/%.md scripts/docs-build.js $(build-doc-tools) +## build-time dependencies for the documentation +dev-deps: + node bin/npm-cli.js install --only=dev --no-audit --ignore-scripts + +## targets for man files, these are encouraged to be only built by running `make docs` or `make mandocs` +man/man1/%.1: docs/content/commands/%.md scripts/docs-build.js @[ -d man/man1 ] || mkdir -p man/man1 node scripts/docs-build.js $< $@ @@ -95,47 +60,41 @@ man/man5/npm-json.5: man/man5/package.json.5 man/man5/npm-global.5: man/man5/folders.5 cp $< $@ -man/man5/%.5: docs/content/configuring-npm/%.md scripts/docs-build.js $(build-doc-tools) +man/man5/%.5: docs/content/configuring-npm/%.md scripts/docs-build.js @[ -d man/man5 ] || mkdir -p man/man5 node scripts/docs-build.js $< $@ -man/man7/%.7: docs/content/using-npm/%.md scripts/docs-build.js $(build-doc-tools) +man/man7/%.7: docs/content/using-npm/%.md scripts/docs-build.js @[ -d man/man7 ] || mkdir -p man/man7 node scripts/docs-build.js $< $@ -marked: node_modules/.bin/marked - -node_modules/.bin/marked: - node bin/npm-cli.js install marked --no-global --no-timing --no-save - -marked-man: node_modules/.bin/marked-man - -node_modules/.bin/marked-man: - node bin/npm-cli.js install marked-man --no-global --no-timing --no-save - -test: docs +test: dev-deps node bin/npm-cli.js test -tag: - node bin/npm-cli.js tag npm@$(PUBLISHTAG) latest - ls-ok: - node . ls >/dev/null + node . ls --production >/dev/null gitclean: git clean -fd -publish: gitclean ls-ok link docs-clean docs +uninstall: + node bin/npm-cli.js rm -g -f npm + +link: uninstall + node bin/npm-cli.js link -f --ignore-scripts + +prune: + node bin/npm-cli.js prune --production --no-save --no-audit + @[[ "$(shell git status -s)" != "" ]] && echo "ERR: found unpruned files" && exit 1 || echo "git status is clean" + + +publish: gitclean ls-ok link test docs-clean docs prune @git push origin :v$(shell node bin/npm-cli.js --no-timing -v) 2>&1 || true git push origin $(BRANCH) &&\ git push origin --tags &&\ node bin/npm-cli.js publish --tag=$(PUBLISHTAG) -release: gitclean ls-ok markedclean marked-manclean docs-clean docs - node bin/npm-cli.js prune --production --no-save +release: gitclean ls-ok docs-clean docs prune @bash scripts/release.sh -sandwich: - @[ $$(whoami) = "root" ] && (echo "ok"; echo "ham" > sandwich) || (echo "make it yourself" && exit 13) - -.PHONY: all latest install dev link docs clean uninstall test man docs-clean docsclean release ls-ok realclean +.PHONY: all latest install dev link docs clean uninstall test man docs-clean docsclean release ls-ok dev-deps prune diff --git a/lib/ci.js b/lib/ci.js index a0728f8a46467..a72e1c0cffba6 100644 --- a/lib/ci.js +++ b/lib/ci.js @@ -31,7 +31,7 @@ const ci = async () => { 'later to generate a package-lock.json file, then try again.' throw new Error(msg) }), - rimraf(`${where}/node_modules/`), + rimraf(`${where}/node_modules/*`, { glob: { dot: true, nosort: true, silent: true } }), ]) // npm ci should never modify the lockfile or package.json await arb.reify({ save: false }) diff --git a/lib/exec.js b/lib/exec.js index 96eb8190053f5..088a7c00eba31 100644 --- a/lib/exec.js +++ b/lib/exec.js @@ -65,6 +65,41 @@ const PATH = require('./utils/path.js') const cmd = (args, cb) => exec(args).then(() => cb()).catch(cb) +const run = async ({ args, call, pathArr }) => { + // turn list of args into command string + const script = call || args.map(escapeArg).join(' ').trim() + + // do the fakey runScript dance + // still should work if no package.json in cwd + const realPkg = await readPackageJson(`${npm.localPrefix}/package.json`) + .catch(() => ({})) + const pkg = { + ...realPkg, + scripts: { + ...(realPkg.scripts || {}), + npx: script, + }, + } + + npm.log.disableProgress() + try { + return await runScript({ + pkg, + banner: false, + // we always run in cwd, not --prefix + path: process.cwd(), + stdioString: true, + event: 'npx', + env: { + PATH: pathArr.join(delimiter), + }, + stdio: 'inherit', + }) + } finally { + npm.log.enableProgress() + } +} + const exec = async args => { const { package: packages, call } = npm.flatOptions @@ -89,17 +124,10 @@ const exec = async args => { } if (binExists) { - return await runScript({ - cmd: [args[0], ...args.slice(1).map(escapeArg)].join(' ').trim(), - banner: false, - // we always run in cwd, not --prefix - path: process.cwd(), - stdioString: true, - event: 'npx', - env: { - PATH: pathArr.join(delimiter), - }, - stdio: 'inherit', + return await run({ + args, + call: [args[0], ...args.slice(1).map(escapeArg)].join(' ').trim(), + pathArr, }) } @@ -129,9 +157,6 @@ const exec = async args => { if (needPackageCommandSwap) args[0] = getBinFromManifest(manis[0]) - // turn list of args into command string - const script = call || args.map(escapeArg).join(' ').trim() - // figure out whether we need to install stuff, or if local is fine const localArb = new Arborist({ ...npm.flatOptions, @@ -180,35 +205,7 @@ const exec = async args => { pathArr.unshift(resolve(installDir, 'node_modules/.bin')) } - // do the fakey runScript dance - // still should work if no package.json in cwd - const realPkg = await readPackageJson(`${npm.localPrefix}/package.json`) - .catch(() => ({})) - const pkg = { - ...realPkg, - scripts: { - ...(realPkg.scripts || {}), - npx: script, - }, - } - - npm.log.disableProgress() - try { - return await runScript({ - pkg, - banner: false, - // we always run in cwd, not --prefix - path: process.cwd(), - stdioString: true, - event: 'npx', - env: { - PATH: pathArr.join(delimiter), - }, - stdio: 'inherit', - }) - } finally { - npm.log.enableProgress() - } + return await run({ args, call, pathArr }) } const manifestMissing = (tree, mani) => { diff --git a/lib/run-script.js b/lib/run-script.js index 2802c54ba51a5..4d27e8eed965e 100644 --- a/lib/run-script.js +++ b/lib/run-script.js @@ -71,6 +71,7 @@ const runScript = async (args) => { stdio: 'inherit', stdioString: true, pkg, + banner: log.level !== 'silent', } for (const [event, args] of events) { diff --git a/lib/utils/config.js b/lib/utils/config.js index 9af6289ffa0f4..f9de6e9a79220 100644 --- a/lib/utils/config.js +++ b/lib/utils/config.js @@ -21,7 +21,7 @@ const editor = process.env.EDITOR || (isWindows ? 'notepad.exe' : 'vi') const shell = isWindows ? process.env.ComSpec || 'cmd' - : process.env.SHELL || 'bash' + : process.env.SHELL || 'sh' const { tmpdir, networkInterfaces } = require('os') const getLocalAddresses = () => { diff --git a/lib/utils/error-handler.js b/lib/utils/error-handler.js index 91bfe787a9584..dc9e2a26bcfa5 100644 --- a/lib/utils/error-handler.js +++ b/lib/utils/error-handler.js @@ -1,3 +1,5 @@ +'use strict' + let cbCalled = false const log = require('npmlog') const npm = require('../npm.js') @@ -6,6 +8,7 @@ const path = require('path') let wroteLogFile = false let exitCode = 0 const errorMessage = require('./error-message.js') +const replaceInfo = require('./replace-info.js') const stopMetrics = require('./metrics.js').stop const cacheFile = require('./cache-file.js') @@ -149,14 +152,15 @@ const errorHandler = (er) => { for (const k of ['type', 'stack', 'statusCode', 'pkgid']) { const v = er[k] if (v) - log.verbose(k, v) + log.verbose(k, replaceInfo(v)) } log.verbose('cwd', process.cwd()) const os = require('os') + const args = replaceInfo(process.argv) log.verbose('', os.type() + ' ' + os.release()) - log.verbose('argv', process.argv.map(JSON.stringify).join(' ')) + log.verbose('argv', args.map(JSON.stringify).join(' ')) log.verbose('node', process.version) log.verbose('npm ', 'v' + npm.version) diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js index 26dc7c3cb154d..04034243fb5e5 100644 --- a/lib/utils/error-message.js +++ b/lib/utils/error-message.js @@ -1,14 +1,22 @@ 'use strict' + const npm = require('../npm.js') const { format } = require('util') const { resolve } = require('path') const nameValidator = require('validate-npm-package-name') const npmlog = require('npmlog') +const replaceInfo = require('./replace-info.js') const { report: explainEresolve } = require('./explain-eresolve.js') module.exports = (er) => { const short = [] const detail = [] + + if (er.message) + er.message = replaceInfo(er.message) + if (er.stack) + er.stack = replaceInfo(er.stack) + switch (er.code) { case 'ERESOLVE': short.push(['ERESOLVE', er.message]) diff --git a/lib/utils/replace-info.js b/lib/utils/replace-info.js new file mode 100644 index 0000000000000..e3e324c885a06 --- /dev/null +++ b/lib/utils/replace-info.js @@ -0,0 +1,33 @@ +'use strict' + +const URL = require('url').URL + +// replaces auth info in an array of arguments or in a strings +function replaceInfo (arg) { + const isArray = Array.isArray(arg) + const isString = str => typeof str === 'string' + + if (!isArray && !isString(arg)) + return arg + + const testUrlAndReplace = str => { + try { + const url = new URL(str) + return url.password === '' ? str : str.replace(url.password, '***') + } catch (e) { + return str + } + } + + const args = isString(arg) ? arg.split(' ') : arg + const info = args.map(a => { + if (isString(a) && a.indexOf(' ') > -1) + return a.split(' ').map(testUrlAndReplace).join(' ') + + return testUrlAndReplace(a) + }) + + return isString(arg) ? info.join(' ') : info +} + +module.exports = replaceInfo diff --git a/node_modules/@npmcli/arborist/lib/diff.js b/node_modules/@npmcli/arborist/lib/diff.js index 2e70234b50c7f..1864a3ea10b67 100644 --- a/node_modules/@npmcli/arborist/lib/diff.js +++ b/node_modules/@npmcli/arborist/lib/diff.js @@ -6,6 +6,7 @@ // for a given branch of the tree being mutated. const {depth} = require('treeverse') +const {existsSync} = require('fs') const ssri = require('ssri') @@ -37,25 +38,35 @@ class Diff { } } -const getAction = ({actual, ideal}) => - !ideal ? 'REMOVE' +const getAction = ({actual, ideal}) => { + if (!ideal) + return 'REMOVE' + // bundled meta-deps are copied over to the ideal tree when we visit it, // so they'll appear to be missing here. There's no need to handle them // in the diff, though, because they'll be replaced at reify time anyway // Otherwise, add the missing node. - : !actual ? (ideal.inDepBundle ? null : 'ADD') + if (!actual) + return ideal.inDepBundle ? null : 'ADD' + // always ignore the root node - : ideal.isRoot && actual.isRoot || + if (ideal.isRoot && actual.isRoot) + return null + + const binsExist = ideal.binPaths.every((path) => existsSync(path)) + // top nodes, links, and git deps won't have integrity, but do have resolved - !ideal.integrity && !actual.integrity && - ideal.resolved === actual.resolved || + if (!ideal.integrity && !actual.integrity && ideal.resolved === actual.resolved && binsExist) + return null + // otherwise, verify that it's the same bits // note that if ideal has integrity, and resolved doesn't, we treat // that as a 'change', so that it gets re-fetched and locked down. - ideal.integrity && - actual.integrity && - ssri.parse(ideal.integrity).match(actual.integrity) ? null - : 'CHANGE' + if (!ideal.integrity || !actual.integrity || !ssri.parse(ideal.integrity).match(actual.integrity) || !binsExist) + return 'CHANGE' + + return null +} const allChildren = node => { if (!node) diff --git a/node_modules/@npmcli/arborist/package.json b/node_modules/@npmcli/arborist/package.json index ff6abb29e40b7..73c6ce58d2839 100644 --- a/node_modules/@npmcli/arborist/package.json +++ b/node_modules/@npmcli/arborist/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/arborist", - "version": "1.0.5", + "version": "1.0.6", "description": "Manage node_modules trees", "dependencies": { "@npmcli/installed-package-contents": "^1.0.5", diff --git a/node_modules/@npmcli/promise-spawn/index.js b/node_modules/@npmcli/promise-spawn/index.js index cc73d1dad6b07..6ad51b8e08ccf 100644 --- a/node_modules/@npmcli/promise-spawn/index.js +++ b/node_modules/@npmcli/promise-spawn/index.js @@ -11,18 +11,13 @@ const isPipe = (stdio = 'pipe', fd) => const promiseSpawn = (cmd, args, opts, extra = {}) => { const cwd = opts.cwd || process.cwd() const isRoot = process.getuid && process.getuid() === 0 - return !isRoot ? promiseSpawnUid(cmd, args, { - ...opts, - cwd, - uid: undefined, - gid: undefined, - }, extra) - : inferOwner(cwd).then(({uid, gid}) => promiseSpawnUid(cmd, args, { + const { uid, gid } = isRoot ? inferOwner.sync(cwd) : {} + return promiseSpawnUid(cmd, args, { ...opts, cwd, uid, - gid, - }, extra)) + gid + }, extra) } const stdioResult = (stdout, stderr, {stdioString, stdio}) => diff --git a/node_modules/@npmcli/promise-spawn/package.json b/node_modules/@npmcli/promise-spawn/package.json index d640c9457d2d4..be7342f56a0d8 100644 --- a/node_modules/@npmcli/promise-spawn/package.json +++ b/node_modules/@npmcli/promise-spawn/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/promise-spawn", - "version": "1.3.1", + "version": "1.3.2", "files": [ "index.js" ], diff --git a/node_modules/@npmcli/run-script/lib/is-server-package.js b/node_modules/@npmcli/run-script/lib/is-server-package.js new file mode 100644 index 0000000000000..667a3c4f2c3ea --- /dev/null +++ b/node_modules/@npmcli/run-script/lib/is-server-package.js @@ -0,0 +1,10 @@ +const { stat } = require('fs').promises +const { resolve } = require('path') +module.exports = async path => { + try { + const st = await stat(resolve(path, 'server.js')) + return st.isFile() + } catch (er) { + return false + } +} diff --git a/node_modules/@npmcli/run-script/lib/run-script-pkg.js b/node_modules/@npmcli/run-script/lib/run-script-pkg.js index e7d7368beded6..5980376f558f4 100644 --- a/node_modules/@npmcli/run-script/lib/run-script-pkg.js +++ b/node_modules/@npmcli/run-script/lib/run-script-pkg.js @@ -3,6 +3,7 @@ const promiseSpawn = require('@npmcli/promise-spawn') const packageEnvs = require('./package-envs.js') const { isNodeGypPackage, defaultGypInstallScript } = require('@npmcli/node-gyp') const signalManager = require('./signal-manager.js') +const isServerPackage = require('./is-server-package.js') // you wouldn't like me when I'm angry... const bruce = (id, event, cmd) => `\n> ${id ? id + ' ' : ''}${event}\n> ${cmd}\n` @@ -35,6 +36,8 @@ const runScriptPkg = async options => { await isNodeGypPackage(path) ) cmd = defaultGypInstallScript + else if (event === 'start' && await isServerPackage(path)) + cmd = 'node server.js' + args.map(a => ` ${JSON.stringify(a)}`).join('') if (!cmd) return { code: 0, signal: null } diff --git a/node_modules/@npmcli/run-script/lib/signal-manager.js b/node_modules/@npmcli/run-script/lib/signal-manager.js index 30627e5dad4b8..556e758c254f0 100644 --- a/node_modules/@npmcli/run-script/lib/signal-manager.js +++ b/node_modules/@npmcli/run-script/lib/signal-manager.js @@ -33,8 +33,7 @@ const add = proc => { if (!handlersInstalled) setupListeners() - proc.once('exit', ({ code }) => { - process.exitCode = process.exitCode || code + proc.once('exit', () => { runningProcs.delete(proc) cleanupListeners() }) diff --git a/node_modules/@npmcli/run-script/package.json b/node_modules/@npmcli/run-script/package.json index 3a1598fad12f1..5ec3bb5b66876 100644 --- a/node_modules/@npmcli/run-script/package.json +++ b/node_modules/@npmcli/run-script/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/run-script", - "version": "1.7.3", + "version": "1.7.4", "description": "Run a lifecycle script for a package (descendant of npm-lifecycle)", "author": "Isaac Z. Schlueter (https://izs.me)", "license": "ISC", diff --git a/node_modules/is-stream/index.js b/node_modules/is-stream/index.js deleted file mode 100644 index 6f7ec91a4014b..0000000000000 --- a/node_modules/is-stream/index.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -var isStream = module.exports = function (stream) { - return stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function'; -}; - -isStream.writable = function (stream) { - return isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object'; -}; - -isStream.readable = function (stream) { - return isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object'; -}; - -isStream.duplex = function (stream) { - return isStream.writable(stream) && isStream.readable(stream); -}; - -isStream.transform = function (stream) { - return isStream.duplex(stream) && typeof stream._transform === 'function' && typeof stream._transformState === 'object'; -}; diff --git a/node_modules/is-stream/license b/node_modules/is-stream/license deleted file mode 100644 index 654d0bfe94343..0000000000000 --- a/node_modules/is-stream/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/is-stream/package.json b/node_modules/is-stream/package.json deleted file mode 100644 index 0308918d09e59..0000000000000 --- a/node_modules/is-stream/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "is-stream", - "version": "1.1.0", - "description": "Check if something is a Node.js stream", - "license": "MIT", - "repository": "sindresorhus/is-stream", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "index.js" - ], - "keywords": [ - "stream", - "type", - "streams", - "writable", - "readable", - "duplex", - "transform", - "check", - "detect", - "is" - ], - "devDependencies": { - "ava": "*", - "tempfile": "^1.1.0", - "xo": "*" - } -} diff --git a/node_modules/is-stream/readme.md b/node_modules/is-stream/readme.md deleted file mode 100644 index d8afce81d216e..0000000000000 --- a/node_modules/is-stream/readme.md +++ /dev/null @@ -1,42 +0,0 @@ -# is-stream [![Build Status](https://travis-ci.org/sindresorhus/is-stream.svg?branch=master)](https://travis-ci.org/sindresorhus/is-stream) - -> Check if something is a [Node.js stream](https://nodejs.org/api/stream.html) - - -## Install - -``` -$ npm install --save is-stream -``` - - -## Usage - -```js -const fs = require('fs'); -const isStream = require('is-stream'); - -isStream(fs.createReadStream('unicorn.png')); -//=> true - -isStream({}); -//=> false -``` - - -## API - -### isStream(stream) - -#### isStream.writable(stream) - -#### isStream.readable(stream) - -#### isStream.duplex(stream) - -#### isStream.transform(stream) - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/json-parse-better-errors/CHANGELOG.md b/node_modules/json-parse-better-errors/CHANGELOG.md deleted file mode 100644 index b1d212de43908..0000000000000 --- a/node_modules/json-parse-better-errors/CHANGELOG.md +++ /dev/null @@ -1,46 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. - - -## [1.0.2](https://github.com/zkat/json-parse-better-errors/compare/v1.0.1...v1.0.2) (2018-03-30) - - -### Bug Fixes - -* **messages:** More friendly messages for non-string ([#1](https://github.com/zkat/json-parse-better-errors/issues/1)) ([a476d42](https://github.com/zkat/json-parse-better-errors/commit/a476d42)) - - - - -## [1.0.1](https://github.com/zkat/json-parse-better-errors/compare/v1.0.0...v1.0.1) (2017-08-16) - - -### Bug Fixes - -* **license:** oops. Forgot to update license.md ([efe2958](https://github.com/zkat/json-parse-better-errors/commit/efe2958)) - - - - -# 1.0.0 (2017-08-15) - - -### Features - -* **init:** Initial Commit ([562c977](https://github.com/zkat/json-parse-better-errors/commit/562c977)) - - -### BREAKING CHANGES - -* **init:** This is the first commit! - - - - -# 0.1.0 (2017-08-15) - - -### Features - -* **init:** Initial Commit ([9dd1a19](https://github.com/zkat/json-parse-better-errors/commit/9dd1a19)) diff --git a/node_modules/json-parse-better-errors/LICENSE.md b/node_modules/json-parse-better-errors/LICENSE.md deleted file mode 100644 index c51842cc4ab3c..0000000000000 --- a/node_modules/json-parse-better-errors/LICENSE.md +++ /dev/null @@ -1,7 +0,0 @@ -Copyright 2017 Kat Marchán - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/json-parse-better-errors/README.md b/node_modules/json-parse-better-errors/README.md deleted file mode 100644 index a1f0f0a592ad3..0000000000000 --- a/node_modules/json-parse-better-errors/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# json-parse-better-errors [![npm version](https://img.shields.io/npm/v/json-parse-better-errors.svg)](https://npm.im/json-parse-better-errors) [![license](https://img.shields.io/npm/l/json-parse-better-errors.svg)](https://npm.im/json-parse-better-errors) [![Travis](https://img.shields.io/travis/zkat/json-parse-better-errors.svg)](https://travis-ci.org/zkat/json-parse-better-errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/json-parse-better-errors?svg=true)](https://ci.appveyor.com/project/zkat/json-parse-better-errors) [![Coverage Status](https://coveralls.io/repos/github/zkat/json-parse-better-errors/badge.svg?branch=latest)](https://coveralls.io/github/zkat/json-parse-better-errors?branch=latest) - -[`json-parse-better-errors`](https://github.com/zkat/json-parse-better-errors) is a Node.js library for -getting nicer errors out of `JSON.parse()`, including context and position of the parse errors. - -## Install - -`$ npm install --save json-parse-better-errors` - -## Table of Contents - -* [Example](#example) -* [Features](#features) -* [Contributing](#contributing) -* [API](#api) - * [`parse`](#parse) - -### Example - -```javascript -const parseJson = require('json-parse-better-errors') - -parseJson('"foo"') -parseJson('garbage') // more useful error message -``` - -### Features - -* Like JSON.parse, but the errors are better. - -### Contributing - -The npm team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The [Contributor Guide](CONTRIBUTING.md) has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear. - -All participants and maintainers in this project are expected to follow [Code of Conduct](CODE_OF_CONDUCT.md), and just generally be excellent to each other. - -Please refer to the [Changelog](CHANGELOG.md) for project history details, too. - -Happy hacking! - -### API - -#### `> parse(txt, ?reviver, ?context=20)` - -Works just like `JSON.parse`, but will include a bit more information when an -error happens. diff --git a/node_modules/json-parse-better-errors/index.js b/node_modules/json-parse-better-errors/index.js deleted file mode 100644 index 14644c2f1a813..0000000000000 --- a/node_modules/json-parse-better-errors/index.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict' - -module.exports = parseJson -function parseJson (txt, reviver, context) { - context = context || 20 - try { - return JSON.parse(txt, reviver) - } catch (e) { - if (typeof txt !== 'string') { - const isEmptyArray = Array.isArray(txt) && txt.length === 0 - const errorMessage = 'Cannot parse ' + - (isEmptyArray ? 'an empty array' : String(txt)) - throw new TypeError(errorMessage) - } - const syntaxErr = e.message.match(/^Unexpected token.*position\s+(\d+)/i) - const errIdx = syntaxErr - ? +syntaxErr[1] - : e.message.match(/^Unexpected end of JSON.*/i) - ? txt.length - 1 - : null - if (errIdx != null) { - const start = errIdx <= context - ? 0 - : errIdx - context - const end = errIdx + context >= txt.length - ? txt.length - : errIdx + context - e.message += ` while parsing near '${ - start === 0 ? '' : '...' - }${txt.slice(start, end)}${ - end === txt.length ? '' : '...' - }'` - } else { - e.message += ` while parsing '${txt.slice(0, context * 2)}'` - } - throw e - } -} diff --git a/node_modules/json-parse-better-errors/package.json b/node_modules/json-parse-better-errors/package.json deleted file mode 100644 index c4c2c20a68c17..0000000000000 --- a/node_modules/json-parse-better-errors/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "json-parse-better-errors", - "version": "1.0.2", - "description": "JSON.parse with context information on error", - "main": "index.js", - "files": [ - "*.js" - ], - "scripts": { - "prerelease": "npm t", - "postrelease": "npm publish && git push --follow-tags", - "pretest": "standard", - "release": "standard-version -s", - "test": "tap -J --coverage test/*.js", - "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", - "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" - }, - "repository": "https://github.com/zkat/json-parse-better-errors", - "keywords": [ - "JSON", - "parser" - ], - "author": { - "name": "Kat Marchán", - "email": "kzm@zkat.tech", - "twitter": "maybekatz" - }, - "license": "MIT", - "devDependencies": { - "nyc": "^10.3.2", - "standard": "^9.0.2", - "standard-version": "^4.1.0", - "tap": "^10.3.3", - "weallbehave": "^1.2.0", - "weallcontribute": "^1.0.8" - }, - "config": { - "nyc": { - "exclude": [ - "node_modules/**", - "test/**" - ] - } - } -} diff --git a/node_modules/os-homedir/index.js b/node_modules/os-homedir/index.js deleted file mode 100644 index 33066166fe669..0000000000000 --- a/node_modules/os-homedir/index.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -var os = require('os'); - -function homedir() { - var env = process.env; - var home = env.HOME; - var user = env.LOGNAME || env.USER || env.LNAME || env.USERNAME; - - if (process.platform === 'win32') { - return env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || home || null; - } - - if (process.platform === 'darwin') { - return home || (user ? '/Users/' + user : null); - } - - if (process.platform === 'linux') { - return home || (process.getuid() === 0 ? '/root' : (user ? '/home/' + user : null)); - } - - return home || null; -} - -module.exports = typeof os.homedir === 'function' ? os.homedir : homedir; diff --git a/node_modules/os-homedir/license b/node_modules/os-homedir/license deleted file mode 100644 index 654d0bfe94343..0000000000000 --- a/node_modules/os-homedir/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/os-homedir/package.json b/node_modules/os-homedir/package.json deleted file mode 100644 index 525b225172f2e..0000000000000 --- a/node_modules/os-homedir/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "os-homedir", - "version": "1.0.2", - "description": "Node.js 4 `os.homedir()` ponyfill", - "license": "MIT", - "repository": "sindresorhus/os-homedir", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "index.js" - ], - "keywords": [ - "builtin", - "core", - "ponyfill", - "polyfill", - "shim", - "os", - "homedir", - "home", - "dir", - "directory", - "folder", - "user", - "path" - ], - "devDependencies": { - "ava": "*", - "path-exists": "^2.0.0", - "xo": "^0.16.0" - } -} diff --git a/node_modules/os-homedir/readme.md b/node_modules/os-homedir/readme.md deleted file mode 100644 index 856ae615b0c0b..0000000000000 --- a/node_modules/os-homedir/readme.md +++ /dev/null @@ -1,31 +0,0 @@ -# os-homedir [![Build Status](https://travis-ci.org/sindresorhus/os-homedir.svg?branch=master)](https://travis-ci.org/sindresorhus/os-homedir) - -> Node.js 4 [`os.homedir()`](https://nodejs.org/api/os.html#os_os_homedir) [ponyfill](https://ponyfill.com) - - -## Install - -``` -$ npm install --save os-homedir -``` - - -## Usage - -```js -const osHomedir = require('os-homedir'); - -console.log(osHomedir()); -//=> '/Users/sindresorhus' -``` - - -## Related - -- [user-home](https://github.com/sindresorhus/user-home) - Same as this module but caches the result -- [home-or-tmp](https://github.com/sindresorhus/home-or-tmp) - Get the user home directory with fallback to the system temp directory - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/pseudomap/LICENSE b/node_modules/pseudomap/LICENSE deleted file mode 100644 index 19129e315fe59..0000000000000 --- a/node_modules/pseudomap/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and Contributors - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/pseudomap/README.md b/node_modules/pseudomap/README.md deleted file mode 100644 index 778bf01dfaaf9..0000000000000 --- a/node_modules/pseudomap/README.md +++ /dev/null @@ -1,60 +0,0 @@ -# pseudomap - -A thing that is a lot like ES6 `Map`, but without iterators, for use -in environments where `for..of` syntax and `Map` are not available. - -If you need iterators, or just in general a more faithful polyfill to -ES6 Maps, check out [es6-map](http://npm.im/es6-map). - -If you are in an environment where `Map` is supported, then that will -be returned instead, unless `process.env.TEST_PSEUDOMAP` is set. - -You can use any value as keys, and any value as data. Setting again -with the identical key will overwrite the previous value. - -Internally, data is stored on an `Object.create(null)` style object. -The key is coerced to a string to generate the key on the internal -data-bag object. The original key used is stored along with the data. - -In the event of a stringified-key collision, a new key is generated by -appending an increasing number to the stringified-key until finding -either the intended key or an empty spot. - -Note that because object traversal order of plain objects is not -guaranteed to be identical to insertion order, the insertion order -guarantee of `Map.prototype.forEach` is not guaranteed in this -implementation. However, in all versions of Node.js and V8 where this -module works, `forEach` does traverse data in insertion order. - -## API - -Most of the [Map -API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map), -with the following exceptions: - -1. A `Map` object is not an iterator. -2. `values`, `keys`, and `entries` methods are not implemented, - because they return iterators. -3. The argument to the constructor can be an Array of `[key, value]` - pairs, or a `Map` or `PseudoMap` object. But, since iterators - aren't used, passing any plain-old iterator won't initialize the - map properly. - -## USAGE - -Use just like a regular ES6 Map. - -```javascript -var PseudoMap = require('pseudomap') - -// optionally provide a pseudomap, or an array of [key,value] pairs -// as the argument to initialize the map with -var myMap = new PseudoMap() - -myMap.set(1, 'number 1') -myMap.set('1', 'string 1') -var akey = {} -var bkey = {} -myMap.set(akey, { some: 'data' }) -myMap.set(bkey, { some: 'other data' }) -``` diff --git a/node_modules/pseudomap/map.js b/node_modules/pseudomap/map.js deleted file mode 100644 index 7db15994612fd..0000000000000 --- a/node_modules/pseudomap/map.js +++ /dev/null @@ -1,9 +0,0 @@ -if (process.env.npm_package_name === 'pseudomap' && - process.env.npm_lifecycle_script === 'test') - process.env.TEST_PSEUDOMAP = 'true' - -if (typeof Map === 'function' && !process.env.TEST_PSEUDOMAP) { - module.exports = Map -} else { - module.exports = require('./pseudomap') -} diff --git a/node_modules/pseudomap/package.json b/node_modules/pseudomap/package.json deleted file mode 100644 index 4b02ab7c78880..0000000000000 --- a/node_modules/pseudomap/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "pseudomap", - "version": "1.0.2", - "description": "A thing that is a lot like ES6 `Map`, but without iterators, for use in environments where `for..of` syntax and `Map` are not available.", - "main": "map.js", - "directories": { - "test": "test" - }, - "devDependencies": { - "tap": "^2.3.1" - }, - "scripts": { - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/isaacs/pseudomap.git" - }, - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", - "license": "ISC", - "bugs": { - "url": "https://github.com/isaacs/pseudomap/issues" - }, - "homepage": "https://github.com/isaacs/pseudomap#readme" -} diff --git a/node_modules/pseudomap/pseudomap.js b/node_modules/pseudomap/pseudomap.js deleted file mode 100644 index 25a21d829e8b3..0000000000000 --- a/node_modules/pseudomap/pseudomap.js +++ /dev/null @@ -1,113 +0,0 @@ -var hasOwnProperty = Object.prototype.hasOwnProperty - -module.exports = PseudoMap - -function PseudoMap (set) { - if (!(this instanceof PseudoMap)) // whyyyyyyy - throw new TypeError("Constructor PseudoMap requires 'new'") - - this.clear() - - if (set) { - if ((set instanceof PseudoMap) || - (typeof Map === 'function' && set instanceof Map)) - set.forEach(function (value, key) { - this.set(key, value) - }, this) - else if (Array.isArray(set)) - set.forEach(function (kv) { - this.set(kv[0], kv[1]) - }, this) - else - throw new TypeError('invalid argument') - } -} - -PseudoMap.prototype.forEach = function (fn, thisp) { - thisp = thisp || this - Object.keys(this._data).forEach(function (k) { - if (k !== 'size') - fn.call(thisp, this._data[k].value, this._data[k].key) - }, this) -} - -PseudoMap.prototype.has = function (k) { - return !!find(this._data, k) -} - -PseudoMap.prototype.get = function (k) { - var res = find(this._data, k) - return res && res.value -} - -PseudoMap.prototype.set = function (k, v) { - set(this._data, k, v) -} - -PseudoMap.prototype.delete = function (k) { - var res = find(this._data, k) - if (res) { - delete this._data[res._index] - this._data.size-- - } -} - -PseudoMap.prototype.clear = function () { - var data = Object.create(null) - data.size = 0 - - Object.defineProperty(this, '_data', { - value: data, - enumerable: false, - configurable: true, - writable: false - }) -} - -Object.defineProperty(PseudoMap.prototype, 'size', { - get: function () { - return this._data.size - }, - set: function (n) {}, - enumerable: true, - configurable: true -}) - -PseudoMap.prototype.values = -PseudoMap.prototype.keys = -PseudoMap.prototype.entries = function () { - throw new Error('iterators are not implemented in this version') -} - -// Either identical, or both NaN -function same (a, b) { - return a === b || a !== a && b !== b -} - -function Entry (k, v, i) { - this.key = k - this.value = v - this._index = i -} - -function find (data, k) { - for (var i = 0, s = '_' + k, key = s; - hasOwnProperty.call(data, key); - key = s + i++) { - if (same(data[key].key, k)) - return data[key] - } -} - -function set (data, k, v) { - for (var i = 0, s = '_' + k, key = s; - hasOwnProperty.call(data, key); - key = s + i++) { - if (same(data[key].key, k)) { - data[key].value = v - return - } - } - data.size++ - data[key] = new Entry(k, v, key) -} diff --git a/node_modules/pseudomap/test/basic.js b/node_modules/pseudomap/test/basic.js deleted file mode 100644 index 4378e4541e9a1..0000000000000 --- a/node_modules/pseudomap/test/basic.js +++ /dev/null @@ -1,86 +0,0 @@ -var t = require('tap') - -process.env.TEST_PSEUDOMAP = 'true' - -var PM = require('../') -runTests(PM) - -// if possible, verify that Map also behaves the same way -if (typeof Map === 'function') - runTests(Map) - - -function runTests (Map) { - t.throws(Map) - - var m = new Map() - - t.equal(m.size, 0) - - m.set(1, '1 string') - t.equal(m.get(1), '1 string') - t.equal(m.size, 1) - m.size = 1000 - t.equal(m.size, 1) - m.size = 0 - t.equal(m.size, 1) - - m = new Map([[1, 'number 1'], ['1', 'string 1']]) - t.equal(m.get(1), 'number 1') - t.equal(m.get('1'), 'string 1') - t.equal(m.size, 2) - - m = new Map(m) - t.equal(m.get(1), 'number 1') - t.equal(m.get('1'), 'string 1') - t.equal(m.size, 2) - - var akey = {} - var bkey = {} - m.set(akey, { some: 'data' }) - m.set(bkey, { some: 'other data' }) - t.same(m.get(akey), { some: 'data' }) - t.same(m.get(bkey), { some: 'other data' }) - t.equal(m.size, 4) - - var x = /x/ - var y = /x/ - m.set(x, 'x regex') - m.set(y, 'y regex') - t.equal(m.get(x), 'x regex') - m.set(x, 'x again') - t.equal(m.get(x), 'x again') - t.equal(m.size, 6) - - m.set(NaN, 'not a number') - t.equal(m.get(NaN), 'not a number') - m.set(NaN, 'it is a ' + typeof NaN) - t.equal(m.get(NaN), 'it is a number') - m.set('NaN', 'stringie nan') - t.equal(m.get(NaN), 'it is a number') - t.equal(m.get('NaN'), 'stringie nan') - t.equal(m.size, 8) - - m.delete(NaN) - t.equal(m.get(NaN), undefined) - t.equal(m.size, 7) - - var expect = [ - { value: 'number 1', key: 1 }, - { value: 'string 1', key: '1' }, - { value: { some: 'data' }, key: {} }, - { value: { some: 'other data' }, key: {} }, - { value: 'x again', key: /x/ }, - { value: 'y regex', key: /x/ }, - { value: 'stringie nan', key: 'NaN' } - ] - var actual = [] - - m.forEach(function (value, key) { - actual.push({ value: value, key: key }) - }) - t.same(actual, expect) - - m.clear() - t.equal(m.size, 0) -} diff --git a/package-lock.json b/package-lock.json index b33c5011e2bc2..5edc6bf17767e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "npm", - "version": "7.0.6", + "version": "7.0.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "npm", - "version": "7.0.6", + "version": "7.0.7", "bundleDependencies": [ "@npmcli/arborist", "@npmcli/ci-detect", @@ -78,10 +78,10 @@ ], "license": "Artistic-2.0", "dependencies": { - "@npmcli/arborist": "^1.0.4", + "@npmcli/arborist": "^1.0.6", "@npmcli/ci-detect": "^1.2.0", "@npmcli/config": "^1.2.1", - "@npmcli/run-script": "^1.7.0", + "@npmcli/run-script": "^1.7.4", "abbrev": "~1.1.1", "ansicolors": "~0.3.2", "ansistyles": "~0.1.3", @@ -152,7 +152,7 @@ }, "devDependencies": { "cmark-gfm": "^0.8.3", - "eslint": "^7.11.0", + "eslint": "^7.12.1", "eslint-plugin-import": "^2.22.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1", @@ -365,9 +365,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz", - "integrity": "sha512-4YVwPkANLeNtRjMekzux1ci8hIaH5eGKktGqR0d3LWsKNn5B2X/1Z6Trxy7jQXl9EBGE6Yj02O+t09FMeRllaA==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.2.1.tgz", + "integrity": "sha512-XRUeBZ5zBWLYgSANMpThFddrZZkEbGHgUdt5UJjZfnlN9BGCiUBrf+nvbRupSjMvqzwnQN0qwCmOxITt1cfywA==", "dev": true, "dependencies": { "ajv": "^6.12.4", @@ -386,9 +386,9 @@ } }, "node_modules/@npmcli/arborist": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.5.tgz", - "integrity": "sha512-VK3VqSxnk5muyMB5zIIg12EsmV0COBKpBE8wQ/s85O02nh4N1suUxuf9nbgFonsi+D8uN4DO6qtdQ4FtN6i6+A==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.6.tgz", + "integrity": "sha512-Hj5QxT1/BIU5HMb3sSOCV81trhc6sqT1FaCdXPM+YjZPLpQsO3UFKWAGuDknDcNyx1mVT0IA1nlmrjhGGXDDtQ==", "inBundle": true, "dependencies": { "@npmcli/installed-package-contents": "^1.0.5", @@ -515,18 +515,18 @@ "license": "ISC" }, "node_modules/@npmcli/promise-spawn": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-1.3.1.tgz", - "integrity": "sha512-S+I+ADqj66+ZpmmmvWXdNQkVyvikMYm/yrlk7xzoF6qf8AqL26yLwaxn0/ZTB0r3j1pur8Q/lyxL8yg4fZI76A==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-1.3.2.tgz", + "integrity": "sha512-QyAGYo/Fbj4MXeGdJcFzZ+FkDkomfRBrPM+9QYJSg+PxgAUL+LU3FneQk37rKR2/zjqkCV1BLHccX98wRXG3Sg==", "inBundle": true, "dependencies": { "infer-owner": "^1.0.4" } }, "node_modules/@npmcli/run-script": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-1.7.3.tgz", - "integrity": "sha512-kijsbIhpdai+DjZJ8NiHpAl/bQdJf0+hv2qy4pES7QuEXdfulB04HCMbgmmpwAulE88aOXjAj1zo1h8LVMKcWg==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-1.7.4.tgz", + "integrity": "sha512-GAeOB6P4/aYyvEbROVHXuSGPgy4wwQN/fGfXP993o9btyuCAOaz0T2cr5Y1y4nSeaBPfhk5W/E/AfFKDt6yG7w==", "inBundle": true, "dependencies": { "@npmcli/node-gyp": "^1.0.0", @@ -1881,13 +1881,13 @@ } }, "node_modules/eslint": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.11.0.tgz", - "integrity": "sha512-G9+qtYVCHaDi1ZuWzBsOWo2wSwd70TXnU6UHA3cTYHp7gCTXZcpggWFoUVAMRarg68qtPoNfFbzPh+VdOgmwmw==", + "version": "7.12.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.12.1.tgz", + "integrity": "sha512-HlMTEdr/LicJfN08LB3nM1rRYliDXOmfoO4vj39xN6BLpFzF00hbwBoqHk8UcJ2M/3nlARZWy/mslvGEuZFvsg==", "dev": true, "dependencies": { "@babel/code-frame": "^7.0.0", - "@eslint/eslintrc": "^0.1.3", + "@eslint/eslintrc": "^0.2.1", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -9045,9 +9045,9 @@ } }, "@eslint/eslintrc": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz", - "integrity": "sha512-4YVwPkANLeNtRjMekzux1ci8hIaH5eGKktGqR0d3LWsKNn5B2X/1Z6Trxy7jQXl9EBGE6Yj02O+t09FMeRllaA==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.2.1.tgz", + "integrity": "sha512-XRUeBZ5zBWLYgSANMpThFddrZZkEbGHgUdt5UJjZfnlN9BGCiUBrf+nvbRupSjMvqzwnQN0qwCmOxITt1cfywA==", "dev": true, "requires": { "ajv": "^6.12.4", @@ -9063,9 +9063,9 @@ } }, "@npmcli/arborist": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.5.tgz", - "integrity": "sha512-VK3VqSxnk5muyMB5zIIg12EsmV0COBKpBE8wQ/s85O02nh4N1suUxuf9nbgFonsi+D8uN4DO6qtdQ4FtN6i6+A==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.6.tgz", + "integrity": "sha512-Hj5QxT1/BIU5HMb3sSOCV81trhc6sqT1FaCdXPM+YjZPLpQsO3UFKWAGuDknDcNyx1mVT0IA1nlmrjhGGXDDtQ==", "requires": { "@npmcli/installed-package-contents": "^1.0.5", "@npmcli/map-workspaces": "^1.0.1", @@ -9158,17 +9158,17 @@ "version": "1.0.1" }, "@npmcli/promise-spawn": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-1.3.1.tgz", - "integrity": "sha512-S+I+ADqj66+ZpmmmvWXdNQkVyvikMYm/yrlk7xzoF6qf8AqL26yLwaxn0/ZTB0r3j1pur8Q/lyxL8yg4fZI76A==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-1.3.2.tgz", + "integrity": "sha512-QyAGYo/Fbj4MXeGdJcFzZ+FkDkomfRBrPM+9QYJSg+PxgAUL+LU3FneQk37rKR2/zjqkCV1BLHccX98wRXG3Sg==", "requires": { "infer-owner": "^1.0.4" } }, "@npmcli/run-script": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-1.7.3.tgz", - "integrity": "sha512-kijsbIhpdai+DjZJ8NiHpAl/bQdJf0+hv2qy4pES7QuEXdfulB04HCMbgmmpwAulE88aOXjAj1zo1h8LVMKcWg==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-1.7.4.tgz", + "integrity": "sha512-GAeOB6P4/aYyvEbROVHXuSGPgy4wwQN/fGfXP993o9btyuCAOaz0T2cr5Y1y4nSeaBPfhk5W/E/AfFKDt6yG7w==", "requires": { "@npmcli/node-gyp": "^1.0.0", "@npmcli/promise-spawn": "^1.3.0", @@ -10121,13 +10121,13 @@ } }, "eslint": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.11.0.tgz", - "integrity": "sha512-G9+qtYVCHaDi1ZuWzBsOWo2wSwd70TXnU6UHA3cTYHp7gCTXZcpggWFoUVAMRarg68qtPoNfFbzPh+VdOgmwmw==", + "version": "7.12.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.12.1.tgz", + "integrity": "sha512-HlMTEdr/LicJfN08LB3nM1rRYliDXOmfoO4vj39xN6BLpFzF00hbwBoqHk8UcJ2M/3nlARZWy/mslvGEuZFvsg==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@eslint/eslintrc": "^0.1.3", + "@eslint/eslintrc": "^0.2.1", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", diff --git a/package.json b/package.json index ed8c35d2be7f2..ef00418446c85 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "7.0.6", + "version": "7.0.7", "name": "npm", "description": "a package manager for JavaScript", "keywords": [ @@ -42,10 +42,10 @@ "./package.json": "./package.json" }, "dependencies": { - "@npmcli/arborist": "^1.0.4", + "@npmcli/arborist": "^1.0.6", "@npmcli/ci-detect": "^1.2.0", "@npmcli/config": "^1.2.1", - "@npmcli/run-script": "^1.7.0", + "@npmcli/run-script": "^1.7.4", "abbrev": "~1.1.1", "ansicolors": "~0.3.2", "ansistyles": "~0.1.3", @@ -181,7 +181,7 @@ ], "devDependencies": { "cmark-gfm": "^0.8.3", - "eslint": "^7.11.0", + "eslint": "^7.12.1", "eslint-plugin-import": "^2.22.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1", @@ -194,7 +194,6 @@ }, "scripts": { "dumpconf": "env | grep npm | sort | uniq", - "prepare": "node bin/npm-cli.js rebuild && make -j4", "preversion": "bash scripts/update-authors.sh && git add AUTHORS && git commit -m \"update AUTHORS\" || true", "licenses": "licensee --production --errors-only", "test": "tap", diff --git a/tap-snapshots/test-lib-utils-error-message.js-TAP.test.js b/tap-snapshots/test-lib-utils-error-message.js-TAP.test.js index 21fff0b87be09..bcf5144499f24 100644 --- a/tap-snapshots/test-lib-utils-error-message.js-TAP.test.js +++ b/tap-snapshots/test-lib-utils-error-message.js-TAP.test.js @@ -1209,6 +1209,18 @@ Object { } ` +exports[`test/lib/utils/error-message.js TAP replace message/stack sensistive info > must match snapshot 1`] = ` +Object { + "detail": Array [], + "summary": Array [ + Array [ + "audit", + "Error at registry: https://user:***@registry.npmjs.org/", + ], + ], +} +` + exports[`v TAP json parse json somewhere else > must match snapshot 1`] = ` Object { "detail": Array [ diff --git a/test/lib/ci.js b/test/lib/ci.js index 3c642ba930135..645fc6aed97e4 100644 --- a/test/lib/ci.js +++ b/test/lib/ci.js @@ -104,7 +104,8 @@ test('should remove existing node_modules before installing', (t) => { t.equal(options.save, false, 'npm ci should never save') // check if node_modules was removed before reifying const contents = await readdir(testDir) - t.equals(contents.indexOf('node_modules'), -1, 'node_modules does not exist') + const nodeModules = contents.filter((path) => path.startsWith('node_modules')) + t.same(nodeModules, ['node_modules'], 'should only have the node_modules directory') t.end() } } diff --git a/test/lib/exec.js b/test/lib/exec.js index 97da01140edb0..fb89776b55eaf 100644 --- a/test/lib/exec.js +++ b/test/lib/exec.js @@ -82,7 +82,7 @@ const PATH = require('../../lib/utils/path.js') let CI_NAME = 'travis-ci' -const exec = requireInject('../../lib/exec.js', { +const mocks = { '@npmcli/arborist': Arborist, '@npmcli/run-script': runScript, '@npmcli/ci-detect': () => CI_NAME, @@ -90,7 +90,8 @@ const exec = requireInject('../../lib/exec.js', { pacote, read, 'mkdirp-infer-owner': mkdirp -}) +} +const exec = requireInject('../../lib/exec.js', mocks) t.afterEach(cb => { MKDIRPS.length = 0 @@ -122,7 +123,7 @@ t.test('npx foo, bin already exists locally', async t => { t.ifError(er, 'npm exec') }) t.strictSame(RUN_SCRIPTS, [{ - cmd: 'foo', + pkg: { scripts: { npx: 'foo' }}, banner: false, path: process.cwd(), stdioString: true, @@ -146,7 +147,7 @@ t.test('npx foo, bin already exists globally', async t => { t.ifError(er, 'npm exec') }) t.strictSame(RUN_SCRIPTS, [{ - cmd: 'foo', + pkg: { scripts: { npx: 'foo' }}, banner: false, path: process.cwd(), stdioString: true, diff --git a/test/lib/run-script.js b/test/lib/run-script.js index 9f48b8f59bbeb..7a034aff01561 100644 --- a/test/lib/run-script.js +++ b/test/lib/run-script.js @@ -253,6 +253,7 @@ t.test('skip pre/post hooks when using ignoreScripts', async t => { postenv: 'echo after the env', env: 'env' } }, + banner: true, event: 'env' } ]) @@ -295,7 +296,8 @@ t.test('run silent', async t => { pkg: { name: 'x', version: '1.2.3', _id: 'x@1.2.3', scripts: { env: 'env' } }, - event: 'env' + event: 'env', + banner: false }, { event: 'postenv', diff --git a/test/lib/utils/config.js b/test/lib/utils/config.js index 293e68c00449d..e8133eecb24f1 100644 --- a/test/lib/utils/config.js +++ b/test/lib/utils/config.js @@ -138,7 +138,7 @@ t.test('no shell on posix', t => { '@npmcli/ci-detect': () => false, '../../../lib/utils/is-windows.js': false }) - t.equal(config.defaults.shell, 'bash') + t.equal(config.defaults.shell, 'sh') t.end() }) diff --git a/test/lib/utils/error-message.js b/test/lib/utils/error-message.js index 46df017f4847a..2647a8e1994ea 100644 --- a/test/lib/utils/error-message.js +++ b/test/lib/utils/error-message.js @@ -112,6 +112,24 @@ t.test('just simple messages', t => { }) }) +t.test('replace message/stack sensistive info', t => { + npm.command = 'audit' + const path = '/some/path' + const pkgid = 'some@package' + const file = '/some/file' + const stack = 'dummy stack trace at https://user:pass@registry.npmjs.org/' + const message = 'Error at registry: https://user:pass@registry.npmjs.org/' + const er = Object.assign(new Error(message), { + code: 'ENOAUDIT', + path, + pkgid, + file, + stack, + }) + t.matchSnapshot(errorMessage(er)) + t.end() +}) + t.test('bad engine with config loaded', t => { npm.config.loaded = true t.teardown(() => { npm.config.loaded = false }) diff --git a/test/lib/utils/replace-info.js b/test/lib/utils/replace-info.js new file mode 100644 index 0000000000000..f5e1246f1c353 --- /dev/null +++ b/test/lib/utils/replace-info.js @@ -0,0 +1,78 @@ +const t = require('tap') +const replaceInfo = require('../../../lib/utils/replace-info.js') + +t.equal( + replaceInfo(), + undefined, + 'should return undefined item' +) + +t.equal( + replaceInfo(null), + null, + 'should return null' +) + +t.equal( + replaceInfo(1234), + 1234, + 'should return numbers' +) + +t.equal( + replaceInfo('https://user:pass@registry.npmjs.org/'), + 'https://user:***@registry.npmjs.org/', + 'should replace single item' +) + +t.equal( + replaceInfo('https://example.npmjs.org'), + 'https://example.npmjs.org', + 'should not replace single item with no password' +) + +t.equal( + replaceInfo('foo bar https://example.npmjs.org lorem ipsum'), + 'foo bar https://example.npmjs.org lorem ipsum', + 'should not replace single item with no password with multiple items' +) + +t.equal( + replaceInfo('https://user:pass@registry.npmjs.org/ http://a:b@reg.github.com'), + 'https://user:***@registry.npmjs.org/ http://a:***@reg.github.com', + 'should replace multiple items on a string' +) + +t.equal( + replaceInfo('Something https://user:pass@registry.npmjs.org/ foo bar'), + 'Something https://user:***@registry.npmjs.org/ foo bar', + 'should replace single item withing a phrase' +) + +t.deepEqual( + replaceInfo([ + 'Something https://user:pass@registry.npmjs.org/ foo bar', + 'http://foo:bar@registry.npmjs.org', + 'http://example.npmjs.org', + ]), + [ + 'Something https://user:***@registry.npmjs.org/ foo bar', + 'http://foo:***@registry.npmjs.org', + 'http://example.npmjs.org', + ], + 'should replace single item within a phrase' +) + +t.deepEqual( + replaceInfo([ + 'Something https://user:pass@registry.npmjs.org/ foo bar', + null, + [], + ]), + [ + 'Something https://user:***@registry.npmjs.org/ foo bar', + null, + [], + ], + 'should ignore invalid items of array' +)