nestcraftx 0.2.4 → 0.2.6
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.
- package/.gitattributes +6 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
- package/.github/ISSUE_TEMPLATE/pull_request_template.md +24 -0
- package/CHANGELOG.fr.md +97 -97
- package/CHANGELOG.md +98 -98
- package/CLI_USAGE.fr.md +331 -331
- package/CLI_USAGE.md +364 -364
- package/DEMO.fr.md +292 -292
- package/DEMO.md +294 -294
- package/LICENSE +21 -21
- package/MIGRATION_GUIDE.fr.md +127 -127
- package/MIGRATION_GUIDE.md +124 -124
- package/QUICK_START.fr.md +152 -152
- package/QUICK_START.md +169 -169
- package/README.fr.md +653 -659
- package/SECURITY.md +10 -0
- package/bin/nestcraft.js +84 -64
- package/commands/demo.js +333 -330
- package/commands/generate.js +93 -0
- package/commands/generateConf.js +91 -0
- package/commands/help.js +78 -78
- package/commands/info.js +48 -48
- package/commands/new.js +338 -335
- package/commands/start.js +19 -19
- package/commands/test.js +7 -7
- package/package.json +41 -41
- package/readme.md +638 -643
- package/utils/cliParser.js +133 -76
- package/utils/colors.js +62 -62
- package/utils/configs/configureDocker.js +120 -120
- package/utils/configs/setupCleanArchitecture.js +563 -557
- package/utils/configs/setupLightArchitecture.js +701 -660
- package/utils/envGenerator.js +122 -122
- package/utils/file-utils/packageJsonUtils.js +49 -55
- package/utils/file-utils/saveProjectConfig.js +36 -0
- package/utils/fullModeInput.js +607 -607
- package/utils/generators/application/dtoUpdater.js +54 -0
- package/utils/generators/cleanModuleGenerator.js +475 -0
- package/utils/generators/database/setupDatabase.js +31 -0
- package/utils/generators/domain/entityUpdater.js +78 -0
- package/utils/generators/infrastructure/mapperUpdater.js +65 -0
- package/utils/generators/lightModuleGenerator.js +131 -0
- package/utils/generators/relation/relation.engine.js +64 -0
- package/utils/interactive/askEntityInputs.js +165 -0
- package/utils/lightModeInput.js +460 -460
- package/utils/loggers/logError.js +7 -7
- package/utils/loggers/logInfo.js +7 -7
- package/utils/loggers/logSuccess.js +7 -7
- package/utils/loggers/logWarning.js +7 -7
- package/utils/setups/orms/typeOrmSetup.js +630 -630
- package/utils/setups/projectSetup.js +46 -46
- package/utils/setups/setupAuth.js +973 -926
- package/utils/setups/setupDatabase.js +75 -75
- package/utils/setups/setupLogger.js +69 -59
- package/utils/setups/setupMongoose.js +377 -432
- package/utils/setups/setupPrisma.js +802 -630
- package/utils/setups/setupSwagger.js +97 -88
- package/utils/shell.js +32 -32
- package/utils/spinner.js +57 -57
- package/utils/systemCheck.js +124 -124
- package/utils/userInput.js +421 -421
- package/utils/utils.js +2197 -1762
package/CLI_USAGE.md
CHANGED
|
@@ -1,364 +1,364 @@
|
|
|
1
|
-
# NestCraftX CLI - User Guide
|
|
2
|
-
|
|
3
|
-
## Installation
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
npm install -g nestcraftx
|
|
7
|
-
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
## Available Commands
|
|
11
|
-
|
|
12
|
-
### Create a new project
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
nestcraftx new <project-name> [options]
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Generation Modes
|
|
20
|
-
|
|
21
|
-
### FULL Mode (Complete Architecture - Clean Architecture + DDD)
|
|
22
|
-
|
|
23
|
-
Complete structure with use-cases, mappers, adapters, and strict layer separation.
|
|
24
|
-
Ideal for complex and scalable projects.
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
nestcraftx new my-project --full
|
|
28
|
-
nestcraftx new my-project --mode=full
|
|
29
|
-
nestcraftx new my-project
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Generated Structure:**
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
src
|
|
37
|
-
├── [entity]
|
|
38
|
-
│ ├── application
|
|
39
|
-
│ │ ├── dtos
|
|
40
|
-
│ │ ├── services
|
|
41
|
-
│ │ ├── use-cases
|
|
42
|
-
│ │ └── interfaces
|
|
43
|
-
│ │
|
|
44
|
-
│ ├── domain
|
|
45
|
-
│ │ ├── entities
|
|
46
|
-
│ │ ├── enums
|
|
47
|
-
│ │ └── interfaces
|
|
48
|
-
│ │
|
|
49
|
-
│ ├── infrastructure
|
|
50
|
-
│ │ ├── adapters
|
|
51
|
-
│ │ ├── mappers
|
|
52
|
-
│ │ ├── repositories
|
|
53
|
-
│ │ └── services
|
|
54
|
-
│ │
|
|
55
|
-
│ ├── presentation
|
|
56
|
-
│ │ └── controllers
|
|
57
|
-
│ │
|
|
58
|
-
│ └── [entity].module.ts
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### LIGHT Mode (Simplified MVP)
|
|
63
|
-
|
|
64
|
-
Flat structure with fewer abstraction layers.
|
|
65
|
-
Perfect for prototypes and small projects.
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
nestcraftx new my-project --light
|
|
69
|
-
nestcraftx new my-project --mode=light
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
**Generated Structure:**
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
src
|
|
77
|
-
├── [entity]
|
|
78
|
-
│ ├── entities
|
|
79
|
-
│ ├── dto
|
|
80
|
-
│ ├── services
|
|
81
|
-
│ ├── repositories
|
|
82
|
-
│ ├── controllers
|
|
83
|
-
│ └── [entity].module.ts
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## Available Options
|
|
90
|
-
|
|
91
|
-
### ORM
|
|
92
|
-
|
|
93
|
-
Choose which ORM to use:
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
--orm=prisma # Prisma (default)
|
|
97
|
-
--orm=typeorm # TypeORM
|
|
98
|
-
--orm=mongoose # Mongoose (MongoDB - beta phase)
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**Examples:**
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
nestcraftx new my-api --light --orm=prisma
|
|
106
|
-
nestcraftx new my-api --full --orm=typeorm
|
|
107
|
-
nestcraftx new my-api --orm=mongoose
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Authentication
|
|
112
|
-
|
|
113
|
-
Enable JWT authentication:
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
--auth # Enables JWT auth
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
**Example:**
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
nestcraftx new my-api --light --auth --orm=prisma
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
With `--auth`, a User entity is automatically generated with:
|
|
128
|
-
|
|
129
|
-
- email (string)
|
|
130
|
-
- password (string)
|
|
131
|
-
- isActive (boolean)
|
|
132
|
-
|
|
133
|
-
### Swagger
|
|
134
|
-
|
|
135
|
-
Enable Swagger/OpenAPI documentation:
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
--swagger # Enables Swagger UI
|
|
139
|
-
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**Example:**
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
nestcraftx new my-api --light --swagger
|
|
146
|
-
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Swagger will be accessible at: `http://localhost:3000/api/docs`
|
|
150
|
-
|
|
151
|
-
### Docker
|
|
152
|
-
|
|
153
|
-
Disable Docker (enabled by default):
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
--docker=false # Disables Docker
|
|
157
|
-
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
**Example:**
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
nestcraftx new my-api --light --docker=false
|
|
164
|
-
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
---
|
|
168
|
-
|
|
169
|
-
## Full Command Examples
|
|
170
|
-
|
|
171
|
-
### LIGHT Project with all options
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
nestcraftx new my-api --light --orm=prisma --auth --swagger
|
|
175
|
-
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### FULL Project with TypeORM and Auth
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
nestcraftx new my-api --full --orm=typeorm --auth
|
|
182
|
-
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### Minimal LIGHT Project (interactive mode)
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
nestcraftx new my-api --light
|
|
189
|
-
# The CLI will prompt for all necessary options
|
|
190
|
-
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### MongoDB Project with Mongoose
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
nestcraftx new my-api --light --orm=mongoose --auth --swagger
|
|
197
|
-
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
---
|
|
201
|
-
|
|
202
|
-
## Automatic Configuration
|
|
203
|
-
|
|
204
|
-
### Generated .env file
|
|
205
|
-
|
|
206
|
-
The CLI automatically generates a `.env` file with:
|
|
207
|
-
|
|
208
|
-
**For PostgreSQL (Prisma/TypeORM):**
|
|
209
|
-
|
|
210
|
-
```env
|
|
211
|
-
NODE_ENV=development
|
|
212
|
-
PORT=3000
|
|
213
|
-
JWT_SECRET=<auto-generated-64-chars>
|
|
214
|
-
JWT_REFRESH_SECRET=<auto-generated-64-chars>
|
|
215
|
-
JWT_EXPIRES_IN=15m
|
|
216
|
-
JWT_REFRESH_EXPIRES_IN=7d
|
|
217
|
-
POSTGRES_USER=postgres
|
|
218
|
-
POSTGRES_PASSWORD=postgres
|
|
219
|
-
POSTGRES_DB=my-api
|
|
220
|
-
POSTGRES_HOST=localhost
|
|
221
|
-
POSTGRES_PORT=5432
|
|
222
|
-
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/my-api?schema=public
|
|
223
|
-
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
**For MongoDB (Mongoose):**
|
|
227
|
-
|
|
228
|
-
```env
|
|
229
|
-
NODE_ENV=development
|
|
230
|
-
PORT=3000
|
|
231
|
-
JWT_SECRET=<auto-generated-64-chars>
|
|
232
|
-
JWT_REFRESH_SECRET=<auto-generated-64-chars>
|
|
233
|
-
JWT_EXPIRES_IN=15m
|
|
234
|
-
JWT_REFRESH_EXPIRES_IN=7d
|
|
235
|
-
MONGO_URI=mongodb://localhost:27017
|
|
236
|
-
MONGO_DB=my-api
|
|
237
|
-
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
JWT secrets are automatically generated in a secure manner.
|
|
241
|
-
|
|
242
|
-
---
|
|
243
|
-
|
|
244
|
-
## Interactive Modes
|
|
245
|
-
|
|
246
|
-
### Interactive LIGHT Mode
|
|
247
|
-
|
|
248
|
-
If you don't provide all necessary flags, the CLI will enter interactive mode to ask for missing options.
|
|
249
|
-
|
|
250
|
-
**Example:**
|
|
251
|
-
|
|
252
|
-
```bash
|
|
253
|
-
nestcraftx new my-api --light
|
|
254
|
-
|
|
255
|
-
[LIGHT MODE] Simplified configuration for my-api
|
|
256
|
-
|
|
257
|
-
[?] Choose an ORM (prisma, typeorm, mongoose) [prisma]: prisma
|
|
258
|
-
[?] Enable JWT authentication? (Y/n): y
|
|
259
|
-
[INFO] Auth enabled: automatically adding User entity
|
|
260
|
-
[?] Enable Swagger for API documentation? (Y/n): y
|
|
261
|
-
[?] Generate Docker files? (Y/n): y
|
|
262
|
-
|
|
263
|
-
[INFO] PostgreSQL Configuration
|
|
264
|
-
PostgreSQL User [postgres]:
|
|
265
|
-
PostgreSQL Password [postgres]:
|
|
266
|
-
Database Name [my-api]:
|
|
267
|
-
PostgreSQL Host [localhost]:
|
|
268
|
-
PostgreSQL Port [5432]:
|
|
269
|
-
|
|
270
|
-
[?] Do you want to add additional entities? (Y/n): n
|
|
271
|
-
|
|
272
|
-
[INFO] Starting project generation...
|
|
273
|
-
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
### Interactive FULL Mode
|
|
277
|
-
|
|
278
|
-
The FULL mode is always interactive to give you total control over the configuration.
|
|
279
|
-
|
|
280
|
-
**Example:**
|
|
281
|
-
|
|
282
|
-
```bash
|
|
283
|
-
nestcraftx new my-project
|
|
284
|
-
|
|
285
|
-
[FULL MODE] Complete configuration with Clean Architecture
|
|
286
|
-
|
|
287
|
-
[?] Project name: my-project
|
|
288
|
-
[?] Database (postgresql, mongodb) [postgresql]: postgresql
|
|
289
|
-
|
|
290
|
-
[INFO] PostgreSQL Configuration
|
|
291
|
-
PostgreSQL User [postgres]:
|
|
292
|
-
PostgreSQL Password [postgres]:
|
|
293
|
-
...
|
|
294
|
-
|
|
295
|
-
[?] ORM for PostgreSQL (prisma, typeorm) [prisma]: prisma
|
|
296
|
-
[?] Use Yarn? (Y/n): n
|
|
297
|
-
[?] Generate Docker files? (Y/n): y
|
|
298
|
-
[?] Add JWT authentication? (Y/n): y
|
|
299
|
-
[?] Install Swagger? (Y/n): y
|
|
300
|
-
|
|
301
|
-
[INFO] Swagger Configuration
|
|
302
|
-
API Title [my-project API]:
|
|
303
|
-
Description [API generated by NestCraftX]:
|
|
304
|
-
Version [1.0.0]:
|
|
305
|
-
Endpoint [api/docs]:
|
|
306
|
-
|
|
307
|
-
[INFO] Entity Input (FULL Mode - Complete Architecture)
|
|
308
|
-
[?] Add an entity? (Y/n): y
|
|
309
|
-
Entity name: post
|
|
310
|
-
Fields for "post":
|
|
311
|
-
Field name (empty to finish): title
|
|
312
|
-
Type for "title" (string, number, boolean, Date, enum): string
|
|
313
|
-
Field name (empty to finish): content
|
|
314
|
-
Type for "content" (string, number, boolean, Date, enum): string
|
|
315
|
-
Field name (empty to finish):
|
|
316
|
-
|
|
317
|
-
[✓] Entity "post" added with 2 field(s)
|
|
318
|
-
[?] Add another entity? (Y/n): n
|
|
319
|
-
[?] Add relationships between entities? (Y/n): n
|
|
320
|
-
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
---
|
|
324
|
-
|
|
325
|
-
## After Creation
|
|
326
|
-
|
|
327
|
-
```bash
|
|
328
|
-
cd my-project
|
|
329
|
-
npm run start:dev
|
|
330
|
-
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
If Swagger is enabled:
|
|
334
|
-
`http://localhost:3000/api/docs`
|
|
335
|
-
|
|
336
|
-
## Other Commands
|
|
337
|
-
|
|
338
|
-
### Check environment
|
|
339
|
-
|
|
340
|
-
```bash
|
|
341
|
-
nestcraftx test
|
|
342
|
-
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
### CLI Information
|
|
346
|
-
|
|
347
|
-
```bash
|
|
348
|
-
nestcraftx info
|
|
349
|
-
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
### Help
|
|
353
|
-
|
|
354
|
-
```bash
|
|
355
|
-
nestcraftx --help
|
|
356
|
-
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
## Important Notes
|
|
360
|
-
|
|
361
|
-
- JWT secrets are securely auto-generated (64 characters).
|
|
362
|
-
- `DATABASE_URL` is automatically built based on the chosen ORM.
|
|
363
|
-
- Docker is enabled by default in LIGHT mode.
|
|
364
|
-
- FULL mode requires interactive configuration if no options are provided.
|
|
1
|
+
# NestCraftX CLI - User Guide
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g nestcraftx
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Available Commands
|
|
11
|
+
|
|
12
|
+
### Create a new project
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
nestcraftx new <project-name> [options]
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Generation Modes
|
|
20
|
+
|
|
21
|
+
### FULL Mode (Complete Architecture - Clean Architecture + DDD)
|
|
22
|
+
|
|
23
|
+
Complete structure with use-cases, mappers, adapters, and strict layer separation.
|
|
24
|
+
Ideal for complex and scalable projects.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
nestcraftx new my-project --full
|
|
28
|
+
nestcraftx new my-project --mode=full
|
|
29
|
+
nestcraftx new my-project
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Generated Structure:**
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
src
|
|
37
|
+
├── [entity]
|
|
38
|
+
│ ├── application
|
|
39
|
+
│ │ ├── dtos
|
|
40
|
+
│ │ ├── services
|
|
41
|
+
│ │ ├── use-cases
|
|
42
|
+
│ │ └── interfaces
|
|
43
|
+
│ │
|
|
44
|
+
│ ├── domain
|
|
45
|
+
│ │ ├── entities
|
|
46
|
+
│ │ ├── enums
|
|
47
|
+
│ │ └── interfaces
|
|
48
|
+
│ │
|
|
49
|
+
│ ├── infrastructure
|
|
50
|
+
│ │ ├── adapters
|
|
51
|
+
│ │ ├── mappers
|
|
52
|
+
│ │ ├── repositories
|
|
53
|
+
│ │ └── services
|
|
54
|
+
│ │
|
|
55
|
+
│ ├── presentation
|
|
56
|
+
│ │ └── controllers
|
|
57
|
+
│ │
|
|
58
|
+
│ └── [entity].module.ts
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### LIGHT Mode (Simplified MVP)
|
|
63
|
+
|
|
64
|
+
Flat structure with fewer abstraction layers.
|
|
65
|
+
Perfect for prototypes and small projects.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
nestcraftx new my-project --light
|
|
69
|
+
nestcraftx new my-project --mode=light
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Generated Structure:**
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
src
|
|
77
|
+
├── [entity]
|
|
78
|
+
│ ├── entities
|
|
79
|
+
│ ├── dto
|
|
80
|
+
│ ├── services
|
|
81
|
+
│ ├── repositories
|
|
82
|
+
│ ├── controllers
|
|
83
|
+
│ └── [entity].module.ts
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Available Options
|
|
90
|
+
|
|
91
|
+
### ORM
|
|
92
|
+
|
|
93
|
+
Choose which ORM to use:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
--orm=prisma # Prisma (default)
|
|
97
|
+
--orm=typeorm # TypeORM
|
|
98
|
+
--orm=mongoose # Mongoose (MongoDB - beta phase)
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Examples:**
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
nestcraftx new my-api --light --orm=prisma
|
|
106
|
+
nestcraftx new my-api --full --orm=typeorm
|
|
107
|
+
nestcraftx new my-api --orm=mongoose
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Authentication
|
|
112
|
+
|
|
113
|
+
Enable JWT authentication:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
--auth # Enables JWT auth
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Example:**
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
nestcraftx new my-api --light --auth --orm=prisma
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
With `--auth`, a User entity is automatically generated with:
|
|
128
|
+
|
|
129
|
+
- email (string)
|
|
130
|
+
- password (string)
|
|
131
|
+
- isActive (boolean)
|
|
132
|
+
|
|
133
|
+
### Swagger
|
|
134
|
+
|
|
135
|
+
Enable Swagger/OpenAPI documentation:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
--swagger # Enables Swagger UI
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Example:**
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
nestcraftx new my-api --light --swagger
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Swagger will be accessible at: `http://localhost:3000/api/docs`
|
|
150
|
+
|
|
151
|
+
### Docker
|
|
152
|
+
|
|
153
|
+
Disable Docker (enabled by default):
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
--docker=false # Disables Docker
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Example:**
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
nestcraftx new my-api --light --docker=false
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Full Command Examples
|
|
170
|
+
|
|
171
|
+
### LIGHT Project with all options
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
nestcraftx new my-api --light --orm=prisma --auth --swagger
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### FULL Project with TypeORM and Auth
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
nestcraftx new my-api --full --orm=typeorm --auth
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Minimal LIGHT Project (interactive mode)
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
nestcraftx new my-api --light
|
|
189
|
+
# The CLI will prompt for all necessary options
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### MongoDB Project with Mongoose
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
nestcraftx new my-api --light --orm=mongoose --auth --swagger
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Automatic Configuration
|
|
203
|
+
|
|
204
|
+
### Generated .env file
|
|
205
|
+
|
|
206
|
+
The CLI automatically generates a `.env` file with:
|
|
207
|
+
|
|
208
|
+
**For PostgreSQL (Prisma/TypeORM):**
|
|
209
|
+
|
|
210
|
+
```env
|
|
211
|
+
NODE_ENV=development
|
|
212
|
+
PORT=3000
|
|
213
|
+
JWT_SECRET=<auto-generated-64-chars>
|
|
214
|
+
JWT_REFRESH_SECRET=<auto-generated-64-chars>
|
|
215
|
+
JWT_EXPIRES_IN=15m
|
|
216
|
+
JWT_REFRESH_EXPIRES_IN=7d
|
|
217
|
+
POSTGRES_USER=postgres
|
|
218
|
+
POSTGRES_PASSWORD=postgres
|
|
219
|
+
POSTGRES_DB=my-api
|
|
220
|
+
POSTGRES_HOST=localhost
|
|
221
|
+
POSTGRES_PORT=5432
|
|
222
|
+
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/my-api?schema=public
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**For MongoDB (Mongoose):**
|
|
227
|
+
|
|
228
|
+
```env
|
|
229
|
+
NODE_ENV=development
|
|
230
|
+
PORT=3000
|
|
231
|
+
JWT_SECRET=<auto-generated-64-chars>
|
|
232
|
+
JWT_REFRESH_SECRET=<auto-generated-64-chars>
|
|
233
|
+
JWT_EXPIRES_IN=15m
|
|
234
|
+
JWT_REFRESH_EXPIRES_IN=7d
|
|
235
|
+
MONGO_URI=mongodb://localhost:27017
|
|
236
|
+
MONGO_DB=my-api
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
JWT secrets are automatically generated in a secure manner.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Interactive Modes
|
|
245
|
+
|
|
246
|
+
### Interactive LIGHT Mode
|
|
247
|
+
|
|
248
|
+
If you don't provide all necessary flags, the CLI will enter interactive mode to ask for missing options.
|
|
249
|
+
|
|
250
|
+
**Example:**
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
nestcraftx new my-api --light
|
|
254
|
+
|
|
255
|
+
[LIGHT MODE] Simplified configuration for my-api
|
|
256
|
+
|
|
257
|
+
[?] Choose an ORM (prisma, typeorm, mongoose) [prisma]: prisma
|
|
258
|
+
[?] Enable JWT authentication? (Y/n): y
|
|
259
|
+
[INFO] Auth enabled: automatically adding User entity
|
|
260
|
+
[?] Enable Swagger for API documentation? (Y/n): y
|
|
261
|
+
[?] Generate Docker files? (Y/n): y
|
|
262
|
+
|
|
263
|
+
[INFO] PostgreSQL Configuration
|
|
264
|
+
PostgreSQL User [postgres]:
|
|
265
|
+
PostgreSQL Password [postgres]:
|
|
266
|
+
Database Name [my-api]:
|
|
267
|
+
PostgreSQL Host [localhost]:
|
|
268
|
+
PostgreSQL Port [5432]:
|
|
269
|
+
|
|
270
|
+
[?] Do you want to add additional entities? (Y/n): n
|
|
271
|
+
|
|
272
|
+
[INFO] Starting project generation...
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Interactive FULL Mode
|
|
277
|
+
|
|
278
|
+
The FULL mode is always interactive to give you total control over the configuration.
|
|
279
|
+
|
|
280
|
+
**Example:**
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
nestcraftx new my-project
|
|
284
|
+
|
|
285
|
+
[FULL MODE] Complete configuration with Clean Architecture
|
|
286
|
+
|
|
287
|
+
[?] Project name: my-project
|
|
288
|
+
[?] Database (postgresql, mongodb) [postgresql]: postgresql
|
|
289
|
+
|
|
290
|
+
[INFO] PostgreSQL Configuration
|
|
291
|
+
PostgreSQL User [postgres]:
|
|
292
|
+
PostgreSQL Password [postgres]:
|
|
293
|
+
...
|
|
294
|
+
|
|
295
|
+
[?] ORM for PostgreSQL (prisma, typeorm) [prisma]: prisma
|
|
296
|
+
[?] Use Yarn? (Y/n): n
|
|
297
|
+
[?] Generate Docker files? (Y/n): y
|
|
298
|
+
[?] Add JWT authentication? (Y/n): y
|
|
299
|
+
[?] Install Swagger? (Y/n): y
|
|
300
|
+
|
|
301
|
+
[INFO] Swagger Configuration
|
|
302
|
+
API Title [my-project API]:
|
|
303
|
+
Description [API generated by NestCraftX]:
|
|
304
|
+
Version [1.0.0]:
|
|
305
|
+
Endpoint [api/docs]:
|
|
306
|
+
|
|
307
|
+
[INFO] Entity Input (FULL Mode - Complete Architecture)
|
|
308
|
+
[?] Add an entity? (Y/n): y
|
|
309
|
+
Entity name: post
|
|
310
|
+
Fields for "post":
|
|
311
|
+
Field name (empty to finish): title
|
|
312
|
+
Type for "title" (string, number, boolean, Date, enum): string
|
|
313
|
+
Field name (empty to finish): content
|
|
314
|
+
Type for "content" (string, number, boolean, Date, enum): string
|
|
315
|
+
Field name (empty to finish):
|
|
316
|
+
|
|
317
|
+
[✓] Entity "post" added with 2 field(s)
|
|
318
|
+
[?] Add another entity? (Y/n): n
|
|
319
|
+
[?] Add relationships between entities? (Y/n): n
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## After Creation
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
cd my-project
|
|
329
|
+
npm run start:dev
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
If Swagger is enabled:
|
|
334
|
+
`http://localhost:3000/api/docs`
|
|
335
|
+
|
|
336
|
+
## Other Commands
|
|
337
|
+
|
|
338
|
+
### Check environment
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
nestcraftx test
|
|
342
|
+
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### CLI Information
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
nestcraftx info
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Help
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
nestcraftx --help
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## Important Notes
|
|
360
|
+
|
|
361
|
+
- JWT secrets are securely auto-generated (64 characters).
|
|
362
|
+
- `DATABASE_URL` is automatically built based on the chosen ORM.
|
|
363
|
+
- Docker is enabled by default in LIGHT mode.
|
|
364
|
+
- FULL mode requires interactive configuration if no options are provided.
|