@hazeljs/cli 0.5.4 → 0.6.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 (101) hide show
  1. package/@template-ai-native/package.json +1 -1
  2. package/README.md +122 -591
  3. package/dist/commands/add.js +26 -126
  4. package/dist/commands/generate-app.js +17 -230
  5. package/dist/commands/generate-simple.d.ts +27 -0
  6. package/dist/commands/generate-simple.js +448 -0
  7. package/dist/commands/generate-simple.test.js +100 -0
  8. package/dist/index.js +5 -47
  9. package/dist/index.list.test.js +8 -22
  10. package/dist/index.test.js +19 -56
  11. package/dist/utils/generator-registry.js +29 -65
  12. package/dist/utils/generator.d.ts +0 -1
  13. package/dist/utils/generator.js +0 -22
  14. package/dist/utils/generator.test.js +0 -28
  15. package/dist/utils/packages-registry.d.ts +25 -0
  16. package/dist/utils/packages-registry.js +371 -0
  17. package/package.json +3 -5
  18. package/dist/commands/build.d.ts +0 -2
  19. package/dist/commands/build.js +0 -52
  20. package/dist/commands/generate-agent.d.ts +0 -4
  21. package/dist/commands/generate-agent.js +0 -64
  22. package/dist/commands/generate-agent.test.js +0 -36
  23. package/dist/commands/generate-ai-service.d.ts +0 -4
  24. package/dist/commands/generate-ai-service.js +0 -54
  25. package/dist/commands/generate-ai-service.test.d.ts +0 -1
  26. package/dist/commands/generate-ai-service.test.js +0 -41
  27. package/dist/commands/generate-cache.d.ts +0 -4
  28. package/dist/commands/generate-cache.js +0 -66
  29. package/dist/commands/generate-cache.test.d.ts +0 -1
  30. package/dist/commands/generate-cache.test.js +0 -36
  31. package/dist/commands/generate-config.d.ts +0 -4
  32. package/dist/commands/generate-config.js +0 -59
  33. package/dist/commands/generate-config.test.d.ts +0 -1
  34. package/dist/commands/generate-config.test.js +0 -35
  35. package/dist/commands/generate-controller.d.ts +0 -4
  36. package/dist/commands/generate-controller.js +0 -66
  37. package/dist/commands/generate-controller.test.d.ts +0 -1
  38. package/dist/commands/generate-controller.test.js +0 -48
  39. package/dist/commands/generate-cron.d.ts +0 -4
  40. package/dist/commands/generate-cron.js +0 -61
  41. package/dist/commands/generate-cron.test.d.ts +0 -1
  42. package/dist/commands/generate-cron.test.js +0 -42
  43. package/dist/commands/generate-discovery.d.ts +0 -4
  44. package/dist/commands/generate-discovery.js +0 -63
  45. package/dist/commands/generate-discovery.test.d.ts +0 -1
  46. package/dist/commands/generate-discovery.test.js +0 -36
  47. package/dist/commands/generate-exception-filter.d.ts +0 -4
  48. package/dist/commands/generate-exception-filter.js +0 -54
  49. package/dist/commands/generate-exception-filter.test.d.ts +0 -1
  50. package/dist/commands/generate-exception-filter.test.js +0 -43
  51. package/dist/commands/generate-guard.d.ts +0 -4
  52. package/dist/commands/generate-guard.js +0 -42
  53. package/dist/commands/generate-guard.test.d.ts +0 -1
  54. package/dist/commands/generate-guard.test.js +0 -41
  55. package/dist/commands/generate-interceptor.d.ts +0 -4
  56. package/dist/commands/generate-interceptor.js +0 -43
  57. package/dist/commands/generate-interceptor.test.d.ts +0 -1
  58. package/dist/commands/generate-interceptor.test.js +0 -41
  59. package/dist/commands/generate-middleware.d.ts +0 -4
  60. package/dist/commands/generate-middleware.js +0 -47
  61. package/dist/commands/generate-middleware.test.d.ts +0 -1
  62. package/dist/commands/generate-middleware.test.js +0 -41
  63. package/dist/commands/generate-pipe.d.ts +0 -4
  64. package/dist/commands/generate-pipe.js +0 -39
  65. package/dist/commands/generate-pipe.test.d.ts +0 -1
  66. package/dist/commands/generate-pipe.test.js +0 -35
  67. package/dist/commands/generate-rag.d.ts +0 -4
  68. package/dist/commands/generate-rag.js +0 -68
  69. package/dist/commands/generate-rag.test.d.ts +0 -1
  70. package/dist/commands/generate-rag.test.js +0 -35
  71. package/dist/commands/generate-repository.d.ts +0 -4
  72. package/dist/commands/generate-repository.js +0 -46
  73. package/dist/commands/generate-repository.test.d.ts +0 -1
  74. package/dist/commands/generate-repository.test.js +0 -41
  75. package/dist/commands/generate-serverless-handler.d.ts +0 -4
  76. package/dist/commands/generate-serverless-handler.js +0 -57
  77. package/dist/commands/generate-serverless-handler.test.d.ts +0 -1
  78. package/dist/commands/generate-serverless-handler.test.js +0 -42
  79. package/dist/commands/generate-service.d.ts +0 -4
  80. package/dist/commands/generate-service.js +0 -58
  81. package/dist/commands/generate-service.test.d.ts +0 -1
  82. package/dist/commands/generate-service.test.js +0 -41
  83. package/dist/commands/generate-setup.d.ts +0 -4
  84. package/dist/commands/generate-setup.js +0 -187
  85. package/dist/commands/generate-setup.test.d.ts +0 -1
  86. package/dist/commands/generate-setup.test.js +0 -50
  87. package/dist/commands/generate-websocket-gateway.d.ts +0 -4
  88. package/dist/commands/generate-websocket-gateway.js +0 -53
  89. package/dist/commands/generate-websocket-gateway.test.d.ts +0 -1
  90. package/dist/commands/generate-websocket-gateway.test.js +0 -41
  91. package/dist/commands/pdf-to-audio.d.ts +0 -2
  92. package/dist/commands/pdf-to-audio.js +0 -170
  93. package/dist/commands/pdf-to-audio.test.d.ts +0 -1
  94. package/dist/commands/pdf-to-audio.test.js +0 -92
  95. package/dist/commands/start.d.ts +0 -2
  96. package/dist/commands/start.js +0 -61
  97. package/dist/commands/test.d.ts +0 -2
  98. package/dist/commands/test.js +0 -63
  99. package/dist/commands/utility-commands.test.d.ts +0 -1
  100. package/dist/commands/utility-commands.test.js +0 -95
  101. /package/dist/commands/{generate-agent.test.d.ts → generate-simple.test.d.ts} +0 -0
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **From zero to AI-powered apps in one command.**
4
4
 
5
- Generate controllers, services, modules, AI agents, RAG systems — or create a complete AI-Native application with PostgreSQL, Redis, and Docker. Interactive project setup, package management, and code that follows best practices. Stop copy-pasting, start shipping intelligent applications.
5
+ Generate controllers, services, modules, AI agents, RAG systems — or create a complete AI-Native application with PostgreSQL, Redis, and Docker. Interactive project setup, package management, and code that follows best practices.
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/@hazeljs/cli.svg)](https://www.npmjs.com/package/@hazeljs/cli)
8
8
  [![npm downloads](https://img.shields.io/npm/dm/@hazeljs/cli)](https://www.npmjs.com/package/@hazeljs/cli)
@@ -12,17 +12,11 @@ Generate controllers, services, modules, AI agents, RAG systems — or create a
12
12
 
13
13
  - 🤖 **AI-Native Templates** - Create complete AI applications with agents, RAG, PostgreSQL, and Docker
14
14
  - 🚀 **Project Scaffolding** - Create new HazelJS applications instantly with interactive setup
15
- - 🎨 **Code Generation** - Generate controllers, services, AI agents, RAG systems, and more
15
+ - 🎨 **Code Generation** - Generate controllers, services, AI agents, RAG systems, and 20+ component types
16
+ - 📦 **Package Management** - Add HazelJS packages interactively with optional setup file generation
16
17
  - 🏗️ **Best Practices** - Generated code follows HazelJS conventions and AI patterns
17
- - 🔧 **Customizable** - Specify paths and options for generated files
18
- - 📦 **Multiple Templates** - Support for various component types including AI components
18
+ - 🎯 **TypeScript First** - All generated code is fully typed
19
19
  - ⚡ **Fast Development** - Reduce boilerplate and speed up development
20
- - 🎯 **TypeScript First** - All generated code is fully typed with AI safety
21
- - 🛠️ **Utility Commands** - Build, start, test, and manage your project
22
- - 📊 **Project Info** - Display comprehensive project information
23
- - ➕ **Package Management** - Add HazelJS packages interactively
24
- - 🎭 **CRUD Generator** - Generate complete CRUD resources in one command
25
- - 🧠 **AI Components** - Generate agents, tools, RAG pipelines, and AI services
26
20
 
27
21
  ## Installation
28
22
 
@@ -38,672 +32,228 @@ npm install -g @hazeljs/cli
38
32
  npm install --save-dev @hazeljs/cli
39
33
  ```
40
34
 
41
- ## Usage
42
-
43
- The CLI provides commands to generate various HazelJS components, create new applications, and manage your project.
44
-
45
35
  ## Commands
46
36
 
47
- ### Project Management
37
+ ### Create a New Application
48
38
 
49
- #### Create new application
50
-
51
- **🤖 AI-Native Application (Recommended for AI Projects):**
39
+ **AI-Native Application (Recommended for AI Projects):**
52
40
  ```bash
53
- hazel g app <appName> --template=ai-native
54
- # Then: cd <appName> && npm install && cp .env.example .env && docker-compose up -d && npm run dev
41
+ hazel g app my-ai-app --template=ai-native
42
+ cd my-ai-app && npm install && cp .env.example .env && docker-compose up -d && npm run dev
55
43
  ```
56
44
 
57
- Creates a complete AI-powered application with:
58
- - 🤖 AI Agents with tools and memory
59
- - 📚 RAG System with PostgreSQL + pgvector
60
- - 🗄️ Database Setup (PostgreSQL, Redis)
61
- - 🐳 Docker Configuration for production
62
- - 📊 Complete API endpoints ready to use
45
+ Creates a complete AI-powered application with agents, RAG (PostgreSQL + pgvector), Redis, and Docker.
63
46
 
64
- **Skeleton app (quick start, like create-next-app):**
47
+ **Skeleton app (quick start):**
65
48
  ```bash
66
- hazel g app <appName>
67
- # Then: cd <appName> && npm install && npm run dev
49
+ hazel g app my-app
50
+ cd my-app && npm install && npm run dev
68
51
  ```
69
52
 
70
53
  **Full setup with interactive package selection:**
71
54
  ```bash
72
- hazel new <appName> [options]
55
+ hazel new my-app -i
73
56
  ```
74
57
 
75
- Creates a new HazelJS application. Use `hazel g app <name> --template=ai-native` for AI applications; `hazel g app <name>` for a minimal skeleton; use `hazel new <name> -i` for interactive setup with optional packages.
76
-
77
58
  **Options:**
78
59
  - `-d, --dest <path>` - Destination path (default: current directory)
79
60
  - `-i, --interactive` - Interactive setup with package selection
61
+ - `--template <template>` - Template to use (`ai-native` or `default`)
80
62
  - `--skip-install` - Skip npm install
81
63
  - `--skip-git` - Skip git initialization
82
64
 
83
- **Examples:**
84
- ```bash
85
- # AI-Native application (recommended for AI projects)
86
- hazel g app my-ai-app --template=ai-native
87
-
88
- # Basic project creation
89
- hazel new my-app
90
-
91
- # Interactive setup with package selection
92
- hazel new my-app -i
93
-
94
- # Create without installing dependencies
95
- hazel new my-app --skip-install
96
- ```
97
-
98
- #### Project Information
65
+ ### Project Info
99
66
 
100
67
  ```bash
101
68
  hazel info
102
69
  ```
103
70
 
104
- Display comprehensive information about your HazelJS project including:
105
- - Project name, version, and description
106
- - Installed HazelJS packages
107
- - Project structure
108
- - Environment details
109
- - Configuration files
71
+ Display project name, version, installed HazelJS packages, project structure, and environment details.
110
72
 
111
- #### Add Packages
73
+ ### Add Packages
112
74
 
113
75
  ```bash
114
- hazel add [package]
76
+ hazel add [package] [--setup] [--dev]
115
77
  ```
116
78
 
117
- Add HazelJS packages to your project interactively.
79
+ Install a HazelJS package and show usage hints. Use `--setup` to also generate a minimal starter file.
118
80
 
119
81
  **Examples:**
120
82
  ```bash
121
- # Interactive package selection
122
- hazel add
123
-
124
- # Add specific package
125
- hazel add ai
126
- hazel add auth
127
- hazel add prisma
83
+ hazel add # Interactive package selection
84
+ hazel add ai # Install @hazeljs/ai
85
+ hazel add auth --setup # Install @hazeljs/auth + generate auth.setup.ts
86
+ hazel add prisma --dev # Install as devDependency
128
87
  ```
129
88
 
130
- **Available packages:**
131
- - `ai` - AI Integration (@hazeljs/ai)
132
- - `agent` - AI Agents (@hazeljs/agent)
133
- - `audit` - Audit Logging (@hazeljs/audit)
134
- - `auth` - Authentication (@hazeljs/auth)
135
- - `cache` - Caching (@hazeljs/cache)
136
- - `config` - Configuration (@hazeljs/config)
137
- - `cron` - Cron Jobs (@hazeljs/cron)
138
- - `data` - Data/ETL (@hazeljs/data)
139
- - `mcp` - Model Context Protocol (@hazeljs/mcp)
140
- - `ml` - Machine Learning (@hazeljs/ml)
141
- - `prisma` - Prisma ORM (@hazeljs/prisma)
142
- - `prompts` - Typed prompt templates (@hazeljs/prompts)
143
- - `rag` - RAG/Vector Search (@hazeljs/rag)
144
- - `serverless` - Serverless (@hazeljs/serverless)
145
- - `swagger` - Swagger/OpenAPI (@hazeljs/swagger)
146
- - `typeorm` - TypeORM (@hazeljs/typeorm)
147
- - `websocket` - WebSocket (@hazeljs/websocket)
148
-
149
- #### Build Project
150
-
151
- ```bash
152
- hazel build [options]
153
- ```
154
-
155
- Build your HazelJS project.
156
-
157
- **Options:**
158
- - `-w, --watch` - Watch mode
159
- - `-p, --production` - Production build
160
-
161
- **Examples:**
162
- ```bash
163
- # Standard build
164
- hazel build
165
-
166
- # Watch mode
167
- hazel build -w
168
-
169
- # Production build
170
- hazel build -p
171
- ```
172
-
173
- #### Start Application
174
-
175
- ```bash
176
- hazel start [options]
177
- ```
178
-
179
- Start your HazelJS application.
180
-
181
- **Options:**
182
- - `-d, --dev` - Start in development mode
183
- - `-p, --port <port>` - Specify port
184
-
185
- **Examples:**
186
- ```bash
187
- # Start in production mode
188
- hazel start
189
-
190
- # Start in development mode with hot reload
191
- hazel start -d
192
-
193
- # Start on specific port
194
- hazel start -p 8080
195
- ```
196
-
197
- #### Run Tests
198
-
199
- ```bash
200
- hazel test [pattern] [options]
201
- ```
202
-
203
- Run tests for your HazelJS project.
204
-
205
- **Options:**
206
- - `-w, --watch` - Watch mode
207
- - `-c, --coverage` - Generate coverage report
208
- - `--ci` - Run in CI mode
209
-
210
- **Examples:**
211
- ```bash
212
- # Run all tests
213
- hazel test
214
-
215
- # Run specific test file
216
- hazel test user.test
217
-
218
- # Watch mode
219
- hazel test -w
220
-
221
- # Generate coverage
222
- hazel test -c
223
- ```
89
+ **Available packages:** `ai`, `agent`, `audit`, `auth`, `oauth`, `cache`, `config`, `cron`, `data`, `discovery`, `event-emitter`, `gateway`, `graphql`, `grpc`, `guardrails`, `kafka`, `mcp`, `messaging`, `ml`, `prisma`, `prompts`, `queue`, `rag`, `resilience`, `pdf-to-audio`, `serverless`, `swagger`, `typeorm`, `websocket`
224
90
 
225
91
  ### Code Generation
226
92
 
227
93
  ```bash
228
- hazel generate <component> <name> [options]
94
+ hazel g <type> <name> [--path <path>] [--dry-run] [--json]
229
95
  ```
230
96
 
231
- Or using the shorter alias:
232
-
97
+ **Discover generators:**
233
98
  ```bash
234
- hazel g <component> <name> [options]
235
- ```
236
-
237
- #### Generation options
238
-
239
- - **One pattern:** `hazel g <type> <name> [--path <path>] [--dry-run] [--json]`
240
- - **List types:** `hazel g --list` — list all generator types
241
- - **List as JSON:** `hazel g --list --list-json` — output `{ "generators": [ ... ] }`
242
- - **Result as JSON:** add `--json` to any generator to get `{ "ok", "created", "nextSteps" }` on stdout
243
- - **Stable options:** `-p, --path`, `--dry-run`, and `--json` work the same for every generator.
244
-
245
- ```bash
246
- # See what you can generate
247
- hazel g --list
248
- hazel g --list --list-json
249
-
250
- # Generate with JSON result
251
- hazel g controller users --json
252
- hazel g crud product --path src/products --json
253
-
254
- # Dry run (no files written)
255
- hazel g module orders --dry-run
99
+ hazel g --list # Human-readable list
100
+ hazel g --list --list-json # JSON output
256
101
  ```
257
102
 
258
- ### Available Generators
259
-
260
- #### Application Templates
261
- - `app` - Generate a HazelJS application. Use `hazel g app my-app --template=ai-native` for AI applications or `hazel g app my-app` for minimal template.
262
-
263
- **Available Templates:**
264
- - `ai-native` - Complete AI application with agents, RAG, PostgreSQL, Redis, and Docker
265
- - `default` - Minimal HazelJS application (like create-next-app)
266
-
267
- #### Package setup
268
- - `setup` / `st` - Generate a minimal setup starter file for a HazelJS package (e.g. `hazel g setup swagger`).
269
-
270
- #### Core Components
271
- - `controller` / `c` - Generate a new controller
272
- - `service` / `s` - Generate a new service
273
- - `module` / `m` - Generate a new module
274
- - `dto` - Generate create and update DTOs
275
- - `guard` - Generate a new guard
276
- - `interceptor` / `i` - Generate a new interceptor
277
- - `middleware` / `mw` - Generate a new middleware
278
-
279
- #### Advanced Generators
280
- - **`crud`** - Generate complete CRUD resource (controller + service + module + DTOs)
281
- - `gateway` / `ws` - Generate a WebSocket gateway
282
- - `filter` / `f` - Generate an exception filter
283
- - `pipe` / `p` - Generate a transformation pipe
284
- - `repository` / `repo` - Generate a Prisma repository
285
- - `ai-service` / `ai` - Generate an AI service with decorators
286
- - `agent` - Generate an AI agent with tools and memory
287
- - `rag-controller` - Generate a RAG controller with document ingestion and search
288
- - `tool` - Generate an AI tool for agents
289
- - `serverless` / `sls` - Generate a serverless handler (Lambda/Cloud Function)
290
-
291
- ### Generator Options
292
-
293
- - `-p, --path <path>` - Specify the path where the component should be generated (default: 'src')
103
+ **Common options** (work the same for every generator):
104
+ - `-p, --path <path>` - Where to generate (default: `src`)
294
105
  - `--dry-run` - Preview files without writing them
295
- - `--json` - Output result as JSON (created paths and next steps)
296
- - `-r, --route <route>` - Specify the route path (for CRUD generator)
297
- - `--platform <platform>` - For serverless, specify platform: `lambda` or `cloud-function` (default: 'lambda')
106
+ - `--json` - Output result as JSON (`{ ok, created, nextSteps }`)
107
+
108
+ #### Multi-File Generators
109
+
110
+ | Generator | Alias | Description | Creates |
111
+ |-----------|-------|-------------|---------|
112
+ | `crud <name>` | — | Complete CRUD resource | controller + service + module + DTOs |
113
+ | `module <name>` | `m` | Feature module | module + controller + service + DTOs |
114
+ | `dto <name>` | `d` | Create & update DTOs | two DTO files |
115
+ | `auth` | — | Auth module | JWT guard + service + controller + DTOs |
116
+
117
+ #### Single-File Generators
118
+
119
+ | Generator | Alias | Description |
120
+ |-----------|-------|-------------|
121
+ | `controller <name>` | `c` | REST controller with CRUD methods |
122
+ | `service <name>` | `s` | Injectable service class |
123
+ | `guard <name>` | `gu` | Route guard (e.g. auth) |
124
+ | `interceptor <name>` | `i` | Request/response interceptor |
125
+ | `middleware <name>` | `mw` | Express-style middleware |
126
+ | `pipe <name>` | — | Validation/transform pipe |
127
+ | `filter <name>` | `f` | Exception filter |
128
+ | `repository <name>` | `repo` | Prisma repository |
129
+ | `gateway <name>` | `ws` | WebSocket gateway |
130
+ | `ai-service <name>` | `ai` | AI service with decorators |
131
+ | `agent <name>` | — | AI agent with @Agent and @Tool |
132
+ | `cache <name>` | — | Cache service with decorators |
133
+ | `cron <name>` | `job` | Cron/scheduled job service |
134
+ | `rag <name>` | — | RAG service |
135
+ | `discovery <name>` | — | Service discovery setup |
136
+ | `config` | — | Config module setup |
137
+ | `serverless <name>` | `sls` | Serverless handler (Lambda/Cloud Function) |
138
+
139
+ **Serverless** also accepts `--platform <lambda|cloud-function>` (default: `lambda`).
298
140
 
299
141
  ### Generator Examples
300
142
 
301
- #### CRUD Generator (Recommended)
302
-
303
- Generate a complete CRUD resource with controller, service, module, and DTOs:
304
143
  ```bash
144
+ # CRUD resource (recommended for new features)
305
145
  hazel g crud user
146
+ hazel g crud product -p src/products -r /api/products
306
147
 
307
- # With custom path
308
- hazel g crud product -p src/products
309
-
310
- # With custom route
311
- hazel g crud article -r /api/articles
312
- ```
313
-
314
- This creates:
315
- - `user.controller.ts` - Full CRUD controller
316
- - `user.service.ts` - Service with all CRUD methods
317
- - `user.module.ts` - Module configuration
318
- - `dto/user.dto.ts` - Create and Update DTOs
319
-
320
- #### Core Components
321
-
322
- Generate a new user controller:
323
- ```bash
148
+ # Core components
324
149
  hazel g controller user
325
- ```
326
-
327
- Generate a new auth service in a specific path:
328
- ```bash
329
150
  hazel g service auth -p src/auth
330
- ```
331
-
332
- Generate create and update DTOs for a product:
333
- ```bash
151
+ hazel g module orders
334
152
  hazel g dto product
335
- ```
336
153
 
337
- Generate a new authentication guard:
338
- ```bash
154
+ # Infrastructure
339
155
  hazel g guard auth
340
- ```
341
-
342
- Generate a new logging interceptor:
343
- ```bash
344
156
  hazel g interceptor logging
345
- ```
346
-
347
- Generate a new middleware:
348
- ```bash
349
- hazel g middleware logging
350
- # or
351
- hazel g mw cors -p src/middleware
352
- ```
353
-
354
- #### Advanced Generators
355
-
356
- Generate a WebSocket gateway:
357
- ```bash
358
- hazel g gateway notifications
359
- # or
360
- hazel g ws notifications
361
- ```
362
-
363
- Generate an exception filter:
364
- ```bash
157
+ hazel g middleware cors -p src/middleware
365
158
  hazel g filter http-exception
366
- # or
367
- hazel g f http-exception
368
- ```
369
159
 
370
- Generate a validation pipe:
371
- ```bash
372
- hazel g pipe validation
373
- # or
374
- hazel g p validation
375
- ```
376
-
377
- Generate an AI service with decorators:
378
- ```bash
160
+ # AI components
379
161
  hazel g ai-service chat
380
- # or
381
- hazel g ai chat
382
- ```
383
-
384
- Generate an AI agent with tools and memory:
385
- ```bash
386
162
  hazel g agent support
387
- ```
388
-
389
- Generate a RAG controller with document ingestion and search:
390
- ```bash
391
- hazel g rag-controller knowledge
392
- ```
393
-
394
- Generate an AI tool for agents:
395
- ```bash
396
- hazel g tool weather
397
- ```
398
-
399
- Generate a Prisma repository:
400
- ```bash
401
- hazel g repository user
402
- # or
403
- hazel g repo user
404
- ```
163
+ hazel g rag knowledge
405
164
 
406
- Generate an AI service:
407
- ```bash
408
- hazel g ai-service chat
409
- # or
410
- hazel g ai chat
411
- ```
412
-
413
- Generate a Lambda handler:
414
- ```bash
165
+ # Serverless
415
166
  hazel g serverless handler --platform lambda
416
- # or
417
- hazel g sls handler
418
- ```
419
-
420
- Generate a Cloud Function handler:
421
- ```bash
422
- hazel g serverless handler --platform cloud-function
423
- ```
424
-
425
- ## Generated File Structure
426
-
427
- ### Controller
428
-
429
- ```typescript
430
- import { Controller, Get, Post, Put, Delete, Body, Param } from '@hazeljs/core';
431
- import { UserService } from './user.service';
432
-
433
- @Controller('/users')
434
- export class UserController {
435
- constructor(private userService: UserService) {}
436
-
437
- @Get()
438
- findAll() {
439
- return this.userService.findAll();
440
- }
441
-
442
- @Get('/:id')
443
- findOne(@Param('id') id: string) {
444
- return this.userService.findOne(id);
445
- }
446
-
447
- @Post()
448
- create(@Body() createDto: any) {
449
- return this.userService.create(createDto);
450
- }
451
-
452
- @Put('/:id')
453
- update(@Param('id') id: string, @Body() updateDto: any) {
454
- return this.userService.update(id, updateDto);
455
- }
456
-
457
- @Delete('/:id')
458
- delete(@Param('id') id: string) {
459
- return this.userService.delete(id);
460
- }
461
- }
462
- ```
463
-
464
- ### Service
465
-
466
- ```typescript
467
- import { Injectable } from '@hazeljs/core';
468
-
469
- @Injectable()
470
- export class UserService {
471
- findAll() {
472
- return [];
473
- }
474
-
475
- findOne(id: string) {
476
- return { id };
477
- }
478
-
479
- create(data: any) {
480
- return { id: '1', ...data };
481
- }
482
-
483
- update(id: string, data: any) {
484
- return { id, ...data };
485
- }
486
-
487
- delete(id: string) {
488
- return { id };
489
- }
490
- }
167
+ hazel g sls api --platform cloud-function
491
168
  ```
492
169
 
493
- ### Module
494
-
495
- ```typescript
496
- import { HazelModule } from '@hazeljs/core';
497
- import { UserController } from './user.controller';
498
- import { UserService } from './user.service';
499
-
500
- @HazelModule({
501
- controllers: [UserController],
502
- providers: [UserService],
503
- })
504
- export class UserModule {}
505
- ```
506
-
507
- ### DTO
508
-
509
- ```typescript
510
- import { IsString, IsEmail, MinLength } from 'class-validator';
511
-
512
- export class CreateUserDto {
513
- @IsEmail()
514
- email: string;
515
-
516
- @IsString()
517
- @MinLength(8)
518
- password: string;
519
-
520
- @IsString()
521
- name: string;
522
- }
523
-
524
- export class UpdateUserDto {
525
- @IsEmail()
526
- email?: string;
527
-
528
- @IsString()
529
- name?: string;
530
- }
531
- ```
532
-
533
- ## Best Practices
534
-
535
- 1. **Organize by Feature** - Group related components in feature modules
536
- 2. **Use DTOs** - Always generate and use DTOs for validation
537
- 3. **Follow Naming Conventions** - Use singular names for entities (User, not Users)
538
- 4. **Specify Paths** - Use `-p` flag to organize files properly
539
- 5. **Generate Complete Features** - Generate controller, service, module, and DTOs together
540
-
541
170
  ## Common Workflows
542
171
 
543
172
  ### Create a Complete CRUD Feature
544
173
 
545
- **Option 1: Using CRUD Generator (Recommended)**
546
174
  ```bash
547
- # Generate everything in one command
175
+ # One command generates controller, service, module, and DTOs
548
176
  hazel g crud user -p src/user
549
177
  ```
550
178
 
551
- **Option 2: Manual Generation**
552
- ```bash
553
- # Generate all components separately
554
- hazel g module user -p src/user
555
- hazel g controller user -p src/user
556
- hazel g service user -p src/user
557
- hazel g dto user -p src/user
558
- ```
559
-
560
179
  ### Create a Microservice
561
180
 
562
181
  ```bash
563
- # Create new app with interactive setup
564
- hazel new my-microservice -i
565
-
566
- # Navigate to project
567
- cd my-microservice
568
-
569
- # Generate CRUD resources
182
+ hazel new my-service -i # Interactive setup with package selection
183
+ cd my-service
570
184
  hazel g crud user
571
185
  hazel g crud product
572
- hazel g crud order
573
-
574
- # Add additional packages
575
186
  hazel add swagger
576
- hazel add auth
577
-
578
- # Start development
579
- hazel start -d
187
+ npm run dev
580
188
  ```
581
189
 
582
- ### Add WebSocket Support
190
+ ### Add AI Integration
583
191
 
584
192
  ```bash
585
- # Generate WebSocket gateway
586
- hazel g gateway chat -p src/chat
587
- hazel g service chat -p src/chat
193
+ hazel add ai --setup
194
+ hazel g ai-service assistant -p src/ai
195
+ hazel g agent support
588
196
  ```
589
197
 
590
- ### Add AI Integration
198
+ ### Add WebSocket Support
591
199
 
592
200
  ```bash
593
- # Generate AI service
594
- hazel g ai-service assistant -p src/ai
201
+ hazel g gateway chat -p src/chat
202
+ hazel g service chat -p src/chat
595
203
  ```
596
204
 
597
205
  ### Prepare for Serverless
598
206
 
599
207
  ```bash
600
- # Generate Lambda handler
601
208
  hazel g serverless handler --platform lambda
602
209
  ```
603
210
 
604
211
  ## Quick Reference
605
212
 
606
- ### All Available Commands
607
-
608
213
  ```bash
609
214
  # Project Management
610
- hazel new <name> [-i] # Create new project
611
- hazel info # Show project info
612
- hazel add [package] # Add HazelJS packages
613
- hazel build [-w] [-p] # Build project
614
- hazel start [-d] [-p <port>] # Start application
615
- hazel test [pattern] [-w] [-c] # Run tests
215
+ hazel new <name> [-i] # Create new project
216
+ hazel info # Show project info
217
+ hazel add [package] [--setup] # Add HazelJS package
616
218
 
617
219
  # Code Generation (alias: g)
618
- hazel g app <name> # Skeleton application
619
- hazel g crud <name> # Complete CRUD resource
620
- hazel g controller <name> # Controller
621
- hazel g service <name> # Service
622
- hazel g module <name> # Module
623
- hazel g middleware <name> # Middleware
624
- hazel g guard <name> # Guard
625
- hazel g interceptor <name> # Interceptor
626
- hazel g filter <name> # Exception filter
627
- hazel g pipe <name> # Pipe
628
- hazel g dto <name> # DTOs
629
- hazel g repository <name> # Prisma repository
630
- hazel g ai-service <name> # AI service
631
- hazel g gateway <name> # WebSocket gateway
632
- hazel g serverless <name> # Serverless handler
633
- ```
634
-
635
- ## Configuration
636
-
637
- Create a `.hazelrc.json` file in your project root for custom configuration:
638
-
639
- ```json
640
- {
641
- "defaultPath": "src",
642
- "typescript": true,
643
- "generateTests": true,
644
- "styleGuide": "airbnb"
645
- }
646
- ```
647
-
648
- ## Tips & Tricks
649
-
650
- ### Use Aliases
651
-
652
- ```bash
653
- # These are equivalent
654
- hazel generate controller user
655
- hazel g c user
656
-
657
- # CRUD generator is the fastest way
658
- hazel g crud user
659
- ```
660
-
661
- ### Interactive Setup
662
-
663
- ```bash
664
- # Use interactive mode for new projects
665
- hazel new my-app -i
666
-
667
- # Select packages interactively
668
- hazel add
669
- ```
670
-
671
- ### Batch Generation
672
-
673
- ```bash
674
- # Use CRUD generator instead of multiple commands
675
- hazel g crud user # Better than:
676
- # hazel g controller user && hazel g service user && hazel g module user && hazel g dto user
677
- ```
678
-
679
- ### Custom Paths
680
-
681
- ```bash
682
- # Organize by feature
683
- hazel g crud user -p src/features/user
684
- hazel g middleware logging -p src/common/middleware
220
+ hazel g app <name> # Application template
221
+ hazel g crud <name> # Complete CRUD resource
222
+ hazel g controller <name> # Controller
223
+ hazel g service <name> # Service
224
+ hazel g module <name> # Module (+ controller, service, DTOs)
225
+ hazel g guard <name> # Guard
226
+ hazel g interceptor <name> # Interceptor
227
+ hazel g middleware <name> # Middleware
228
+ hazel g filter <name> # Exception filter
229
+ hazel g pipe <name> # Pipe
230
+ hazel g dto <name> # DTOs
231
+ hazel g repository <name> # Prisma repository
232
+ hazel g ai-service <name> # AI service
233
+ hazel g agent <name> # AI agent
234
+ hazel g gateway <name> # WebSocket gateway
235
+ hazel g cache <name> # Cache service
236
+ hazel g cron <name> # Cron service
237
+ hazel g rag <name> # RAG service
238
+ hazel g discovery <name> # Service discovery
239
+ hazel g config # Config module
240
+ hazel g serverless <name> # Serverless handler
241
+ hazel g auth # Auth module
242
+ hazel g --list # List all generators
685
243
  ```
686
244
 
687
- ### Development Workflow
245
+ ## Best Practices
688
246
 
689
- ```bash
690
- # Quick development cycle
691
- hazel new my-app -i # Create with interactive setup
692
- cd my-app
693
- hazel g crud user # Generate CRUD resource
694
- hazel add swagger # Add API documentation
695
- hazel start -d # Start in dev mode
696
-
697
- # In another terminal
698
- hazel test -w # Run tests in watch mode
699
- ```
247
+ 1. **Organize by Feature** - Group related components in feature modules
248
+ 2. **Use DTOs** - Always generate and use DTOs for validation
249
+ 3. **Follow Naming Conventions** - Use singular names for entities (User, not Users)
250
+ 4. **Specify Paths** - Use `-p` flag to organize files properly
251
+ 5. **Use CRUD Generator** - For new features, `hazel g crud` is the fastest path
700
252
 
701
253
  ## Troubleshooting
702
254
 
703
255
  ### Command Not Found
704
256
 
705
- If `hazel` command is not found after global installation:
706
-
707
257
  ```bash
708
258
  # Check npm global bin path
709
259
  npm config get prefix
@@ -718,10 +268,7 @@ npm install -g @hazeljs/cli
718
268
  ### Permission Errors
719
269
 
720
270
  ```bash
721
- # Use sudo (not recommended)
722
- sudo npm install -g @hazeljs/cli
723
-
724
- # Or fix npm permissions
271
+ # Fix npm permissions (recommended)
725
272
  mkdir ~/.npm-global
726
273
  npm config set prefix '~/.npm-global'
727
274
  export PATH=~/.npm-global/bin:$PATH
@@ -729,28 +276,12 @@ export PATH=~/.npm-global/bin:$PATH
729
276
 
730
277
  ## Development
731
278
 
732
- ### Building
733
-
734
- ```bash
735
- npm run build
736
- ```
737
-
738
- ### Testing
739
-
740
279
  ```bash
741
- npm test
280
+ npm run build # Build
281
+ npm test # Run tests
282
+ npm run lint # Lint
742
283
  ```
743
284
 
744
- ### Linting
745
-
746
- ```bash
747
- npm run lint
748
- ```
749
-
750
- ## Examples
751
-
752
- See the [examples](../../example) directory for complete working examples of generated code.
753
-
754
285
  ## Contributing
755
286
 
756
287
  Contributions are welcome! Please read our [Contributing Guide](../../CONTRIBUTING.md) for details.
@@ -764,4 +295,4 @@ Apache 2.0 © [HazelJS](https://hazeljs.ai)
764
295
  - [Documentation](https://hazeljs.ai/docs/packages/cli)
765
296
  - [GitHub](https://github.com/hazel-js/hazeljs)
766
297
  - [Issues](https://github.com/hazel-js/hazeljs/issues)
767
- - [Discord](https://discord.gg/xe495BvE)
298
+ - [Discord](https://discord.com/channels/1448263814238965833/1448263814859456575)