目录
选择命令行版本:
目录
概要
¥Synopsis
npm hook add <pkg> <url> <secret> [--type=<type>]npm hook ls [pkg]npm hook rm <id>npm hook update <id> <url> <secret>
注意:此命令对工作区无感知。
¥Note: This command is unaware of workspaces.
描述
¥Description
允许你管理 npm hooks,包括添加、删除、列出和更新。
¥Allows you to manage npm hooks, including adding, removing, listing, and updating.
钩子允许你配置 URL 端点,只要任何受支持的实体类型发生更改,就会通知这些端点。钩子可以监视三种不同类型的实体:包、所有者和范围。
¥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.
要创建所有者钩子,请在所有者名称前加上 ~
(如 ~youruser
)。
¥To create an owner hook, prefix the owner name with ~
(as in, ~youruser
).
要创建范围钩子,请在范围名称前加上 @
(如 @yourscope
)。
¥To create a scope hook, prefix the scope name with @
(as in, @yourscope
).
update
和 rm
使用的钩子 id
是 npm hook ls
中为该特定钩子列出的 ID。
¥The hook id
used by update
and rm
are the IDs listed in npm hook ls
for that particular hook.
共享密钥将被发送到 URL 端点,因此你可以验证请求来自你自己配置的钩子。
¥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:
$ npm hook add lodash https://example.com/ my-shared-secret
添加一个钩子来查看属于用户 substack
的包:
¥Add a hook to watch packages belonging to the user substack
:
$ npm hook add ~substack https://example.com/ my-shared-secret
添加一个钩子来监视范围 @npm
中的包
¥Add a hook to watch packages in the scope @npm
$ npm hook add @npm https://example.com/ my-shared-secret
列出所有活动的钩子:
¥List all your active hooks:
$ npm hook ls
列出 lodash
包的活动钩子:
¥List your active hooks for the lodash
package:
$ npm hook ls lodash
更新现有钩子的 url:
¥Update an existing hook's url:
$ npm hook update id-deadbeef https://my-new-website.here/
移除一个钩子:
¥Remove a hook:
$ npm hook rm id-deadbeef
配置
¥Configuration
registry
-
默认值:"https://registry.npmjs.org/"
¥Default: "https://registry.npmjs.org/"
-
类型:URL
¥Type: URL
npm 注册表的基本 URL。
¥The base URL of the npm registry.
otp
-
默认值:null
¥Default: null
-
类型:空值或字符串
¥Type: null or String
这是来自双重身份验证器的一次性密码。使用 npm access
发布或更改包权限时需要它。
¥This is a one-time password from a two-factor authenticator. It's needed when publishing or changing package permissions with npm access
.
如果未设置,并且注册表响应失败并询问一次性密码,npm 将在命令行上提示输入一次密码。
¥If not set, and a registry response fails with a challenge for a one-time password, npm will prompt on the command line for one.
也可以看看
¥See Also