Skip to content

CLI Cheat Sheet

Quick Commands

Your go-to reference for common CLI operations. For detailed documentation, see CLI Reference.

Most Common Commands

bash
# Quick single builder generation
npx fluent-gen-ts generate ./src/types.ts User

# Batch generation (uses config file)
npx fluent-gen-ts batch

# Interactive setup
npx fluent-gen-ts init

# Scan for available types
npx fluent-gen-ts scan "src/**/*.ts"

Essential Workflows

First Time Setup

bash
# 1. Initialize config
npx fluent-gen-ts init

# 2. Generate builders
npx fluent-gen-ts batch

# 3. Add to package.json
npm pkg set scripts.generate="fluent-gen-ts batch"

Daily Development

bash
# Regenerate all builders
npm run generate

# Preview changes (dry run)
npx fluent-gen-ts batch --dry-run

# Parallel generation for speed
npx fluent-gen-ts batch --parallel

Command Quick Reference

CommandWhat It DoesExample
generateCreate a single builderfluent-gen-ts generate file.ts Type
batchGenerate all builders from configfluent-gen-ts batch
initCreate config file interactivelyfluent-gen-ts init
scanList all available typesfluent-gen-ts scan "src/**/*.ts"
setup-commonCreate common utilities filefluent-gen-ts setup-common

Key Options

For generate Command

bash
-o, --output <path>       # Where to save the builder
-c, --config <path>       # Config file path
-t, --tsconfig <path>     # Custom tsconfig path
-p, --plugins <paths...>  # Plugin file paths
-d, --defaults            # Enable smart defaults
--dry-run                 # Preview without writing
--no-comments             # Disable JSDoc comments

For batch Command

bash
-c, --config <path>       # Config file (default: fluentgen.config.js)
-p, --plugins <paths...>  # Plugin file paths
-d, --dry-run             # Preview only, don't write files
--parallel                # Run generation in parallel

For scan Command

bash
-o, --output <pattern>    # Output pattern with {file}, {type}
-c, --config <path>       # Config file path
-p, --plugins <paths...>  # Plugin file paths
-e, --exclude <patterns...> # Exclude patterns
-t, --types <types>       # Comma-separated type names
-i, --interactive         # Interactive selection mode
--dry-run                 # Preview mode
--ignore-private          # Ignore non-exported types

Common Patterns

Add to package.json

json
{
  "scripts": {
    "generate": "fluent-gen-ts batch",
    "generate:watch": "chokidar 'src/types/**/*.ts' -c 'npm run generate'",
    "prebuild": "npm run generate",
    "pretest": "npm run generate"
  }
}

Git Hooks

bash
# .husky/pre-commit
#!/bin/sh
npm run generate
git add src/builders

Watch for Changes

bash
# Using nodemon
npx nodemon --watch src/types --exec 'npx fluent-gen-ts batch'

# Using chokidar
npx chokidar 'src/types/**/*.ts' -c 'npx fluent-gen-ts batch'

Troubleshooting Quick Fixes

"Type not found"

bash
# List all available types
npx fluent-gen-ts scan "./src/types.ts"

# Make sure type is exported
export interface User { ... }

"Config error"

bash
# Validate config syntax
node -e "console.log(require('./fluentgen.config.js'))"

# Recreate config
npx fluent-gen-ts init --overwrite

"Nothing generated"

bash
# Check what would be generated
npx fluent-gen-ts batch --dry-run

# Verify config targets
cat fluentgen.config.js

Check Exit Codes

bash
# Run and check status
npx fluent-gen-ts batch
echo $?  # 0 = success, non-zero = error

CI/CD Quick Setup

GitHub Actions

yaml
- name: Generate builders
  run: npx fluent-gen-ts batch

- name: Verify no changes
  run: git diff --exit-code src/builders

GitLab CI

yaml
generate:
  script:
    - npm install
    - npx fluent-gen-ts batch
    - git diff --exit-code src/builders

Tips & Shortcuts

Create Alias

bash
# Add to ~/.bashrc or ~/.zshrc
alias fgen="npx fluent-gen-ts"

# Usage
fgen batch
fgen generate ./types.ts User

Quick Type Discovery

bash
# List all types in a directory
npx fluent-gen-ts scan "src/**/*.ts"

# Interactive selection
npx fluent-gen-ts scan "src/**/*.ts" --interactive

Parallel Generation (Monorepo)

bash
# Run in all workspaces
npm run generate --workspaces

# Or manually
find packages -name 'fluentgen.config.js' \
  -execdir npx fluent-gen-ts batch \;

When You Need More

Released under the MIT License.