@igniter-js/cli 0.2.71 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +213 -27
  2. package/dist/index.d.mts +2 -1
  3. package/dist/index.mjs +3556 -19991
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +38 -53
  6. package/templates/add-ons/auth/better-auth/auth.hbs +37 -0
  7. package/templates/add-ons/bots/nextjs/route-handler.hbs +10 -0
  8. package/templates/add-ons/bots/sample-bot.hbs +26 -0
  9. package/templates/add-ons/bots/tanstack-start/route-handler.hbs +15 -0
  10. package/templates/add-ons/database/prisma/lib.hbs +11 -0
  11. package/templates/add-ons/database/prisma/prisma.config.hbs +13 -0
  12. package/templates/add-ons/database/prisma/schema.hbs +15 -0
  13. package/templates/add-ons/jobs/jobs.ts.hbs +32 -0
  14. package/templates/add-ons/jobs/redis.ts.hbs +13 -0
  15. package/templates/add-ons/jobs/store.ts.hbs +12 -0
  16. package/templates/add-ons/logging/logger.ts.hbs +14 -0
  17. package/templates/add-ons/mcp/mcp.ts.hbs +21 -0
  18. package/templates/add-ons/mcp/nextjs/route-handler.hbs +11 -0
  19. package/templates/add-ons/mcp/tanstack-start/route-handler.hbs +19 -0
  20. package/templates/add-ons/store/redis.ts.hbs +13 -0
  21. package/templates/add-ons/store/store.ts.hbs +12 -0
  22. package/templates/add-ons/telemetry/telemetry.ts.hbs +20 -0
  23. package/templates/generate/feature/empty.controller.hbs +20 -0
  24. package/templates/generate/feature/empty.interfaces.hbs +5 -0
  25. package/templates/generate/feature/procedure.hbs +23 -0
  26. package/templates/generate/feature/schema.controller.hbs +73 -0
  27. package/templates/generate/feature/schema.interfaces.hbs +23 -0
  28. package/templates/generate/feature/schema.procedure.hbs +23 -0
  29. package/templates/scaffold/example-feature/example.controller.hbs +23 -0
  30. package/templates/scaffold/example-feature/example.interfaces.hbs +14 -0
  31. package/templates/scaffold/example-feature/example.procedure.hbs +28 -0
  32. package/templates/scaffold/igniter.schema.hbs +21 -0
  33. package/templates/starters/igniter.client.hbs +52 -0
  34. package/templates/starters/igniter.context.hbs +10 -0
  35. package/templates/starters/igniter.hbs +43 -0
  36. package/templates/starters/igniter.router.hbs +14 -0
  37. package/templates/starters/nextjs/route-handler.hbs +8 -0
  38. package/templates/starters/nextjs/tsconfig.hbs +35 -0
  39. package/templates/starters/open-api.hbs +45 -0
  40. package/templates/starters/tanstack-start/route-handler.hbs +13 -0
  41. package/templates/starters/tanstack-start/tsconfig.hbs +15 -0
  42. package/bin/igniter +0 -2
  43. package/dist/index.d.ts +0 -1
  44. package/dist/index.js +0 -20307
  45. package/dist/index.js.map +0 -1
package/README.md CHANGED
@@ -1,57 +1,243 @@
1
- # @igniter-js/cli
1
+ # @igniter-js/new-cli
2
2
 
3
- [![NPM Version](https://img.shields.io/npm/v/@igniter-js/cli.svg)](https://www.npmjs.com/package/@igniter-js/cli)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
+ The official Igniter.js command-line interface for scaffolding projects, generating features, wiring add-ons, and keeping your API docs in sync. It is designed for a fast developer experience, type-safe defaults, and seamless automation.
5
4
 
6
- The official Command-Line Interface (CLI) for the Igniter.js framework. This tool is designed to enhance developer productivity by automating common tasks like project scaffolding and running the development server.
5
+ ## Highlights
7
6
 
8
- ## Role in the Ecosystem
7
+ - 🚀 **Project bootstrapper** with interactive wizards, starter templates, and add-on setup (store, jobs, auth, bots, telemetry, MCP, database, Shadcn/UI).
8
+ - 🛠️ **Code generators** for features, controllers, procedures, schemas, and OpenAPI specs, all backed by Handlebars templates.
9
+ - 🧠 **Schema-aware workflow** with pluggable providers (Prisma out of the box) that produce strongly typed controllers, procedures, and interfaces.
10
+ - 👀 **Development dashboard** powered by Ink that automatically regenerates schema/docs and streams app logs in a split view.
11
+ - 🧩 **Template engine + registries** to extend starters, add-ons, and schema providers without touching the core.
9
12
 
10
- The `@igniter-js/cli` package is a key part of the Igniter.js developer experience. It provides a set of simple commands that handle complex setup and execution processes, allowing you to focus on writing code instead of configuring boilerplate.
13
+ ---
11
14
 
12
- ## Usage
15
+ ## Requirements
13
16
 
14
- The recommended way to use the CLI is via `npx`, which ensures you are always using the latest version without needing a global installation.
17
+ - Node.js **18.17+** (supports npm, pnpm, yarn, bun)
18
+ - Git (used for cloning starters)
19
+ - Docker (optional, for add-ons that provision services such as Redis/PostgreSQL)
20
+
21
+ ---
22
+
23
+ ## Installation
24
+
25
+ > You can run the CLI on demand via `npx`/`pnpx`/`bunx`/`yarn dlx`, or install it globally if you prefer the `igniter` executable on your PATH.
15
26
 
16
27
  ```bash
17
- npx @igniter-js/cli <command>
28
+ # Execute without installing globally
29
+ npx @igniter-js/new-cli@latest --help
30
+
31
+ # Install globally with your favourite package manager
32
+ npm install -g @igniter-js/new-cli
33
+ # or
34
+ pnpm add -g @igniter-js/new-cli
35
+ # or
36
+ yarn global add @igniter-js/new-cli
37
+ # or
38
+ bun add -g @igniter-js/new-cli
39
+
40
+ # Verify
41
+ igniter --version
18
42
  ```
19
43
 
20
- ## Commands
44
+ ---
45
+
46
+ ## Quick Start
47
+
48
+ ```bash
49
+ # Scaffold a Next.js app with Redis store + Better Auth + Prisma/PostgreSQL database
50
+ igniter init my-igniter-app \
51
+ --template nextjs \
52
+ --add-ons store,auth,database \
53
+ --database postgresql
54
+
55
+ # Generate a feature from a Prisma model
56
+ cd my-igniter-app
57
+ igniter generate feature user --schema prisma:User
58
+
59
+ # Keep schema + docs in sync while coding
60
+ igniter dev --cmd "pnpm dev"
61
+ ```
62
+
63
+ During `igniter init` you can accept interactive defaults, or supply flags for fully scripted runs. Add-ons configure package.json, .env, docker-compose, and template files — all tailored to the starter you pick.
21
64
 
22
- The CLI provides two main commands to manage your project's lifecycle.
65
+ ---
66
+
67
+ ## Commands
23
68
 
24
69
  ### `igniter init`
25
70
 
26
- The `init` command scaffolds a new, production-ready Igniter.js project from scratch. It runs an interactive setup wizard that configures your project structure, dependencies, and optional features like the Store and Queues.
71
+ Create a new Igniter.js project (either in-place or as a new directory).
27
72
 
28
- **Example:**
29
- ```bash
30
- # Create a new project in a directory named 'my-api'
31
- npx @igniter-js/cli init my-api
73
+ | Option | Description | Default |
74
+ |--------|-------------|---------|
75
+ | `[project-name]` | Output directory (omit to use current working dir) | `.` |
76
+ | `--mode <install\|new-project>` | Use existing folder or scaffold a fresh directory | `new-project` |
77
+ | `--pm, --package-manager <npm\|yarn\|pnpm\|bun>` | Force package manager detection | auto |
78
+ | `--template <starter-id>` | Starter ID (`nextjs`, `express-rest-api`, `tanstack-start`, `bun-rest-api`, `bun-react-app`, `deno-rest-api`) | prompted |
79
+ | `--add-ons <list>` | Comma-separated add-ons (`store`,`jobs`,`mcp`,`logging`,`telemetry`,`bots`,`database`,`auth`,`shadcn-ui`) | prompted |
80
+ | `--database <provider>` | Preselect database provider when not using prompts (`postgresql`,`mysql`,`sqlite`,`none`) | prompted |
81
+ | `--no-git` / `--no-install` / `--no-docker` | Skip Git init, dependency install, or Docker bootstrap | `false` |
82
+
83
+ Starters are fetched from the Igniter.js monorepo, dependencies are installed via the detected package manager, and add-ons may run post-install hooks (Prisma generate, Better Auth CLI, Shadcn init, etc.).
84
+
85
+ ---
86
+
87
+ ### `igniter generate feature`
88
+
89
+ Scaffold a feature skeleton under `src/features/<name>/` with controllers, interfaces, and optional procedures.
90
+
91
+ ```
92
+ igniter generate feature users
93
+ igniter generate feature post --schema prisma:Post --schema-path prisma/schema.prisma
32
94
  ```
33
95
 
34
- For more details, see the **[igniter init documentation](https://igniterjs.com/docs/cli-and-tooling/igniter-init)**.
96
+ Flags:
97
+ - `--schema <provider:model>` picks a schema provider (Prisma by default) to generate CRUD-ready files.
98
+ - `--schema-path <path>` overrides the provider’s default schema location (e.g., custom Prisma schema path).
99
+
100
+ ### `igniter generate controller`
101
+
102
+ ```
103
+ igniter generate controller profile --feature user
104
+ ```
105
+
106
+ Adds a controller file to an existing feature, ensuring directories and naming conventions stay consistent.
107
+
108
+ ### `igniter generate procedure`
109
+
110
+ ```
111
+ igniter generate procedure billing --feature invoices
112
+ ```
113
+
114
+ Creates a procedure scaffold (including removal of the `.gitkeep` placeholder when necessary).
115
+
116
+ ### `igniter generate docs`
117
+
118
+ ```
119
+ igniter generate docs --router src/igniter.router.ts --output src/docs
120
+ ```
121
+
122
+ Produces an OpenAPI 3.0 JSON file using your router’s docs configuration. Useful for deploying documentation or powering Igniter Studio.
123
+
124
+ ### `igniter generate schema`
125
+
126
+ ```
127
+ igniter generate schema --router src/igniter.router.ts --output src/igniter.schema.ts
128
+ ```
129
+
130
+ Generates a TypeScript client schema (const assertion + type) that mirrors your server endpoints.
35
131
 
36
132
  ### `igniter dev`
37
133
 
38
- The `dev` command starts the Igniter.js development server. It watches your files for changes and provides hot-reloading. Its most powerful feature is the interactive mode.
134
+ Watch mode that keeps schema and docs regenerated while proxying your application’s dev server.
135
+
136
+ ```
137
+ igniter dev \
138
+ --router src/igniter.router.ts \
139
+ --output src/igniter.schema.ts \
140
+ --docs-output src/docs \
141
+ --cmd "pnpm dev"
142
+ ```
143
+
144
+ Features:
145
+ - Ink-powered UI with two tabs (Igniter logs / Application logs) — switch via `←/→` or `1/2`.
146
+ - Debounced regeneration (300 ms) when `src/igniter.router.ts` or `src/features/**/*` changes.
147
+ - Default dev command inferred from the running package manager (`npm run dev`, `pnpm dev`, `bun dev`, `yarn dev`) when `--cmd` is omitted.
148
+ - Graceful teardown on `Ctrl+C` or `ESC`.
149
+
150
+ ---
151
+
152
+ ## Add-On Catalogue
153
+
154
+ | ID | Purpose | What you get | Docker |
155
+ |----|---------|--------------|--------|
156
+ | `store` | Redis-backed caching, sessions, pub/sub | `src/services/redis.ts`, `src/services/store.ts`, deps `@igniter-js/adapter-redis`, `ioredis`, env `REDIS_*` | `redis:7-alpine` |
157
+ | `jobs` | BullMQ job processing | Services for Redis + BullMQ, deps `@igniter-js/adapter-bullmq`, `bullmq`, env `IGNITER_JOBS_QUEUE_PREFIX` | `redis:7-alpine` |
158
+ | `mcp` | Model Context Protocol server | `src/igniter.mcp.ts`, Next.js/TanStack route handlers, deps `@igniter-js/adapter-mcp-server`, env `IGNITER_MCP_*`, `REDIS_*` | `redis:7-alpine` |
159
+ | `logging` | Structured logging | `src/services/logger.ts`, dep `@igniter-js/core`, env `IGNITER_LOG_LEVEL` | – |
160
+ | `telemetry` | Tracing + metrics hooks | `src/services/telemetry.ts`, dep `@igniter-js/core`, env `IGNITER_TELEMETRY_ENABLE_*` | – |
161
+ | `bots` | Multi-platform bot starter | Sample bot + framework-specific HTTP routes, dep `@igniter-js/bot@alpha`, env `TELEGRAM_*` | – |
162
+ | `database` | ORM + provider support | Interactive `orm` (Prisma/Drizzle) and `provider` (PostgreSQL/MySQL/SQLite) selection, generates env vars, `src/lib/database.ts`, Prisma schema & config when chosen; runs CLI post-install (`prisma generate` / `drizzle init`) | PostgreSQL (`postgres:16-alpine`) / MySQL (`mysql:8.0`) as needed |
163
+ | `auth` | Better Auth integration | `src/lib/auth.ts` with plugin imports, installs `better-auth@1.3.0`, runs `@better-auth/cli generate` | – |
164
+ | `shadcn-ui` | UI component kit | Runs `shadcn@latest init --base-color zinc --src-dir --silent --yes` after dependencies | – |
165
+
166
+ Add-on selections are fully templated: dependencies, `.env`, `docker-compose.yml`, and generated files all stay in sync with your choices.
167
+
168
+ ---
169
+
170
+ ## Schema Providers
171
+
172
+ Schema providers convert domain models into fully wired Igniter.js features.
173
+
174
+ - Providers live under `src/core/registry/schema-provider` and register through `schemaProviderRegistry`.
175
+ - Prisma support is built-in: run `igniter generate feature <name> --schema prisma:ModelName`.
176
+ - Use `--schema-path` to point at a custom Prisma schema (e.g., `--schema-path apps/admin/prisma/schema.prisma`).
177
+ - Providers can contribute templates, env vars, docker services, and post-install steps.
178
+
179
+ Extending the system:
180
+
181
+ 1. Implement a class extending `SchemaProvider`.
182
+ 2. Register it in `src/registry/schema-provider/index.ts`.
183
+ 3. Ship templates under `templates/generate/feature/` as needed.
184
+
185
+ ---
186
+
187
+ ## Development Mode UI
188
+
189
+ The Ink dashboard offers:
190
+
191
+ - **Tabs**: `Igniter.js` (CLI logs) and `Application` (child process output).
192
+ - **Shortcuts**: `1` / `←` toggles to Igniter, `2` / `→` toggles to Application, `Ctrl+C` or `ESC` exits.
193
+ - **Log retention**: Keeps the last 1,000 entries per stream with coloured severity badges.
194
+ - **Metrics**: Each regeneration reports duration, controller/action counts, and OpenAPI file size.
195
+
196
+ Ideal for local development alongside frameworks like Next.js, TanStack Start, Express, Bun, or Deno.
197
+
198
+ ---
199
+
200
+ ## Local Development (Maintainers)
39
201
 
40
- **Example:**
41
202
  ```bash
42
- # Start the development server in interactive mode
43
- igniter dev --interactive
203
+ # Install dependencies
204
+ npm install
205
+
206
+ # Watch build (tsup --watch)
207
+ npm run dev
208
+
209
+ # Type-check and build
210
+ npm run typecheck
211
+ npm run build
44
212
 
45
- # Start the server and manage the Next.js dev server alongside it
46
- igniter dev --interactive --framework nextjs
213
+ # Try the locally built CLI
214
+ npm link # once
215
+ igniter --help
47
216
  ```
48
217
 
49
- For more details, see the **[igniter dev documentation](https://igniterjs.com/docs/cli-and-tooling/igniter-dev)**.
218
+ Useful tips:
219
+ - The repository uses npm workspaces; run the commands from `packages/cli`.
220
+ - `npm run dev` rebuilds `dist/index.mjs` automatically when editing `src/**`.
221
+ - Keep `templates/` and registries in sync; always update `AGENTS.md` when adding new files.
50
222
 
51
- ## Contributing
223
+ ---
52
224
 
53
- Contributions are welcome! Please see the main [CONTRIBUTING.md](/CONTRIBUTING.md) file for details on how to get started.
225
+ ## Troubleshooting
226
+
227
+ - **Router not found**: Ensure `--router` points to the compiled TypeScript entry (default `src/igniter.router.ts`).
228
+ - **Docs generation fails**: Your router must include a `docs` configuration (`router.config.docs`). Without it, `igniter generate docs` exits with an error.
229
+ - **Docker conflicts**: The init command attempts to free ports used in `docker-compose.yml`. Free them manually if the helper cannot terminate existing processes.
230
+ - **Better Auth / Prisma CLI errors**: These post-install hooks require the dependencies to be installed. Re-run `npm install` and `igniter init` (or rerun the add-on setup) if they fail.
231
+ - **Ink UI not rendering**: Ensure you are running inside a Node-supported terminal (macOS Terminal, iTerm, Windows Terminal, etc.).
232
+
233
+ ---
54
234
 
55
235
  ## License
56
236
 
57
- This package is licensed under the [MIT License](/LICENSE).
237
+ MIT © Felipe Barcelos and the Igniter.js contributors.
238
+
239
+
240
+
241
+
242
+
243
+
package/dist/index.d.mts CHANGED
@@ -1 +1,2 @@
1
- #!/usr/bin/env node
1
+
2
+ export { }