@book000/create-ts
v0.2.173
Published
Create book000-style TypeScript projects
Readme
create-ts
A CLI that scaffolds book000-style TypeScript / Node.js projects. It copies the bundled template for the chosen variant into a directory, fills in the project metadata, and runs pnpm install.
Requirements
- Node.js >=26.13.1 <27 (the CLI exits with an error otherwise)
- pnpm (generated projects reject other package managers with
only-allow) - Network access: dependencies are installed with
pnpm install, theLICENSEtext is fetched from the GitHub licenses API (skipped with a warning on failure), andfixpack/fixdevcontainerare run throughnpx(skipped on failure)
Usage
pnpm create @book000/ts [outdir] [options]outdir defaults to the current directory and is created if it does not exist. Any value not given as an option is asked interactively. The directory name is offered as the default project name when it is a valid package name.
To run without prompts, pass every option:
pnpm create @book000/ts my-app \
--name my-app --org book000 --repo my-app \
--description "My app" --author book000 --license MIT --homepage "" \
--bug-url https://github.com/book000/my-app/issues \
--variant base --no-esm --no-test --no-docker \
--no-ignore-data --no-add-reviewer --overwriteOptions
| Option | Description | Default |
| --- | --- | --- |
| --name <name> | Project name (npm package name rule: lowercase, up to 214 characters) | Asked |
| --org <org> | GitHub organization / user name. The package is named @<org lowercased>/<name> | Asked (book000) |
| --repo <repo> | Repository name | Asked |
| --description <desc> | Project description | Asked |
| --author <author> | Author name | Asked |
| --license <spdx> | SPDX license identifier (for example MIT, Apache-2.0) | Asked (MIT) |
| --homepage <url> | Homepage URL. An empty string omits the field | Asked |
| --bug-url <url> | Bug report URL | Asked |
| --variant <variant> | base, config-batch, fastify or discord-bot | Asked (base) |
| --esm / --no-esm | ES Modules / CommonJS | Asked (CommonJS) |
| --test / --no-test | Add / do not add Jest tests | Asked (no) |
| --docker / --no-docker | Add / do not add Dockerfile, entrypoint.sh and the Docker workflow | Asked (no) |
| --ignore-data / --no-ignore-data | Add / do not add data/ to .gitignore | Asked (no) |
| --add-reviewer / --no-add-reviewer | Add / do not add the add-reviewer workflow | Asked (no) |
| --overwrite | Overwrite existing files without asking. Without it, existing destination files are listed and require confirmation; non-interactive runs fail on collisions | Off |
Invalid values for --name, --org, --repo, --license or --variant make the CLI exit with an error. The prompts and most CLI messages are in Japanese.
Variants
| Variant | Contents |
| --- | --- |
| base | Minimal setup: src/main.ts |
| config-batch | Batch job with a JSON config (ConfigFramework from @book000/node-utils) and a generate-schema script |
| fastify | Fastify HTTP server with @fastify/cors |
| discord-bot | discord.js bot with a config and a generate-schema script |
Generated project
Every project gets tsconfig.json, .prettierrc.yml, eslint.config.mjs, renovate.json, .depcheckrc.json, .fixpackrc, pnpm-workspace.yaml, .devcontainer/devcontainer.json, .gitignore, .node-version (the Node.js version used to run the CLI), LICENSE (when it can be fetched), package.json, pnpm-lock.yaml, .github/workflows/nodejs-ci-pnpm.yml and the variant's src/ files. With --test, the variant's test files and tsconfig.test.json are added. Without it, Jest packages are removed after install.
Inside the generated project, pnpm run lint, pnpm run test (with --test), pnpm start and pnpm run dev are available.
Generated projects require Node.js >=26.13.1 <27 and use Node.js 26 for both the devcontainer and Docker image. The fastify test script enables Node.js VM modules so Jest can load ESM dependencies used by request injection. Its Node.js v24.9 minimum is covered by the generated project requirement.
Docker workflow
With --docker, the generated .github/workflows/docker.yml builds fork pull requests from pull_request_target with a privileged checkout. To keep that safe, create an Environment named fork-pr-build in the generated repository (Settings > Environments) and add at least one required reviewer. A job named Verify environment protection checks this through the REST API and fails the run when the Environment is missing or has no required reviewers, so fork PR builds stay blocked until it is configured. Naming an Environment alone does not protect anything: GitHub creates it without protection rules when it is first referenced.
Development
pnpm install
pnpm build # bundle src/index.ts to dist/index.mjs with tsdown
pnpm lint # prettier --check src, eslint, tsc
pnpm test # vitest
node dist/index.mjs --helpThe Node.js version is pinned in .node-version and pnpm in package.json. See AGENTS.md for the code structure and conventions.
Release
Every push to main or master runs .github/workflows/release.yml, which bumps the version from the Conventional Commit types, tags it, and publishes @book000/create-ts to npm. Do not bump the version or publish manually.
License
MIT
