Skip to content

Repository files navigation

ts-cli-template (Bun)

A best-practice TypeScript CLI project template powered by Bun.

Features

  • Runtime: Bun for ultra-fast execution, native TypeScript support, and built-in testing.
  • CLI Framework: Commander.js for structured subcommands.
  • Linting & Formatting: Biome for ultra-fast linting and formatting.
  • Configuration: Platform-standard config paths using platformdirs and zod for validation.
  • Visuals: Emoji-enhanced logging with chalk and timestamps.
  • Compilation: Easy binary compilation using bun build --compile.

Getting Started

  1. Clone the repository.
  2. Install dependencies:
    bun install
  3. Run pre-check:
    bun start precheck
  4. Initialize config:
    bun start config init
  5. Setup Development Environment:
    bun run dev-register   # Register your git identity
    Git hooks are installed automatically by bun install. Run bun run setup-hooks if you need to repair or reinstall them.
  6. Run the application:
    bun start run
  7. Run tests:
    bun test

Configuration

Configuration is stored in platform-standard locations via platformdirs:

  • macOS: ~/Library/Application Support/ts-cli-template/config.json
  • Linux: ~/.config/ts-cli-template/config.json
  • Windows: %APPDATA%\ts-cli-template\config.json

For tests or isolated runs, set TS_CLI_TEMPLATE_CONFIG_DIR to override the config directory.

Development

  • Linting: bun run lint
  • Formatting: bun run format
  • Check (Lint + Format Validation): bun run check
  • Check and Fix: bun run check:fix
  • Type Checking: bun run typecheck
  • Git Hooks: bun install automatically installs hooks from lefthook.yml; bun run setup-hooks reinstalls them manually.

Lefthook verifies your registered Git identity and runs bun run check before commits. Before pushes it verifies identity, runs bun run typecheck, and runs bun test.

Build

Compile your CLI into a single, standalone executable:

bun run build

The output will be located in dist/ts-cli-template. This binary includes the Bun runtime, your code, and all dependencies.

About

my best practices template for new typescript cli projects

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages