基于 npm 命令快速生成发布版本,方便发布npm包
# 查看使用
npx @kinngyo/np --help
# 查看版本
npx @kinngyo/np --version
# 发布
npx @kinngyo/np --remote=false --tag=beta --access=public --registry=https://registry.npmjs.org/
yarn add @kinngyo/np -D
# 或者
npm i @kinngyo/np --save-dev
# 查看使用
np --help
# 查看版本
np --version
# 发布
np --remote=false --tag=beta --access=public --registry=https://registry.npmjs.org/
参数 |
类型 |
必填 |
可选 |
说明 |
默认值 |
-h, --help |
string |
否 |
-- |
查看帮助 |
-- |
-v,--version |
string |
否 |
-- |
版本 |
-- |
--remote |
boolean |
否 |
--- |
是否远程查询该包版本 |
true |
---no-remote |
boolean |
否 |
-- |
禁止远程查询该包版本 |
-- |
--tag |
string |
否 |
-- |
发布时候的 tag 标签 |
-- |
--access |
string |
否 |
- |
私有包访问权限 |
public |
--registry |
string |
否 |
-- |
发布源 |
-- |
import NpmPublish from '@kinngyo/np'
const np = new NpmPublish(root:string)
np.publish(option: Partial<INpOption>)
interface INpOption {
remote: boolean
tag: string
access: string
registry: string
}
属性 |
类型 |
必填 |
可选 |
说明 |
默认值 |
remote |
boolean |
否 |
true/false |
是否远程查询该包版本 |
true |
tag |
string |
否 |
- |
发布时候的 tag 标签 |
'latest' |
access |
string |
否 |
|
私有包访问权限 |
'public' |
registry |
string |
否 |
- |
发布源 |
-- |
- 命令、api调用都可以通过publishConfig设置
{
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public",
"tag": "beta"
}
}
命令(API)参数 > publishConfig > 默认
- 1.请确保
npm login
登录状态
- 2.如果是远程git代码,需要commit本地代码