diff --git a/.github/workflows/ci-libnpmhook.yml b/.github/workflows/ci-libnpmhook.yml deleted file mode 100644 index 6b3f0fb010cc6..0000000000000 --- a/.github/workflows/ci-libnpmhook.yml +++ /dev/null @@ -1,119 +0,0 @@ -# This file is automatically added by @npmcli/template-oss. Do not edit. - -name: CI - libnpmhook - -on: - workflow_dispatch: - pull_request: - paths: - - workspaces/libnpmhook/** - push: - branches: - - latest - - release/v* - paths: - - workspaces/libnpmhook/** - 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@v4 - - 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@v4 - id: node - with: - node-version: 22.x - check-latest: contains('22.x', '.x') - cache: npm - - name: Install Latest npm - uses: ./.github/actions/install-latest-npm - with: - node: ${{ steps.node.outputs.node-version }} - - name: Check Git Status - run: node scripts/git-dirty.js - - name: Reset Deps - run: node scripts/resetdeps.js - - name: Lint - run: npm run lint --ignore-scripts -w libnpmhook - - name: Post Lint - run: npm run postlint --ignore-scripts -w libnpmhook - - 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: macOS - os: macos-13 - shell: bash - - name: Windows - os: windows-latest - shell: cmd - node-version: - - 20.17.0 - - 20.x - - 22.9.0 - - 22.x - exclude: - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 20.17.0 - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 20.x - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 22.9.0 - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 22.x - runs-on: ${{ matrix.platform.os }} - defaults: - run: - shell: ${{ matrix.platform.shell }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - 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@v4 - id: node - with: - node-version: ${{ matrix.node-version }} - check-latest: contains(matrix.node-version, '.x') - cache: npm - - name: Install Latest npm - uses: ./.github/actions/install-latest-npm - with: - node: ${{ steps.node.outputs.node-version }} - - name: Check Git Status - run: node scripts/git-dirty.js - - name: Reset Deps - run: node scripts/resetdeps.js - - name: Add Problem Matcher - run: echo "::add-matcher::.github/matchers/tap.json" - - name: Test - run: npm test --ignore-scripts -w libnpmhook - - name: Check Git Status - run: node scripts/git-dirty.js diff --git a/.gitignore b/.gitignore index 9d9d69178ed10..2b4c8df810b36 100644 --- a/.gitignore +++ b/.gitignore @@ -55,7 +55,6 @@ tap-testdir*/ !/workspaces/libnpmdiff/ !/workspaces/libnpmexec/ !/workspaces/libnpmfund/ -!/workspaces/libnpmhook/ !/workspaces/libnpmorg/ !/workspaces/libnpmpack/ !/workspaces/libnpmpublish/ diff --git a/DEPENDENCIES.json b/DEPENDENCIES.json index d2dbb4c78b2b7..7cbe7ac9572a4 100644 --- a/DEPENDENCIES.json +++ b/DEPENDENCIES.json @@ -28,7 +28,6 @@ [ "@npmcli/run-script", "@npmcli/map-workspaces", - "libnpmhook", "libnpmorg", "libnpmsearch", "libnpmteam", diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index cb51908fc2283..0b173d327356d 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -44,9 +44,6 @@ graph LR; libnpmfund-->npmcli-arborist["@npmcli/arborist"]; libnpmfund-->npmcli-eslint-config["@npmcli/eslint-config"]; libnpmfund-->npmcli-template-oss["@npmcli/template-oss"]; - libnpmhook-->npm-registry-fetch; - libnpmhook-->npmcli-eslint-config["@npmcli/eslint-config"]; - libnpmhook-->npmcli-template-oss["@npmcli/template-oss"]; libnpmorg-->npm-registry-fetch; libnpmorg-->npmcli-eslint-config["@npmcli/eslint-config"]; libnpmorg-->npmcli-template-oss["@npmcli/template-oss"]; @@ -98,7 +95,6 @@ graph LR; npm-->libnpmdiff; npm-->libnpmexec; npm-->libnpmfund; - npm-->libnpmhook; npm-->libnpmorg; npm-->libnpmpack; npm-->libnpmpublish; @@ -363,12 +359,6 @@ graph LR; libnpmfund-->npmcli-eslint-config["@npmcli/eslint-config"]; libnpmfund-->npmcli-template-oss["@npmcli/template-oss"]; libnpmfund-->tap; - libnpmhook-->aproba; - libnpmhook-->nock; - libnpmhook-->npm-registry-fetch; - libnpmhook-->npmcli-eslint-config["@npmcli/eslint-config"]; - libnpmhook-->npmcli-template-oss["@npmcli/template-oss"]; - libnpmhook-->tap; libnpmorg-->aproba; libnpmorg-->minipass; libnpmorg-->nock; @@ -483,7 +473,6 @@ graph LR; npm-->libnpmdiff; npm-->libnpmexec; npm-->libnpmfund; - npm-->libnpmhook; npm-->libnpmorg; npm-->libnpmpack; npm-->libnpmpublish; @@ -799,7 +788,7 @@ packages higher up the chain. - @npmcli/arborist - @npmcli/metavuln-calculator - pacote, @npmcli/config, libnpmversion - - @npmcli/run-script, @npmcli/map-workspaces, libnpmhook, libnpmorg, libnpmsearch, libnpmteam, init-package-json, npm-profile + - @npmcli/run-script, @npmcli/map-workspaces, libnpmorg, libnpmsearch, libnpmteam, init-package-json, npm-profile - @npmcli/package-json, npm-registry-fetch - @npmcli/git, make-fetch-happen - npm-pick-manifest, @npmcli/installed-package-contents, cacache, promzard diff --git a/docs/lib/content/commands/npm-hook.md b/docs/lib/content/commands/npm-hook.md deleted file mode 100644 index c1394e1baad80..0000000000000 --- a/docs/lib/content/commands/npm-hook.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -title: npm-hook -section: 1 -description: Manage registry hooks ---- - -### Synopsis - - - -### Description - -Allows you to manage [npm -hooks](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm), -including adding, removing, listing, and updating. - -Hooks allow you to configure URL endpoints that will be notified whenever a -change happens to any of the supported entity types. Three different types -of entities can be watched by hooks: packages, owners, and scopes. - -To create a package hook, simply reference the package name. - -To create an owner hook, prefix the owner name with `~` (as in, -`~youruser`). - -To create a scope hook, prefix the scope name with `@` (as in, -`@yourscope`). - -The hook `id` used by `update` and `rm` are the IDs listed in `npm hook ls` -for that particular hook. - -The shared secret will be sent along to the URL endpoint so you can verify -the request came from your own configured hook. - -### Example - -Add a hook to watch a package for changes: - -```bash -$ npm hook add lodash https://example.com/ my-shared-secret -``` - -Add a hook to watch packages belonging to the user `substack`: - -```bash -$ npm hook add ~substack https://example.com/ my-shared-secret -``` - -Add a hook to watch packages in the scope `@npm` - -```bash -$ npm hook add @npm https://example.com/ my-shared-secret -``` - -List all your active hooks: - -```bash -$ npm hook ls -``` - -List your active hooks for the `lodash` package: - -```bash -$ npm hook ls lodash -``` - -Update an existing hook's url: - -```bash -$ npm hook update id-deadbeef https://my-new-website.here/ -``` - -Remove a hook: - -```bash -$ npm hook rm id-deadbeef -``` - -### Configuration - - - -### See Also - -* ["Introducing Hooks" blog post](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm) diff --git a/docs/lib/content/nav.yml b/docs/lib/content/nav.yml index 6b7325fec5f12..96c89e5cc1b71 100644 --- a/docs/lib/content/nav.yml +++ b/docs/lib/content/nav.yml @@ -75,9 +75,6 @@ - title: npm help-search url: /commands/npm-help-search description: Get help on npm - - title: npm hook - url: /commands/npm-hook - description: Manage registry hooks - title: npm init url: /commands/npm-init description: Create a package.json file diff --git a/lib/commands/hook.js b/lib/commands/hook.js deleted file mode 100644 index 5793b974197c8..0000000000000 --- a/lib/commands/hook.js +++ /dev/null @@ -1,109 +0,0 @@ -const hookApi = require('libnpmhook') -const { otplease } = require('../utils/auth.js') -const relativeDate = require('tiny-relative-date') -const { output } = require('proc-log') -const BaseCommand = require('../base-cmd.js') - -class Hook extends BaseCommand { - static description = 'Manage registry hooks' - static name = 'hook' - static params = [ - 'registry', - 'otp', - ] - - static usage = [ - 'add [--type=]', - 'ls [pkg]', - 'rm ', - 'update ', - ] - - async exec (args) { - return otplease(this.npm, { ...this.npm.flatOptions }, (opts) => { - switch (args[0]) { - case 'add': - return this.add(args[1], args[2], args[3], opts) - case 'ls': - return this.ls(args[1], opts) - case 'rm': - return this.rm(args[1], opts) - case 'update': - case 'up': - return this.update(args[1], args[2], args[3], opts) - default: - throw this.usageError() - } - }) - } - - async add (pkg, uri, secret, opts) { - const hook = await hookApi.add(pkg, uri, secret, opts) - if (opts.json) { - output.buffer(hook) - } else if (opts.parseable) { - output.standard(Object.keys(hook).join('\t')) - output.standard(Object.keys(hook).map(k => hook[k]).join('\t')) - } else if (!this.npm.silent) { - output.standard(`+ ${this.hookName(hook)} ${opts.unicode ? ' ➜ ' : ' -> '} ${hook.endpoint}`) - } - } - - async ls (pkg, opts) { - const hooks = await hookApi.ls({ ...opts, package: pkg }) - - if (opts.json) { - output.buffer(hooks) - } else if (opts.parseable) { - output.standard(Object.keys(hooks[0]).join('\t')) - hooks.forEach(hook => { - output.standard(Object.keys(hook).map(k => hook[k]).join('\t')) - }) - } else if (!hooks.length) { - output.standard("You don't have any hooks configured yet.") - } else if (!this.npm.silent) { - output.standard(`You have ${hooks.length} hook${hooks.length !== 1 ? 's' : ''} configured.`) - - for (const hook of hooks) { - output.standard(`Hook ${hook.id}: ${this.hookName(hook)}`) - output.standard(`Endpoint: ${hook.endpoint}`) - if (hook.last_delivery) { - /* eslint-disable-next-line max-len */ - output.standard(`Triggered ${relativeDate(hook.last_delivery)}, response code was "${hook.response_code}"\n`) - } else { - output.standard('Never triggered\n') - } - } - } - } - - async rm (id, opts) { - const hook = await hookApi.rm(id, opts) - if (opts.json) { - output.buffer(hook) - } else if (opts.parseable) { - output.standard(Object.keys(hook).join('\t')) - output.standard(Object.keys(hook).map(k => hook[k]).join('\t')) - } else if (!this.npm.silent) { - output.standard(`- ${this.hookName(hook)} ${opts.unicode ? ' ✘ ' : ' X '} ${hook.endpoint}`) - } - } - - async update (id, uri, secret, opts) { - const hook = await hookApi.update(id, uri, secret, opts) - if (opts.json) { - output.buffer(hook) - } else if (opts.parseable) { - output.standard(Object.keys(hook).join('\t')) - output.standard(Object.keys(hook).map(k => hook[k]).join('\t')) - } else if (!this.npm.silent) { - output.standard(`+ ${this.hookName(hook)} ${opts.unicode ? ' ➜ ' : ' -> '} ${hook.endpoint}`) - } - } - - hookName (hook) { - return `${hook.type === 'owner' ? '~' : ''}${hook.name}` - } -} - -module.exports = Hook diff --git a/lib/utils/cmd-list.js b/lib/utils/cmd-list.js index 9017b2b80ce52..039d6ffddeb16 100644 --- a/lib/utils/cmd-list.js +++ b/lib/utils/cmd-list.js @@ -26,7 +26,6 @@ const commands = [ 'get', 'help', 'help-search', - 'hook', 'init', 'install', 'install-ci-test', diff --git a/package-lock.json b/package-lock.json index f6ec54c4eb9cb..c724bdf67bac0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,6 @@ "libnpmdiff", "libnpmexec", "libnpmfund", - "libnpmhook", "libnpmorg", "libnpmpack", "libnpmpublish", @@ -115,7 +114,6 @@ "libnpmdiff": "^7.0.0", "libnpmexec": "^9.0.0", "libnpmfund": "^6.0.0", - "libnpmhook": "^11.0.0", "libnpmorg": "^7.0.0", "libnpmpack": "^8.0.0", "libnpmpublish": "^10.0.0", @@ -9371,10 +9369,6 @@ "resolved": "workspaces/libnpmfund", "link": true }, - "node_modules/libnpmhook": { - "resolved": "workspaces/libnpmhook", - "link": true - }, "node_modules/libnpmorg": { "resolved": "workspaces/libnpmorg", "link": true @@ -18010,6 +18004,7 @@ }, "workspaces/libnpmhook": { "version": "11.0.0", + "extraneous": true, "license": "ISC", "dependencies": { "aproba": "^2.0.0", diff --git a/package.json b/package.json index 75a0d8a732bce..b1ade20fb7cbf 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,6 @@ "libnpmdiff": "^7.0.0", "libnpmexec": "^9.0.0", "libnpmfund": "^6.0.0", - "libnpmhook": "^11.0.0", "libnpmorg": "^7.0.0", "libnpmpack": "^8.0.0", "libnpmpublish": "^10.0.0", @@ -150,7 +149,6 @@ "libnpmdiff", "libnpmexec", "libnpmfund", - "libnpmhook", "libnpmorg", "libnpmpack", "libnpmpublish", diff --git a/tap-snapshots/test/lib/commands/completion.js.test.cjs b/tap-snapshots/test/lib/commands/completion.js.test.cjs index a538e3c068863..9b6f1ba51c787 100644 --- a/tap-snapshots/test/lib/commands/completion.js.test.cjs +++ b/tap-snapshots/test/lib/commands/completion.js.test.cjs @@ -64,7 +64,6 @@ Array [ get help help-search - hook init install install-ci-test diff --git a/tap-snapshots/test/lib/commands/publish.js.test.cjs b/tap-snapshots/test/lib/commands/publish.js.test.cjs index 78395c5cbca63..c0dc06b568180 100644 --- a/tap-snapshots/test/lib/commands/publish.js.test.cjs +++ b/tap-snapshots/test/lib/commands/publish.js.test.cjs @@ -174,7 +174,6 @@ Object { "man/man1/npm-fund.1", "man/man1/npm-help-search.1", "man/man1/npm-help.1", - "man/man1/npm-hook.1", "man/man1/npm-init.1", "man/man1/npm-install-ci-test.1", "man/man1/npm-install-test.1", diff --git a/tap-snapshots/test/lib/commands/search.js.test.cjs b/tap-snapshots/test/lib/commands/search.js.test.cjs index 7645e60abb88b..f1fa0363c8e68 100644 --- a/tap-snapshots/test/lib/commands/search.js.test.cjs +++ b/tap-snapshots/test/lib/commands/search.js.test.cjs @@ -45,12 +45,6 @@ npm Team management APIs Version 2.0.2 published 2020-11-03 by nlf Maintainers: nlf ruyadorno darcyclarke isaacs https://npm.im/libnpmteam -libnpmhook -programmatic API for managing npm registry hooks -Version 6.0.1 published 2020-11-03 by nlf -Maintainers: nlf ruyadorno darcyclarke isaacs -Keywords: npm hooks registry npm api -https://npm.im/libnpmhook libnpmpublish Programmatic API for the bits behind npm publish and unpublish Version 4.0.0 published 2020-11-03 by nlf @@ -124,12 +118,6 @@ npm Team management APIs Version 2.0.2 published 2020-11-03 by nlf Maintainers: nlf ruyadorno darcyclarke isaacs https://npm.im/libnpmteam -libnpmhook -programmatic API for managing npm registry hooks -Version 6.0.1 published 2020-11-03 by nlf -Maintainers: nlf ruyadorno darcyclarke isaacs -Keywords: npm hooks registry npm api -https://npm.im/libnpmhook libnpmpublish Programmatic API for the bits behind npm publish and unpublish Version 4.0.0 published 2020-11-03 by nlf @@ -171,7 +159,6 @@ libnpmaccess programmatic library for \`npm access\` commands 2020-11-03 4.0.1 l libnpmorg Programmatic api for \`npm org\` commands 2020-11-03 2.0.1 libnpm,npm,package manager,api,orgs,teams libnpmsearch Programmatic API for searching in npm and compatible registries. 2020-12-08 3.1.0 npm,search,api,libnpm libnpmteam npm Team management APIs 2020-11-03 2.0.2 -libnpmhook programmatic API for managing npm registry hooks 2020-11-03 6.0.1 npm,hooks,registry,npm api libnpmpublish Programmatic API for the bits behind npm publish and unpublish 2020-11-03 4.0.0 libnpmfund Programmatic API for npm fund 2020-12-08 1.0.2 npm,npmcli,libnpm,cli,git,fund,gitfund @npmcli/map-workspaces Retrieves a name:pathname Map for a given workspaces config 2020-09-30 1.0.1 npm,,bad map,npmcli,libnpm,cli,workspaces,map-workspaces @@ -235,12 +222,6 @@ npm Team management APIs Version 2.0.2 published 2020-11-03 by nlf Maintainers: nlf ruyadorno darcyclarke isaacs https://npm.im/libnpmteam -libnpmhook -programmatic API for managing npm registry hooks -Version 6.0.1 published 2020-11-03 by nlf -Maintainers: nlf ruyadorno darcyclarke isaacs -Keywords: npm hooks registry npm api -https://npm.im/libnpmhook libnpmpublish Programmatic API for the bits behind npm publish and unpublish Version 4.0.0 published 2020-11-03 by nlf @@ -318,12 +299,6 @@ npm Team management APIs Version 2.0.2 published 2020-11-03 by nlf Maintainers: nlf ruyadorno darcyclarke isaacs https://npm.im/libnpmteam -libnpmhook -programmatic API for managing npm registry hooks -Version 6.0.1 published 2020-11-03 by nlf -Maintainers: nlf ruyadorno darcyclarke isaacs -Keywords: npm hooks registry npm api -https://npm.im/libnpmhook libnpmpublish Programmatic API for the bits behind npm publish and unpublish Version 4.0.0 published 2020-11-03 by nlf @@ -392,12 +367,6 @@ npm Team management APIs Version 2.0.2 published 2020-11-03 by nlf Maintainers: nlf ruyadorno darcyclarke isaacs https://npm.im/libnpmteam -libnpmhook -programmatic API for managing npm registry hooks -Version 6.0.1 published 2020-11-03 by nlf -Maintainers: nlf ruyadorno darcyclarke isaacs -Keywords: npm hooks registry npm api -https://npm.im/libnpmhook libnpmpublish Programmatic API for the bits behind npm publish and unpublish Version 4.0.0 published 2020-11-03 by nlf @@ -466,12 +435,6 @@ npm Team management APIs Version 2.0.2 published 2020-11-03 by nlf Maintainers: nlf ruyadorno darcyclarke isaacs https://npm.im/libnpmteam -libnpmhook -programmatic API for managing npm registry hooks -Version 6.0.1 published 2020-11-03 by nlf -Maintainers: nlf ruyadorno darcyclarke isaacs -Keywords: npm hooks registry npm api -https://npm.im/libnpmhook libnpmpublish Programmatic API for the bits behind npm publish and unpublish Version 4.0.0 published 2020-11-03 by nlf @@ -772,51 +735,6 @@ Array [ "scope": "unscoped", "version": "2.0.2", }, - Object { - "author": Object { - "email": "kzm@sykosomatic.org", - "name": "Kat Marchán", - }, - "date": "2020-11-03T19:20:45.818Z", - "description": "programmatic API for managing npm registry hooks", - "keywords": Array [ - "npm", - "hooks", - "registry", - "npm api", - ], - "links": Object { - "bugs": "https://github.com/npm/libnpmhook/issues", - "homepage": "https://github.com/npm/libnpmhook#readme", - "npm": "https://www.npmjs.com/package/libnpmhook", - "repository": "https://github.com/npm/libnpmhook", - }, - "maintainers": Array [ - Object { - "email": "quitlahok@gmail.com", - "username": "nlf", - }, - Object { - "email": "ruyadorno@hotmail.com", - "username": "ruyadorno", - }, - Object { - "email": "darcy@darcyclarke.me", - "username": "darcyclarke", - }, - Object { - "email": "i@izs.me", - "username": "isaacs", - }, - ], - "name": "libnpmhook", - "publisher": Object { - "email": "quitlahok@gmail.com", - "username": "nlf", - }, - "scope": "unscoped", - "version": "6.0.1", - }, Object { "author": Object { "email": "support@npmjs.com", diff --git a/tap-snapshots/test/lib/docs.js.test.cjs b/tap-snapshots/test/lib/docs.js.test.cjs index 81cd5c1f11ba8..8e1c57be0bf93 100644 --- a/tap-snapshots/test/lib/docs.js.test.cjs +++ b/tap-snapshots/test/lib/docs.js.test.cjs @@ -119,7 +119,6 @@ Array [ "get", "help", "help-search", - "hook", "init", "install", "install-ci-test", @@ -3200,33 +3199,6 @@ Note: This command is unaware of workspaces. #### \`long\` ` -exports[`test/lib/docs.js TAP usage hook > must match snapshot 1`] = ` -Manage registry hooks - -Usage: -npm hook add [--type=] -npm hook ls [pkg] -npm hook rm -npm hook update - -Options: -[--registry ] [--otp ] - -Run "npm help hook" for more info - -\`\`\`bash -npm hook add [--type=] -npm hook ls [pkg] -npm hook rm -npm hook update -\`\`\` - -Note: This command is unaware of workspaces. - -#### \`registry\` -#### \`otp\` -` - exports[`test/lib/docs.js TAP usage init > must match snapshot 1`] = ` Create a package.json file diff --git a/tap-snapshots/test/lib/npm.js.test.cjs b/tap-snapshots/test/lib/npm.js.test.cjs index 32ab47ef06b18..0864ffe37d297 100644 --- a/tap-snapshots/test/lib/npm.js.test.cjs +++ b/tap-snapshots/test/lib/npm.js.test.cjs @@ -34,13 +34,12 @@ All commands: access, adduser, audit, bugs, cache, ci, completion, config, dedupe, deprecate, diff, dist-tag, docs, doctor, edit, exec, explain, explore, find-dupes, fund, get, help, - help-search, hook, init, install, install-ci-test, - install-test, link, ll, login, logout, ls, org, outdated, - owner, pack, ping, pkg, prefix, profile, prune, publish, - query, rebuild, repo, restart, root, run-script, sbom, - search, set, shrinkwrap, star, stars, start, stop, team, - test, token, uninstall, unpublish, unstar, update, version, - view, whoami + help-search, init, install, install-ci-test, install-test, + link, ll, login, logout, ls, org, outdated, owner, pack, + ping, pkg, prefix, profile, prune, publish, query, rebuild, + repo, restart, root, run-script, sbom, search, set, + shrinkwrap, star, stars, start, stop, team, test, token, + uninstall, unpublish, unstar, update, version, view, whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -76,7 +75,7 @@ All commands: edit, exec, explain, explore, find-dupes, fund, get, help, - help-search, hook, init, + help-search, init, install, install-ci-test, install-test, link, ll, @@ -128,7 +127,7 @@ All commands: edit, exec, explain, explore, find-dupes, fund, get, help, - help-search, hook, init, + help-search, init, install, install-ci-test, install-test, link, ll, @@ -175,13 +174,12 @@ All commands: access, adduser, audit, bugs, cache, ci, completion, config, dedupe, deprecate, diff, dist-tag, docs, doctor, edit, exec, explain, explore, find-dupes, fund, get, help, - help-search, hook, init, install, install-ci-test, - install-test, link, ll, login, logout, ls, org, outdated, - owner, pack, ping, pkg, prefix, profile, prune, publish, - query, rebuild, repo, restart, root, run-script, sbom, - search, set, shrinkwrap, star, stars, start, stop, team, - test, token, uninstall, unpublish, unstar, update, version, - view, whoami + help-search, init, install, install-ci-test, install-test, + link, ll, login, logout, ls, org, outdated, owner, pack, + ping, pkg, prefix, profile, prune, publish, query, rebuild, + repo, restart, root, run-script, sbom, search, set, + shrinkwrap, star, stars, start, stop, team, test, token, + uninstall, unpublish, unstar, update, version, view, whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -217,7 +215,7 @@ All commands: edit, exec, explain, explore, find-dupes, fund, get, help, - help-search, hook, init, + help-search, init, install, install-ci-test, install-test, link, ll, @@ -269,7 +267,7 @@ All commands: edit, exec, explain, explore, find-dupes, fund, get, help, - help-search, hook, init, + help-search, init, install, install-ci-test, install-test, link, ll, @@ -321,7 +319,7 @@ All commands: edit, exec, explain, explore, find-dupes, fund, get, help, - help-search, hook, init, + help-search, init, install, install-ci-test, install-test, link, ll, login, logout, ls, org, @@ -367,13 +365,13 @@ All commands: access, adduser, audit, bugs, cache, ci, completion, config, dedupe, deprecate, diff, dist-tag, docs, doctor, edit, exec, explain, explore, find-dupes, fund, get, help, - help-search, hook, init, install, install-ci-test, - install-test, link, ll, login, logout, ls, org, outdated, - owner, pack, ping, pkg, prefix, profile, prune, publish, - query, rebuild, repo, restart, root, run-script, sbom, - search, set, shrinkwrap, star, stars, start, stop, team, - test, token, uninstall, unpublish, unstar, update, version, - view, whoami + help-search, init, install, install-ci-test, install-test, + link, ll, login, logout, ls, org, outdated, owner, pack, + ping, pkg, prefix, profile, prune, publish, query, rebuild, + repo, restart, root, run-script, sbom, search, set, + shrinkwrap, star, stars, start, stop, team, test, token, + uninstall, unpublish, unstar, update, version, view, + whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -404,13 +402,12 @@ All commands: access, adduser, audit, bugs, cache, ci, completion, config, dedupe, deprecate, diff, dist-tag, docs, doctor, edit, exec, explain, explore, find-dupes, fund, get, help, - help-search, hook, init, install, install-ci-test, - install-test, link, ll, login, logout, ls, org, outdated, - owner, pack, ping, pkg, prefix, profile, prune, publish, - query, rebuild, repo, restart, root, run-script, sbom, - search, set, shrinkwrap, star, stars, start, stop, team, - test, token, uninstall, unpublish, unstar, update, version, - view, whoami + help-search, init, install, install-ci-test, install-test, + link, ll, login, logout, ls, org, outdated, owner, pack, + ping, pkg, prefix, profile, prune, publish, query, rebuild, + repo, restart, root, run-script, sbom, search, set, + shrinkwrap, star, stars, start, stop, team, test, token, + uninstall, unpublish, unstar, update, version, view, whoami Specify configs in the ini-formatted file: {USERCONFIG} @@ -441,13 +438,12 @@ All commands: access, adduser, audit, bugs, cache, ci, completion, config, dedupe, deprecate, diff, dist-tag, docs, doctor, edit, exec, explain, explore, find-dupes, fund, get, help, - help-search, hook, init, install, install-ci-test, - install-test, link, ll, login, logout, ls, org, outdated, - owner, pack, ping, pkg, prefix, profile, prune, publish, - query, rebuild, repo, restart, root, run-script, sbom, - search, set, shrinkwrap, star, stars, start, stop, team, - test, token, uninstall, unpublish, unstar, update, version, - view, whoami + help-search, init, install, install-ci-test, install-test, + link, ll, login, logout, ls, org, outdated, owner, pack, + ping, pkg, prefix, profile, prune, publish, query, rebuild, + repo, restart, root, run-script, sbom, search, set, + shrinkwrap, star, stars, start, stop, team, test, token, + uninstall, unpublish, unstar, update, version, view, whoami Specify configs in the ini-formatted file: {USERCONFIG} diff --git a/test/fixtures/libnpmsearch-stream-result.js b/test/fixtures/libnpmsearch-stream-result.js index 872a7940340d4..db1c0fae5752b 100644 --- a/test/fixtures/libnpmsearch-stream-result.js +++ b/test/fixtures/libnpmsearch-stream-result.js @@ -140,28 +140,6 @@ module.exports = [ { username: 'isaacs', email: 'i@izs.me' }, ], }, - { - name: 'libnpmhook', - scope: 'unscoped', - version: '6.0.1', - description: 'programmatic API for managing npm registry hooks', - keywords: ['npm', 'hooks', 'registry', 'npm api'], - date: '2020-11-03T19:20:45.818Z', - links: { - npm: 'https://www.npmjs.com/package/libnpmhook', - homepage: 'https://github.com/npm/libnpmhook#readme', - repository: 'https://github.com/npm/libnpmhook', - bugs: 'https://github.com/npm/libnpmhook/issues', - }, - author: { name: 'Kat Marchán', email: 'kzm@sykosomatic.org' }, - publisher: { username: 'nlf', email: 'quitlahok@gmail.com' }, - maintainers: [ - { username: 'nlf', email: 'quitlahok@gmail.com' }, - { username: 'ruyadorno', email: 'ruyadorno@hotmail.com' }, - { username: 'darcyclarke', email: 'darcy@darcyclarke.me' }, - { username: 'isaacs', email: 'i@izs.me' }, - ], - }, { name: 'libnpmpublish', scope: 'unscoped', diff --git a/test/lib/commands/hook.js b/test/lib/commands/hook.js deleted file mode 100644 index 003dae647a35a..0000000000000 --- a/test/lib/commands/hook.js +++ /dev/null @@ -1,640 +0,0 @@ -const t = require('tap') -const mockNpm = require('../../fixtures/mock-npm') - -const mockHook = async (t, { hookResponse, ...npmOpts } = {}) => { - const now = Date.now() - - let hookArgs = null - - const pkgTypes = { - semver: 'package', - '@npmcli': 'scope', - npm: 'owner', - } - - const libnpmhook = { - add: async (pkg, uri, secret, opts) => { - hookArgs = { pkg, uri, secret, opts } - return { id: 1, name: pkg, type: pkgTypes[pkg], endpoint: uri } - }, - ls: async opts => { - hookArgs = opts - let id = 0 - if (hookResponse) { - return hookResponse - } - - return Object.keys(pkgTypes).map(name => ({ - id: ++id, - name, - type: pkgTypes[name], - endpoint: 'https://google.com', - last_delivery: id % 2 === 0 ? now : undefined, - response_code: 200, - })) - }, - rm: async (id, opts) => { - hookArgs = { id, opts } - const pkg = Object.keys(pkgTypes)[0] - return { - id: 1, - name: pkg, - type: pkgTypes[pkg], - endpoint: 'https://google.com', - } - }, - update: async (id, uri, secret, opts) => { - hookArgs = { id, uri, secret, opts } - const pkg = Object.keys(pkgTypes)[0] - return { id, name: pkg, type: pkgTypes[pkg], endpoint: uri } - }, - } - - const mock = await mockNpm(t, { - ...npmOpts, - command: 'hook', - mocks: { - libnpmhook, - ...npmOpts.mocks, - }, - }) - - return { - ...mock, - now, - hookArgs: () => hookArgs, - } -} - -t.test('npm hook no args', async t => { - const { hook } = await mockHook(t) - await t.rejects(hook.exec([]), hook.usage, 'throws usage with no arguments') -}) - -t.test('npm hook add', async t => { - const { npm, hook, outputs, hookArgs } = await mockHook(t) - await hook.exec(['add', 'semver', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - pkg: 'semver', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'provided the correct arguments to libnpmhook' - ) - t.strictSame(outputs[0], '+ semver -> https://google.com', 'prints the correct output') -}) - -t.test('npm hook add - correct owner hook output', async t => { - const { npm, hook, outputs, hookArgs } = await mockHook(t) - await hook.exec(['add', '~npm', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - pkg: '~npm', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'provided the correct arguments to libnpmhook' - ) - t.strictSame(outputs[0], '+ ~npm -> https://google.com', 'prints the correct output') -}) - -t.test('npm hook add - correct scope hook output', async t => { - const { npm, hook, outputs, hookArgs } = await mockHook(t) - await hook.exec(['add', '@npmcli', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - pkg: '@npmcli', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'provided the correct arguments to libnpmhook' - ) - t.strictSame(outputs[0], '+ @npmcli -> https://google.com', 'prints the correct output') -}) - -t.test('npm hook add - unicode output', async t => { - const config = { - unicode: true, - } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['add', 'semver', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - pkg: 'semver', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'provided the correct arguments to libnpmhook' - ) - t.strictSame(outputs[0], '+ semver ➜ https://google.com', 'prints the correct output') -}) - -t.test('npm hook add - json output', async t => { - const config = { - json: true, - } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['add', '@npmcli', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - pkg: '@npmcli', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'provided the correct arguments to libnpmhook' - ) - t.strictSame( - JSON.parse(outputs[0]), - { - id: 1, - name: '@npmcli', - endpoint: 'https://google.com', - type: 'scope', - }, - 'prints the correct json output' - ) -}) - -t.test('npm hook add - parseable output', async t => { - const config = { - parseable: true, - } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['add', '@npmcli', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - pkg: '@npmcli', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'provided the correct arguments to libnpmhook' - ) - - t.strictSame( - outputs[0].split(/\t/), - ['id', 'name', 'type', 'endpoint'], - 'prints the correct parseable output headers' - ) - t.strictSame( - outputs[1].split(/\t/), - ['1', '@npmcli', 'scope', 'https://google.com'], - 'prints the correct parseable values' - ) -}) - -t.test('npm hook add - silent output', async t => { - const config = { loglevel: 'silent' } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['add', '@npmcli', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - pkg: '@npmcli', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'provided the correct arguments to libnpmhook' - ) - t.strictSame(outputs, [], 'printed no output') -}) - -t.test('npm hook ls', async t => { - const { npm, hook, outputs, hookArgs } = await mockHook(t) - await hook.exec(['ls']) - - t.match( - hookArgs(), - { - ...npm.flatOptions, - package: undefined, - }, - 'received the correct arguments' - ) - t.strictSame(outputs, [ - 'You have 3 hooks configured.', - 'Hook 1: semver', - 'Endpoint: https://google.com', - 'Never triggered\n', - 'Hook 2: @npmcli', - 'Endpoint: https://google.com', - 'Triggered just now, response code was "200"\n', - 'Hook 3: ~npm', - 'Endpoint: https://google.com', - 'Never triggered\n', - ]) -}) - -t.test('npm hook ls, no results', async t => { - const hookResponse = [] - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - hookResponse, - }) - - await hook.exec(['ls']) - - t.match( - hookArgs(), - { - ...npm.flatOptions, - package: undefined, - }, - 'received the correct arguments' - ) - t.strictSame(outputs, [`You don't have any hooks configured yet.`]) -}) - -t.test('npm hook ls, single result', async t => { - const hookResponse = [ - { - id: 1, - name: 'semver', - type: 'package', - endpoint: 'https://google.com', - }, - ] - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - hookResponse, - }) - - await hook.exec(['ls']) - - t.match( - hookArgs(), - { - ...npm.flatOptions, - package: undefined, - }, - 'received the correct arguments' - ) - t.strictSame(outputs, [ - 'You have 1 hook configured.', - 'Hook 1: semver', - 'Endpoint: https://google.com', - 'Never triggered\n', - ]) -}) - -t.test('npm hook ls - json output', async t => { - const config = { - json: true, - } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['ls']) - - t.match( - hookArgs(), - { - ...npm.flatOptions, - package: undefined, - }, - 'received the correct arguments' - ) - const out = JSON.parse(outputs[0]) - t.match( - out, - [ - { - id: 1, - name: 'semver', - type: 'package', - endpoint: 'https://google.com', - }, - { - id: 2, - name: 'npmcli', - type: 'scope', - endpoint: 'https://google.com', - }, - { - id: 3, - name: 'npm', - type: 'owner', - endpoint: 'https://google.com', - }, - ], - 'prints the correct output' - ) -}) - -t.test('npm hook ls - parseable output', async t => { - const config = { - parseable: true, - } - const { npm, hook, outputs, hookArgs, now } = await mockHook(t, { - config, - }) - - await hook.exec(['ls']) - - t.match( - hookArgs(), - { - ...npm.flatOptions, - package: undefined, - }, - 'received the correct arguments' - ) - t.strictSame( - outputs.map(line => line.split(/\t/)), - [ - ['id', 'name', 'type', 'endpoint', 'last_delivery', 'response_code'], - ['1', 'semver', 'package', 'https://google.com', '', '200'], - ['2', '@npmcli', 'scope', 'https://google.com', `${now}`, '200'], - ['3', 'npm', 'owner', 'https://google.com', '', '200'], - ], - 'prints the correct result' - ) -}) - -t.test('npm hook ls - silent output', async t => { - const config = { loglevel: 'silent' } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['ls']) - - t.match( - hookArgs(), - { - ...npm.flatOptions, - package: undefined, - }, - 'received the correct arguments' - ) - t.strictSame(outputs, [], 'printed no output') -}) - -t.test('npm hook rm', async t => { - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - }) - await hook.exec(['rm', '1']) - - t.match( - hookArgs(), - { - id: '1', - opts: npm.flatOptions, - }, - 'received the correct arguments' - ) - t.strictSame(outputs[0], '- semver X https://google.com', 'printed the correct output') -}) - -t.test('npm hook rm - unicode output', async t => { - const config = { - unicode: true, - } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['rm', '1']) - - t.match( - hookArgs(), - { - id: '1', - opts: npm.flatOptions, - }, - 'received the correct arguments' - ) - t.strictSame(outputs[0], '- semver ✘ https://google.com', 'printed the correct output') -}) - -t.test('npm hook rm - silent output', async t => { - const config = { loglevel: 'silent' } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['rm', '1']) - - t.match( - hookArgs(), - { - id: '1', - opts: npm.flatOptions, - }, - 'received the correct arguments' - ) - t.strictSame(outputs, [], 'printed no output') -}) - -t.test('npm hook rm - json output', async t => { - const config = { - json: true, - } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['rm', '1']) - - t.match( - hookArgs(), - { - id: '1', - opts: npm.flatOptions, - }, - 'received the correct arguments' - ) - t.strictSame( - JSON.parse(outputs[0]), - { - id: 1, - name: 'semver', - type: 'package', - endpoint: 'https://google.com', - }, - 'printed correct output' - ) -}) - -t.test('npm hook rm - parseable output', async t => { - const config = { - parseable: true, - } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['rm', '1']) - - t.match( - hookArgs(), - { - id: '1', - opts: npm.flatOptions, - }, - 'received the correct arguments' - ) - t.strictSame( - outputs.map(line => line.split(/\t/)), - [ - ['id', 'name', 'type', 'endpoint'], - ['1', 'semver', 'package', 'https://google.com'], - ], - 'printed correct output' - ) -}) - -t.test('npm hook update', async t => { - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - }) - await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - id: '1', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'received the correct arguments' - ) - t.strictSame(outputs[0], '+ semver -> https://google.com', 'printed the correct output') -}) - -t.test('npm hook update - unicode', async t => { - const config = { - unicode: true, - } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - id: '1', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'received the correct arguments' - ) - t.strictSame(outputs[0], '+ semver ➜ https://google.com', 'printed the correct output') -}) - -t.test('npm hook update - json output', async t => { - const config = { - json: true, - } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - id: '1', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'received the correct arguments' - ) - t.strictSame( - JSON.parse(outputs[0]), - { - id: '1', - name: 'semver', - type: 'package', - endpoint: 'https://google.com', - }, - 'printed the correct output' - ) -}) - -t.test('npm hook update - parseable output', async t => { - const config = { - parseable: true, - } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - id: '1', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'received the correct arguments' - ) - t.strictSame( - outputs.map(line => line.split(/\t/)), - [ - ['id', 'name', 'type', 'endpoint'], - ['1', 'semver', 'package', 'https://google.com'], - ], - 'printed the correct output' - ) -}) - -t.test('npm hook update - silent output', async t => { - const config = { loglevel: 'silent' } - const { npm, hook, outputs, hookArgs } = await mockHook(t, { - config, - }) - - await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - - t.match( - hookArgs(), - { - id: '1', - uri: 'https://google.com', - secret: 'some-secret', - opts: npm.flatOptions, - }, - 'received the correct arguments' - ) - t.strictSame(outputs, [], 'printed no output') -}) diff --git a/workspaces/libnpmhook/.eslintrc.js b/workspaces/libnpmhook/.eslintrc.js deleted file mode 100644 index f21d26eccec7d..0000000000000 --- a/workspaces/libnpmhook/.eslintrc.js +++ /dev/null @@ -1,20 +0,0 @@ -/* 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, - ignorePatterns: [ - 'tap-testdir*/', - ], - extends: [ - '@npmcli', - ...localConfigs, - ], -} diff --git a/workspaces/libnpmhook/.gitignore b/workspaces/libnpmhook/.gitignore deleted file mode 100644 index 8591cc376e949..0000000000000 --- a/workspaces/libnpmhook/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -# This file is automatically added by @npmcli/template-oss. Do not edit. - -# ignore everything in the root -/* - -!**/.gitignore -!/.eslintrc.js -!/.eslintrc.local.* -!/.git-blame-ignore-revs -!/.gitignore -!/bin/ -!/CHANGELOG* -!/docs/ -!/lib/ -!/LICENSE* -!/map.js -!/package.json -!/README* -!/scripts/ -!/tap-snapshots/ -!/test/ -tap-testdir*/ diff --git a/workspaces/libnpmhook/CHANGELOG.md b/workspaces/libnpmhook/CHANGELOG.md deleted file mode 100644 index ab213fa918df0..0000000000000 --- a/workspaces/libnpmhook/CHANGELOG.md +++ /dev/null @@ -1,262 +0,0 @@ -# Changelog - -## [11.0.0](https://github.com/npm/cli/compare/libnpmhook-v10.0.5...libnpmhook-v11.0.0) (2024-10-03) -### ⚠️ BREAKING CHANGES -* `libnpmhook` now supports node `^18.17.0 || >=20.5.0` -### Bug Fixes -* [`0e69c92`](https://github.com/npm/cli/commit/0e69c928ba5bef5fbc101f15e498d4a1182a8b59) [#7803](https://github.com/npm/cli/pull/7803) align libnpmhook to npm 10 node engine range (@reggi) -### Dependencies -* [`d13a20b`](https://github.com/npm/cli/commit/d13a20bebef1b9932f86c44741ea6d214ad6842b) [#7803](https://github.com/npm/cli/pull/7803) update `npm-registry-fetch@18.0.1` -### Chores -* [`2072705`](https://github.com/npm/cli/commit/2072705aa80d009dc077639adc305692f4a6c0b9) [#7803](https://github.com/npm/cli/pull/7803) update `@npmcli/eslint-config@5.0.1` (@reggi) -* [`8035725`](https://github.com/npm/cli/commit/80357253ecd8483463cd66c783c4464c330d72df) [#7756](https://github.com/npm/cli/pull/7756) `@npmcli/template-oss@4.23.3` (@wraithgar) - -## [10.0.5](https://github.com/npm/cli/compare/libnpmhook-v10.0.4...libnpmhook-v10.0.5) (2024-05-15) - -### Dependencies - -* [`63ef498`](https://github.com/npm/cli/commit/63ef498bf2916a882a92c0b9fe6de6728584694a) [#7457](https://github.com/npm/cli/pull/7457) `npm-registry-fetch@17.0.1` - -### Chores - -* [`9c4d3c4`](https://github.com/npm/cli/commit/9c4d3c402c77bd7aaa514ee9e02d7fd87223343e) [#7467](https://github.com/npm/cli/pull/7467) template-oss-apply (@lukekarrys) -* [`2b7ec54`](https://github.com/npm/cli/commit/2b7ec54f52f9e8aee568ccb4e34ce4a5733af21a) [#7467](https://github.com/npm/cli/pull/7467) `template-oss@4.22.0` (@lukekarrys) - -## [10.0.4](https://github.com/npm/cli/compare/libnpmhook-v10.0.3...libnpmhook-v10.0.4) (2024-04-30) - -### Bug Fixes - -* [`57ebebf`](https://github.com/npm/cli/commit/57ebebf03d55d4eda2b6439149a97b595a191aaf) [#7418](https://github.com/npm/cli/pull/7418) update repository.url in package.json (#7418) (@wraithgar) - -### Dependencies - -* [`a7145d4`](https://github.com/npm/cli/commit/a7145d422485fcbcb9427efa775c15180c7ee1c2) [#7453](https://github.com/npm/cli/pull/7453) `npm-registry-fetch@17.0.0` - -## [10.0.3](https://github.com/npm/cli/compare/libnpmhook-v10.0.2...libnpmhook-v10.0.3) (2024-04-25) - -### Dependencies - -* [`ee4b3e0`](https://github.com/npm/cli/commit/ee4b3e0e741545045dc03741c7147560961d867d) [#7373](https://github.com/npm/cli/pull/7373) `npm-registry-fetch@16.2.1` - -## [10.0.2](https://github.com/npm/cli/compare/libnpmhook-v10.0.1...libnpmhook-v10.0.2) (2024-04-03) - -### Dependencies - -* [`87a61fc`](https://github.com/npm/cli/commit/87a61fc8bb65c950cda389ab3d14ae250ab2345d) [#7334](https://github.com/npm/cli/pull/7334) `npm-registry-fetch@16.2.0` - -## [10.0.1](https://github.com/npm/cli/compare/libnpmhook-v10.0.0...libnpmhook-v10.0.1) (2023-12-06) - -### Chores - -* [`f656b66`](https://github.com/npm/cli/commit/f656b669e549286844f2071b9b62cf23f7958034) [#7062](https://github.com/npm/cli/pull/7062) `@npmcli/template-oss@4.21.3` (#7062) (@lukekarrys) -* [`9754b17`](https://github.com/npm/cli/commit/9754b173de26f3173e7f41eab34733fe9ba50f1d) [#7051](https://github.com/npm/cli/pull/7051) use global npm for workspace tests (@lukekarrys) -* [`3891757`](https://github.com/npm/cli/commit/3891757f54d6d960cbf5f0d93d183d6424e8bed6) [#7051](https://github.com/npm/cli/pull/7051) `@npmcli/template-oss@4.21.2` (@lukekarrys) -* [`0270a7d`](https://github.com/npm/cli/commit/0270a7d42984210fd388f3d9a70aaa01887d29f6) [#6807](https://github.com/npm/cli/pull/6807) set workspace engines (@lukekarrys) -* [`fec08ad`](https://github.com/npm/cli/commit/fec08ade0fed990b838b781867adf03253907e91) [#6807](https://github.com/npm/cli/pull/6807) `@npmcli/template-oss@4.19.0` (@lukekarrys) - -## [10.0.0](https://github.com/npm/cli/compare/libnpmhook-v10.0.0-pre.0...libnpmhook-v10.0.0) (2023-08-31) - -### Features - -* [`fb31c7e`](https://github.com/npm/cli/commit/fb31c7e5f00ae39e67f9a5d6b6860c1d839c704b) trigger release process (@lukekarrys) - -## [10.0.0-pre.0](https://github.com/npm/cli/compare/libnpmhook-v9.0.3...libnpmhook-v10.0.0-pre.0) (2023-08-31) - -### ⚠️ BREAKING CHANGES - -* support for node <=16.13 has been removed -* support for node 14 has been removed - -### Bug Fixes - -* [`6b251b1`](https://github.com/npm/cli/commit/6b251b1009648b36d49b83a2cc407c348fa225e0) [#6706](https://github.com/npm/cli/pull/6706) drop node 16.13.x support (@lukekarrys) -* [`4caedd0`](https://github.com/npm/cli/commit/4caedd0e49641e9f1757f5622e5845b5b49c56c1) [#6706](https://github.com/npm/cli/pull/6706) drop node14 support (@lukekarrys) - -### Dependencies - -* [`2ee0fb3`](https://github.com/npm/cli/commit/2ee0fb3ac0c5e49f9eba545d6b05e20be1352414) [#6706](https://github.com/npm/cli/pull/6706) `npm-registry-fetch@16.0.0` -* [`5d0d859`](https://github.com/npm/cli/commit/5d0d8592cbf3b816d9fe44c36d390200ec15e87a) [#6706](https://github.com/npm/cli/pull/6706) `npm-registry-fetch@15.0.0` - -## [9.0.3](https://github.com/npm/cli/compare/libnpmhook-v9.0.2...libnpmhook-v9.0.3) (2023-02-07) - -### Bug Fixes - -* [`12ec7ee`](https://github.com/npm/cli/commit/12ec7ee1983876565445ae7967e2f14f3d95e356) remove unused package.json scripts (@lukekarrys) - -## [9.0.2](https://github.com/npm/cli/compare/libnpmhook-v9.0.1...libnpmhook-v9.0.2) (2023-02-01) - -### Dependencies - -* [`721fe3f`](https://github.com/npm/cli/commit/721fe3fac383d714aa7fd7285b4392619903b1e7) [#6118](https://github.com/npm/cli/pull/6118) `read-package-json-fast@3.0.2` -* [`a39556f`](https://github.com/npm/cli/commit/a39556f1cff4526dcbcb7b65cdd86a1ba092e13e) `@npmcli/template-oss@4.11.3` - -## [9.0.1](https://github.com/npm/cli/compare/libnpmhook-v9.0.0...libnpmhook-v9.0.1) (2022-12-07) - -### Dependencies - -* [`0a3fe00`](https://github.com/npm/cli/commit/0a3fe000e2723ae6fdb8b1d3154fd3835057c992) [#5933](https://github.com/npm/cli/pull/5933) `minipass@4.0.0` -* [`fee9b66`](https://github.com/npm/cli/commit/fee9b6686892a1c7f976c36ddd5d89b70c416817) `npm-registry-fetch@14.0.3` - -## [9.0.0](https://github.com/npm/cli/compare/libnpmhook-v9.0.0-pre.1...libnpmhook-v9.0.0) (2022-10-19) - -### Features - -* [`586e78d`](https://github.com/npm/cli/commit/586e78d59c3dad29e8e886a4764d2eb8021d11d1) empty commit to trigger all workspace releases (@lukekarrys) - -## [9.0.0-pre.1](https://github.com/npm/cli/compare/libnpmhook-v9.0.0-pre.0...libnpmhook-v9.0.0-pre.1) (2022-10-19) - -### Dependencies - -* [`aa01072`](https://github.com/npm/cli/commit/aa010722996ef6de46e1bb937c6f8a94dc2844fa) [#5707](https://github.com/npm/cli/pull/5707) update the following dependencies - -## [9.0.0-pre.0](https://github.com/npm/cli/compare/libnpmhook-v8.0.4...libnpmhook-v9.0.0-pre.0) (2022-09-08) - -### ⚠ BREAKING CHANGES - -* **workspaces:** all workspace packages are now compatible with the following semver range for node: `^14.17.0 || ^16.13.0 || >=18.0.0` - -### Features - - * [`e95017a`](https://github.com/npm/cli/commit/e95017a07b041cbb3293e659dad853f76462c108) [#5485](https://github.com/npm/cli/pull/5485) feat(workspaces): update supported node engines in package.json (@lukekarrys) - -## [8.0.4](https://github.com/npm/cli/compare/libnpmhook-v8.0.3...libnpmhook-v8.0.4) (2022-08-31) - -### Dependencies - - * [`8ab12dc`](https://github.com/npm/cli/commit/8ab12dc32b26db770b868cf694cedab38f4e7460) [#5323](https://github.com/npm/cli/pull/5323) deps: `@npmcli/eslint-config@3.1.0` - -### [8.0.3](https://github.com/npm/cli/compare/libnpmhook-v8.0.2...libnpmhook-v8.0.3) (2022-04-06) - - -### Bug Fixes - -* replace deprecated String.prototype.substr() ([#4667](https://github.com/npm/cli/issues/4667)) ([e3da5df](https://github.com/npm/cli/commit/e3da5df4152fbe547f7871547165328e1bf06262)) -* update readme badges ([#4658](https://github.com/npm/cli/issues/4658)) ([2829cb2](https://github.com/npm/cli/commit/2829cb28a432b5ff7beeeb3bf3e7e2e174c1121d)) - - -### Dependencies - -* @npmcli/template-oss@3.2.1 ([aac01b8](https://github.com/npm/cli/commit/aac01b89caf6336a2eb34d696296303cdadd5c08)) -* @npmcli/template-oss@3.2.2 ([#4639](https://github.com/npm/cli/issues/4639)) ([a59fd2c](https://github.com/npm/cli/commit/a59fd2cb863245fce56f96c90ac854e62c5c4d6f)) - -### [8.0.2](https://www.github.com/npm/cli/compare/libnpmhook-v8.0.1...libnpmhook-v8.0.2) (2022-03-10) - - -### Documentation - -* standardize changelog heading ([#4510](https://www.github.com/npm/cli/issues/4510)) ([91f03ee](https://www.github.com/npm/cli/commit/91f03ee618bc635f9cfbded735fe98bbfa9d643f)) - -## [6.0.0](https://github.com/npm/libnpmhook/compare/v5.0.2...v6.0.0) (2020-02-26) - -### Breaking Changes - -* [`aa629b4`](https://github.com/npm/libnpmhook/commit/aa629b4) fix: remove figgy-pudding ([@claudiahdz](https://github.com/claudiahdz)) - -### Miscellaneuous - -* [`ea795fb`](https://github.com/npm/libnpmhook/commit/ea795fb) chore: basic project updates ([@claudiahdz](https://github.com/claudiahdz)) -* [`a0fdf7e`](https://github.com/npm/libnpmhook/commit/a0fdf7e) chore: cleanup badges, contrib, readme ([@ruyadorno](https://github.com/ruyadorno)) - ---- - -All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. - - -### [8.0.1](https://www.github.com/npm/cli/compare/libnpmhook-vlibnpmhook@8.0.0...libnpmhook-v8.0.1) (2022-03-03) - - -### Bug Fixes - -* set proper workspace repo urls in package.json ([#4476](https://www.github.com/npm/cli/issues/4476)) ([0cfc155](https://www.github.com/npm/cli/commit/0cfc155db5f11ce23419e440111d99a63bf39754)) - -## [5.0.2](https://github.com/npm/libnpmhook/compare/v5.0.1...v5.0.2) (2018-08-24) - - - - -## [5.0.1](https://github.com/npm/libnpmhook/compare/v5.0.0...v5.0.1) (2018-08-23) - - -### Bug Fixes - -* **deps:** move JSONStream to prod deps ([bb63594](https://github.com/npm/libnpmhook/commit/bb63594)) - - - - -# [5.0.0](https://github.com/npm/libnpmhook/compare/v4.0.1...v5.0.0) (2018-08-21) - - -### Features - -* **api:** overhauled API ([46b271b](https://github.com/npm/libnpmhook/commit/46b271b)) - - -### BREAKING CHANGES - -* **api:** the API for ls() has changed, and rm() no longer errors on 404 - - - - -## [4.0.1](https://github.com/npm/libnpmhook/compare/v4.0.0...v4.0.1) (2018-04-09) - - - - -# [4.0.0](https://github.com/npm/libnpmhook/compare/v3.0.1...v4.0.0) (2018-04-08) - - -### meta - -* drop support for node 4 and 7 ([f2a301e](https://github.com/npm/libnpmhook/commit/f2a301e)) - - -### BREAKING CHANGES - -* node@4 and node@7 are no longer supported - - - - -## [3.0.1](https://github.com/npm/libnpmhook/compare/v3.0.0...v3.0.1) (2018-04-08) - - - - -# [3.0.0](https://github.com/npm/libnpmhook/compare/v2.0.1...v3.0.0) (2018-04-04) - - -### add - -* guess type based on name ([9418224](https://github.com/npm/libnpmhook/commit/9418224)) - - -### BREAKING CHANGES - -* hook type is now based on name prefix - - - - -## [2.0.1](https://github.com/npm/libnpmhook/compare/v2.0.0...v2.0.1) (2018-03-16) - - -### Bug Fixes - -* **urls:** was hitting the wrong URL endpoints ([10171a9](https://github.com/npm/libnpmhook/commit/10171a9)) - - - - -# [2.0.0](https://github.com/npm/libnpmhook/compare/v1.0.0...v2.0.0) (2018-03-16) - - - - -# 1.0.0 (2018-03-16) - - -### Features - -* **api:** baseline working api ([122658e](https://github.com/npm/npm-hooks/commit/122658e)) diff --git a/workspaces/libnpmhook/LICENSE.md b/workspaces/libnpmhook/LICENSE.md deleted file mode 100644 index 8d28acf866d93..0000000000000 --- a/workspaces/libnpmhook/LICENSE.md +++ /dev/null @@ -1,16 +0,0 @@ -ISC License - -Copyright (c) npm, Inc. - -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 COPYRIGHT HOLDER DISCLAIMS -ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE -USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/workspaces/libnpmhook/README.md b/workspaces/libnpmhook/README.md deleted file mode 100644 index 309f8041da08b..0000000000000 --- a/workspaces/libnpmhook/README.md +++ /dev/null @@ -1,271 +0,0 @@ -# libnpmhook - -[![npm version](https://img.shields.io/npm/v/libnpmhook.svg)](https://npm.im/libnpmhook) -[![license](https://img.shields.io/npm/l/libnpmhook.svg)](https://npm.im/libnpmhook) -[![CI - libnpmhook](https://github.com/npm/cli/actions/workflows/ci-libnpmhook.yml/badge.svg)](https://github.com/npm/cli/actions/workflows/ci-libnpmhook.yml) - -[`libnpmhook`](https://github.com/npm/libnpmhook) is a Node.js library for -programmatically managing the npm registry's server-side hooks. - -For a more general introduction to managing hooks, see [the introductory blog -post](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm). - -## Table of Contents - -* [Example](#example) -* [Install](#install) -* [Contributing](#contributing) -* [API](#api) - * [hook opts](#opts) - * [`add()`](#add) - * [`rm()`](#rm) - * [`ls()`](#ls) - * [`ls.stream()`](#ls-stream) - * [`update()`](#update) - -## Example - -```js -const hooks = require('libnpmhook') - -console.log(await hooks.ls('mypkg', {token: 'deadbeef'})) -// array of hook objects on `mypkg`. -``` - -## Install - -`$ npm install libnpmhook` - -### API - -#### `opts` for `libnpmhook` commands - -`libnpmhook` uses [`npm-registry-fetch`](https://npm.im/npm-registry-fetch). -All options are passed through directly to that library, so please refer to [its -own `opts` -documentation](https://www.npmjs.com/package/npm-registry-fetch#fetch-options) -for options that can be passed in. - -A couple of options of note for those in a hurry: - -* `opts.token` - can be passed in and will be used as the authentication token for the registry. For other ways to pass in auth details, see the n-r-f docs. -* `opts.otp` - certain operations will require an OTP token to be passed in. If a `libnpmhook` command fails with `err.code === EOTP`, please retry the request with `{otp: <2fa token>}` - -#### `> hooks.add(name, endpoint, secret, [opts]) -> Promise` - -`name` is the name of the package, org, or user/org scope to watch. The type is -determined by the name syntax: `'@foo/bar'` and `'foo'` are treated as packages, -`@foo` is treated as a scope, and `~user` is treated as an org name or scope. -Each type will attach to different events. - -The `endpoint` should be a fully-qualified http URL for the endpoint the hook -will send its payload to when it fires. `secret` is a shared secret that the -hook will send to that endpoint to verify that it's actually coming from the -registry hook. - -The returned Promise resolves to the full hook object that was created, -including its generated `id`. - -See also: [`POST -/v1/hooks/hook`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#post-v1hookshook) - -##### Example - -```javascript -await hooks.add('~zkat', 'https://example.com/api/added', 'supersekrit', { - token: 'myregistrytoken', - otp: '694207' -}) - -=> - -{ id: '16f7xoal', - username: 'zkat', - name: 'zkat', - endpoint: 'https://example.com/api/added', - secret: 'supersekrit', - type: 'owner', - created: '2018-08-21T20:05:25.125Z', - updated: '2018-08-21T20:05:25.125Z', - deleted: false, - delivered: false, - last_delivery: null, - response_code: 0, - status: 'active' } -``` - -#### `> hooks.find(id, [opts]) -> Promise` - -Returns the hook identified by `id`. - -The returned Promise resolves to the full hook object that was found, or error -with `err.code` of `'E404'` if it didn't exist. - -See also: [`GET -/v1/hooks/hook/:id`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#get-v1hookshookid) - -##### Example - -```javascript -await hooks.find('16f7xoal', {token: 'myregistrytoken'}) - -=> - -{ id: '16f7xoal', - username: 'zkat', - name: 'zkat', - endpoint: 'https://example.com/api/added', - secret: 'supersekrit', - type: 'owner', - created: '2018-08-21T20:05:25.125Z', - updated: '2018-08-21T20:05:25.125Z', - deleted: false, - delivered: false, - last_delivery: null, - response_code: 0, - status: 'active' } -``` - -#### `> hooks.rm(id, [opts]) -> Promise` - -Removes the hook identified by `id`. - -The returned Promise resolves to the full hook object that was removed, if it -existed, or `null` if no such hook was there (instead of erroring). - -See also: [`DELETE -/v1/hooks/hook/:id`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#delete-v1hookshookid) - -##### Example - -```javascript -await hooks.rm('16f7xoal', { - token: 'myregistrytoken', - otp: '694207' -}) - -=> - -{ id: '16f7xoal', - username: 'zkat', - name: 'zkat', - endpoint: 'https://example.com/api/added', - secret: 'supersekrit', - type: 'owner', - created: '2018-08-21T20:05:25.125Z', - updated: '2018-08-21T20:05:25.125Z', - deleted: true, - delivered: false, - last_delivery: null, - response_code: 0, - status: 'active' } - -// Repeat it... -await hooks.rm('16f7xoal', { - token: 'myregistrytoken', - otp: '694207' -}) - -=> null -``` - -#### `> hooks.update(id, endpoint, secret, [opts]) -> Promise` - -The `id` should be a hook ID from a previously-created hook. - -The `endpoint` should be a fully-qualified http URL for the endpoint the hook -will send its payload to when it fires. `secret` is a shared secret that the -hook will send to that endpoint to verify that it's actually coming from the -registry hook. - -The returned Promise resolves to the full hook object that was updated, if it -existed. Otherwise, it will error with an `'E404'` error code. - -See also: [`PUT -/v1/hooks/hook/:id`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#put-v1hookshookid) - -##### Example - -```javascript -await hooks.update('16fxoal', 'https://example.com/api/other', 'newsekrit', { - token: 'myregistrytoken', - otp: '694207' -}) - -=> - -{ id: '16f7xoal', - username: 'zkat', - name: 'zkat', - endpoint: 'https://example.com/api/other', - secret: 'newsekrit', - type: 'owner', - created: '2018-08-21T20:05:25.125Z', - updated: '2018-08-21T20:14:41.964Z', - deleted: false, - delivered: false, - last_delivery: null, - response_code: 0, - status: 'active' } -``` - -#### `> hooks.ls([opts]) -> Promise` - -Resolves to an array of hook objects associated with the account you're -authenticated as. - -Results can be further filtered with three values that can be passed in through -`opts`: - -* `opts.package` - filter results by package name -* `opts.limit` - maximum number of hooks to return -* `opts.offset` - pagination offset for results (use with `opts.limit`) - -See also: - * [`hooks.ls.stream()`](#ls-stream) - * [`GET -/v1/hooks`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#get-v1hooks) - -##### Example - -```javascript -await hooks.ls({token: 'myregistrytoken'}) - -=> -[ - { id: '16f7xoal', ... }, - { id: 'wnyf98a1', ... }, - ... -] -``` - -#### `> hooks.ls.stream([opts]) -> Stream` - -Returns a stream of hook objects associated with the account you're -authenticated as. The returned stream is a valid `Symbol.asyncIterator` on -`node@>=10`. - -Results can be further filtered with three values that can be passed in through -`opts`: - -* `opts.package` - filter results by package name -* `opts.limit` - maximum number of hooks to return -* `opts.offset` - pagination offset for results (use with `opts.limit`) - -See also: - * [`hooks.ls()`](#ls) - * [`GET -/v1/hooks`](https://github.com/npm/registry/blob/master/docs/hooks/endpoints.md#get-v1hooks) - -##### Example - -```javascript -for await (let hook of hooks.ls.stream({token: 'myregistrytoken'})) { - console.log('found hook:', hook.id) -} - -=> -// outputs: -// found hook: 16f7xoal -// found hook: wnyf98a1 -``` diff --git a/workspaces/libnpmhook/lib/index.js b/workspaces/libnpmhook/lib/index.js deleted file mode 100644 index 091cdc49a80d1..0000000000000 --- a/workspaces/libnpmhook/lib/index.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict' - -const fetch = require('npm-registry-fetch') -const validate = require('aproba') - -const eu = encodeURIComponent -const cmd = module.exports = {} -cmd.add = (name, endpoint, secret, opts = {}) => { - validate('SSSO', [name, endpoint, secret, opts]) - let type = 'package' - if (name.match(/^@[^/]+$/)) { - type = 'scope' - } - if (name[0] === '~') { - type = 'owner' - name = name.slice(1) - } - return fetch.json('/-/npm/v1/hooks/hook', { - ...opts, - method: 'POST', - body: { type, name, endpoint, secret }, - }) -} - -cmd.rm = (id, opts = {}) => { - validate('SO', [id, opts]) - return fetch.json(`/-/npm/v1/hooks/hook/${eu(id)}`, { - ...opts, - method: 'DELETE', - }).catch(err => { - if (err.code === 'E404') { - return null - } else { - throw err - } - }) -} - -cmd.update = (id, endpoint, secret, opts = {}) => { - validate('SSSO', [id, endpoint, secret, opts]) - return fetch.json(`/-/npm/v1/hooks/hook/${eu(id)}`, { - ...opts, - method: 'PUT', - body: { endpoint, secret }, - }) -} - -cmd.find = (id, opts = {}) => { - validate('SO', [id, opts]) - return fetch.json(`/-/npm/v1/hooks/hook/${eu(id)}`, opts) -} - -cmd.ls = (opts = {}) => { - return cmd.ls.stream(opts).collect() -} - -cmd.ls.stream = (opts = {}) => { - const { package: pkg, limit, offset } = opts - validate('S|Z', [pkg]) - validate('N|Z', [limit]) - validate('N|Z', [offset]) - return fetch.json.stream('/-/npm/v1/hooks', 'objects.*', { - ...opts, - query: { - package: pkg, - limit, - offset, - }, - }) -} diff --git a/workspaces/libnpmhook/package.json b/workspaces/libnpmhook/package.json deleted file mode 100644 index 7fa1bcbdb7606..0000000000000 --- a/workspaces/libnpmhook/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "libnpmhook", - "version": "11.0.0", - "description": "programmatic API for managing npm registry hooks", - "main": "lib/index.js", - "files": [ - "bin/", - "lib/" - ], - "scripts": { - "test": "tap", - "lint": "npm run eslint", - "postlint": "template-oss-check", - "lintfix": "npm run eslint -- --fix", - "snap": "tap", - "posttest": "npm run lint", - "template-oss-apply": "template-oss-apply --force", - "eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/npm/cli.git", - "directory": "workspaces/libnpmhook" - }, - "keywords": [ - "npm", - "hooks", - "registry", - "npm api" - ], - "author": "GitHub Inc.", - "license": "ISC", - "dependencies": { - "aproba": "^2.0.0", - "npm-registry-fetch": "^18.0.1" - }, - "devDependencies": { - "@npmcli/eslint-config": "^5.0.1", - "@npmcli/template-oss": "4.23.3", - "nock": "^13.3.3", - "tap": "^16.3.8" - }, - "engines": { - "node": "^20.17.0 || >=22.9.0" - }, - "templateOSS": { - "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.23.3", - "content": "../../scripts/template-oss/index.js" - }, - "tap": { - "nyc-arg": [ - "--exclude", - "tap-snapshots/**" - ] - } -} diff --git a/workspaces/libnpmhook/test/fixtures/tnock.js b/workspaces/libnpmhook/test/fixtures/tnock.js deleted file mode 100644 index 048639a504e08..0000000000000 --- a/workspaces/libnpmhook/test/fixtures/tnock.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict' - -const nock = require('nock') - -module.exports = tnock -function tnock (t, host) { - const server = nock(host) - t.teardown(function () { - server.done() - }) - return server -} diff --git a/workspaces/libnpmhook/test/index.js b/workspaces/libnpmhook/test/index.js deleted file mode 100644 index 7ca3b06ae805d..0000000000000 --- a/workspaces/libnpmhook/test/index.js +++ /dev/null @@ -1,267 +0,0 @@ -'use strict' - -const test = require('tap').test -const tnock = require('./fixtures/tnock.js') - -const hooks = require('../lib/index.js') - -const OPTS = { - registry: 'https://mock.reg/', -} - -const HOOK_URL = 'https://my.hook.url/' -const REG = 'https://registry.npmjs.org/' - -test('add package hook with no options', t => { - const params = { - type: 'package', - name: 'mypkg', - endpoint: HOOK_URL, - secret: 'sekrit', - } - const hook = Object.assign({ - id: 'deadbeef', - status: 'active', - }, params) - tnock(t, REG) - .post('/-/npm/v1/hooks/hook', params) - .reply(200, hook) - return hooks.add('mypkg', HOOK_URL, 'sekrit') - .then(json => t.same(json, hook)) -}) - -test('add package hook', t => { - const params = { - type: 'package', - name: 'mypkg', - endpoint: HOOK_URL, - secret: 'sekrit', - } - const hook = Object.assign({ - id: 'deadbeef', - status: 'active', - }, params) - tnock(t, OPTS.registry) - .post('/-/npm/v1/hooks/hook', params) - .reply(200, hook) - return hooks.add('mypkg', HOOK_URL, 'sekrit', OPTS) - .then(json => t.same(json, hook)) -}) - -test('add scoped package hook', t => { - const params = { - type: 'package', - name: '@myscope/mypkg', - endpoint: HOOK_URL, - secret: 'sekrit', - } - const hook = Object.assign({ - id: 'deadbeef', - status: 'active', - }, params) - tnock(t, OPTS.registry) - .post('/-/npm/v1/hooks/hook', params) - .reply(200, hook) - return hooks.add('@myscope/mypkg', HOOK_URL, 'sekrit', OPTS) - .then(json => t.same(json, hook)) -}) - -test('add owner hook', t => { - const params = { - type: 'owner', - name: 'myuser', - endpoint: HOOK_URL, - secret: 'sekrit', - } - const hook = Object.assign({ - id: 'deadbeef', - status: 'active', - }, params) - tnock(t, OPTS.registry) - .post('/-/npm/v1/hooks/hook', params) - .reply(200, hook) - return hooks.add('~myuser', HOOK_URL, 'sekrit', OPTS) - .then(json => t.same(json, hook)) -}) - -test('add scope hook', t => { - const params = { - type: 'scope', - name: '@myscope', - endpoint: HOOK_URL, - secret: 'sekrit', - } - const hook = Object.assign({ - id: 'deadbeef', - status: 'active', - }, params) - tnock(t, OPTS.registry) - .post('/-/npm/v1/hooks/hook', params) - .reply(200, hook) - return hooks.add('@myscope', HOOK_URL, 'sekrit', OPTS) - .then(json => t.same(json, hook)) -}) - -test('rm with no options', t => { - tnock(t, REG) - .delete('/-/npm/v1/hooks/hook/hithere') - .reply(200, { id: 'hithere' }) - return hooks.rm('hithere') - .then(json => t.equal(json.id, 'hithere')) -}) - -test('rm', t => { - tnock(t, OPTS.registry) - .delete('/-/npm/v1/hooks/hook/hithere') - .reply(200, { id: 'hithere' }) - return hooks.rm('hithere', OPTS) - .then(json => t.equal(json.id, 'hithere')) -}) - -test('rm null on 404', t => { - tnock(t, OPTS.registry) - .delete('/-/npm/v1/hooks/hook/hithere') - .reply(404) - return hooks.rm('hithere', OPTS) - .then(json => t.equal(json, null)) -}) - -test('rm null on other err', t => { - tnock(t, OPTS.registry) - .delete('/-/npm/v1/hooks/hook/hithere') - .reply(401) - return hooks.rm('hithere', OPTS).then( - () => { - throw new Error('should not succees') - }, - err => t.equal(err.code, 'E401', 'got a proper error + code') - ) -}) - -test('find with no options', t => { - tnock(t, REG) - .get('/-/npm/v1/hooks/hook/hithere') - .reply(200, { id: 'hithere' }) - return hooks.find('hithere') - .then(json => t.equal(json.id, 'hithere')) -}) - -test('find', t => { - tnock(t, OPTS.registry) - .get('/-/npm/v1/hooks/hook/hithere') - .reply(200, { id: 'hithere' }) - return hooks.find('hithere', OPTS) - .then(json => t.equal(json.id, 'hithere')) -}) - -test('ls', t => { - const entries = [ - { id: 'first' }, - { id: 'second' }, - { id: 'third' }, - ] - tnock(t, REG) - .get('/-/npm/v1/hooks') - .reply(200, { objects: entries }) - return hooks.ls().then( - json => t.same(json, entries) - ) -}) - -test('ls.stream', t => { - const entries = [ - { id: 'first' }, - { id: 'second' }, - { id: 'third' }, - ] - tnock(t, REG) - .get('/-/npm/v1/hooks') - .reply(200, { objects: entries }) - - return hooks.ls.stream().collect().then( - json => t.same(json, entries) - ) -}) - -test('ls', t => { - const entries = [ - { id: 'first' }, - { id: 'second' }, - { id: 'third' }, - ] - tnock(t, OPTS.registry) - .get('/-/npm/v1/hooks') - .reply(200, { objects: entries }) - return hooks.ls(OPTS).then( - json => t.same(json, entries) - ) -}) - -test('ls package', t => { - const entries = [ - { id: 'first' }, - { id: 'second' }, - { id: 'third' }, - ] - tnock(t, OPTS.registry) - .get('/-/npm/v1/hooks?package=%40npm%2Fhooks') - .reply(200, { objects: entries }) - return hooks.ls({ - ...OPTS, - package: '@npm/hooks', - }).then(json => t.same(json, entries)) -}) - -test('ls limit+offset', t => { - const entries = [ - { id: 'first' }, - { id: 'second' }, - { id: 'third' }, - ] - tnock(t, OPTS.registry) - .get('/-/npm/v1/hooks?limit=10&offset=20') - .reply(200, { objects: entries }) - return hooks.ls({ - ...OPTS, - limit: 10, - offset: 20, - }).then(json => t.same(json, entries)) -}) - -test('ls package+limit+offset', t => { - const entries = [ - { id: 'first' }, - { id: 'second' }, - { id: 'third' }, - ] - tnock(t, OPTS.registry) - .get('/-/npm/v1/hooks?package=%40npm%2Fhooks&limit=10&offset=20') - .reply(200, { objects: entries }) - return hooks.ls({ - ...OPTS, - limit: 10, - offset: 20, - package: '@npm/hooks', - }).then(json => t.same(json, entries)) -}) -test('update with no options', t => { - tnock(t, REG) - .put('/-/npm/v1/hooks/hook/hi') - .reply(200, (uri, body) => body) - return hooks.update('hi', HOOK_URL, 'sekrit') - .then(json => t.same(json, { - endpoint: HOOK_URL, - secret: 'sekrit', - })) -}) - -test('update', t => { - tnock(t, OPTS.registry) - .put('/-/npm/v1/hooks/hook/hi') - .reply(200, (uri, body) => body) - return hooks.update('hi', HOOK_URL, 'sekrit', OPTS) - .then(json => t.same(json, { - endpoint: HOOK_URL, - secret: 'sekrit', - })) -})