cli

command module
v0.0.0-...-8ef18ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

create-b7 (preview)

npm create b7@preview my-app                                  # asks for the template and its options
npm create b7@preview my-app -- -t fullstack --email none     # or: pnpm create b7 my-app -t fullstack --email none

A single Go binary with the templates of templates/ embedded. It copies one, including its b7.json (the configuration it implements), creates .env with a generated BETTER_AUTH_SECRET and POSTGRES_PASSWORD, runs pnpm install and git init, showing each step with its time. When a step fails, it prints the end of that step's output. When pnpm or Node.js 22.12+ is missing, it says how to install them (Node.js 25+ no longer ships corepack). Without a terminal (piped stdin), the prompts fall back to numbered questions.

Each directory in templates/ is a template, so adding templates/web makes -t web available. A template named <name> uses b7-<name> as its placeholder project name in package.json and README.md. Today only fullstack exists.

Flag Effect
--template, -t <name> Template to use. Without it, the CLI asks (or takes the first with --yes)
--email <resend|none> · --[no-]organizations · --billing <stripe|none> Configuration options. A template offers only those in its b7.features.json; the rest are rejected with rule 1. Without a flag, the CLI asks (or uses the default with --yes)
--yes, -y Accept defaults, no prompts
--no-install · --no-git Skip pnpm install · git init
--version, -v · --help, -h Print the version · usage

Preview. The generated project is tested locally, not yet on a deployed Worker. Read its Verification status before deploying.

Contract

create-b7 turns a B7Config into a project:

  1. Collect. Ask for the profile, then only the options that profile offers. Every prompt also has a flag (--profile fullstack --billing stripe).
  2. Validate. Apply the rules. Reject violations with the rule number. Print the EXPERIMENTAL notice where rule 4 applies.
  3. Generate. Write only the packages, files, Compose services and .env.example entries that the feature table lists for the selected options.
  4. Record. Write b7.json with the resolved configuration, including derived values, for later b7 add <option> commands.

All four steps are implemented. Options compose by removing feature regions from the complete template (ADR-014): a smaller configuration also gets a fresh drizzle/ migration, a regenerated route tree and an updated lockfile (pnpm install, or --lockfile-only with --no-install). Other profiles and b7 add arrive as each gets a tested template (ROADMAP.md).

Shared packages (packages/) are created only when two or more templates actually share code.

Develop

Needs Go (the version in go.mod).

go generate ./...          # copies ../templates into internal/template/templates for go:embed (gitignored)
go test ./...              # rules, regions, and the built binary against every option
go run . my-app --yes      # or: go build && ./create-b7
Path Role
main.go, ui.go Flags, prompts (huh), steps and the summary (lipgloss)
internal/config Configuration rules 1–4
internal/regions Feature regions (ADR-014)
internal/generate Copy, regions, removed options, b7.json, .env
testdata/ Rule and region cases, also run by site/test/b7.test.js against the landing's JS copy (site/src/lib/b7/), so the two never drift

Release

npm installs a native binary through optional dependencies, the way esbuild does:

  • create-b7 (npm/create-b7) is a launcher of a few lines that runs the binary for the user's platform.
  • create-b7-<os>-<arch> (linux-x64, linux-arm64, darwin-x64, darwin-arm64, win32-x64) each hold one binary. They are optionalDependencies of create-b7, so npm installs only the matching one.

The version lives in npm/create-b7/package.json. To release, bump it, commit, and push the tag v<version>. release.yml checks that the tag matches, runs GoReleaser (.goreleaser.yaml: binaries and a GitHub release with checksums), writes the npm packages (scripts/npm-packages.js), and publishes them with npm trusted publishing. A prerelease version (-preview.N) goes to the preview dist-tag.

CI (.github/workflows/cli.yml) runs the tests, builds a snapshot, packs the launcher and the linux-x64 package, generates a project through npm exec, and runs that project's checks and Compose stack.

Documentation

Overview

create-b7 generates a B7 project from an embedded template (cli/README.md).

Directories

Path Synopsis
internal
config
Package config resolves and validates a configuration against a template's b7.features.json and the configuration model rules (site/content/docs/configuration-model.md › Rules).
Package config resolves and validates a configuration against a template's b7.features.json and the configuration model rules (site/content/docs/configuration-model.md › Rules).
generate
Package generate writes a configuration of a template into a directory.
Package generate writes a configuration of a template into a directory.
ordered
Package ordered is a JSON object that keeps its key order, so package.json, b7.json and b7.features.json are written back the way JSON.stringify would write them.
Package ordered is a JSON object that keeps its key order, so package.json, b7.json and b7.features.json are written back the way JSON.stringify would write them.
regions
Package regions applies feature regions (ADR-014): lines between `#if <cond>` and `#endif` markers, in any comment style (`// #if x`, `# #if x`, `-- #if x`, `{/* #if x */}`, `<!-- #if x -->`), are kept only when <cond> holds.
Package regions applies feature regions (ADR-014): lines between `#if <cond>` and `#endif` markers, in any comment style (`// #if x`, `# #if x`, `-- #if x`, `{/* #if x */}`, `<!-- #if x -->`), are kept only when <cond> holds.
template
Package template embeds ../templates, copied here by `go generate` (the copy is gitignored).
Package template embeds ../templates, copied here by `go generate` (the copy is gitignored).
template/copy command
Copies ../../../templates into ../templates for go:embed, without build output and local state.
Copies ../../../templates into ../templates for go:embed, without build output and local state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL