diff options
author | Luke Karrys <luke@lukekarrys.com> | 2022-11-09 03:34:01 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2022-11-09 21:28:12 +0300 |
commit | f36df466aab2481069fe6213671c60d2f8e8474e (patch) | |
tree | 00dfb27461f805116aa9cafb21b27ea3b1ad4060 | |
parent | 6a15d8a3a5846b7b23559118e234eb074f84f480 (diff) |
chore: move mock-registry to workspace
24 files changed, 1105 insertions, 1570 deletions
diff --git a/.eslintrc.js b/.eslintrc.js index ff8d43d7f..4d943ad31 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,6 +13,7 @@ module.exports = { ignorePatterns: [ 'docs/**', 'smoke-tests/**', + 'mock-registry/**', 'workspaces/**', ], extends: [ diff --git a/.github/workflows/ci-npmcli-mock-registry.yml b/.github/workflows/ci-npmcli-mock-registry.yml new file mode 100644 index 000000000..db394f789 --- /dev/null +++ b/.github/workflows/ci-npmcli-mock-registry.yml @@ -0,0 +1,94 @@ +# This file is automatically added by @npmcli/template-oss. Do not edit. + +name: CI - @npmcli/mock-registry + +on: + workflow_dispatch: + pull_request: + paths: + - mock-registry/** + push: + branches: + - main + - latest + paths: + - mock-registry/** + schedule: + # "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1 + - cron: "0 9 * * 1" + +jobs: + lint: + name: Lint + if: github.repository_owner == 'npm' + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User + run: | + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: npm + - name: Reset Deps + run: node . run resetdeps + - name: Lint + run: node . run lint --ignore-scripts -w @npmcli/mock-registry + - name: Post Lint + run: node . run postlint --ignore-scripts -w @npmcli/mock-registry + + test: + name: Test - ${{ matrix.platform.name }} - ${{ matrix.node-version }} + if: github.repository_owner == 'npm' + strategy: + fail-fast: false + matrix: + platform: + - name: Linux + os: ubuntu-latest + shell: bash + - name: macOS + os: macos-latest + shell: bash + - name: Windows + os: windows-latest + shell: cmd + node-version: + - 14.17.0 + - 14.x + - 16.13.0 + - 16.x + - 18.0.0 + - 18.x + runs-on: ${{ matrix.platform.os }} + defaults: + run: + shell: ${{ matrix.platform.shell }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Git User + run: | + git config --global user.email "npm-cli+bot@github.com" + git config --global user.name "npm CLI robot" + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: npm + - name: Reset Deps + run: node . run resetdeps + - name: Add Problem Matcher + run: echo "::add-matcher::.github/matchers/tap.json" + - name: Test + run: node . test --ignore-scripts -w @npmcli/mock-registry + - name: Check Git Status + if: matrix && matrix.platform.os != 'windows-latest' + run: node scripts/git-dirty.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3268396f..639bf4a0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ on: paths-ignore: - docs/** - smoke-tests/** + - mock-registry/** - workspaces/** push: branches: @@ -16,6 +17,7 @@ on: paths-ignore: - docs/** - smoke-tests/** + - mock-registry/** - workspaces/** schedule: # "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1 diff --git a/.gitignore b/.gitignore index 2ab23adf7..dd81bed48 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ !/test/ !/docs/ !/smoke-tests/ +!/mock-registry/ !/workspaces/ /workspaces/* !/workspaces/arborist/ diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index c0d75350b..e0ec307f0 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -120,6 +120,7 @@ graph LR; npm-->npmcli-fs["@npmcli/fs"]; npm-->npmcli-git["@npmcli/git"]; npm-->npmcli-map-workspaces["@npmcli/map-workspaces"]; + npm-->npmcli-mock-registry["@npmcli/mock-registry"]; npm-->npmcli-package-json["@npmcli/package-json"]; npm-->npmcli-promise-spawn["@npmcli/promise-spawn"]; npm-->npmcli-run-script["@npmcli/run-script"]; @@ -207,12 +208,18 @@ graph LR; npmcli-metavuln-calculator-->json-parse-even-better-errors; npmcli-metavuln-calculator-->pacote; npmcli-metavuln-calculator-->semver; + npmcli-mock-registry-->npm-package-arg; + npmcli-mock-registry-->npmcli-arborist["@npmcli/arborist"]; + npmcli-mock-registry-->npmcli-eslint-config["@npmcli/eslint-config"]; + npmcli-mock-registry-->npmcli-template-oss["@npmcli/template-oss"]; + npmcli-mock-registry-->pacote; npmcli-package-json-->json-parse-even-better-errors; npmcli-run-script-->npmcli-node-gyp["@npmcli/node-gyp"]; npmcli-run-script-->npmcli-promise-spawn["@npmcli/promise-spawn"]; npmcli-run-script-->read-package-json-fast; npmcli-smoke-tests-->minify-registry-metadata; npmcli-smoke-tests-->npmcli-eslint-config["@npmcli/eslint-config"]; + npmcli-smoke-tests-->npmcli-mock-registry["@npmcli/mock-registry"]; npmcli-smoke-tests-->npmcli-promise-spawn["@npmcli/promise-spawn"]; npmcli-smoke-tests-->npmcli-template-oss["@npmcli/template-oss"]; npmlog-->are-we-there-yet; @@ -520,6 +527,7 @@ graph LR; npm-->npmcli-fs["@npmcli/fs"]; npm-->npmcli-git["@npmcli/git"]; npm-->npmcli-map-workspaces["@npmcli/map-workspaces"]; + npm-->npmcli-mock-registry["@npmcli/mock-registry"]; npm-->npmcli-package-json["@npmcli/package-json"]; npm-->npmcli-promise-spawn["@npmcli/promise-spawn"]; npm-->npmcli-run-script["@npmcli/run-script"]; @@ -657,6 +665,13 @@ graph LR; npmcli-metavuln-calculator-->json-parse-even-better-errors; npmcli-metavuln-calculator-->pacote; npmcli-metavuln-calculator-->semver; + npmcli-mock-registry-->nock; + npmcli-mock-registry-->npm-package-arg; + npmcli-mock-registry-->npmcli-arborist["@npmcli/arborist"]; + npmcli-mock-registry-->npmcli-eslint-config["@npmcli/eslint-config"]; + npmcli-mock-registry-->npmcli-template-oss["@npmcli/template-oss"]; + npmcli-mock-registry-->pacote; + npmcli-mock-registry-->tap; npmcli-move-file-->mkdirp; npmcli-move-file-->rimraf; npmcli-package-json-->json-parse-even-better-errors; @@ -667,8 +682,12 @@ graph LR; npmcli-run-script-->npmcli-promise-spawn["@npmcli/promise-spawn"]; npmcli-run-script-->read-package-json-fast; npmcli-run-script-->which; + npmcli-smoke-tests-->http-proxy; + npmcli-smoke-tests-->just-extend; + npmcli-smoke-tests-->just-safe-set; npmcli-smoke-tests-->minify-registry-metadata; npmcli-smoke-tests-->npmcli-eslint-config["@npmcli/eslint-config"]; + npmcli-smoke-tests-->npmcli-mock-registry["@npmcli/mock-registry"]; npmcli-smoke-tests-->npmcli-promise-spawn["@npmcli/promise-spawn"]; npmcli-smoke-tests-->npmcli-template-oss["@npmcli/template-oss"]; npmcli-smoke-tests-->tap; @@ -757,13 +776,13 @@ Each group depends on packages lower down the chain, nothing depends on packages higher up the chain. - npm - - libnpmpublish - - libnpmdiff, libnpmexec, libnpmfund, libnpmpack + - @npmcli/smoke-tests, libnpmpublish + - @npmcli/mock-registry, libnpmdiff, libnpmexec, libnpmfund, libnpmpack - @npmcli/arborist - @npmcli/metavuln-calculator - 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, promzard - - @npmcli/docs, @npmcli/smoke-tests, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, npm-packlist, normalize-package-data, @npmcli/package-json, bin-links, nopt, npmlog, parse-conflict-json, read - - @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, @npmcli/promise-spawn, minify-registry-metadata, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, treeverse, ini, @npmcli/disparity-colors, @npmcli/ci-detect, mute-stream, npm-audit-report, npm-user-validate + - @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, npm-packlist, normalize-package-data, @npmcli/package-json, bin-links, nopt, npmlog, parse-conflict-json, read + - @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, treeverse, minify-registry-metadata, ini, @npmcli/disparity-colors, @npmcli/ci-detect, mute-stream, npm-audit-report, npm-user-validate diff --git a/mock-registry/.eslintrc.js b/mock-registry/.eslintrc.js new file mode 100644 index 000000000..5db9f8155 --- /dev/null +++ b/mock-registry/.eslintrc.js @@ -0,0 +1,17 @@ +/* This file is automatically added by @npmcli/template-oss. Do not edit. */ + +'use strict' + +const { readdirSync: readdir } = require('fs') + +const localConfigs = readdir(__dirname) + .filter((file) => file.startsWith('.eslintrc.local.')) + .map((file) => `./${file}`) + +module.exports = { + root: true, + extends: [ + '@npmcli', + ...localConfigs, + ], +} diff --git a/mock-registry/.gitignore b/mock-registry/.gitignore new file mode 100644 index 000000000..79af2bfca --- /dev/null +++ b/mock-registry/.gitignore @@ -0,0 +1,21 @@ +# This file is automatically added by @npmcli/template-oss. Do not edit. + +# ignore everything in the root +/* + +# keep these +!**/.gitignore +!/.eslintrc.js +!/.eslintrc.local.* +!/.gitignore +!/bin/ +!/CHANGELOG* +!/docs/ +!/lib/ +!/LICENSE* +!/map.js +!/package.json +!/README* +!/scripts/ +!/tap-snapshots/ +!/test/ diff --git a/test/fixtures/mock-registry.js b/mock-registry/lib/index.js index a39532958..1652e3344 100644 --- a/test/fixtures/mock-registry.js +++ b/mock-registry/lib/index.js @@ -1,18 +1,15 @@ -/* - * Mock registry class - * - * This should end up as the centralized place where we generate test fixtures - * for tests against any registry data. - */ const pacote = require('pacote') const Arborist = require('@npmcli/arborist') const npa = require('npm-package-arg') +const Nock = require('nock') + class MockRegistry { #tap #nock #registry #authorization #basic + #debug constructor (opts) { if (!opts.registry) { @@ -21,16 +18,33 @@ class MockRegistry { this.#registry = (new URL(opts.registry)).origin this.#authorization = opts.authorization this.#basic = opts.basic + this.#debug = opts.debug // Required for this.package this.#tap = opts.tap } + static tnock (t, host, opts, { debug = false } = {}) { + if (debug) { + Nock.emitter.on('no match', req => console.error('NO MATCH', req.options)) + } + Nock.disableNetConnect() + const server = Nock(host, opts) + t.teardown(() => { + Nock.enableNetConnect() + server.done() + }) + return server + } + + get origin () { + return this.#registry + } + get nock () { if (!this.#nock) { if (!this.#tap) { throw new Error('cannot mock packages without a tap fixture') } - const tnock = require('./tnock.js') const reqheaders = {} if (this.#authorization) { reqheaders.authorization = `Bearer ${this.#authorization}` @@ -38,7 +52,12 @@ class MockRegistry { if (this.#basic) { reqheaders.authorization = `Basic ${this.#basic}` } - this.#nock = tnock(this.#tap, this.#registry, { reqheaders }) + this.#nock = MockRegistry.tnock( + this.#tap, + this.#registry, + { reqheaders }, + { debug: this.#debug } + ) } return this.#nock } @@ -260,7 +279,7 @@ class MockRegistry { // or an array of versions // the last packument in the packuments or versions array will be tagged latest manifest ({ name = 'test-package', users, packuments, versions } = {}) { - packuments = this.packuments(packuments, name) + packuments = this.packuments(versions || packuments, name) const latest = packuments.slice(-1)[0] const manifest = { _id: `${name}@${latest.version}`, @@ -276,10 +295,6 @@ class MockRegistry { if (users) { manifest.users = users } - if (versions) { - packuments = versions.map(version => ({ version })) - } - for (const packument of packuments) { manifest.versions[packument.version] = { _id: `${name}@${packument.version}`, diff --git a/mock-registry/package.json b/mock-registry/package.json new file mode 100644 index 000000000..253d06dd2 --- /dev/null +++ b/mock-registry/package.json @@ -0,0 +1,55 @@ +{ + "name": "@npmcli/mock-registry", + "version": "1.0.0", + "description": "", + "main": "lib/index.js", + "private": true, + "scripts": { + "test": "tap", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force", + "lintfix": "node .. run lint -- --fix", + "snap": "tap", + "posttest": "node .. run lint" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/cli.git", + "directory": "mock-registry" + }, + "keywords": [], + "author": "GitHub Inc.", + "license": "ISC", + "bugs": { + "url": "https://github.com/npm/cli/issues" + }, + "homepage": "https://github.com/npm/cli#readme", + "files": [ + "bin/", + "lib/" + ], + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "4.8.0" + }, + "tap": { + "no-coverage": true, + "nyc-arg": [ + "--exclude", + "tap-snapshots/**" + ] + }, + "devDependencies": { + "@npmcli/arborist": "^6.1.1", + "@npmcli/eslint-config": "^4.0.1", + "@npmcli/template-oss": "4.8.0", + "nock": "^13.2.9", + "npm-package-arg": "^10.0.0", + "pacote": "^15.0.6", + "tap": "^16.3.0" + } +} diff --git a/mock-registry/test/index.js b/mock-registry/test/index.js new file mode 100644 index 000000000..45f9bc16d --- /dev/null +++ b/mock-registry/test/index.js @@ -0,0 +1,8 @@ +const t = require('tap') +const MockRegistry = require('..') + +t.test('it works', async t => { + t.ok(new MockRegistry({ + registry: 'http://registry.npmjs.org/', + })) +}) diff --git a/package-lock.json b/package-lock.json index 4a3add128..f8736f5f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -81,6 +81,7 @@ "workspaces": [ "docs", "smoke-tests", + "mock-registry", "workspaces/*" ], "dependencies": { @@ -202,6 +203,23 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "mock-registry": { + "name": "@npmcli/mock-registry", + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "@npmcli/arborist": "^6.1.1", + "@npmcli/eslint-config": "^4.0.1", + "@npmcli/template-oss": "4.8.0", + "nock": "^13.2.9", + "npm-package-arg": "^10.0.0", + "pacote": "^15.0.6", + "tap": "^16.3.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/@actions/core": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", @@ -2180,6 +2198,10 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/@npmcli/mock-registry": { + "resolved": "mock-registry", + "link": true + }, "node_modules/@npmcli/name-from-folder": { "version": "1.0.1", "inBundle": true, @@ -5103,6 +5125,26 @@ "dev": true, "peer": true }, + "node_modules/follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/foreground-child": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", @@ -5728,6 +5770,20 @@ "inBundle": true, "license": "BSD-2-Clause" }, + "node_modules/http-proxy": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz", + "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==", + "dev": true, + "dependencies": { + "eventemitter3": "^4.0.0", + "follow-redirects": "^1.0.0", + "requires-port": "^1.0.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/http-proxy-agent": { "version": "5.0.0", "inBundle": true, @@ -6735,6 +6791,18 @@ "inBundle": true, "license": "MIT" }, + "node_modules/just-extend": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-6.1.1.tgz", + "integrity": "sha512-1UWaMWIB90HnIZAmXOTLobwWc9lc1ZMUBRKf8PaozCAiNUif6wv1fyeXpqccWZCu7L9zxIgXG55vARuZluyvqw==", + "dev": true + }, + "node_modules/just-safe-set": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/just-safe-set/-/just-safe-set-4.1.1.tgz", + "integrity": "sha512-3tQtDVCvZfWc64yEbh2D8R80Zlz+x9LJVpkQ4K3ppdiO7iI1Jzf6wYgsAs1o/EMSwucRbaNb6JHex/24TbSaKw==", + "dev": true + }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -9449,8 +9517,9 @@ }, "node_modules/npm-package-arg": { "version": "10.0.0", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-10.0.0.tgz", + "integrity": "sha512-7dkh8mRp7s0KwVHKIVJnFCJQ2B34gOGnzgBjDGyprycmARq/82SX/lhilQ95ZuacP/G/1gsS345iAkKmxWBQ2Q==", "inBundle": true, - "license": "ISC", "dependencies": { "hosted-git-info": "^6.0.0", "proc-log": "^3.0.0", @@ -10033,8 +10102,9 @@ }, "node_modules/pacote": { "version": "15.0.6", + "resolved": "https://registry.npmjs.org/pacote/-/pacote-15.0.6.tgz", + "integrity": "sha512-dQwcz/sME7QIL+cdrw/jftQfMMXxSo17i2kJ/gnhBhUvvBAsxoBu1lw9B5IzCH/Ce8CvEkG/QYZ6txzKfn0bTw==", "inBundle": true, - "license": "ISC", "dependencies": { "@npmcli/git": "^4.0.0", "@npmcli/installed-package-contents": "^2.0.1", @@ -14895,8 +14965,12 @@ "license": "ISC", "devDependencies": { "@npmcli/eslint-config": "^4.0.0", + "@npmcli/mock-registry": "^1.0.0", "@npmcli/promise-spawn": "^6.0.1", "@npmcli/template-oss": "4.8.0", + "http-proxy": "^1.18.1", + "just-extend": "^6.1.1", + "just-safe-set": "^4.1.1", "minify-registry-metadata": "^2.2.0", "tap": "^16.0.1", "which": "^3.0.0" @@ -15196,6 +15270,29 @@ "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } + }, + "workspaces/ws-a": { + "version": "1.0.0", + "extraneous": true, + "license": "ISC", + "dependencies": { + "abbrev": "1.0.5", + "ws-b": "1.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "workspaces/ws-b": { + "version": "1.0.0", + "extraneous": true, + "license": "ISC", + "dependencies": { + "abbrev": "1.0.6" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } } } } diff --git a/package.json b/package.json index fd7997e55..4fa888e76 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "workspaces": [ "docs", "smoke-tests", + "mock-registry", "workspaces/*" ], "files": [ @@ -244,11 +245,13 @@ "--exclude", "smoke-tests/**", "--exclude", + "mock-registry/**", + "--exclude", "workspaces/**", "--exclude", "tap-snapshots/**" ], - "test-ignore": "^(docs|smoke-tests|workspaces)/" + "test-ignore": "^(docs|smoke-tests|mock-registry|workspaces)/" }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", diff --git a/smoke-tests/package.json b/smoke-tests/package.json index 1ee4b2ca3..8bcc03467 100644 --- a/smoke-tests/package.json +++ b/smoke-tests/package.json @@ -19,8 +19,12 @@ }, "devDependencies": { "@npmcli/eslint-config": "^4.0.0", + "@npmcli/mock-registry": "^1.0.0", "@npmcli/promise-spawn": "^6.0.1", "@npmcli/template-oss": "4.8.0", + "http-proxy": "^1.18.1", + "just-extend": "^6.1.1", + "just-safe-set": "^4.1.1", "minify-registry-metadata": "^2.2.0", "tap": "^16.0.1", "which": "^3.0.0" @@ -34,8 +38,8 @@ }, "tap": { "no-coverage": true, - "timeout": 300, - "files": "test/*.js", + "timeout": 600, + "test-ignore": "fixtures/*", "nyc-arg": [ "--exclude", "tap-snapshots/**" diff --git a/smoke-tests/tap-snapshots/test/index.js.test.cjs b/smoke-tests/tap-snapshots/test/index.js.test.cjs index 9f539bf8a..904b09b05 100644 --- a/smoke-tests/tap-snapshots/test/index.js.test.cjs +++ b/smoke-tests/tap-snapshots/test/index.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/index.js TAP npm (no args) > should have expected no args output 1`] = ` +exports[`test/index.js TAP basic npm (no args) > should have expected no args output 1`] = ` npm <command> Usage: @@ -32,7 +32,7 @@ All commands: unstar, update, version, view, whoami Specify configs in the ini-formatted file: - {CWD}/smoke-tests/test/tap-testdir-index/.npmrc + {CWD}/{TESTDIR}/project/.npmrc or on the command line via: npm <command> --key=value More configuration info: npm help config @@ -41,7 +41,7 @@ Configuration fields: npm help 7 config npm {CWD} ` -exports[`test/index.js TAP npm ci > should throw mismatch deps in lock file error 1`] = ` +exports[`test/index.js TAP basic npm ci > should throw mismatch deps in lock file error 1`] = ` npm ERR! code EUSAGE npm ERR! npm ERR! \`npm ci\` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with \`npm install\` before continuing. @@ -71,274 +71,43 @@ npm ERR! A complete log of this run can be found in: ` -exports[`test/index.js TAP npm diff > should have expected diff output 1`] = ` +exports[`test/index.js TAP basic npm diff > should have expected diff output 1`] = ` +diff --git a/index.js b/index.js +index v1.0.4..v1.1.1 100644 +--- a/index.js ++++ b/index.js +@@ -1,1 +1,1 @@ +-module.exports = "1.0.4" +/ No newline at end of file ++module.exports = "1.1.1" +/ No newline at end of file diff --git a/package.json b/package.json index v1.0.4..v1.1.1 100644 --- a/package.json +++ b/package.json -@@ -1,15 +1,21 @@ +@@ -1,4 +1,4 @@ { "name": "abbrev", -- "version": "1.0.4", -+ "version": "1.1.1", - "description": "Like ruby's abbrev module, but in js", - "author": "Isaac Z. Schlueter <i@izs.me>", -- "main": "./lib/abbrev.js", -+ "main": "abbrev.js", - "scripts": { -- "test": "node lib/abbrev.js" -+ "test": "tap test.js --100", -+ "preversion": "npm test", -+ "postversion": "npm publish", -+ "postpublish": "git push origin --all; git push origin --tags" - }, - "repository": "http://github.com/isaacs/abbrev-js", -- "license": { -- "type": "MIT", -- "url": "https://github.com/isaacs/abbrev-js/raw/master/LICENSE" -- } -+ "license": "ISC", -+ "devDependencies": { -+ "tap": "^10.1" -+ }, -+ "files": [ -+ "abbrev.js" -+ ] +- "version": "1.0.4" ++ "version": "1.1.1" } -diff --git a/LICENSE b/LICENSE -index v1.0.4..v1.1.1 100644 ---- a/LICENSE -+++ b/LICENSE -@@ -1,4 +1,27 @@ --Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -+This software is dual-licensed under the ISC and MIT licenses. -+You may use this software under EITHER of the following licenses. -+ -+---------- -+ -+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. -+ -+---------- -+ -+Copyright Isaac Z. Schlueter and Contributors - All rights reserved. - - Permission is hereby granted, free of charge, to any person -diff --git a/lib/abbrev.js b/lib/abbrev.js -deleted file mode 100644 -index v1.0.4..v1.1.1 ---- a/lib/abbrev.js -+++ b/lib/abbrev.js -@@ -1,111 +0,0 @@ -- --module.exports = exports = abbrev.abbrev = abbrev -- --abbrev.monkeyPatch = monkeyPatch -- --function monkeyPatch () { -- Object.defineProperty(Array.prototype, 'abbrev', { -- value: function () { return abbrev(this) }, -- enumerable: false, configurable: true, writable: true -- }) -- -- Object.defineProperty(Object.prototype, 'abbrev', { -- value: function () { return abbrev(Object.keys(this)) }, -- enumerable: false, configurable: true, writable: true -- }) --} -- --function abbrev (list) { -- if (arguments.length !== 1 || !Array.isArray(list)) { -- list = Array.prototype.slice.call(arguments, 0) -- } -- for (var i = 0, l = list.length, args = [] ; i < l ; i ++) { -- args[i] = typeof list[i] === "string" ? list[i] : String(list[i]) -- } -- -- // sort them lexicographically, so that they're next to their nearest kin -- args = args.sort(lexSort) -- -- // walk through each, seeing how much it has in common with the next and previous -- var abbrevs = {} -- , prev = "" -- for (var i = 0, l = args.length ; i < l ; i ++) { -- var current = args[i] -- , next = args[i + 1] || "" -- , nextMatches = true -- , prevMatches = true -- if (current === next) continue -- for (var j = 0, cl = current.length ; j < cl ; j ++) { -- var curChar = current.charAt(j) -- nextMatches = nextMatches && curChar === next.charAt(j) -- prevMatches = prevMatches && curChar === prev.charAt(j) -- if (!nextMatches && !prevMatches) { -- j ++ -- break -- } -- } -- prev = current -- if (j === cl) { -- abbrevs[current] = current -- continue -- } -- for (var a = current.substr(0, j) ; j <= cl ; j ++) { -- abbrevs[a] = current -- a += current.charAt(j) -- } -- } -- return abbrevs --} -- --function lexSort (a, b) { -- return a === b ? 0 : a > b ? 1 : -1 --} -- -- --// tests --if (module === require.main) { -- --var assert = require("assert") --var util = require("util") -- --console.log("running tests") --function test (list, expect) { -- var actual = abbrev(list) -- assert.deepEqual(actual, expect, -- "abbrev("+util.inspect(list)+") === " + util.inspect(expect) + "/n"+ -- "actual: "+util.inspect(actual)) -- actual = abbrev.apply(exports, list) -- assert.deepEqual(abbrev.apply(exports, list), expect, -- "abbrev("+list.map(JSON.stringify).join(",")+") === " + util.inspect(expect) + "/n"+ -- "actual: "+util.inspect(actual)) --} -- --test([ "ruby", "ruby", "rules", "rules", "rules" ], --{ rub: 'ruby' --, ruby: 'ruby' --, rul: 'rules' --, rule: 'rules' --, rules: 'rules' --}) --test(["fool", "foom", "pool", "pope"], --{ fool: 'fool' --, foom: 'foom' --, poo: 'pool' --, pool: 'pool' --, pop: 'pope' --, pope: 'pope' --}) --test(["a", "ab", "abc", "abcd", "abcde", "acde"], --{ a: 'a' --, ab: 'ab' --, abc: 'abc' --, abcd: 'abcd' --, abcde: 'abcde' --, ac: 'acde' --, acd: 'acde' --, acde: 'acde' --}) -- --console.log("pass") -- --} / No newline at end of file -diff --git a/abbrev.js b/abbrev.js -new file mode 100644 -index v1.0.4..v1.1.1 ---- a/abbrev.js -+++ b/abbrev.js -@@ -0,0 +1,61 @@ -+module.exports = exports = abbrev.abbrev = abbrev -+ -+abbrev.monkeyPatch = monkeyPatch -+ -+function monkeyPatch () { -+ Object.defineProperty(Array.prototype, 'abbrev', { -+ value: function () { return abbrev(this) }, -+ enumerable: false, configurable: true, writable: true -+ }) -+ -+ Object.defineProperty(Object.prototype, 'abbrev', { -+ value: function () { return abbrev(Object.keys(this)) }, -+ enumerable: false, configurable: true, writable: true -+ }) -+} -+ -+function abbrev (list) { -+ if (arguments.length !== 1 || !Array.isArray(list)) { -+ list = Array.prototype.slice.call(arguments, 0) -+ } -+ for (var i = 0, l = list.length, args = [] ; i < l ; i ++) { -+ args[i] = typeof list[i] === "string" ? list[i] : String(list[i]) -+ } -+ -+ // sort them lexicographically, so that they're next to their nearest kin -+ args = args.sort(lexSort) -+ -+ // walk through each, seeing how much it has in common with the next and previous -+ var abbrevs = {} -+ , prev = "" -+ for (var i = 0, l = args.length ; i < l ; i ++) { -+ var current = args[i] -+ , next = args[i + 1] || "" -+ , nextMatches = true -+ , prevMatches = true -+ if (current === next) continue -+ for (var j = 0, cl = current.length ; j < cl ; j ++) { -+ var curChar = current.charAt(j) -+ nextMatches = nextMatches && curChar === next.charAt(j) -+ prevMatches = prevMatches && curChar === prev.charAt(j) -+ if (!nextMatches && !prevMatches) { -+ j ++ -+ break -+ } -+ } -+ prev = current -+ if (j === cl) { -+ abbrevs[current] = current -+ continue -+ } -+ for (var a = current.substr(0, j) ; j <= cl ; j ++) { -+ abbrevs[a] = current -+ a += current.charAt(j) -+ } -+ } -+ return abbrevs -+} -+ -+function lexSort (a, b) { -+ return a === b ? 0 : a > b ? 1 : -1 -+} ` -exports[`test/index.js TAP npm explain > should have expected explain output 1`] = ` +exports[`test/index.js TAP basic npm explain > should have expected explain output 1`] = ` abbrev@1.0.4 node_modules/abbrev abbrev@"^1.0.4" from the root project ` -exports[`test/index.js TAP npm fund > should have expected fund output 1`] = ` +exports[`test/index.js TAP basic npm fund > should have expected fund output 1`] = ` project@1.0.0 -\`-- https://github.com/sponsors/isaacs - \`-- promise-all-reject-late@1.0.1 +\`-- https://github.com/sponsors + \`-- promise-all-reject-late@5.0.0 ` -exports[`test/index.js TAP npm init > should have successful npm init result 1`] = ` -Wrote to {CWD}/smoke-tests/test/tap-testdir-index/project/package.json: +exports[`test/index.js TAP basic npm init > should have successful npm init result 1`] = ` +Wrote to {CWD}/{TESTDIR}/project/package.json: { "name": "project", @@ -354,194 +123,185 @@ Wrote to {CWD}/smoke-tests/test/tap-testdir-index/project/package.json: } ` -exports[`test/index.js TAP npm install dev dep > should have expected dev dep added lockfile result 1`] = ` -{ - "name": "project", - "version": "1.0.0", +exports[`test/index.js TAP basic npm install dev dep > should have expected dev dep added lockfile result 1`] = ` +Object { "lockfileVersion": 3, - "requires": true, - "packages": { - "": { + "name": "project", + "packages": Object { + "": Object { + "dependencies": Object { + "abbrev": "^1.0.4", + }, + "devDependencies": Object { + "promise-all-reject-late": "^5.0.0", + }, + "license": "ISC", "name": "project", "version": "1.0.0", - "license": "ISC", - "dependencies": { - "abbrev": "^1.0.4" - }, - "devDependencies": { - "promise-all-reject-late": "^1.0.1" - } }, - "node_modules/abbrev": { + "node_modules/abbrev": Object { + "resolved": "http://smoke-test-registry.club/abbrev/-/abbrev-1.0.4.tgz", "version": "1.0.4", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz", - "integrity": "sha1-vVWuXkE7oXIu5Mq6H26hBBSlns0=" }, - "node_modules/promise-all-reject-late": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/promise-all-reject-late/-/promise-all-reject-late-1.0.1.tgz", - "integrity": "sha512-vuf0Lf0lOxyQREH7GDIOUMLS7kz+gs8i6B+Yi8dC68a2sychGrHTJYghMBD6k7eUcH0H5P73EckCA48xijWqXw==", + "node_modules/promise-all-reject-late": Object { "dev": true, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - } - } + "funding": Object { + "url": "https://github.com/sponsors", + }, + "resolved": "http://smoke-test-registry.club/promise-all-reject-late/-/promise-all-reject-late-5.0.0.tgz", + "version": "5.0.0", + }, + }, + "requires": true, + "version": "1.0.0", } - ` -exports[`test/index.js TAP npm install dev dep > should have expected dev dep added package.json result 1`] = ` -{ - "name": "project", - "version": "1.0.0", +exports[`test/index.js TAP basic npm install dev dep > should have expected dev dep added package.json result 1`] = ` +Object { + "author": "", + "dependencies": Object { + "abbrev": "^1.0.4", + }, "description": "", - "main": "index.js", - "scripts": { - "test": "echo /"Error: no test specified/" && exit 1" + "devDependencies": Object { + "promise-all-reject-late": "^5.0.0", }, - "keywords": [], - "author": "", + "keywords": Array [], "license": "ISC", - "dependencies": { - "abbrev": "^1.0.4" + "main": "index.js", + "name": "project", + "scripts": Object { + "test": "echo /"Error: no test specified/" && exit 1", }, - "devDependencies": { - "promise-all-reject-late": "^1.0.1" - } + "version": "1.0.0", } - ` -exports[`test/index.js TAP npm install dev dep > should have expected dev dep added reify output 1`] = ` -added 1 package +exports[`test/index.js TAP basic npm install dev dep > should have expected dev dep added reify output 1`] = ` +added 1 package in {TIME} 1 package is looking for funding run \`npm fund\` for details ` -exports[`test/index.js TAP npm install prodDep@version > should have expected install reify output 1`] = ` -added 1 package +exports[`test/index.js TAP basic npm install prodDep@version > should have expected install reify output 1`] = ` +added 1 package in {TIME} ` -exports[`test/index.js TAP npm install prodDep@version > should have expected lockfile result 1`] = ` -{ - "name": "project", - "version": "1.0.0", +exports[`test/index.js TAP basic npm install prodDep@version > should have expected lockfile result 1`] = ` +Object { "lockfileVersion": 3, - "requires": true, - "packages": { - "": { + "name": "project", + "packages": Object { + "": Object { + "dependencies": Object { + "abbrev": "^1.0.4", + }, + "license": "ISC", "name": "project", "version": "1.0.0", - "license": "ISC", - "dependencies": { - "abbrev": "^1.0.4" - } }, - "node_modules/abbrev": { + "node_modules/abbrev": Object { + "resolved": "http://smoke-test-registry.club/abbrev/-/abbrev-1.0.4.tgz", "version": "1.0.4", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz", - "integrity": "sha1-vVWuXkE7oXIu5Mq6H26hBBSlns0=" - } - } + }, + }, + "requires": true, + "version": "1.0.0", } - ` -exports[`test/index.js TAP npm install prodDep@version > should have expected package.json result 1`] = ` -{ - "name": "project", - "version": "1.0.0", +exports[`test/index.js TAP basic npm install prodDep@version > should have expected package.json result 1`] = ` +Object { + "author": "", + "dependencies": Object { + "abbrev": "^1.0.4", + }, "description": "", + "keywords": Array [], + "license": "ISC", "main": "index.js", - "scripts": { - "test": "echo /"Error: no test specified/" && exit 1" + "name": "project", + "scripts": Object { + "test": "echo /"Error: no test specified/" && exit 1", }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "abbrev": "^1.0.4" - } + "version": "1.0.0", } - ` -exports[`test/index.js TAP npm ls > should have expected ls output 1`] = ` -project@1.0.0 {CWD}/smoke-tests/test/tap-testdir-index/project +exports[`test/index.js TAP basic npm ls > should have expected ls output 1`] = ` +project@1.0.0 {CWD}/{TESTDIR}/project +-- abbrev@1.0.4 -\`-- promise-all-reject-late@1.0.1 +\`-- promise-all-reject-late@5.0.0 ` -exports[`test/index.js TAP npm outdated > should have expected outdated output 1`] = ` +exports[`test/index.js TAP basic npm outdated > should have expected outdated output 1`] = ` Package Current Wanted Latest Location Depended by abbrev 1.0.4 1.1.1 1.1.1 node_modules/abbrev project ` -exports[`test/index.js TAP npm pkg > should have expected npm pkg delete modified package.json result 1`] = ` -{ - "name": "project", - "version": "1.0.0", +exports[`test/index.js TAP basic npm pkg > should have expected npm pkg delete modified package.json result 1`] = ` +Object { + "author": "", + "dependencies": Object { + "abbrev": "^1.0.4", + }, "description": "", + "keywords": Array [], + "license": "ISC", "main": "index.js", - "scripts": { + "name": "project", + "scripts": Object { + "hello": "echo Hello", "test": "echo /"Error: no test specified/" && exit 1", - "hello": "echo Hello" }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "abbrev": "^1.0.4" - } + "version": "1.0.0", } - ` -exports[`test/index.js TAP npm pkg > should have expected npm pkg set modified package.json result 1`] = ` -{ - "name": "project", - "version": "1.0.0", +exports[`test/index.js TAP basic npm pkg > should have expected npm pkg set modified package.json result 1`] = ` +Object { + "author": "", + "dependencies": Object { + "abbrev": "^1.0.4", + }, "description": "", + "keywords": Array [], + "license": "ISC", "main": "index.js", - "scripts": { + "name": "project", + "scripts": Object { + "hello": "echo Hello", "test": "echo /"Error: no test specified/" && exit 1", - "hello": "echo Hello" }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "abbrev": "^1.0.4" + "tap": Object { + "test-env": Array [ + "LC_ALL=sk", + ], }, - "tap": { - "test-env": [ - "LC_ALL=sk" - ] - } + "version": "1.0.0", } - ` -exports[`test/index.js TAP npm pkg > should have expected pkg delete output 1`] = ` +exports[`test/index.js TAP basic npm pkg > should have expected pkg delete output 1`] = ` ` -exports[`test/index.js TAP npm pkg > should have expected pkg get output 1`] = ` +exports[`test/index.js TAP basic npm pkg > should have expected pkg get output 1`] = ` "ISC" ` -exports[`test/index.js TAP npm pkg > should have expected pkg set output 1`] = ` +exports[`test/index.js TAP basic npm pkg > should have expected pkg set output 1`] = ` ` -exports[`test/index.js TAP npm pkg > should print package.json contents 1`] = ` +exports[`test/index.js TAP basic npm pkg > should print package.json contents 1`] = ` { "name": "project", "version": "1.0.0", "description": "", - "ma", + "main": "index.js", "scripts": { "test": "echo /"Error: no test specified/" && exit 1", "hello": "echo Hello" @@ -560,178 +320,162 @@ exports[`test/index.js TAP npm pkg > should print package.json contents 1`] = ` } ` -exports[`test/index.js TAP npm pkg set scripts > should have expected script added package.json result 1`] = ` -{ - "name": "project", - "version": "1.0.0", +exports[`test/index.js TAP basic npm pkg set scripts > should have expected script added package.json result 1`] = ` +Object { + "author": "", + "dependencies": Object { + "abbrev": "^1.0.4", + }, "description": "", - "main": "index.js", - "scripts": { - "test": "echo /"Error: no test specified/" && exit 1", - "hello": "echo Hello" + "devDependencies": Object { + "promise-all-reject-late": "^5.0.0", }, - "keywords": [], - "author": "", + "keywords": Array [], "license": "ISC", - "dependencies": { - "abbrev": "^1.0.4" + "main": "index.js", + "name": "project", + "scripts": Object { + "hello": "echo Hello", + "test": "echo /"Error: no test specified/" && exit 1", }, - "devDependencies": { - "promise-all-reject-late": "^1.0.1" - } + "version": "1.0.0", } - ` -exports[`test/index.js TAP npm pkg set scripts > should have expected set-script output 1`] = ` +exports[`test/index.js TAP basic npm pkg set scripts > should have expected set-script output 1`] = ` ` -exports[`test/index.js TAP npm prefix > should have expected prefix output 1`] = ` -{CWD}/smoke-tests/test/tap-testdir-index/project +exports[`test/index.js TAP basic npm prefix > should have expected prefix output 1`] = ` +{CWD}/{TESTDIR}/project ` -exports[`test/index.js TAP npm run-script > should have expected run-script output 1`] = ` +exports[`test/index.js TAP basic npm run-script > should have expected run-script output 1`] = ` > project@1.0.0 hello > echo Hello Hello ` -exports[`test/index.js TAP npm uninstall > should have expected uninstall lockfile result 1`] = ` -{ - "name": "project", - "version": "1.0.0", +exports[`test/index.js TAP basic npm uninstall > should have expected uninstall lockfile result 1`] = ` +Object { "lockfileVersion": 3, - "requires": true, - "packages": { - "": { + "name": "project", + "packages": Object { + "": Object { + "dependencies": Object { + "abbrev": "^1.0.4", + }, + "license": "ISC", "name": "project", "version": "1.0.0", - "license": "ISC", - "dependencies": { - "abbrev": "^1.0.4" - } }, - "node_modules/abbrev": { + "node_modules/abbrev": Object { + "resolved": "http://smoke-test-registry.club/abbrev/-/abbrev-1.1.1.tgz", "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" - } - } + }, + }, + "requires": true, + "version": "1.0.0", } - ` -exports[`test/index.js TAP npm uninstall > should have expected uninstall package.json result 1`] = ` -{ - "name": "project", - "version": "1.0.0", +exports[`test/index.js TAP basic npm uninstall > should have expected uninstall package.json result 1`] = ` +Object { + "author": "", + "dependencies": Object { + "abbrev": "^1.0.4", + }, "description": "", + "keywords": Array [], + "license": "ISC", "main": "index.js", - "scripts": { + "name": "project", + "scripts": Object { + "hello": "echo Hello", "test": "echo /"Error: no test specified/" && exit 1", - "hello": "echo Hello" }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "abbrev": "^1.0.4" - } + "version": "1.0.0", } - ` -exports[`test/index.js TAP npm uninstall > should have expected uninstall reify output 1`] = ` -removed 1 package +exports[`test/index.js TAP basic npm uninstall > should have expected uninstall reify output 1`] = ` +removed 1 package in {TIME} ` -exports[`test/index.js TAP npm update dep > should have expected update lockfile result 1`] = ` -{ - "name": "project", - "version": "1.0.0", +exports[`test/index.js TAP basic npm update dep > should have expected update lockfile result 1`] = ` +Object { "lockfileVersion": 3, - "requires": true, - "packages": { - "": { + "name": "project", + "packages": Object { + "": Object { + "dependencies": Object { + "abbrev": "^1.0.4", + }, + "devDependencies": Object { + "promise-all-reject-late": "^5.0.0", + }, + "license": "ISC", "name": "project", "version": "1.0.0", - "license": "ISC", - "dependencies": { - "abbrev": "^1.0.4" - }, - "devDependencies": { - "promise-all-reject-late": "^1.0.1" - } }, - "node_modules/abbrev": { + "node_modules/abbrev": Object { + "resolved": "http://smoke-test-registry.club/abbrev/-/abbrev-1.1.1.tgz", "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" }, - "node_modules/promise-all-reject-late": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/promise-all-reject-late/-/promise-all-reject-late-1.0.1.tgz", - "integrity": "sha512-vuf0Lf0lOxyQREH7GDIOUMLS7kz+gs8i6B+Yi8dC68a2sychGrHTJYghMBD6k7eUcH0H5P73EckCA48xijWqXw==", + "node_modules/promise-all-reject-late": Object { "dev": true, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - } - } + "funding": Object { + "url": "https://github.com/sponsors", + }, + "resolved": "http://smoke-test-registry.club/promise-all-reject-late/-/promise-all-reject-late-5.0.0.tgz", + "version": "5.0.0", + }, + }, + "requires": true, + "version": "1.0.0", } - ` -exports[`test/index.js TAP npm update dep > should have expected update package.json result 1`] = ` -{ - "name": "project", - "version": "1.0.0", +exports[`test/index.js TAP basic npm update dep > should have expected update package.json result 1`] = ` +Object { + "author": "", + "dependencies": Object { + "abbrev": "^1.0.4", + }, "description": "", - "main": "index.js", - "scripts": { - "test": "echo /"Error: no test specified/" && exit 1", - "hello": "echo Hello" + "devDependencies": Object { + "promise-all-reject-late": "^5.0.0", }, - "keywords": [], - "author": "", + "keywords": Array [], "license": "ISC", - "dependencies": { - "abbrev": "^1.0.4" + "main": "index.js", + "name": "project", + "scripts": Object { + "hello": "echo Hello", + "test": "echo /"Error: no test specified/" && exit 1", }, - "devDependencies": { - "promise-all-reject-late": "^1.0.1" - } + "version": "1.0.0", } - ` -exports[`test/index.js TAP npm update dep > should have expected update reify output 1`] = ` -changed 1 package +exports[`test/index.js TAP basic npm update dep > should have expected update reify output 1`] = ` +changed 1 package in {TIME} 1 package is looking for funding run \`npm fund\` for details ` -exports[`test/index.js TAP npm view > should have expected view output 1`] = ` -abbrev@1.0.4 | MIT | deps: none | versions: 8 -Like ruby's abbrev module, but in js -https://github.com/isaacs/abbrev-js#readme +exports[`test/index.js TAP basic npm view > should have expected view output 1`] = ` +abbrev@1.0.4 | Proprietary | deps: none | versions: 2 +mocked test package dist -.tarball: https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz -.shasum: bd55ae5e413ba1722ee4caba1f6ea10414a59ecd - -maintainers: -- nlf <quitlahok@gmail.com> -- ruyadorno <ruyadorno@hotmail.com> -- darcyclarke <darcy@darcyclarke.me> -- adam_baldwin <evilpacket@gmail.com> -- isaacs <i@izs.me> +.tarball: http://smoke-test-registry.club/abbrev/-/abbrev-1.0.4.tgz +.shasum: undefined dist-tags: latest: 1.1.1 -published over a year ago by isaacs <i@izs.me> +published just now ` diff --git a/smoke-tests/test/fixtures/abbrev.json b/smoke-tests/test/fixtures/abbrev.json deleted file mode 100644 index ffcf5474a..000000000 --- a/smoke-tests/test/fixtures/abbrev.json +++ /dev/null @@ -1,449 +0,0 @@ -{ - "_id": "abbrev", - "_rev": "72-d1d46bef3d311d6da6737e109e771869", - "name": "abbrev", - "dist-tags": { - "latest": "1.1.1" - }, - "versions": { - "1.0.3": { - "name": "abbrev", - "version": "1.0.3", - "description": "Like ruby's abbrev module, but in js", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "main": "./lib/abbrev.js", - "scripts": { - "test": "node lib/abbrev.js" - }, - "repository": { - "type": "git", - "url": "git://github.com/isaacs/abbrev-js.git" - }, - "_id": "abbrev@1.0.3", - "engines": { - "node": "*" - }, - "_engineSupported": true, - "_npmVersion": "1.0.0rc7", - "_nodeVersion": "v0.5.0-pre", - "_defaultsLoaded": true, - "dist": { - "shasum": "aa049c967f999222aa42e14434f0c562ef468241", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.3.tgz" - }, - "directories": {} - }, - "1.0.4": { - "name": "abbrev", - "version": "1.0.4", - "description": "Like ruby's abbrev module, but in js", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "main": "./lib/abbrev.js", - "scripts": { - "test": "node lib/abbrev.js" - }, - "repository": { - "type": "git", - "url": "http://github.com/isaacs/abbrev-js" - }, - "license": { - "type": "MIT", - "url": "https://github.com/isaacs/abbrev-js/raw/master/LICENSE" - }, - "_id": "abbrev@1.0.4", - "dist": { - "shasum": "bd55ae5e413ba1722ee4caba1f6ea10414a59ecd", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz" - }, - "_npmVersion": "1.1.70", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "directories": {} - }, - "1.0.5": { - "name": "abbrev", - "version": "1.0.5", - "description": "Like ruby's abbrev module, but in js", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "main": "abbrev.js", - "scripts": { - "test": "node test.js" - }, - "repository": { - "type": "git", - "url": "http://github.com/isaacs/abbrev-js" - }, - "license": { - "type": "MIT", - "url": "https://github.com/isaacs/abbrev-js/raw/master/LICENSE" - }, - "bugs": { - "url": "https://github.com/isaacs/abbrev-js/issues" - }, - "homepage": "https://github.com/isaacs/abbrev-js", - "_id": "abbrev@1.0.5", - "_shasum": "5d8257bd9ebe435e698b2fa431afde4fe7b10b03", - "_from": ".", - "_npmVersion": "1.4.7", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "dist": { - "shasum": "5d8257bd9ebe435e698b2fa431afde4fe7b10b03", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.5.tgz" - }, - "directories": {} - }, - "1.0.6": { - "name": "abbrev", - "version": "1.0.6", - "description": "Like ruby's abbrev module, but in js", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "main": "abbrev.js", - "scripts": { - "test": "node test.js" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/isaacs/abbrev-js.git" - }, - "license": "ISC", - "gitHead": "648a6735d9c5a7a04885e3ada49eed4db36181c2", - "bugs": { - "url": "https://github.com/isaacs/abbrev-js/issues" - }, - "homepage": "https://github.com/isaacs/abbrev-js#readme", - "_id": "abbrev@1.0.6", - "_shasum": "b6d632b859b3fa2d6f7e4b195472461b9e32dc30", - "_from": ".", - "_npmVersion": "2.10.0", - "_nodeVersion": "2.0.1", - "_npmUser": { - "name": "isaacs", - "email": "isaacs@npmjs.com" - }, - "dist": { - "shasum": "b6d632b859b3fa2d6f7e4b195472461b9e32dc30", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.6.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "directories": {} - }, - "1.0.7": { - "name": "abbrev", - "version": "1.0.7", - "description": "Like ruby's abbrev module, but in js", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "main": "abbrev.js", - "scripts": { - "test": "tap test.js --cov" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/isaacs/abbrev-js.git" - }, - "license": "ISC", - "devDependencies": { - "tap": "^1.2.0" - }, - "gitHead": "821d09ce7da33627f91bbd8ed631497ed6f760c2", - "bugs": { - "url": "https://github.com/isaacs/abbrev-js/issues" - }, - "homepage": "https://github.com/isaacs/abbrev-js#readme", - "_id": "abbrev@1.0.7", - "_shasum": "5b6035b2ee9d4fb5cf859f08a9be81b208491843", - "_from": ".", - "_npmVersion": "2.10.1", - "_nodeVersion": "2.0.1", - "_npmUser": { - "name": "isaacs", - "email": "isaacs@npmjs.com" - }, - "dist": { - "shasum": "5b6035b2ee9d4fb5cf859f08a9be81b208491843", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "directories": {} - }, - "1.0.9": { - "name": "abbrev", - "version": "1.0.9", - "description": "Like ruby's abbrev module, but in js", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "main": "abbrev.js", - "scripts": { - "test": "tap test.js --cov" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/isaacs/abbrev-js.git" - }, - "license": "ISC", - "devDependencies": { - "tap": "^5.7.2" - }, - "files": [ - "abbrev.js" - ], - "gitHead": "c386cd9dbb1d8d7581718c54d4ba944cc9298d6f", - "bugs": { - "url": "https://github.com/isaacs/abbrev-js/issues" - }, - "homepage": "https://github.com/isaacs/abbrev-js#readme", - "_id": "abbrev@1.0.9", - "_shasum": "91b4792588a7738c25f35dd6f63752a2f8776135", - "_from": ".", - "_npmVersion": "3.9.1", - "_nodeVersion": "4.4.4", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "dist": { - "shasum": "91b4792588a7738c25f35dd6f63752a2f8776135", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/abbrev-1.0.9.tgz_1466016055839_0.7825860097073019" - }, - "directories": {} - }, - "1.1.0": { - "name": "abbrev", - "version": "1.1.0", - "description": "Like ruby's abbrev module, but in js", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "main": "abbrev.js", - "scripts": { - "test": "tap test.js --100", - "preversion": "npm test", - "postversion": "npm publish", - "postpublish": "git push origin --all; git push origin --tags" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/isaacs/abbrev-js.git" - }, - "license": "ISC", - "devDependencies": { - "tap": "^10.1" - }, - "files": [ - "abbrev.js" - ], - "gitHead": "7136d4d95449dc44115d4f78b80ec907724f64e0", - "bugs": { - "url": "https://github.com/isaacs/abbrev-js/issues" - }, - "homepage": "https://github.com/isaacs/abbrev-js#readme", - "_id": "abbrev@1.1.0", - "_shasum": "d0554c2256636e2f56e7c2e5ad183f859428d81f", - "_from": ".", - "_npmVersion": "4.3.0", - "_nodeVersion": "8.0.0-pre", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "dist": { - "shasum": "d0554c2256636e2f56e7c2e5ad183f859428d81f", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/abbrev-1.1.0.tgz_1487054000015_0.9229173036292195" - }, - "directories": {} - }, - "1.1.1": { - "name": "abbrev", - "version": "1.1.1", - "description": "Like ruby's abbrev module, but in js", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "main": "abbrev.js", - "scripts": { - "test": "tap test.js --100", - "preversion": "npm test", - "postversion": "npm publish", - "postpublish": "git push origin --all; git push origin --tags" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/isaacs/abbrev-js.git" - }, - "license": "ISC", - "devDependencies": { - "tap": "^10.1" - }, - "files": [ - "abbrev.js" - ], - "gitHead": "a9ee72ebc8fe3975f1b0c7aeb3a8f2a806a432eb", - "bugs": { - "url": "https://github.com/isaacs/abbrev-js/issues" - }, - "homepage": "https://github.com/isaacs/abbrev-js#readme", - "_id": "abbrev@1.1.1", - "_npmVersion": "5.4.2", - "_nodeVersion": "8.5.0", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "dist": { - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", - "shasum": "f8f2c887ad10bf67f634f005b6987fed3179aac8", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz" - }, - "maintainers": [ - { - "name": "gabra", - "email": "jerry+1@npmjs.com" - }, - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/abbrev-1.1.1.tgz_1506566833068_0.05750026390887797" - }, - "directories": {} - } - }, - "maintainers": [ - { - "email": "quitlahok@gmail.com", - "name": "nlf" - }, - { - "email": "ruyadorno@hotmail.com", - "name": "ruyadorno" - }, - { - "email": "darcy@darcyclarke.me", - "name": "darcyclarke" - }, - { - "email": "evilpacket@gmail.com", - "name": "adam_baldwin" - }, - { - "email": "i@izs.me", - "name": "isaacs" - } - ], - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "description": "Like ruby's abbrev module, but in js", - "time": { - "modified": "2020-10-13T05:04:03.636Z", - "created": "2011-03-21T22:21:11.183Z", - "1.0.1": "2011-03-21T22:21:11.183Z", - "1.0.2": "2011-03-21T22:21:11.183Z", - "1.0.3": "2011-03-21T22:21:11.183Z", - "1.0.3-1": "2011-03-24T23:01:19.581Z", - "1.0.4": "2013-01-09T00:01:24.135Z", - "1.0.5": "2014-04-17T20:09:12.523Z", - "1.0.6": "2015-05-21T00:58:16.778Z", - "1.0.7": "2015-05-30T22:57:54.685Z", - "1.0.9": "2016-06-15T18:41:01.215Z", - "1.1.0": "2017-02-14T06:33:20.235Z", - "1.1.1": "2017-09-28T02:47:13.220Z" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/isaacs/abbrev-js.git" - }, - "users": { - "leesei": true, - "ceejbot": true, - "isaacs": true, - "npm-www": true, - "tunnckocore": true, - "ruanyu1": true, - "leodutra": true, - "jessaustin": true, - "jian263994241": true, - "floriannagel": true, - "tdmalone": true, - "ryanve": true, - "detj": true, - "monjer": true, - "d-band": true - }, - "readme": "# abbrev-js\n\nJust like [ruby's Abbrev](http://apidock.com/ruby/Abbrev).\n\nUsage:\n\n var abbrev = require(\"abbrev\");\n abbrev(\"foo\", \"fool\", \"folding\", \"flop\");\n \n // returns:\n { fl: 'flop'\n , flo: 'flop'\n , flop: 'flop'\n , fol: 'folding'\n , fold: 'folding'\n , foldi: 'folding'\n , foldin: 'folding'\n , folding: 'folding'\n , foo: 'foo'\n , fool: 'fool'\n }\n\nThis is handy for command-line scripts, or other cases where you want to be able to accept shorthands.\n", - "readmeFilename": "README.md", - "homepage": "https://github.com/isaacs/abbrev-js#readme", - "bugs": { - "url": "https://github.com/isaacs/abbrev-js/issues" - }, - "license": "ISC" -} diff --git a/smoke-tests/test/fixtures/abbrev.min.json b/smoke-tests/test/fixtures/abbrev.min.json deleted file mode 100644 index c03d91c9c..000000000 --- a/smoke-tests/test/fixtures/abbrev.min.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "name": "abbrev", - "dist-tags": { - "latest": "1.1.1" - }, - "versions": { - "1.0.3": { - "name": "abbrev", - "version": "1.0.3", - "dist": { - "shasum": "aa049c967f999222aa42e14434f0c562ef468241", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.3.tgz" - }, - "engines": { - "node": "*" - } - }, - "1.0.4": { - "name": "abbrev", - "version": "1.0.4", - "dist": { - "shasum": "bd55ae5e413ba1722ee4caba1f6ea10414a59ecd", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz" - } - }, - "1.0.5": { - "name": "abbrev", - "version": "1.0.5", - "dist": { - "shasum": "5d8257bd9ebe435e698b2fa431afde4fe7b10b03", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.5.tgz" - } - }, - "1.0.6": { - "name": "abbrev", - "version": "1.0.6", - "dist": { - "shasum": "b6d632b859b3fa2d6f7e4b195472461b9e32dc30", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.6.tgz" - } - }, - "1.0.7": { - "name": "abbrev", - "version": "1.0.7", - "devDependencies": { - "tap": "^1.2.0" - }, - "dist": { - "shasum": "5b6035b2ee9d4fb5cf859f08a9be81b208491843", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz" - } - }, - "1.0.9": { - "name": "abbrev", - "version": "1.0.9", - "devDependencies": { - "tap": "^5.7.2" - }, - "dist": { - "shasum": "91b4792588a7738c25f35dd6f63752a2f8776135", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz" - } - }, - "1.1.0": { - "name": "abbrev", - "version": "1.1.0", - "devDependencies": { - "tap": "^10.1" - }, - "dist": { - "shasum": "d0554c2256636e2f56e7c2e5ad183f859428d81f", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz" - } - }, - "1.1.1": { - "name": "abbrev", - "version": "1.1.1", - "devDependencies": { - "tap": "^10.1" - }, - "dist": { - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", - "shasum": "f8f2c887ad10bf67f634f005b6987fed3179aac8", - "tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz" - } - } - }, - "modified": "2020-10-13T05:04:03.636Z" -} diff --git a/smoke-tests/test/fixtures/abbrev/-/abbrev-1.0.4.tgz b/smoke-tests/test/fixtures/abbrev/-/abbrev-1.0.4.tgz Binary files differdeleted file mode 100644 index dfd1b5591..000000000 --- a/smoke-tests/test/fixtures/abbrev/-/abbrev-1.0.4.tgz +++ /dev/null diff --git a/smoke-tests/test/fixtures/abbrev/-/abbrev-1.1.1.tgz b/smoke-tests/test/fixtures/abbrev/-/abbrev-1.1.1.tgz Binary files differdeleted file mode 100644 index 4d9504504..000000000 --- a/smoke-tests/test/fixtures/abbrev/-/abbrev-1.1.1.tgz +++ /dev/null diff --git a/smoke-tests/test/fixtures/promise-all-reject-late.json b/smoke-tests/test/fixtures/promise-all-reject-late.json deleted file mode 100644 index e243b92a3..000000000 --- a/smoke-tests/test/fixtures/promise-all-reject-late.json +++ /dev/null @@ -1,138 +0,0 @@ -{ - "_id": "promise-all-reject-late", - "_rev": "1-bb2ac9479869cc8479d1dd01c568acc0", - "name": "promise-all-reject-late", - "dist-tags": { - "latest": "1.0.1" - }, - "versions": { - "1.0.0": { - "name": "promise-all-reject-late", - "version": "1.0.0", - "description": "Like Promise.all, but save rejections until all promises are resolved", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "https://izs.me" - }, - "license": "ISC", - "scripts": { - "test": "tap", - "preversion": "npm test", - "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" - }, - "tap": { - "check-coverage": true - }, - "devDependencies": { - "tap": "^14.10.5" - }, - "gitHead": "e9614a15b22f421aa97ff281d4e0f23681edbe98", - "_id": "promise-all-reject-late@1.0.0", - "_nodeVersion": "13.3.0", - "_npmVersion": "6.13.4", - "dist": { - "integrity": "sha512-f5XvVl++12pEo7Sv7f7FGfzVuVpeY2msNKjn7nNcXyOSKh5uVu7IAzDO6RE9hDVoHJhxvg+gqEacwkZ891Se5g==", - "shasum": "4fa37515e2d78c3b0462414402a8debce62b8b9f", - "tarball": "https://registry.npmjs.org/promise-all-reject-late/-/promise-all-reject-late-1.0.0.tgz", - "fileCount": 7, - "unpackedSize": 123039, - "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeBmldCRA9TVsSAnZWagAAaigP/2CarvNCbglNS0dgjOoH\n7ZuFo1cG+N8BkZct00TyEJjuB+5UUmv9TSnZogfEOGutvMqUTSRhvm3fOWsJ\n7TXs8zJ6SotDR9+xlxqi/skpYXfRdNjdaMvo9kYO5jaV84pstdbl17sPeYXd\nCudbAKp1sYodlaJyqpyfUd2PWUNe/VGLODmjLogHB4/bevT3tdjsdauKrUS4\n3VFw8sS1Fwp7P2YneNIK3C1TY/Yb66KysZO23VsQemCQFKXpQJMa9B6yj8zs\n5BQp+W5tM70IfW6OXD0+Vt2jWr9jmKmoWVEiL5usJT3zD7vRbeH3xQvSEgDD\nskI8vH8iJ+3EbEOWTGlIu7mX88Dp2KnHOoRUkOR03WJWuGnsTC8Uyqi0F1Xd\nFeFlaeNzynR/R2LcdRNiFOM+1xtzfAtVGF7TIp9UjgJwSNNkEMlkNzQqSiC7\n/AeqsAYoBBNmYWY2fvXdS9HQ4HfIGjI++jCYWX4I7sUvOjqfcwlEz8MwromA\nqeBAFPdvnB0F/q/AOOLkcdsO81jES7ts0nB7bDt0rDbztWWq34BSMDnNoSDo\nDE9q8u7g68tQcr3WmOQr4ro10sSbJVJZmz8DSJKCbVJ+FN0+GM+49oyyhIFl\nOjokXn5U8ASEdiZnmFnt51dr9A4fyjhehotJA6qSs7t2fBe86VnufijC971U\nv3Jc\r\n=lLwf\r\n-----END PGP SIGNATURE-----\r\n" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "directories": {}, - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/promise-all-reject-late_1.0.0_1577478492470_0.9438095135747766" - }, - "_hasShrinkwrap": false - }, - "1.0.1": { - "name": "promise-all-reject-late", - "version": "1.0.1", - "description": "Like Promise.all, but save rejections until all promises are resolved", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "https://izs.me" - }, - "license": "ISC", - "scripts": { - "test": "tap", - "preversion": "npm test", - "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" - }, - "tap": { - "check-coverage": true - }, - "devDependencies": { - "tap": "^14.10.5" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - }, - "gitHead": "c892a9db86650c9229ab4cc70395106684d6818a", - "_id": "promise-all-reject-late@1.0.1", - "_nodeVersion": "12.14.1", - "_npmVersion": "6.13.6", - "dist": { - "integrity": "sha512-vuf0Lf0lOxyQREH7GDIOUMLS7kz+gs8i6B+Yi8dC68a2sychGrHTJYghMBD6k7eUcH0H5P73EckCA48xijWqXw==", - "shasum": "f8ebf13483e5ca91ad809ccc2fcf25f26f8643c2", - "tarball": "https://registry.npmjs.org/promise-all-reject-late/-/promise-all-reject-late-1.0.1.tgz", - "fileCount": 8, - "unpackedSize": 123171, - "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeL65kCRA9TVsSAnZWagAAas4P/2WFFJvncp0LWb3DbE0t\ndx9BhZEwY3W8V6ug8uKvph24LoQp1PakkncscKS7PsCVHyIslD+fi6V99AmI\nOmL2ECAMUd5N69Cs8eTi4tKTNtUoIslfCu0+SMlCAF11D7oBXSabdOxGQofA\nuksoHdCqGM6M1y2BGjK7FR8dSwvgbQCPaUzazZ5w7w4XqVxDlzbvNj2E5mSF\n5HjlT5q239uNQppwPIFpisyi9DKa0ran2N7F2ioZ1PHvhFCqo6rmL8tAQsxQ\n+3OA4eFD0FJCJuqd3MOaY66mkncfNpmPvQYMyigKBUdJJyrgNsB67yfaFduy\ndK198Bnva5kotttQ4EHxM6gkqRm2d9o1/sYmAUtDELgrVDxzeNl+yG+nCkho\n1ta4cY+wy1dTjqAYaprQJ855nIeGGnr3tvz4dEGX/5eyh5K+oYVOYRFvWFX6\nVlEhBmSRqamfW5N1ndMyY18FM+Vc12yu66yZ3z1FqbgEGqdf3EP3lwWqClpP\nbPdXANzHM1FIz1PGHC7IZFWXH5KV1z+JXXahg/d8CLzz0PY6jaBt4c2xDvo7\nLaEAm7kNMbdewKvuTuG7x2Kqyf1KwjpOhXMrq6h0rlFm0pRt0xAArQ9Sglw8\n2Vq9Ic9EEsSIpzA5iQ86O1xkTREGHTB3uTRXUJixXIGkhLkhBB+Uj9y+GoOh\nX+Dm\r\n=yF+m\r\n-----END PGP SIGNATURE-----\r\n" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "directories": {}, - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/promise-all-reject-late_1.0.1_1580183139628_0.5159334029276426" - }, - "_hasShrinkwrap": false - } - }, - "time": { - "created": "2019-12-27T20:28:12.428Z", - "1.0.0": "2019-12-27T20:28:12.645Z", - "modified": "2020-01-28T03:45:42.154Z", - "1.0.1": "2020-01-28T03:45:39.762Z" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "description": "Like Promise.all, but save rejections until all promises are resolved", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "https://izs.me" - }, - "license": "ISC", - "readme": "# promise-all-reject-late\n\nLike Promise.all, but save rejections until all promises are resolved.\n\nThis is handy when you want to do a bunch of things in parallel, and\nrollback on failure, without clobbering or conflicting with those parallel\nactions that may be in flight. For example, creating a bunch of files,\nand deleting any if they don't all succeed.\n\nExample:\n\n```js\nconst lateReject = require('promise-all-reject-late')\n\nconst { promisify } = require('util')\nconst fs = require('fs')\nconst writeFile = promisify(fs.writeFile)\n\nconst createFilesOrRollback = (files) => {\n return lateReject(files.map(file => writeFile(file, 'some data')))\n .catch(er => {\n // try to clean up, then fail with the initial error\n // we know that all write attempts are finished at this point\n return lateReject(files.map(file => rimraf(file)))\n .catch(er => {\n console.error('failed to clean up, youre on your own i guess', er)\n })\n .then(() => {\n // fail with the original error\n throw er\n })\n })\n}\n```\n\n## API\n\n* `lateReject([array, of, promises])` - Resolve all the promises,\n returning a promise that rejects with the first error, or resolves with\n the array of results, but only after all promises are settled.\n", - "readmeFilename": "README.md", - "_cached": false, - "_contentLength": 0 -}
\ No newline at end of file diff --git a/smoke-tests/test/fixtures/promise-all-reject-late.min.json b/smoke-tests/test/fixtures/promise-all-reject-late.min.json deleted file mode 100644 index 699be7aaf..000000000 --- a/smoke-tests/test/fixtures/promise-all-reject-late.min.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "promise-all-reject-late", - "dist-tags": { - "latest": "1.0.1" - }, - "versions": { - "1.0.0": { - "name": "promise-all-reject-late", - "version": "1.0.0", - "devDependencies": { - "tap": "^14.10.5" - }, - "dist": { - "integrity": "sha512-f5XvVl++12pEo7Sv7f7FGfzVuVpeY2msNKjn7nNcXyOSKh5uVu7IAzDO6RE9hDVoHJhxvg+gqEacwkZ891Se5g==", - "shasum": "4fa37515e2d78c3b0462414402a8debce62b8b9f", - "tarball": "https://registry.npmjs.org/promise-all-reject-late/-/promise-all-reject-late-1.0.0.tgz", - "fileCount": 7, - "unpackedSize": 123039, - "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeBmldCRA9TVsSAnZWagAAaigP/2CarvNCbglNS0dgjOoH\n7ZuFo1cG+N8BkZct00TyEJjuB+5UUmv9TSnZogfEOGutvMqUTSRhvm3fOWsJ\n7TXs8zJ6SotDR9+xlxqi/skpYXfRdNjdaMvo9kYO5jaV84pstdbl17sPeYXd\nCudbAKp1sYodlaJyqpyfUd2PWUNe/VGLODmjLogHB4/bevT3tdjsdauKrUS4\n3VFw8sS1Fwp7P2YneNIK3C1TY/Yb66KysZO23VsQemCQFKXpQJMa9B6yj8zs\n5BQp+W5tM70IfW6OXD0+Vt2jWr9jmKmoWVEiL5usJT3zD7vRbeH3xQvSEgDD\nskI8vH8iJ+3EbEOWTGlIu7mX88Dp2KnHOoRUkOR03WJWuGnsTC8Uyqi0F1Xd\nFeFlaeNzynR/R2LcdRNiFOM+1xtzfAtVGF7TIp9UjgJwSNNkEMlkNzQqSiC7\n/AeqsAYoBBNmYWY2fvXdS9HQ4HfIGjI++jCYWX4I7sUvOjqfcwlEz8MwromA\nqeBAFPdvnB0F/q/AOOLkcdsO81jES7ts0nB7bDt0rDbztWWq34BSMDnNoSDo\nDE9q8u7g68tQcr3WmOQr4ro10sSbJVJZmz8DSJKCbVJ+FN0+GM+49oyyhIFl\nOjokXn5U8ASEdiZnmFnt51dr9A4fyjhehotJA6qSs7t2fBe86VnufijC971U\nv3Jc\r\n=lLwf\r\n-----END PGP SIGNATURE-----\r\n" - } - }, - "1.0.1": { - "name": "promise-all-reject-late", - "version": "1.0.1", - "devDependencies": { - "tap": "^14.10.5" - }, - "dist": { - "integrity": "sha512-vuf0Lf0lOxyQREH7GDIOUMLS7kz+gs8i6B+Yi8dC68a2sychGrHTJYghMBD6k7eUcH0H5P73EckCA48xijWqXw==", - "shasum": "f8ebf13483e5ca91ad809ccc2fcf25f26f8643c2", - "tarball": "https://registry.npmjs.org/promise-all-reject-late/-/promise-all-reject-late-1.0.1.tgz", - "fileCount": 8, - "unpackedSize": 123171, - "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeL65kCRA9TVsSAnZWagAAas4P/2WFFJvncp0LWb3DbE0t\ndx9BhZEwY3W8V6ug8uKvph24LoQp1PakkncscKS7PsCVHyIslD+fi6V99AmI\nOmL2ECAMUd5N69Cs8eTi4tKTNtUoIslfCu0+SMlCAF11D7oBXSabdOxGQofA\nuksoHdCqGM6M1y2BGjK7FR8dSwvgbQCPaUzazZ5w7w4XqVxDlzbvNj2E5mSF\n5HjlT5q239uNQppwPIFpisyi9DKa0ran2N7F2ioZ1PHvhFCqo6rmL8tAQsxQ\n+3OA4eFD0FJCJuqd3MOaY66mkncfNpmPvQYMyigKBUdJJyrgNsB67yfaFduy\ndK198Bnva5kotttQ4EHxM6gkqRm2d9o1/sYmAUtDELgrVDxzeNl+yG+nCkho\n1ta4cY+wy1dTjqAYaprQJ855nIeGGnr3tvz4dEGX/5eyh5K+oYVOYRFvWFX6\nVlEhBmSRqamfW5N1ndMyY18FM+Vc12yu66yZ3z1FqbgEGqdf3EP3lwWqClpP\nbPdXANzHM1FIz1PGHC7IZFWXH5KV1z+JXXahg/d8CLzz0PY6jaBt4c2xDvo7\nLaEAm7kNMbdewKvuTuG7x2Kqyf1KwjpOhXMrq6h0rlFm0pRt0xAArQ9Sglw8\n2Vq9Ic9EEsSIpzA5iQ86O1xkTREGHTB3uTRXUJixXIGkhLkhBB+Uj9y+GoOh\nX+Dm\r\n=yF+m\r\n-----END PGP SIGNATURE-----\r\n" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - } - }, - "modified": "2020-01-28T03:45:42.154Z", - "_cached": false, - "_contentLength": 2803 -}
\ No newline at end of file diff --git a/smoke-tests/test/fixtures/promise-all-reject-late/-/promise-all-reject-late-1.0.1.tgz b/smoke-tests/test/fixtures/promise-all-reject-late/-/promise-all-reject-late-1.0.1.tgz Binary files differdeleted file mode 100644 index 7da404423..000000000 --- a/smoke-tests/test/fixtures/promise-all-reject-late/-/promise-all-reject-late-1.0.1.tgz +++ /dev/null diff --git a/smoke-tests/test/fixtures/setup.js b/smoke-tests/test/fixtures/setup.js index bd2e1bf2d..38fc27f3e 100644 --- a/smoke-tests/test/fixtures/setup.js +++ b/smoke-tests/test/fixtures/setup.js @@ -1,157 +1,204 @@ -const fs = require('fs') -const { join, resolve, sep, basename } = require('path') -const which = require('which').sync -const http = require('http') +const fs = require('fs/promises') +const { join, resolve, sep, extname, relative, delimiter } = require('path') +const which = require('which') const spawn = require('@npmcli/promise-spawn') +const justExtend = require('just-extend') +const justSet = require('just-safe-set') +const MockRegistry = require('@npmcli/mock-registry') +const { Blob } = require('buffer') +const http = require('http') +const httpProxy = require('http-proxy') -const { SMOKE_PUBLISH_NPM, CI, PATH, TAP_CHILD_ID = '0' } = process.env -const PORT = 12345 + Number(TAP_CHILD_ID) -const log = CI ? console.error : () => {} -const registry = `http://localhost:${PORT}/` -const corgiDoc = 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*' +const { SMOKE_PUBLISH_NPM, CI, PATH, Path, TAP_CHILD_ID = '0' } = process.env +const PORT = 12345 + (+TAP_CHILD_ID) +const set = (obj, ...args) => justSet(obj, ...args) && obj +const merge = (...args) => justExtend(true, ...args) const normalizePath = path => path.replace(/[A-Z]:/, '').replace(/\\/g, '/') +const exists = (f) => fs.access(f, fs.constants.F_OK).catch(() => false) + +const testdirHelper = (obj) => { + for (const [key, value] of Object.entries(obj)) { + if (extname(key) === '.json') { + obj[key] = JSON.stringify(value, null, 2) + } else if (typeof value === 'object') { + obj[key] = testdirHelper(value) + } else { + obj[key] = value + } + } + return obj +} -const cwd = resolve(__dirname, '..', '..', '..') -const npmCli = join('bin', 'npm-cli.js') -const execArgv = SMOKE_PUBLISH_NPM ? ['npm'] : [process.execPath, join(cwd, npmCli)] -const npmDir = SMOKE_PUBLISH_NPM ? fs.realpathSync(which('npm')).replace(sep + npmCli, '') : cwd +const getNpm = async () => { + const cliRoot = resolve(__dirname, '..', '..', '..') + const cliBin = join('bin', 'npm-cli.js') + + if (SMOKE_PUBLISH_NPM) { + return { + command: ['npm'], + cleanPaths: [ + cliRoot, + await which('npm').then(p => fs.realpath(p).replace(sep + cliBin)), + ], + } + } + + return { + command: [process.execPath, join(cliRoot, cliBin)], + cleanPaths: [process.execPath, cliRoot], + } +} + +module.exports = async (t, { testdir = {}, debug } = {}) => { + const { command, cleanPaths } = await getNpm(t) -module.exports = (t) => { // setup fixtures - const path = t.testdir({ - '.npmrc': '', + const root = t.testdir({ cache: {}, - project: {}, + project: { '.npmrc': '' }, bin: {}, + global: { '.npmrc': '' }, + ...testdirHelper(testdir), }) - const localPrefix = resolve(path, 'project') - const userconfigLocation = resolve(path, '.npmrc') - const cacheLocation = resolve(path, 'cache') - const binLocation = resolve(path, 'bin') - - // setup server - let server = null - t.before(() => new Promise((resolvePromise) => { - server = http.createServer((req, res) => { - res.setHeader('connection', 'close') - - const f = join(__dirname, join('/', req.url.replace(/@/, '').replace(/%2f/i, '/'))) - - // a magic package that causes us to return an error that will be logged - if (basename(f) === 'fail_reflect_user_agent') { - res.statusCode = 404 - res.setHeader('npm-notice', req.headers['user-agent']) - return res.end() - } + const paths = { + root, + project: join(root, 'project'), + global: join(root, 'global'), + userConfig: join(root, 'project', '.npmrc'), + globalConfig: join(root, 'global', '.npmrc'), + cache: join(root, 'cache'), + bin: join(root, 'bin'), + } - const isCorgi = req.headers.accept.includes('application/vnd.npm.install-v1+json') - const file = f + ( - isCorgi && fs.existsSync(`${f}.min.json`) ? '.min.json' - : fs.existsSync(`${f}.json`) ? '.json' - : fs.existsSync(`${f}/index.json`) ? 'index.json' - : '' - ) - - try { - const body = fs.readFileSync(file) - res.setHeader('content-length', body.length) - res.setHeader('content-type', /\.min\.json$/.test(file) ? corgiDoc - : /\.json$/.test(file) ? 'application/json' - : 'application/octet-stream') - res.end(body) - } catch { - res.statusCode = 500 - res.setHeader('content-type', 'text/plain') - res.end('bad') - } - }).listen(PORT, resolvePromise) - })) + const registry = new MockRegistry({ + tap: t, + registry: 'http://smoke-test-registry.club/', + debug, + }) + const httpProxyRegistry = `http://localhost:${PORT}/` + const proxy = httpProxy.createProxyServer({}) + const server = http.createServer((req, res) => proxy.web(req, res, { target: registry.origin })) + await new Promise(res => server.listen(PORT, res)) t.teardown(() => server.close()) // update notifier should never be written - t.afterEach((t) => { - const updateExists = fs.existsSync(join(cacheLocation, '_update-notifier-last-checked')) + t.afterEach(async (t) => { + const updateExists = await exists(join(paths.cache, '_update-notifier-last-checked')) t.equal(updateExists, false) + // this requires that mocks not be shared between sub tests but it helps + // find mistakes quicker instead of waiting for the entire test to end + t.strictSame(registry.nock.pendingMocks(), [], 'no pending mocks after each') + t.strictSame(registry.nock.activeMocks(), [], 'no active mocks after each') }) - t.cleanSnapshot = s => - s + const cleanOutput = s => { // sometimes we print normalized paths in snapshots regardless of - // platform so replace those first - .split(normalizePath(npmDir)) - .join('{CWD}') - .split(normalizePath(cwd)) - .join('{CWD}') - .split(registry) - .join('https://registry.npmjs.org/') - .split(normalizePath(process.execPath)) - .join('node') - // then replace platform style paths - .split(npmDir) - .join('{CWD}') - .split(cwd) - .join('{CWD}') + // platform so replace those first then replace platform style paths + for (const cleanPath of cleanPaths) { + s = s + .split(normalizePath(cleanPath)).join('{CWD}') + .split(cleanPath).join('{CWD}') + .split(relative(cleanPath, t.testdirName)).join('{TESTDIR}') + } + + return s.split(httpProxyRegistry).join('{REGISTRY}') .replace(/\\+/g, '/') .replace(/\r\n/g, '\n') .replace(/ \(in a browser\)/g, '') .replace(/^npm@.* /gm, 'npm ') .replace(/^.*debug-[0-9]+.log$/gm, '') + .replace(/in \d+ms$/gm, 'in {TIME}') + } + t.cleanSnapshot = cleanOutput + const log = !debug && !CI ? () => {} : (...args) => { + console.error(...args.map(a => cleanOutput(a.toString()))) + } - const exec = async (...args) => { - const cmd = [] - const opts = [ - `--registry=${registry}`, - `--cache=${cacheLocation}`, - `--userconfig=${userconfigLocation}`, + const npm = async (...args) => { + const defaultCmd = [] + const defaultOpts = [ + `--registry=${httpProxyRegistry}`, + `--cache=${paths.cache}`, + `--prefix=${paths.project}`, + `--userconfig=${paths.userConfig}`, + `--globalconfig=${paths.globalConfig}`, '--no-audit', '--no-update-notifier', '--loglevel=silly', + '--fetch-timeout=5000', + '--fetch-retries=0', ] - for (const arg of args) { + + const [cmd, opts] = args.reduce((acc, arg) => { if (arg.startsWith('--')) { - opts.push(arg) + acc[1].push(arg) } else { - cmd.push(arg) + acc[0].push(arg) } - } + return acc + }, [defaultCmd, defaultOpts]) - const hasWorkspaceOpt = opts.some(o => /^--workspaces?($|=)/.test(o)) - // XXX: not sure why outdated fails with no-workspaces but works without it - if (!hasWorkspaceOpt && cmd[0] !== 'outdated') { - // This is required so we dont detect any workspace roots above the testdir - opts.push('--no-workspaces') - } + const spawnCmd = command[0] + const spawnArgs = [...command.slice(1), ...cmd, ...opts] - const spawnArgs = [execArgv[0], [...execArgv.slice(1), ...cmd, ...opts]] - log([spawnArgs[0], ...spawnArgs[1]].join('\n')) + log('='.repeat(40)) + log(`\n${spawnCmd} ${spawnArgs.join(' ')}`) - const res = await spawn(...spawnArgs, { - cwd: localPrefix, + const { stderr, stdout } = await spawn(spawnCmd, spawnArgs, { + cwd: paths.project, env: { - HOME: path, - PATH: `${PATH}:${binLocation}`, + HTTP_PROXY: httpProxyRegistry, + HOME: paths.root, + [Path ? 'Path' : 'PATH']: `${Path || PATH}${delimiter}${paths.bin}`, COMSPEC: process.env.COMSPEC, }, }) - log(res.stderr) - return res.stdout + log('\n' + stderr) + log('\n' + stdout) + log('='.repeat(40)) + + return cleanOutput(stdout) + } + + // helpers for reading/writing files and their source + const readFile = async (f) => { + const file = await fs.readFile(join(paths.project, f), 'utf-8') + return extname(f) === '.json' ? JSON.parse(file) : file } - const readFile = (f) => fs.readFileSync(resolve(localPrefix, f), 'utf-8') - const writeFile = (f, d) => fs.writeFileSync(resolve(localPrefix, f), d, 'utf-8') - const rmDir = () => { - for (const f of fs.readdirSync(localPrefix)) { - fs.rmSync(join(localPrefix, f), { recursive: true, force: true }) + // Returns a recurisve list of relative file paths in the testdir root + // will also follow symlinks and print their relative paths + const tree = async (rootDir = paths.project, dir = rootDir) => { + const results = {} + for (const item of await fs.readdir(dir)) { + const itemPath = join(dir, item) + const relPath = relative(rootDir, itemPath) + const stat = await fs.lstat(itemPath) + + if (stat.isSymbolicLink()) { + const realpath = await fs.realpath(itemPath) + merge(results, await tree(rootDir, realpath)) + } else if (stat.isDirectory()) { + merge(results, await tree(rootDir, itemPath)) + } else { + const raw = await readFile(relPath) + const content = typeof raw === 'string' ? `${new Blob([raw]).size} bytes` : raw + merge(results, set({}, relPath.split(sep), content)) + } } + return results } return { - exec, + npm, readFile, - writeFile, - rmDir, + tree, + paths, + registry, isSmokePublish: !!SMOKE_PUBLISH_NPM, } } + +module.exports.testdir = testdirHelper diff --git a/smoke-tests/test/index.js b/smoke-tests/test/index.js index e83e43de4..4aafcb2cb 100644 --- a/smoke-tests/test/index.js +++ b/smoke-tests/test/index.js @@ -2,246 +2,337 @@ const { join } = require('path') const t = require('tap') const setup = require('./fixtures/setup.js') -const { exec, isSmokePublish, readFile, writeFile, rmDir } = setup(t) - -// this test must come first, its package.json will be destroyed and the one -// created in the next test (npm init) will create a new one that must be -// present for later tests -t.test('npm install sends correct user-agent', async t => { - writeFile('package.json', JSON.stringify({ name: 'smoke-test-workspaces' })) - t.teardown(() => rmDir()) - - await exec('init', '-y', `--workspace=${join('packages', 'foo')}`) - - await t.rejects( - exec('install', 'fail_reflect_user_agent'), - { - stderr: /workspaces\/false/, - }, - 'workspaces/false is present in output' - ) - - await t.rejects( - exec('install', 'fail_reflect_user_agent', '--workspaces'), - { - stderr: /workspaces\/true/, +t.test('basic', async t => { + const { registry, npm, isSmokePublish, readFile, paths } = await setup(t, { + testdir: { + packages: { + 'abbrev-1.0.4': { + 'package.json': { name: 'abbrev', version: '1.0.4' }, + 'index.js': 'module.exports = "1.0.4"', + }, + 'abbrev-1.1.1': { + 'package.json': { name: 'abbrev', version: '1.1.1' }, + 'index.js': 'module.exports = "1.1.1"', + }, + 'promise-all-reject-late': { + 'package.json': { name: 'promise-all-reject-late', version: '5.0.0' }, + 'index.js': 'module.exports = null', + }, + }, }, - 'workspaces/true is present in output' - ) -}) - -t.test('npm init', async t => { - const cmdRes = await exec('init', '-y') - - t.matchSnapshot(cmdRes, 'should have successful npm init result') - const pkg = JSON.parse(readFile('package.json')) - t.equal(pkg.name, 'project', 'should have expected generated name') - t.equal(pkg.version, '1.0.0', 'should have expected generated version') -}) - -t.test('npm --version', async t => { - const v = await exec('--version') - - if (isSmokePublish) { - t.match(v.trim(), /-[0-9a-f]{40}\.\d$/, 'must have a git version') - } else { - t.skip('not checking version') - } -}) - -t.test('npm (no args)', async t => { - const err = await exec('--loglevel=notice').catch(e => e) - - t.equal(err.code, 1, 'should exit with error code') - t.equal(err.stderr, '', 'should have no stderr output') - t.matchSnapshot(err.stdout, 'should have expected no args output') -}) - -t.test('npm install prodDep@version', async t => { - const cmdRes = await exec('install', 'abbrev@1.0.4') - - t.matchSnapshot(cmdRes.replace(/in.*s/, ''), 'should have expected install reify output') - t.matchSnapshot(readFile('package.json'), 'should have expected package.json result') - t.matchSnapshot(readFile('package-lock.json'), 'should have expected lockfile result') -}) - -t.test('npm install dev dep', async t => { - const cmdRes = await exec('install', 'promise-all-reject-late', '-D') - - t.matchSnapshot(cmdRes.replace(/in.*s/, ''), 'should have expected dev dep added reify output') - t.matchSnapshot( - readFile('package.json'), - 'should have expected dev dep added package.json result' - ) - t.matchSnapshot( - readFile('package-lock.json'), - 'should have expected dev dep added lockfile result' - ) -}) - -t.test('npm ls', async t => { - const cmdRes = await exec('ls') - - t.matchSnapshot(cmdRes, 'should have expected ls output') -}) - -t.test('npm fund', async t => { - const cmdRes = await exec('fund') - - t.matchSnapshot(cmdRes, 'should have expected fund output') -}) - -t.test('npm explain', async t => { - const cmdRes = await exec('explain', 'abbrev') - - t.matchSnapshot(cmdRes, 'should have expected explain output') -}) - -t.test('npm diff', async t => { - const cmdRes = await exec('diff', '--diff=abbrev@1.0.4', '--diff=abbrev@1.1.1') - - t.matchSnapshot(cmdRes, 'should have expected diff output') -}) - -t.test('npm outdated', async t => { - const err = await exec('outdated').catch(e => e) - - t.equal(err.code, 1, 'should exit with error code') - t.not(err.stderr, '', 'should have stderr output') - t.matchSnapshot(err.stdout, 'should have expected outdated output') -}) - -t.test('npm pkg set scripts', async t => { - const cmdRes = await exec('pkg', 'set', 'scripts.hello=echo Hello') - - t.matchSnapshot(cmdRes, 'should have expected set-script output') - t.matchSnapshot( - readFile('package.json'), - 'should have expected script added package.json result' - ) -}) - -t.test('npm run-script', async t => { - const cmdRes = await exec('run', 'hello') - - t.matchSnapshot(cmdRes, 'should have expected run-script output') -}) - -t.test('npm prefix', async t => { - const cmdRes = await exec('prefix') - - t.matchSnapshot(cmdRes, 'should have expected prefix output') -}) - -t.test('npm view', async t => { - const cmdRes = await exec('view', 'abbrev@1.0.4') - - t.matchSnapshot(cmdRes, 'should have expected view output') -}) - -t.test('npm update dep', async t => { - const cmdRes = await exec('update', 'abbrev') - - t.matchSnapshot(cmdRes.replace(/in.*s/, ''), 'should have expected update reify output') - t.matchSnapshot(readFile('package.json'), 'should have expected update package.json result') - t.matchSnapshot(readFile('package-lock.json'), 'should have expected update lockfile result') -}) - -t.test('npm uninstall', async t => { - const cmdRes = await exec('uninstall', 'promise-all-reject-late') - - t.matchSnapshot(cmdRes.replace(/in.*s/, ''), 'should have expected uninstall reify output') - t.matchSnapshot(readFile('package.json'), 'should have expected uninstall package.json result') - t.matchSnapshot(readFile('package-lock.json'), 'should have expected uninstall lockfile result') -}) - -t.test('npm pkg', async t => { - let cmdRes = await exec('pkg', 'get', 'license') - t.matchSnapshot(cmdRes.replace(/in.*s/, ''), 'should have expected pkg get output') - - cmdRes = await exec('pkg', 'set', 'tap[test-env][0]=LC_ALL=sk') - t.matchSnapshot(cmdRes.replace(/in.*s/, ''), 'should have expected pkg set output') - - t.matchSnapshot( - readFile('package.json'), - 'should have expected npm pkg set modified package.json result' - ) - - cmdRes = await exec('pkg', 'get') - t.matchSnapshot(cmdRes.replace(/in.*s/, ''), 'should print package.json contents') - - cmdRes = await exec('pkg', 'delete', 'tap') - t.matchSnapshot(cmdRes.replace(/in.*s/, ''), 'should have expected pkg delete output') - - t.matchSnapshot( - readFile('package.json'), - 'should have expected npm pkg delete modified package.json result' - ) -}) - -t.test('npm update --no-save --no-package-lock', async t => { - // setup, manually reset dep value - await exec('pkg', 'set', 'dependencies.abbrev==1.0.4') - await exec(`install`) - await exec('pkg', 'set', 'dependencies.abbrev=^1.0.4') - - await exec('update', '--no-save', '--no-package-lock') - - t.equal( - JSON.parse(readFile('package.json')).dependencies.abbrev, - '^1.0.4', - 'should have expected update --no-save --no-package-lock package.json result' - ) - t.equal( - JSON.parse(readFile('package-lock.json')).packages['node_modules/abbrev'].version, - '1.0.4', - 'should have expected update --no-save --no-package-lock lockfile result' - ) -}) - -t.test('npm update --no-save', async t => { - await exec('update', '--no-save') - - t.equal( - JSON.parse(readFile('package.json')).dependencies.abbrev, - '^1.0.4', - 'should have expected update --no-save package.json result' - ) - t.equal( - JSON.parse(readFile('package-lock.json')).packages['node_modules/abbrev'].version, - '1.1.1', - 'should have expected update --no-save lockfile result' - ) -}) - -t.test('npm update --save', async t => { - await exec('update', '--save') - - t.equal( - JSON.parse(readFile('package.json')).dependencies.abbrev, - '^1.1.1', - 'should have expected update --save package.json result' - ) - t.equal( - JSON.parse(readFile('package-lock.json')).packages['node_modules/abbrev'].version, - '1.1.1', - 'should have expected update --save lockfile result' - ) -}) - -t.test('npm ci', async t => { - await exec('uninstall', 'abbrev') - await exec('install', 'abbrev@1.0.4', '--save-exact') - - t.equal( - JSON.parse(readFile('package-lock.json')).packages['node_modules/abbrev'].version, - '1.0.4', - 'should have stored exact installed version' - ) - - await exec('pkg', 'set', 'dependencies.abbrev=^1.1.1') - - const err = await exec('ci', '--loglevel=error').catch(e => e) - t.equal(err.code, 1) - t.matchSnapshot(err.stderr, 'should throw mismatch deps in lock file error') + }) + + const abbrevManifest = () => registry.manifest({ name: 'abbrev', versions: ['1.0.4', '1.1.1'] }) + + await t.test('npm init', async t => { + const cmdRes = await npm('init', '-y') + + t.matchSnapshot(cmdRes, 'should have successful npm init result') + const pkg = await readFile('package.json') + t.equal(pkg.name, 'project', 'should have expected generated name') + t.equal(pkg.version, '1.0.0', 'should have expected generated version') + }) + + await t.test('npm --version', async t => { + const v = await npm('--version') + + if (isSmokePublish) { + t.match(v.trim(), /-[0-9a-f]{40}\.\d$/, 'must have a git version') + } else { + t.match(v.trim(), /^\d+\.\d+\.\d+/, 'has a version') + } + }) + + await t.test('npm (no args)', async t => { + const err = await npm('--loglevel=notice').catch(e => e) + + t.equal(err.code, 1, 'should exit with error code') + t.equal(err.stderr, '', 'should have no stderr output') + t.matchSnapshot(err.stdout, 'should have expected no args output') + }) + + await t.test('npm install prodDep@version', async t => { + const manifest = abbrevManifest() + await registry.package({ + manifest: manifest, + tarballs: { '1.0.4': join(paths.root, 'packages', 'abbrev-1.0.4') }, + }) + + const cmdRes = await npm('install', 'abbrev@1.0.4') + + t.matchSnapshot(cmdRes, 'should have expected install reify output') + t.resolveMatchSnapshot(readFile('package.json'), 'should have expected package.json result') + t.resolveMatchSnapshot(readFile('package-lock.json'), 'should have expected lockfile result') + }) + + await t.test('npm install dev dep', async t => { + const manifest = registry.manifest({ + name: 'promise-all-reject-late', + packuments: [{ version: '5.0.0', funding: 'https://github.com/sponsors' }], + }) + await registry.package({ + manifest: manifest, + tarballs: { '5.0.0': join(paths.root, 'packages', 'promise-all-reject-late') }, + }) + + const cmdRes = await npm('install', 'promise-all-reject-late', '-D') + + t.matchSnapshot(cmdRes, 'should have expected dev dep added reify output') + t.resolveMatchSnapshot( + readFile('package.json'), + 'should have expected dev dep added package.json result' + ) + t.resolveMatchSnapshot( + readFile('package-lock.json'), + 'should have expected dev dep added lockfile result' + ) + }) + + await t.test('npm ls', async t => { + const cmdRes = await npm('ls') + + t.matchSnapshot(cmdRes, 'should have expected ls output') + }) + + await t.test('npm fund', async t => { + const cmdRes = await npm('fund') + + t.matchSnapshot(cmdRes, 'should have expected fund output') + }) + + await t.test('npm explain', async t => { + const cmdRes = await npm('explain', 'abbrev') + + t.matchSnapshot(cmdRes, 'should have expected explain output') + }) + + await t.test('npm diff', async t => { + const manifest = abbrevManifest() + await registry.package({ + manifest: manifest, + tarballs: { '1.0.4': join(paths.root, 'packages', 'abbrev-1.0.4') }, + }) + await registry.package({ + manifest: manifest, + tarballs: { '1.1.1': join(paths.root, 'packages', 'abbrev-1.1.1') }, + }) + + const cmdRes = await npm('diff', '--diff=abbrev@1.0.4', '--diff=abbrev@1.1.1') + + t.matchSnapshot(cmdRes, 'should have expected diff output') + }) + + await t.test('npm outdated', async t => { + await registry.package({ + manifest: registry.manifest({ + name: 'promise-all-reject-late', + versions: ['5.0.0'], + }), + }) + await registry.package({ + manifest: abbrevManifest(), + }) + + const outdated = await npm('outdated').catch(e => e) + + t.equal(outdated.code, 1, 'should exit with error code') + t.not(outdated.stderr, '', 'should have stderr output') + t.matchSnapshot(outdated.stdout, 'should have expected outdated output') + }) + + await t.test('npm pkg set scripts', async t => { + const cmdRes = await npm('pkg', 'set', 'scripts.hello=echo Hello') + + t.matchSnapshot(cmdRes, 'should have expected set-script output') + t.resolveMatchSnapshot( + readFile('package.json'), + 'should have expected script added package.json result' + ) + }) + + await t.test('npm run-script', async t => { + const cmdRes = await npm('run', 'hello') + + t.matchSnapshot(cmdRes, 'should have expected run-script output') + }) + + await t.test('npm prefix', async t => { + const cmdRes = await npm('prefix') + + t.matchSnapshot(cmdRes, 'should have expected prefix output') + }) + + await t.test('npm view', async t => { + await registry.package({ + manifest: abbrevManifest(), + }) + const cmdRes = await npm('view', 'abbrev@1.0.4') + + t.matchSnapshot(cmdRes, 'should have expected view output') + }) + + await t.test('npm update dep', async t => { + const manifest = abbrevManifest() + await registry.package({ + manifest: manifest, + tarballs: { + '1.1.1': join(paths.root, 'packages', 'abbrev-1.1.1'), + }, + }) + + const cmdRes = await npm('update', 'abbrev') + + t.matchSnapshot(cmdRes, 'should have expected update reify output') + t.resolveMatchSnapshot(readFile('package.json'), + 'should have expected update package.json result') + t.resolveMatchSnapshot(readFile('package-lock.json'), + 'should have expected update lockfile result') + }) + + await t.test('npm uninstall', async t => { + const cmdRes = await npm('uninstall', 'promise-all-reject-late') + + t.matchSnapshot(cmdRes, 'should have expected uninstall reify output') + t.resolveMatchSnapshot(readFile('package.json'), + 'should have expected uninstall package.json result') + t.resolveMatchSnapshot(readFile('package-lock.json'), + 'should have expected uninstall lockfile result') + }) + + await t.test('npm pkg', async t => { + let cmdRes = await npm('pkg', 'get', 'license') + t.matchSnapshot(cmdRes, 'should have expected pkg get output') + + cmdRes = await npm('pkg', 'set', 'tap[test-env][0]=LC_ALL=sk') + t.matchSnapshot(cmdRes, 'should have expected pkg set output') + + t.resolveMatchSnapshot( + readFile('package.json'), + 'should have expected npm pkg set modified package.json result' + ) + + cmdRes = await npm('pkg', 'get') + t.matchSnapshot(cmdRes, 'should print package.json contents') + + cmdRes = await npm('pkg', 'delete', 'tap') + t.matchSnapshot(cmdRes, 'should have expected pkg delete output') + + t.resolveMatchSnapshot( + readFile('package.json'), + 'should have expected npm pkg delete modified package.json result' + ) + }) + + await t.test('npm update --no-save --no-package-lock', async t => { + const manifest = abbrevManifest() + await registry.package({ + manifest: manifest, + tarballs: { + '1.0.4': join(paths.root, 'packages', 'abbrev-1.0.4'), + }, + }) + + // setup, manually reset dep value + await npm('pkg', 'set', 'dependencies.abbrev==1.0.4') + await npm('install') + + await registry.package({ + manifest: manifest, + tarballs: { + '1.1.1': join(paths.root, 'packages', 'abbrev-1.1.1'), + }, + }) + + await npm('pkg', 'set', 'dependencies.abbrev=^1.0.4') + await npm('update', '--no-save', '--no-package-lock') + + t.equal( + (await readFile('package.json')).dependencies.abbrev, + '^1.0.4', + 'should have expected update --no-save --no-package-lock package.json result' + ) + t.equal( + (await readFile('package-lock.json')).packages['node_modules/abbrev'].version, + '1.0.4', + 'should have expected update --no-save --no-package-lock lockfile result' + ) + t.equal( + (await readFile('node_modules/abbrev/package.json')).version, + '1.1.1', + 'actual installed version is 1.1.1' + ) + }) + + await t.test('npm update --no-save', async t => { + const manifest = abbrevManifest() + await registry.package({ + manifest: manifest, + tarballs: { + '1.1.1': join(paths.root, 'packages', 'abbrev-1.1.1'), + }, + }) + + await npm('update', '--no-save') + + t.equal( + (await readFile('package.json')).dependencies.abbrev, + '^1.0.4', + 'should have expected update --no-save package.json result' + ) + t.equal( + (await readFile('package-lock.json')).packages['node_modules/abbrev'].version, + '1.1.1', + 'should have expected update --no-save lockfile result' + ) + }) + + await t.test('npm update --save', async t => { + const manifest = abbrevManifest() + await registry.package({ + manifest: manifest, + }) + + await npm('update', '--save') + + t.equal( + (await readFile('package.json')).dependencies.abbrev, + '^1.1.1', + 'should have expected update --save package.json result' + ) + t.equal( + (await readFile('package-lock.json')).packages['node_modules/abbrev'].version, + '1.1.1', + 'should have expected update --save lockfile result' + ) + }) + + await t.test('npm ci', async t => { + await npm('uninstall', 'abbrev') + + const manifest = abbrevManifest() + await registry.package({ + manifest: manifest, + tarballs: { + '1.0.4': join(paths.root, 'packages', 'abbrev-1.0.4'), + }, + }) + + await npm('install', 'abbrev@1.0.4', '--save-exact') + + t.equal( + (await readFile('package-lock.json')).packages['node_modules/abbrev'].version, + '1.0.4', + 'should have stored exact installed version' + ) + + await npm('pkg', 'set', 'dependencies.abbrev=^1.1.1') + + await registry.package({ + manifest, + }) + + const err = await npm('ci', '--loglevel=error').catch(e => e) + t.equal(err.code, 1) + t.matchSnapshot(err.stderr, 'should throw mismatch deps in lock file error') + }) }) diff --git a/smoke-tests/test/workspace-ua.js b/smoke-tests/test/workspace-ua.js new file mode 100644 index 000000000..8cfc40417 --- /dev/null +++ b/smoke-tests/test/workspace-ua.js @@ -0,0 +1,36 @@ + +const t = require('tap') +const setup = require('./fixtures/setup.js') + +t.test('basic', async t => { + const { registry, npm } = await setup(t) + + const mock = () => registry.nock + .get(`/fail_reflect_user_agent`) + // XXX: why does this get fetched twice for each uninstall? + .times(2) + .reply(404, {}, { 'npm-notice': (req) => req.headers['user-agent'] }) + + await t.test('npm install sends correct user-agent', async t => { + await npm('init', '-y') + await npm('init', '-y', `--workspace=foo`) + + mock() + await t.rejects( + npm('install', 'fail_reflect_user_agent'), + { + stderr: /workspaces\/false/, + }, + 'workspaces/false is present in output' + ) + + mock() + await t.rejects( + npm('install', 'fail_reflect_user_agent', '--workspaces'), + { + stderr: /workspaces\/true/, + }, + 'workspaces/true is present in output' + ) + }) +}) |