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.
Files changed (63) hide show
  1. package/.gitattributes +6 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
  4. package/.github/ISSUE_TEMPLATE/pull_request_template.md +24 -0
  5. package/CHANGELOG.fr.md +97 -97
  6. package/CHANGELOG.md +98 -98
  7. package/CLI_USAGE.fr.md +331 -331
  8. package/CLI_USAGE.md +364 -364
  9. package/DEMO.fr.md +292 -292
  10. package/DEMO.md +294 -294
  11. package/LICENSE +21 -21
  12. package/MIGRATION_GUIDE.fr.md +127 -127
  13. package/MIGRATION_GUIDE.md +124 -124
  14. package/QUICK_START.fr.md +152 -152
  15. package/QUICK_START.md +169 -169
  16. package/README.fr.md +653 -659
  17. package/SECURITY.md +10 -0
  18. package/bin/nestcraft.js +84 -64
  19. package/commands/demo.js +333 -330
  20. package/commands/generate.js +93 -0
  21. package/commands/generateConf.js +91 -0
  22. package/commands/help.js +78 -78
  23. package/commands/info.js +48 -48
  24. package/commands/new.js +338 -335
  25. package/commands/start.js +19 -19
  26. package/commands/test.js +7 -7
  27. package/package.json +41 -41
  28. package/readme.md +638 -643
  29. package/utils/cliParser.js +133 -76
  30. package/utils/colors.js +62 -62
  31. package/utils/configs/configureDocker.js +120 -120
  32. package/utils/configs/setupCleanArchitecture.js +563 -557
  33. package/utils/configs/setupLightArchitecture.js +701 -660
  34. package/utils/envGenerator.js +122 -122
  35. package/utils/file-utils/packageJsonUtils.js +49 -55
  36. package/utils/file-utils/saveProjectConfig.js +36 -0
  37. package/utils/fullModeInput.js +607 -607
  38. package/utils/generators/application/dtoUpdater.js +54 -0
  39. package/utils/generators/cleanModuleGenerator.js +475 -0
  40. package/utils/generators/database/setupDatabase.js +31 -0
  41. package/utils/generators/domain/entityUpdater.js +78 -0
  42. package/utils/generators/infrastructure/mapperUpdater.js +65 -0
  43. package/utils/generators/lightModuleGenerator.js +131 -0
  44. package/utils/generators/relation/relation.engine.js +64 -0
  45. package/utils/interactive/askEntityInputs.js +165 -0
  46. package/utils/lightModeInput.js +460 -460
  47. package/utils/loggers/logError.js +7 -7
  48. package/utils/loggers/logInfo.js +7 -7
  49. package/utils/loggers/logSuccess.js +7 -7
  50. package/utils/loggers/logWarning.js +7 -7
  51. package/utils/setups/orms/typeOrmSetup.js +630 -630
  52. package/utils/setups/projectSetup.js +46 -46
  53. package/utils/setups/setupAuth.js +973 -926
  54. package/utils/setups/setupDatabase.js +75 -75
  55. package/utils/setups/setupLogger.js +69 -59
  56. package/utils/setups/setupMongoose.js +377 -432
  57. package/utils/setups/setupPrisma.js +802 -630
  58. package/utils/setups/setupSwagger.js +97 -88
  59. package/utils/shell.js +32 -32
  60. package/utils/spinner.js +57 -57
  61. package/utils/systemCheck.js +124 -124
  62. package/utils/userInput.js +421 -421
  63. package/utils/utils.js +2197 -1762
@@ -1,75 +1,75 @@
1
- const { logInfo } = require("../loggers/logInfo");
2
- const { runCommand } = require("../shell");
3
- const { setupTypeORM } = require("./orms/typeOrmSetup");
4
- const { setupMongoose } = require("./setupMongoose");
5
- const { setupPrisma } = require("./setupPrisma");
6
-
7
- async function setupDatabase(inputs) {
8
- logInfo("🚀 Configuring the database...");
9
-
10
- await runCommand(
11
- "npm install dotenv",
12
- "Error installing dotenv automatically, please run it manually now"
13
- );
14
-
15
- switch (inputs.selectedDB) {
16
- case "postgresql":
17
- await setupPostgres(inputs); // PostgreSQL Configuration
18
- break;
19
- case "mysql":
20
- await setupMySQL(inputs); // MySQL Configuration
21
- break;
22
- case "mongodb":
23
- await setupMongoDB(inputs); // MongoDB Configuration
24
- break;
25
- case "sqlite":
26
- await setupSQLite(inputs); // SQLite Configuration
27
- break;
28
- case "firebase":
29
- await setupFirebase(inputs); // Firebase Configuration
30
- break;
31
- case "redis":
32
- await setupRedis(inputs); // Redis Configuration
33
- break;
34
- default:
35
- throw new Error("Unsupported database.");
36
- }
37
- }
38
-
39
- async function setupMongoDB(inputs) {
40
- logInfo("Configuring MongoDB...");
41
- await setupMongoose(inputs);
42
- }
43
-
44
- async function setupSQLite(inputs) {
45
- logInfo("Configuring SQLite..."); // Calls a SQLite-specific script
46
- await setupSQLiteConfig(inputs);
47
- }
48
-
49
- async function setupMySQL(inputs) {
50
- logInfo("Configuring MySQL..."); // Calls a MySQL-specific script
51
- await setupMySQLConfig(inputs);
52
- }
53
-
54
- async function setupFirebase(inputs) {
55
- logInfo("Configuring Firebase..."); // Calls a Firebase-specific script
56
- await setupFirebaseConfig(inputs);
57
- }
58
-
59
- async function setupPostgres(inputs) {
60
- // Checks which ORM was chosen and calls the corresponding function
61
- if (inputs.dbConfig.orm === "prisma") {
62
- await setupPrisma(inputs);
63
- } else if (inputs.dbConfig.orm === "typeorm") {
64
- await setupTypeORM(inputs);
65
- } else {
66
- throw new Error("Unsupported ORM: " + inputs.dbConfig.orm);
67
- }
68
- }
69
-
70
- async function setupRedis(inputs) {
71
- logInfo("Configuring Redis..."); // Calls a Redis-specific script
72
- await setupRedisConfig(inputs);
73
- }
74
-
75
- module.exports = { setupDatabase };
1
+ const { logInfo } = require("../loggers/logInfo");
2
+ const { runCommand } = require("../shell");
3
+ const { setupTypeORM } = require("./orms/typeOrmSetup");
4
+ const { setupMongoose } = require("./setupMongoose");
5
+ const { setupPrisma } = require("./setupPrisma");
6
+
7
+ async function setupDatabase(inputs) {
8
+ logInfo("🚀 Configuring the database...");
9
+
10
+ await runCommand(
11
+ "npm install dotenv",
12
+ "Error installing dotenv automatically, please run it manually now"
13
+ );
14
+
15
+ switch (inputs.selectedDB) {
16
+ case "postgresql":
17
+ await setupPostgres(inputs); // PostgreSQL Configuration
18
+ break;
19
+ case "mysql":
20
+ await setupMySQL(inputs); // MySQL Configuration
21
+ break;
22
+ case "mongodb":
23
+ await setupMongoDB(inputs); // MongoDB Configuration
24
+ break;
25
+ case "sqlite":
26
+ await setupSQLite(inputs); // SQLite Configuration
27
+ break;
28
+ case "firebase":
29
+ await setupFirebase(inputs); // Firebase Configuration
30
+ break;
31
+ case "redis":
32
+ await setupRedis(inputs); // Redis Configuration
33
+ break;
34
+ default:
35
+ throw new Error("Unsupported database.");
36
+ }
37
+ }
38
+
39
+ async function setupMongoDB(inputs) {
40
+ logInfo("Configuring MongoDB...");
41
+ await setupMongoose(inputs);
42
+ }
43
+
44
+ async function setupSQLite(inputs) {
45
+ logInfo("Configuring SQLite..."); // Calls a SQLite-specific script
46
+ await setupSQLiteConfig(inputs);
47
+ }
48
+
49
+ async function setupMySQL(inputs) {
50
+ logInfo("Configuring MySQL..."); // Calls a MySQL-specific script
51
+ await setupMySQLConfig(inputs);
52
+ }
53
+
54
+ async function setupFirebase(inputs) {
55
+ logInfo("Configuring Firebase..."); // Calls a Firebase-specific script
56
+ await setupFirebaseConfig(inputs);
57
+ }
58
+
59
+ async function setupPostgres(inputs) {
60
+ // Checks which ORM was chosen and calls the corresponding function
61
+ if (inputs.dbConfig.orm === "prisma") {
62
+ await setupPrisma(inputs);
63
+ } else if (inputs.dbConfig.orm === "typeorm") {
64
+ await setupTypeORM(inputs);
65
+ } else {
66
+ throw new Error("Unsupported ORM: " + inputs.dbConfig.orm);
67
+ }
68
+ }
69
+
70
+ async function setupRedis(inputs) {
71
+ logInfo("Configuring Redis..."); // Calls a Redis-specific script
72
+ await setupRedisConfig(inputs);
73
+ }
74
+
75
+ module.exports = { setupDatabase };
@@ -1,59 +1,69 @@
1
- const fs = require("fs");
2
- const { updateFile } = require("../userInput");
3
-
4
- async function setupBootstrapLogger() {
5
- // Modification de main.ts pour intégrer Swagger
6
- const mainTsPath = "src/main.ts";
7
- let mainTs = fs.readFileSync(mainTsPath, "utf8");
8
-
9
- if (!mainTs.includes("await app.listen")) return mainTs;
10
-
11
- // Injecte les imports si non présents
12
- await updateFile({
13
- path: mainTsPath,
14
- pattern: "import { ValidationPipe } from '@nestjs/common';",
15
- replacement: `import { Logger, ValidationPipe } from '@nestjs/common';`,
16
- });
17
- /* if (!mainTs.includes("Logger")) {
18
- } */
19
-
20
- if (!mainTs.includes("ConfigService")) {
21
- await updateFile({
22
- path: mainTsPath,
23
- pattern: "import { NestFactory } from '@nestjs/core';",
24
- replacement: `import { NestFactory } from '@nestjs/core';
25
- import { ConfigService } from '@nestjs/config';`,
26
- });
27
- }
28
-
29
- // Injecte la récupération des variables
30
- if (!mainTs.includes("const host = configService.get<string>('HOST'")) {
31
- await updateFile({
32
- path: mainTsPath,
33
- pattern: "const app = await NestFactory.create(AppModule);",
34
- replacement: `const app = await NestFactory.create(AppModule);
35
- const configService = app.get(ConfigService);
36
- const port = configService.get<number>('PORT', 3000);
37
- const host = configService.get<string>('HOST', '0.0.0.0');`,
38
- });
39
- }
40
-
41
- // Remplace le démarrage de l'app par le bloc stylisé
42
- return await updateFile({
43
- path: mainTsPath,
44
- pattern: "await app.listen(process.env.PORT ?? 3000);",
45
- replacement: `try {
46
- await app.listen(port, host);
47
-
48
- const logger = new Logger('Bootstrap');
49
- logger.log(\`🚀 Application running on: \${await app.getUrl()}\`);
50
- logger.log(\`🌐 Environment: \${process.env.NODE_ENV || 'development'}\`);
51
- logger.log(\`📡 Listening on \${host}:\${port}\`);
52
- } catch (error) {
53
- const logger = new Logger('Bootstrap');
54
- logger.error('❌ Failed to start the server', error);
55
- process.exit(1);
56
- }`,
57
- });
58
- }
59
- module.exports = { setupBootstrapLogger };
1
+ const fs = require("fs");
2
+ const { updateFile } = require("../userInput");
3
+
4
+ async function setupBootstrapLogger() {
5
+ // Modification de main.ts pour intégrer Swagger
6
+ const mainTsPath = "src/main.ts";
7
+ let mainTs = fs.readFileSync(mainTsPath, "utf8");
8
+
9
+ if (!mainTs.includes("await app.listen")) return mainTs;
10
+
11
+ // Injecte les imports si non présents
12
+ await updateFile({
13
+ path: mainTsPath,
14
+ pattern: "import { ValidationPipe } from '@nestjs/common';",
15
+ replacement: `import { Logger, ValidationPipe } from '@nestjs/common';`,
16
+ });
17
+ /* if (!mainTs.includes("Logger")) {
18
+ } */
19
+
20
+ if (!mainTs.includes("ConfigService")) {
21
+ await updateFile({
22
+ path: mainTsPath,
23
+ pattern: "import { NestFactory } from '@nestjs/core';",
24
+ replacement: `import { NestFactory } from '@nestjs/core';
25
+ import { ConfigService } from '@nestjs/config';`,
26
+ });
27
+ }
28
+
29
+ // Injecte la récupération des variables
30
+ if (!mainTs.includes("const host = configService.get<string>('HOST'")) {
31
+ await updateFile({
32
+ path: mainTsPath,
33
+ pattern: "const app = await NestFactory.create(AppModule);",
34
+ replacement: `const app = await NestFactory.create(AppModule);
35
+
36
+ // Global validation & transformation
37
+ app.useGlobalPipes(
38
+ new ValidationPipe({
39
+ transform: true,
40
+ whitelist: true,
41
+ forbidNonWhitelisted: true,
42
+ }),
43
+ );
44
+
45
+ const configService = app.get(ConfigService);
46
+ const port = configService.get<number>('PORT', 3000);
47
+ const host = configService.get<string>('HOST', '0.0.0.0');`,
48
+ });
49
+ }
50
+
51
+ // Remplace le démarrage de l'app par le bloc stylisé
52
+ return await updateFile({
53
+ path: mainTsPath,
54
+ pattern: "await app.listen(process.env.PORT ?? 3000);",
55
+ replacement: `try {
56
+ await app.listen(port, host);
57
+
58
+ const logger = new Logger('Bootstrap');
59
+ logger.log(\`🚀 Application running on: \${await app.getUrl()}\`);
60
+ logger.log(\`🌐 Environment: \${process.env.NODE_ENV || 'development'}\`);
61
+ logger.log(\`📡 Listening on \${host}:\${port}\`);
62
+ } catch (error) {
63
+ const logger = new Logger('Bootstrap');
64
+ logger.error('❌ Failed to start the server', error);
65
+ process.exit(1);
66
+ }`,
67
+ });
68
+ }
69
+ module.exports = { setupBootstrapLogger };