npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@huyooo/cnb-deploy

v0.1.2

Published

CNB 本地打 tag / 选环境部署 CLI,支持交互式与命令式

Readme

@huyooo/cnb-deploy

CNB 本地打 tag / 选环境部署 CLI(架构对齐 @huyooo/release):

  • TypeScript + tsdown
  • citty 命令行
  • consola 交互与日志
  • execa 执行命令
  • steps/ 步骤拆分

与平台 Tag 页 Deploy(tag_deploy.*)并存,本地走 api_trigger_deploy_*。

包地址:https://www.npmjs.com/package/@huyooo/cnb-deploy

安装

npm i -D @huyooo/cnb-deploy
# 或全局
npm i -g @huyooo/cnb-deploy

首次必须登录 CNB:

npx cnb login
npx cnb status   # 应显示「已登录」

项目前置

  1. 仓库根目录有 .cnb/tag_deploy.yml(含各环境 DEPLOY_ENV / DEPLOY_WORKLOAD_NAME)
  2. 流水线模板已配置 api_trigger_deploy_{test,staging,production},并与 tag_deploy.* 共用同一套流水线
  3. 模板变更需先 push 到模板仓 main(项目 .cnb.yml 一般 include 远端 main)

模板示例(ci-cd-templete):

$:
  tag_deploy.test: !reference [.common-pipeline]
  tag_deploy.staging: !reference [.common-pipeline]
  tag_deploy.production: !reference [.common-pipeline]
  api_trigger_deploy_test: !reference [.common-pipeline]
  api_trigger_deploy_staging: !reference [.common-pipeline]
  api_trigger_deploy_production: !reference [.common-pipeline]

命令

# 交互式:选操作 / 环境 / 版本
cnb-deploy

# 部署已有 tag
cnb-deploy deploy test 1.63.4
cnb-deploy deploy --env production --tag 1.63.4 --yes

# 打 tag 并部署(默认基于 git tag bump,不改 package.json)
cnb-deploy release production
cnb-deploy release --env production --tag 1.63.5 --yes

# 仅打 tag
cnb-deploy tag
cnb-deploy bump patch

# 与 @huyooo/release 一样走 bumpp(改 package.json)
cnb-deploy release production --package

package.json 示例

{
  "scripts": {
    "deploy": "cnb-deploy",
    "deploy:test": "cnb-deploy deploy test",
    "deploy:staging": "cnb-deploy deploy staging",
    "deploy:production": "cnb-deploy deploy production",
    "release:prod": "cnb-deploy release production"
  }
}

推荐流程

  1. 先测 test:cnb-deploy deploy test --tag <已有tag>
  2. 到 CNB 构建日志确认流水线成功
  3. 再发 production:cnb-deploy deploy production --tag <同一tag> --yes
    或打新版本:cnb-deploy release production(交互选版本,production 需输入 yes)

平台 Tag 页 Deploy 仍可随时手动使用,两条入口互不影响。

常见问题

1. 无法从 git remote 解析 / 只有 cnb 没有 origin

0.1.2 起会依次尝试 origin → cnb → 其他 remote。也可显式传:

cnb-deploy deploy production --tag 1.0.0 --repo huyooo/infra/xxx

多 Deployment 项目(如 queue-server)使用 DEPLOY_DEPLOYMENT_NAMES,不再强制 DEPLOY_WORKLOAD_NAME。

2. 未找到有效的登录凭证

本地未登录或凭证失效。

npx cnb login
npx cnb status

也可设置环境变量 CNB_TOKEN(需含 repo-cnb-trigger:rw)。

3. 触发成功但流水线找不到事件 / 不跑部署

  • 确认模板已增加 api_trigger_deploy_* 且已 push
  • 确认事件名与环境一致:api_trigger_deploy_test|staging|production
  • 本地传的 --env 会拼到事件名末尾,并读取 .cnb/tag_deploy.yml 注入 DEPLOY_*

4. OpenAPI 不能触发平台「Deploy」按钮吗?

不能。CNB 规定:

| 事件 | 触发方式 | |------|----------| | tag_deploy.* | 仅平台 Tag 页 Deploy | | web_trigger* | 仅页面按钮 | | api_trigger* | OpenAPI / cnb build start-build / CLI |

所以本地脚本必须走 api_trigger_deploy_*,与平台 Deploy 共用流水线定义。

5. npm view @huyooo/cnb-deploy 404,但官网已有包

发布后 registry 偶发同步延迟。稍等再装,或:

npm view @huyooo/cnb-deploy version --registry https://registry.npmjs.org/

6. production 为什么要输入 yes?

防止误操作。脚本/CI 可加 --yes / -y 跳过。

7. 版本从哪来?会不会改 package.json?

  • 默认:基于最新 git tag 做 patch/minor/major(适合应用仓 package.json 为 0.0.0)
  • --package:走 bumpp,会改 package.json 并 commit/tag/push(对齐 @huyooo/release)

8. deploy 和 release 区别

| 命令 | 行为 | |------|------| | deploy | 部署已有 tag,不新建 tag | | release | 选/建版本 → push tag → 再部署 | | tag / bump | 只打 tag,不部署 |

开发

npm install
npm run build
npm test
node bin/cnb-deploy.js --help