|
| 1 | +# @forinda/kickjs-cli |
| 2 | + |
| 3 | +Command-line interface for scaffolding projects, generating code, and running the dev server. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +```bash |
| 8 | +# Global install |
| 9 | +pnpm add -g @forinda/kickjs-cli |
| 10 | + |
| 11 | +# Or use npx |
| 12 | +npx @forinda/kickjs-cli new my-api |
| 13 | +``` |
| 14 | + |
| 15 | +### Link local build (for contributors) |
| 16 | + |
| 17 | +```bash |
| 18 | +pnpm build |
| 19 | +cd packages/cli && pnpm link --global |
| 20 | +``` |
| 21 | + |
| 22 | +`kick` now points to your local build. Re-run `pnpm build` after changes. |
| 23 | + |
| 24 | +## CLI Commands |
| 25 | + |
| 26 | +| Command | Alias | Description | |
| 27 | +|---------|-------|-------------| |
| 28 | +| `kick new <name>` | `kick init` | Create a new KickJS project | |
| 29 | +| `kick dev` | | Start dev server with Vite HMR | |
| 30 | +| `kick list` | `kick ls` | List all available KickJS packages | |
| 31 | +| `kick add <packages...>` | | Install KickJS packages with peer deps | |
| 32 | +| `kick generate --list` | `kick g --list` | List all available generators | |
| 33 | +| `kick generate module <name>` | `kick g module` | Generate a full DDD module with all layers | |
| 34 | +| `kick generate scaffold <name> <fields...>` | `kick g scaffold` | CRUD module from field definitions (`name:type:optional`) | |
| 35 | +| `kick generate adapter <name>` | `kick g adapter` | Generate an AppAdapter scaffold | |
| 36 | +| `kick generate middleware <name>` | `kick g middleware` | Generate an Express middleware function | |
| 37 | +| `kick generate guard <name>` | `kick g guard` | Generate a route guard | |
| 38 | +| `kick generate service <name>` | `kick g service` | Generate a `@Service()` class | |
| 39 | +| `kick generate controller <name>` | `kick g controller` | Generate a `@Controller()` class with routes | |
| 40 | +| `kick generate dto <name>` | `kick g dto` | Generate a Zod DTO schema | |
| 41 | +| `kick generate resolver <name>` | `kick g resolver` | Generate a GraphQL `@Resolver` class | |
| 42 | +| `kick generate job <name>` | `kick g job` | Generate a `@Job` queue processor | |
| 43 | +| `kick generate test <name>` | `kick g test` | Generate a Vitest test scaffold | |
| 44 | +| `kick generate config` | `kick g config` | Generate `kick.config.ts` | |
| 45 | +| `kick info` | | Print system and framework info | |
| 46 | +| `kick inspect` | | Inspect a running KickJS application | |
| 47 | +| `kick tinker` | | Interactive REPL | |
| 48 | + |
| 49 | +### Command Options |
| 50 | + |
| 51 | +**kick new [name]** (use `.` for current directory) |
| 52 | +- `-d, --directory <dir>` -- Target directory (defaults to project name) |
| 53 | +- `--pm <manager>` -- Package manager: `pnpm` | `npm` | `yarn` (prompted if omitted) |
| 54 | +- `--git / --no-git` -- Initialize git repository (prompted if omitted) |
| 55 | +- `--install / --no-install` -- Install dependencies (prompted if omitted) |
| 56 | + |
| 57 | +**kick dev** |
| 58 | +- `-e, --entry <file>` -- Entry file (default: `src/index.ts`) |
| 59 | +- `-p, --port <port>` -- Port number |
| 60 | + |
| 61 | +**kick g module** |
| 62 | +- `--pattern <type>` -- Module structure: `rest` | `ddd` | `cqrs` | `minimal` (default: from config or `ddd`) |
| 63 | +- `--no-entity` -- Skip entity and value object generation (DDD only) |
| 64 | +- `--no-tests` -- Skip test file generation |
| 65 | +- `--repo <type>` -- Repository implementation: `inmemory` | `drizzle` | `prisma` (default: from config or `inmemory`) |
| 66 | +- `--minimal` -- Shorthand for `--pattern minimal` |
| 67 | +- `--modules-dir <dir>` -- Modules directory (default: from config or `src/modules`) |
| 68 | +- `-f, --force` -- Overwrite existing files without prompting |
| 69 | + |
| 70 | +**kick g controller / service / dto / guard / middleware** |
| 71 | +- `-o, --out <dir>` -- Output directory (overrides `--module`) |
| 72 | +- `-m, --module <name>` -- Place inside a module's DDD folder structure |
| 73 | + |
| 74 | +**kick g adapter / resolver / job** |
| 75 | +- `-o, --out <dir>` -- Output directory (defaults vary per generator) |
| 76 | + |
| 77 | +## defineConfig |
| 78 | + |
| 79 | +Helper to define a type-safe `kick.config.ts`. |
| 80 | + |
| 81 | +```typescript |
| 82 | +function defineConfig(config: KickConfig): KickConfig |
| 83 | +``` |
| 84 | + |
| 85 | +## KickConfig |
| 86 | + |
| 87 | +```typescript |
| 88 | +interface KickConfig { |
| 89 | + pattern?: 'rest' | 'ddd' | 'cqrs' | 'minimal' |
| 90 | + modules?: { |
| 91 | + dir?: string // default: 'src/modules' |
| 92 | + repo?: 'drizzle' | 'inmemory' | 'prisma' | { name: string } |
| 93 | + pluralize?: boolean // default: true |
| 94 | + schemaDir?: string // For Drizzle/Prisma schema files |
| 95 | + prismaClientPath?: string // Prisma 7: '@/generated/prisma/client' |
| 96 | + } |
| 97 | + commands?: KickCommandDefinition[] |
| 98 | + style?: { |
| 99 | + semicolons?: boolean |
| 100 | + quotes?: 'single' | 'double' |
| 101 | + trailingComma?: 'all' | 'es5' | 'none' |
| 102 | + indent?: number |
| 103 | + } |
| 104 | + // Deprecated (use modules.* instead) |
| 105 | + modulesDir?: string // @deprecated - use modules.dir |
| 106 | + defaultRepo?: 'drizzle' | 'inmemory' | 'prisma' // @deprecated - use modules.repo |
| 107 | + pluralize?: boolean // @deprecated - use modules.pluralize |
| 108 | + schemaDir?: string // @deprecated - use modules.schemaDir |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | +## KickCommandDefinition |
| 113 | + |
| 114 | +Register custom CLI commands via `kick.config.ts`. |
| 115 | + |
| 116 | +```typescript |
| 117 | +interface KickCommandDefinition { |
| 118 | + name: string // e.g. 'db:migrate' |
| 119 | + description: string |
| 120 | + steps: string | string[] // shell command(s) to run |
| 121 | + aliases?: string[] |
| 122 | +} |
| 123 | +``` |
| 124 | + |
| 125 | +## Programmatic Exports |
| 126 | + |
| 127 | +Generator functions for use outside the CLI. |
| 128 | + |
| 129 | +```typescript |
| 130 | +function generateModule(options: ModuleOptions): Promise<string[]> |
| 131 | +function generateScaffold(options: ScaffoldOptions): Promise<string[]> |
| 132 | +function generateAdapter(options: { name: string; outDir: string }): Promise<string[]> |
| 133 | +function generateMiddleware(options: { name: string; outDir: string }): Promise<string[]> |
| 134 | +function generateGuard(options: { name: string; outDir: string }): Promise<string[]> |
| 135 | +function generateService(options: { name: string; outDir: string }): Promise<string[]> |
| 136 | +function generateController(options: { name: string; outDir: string }): Promise<string[]> |
| 137 | +function generateDto(options: { name: string; outDir: string }): Promise<string[]> |
| 138 | +function generateResolver(options: { name: string; outDir: string }): Promise<string[]> |
| 139 | +function generateJob(options: { name: string; outDir: string; queue?: string }): Promise<string[]> |
| 140 | +function generateConfig(options: ConfigOptions): Promise<string[]> |
| 141 | +function initProject(options: { name: string; directory: string; packageManager: string }): Promise<void> |
| 142 | +function loadKickConfig(cwd: string): Promise<KickConfig | null> |
| 143 | +``` |
| 144 | + |
| 145 | +### RepoType |
| 146 | + |
| 147 | +```typescript |
| 148 | +type RepoType = 'drizzle' | 'inmemory' | 'prisma' |
| 149 | +``` |
| 150 | + |
| 151 | +## Naming Utilities |
| 152 | + |
| 153 | +```typescript |
| 154 | +function toPascalCase(str: string): string |
| 155 | +function toCamelCase(str: string): string |
| 156 | +function toKebabCase(str: string): string |
| 157 | +function pluralize(str: string): string |
| 158 | +``` |
0 commit comments