@wzwjustdoit/helloworld-cli
v1.0.1
Published
A minimalist helloworld CLI that prints 'Hello World'
Maintainers
Readme
helloworld-cli
English | 中文
一个极简的命令行工具,安装后执行 helloworld-cli 即可在终端打印 Hello World
链接
- GitHub: https://github.com/wzwjustdoit/helloworld-cli
- npm 仓库: https://www.npmjs.com/package/@wzwjustdoit/helloworld-cli
安装
全局安装后,可在任意终端直接使用 helloworld-cli 命令
npm
npm install -g @wzwjustdoit/helloworld-clibun
bun add -g @wzwjustdoit/helloworld-cliyarn
yarn global add @wzwjustdoit/helloworld-clipnpm
pnpm add -g @wzwjustdoit/helloworld-cli使用
helloworld-cli输出:
Hello World开发者须知
本项目是纯 JavaScript 实现,无依赖、无编译步骤
构建
无需构建,直接运行测试验证:
npm test检查发布产物内容:
npm pack --dry-run(应只包含 `bin/` `package.json` `README.md` `LICENSE`)发布到 npm
首次发布流程: git commit -> npm adduser -> npm publish -> git push
更新发布流程: git commit -> npm version -> npm publish -> git push
1. 准备 git 仓库 | git commit
git 仓库的初始化、关联远程、提交
注意: 首次发布流程 需要执行此步
git init
git add .
git commit -m "Initial Commit"
git branch -M master
git remote add origin https://github.com/wzwjustdoit/helloworld-cli.git
git push -u origin master
git tag v1.0.0
git push origin v1.0.02. 登录 npm 账号 | npm adduser
注意: 需先在 https://www.npmjs.com 注册
注意: 本机若配置了镜像源(例如 npmmirror ), 必须显式指定官方源
npm adduser
# or
# npm adduser --registry=https://registry.npmjs.org/
# npm whoami --registry=https://registry.npmjs.org/3. 升级版本(可选) | npm version
注意: 更新发布流程 需要执行此步
注意: 先完成 git 提交, 之后 npm version 才能在仓库内自动生成版本提交和 tag
git add .
git commit -m "Fixbugs"
npm version patch # 1.0.0 -> 1.0.1 (修复 bug)
npm version minor # 1.0.0 -> 1.1.0 (新增功能)
npm version major # 1.0.0 -> 2.0.0 (破坏性变更)`npm version` 会自动修改 `package.json` 中的 `version` 字段(同时写回 `package-lock.json` 若存在),
并且在 git 仓库中执行时会自动生成一次版本提交和 tag(如 `v1.0.1`)
因此 `npm version` 必须在 git 仓库内、且工作区已提交干净后执行4. 发布到官方源 | npm publish
注意: 本机若配置了镜像源(例如 npmmirror ), 必须显式指定官方源
npm publish
# or
# npm publish --registry=https://registry.npmjs.org/package.json 中的 publishConfig.access 已设为 public, scoped 包无需额外传 --access=public
5. 仓库和 tag 推送到 GitHub | git push
# or : push all tags
# git push && git push --tags
# or : push specified tag
git push && git push origin v1.0.1参考: npm 发布规范
- npm-publish 命令文档 — 发布命令、包内文件包含规则、
npm pack --dry-run检查 - developers 开发者指南 — package.json 必备字段、
scripts.test、发布前本地自测 - package.json 文档 —
name、version、bin、files、engines等字段规范 - Package name guidelines — 包名必须唯一、描述性、不含大写字母
- Creating and publishing unscoped public packages — 公共包发布流程、账号要求
