@byline/cli

中文文档
6.13.3发布于 2026/11/09MPL-2.0TypeScriptES Module近 30 天下载 1783

Guided installer for Byline CMS into an existing TanStack Start application

原始使用文档
文档目录5 节
  1. Usage
  2. Database selection
  3. Generated collection types
  4. Upgrading older scaffolds and packages
  5. Already-wired apps (post-manual-config)

@byline/cli

Guided installer for Byline CMS into an existing TanStack Start application.

Usage

cd <your-tanstack-start-app>
npx @byline/cli init

The installer is a step-by-step wizard. It prints unified diffs for planned file writes. Confirm-mode phases wait before writing; safe auto phases apply directly unless --dry-run is set.

byline init                    Run the wizard, re-detecting current installation state.
byline init --only db-init     Re-run a single phase.
byline init --from wire        Resume from a specific phase.
byline init --apply            Skip the per-phase confirmation prompt (still prints diffs).
byline init --dry-run          Show every change but write nothing.
byline init --database mysql   Select MySQL without the database prompt.
byline init --apply -y         Apply detected safe scaffold upgrades noninteractively.
byline doctor                  Inspect the current app and report what's wired.

See byline init --help for the full flag list.

Database selection

The installer offers PostgreSQL (the default) and MySQL 8.0.14 or later. Pass --database postgres or --database mysql to choose noninteractively. MariaDB is not supported, and the Docker strategy remains deferred; use a running server with administrator credentials.

The selection controls every database-specific artifact:

SelectionPackageConnection variableServer configuration
PostgreSQL@byline/db-postgresBYLINE_DB_POSTGRES_CONNECTION_STRINGpgAdapter() and @byline/db-postgres/admin
MySQL@byline/db-mysqlBYLINE_DB_MYSQL_CONNECTION_STRINGmysqlAdapter() and @byline/db-mysql/admin

Example installations also receive the matching @byline/search-postgres or @byline/search-mysql provider. Minimal installations omit search. The unselected database package and environment variable are not added.

Generated collection types

byline init creates byline/generated/collection-types.ts and adds two application scripts:

pnpm byline:generate        # regenerate after changing collection or block schemas
pnpm byline:generate:check  # fail without writing when the artifact is missing or stale

The application script evaluates byline/collections/index.ts; it does not load server.config.ts. That collection tuple remains the runtime registry, while the generated module is its deterministic, standalone TypeScript projection for typed clients and frontend code. Keep the artifact committed and run the check in CI.

Upgrading older scaffolds and packages

The installer checks dependency ranges and required files instead of trusting old completed phase flags. Run byline init --apply -y to apply detected safe scaffold upgrades. Missing files and recognized canonical predecessors can be installed, while divergent user-owned scaffold, route, Vite, Turbo, and CI configuration is left untouched with an explicit manual instruction.

For CLI version x.y.z, the selected database adapter is pinned exactly to x.y.z so it matches the bundled schema baseline. Other registry-backed @byline/* dependencies must declare a range within >=x.y.z <(x+1).0.0-0; missing or incompatible declarations are planned at ^x.y.z. Local workspace:*, workspace:^, and workspace:~ links are never replaced. Their package version must resolve locally and satisfy the same compatibility floor, otherwise installation is blocked with a manual instruction.

In a monorepo, run the CLI from the application directory. App files remain under that directory, while pnpm settings, Turbo configuration, CI checks, and package-manager lockfile operations use the nearest workspace root whose declared package patterns include the application. An app excluded by those patterns remains standalone and cannot mutate the outer workspace configuration. When the owning workspace declares a package manager through its workspace file, root packageManager, or lockfile, the installer requires that manager and rejects conflicting --pm or previously selected choices before planning dependency writes. For a package.json-only workspace with no manager metadata, noninteractive runs must pass --pm. Choosing pnpm creates pnpm-workspace.yaml with the existing workspace package patterns and required allowBuilds entries together; npm, Yarn, and Bun continue using package.json workspaces.

Already-wired apps (post-manual-config)

If you wired Byline into your app by hand (collections, server.config.ts, env, routes, scaffold files all in place) and just need to provision the database and seed, use setup instead of init:

byline setup                       Provision DB, then seed super-admin and example docs.
byline setup --database mysql      Select MySQL when no choice is recorded.
byline setup --no-seed-admin       Provision DB and seed docs only.
byline setup --no-seed-docs        Provision DB and seed super-admin only.
byline setup --no-seed-admin --no-seed-docs
                                   Provision DB only.
byline setup --reset --i-mean-it   Destructive: drop and recreate the database.
byline setup --force               Re-run every phase even if recorded as complete.
byline setup --force --reset --i-mean-it
                                   Full re-run: drop and recreate the database, then re-seed.

setup runs preflight, resolves and verifies the database selection, checks the selected adapter's dependencies and environment, then runs db-init and the enabled seed phases. It does not touch project files. Declining or deferring database selection stops the command before downstream work. For new TanStack Start apps that need the full scaffold, use byline init.

By default setup consults .byline-install.json and skips phases already recorded as complete. --force bypasses completion state, but it does not turn the fresh baseline into an upgrade or weaken occupied-database checks.

The ordinary path applies the CLI's release-specific, squashed baseline only to a missing or empty database. It refuses an existing Byline schema and an unrelated occupied schema before mutation. Upgrade an existing installation with the numbered native SQL under packages/db-postgres/sql or packages/db-mysql/sql from the target release tag; the CLI does not apply those upgrade scripts.

Use --force --reset --i-mean-it only for an intentional rebuild. Reset skips occupied-database inspection, drops the named database, reapplies the fresh baseline, and discards all document data. Without --i-mean-it, the reset path asks for confirmation.

版本与发布记录

@byline/cli 共发布 175 个版本,首次发布于 2026/05/04;过去 12 个月发布了 175 个版本。

版本发布日期距今
6.13.3latest2026/11/09今天
6.13.22026/11/09今天
6.13.12026/11/09今天
6.13.02026/11/045 天前
6.12.12026/11/027 天前
6.12.02026/10/319 天前

关于 @byline/cli 的常见问题

@byline/cli 是什么?

Guided installer for Byline CMS into an existing TanStack Start application

如何安装 @byline/cli?

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

@byline/cli 支持 TypeScript 吗?

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

@byline/cli 支持 ESM 还是 CommonJS?

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

@byline/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.22.2。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@byline/cli 可以商用吗?

@byline/cli 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@byline/cli 的下载量有多少?

根据 npm 官方下载统计,@byline/cli 在 2026/10/09 – 2026/11/07 这 30 天内被下载 1,783 次,日均约 59 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@byline/cli 还在维护吗?

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