@basenative/cli

中文文档
3.0.0发布于 2026/10/31Apache-2.0TypeScriptES Module构建来源已验证

bn CLI: create, deploy, doctor, and from-jsx (React drafts to BaseNative templates)

原始使用文档
文档目录10 节
  1. Install
  2. Quick start
  3. Commands
  4. Front door
  5. Workflow
  6. Options
  7. End-to-end example
  8. Templates
  9. Manifest
  10. License

@basenative/cli

The bn command — front door for every BaseNative / DuganLabs project.

Scaffolding, PRDs, spec-driven workflows (compatible with github/spec-kit), GitHub milestones/issues, Nx, Wrangler + Doppler deploys, and a doctor that calls out drift. Zero heavy dependencies — Node built-ins only.

Install

npm install -g @basenative/cli
# or, without installing:
npx @basenative/cli create my-app

Quick start

bn create my-app --template t4bs
cd my-app
bn dev
bn deploy --preview

Commands

Front door

CommandWhat it does
bn create <name> [-t <template>]Scaffold a new project. Templates: webapp (default), worker, library, t4bs. Legacy: minimal, enterprise, api.
bn prd initWrite docs/PRD.md from the t4bs-format scaffold.
bn prd editOpen docs/PRD.md in $EDITOR.
bn prd syncParse the milestones section → .bn/prd-issues.json (consumed by bn gh sync).
bn speckit initBootstrap .specify/ (memory, specs, templates).
bn speckit spec <name>Scaffold .specify/specs/NNN-name/spec.md.
bn speckit planStub plan.md for the active spec.
bn speckit tasksExtract tasks.md items → .bn/speckit-tasks.json.
bn speckit validateLint specs/plans/tasks for required fields.
bn gh syncIdempotently create milestones + issues from .bn/*.json.
bn gh boardCreate / verify the org Project for this repo.
bn gh automateVerify .github/workflows/deploy.yml references DuganLabs/.github reusable workflows.
bn nx [...]Passthrough to nx (uses your detected pm). --task <t> [--affected] shorthand for common runs.

Workflow

CommandWhat it does
bn devRun the project's dev server with hot module replacement (npm-script first, then node --watch, then wrangler dev). --no-hmr opts out.
bn deploy --prod / --previewwrangler pages deploy (or wrangler deploy), wrapped in doppler run -- if Doppler is installed.
`bn deploy --env <previewstaging
bn doctorValidate Node version, .nvmrc, packageManager, eslint config, tsconfig, doppler-required.json, deploy.yml.
bn buildBuild for production.
bn generate <type> <name>Generate a component, route, or page.
`bn env <listset
bn analyze [dir]Bundle size + dependency report.

Options

Every command supports --help/-h. Top-level flags:

  • -h, --help Show help.
  • -v, --version Print the installed CLI version.

Commands that emit data accept --json. Commands that mutate the filesystem or remote state accept --dry-run.

End-to-end example

# 1. Scaffold and check
bn create rocket --template webapp
cd rocket
bn doctor

# 2. Author a PRD, sync to GitHub
bn prd init --owner "Warren"
$EDITOR docs/PRD.md         # fill in milestones
bn prd sync
bn gh sync                  # idempotent

# 3. Spec a feature
bn speckit init
bn speckit spec onboarding
bn speckit plan
bn speckit tasks
bn gh sync --input .bn/speckit-tasks.json

# 4. Build and ship
bn dev
bn deploy --preview
bn deploy --prod

Templates

All templates ship with:

  • package.json referencing @basenative/* packages.
  • eslint.config.js extending @basenative/eslint-config.
  • tsconfig.json extending @basenative/tsconfig.
  • .nvmrc, .prettierrc, .gitignore.
  • wrangler.toml (where applicable).
  • .github/workflows/deploy.yml calling reusable workflows from DuganLabs/.github.
TemplateStack
webappCloudflare Pages SPA + Worker, BaseNative runtime/router/server.
workerCloudflare Worker (API / cron / queue).
librarynpm-publishable library, Apache-2.0.
t4bsGame scaffold using @basenative/og-image, keyboard, share, auth-webauthn, admin, persist.

Manifest

manifest.json enumerates every command, subcommand, and flag — useful for shell completions and downstream tooling.

License

Apache-2.0.

版本与发布记录

@basenative/cli 共发布 11 个版本,首次发布于 2026/03/20;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.0.0latest2026/10/312 天前
2.4.02026/10/268 天前
2.3.22026/10/2212 天前
2.3.12026/10/2212 天前
2.3.02026/10/2212 天前
2.2.02026/10/2113 天前

关于 @basenative/cli 的常见问题

@basenative/cli 是什么?

bn CLI:创建、部署、医生和from-jsx (React草稿到BaseNative模板)

如何安装 @basenative/cli?

在项目目录运行 npm install @basenative/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 bn、create-basenative,可以用 npx bn 直接运行。

@basenative/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@basenative/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@basenative/cli 可以商用吗?

@basenative/cli 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@basenative/cli 还在维护吗?

最新版本 3.0.0 发布于 2026/10/31(2 天前);至今共发布 11 个版本,其中过去 12 个月发布了 11 个;首次发布于 2026/03/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。