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/commands/new.js
CHANGED
|
@@ -1,335 +1,338 @@
|
|
|
1
|
-
const { getFullModeInputs } = require("../utils/fullModeInput");
|
|
2
|
-
const { getLightModeInputs } = require("../utils/lightModeInput");
|
|
3
|
-
const { createProject } = require("../utils/setups/projectSetup");
|
|
4
|
-
const {
|
|
5
|
-
setupCleanArchitecture,
|
|
6
|
-
} = require("../utils/configs/setupCleanArchitecture");
|
|
7
|
-
const {
|
|
8
|
-
setupLightArchitecture,
|
|
9
|
-
} = require("../utils/configs/setupLightArchitecture");
|
|
10
|
-
const { setupAuth } = require("../utils/setups/setupAuth");
|
|
11
|
-
const { setupSwagger } = require("../utils/setups/setupSwagger");
|
|
12
|
-
const { setupDatabase } = require("../utils/setups/setupDatabase");
|
|
13
|
-
const { configureDocker } = require("../utils/configs/configureDocker");
|
|
14
|
-
const { setupBootstrapLogger } = require("../utils/setups/setupLogger");
|
|
15
|
-
const { logSuccess } = require("../utils/loggers/logSuccess");
|
|
16
|
-
const { logInfo } = require("../utils/loggers/logInfo");
|
|
17
|
-
const { logError } = require("../utils/loggers/logError");
|
|
18
|
-
const { generateEnvFile, writeEnvFile } = require("../utils/envGenerator");
|
|
19
|
-
const readline = require("readline-sync");
|
|
20
|
-
const { info, warning } = require("../utils/colors");
|
|
21
|
-
const { logWarning } = require("../utils/loggers/logWarning");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (flags.
|
|
67
|
-
if (flags.
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
inputs
|
|
92
|
-
inputs.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
{ name: "
|
|
159
|
-
{ name: "
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
{ name: "
|
|
233
|
-
{ name: "
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
console.log(
|
|
283
|
-
|
|
284
|
-
console.log(
|
|
285
|
-
console.log(`
|
|
286
|
-
console.log(`
|
|
287
|
-
console.log(`
|
|
288
|
-
console.log(`
|
|
289
|
-
console.log(`
|
|
290
|
-
|
|
291
|
-
console.log("
|
|
292
|
-
console.log(`
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
console.log(
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
console.log(
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
console.log("
|
|
319
|
-
console.log(
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
console.log("
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
1
|
+
const { getFullModeInputs } = require("../utils/fullModeInput");
|
|
2
|
+
const { getLightModeInputs } = require("../utils/lightModeInput");
|
|
3
|
+
const { createProject } = require("../utils/setups/projectSetup");
|
|
4
|
+
const {
|
|
5
|
+
setupCleanArchitecture,
|
|
6
|
+
} = require("../utils/configs/setupCleanArchitecture");
|
|
7
|
+
const {
|
|
8
|
+
setupLightArchitecture,
|
|
9
|
+
} = require("../utils/configs/setupLightArchitecture");
|
|
10
|
+
const { setupAuth } = require("../utils/setups/setupAuth");
|
|
11
|
+
const { setupSwagger } = require("../utils/setups/setupSwagger");
|
|
12
|
+
const { setupDatabase } = require("../utils/setups/setupDatabase");
|
|
13
|
+
const { configureDocker } = require("../utils/configs/configureDocker");
|
|
14
|
+
const { setupBootstrapLogger } = require("../utils/setups/setupLogger");
|
|
15
|
+
const { logSuccess } = require("../utils/loggers/logSuccess");
|
|
16
|
+
const { logInfo } = require("../utils/loggers/logInfo");
|
|
17
|
+
const { logError } = require("../utils/loggers/logError");
|
|
18
|
+
const { generateEnvFile, writeEnvFile } = require("../utils/envGenerator");
|
|
19
|
+
const readline = require("readline-sync");
|
|
20
|
+
const { info, warning } = require("../utils/colors");
|
|
21
|
+
const { logWarning } = require("../utils/loggers/logWarning");
|
|
22
|
+
const { saveProjectConfig } = require("../utils/file-utils/saveProjectConfig");
|
|
23
|
+
|
|
24
|
+
async function newCommand(projectName, flags = {}) {
|
|
25
|
+
if (!projectName) {
|
|
26
|
+
console.log("\n Welcome to NestCraftX CLI \n");
|
|
27
|
+
|
|
28
|
+
let currentProjectName = "";
|
|
29
|
+
let isValid = false;
|
|
30
|
+
|
|
31
|
+
currentProjectName = readline.question(
|
|
32
|
+
`${info("[?]")} Project name [my-app] : `,
|
|
33
|
+
); // Boucle de validation
|
|
34
|
+
|
|
35
|
+
while (!isValid) {
|
|
36
|
+
// La valeur est valide si elle passe la RegEx ET qu'elle n'est pas vide
|
|
37
|
+
const passesRegex = /^[A-Za-z][A-Za-z0-9_-]*$/.test(currentProjectName);
|
|
38
|
+
|
|
39
|
+
if (currentProjectName && passesRegex) {
|
|
40
|
+
isValid = true;
|
|
41
|
+
} else {
|
|
42
|
+
logWarning(
|
|
43
|
+
"Invalid or missing name. Use letters, numbers, _ or - (must start with a letter).",
|
|
44
|
+
);
|
|
45
|
+
currentProjectName = readline.question(
|
|
46
|
+
`${info("[?]")} Project name : `,
|
|
47
|
+
{ placeholder: "my-app" },
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const inputs = await getFullModeInputs(currentProjectName, flags);
|
|
53
|
+
return executeProjectSetup(inputs);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const mode = determineMode(flags);
|
|
57
|
+
const inputs =
|
|
58
|
+
mode === "light"
|
|
59
|
+
? await buildLightModeInputs(projectName, flags)
|
|
60
|
+
: await buildFullModeInputs(projectName, flags);
|
|
61
|
+
|
|
62
|
+
return executeProjectSetup(inputs);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function determineMode(flags) {
|
|
66
|
+
if (flags.light) return "light";
|
|
67
|
+
if (flags.full) return "full";
|
|
68
|
+
if (flags.mode) return flags.mode;
|
|
69
|
+
return "full";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function buildLightModeInputs(projectName, flags) {
|
|
73
|
+
const hasAllRequiredFlags = hasAllLightModeFlags(flags);
|
|
74
|
+
|
|
75
|
+
if (hasAllRequiredFlags) {
|
|
76
|
+
console.log(" LIGHT Mode - Quick configuration (via flags)\n");
|
|
77
|
+
return buildLightModeFromFlags(projectName, flags);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return getLightModeInputs(projectName, flags);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function buildFullModeInputs(projectName, flags) {
|
|
84
|
+
// 1. Tente de construire les inputs avec les flags si l'ORM est fourni (mode non-interactif)
|
|
85
|
+
if (hasAllFullModeFlags(flags)) {
|
|
86
|
+
console.log(" FULL Mode - Quick configuration (via flags)\n");
|
|
87
|
+
return buildFullModeFromFlags(projectName, flags);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 2. Sinon, utiliser la fonction interactive
|
|
91
|
+
const inputs = await getFullModeInputs(projectName, flags);
|
|
92
|
+
inputs.projectName = projectName;
|
|
93
|
+
inputs.mode = "full";
|
|
94
|
+
|
|
95
|
+
return inputs;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function hasAllLightModeFlags(flags) {
|
|
99
|
+
// Logique interne, pas de traduction nƩcessaire
|
|
100
|
+
if (!flags.interactive || flags.interactive === false) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function buildLightModeFromFlags(projectName, flags) {
|
|
107
|
+
const orm = flags.orm || "prisma";
|
|
108
|
+
const validOrms = ["prisma", "typeorm", "mongoose"];
|
|
109
|
+
|
|
110
|
+
if (!validOrms.includes(orm)) {
|
|
111
|
+
logError(`Unrecognized ORM: ${orm}. Using Prisma by default.`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const inputs = {
|
|
115
|
+
projectName,
|
|
116
|
+
mode: "light",
|
|
117
|
+
useYarn: false,
|
|
118
|
+
useDocker: flags.docker !== false,
|
|
119
|
+
useAuth: !!flags.auth,
|
|
120
|
+
useSwagger: !!flags.swagger,
|
|
121
|
+
swaggerInputs: flags.swagger
|
|
122
|
+
? {
|
|
123
|
+
title: `${projectName} API`,
|
|
124
|
+
description: "API generated by NestCraftX",
|
|
125
|
+
version: "1.0.0",
|
|
126
|
+
endpoint: "api/docs",
|
|
127
|
+
}
|
|
128
|
+
: undefined,
|
|
129
|
+
packageManager: "npm",
|
|
130
|
+
entitiesData: {
|
|
131
|
+
entities: [],
|
|
132
|
+
relations: [],
|
|
133
|
+
},
|
|
134
|
+
selectedDB: orm === "mongoose" ? "mongodb" : "postgresql",
|
|
135
|
+
dbConfig:
|
|
136
|
+
orm === "mongoose"
|
|
137
|
+
? {
|
|
138
|
+
orm: "mongoose",
|
|
139
|
+
MONGO_URI: "mongodb://localhost:27017",
|
|
140
|
+
MONGO_DB: projectName,
|
|
141
|
+
}
|
|
142
|
+
: {
|
|
143
|
+
orm: validOrms.includes(orm) ? orm : "prisma",
|
|
144
|
+
POSTGRES_USER: "postgres",
|
|
145
|
+
POSTGRES_PASSWORD: "postgres",
|
|
146
|
+
POSTGRES_DB: projectName,
|
|
147
|
+
POSTGRES_HOST: "localhost",
|
|
148
|
+
POSTGRES_PORT: "5432",
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
if (flags.auth) {
|
|
153
|
+
// š«š· Auth active : ajout automatique de l'entite User
|
|
154
|
+
logInfo("Auth active: User entity automatically added");
|
|
155
|
+
inputs.entitiesData.entities.push({
|
|
156
|
+
name: "user",
|
|
157
|
+
fields: [
|
|
158
|
+
{ name: "email", type: "string" },
|
|
159
|
+
{ name: "password", type: "string" },
|
|
160
|
+
{ name: "isActive", type: "boolean" },
|
|
161
|
+
],
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return inputs;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function hasAllFullModeFlags(flags) {
|
|
169
|
+
// Logique interne, pas de traduction nƩcessaire
|
|
170
|
+
if (!flags.interactive || flags.interactive === false) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function buildFullModeFromFlags(projectName, flags) {
|
|
177
|
+
// Logique interne, pas de traduction nƩcessaire
|
|
178
|
+
const orm = flags.orm || "prisma";
|
|
179
|
+
const validOrms = ["prisma", "typeorm", "mongoose"];
|
|
180
|
+
const finalOrm = validOrms.includes(orm) ? orm : "prisma";
|
|
181
|
+
|
|
182
|
+
const packageManager = flags.yarn ? "yarn" : "npm";
|
|
183
|
+
|
|
184
|
+
const defaultDBConfig =
|
|
185
|
+
finalOrm === "mongoose"
|
|
186
|
+
? {
|
|
187
|
+
orm: finalOrm,
|
|
188
|
+
MONGO_URI: flags.mongoUri || "mongodb://localhost:27017",
|
|
189
|
+
MONGO_DB: flags.dbName || projectName,
|
|
190
|
+
}
|
|
191
|
+
: {
|
|
192
|
+
orm: finalOrm,
|
|
193
|
+
POSTGRES_USER: flags.dbUser || "postgres",
|
|
194
|
+
POSTGRES_PASSWORD: flags.dbPassword || "postgres",
|
|
195
|
+
POSTGRES_DB: flags.dbName || projectName,
|
|
196
|
+
POSTGRES_HOST: flags.dbHost || "localhost",
|
|
197
|
+
POSTGRES_PORT: flags.dbPort || "5432",
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const useAuth = flags.auth !== false;
|
|
201
|
+
const useSwagger = flags.swagger !== false;
|
|
202
|
+
const useDocker = flags.docker !== false;
|
|
203
|
+
|
|
204
|
+
const inputs = {
|
|
205
|
+
projectName,
|
|
206
|
+
mode: "full",
|
|
207
|
+
useYarn: flags.yarn === true,
|
|
208
|
+
packageManager: packageManager,
|
|
209
|
+
useDocker: useDocker,
|
|
210
|
+
useAuth: useAuth,
|
|
211
|
+
useSwagger: useSwagger,
|
|
212
|
+
swaggerInputs: useSwagger
|
|
213
|
+
? {
|
|
214
|
+
title: flags.swaggerTitle || `${projectName} API`,
|
|
215
|
+
description: flags.swaggerDesc || "API generated by NestCraftX",
|
|
216
|
+
version: flags.swaggerVersion || "1.0.0",
|
|
217
|
+
endpoint: flags.swaggerEndpoint || "api/docs",
|
|
218
|
+
}
|
|
219
|
+
: undefined,
|
|
220
|
+
entitiesData: {
|
|
221
|
+
entities: [],
|
|
222
|
+
relations: [],
|
|
223
|
+
},
|
|
224
|
+
selectedDB: finalOrm === "mongoose" ? "mongodb" : "postgresql",
|
|
225
|
+
dbConfig: defaultDBConfig,
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
if (useAuth) {
|
|
229
|
+
inputs.entitiesData.entities.push({
|
|
230
|
+
name: "user",
|
|
231
|
+
fields: [
|
|
232
|
+
{ name: "email", type: "string" },
|
|
233
|
+
{ name: "password", type: "string" },
|
|
234
|
+
{ name: "isActive", type: "boolean" },
|
|
235
|
+
],
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return inputs;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async function executeProjectSetup(inputs) {
|
|
243
|
+
try {
|
|
244
|
+
logInfo("Starting project generation...");
|
|
245
|
+
|
|
246
|
+
await createProject(inputs);
|
|
247
|
+
|
|
248
|
+
if (inputs.mode === "light") {
|
|
249
|
+
await setupLightArchitecture(inputs);
|
|
250
|
+
} else {
|
|
251
|
+
await setupCleanArchitecture(inputs);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (inputs.useAuth) await setupAuth(inputs);
|
|
255
|
+
|
|
256
|
+
if (inputs.useSwagger) {
|
|
257
|
+
await setupSwagger(inputs.swaggerInputs);
|
|
258
|
+
} else {
|
|
259
|
+
setupBootstrapLogger();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (inputs.useDocker) await configureDocker(inputs);
|
|
263
|
+
|
|
264
|
+
await setupDatabase(inputs);
|
|
265
|
+
|
|
266
|
+
const envContent = await generateEnvFile(inputs);
|
|
267
|
+
writeEnvFile(envContent);
|
|
268
|
+
|
|
269
|
+
await saveProjectConfig(inputs);
|
|
270
|
+
|
|
271
|
+
printSuccessSummary(inputs);
|
|
272
|
+
} catch (error) {
|
|
273
|
+
// Erreur lors de la creation du projet: ${error.message}
|
|
274
|
+
logError(`Error during project creation: ${error.message}`);
|
|
275
|
+
throw error;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function printSuccessSummary(inputs) {
|
|
280
|
+
console.log("\n" + "=".repeat(60));
|
|
281
|
+
logSuccess(`Project ${inputs.projectName} created successfully!`);
|
|
282
|
+
console.log("=".repeat(60));
|
|
283
|
+
|
|
284
|
+
console.log("\nConfiguration Summary:");
|
|
285
|
+
console.log(` Project: ${inputs.projectName}`);
|
|
286
|
+
console.log(` Mode: ${inputs.mode || "full"}`.toUpperCase());
|
|
287
|
+
console.log(` Database: ${inputs.selectedDB}`);
|
|
288
|
+
console.log(` ORM: ${inputs.dbConfig.orm}`);
|
|
289
|
+
console.log(` Auth: ${inputs.useAuth ? "Yes" : "No"}`);
|
|
290
|
+
console.log(` Swagger: ${inputs.useSwagger ? "Yes" : "No"}`);
|
|
291
|
+
console.log(` Docker: ${inputs.useDocker ? "Yes" : "No"}`);
|
|
292
|
+
console.log(` Entities: ${inputs.entitiesData.entities.length}`);
|
|
293
|
+
|
|
294
|
+
console.log("\nš Next Steps:");
|
|
295
|
+
console.log(` 1. cd ${inputs.projectName}`);
|
|
296
|
+
|
|
297
|
+
// --- SPECIFIC ORM/DB INSTRUCTIONS ---
|
|
298
|
+
if (inputs.dbConfig.orm === "prisma" || inputs.dbConfig.orm === "typeorm") {
|
|
299
|
+
// Instructions for PostgreSQL (Prisma and TypeORM)
|
|
300
|
+
console.log("\n 2. Create an empty PostgreSQL database.");
|
|
301
|
+
console.log(" (Ex: `createdb " + inputs.dbConfig.POSTGRES_DB + "`)");
|
|
302
|
+
console.log(" 3. Update the .env file with your connection details.");
|
|
303
|
+
|
|
304
|
+
if (inputs.dbConfig.orm === "prisma") {
|
|
305
|
+
console.log("\n 4. **Migrations & Seed (Prisma):**");
|
|
306
|
+
console.log(` ${inputs.packageManager} prisma migrate reset`);
|
|
307
|
+
console.log(` ${inputs.packageManager} prisma migrate dev`);
|
|
308
|
+
} else {
|
|
309
|
+
// TypeORM
|
|
310
|
+
console.log("\n 4. **Migrations (TypeORM):**");
|
|
311
|
+
console.log(` - ${inputs.packageManager} run typeorm:migration:run`);
|
|
312
|
+
}
|
|
313
|
+
console.log("\n 5. Run the project:");
|
|
314
|
+
console.log(` - ${inputs.packageManager} run start:dev`);
|
|
315
|
+
} else if (inputs.dbConfig.orm === "mongoose") {
|
|
316
|
+
// Instructions for MongoDB (Mongoose)
|
|
317
|
+
console.log("\n 2. Ensure your MongoDB server is running.");
|
|
318
|
+
console.log(" 3. Update the .env file (MONGO_URI variable).");
|
|
319
|
+
console.log(" (The database will be created automatically)");
|
|
320
|
+
|
|
321
|
+
console.log("\n 4. Run the project:");
|
|
322
|
+
console.log(` - ${inputs.packageManager} run start:dev`);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// --- ENDPOINTS / SWAGGER ---
|
|
326
|
+
if (inputs.useSwagger) {
|
|
327
|
+
console.log(
|
|
328
|
+
` 6. Open Swagger UI : http://localhost:3000/${inputs.swaggerInputs.endpoint}`,
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
console.log("\nUseful commands:");
|
|
333
|
+
console.log(" - nestcraftx test Check environment");
|
|
334
|
+
console.log(" - nestcraftx info CLI information");
|
|
335
|
+
console.log(" - nestcraftx --help Complete help\n");
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
module.exports = newCommand;
|