nodejs-quickstart-structure 1.19.0 → 2.0.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 (136) hide show
  1. package/CHANGELOG.md +320 -301
  2. package/LICENSE +15 -15
  3. package/README.md +45 -10
  4. package/bin/index.js +7 -1
  5. package/lib/generator.js +139 -139
  6. package/lib/modules/app-setup.js +401 -401
  7. package/lib/modules/config-files.js +151 -151
  8. package/lib/modules/database-setup.js +116 -116
  9. package/lib/modules/project-setup.js +32 -32
  10. package/lib/prompts.js +100 -100
  11. package/package.json +79 -78
  12. package/templates/clean-architecture/js/src/domain/models/User.js +9 -9
  13. package/templates/clean-architecture/js/src/errors/ApiError.js +14 -14
  14. package/templates/clean-architecture/js/src/index.js.ejs +55 -55
  15. package/templates/clean-architecture/js/src/infrastructure/config/env.js.ejs +47 -47
  16. package/templates/clean-architecture/js/src/infrastructure/log/logger.js +36 -36
  17. package/templates/clean-architecture/js/src/infrastructure/log/logger.spec.js.ejs +63 -63
  18. package/templates/clean-architecture/js/src/infrastructure/webserver/middleware/errorMiddleware.js +30 -30
  19. package/templates/clean-architecture/js/src/infrastructure/webserver/server.js.ejs +89 -89
  20. package/templates/clean-architecture/js/src/infrastructure/webserver/swagger.js.ejs +6 -6
  21. package/templates/clean-architecture/js/src/interfaces/graphql/context.js.ejs +13 -13
  22. package/templates/clean-architecture/js/src/interfaces/graphql/context.spec.js.ejs +31 -31
  23. package/templates/clean-architecture/js/src/interfaces/graphql/index.js.ejs +5 -5
  24. package/templates/clean-architecture/js/src/interfaces/graphql/resolvers/index.js.ejs +6 -6
  25. package/templates/clean-architecture/js/src/interfaces/graphql/typeDefs/index.js.ejs +6 -6
  26. package/templates/clean-architecture/js/src/interfaces/routes/api.spec.js.ejs +38 -38
  27. package/templates/clean-architecture/js/src/usecases/CreateUser.js +14 -14
  28. package/templates/clean-architecture/js/src/usecases/CreateUser.spec.js.ejs +51 -51
  29. package/templates/clean-architecture/js/src/usecases/GetAllUsers.js +12 -12
  30. package/templates/clean-architecture/js/src/usecases/GetAllUsers.spec.js.ejs +61 -61
  31. package/templates/clean-architecture/js/src/utils/httpCodes.js +9 -9
  32. package/templates/clean-architecture/ts/src/config/env.ts.ejs +46 -46
  33. package/templates/clean-architecture/ts/src/config/swagger.ts.ejs +6 -6
  34. package/templates/clean-architecture/ts/src/domain/user.ts +7 -7
  35. package/templates/clean-architecture/ts/src/errors/ApiError.ts +15 -15
  36. package/templates/clean-architecture/ts/src/index.ts.ejs +139 -139
  37. package/templates/clean-architecture/ts/src/infrastructure/log/logger.spec.ts.ejs +63 -63
  38. package/templates/clean-architecture/ts/src/infrastructure/log/logger.ts +36 -36
  39. package/templates/clean-architecture/ts/src/interfaces/graphql/context.spec.ts.ejs +32 -32
  40. package/templates/clean-architecture/ts/src/interfaces/graphql/context.ts.ejs +17 -17
  41. package/templates/clean-architecture/ts/src/interfaces/graphql/index.ts.ejs +3 -3
  42. package/templates/clean-architecture/ts/src/interfaces/graphql/resolvers/index.ts.ejs +4 -4
  43. package/templates/clean-architecture/ts/src/interfaces/graphql/typeDefs/index.ts.ejs +4 -4
  44. package/templates/clean-architecture/ts/src/interfaces/routes/userRoutes.spec.ts.ejs +40 -40
  45. package/templates/clean-architecture/ts/src/usecases/createUser.spec.ts.ejs +51 -51
  46. package/templates/clean-architecture/ts/src/usecases/createUser.ts +13 -13
  47. package/templates/clean-architecture/ts/src/usecases/getAllUsers.spec.ts.ejs +63 -63
  48. package/templates/clean-architecture/ts/src/usecases/getAllUsers.ts +10 -10
  49. package/templates/clean-architecture/ts/src/utils/errorMiddleware.ts.ejs +27 -27
  50. package/templates/clean-architecture/ts/src/utils/httpCodes.ts +7 -7
  51. package/templates/common/.cursorrules.ejs +60 -60
  52. package/templates/common/.dockerignore +12 -12
  53. package/templates/common/.env.example.ejs +41 -41
  54. package/templates/common/.gitlab-ci.yml.ejs +86 -86
  55. package/templates/common/.lintstagedrc +6 -6
  56. package/templates/common/.prettierrc +7 -7
  57. package/templates/common/Dockerfile +73 -73
  58. package/templates/common/Jenkinsfile.ejs +87 -87
  59. package/templates/common/SECURITY.md +20 -20
  60. package/templates/common/_github/workflows/ci.yml.ejs +46 -46
  61. package/templates/common/_github/workflows/security.yml.ejs +36 -36
  62. package/templates/common/_gitignore +5 -5
  63. package/templates/common/_husky/pre-commit +4 -4
  64. package/templates/common/caching/clean/js/CreateUser.js.ejs +29 -29
  65. package/templates/common/caching/clean/js/GetAllUsers.js.ejs +37 -37
  66. package/templates/common/caching/clean/ts/createUser.ts.ejs +27 -27
  67. package/templates/common/caching/clean/ts/getAllUsers.ts.ejs +34 -34
  68. package/templates/common/caching/js/memoryCache.js.ejs +60 -60
  69. package/templates/common/caching/js/memoryCache.spec.js.ejs +101 -101
  70. package/templates/common/caching/js/redisClient.js.ejs +75 -75
  71. package/templates/common/caching/js/redisClient.spec.js.ejs +147 -147
  72. package/templates/common/caching/ts/memoryCache.spec.ts.ejs +102 -102
  73. package/templates/common/caching/ts/redisClient.spec.ts.ejs +157 -157
  74. package/templates/common/database/js/database.js.ejs +19 -19
  75. package/templates/common/database/js/database.spec.js.ejs +56 -56
  76. package/templates/common/database/js/mongoose.js.ejs +33 -33
  77. package/templates/common/database/js/mongoose.spec.js.ejs +43 -43
  78. package/templates/common/database/ts/database.spec.ts.ejs +56 -56
  79. package/templates/common/database/ts/database.ts.ejs +21 -21
  80. package/templates/common/database/ts/mongoose.spec.ts.ejs +42 -42
  81. package/templates/common/database/ts/mongoose.ts.ejs +28 -28
  82. package/templates/common/docker-compose.yml.ejs +159 -159
  83. package/templates/common/ecosystem.config.js.ejs +40 -40
  84. package/templates/common/eslint.config.mjs.ejs +77 -77
  85. package/templates/common/health/js/healthRoute.spec.js.ejs +70 -70
  86. package/templates/common/health/ts/healthRoute.spec.ts.ejs +76 -76
  87. package/templates/common/jest.config.js.ejs +32 -32
  88. package/templates/common/kafka/js/config/kafka.js +9 -9
  89. package/templates/common/kafka/js/config/kafka.spec.js.ejs +27 -27
  90. package/templates/common/kafka/js/messaging/baseConsumer.spec.js.ejs +58 -58
  91. package/templates/common/kafka/js/messaging/userEventSchema.spec.js.ejs +27 -27
  92. package/templates/common/kafka/js/services/kafkaService.spec.js.ejs +106 -106
  93. package/templates/common/kafka/ts/config/kafka.spec.ts.ejs +27 -27
  94. package/templates/common/kafka/ts/config/kafka.ts +7 -7
  95. package/templates/common/kafka/ts/messaging/baseConsumer.spec.ts.ejs +50 -50
  96. package/templates/common/kafka/ts/messaging/baseConsumer.ts.ejs +27 -27
  97. package/templates/common/kafka/ts/services/kafkaService.spec.ts.ejs +81 -81
  98. package/templates/common/migrate-mongo-config.js.ejs +31 -31
  99. package/templates/common/migrations/init.js.ejs +23 -23
  100. package/templates/common/package.json.ejs +119 -118
  101. package/templates/common/prompts/add-feature.md.ejs +26 -26
  102. package/templates/common/prompts/project-context.md.ejs +43 -43
  103. package/templates/common/prompts/troubleshoot.md.ejs +28 -28
  104. package/templates/common/public/css/style.css +147 -147
  105. package/templates/common/scripts/run-e2e.js.ejs +63 -63
  106. package/templates/common/sonar-project.properties.ejs +27 -27
  107. package/templates/common/src/utils/errorMiddleware.spec.js.ejs +79 -79
  108. package/templates/common/src/utils/errorMiddleware.spec.ts.ejs +94 -94
  109. package/templates/common/tsconfig.json +22 -22
  110. package/templates/common/views/ejs/index.ejs +55 -55
  111. package/templates/common/views/pug/index.pug +40 -40
  112. package/templates/mvc/js/src/config/env.js.ejs +46 -46
  113. package/templates/mvc/js/src/config/swagger.js.ejs +6 -6
  114. package/templates/mvc/js/src/errors/ApiError.js +14 -14
  115. package/templates/mvc/js/src/graphql/context.js.ejs +7 -7
  116. package/templates/mvc/js/src/graphql/context.spec.js.ejs +29 -29
  117. package/templates/mvc/js/src/graphql/index.js.ejs +5 -5
  118. package/templates/mvc/js/src/graphql/resolvers/index.js.ejs +6 -6
  119. package/templates/mvc/js/src/graphql/typeDefs/index.js.ejs +6 -6
  120. package/templates/mvc/js/src/index.js.ejs +136 -136
  121. package/templates/mvc/js/src/utils/errorMiddleware.js +29 -29
  122. package/templates/mvc/js/src/utils/httpCodes.js +9 -9
  123. package/templates/mvc/js/src/utils/logger.js +40 -40
  124. package/templates/mvc/js/src/utils/logger.spec.js.ejs +63 -63
  125. package/templates/mvc/ts/src/config/env.ts.ejs +45 -45
  126. package/templates/mvc/ts/src/config/swagger.ts.ejs +6 -6
  127. package/templates/mvc/ts/src/errors/ApiError.ts +15 -15
  128. package/templates/mvc/ts/src/graphql/context.spec.ts.ejs +30 -30
  129. package/templates/mvc/ts/src/graphql/context.ts.ejs +12 -12
  130. package/templates/mvc/ts/src/graphql/index.ts.ejs +3 -3
  131. package/templates/mvc/ts/src/graphql/resolvers/index.ts.ejs +4 -4
  132. package/templates/mvc/ts/src/graphql/typeDefs/index.ts.ejs +4 -4
  133. package/templates/mvc/ts/src/utils/errorMiddleware.ts.ejs +27 -27
  134. package/templates/mvc/ts/src/utils/httpCodes.ts +7 -7
  135. package/templates/mvc/ts/src/utils/logger.spec.ts.ejs +63 -63
  136. package/templates/mvc/ts/src/utils/logger.ts +36 -36
package/LICENSE CHANGED
@@ -1,15 +1,15 @@
1
- ISC License
2
-
3
- Copyright (c) 2026, Pau Dang
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted, provided that the above
7
- copyright notice and this permission notice appear in all copies.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1
+ ISC License
2
+
3
+ Copyright (c) 2026, Pau Dang
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -5,12 +5,36 @@
5
5
  [![npm monthly downloads](https://img.shields.io/npm/dm/nodejs-quickstart-structure.svg?style=flat-square)](https://www.npmjs.com/package/nodejs-quickstart-structure)
6
6
  [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg?style=flat-square)](https://opensource.org/licenses/ISC)
7
7
 
8
- A powerful CLI tool to scaffold production-ready Node.js microservices with built-in best practices, allowing you to choose between **MVC** or **Clean Architecture**, **JavaScript** or **TypeScript**, and your preferred database.
8
+ ### 📈 Real-world Adoption
9
+ | **Metric** | **Insight** |
10
+ | :--- | :--- |
11
+ | 🔥 **4,000+** | Downloads on npm |
12
+ | 🚀 **1,200+** | Recent GitHub Clones |
13
+ | 🌍 **Trusted by** | Devs from **Google**, **Viblo**, and global tech teams |
14
+
15
+ ---
16
+
17
+ A powerful CLI tool to scaffold production-ready Node.js microservices with built-in best practices. Choose between **MVC** or **Clean Architecture**, **JavaScript** or **TypeScript**, and your preferred tech stack in seconds.
18
+
19
+ 🎯 **[Try the Next-Gen Web UI Configurator!](https://paudang.github.io/nodejs-quickstart-structure/)**
20
+ *Generate your exact architecture in the browser with real-time folder simulation.*
9
21
 
10
22
  ![Demo](docs/demo.gif)
11
23
 
12
24
  ---
13
25
 
26
+ ## 🆕 What's New in v2.0.0
27
+
28
+ The v2.0.0 release is a major leap forward, turning the generator into a **Community Standard** for Node.js development:
29
+
30
+ - **Next-Gen Web UI Configurator**: A modern, browser-based visual project simulator. Click your stack and copy the generated zero-prompt CLI command instantly! [Try it here](https://paudang.github.io/nodejs-quickstart-structure/).
31
+ - **🦾 AI-Native Foundation**: Built-in `.cursorrules` and Agent skills optimized for **Cursor** & AI coding assistants.
32
+ - **🏗️ Enterprise Clean Architecture**: High-fidelity structure for professional Microservices (TS/JS).
33
+ - **🛡️ Hardened Security**: Integrated Snyk & SonarCloud logic in the core templates.
34
+ - **⚡ Zero-Prompt Workflow**: Generate projects with a single CLI command—no more answering prompts manually.
35
+
36
+ ---
37
+
14
38
  ## 📌 Table of Contents
15
39
 
16
40
  - [🚀 Quick Start](#-quick-start)
@@ -53,7 +77,6 @@ nodejs-quickstart init
53
77
  - **Communication Patterns**: Supports **REST**, **GraphQL** (Apollo), and **Kafka** (Event-driven).
54
78
  - **Multi-layer Caching**: Integrated **Redis** or built-in **Memory Cache**.
55
79
  - **AI-Native Optimized**: specifically designed for **Cursor** and AI agents, including built-in `.cursorrules` and Agent Skill prompts. 🚀
56
- - **Next Gen Web UI**: (Coming Soon) A modern, browser-based project selector featuring real-time virtualization — set for release in v2.0.0!
57
80
 
58
81
  ---
59
82
 
@@ -100,8 +123,7 @@ The CLI will guide you through:
100
123
  ---
101
124
 
102
125
  ## 🏗️ Generated Project Structure
103
-
104
- A typical generated project (TypeScript + Clean Architecture) looks like this:
126
+ Depending on your choices, the structure adapts. Here is a **TypeScript + Clean Architecture** preview:
105
127
 
106
128
  ```text
107
129
  .
@@ -111,12 +133,13 @@ A typical generated project (TypeScript + Clean Architecture) looks like this:
111
133
  │ ├── infrastructure/ # DB, External services, Repositories
112
134
  │ ├── interfaces/ # Controllers, Routes, GraphQL, Kafka
113
135
  │ ├── errors/ # Custom Error Classes
114
- └── index.ts # Entry point
136
+ ├── config/ # Environment & Global settings
137
+ │ └── index.ts # Server entry point
115
138
  ├── flyway/sql/ # SQL migrations (if applicable)
116
139
  ├── docker-compose.yml # Infrastructure services
117
140
  ├── package.json # Scripts and dependencies
118
- ├── tsconfig.json # TypeScript config
119
- └── .cursorrules # AI assistance rules
141
+ ├── .cursorrules # AI assistance rules (The "AI Brain")
142
+ └── .env.example # Environment template
120
143
  ```
121
144
 
122
145
  ---
@@ -130,9 +153,9 @@ For full guides, architecture deep-dives, and feature references, visit our **[O
130
153
  ## ❤️ Support & 🗺️ Roadmap
131
154
 
132
155
  ### Support the Project
133
- We just hit **3,000+ downloads**! If this tool helped you, please:
134
- - Give us a ⭐ on [GitHub](https://github.com/paudang/nodejs-quickstart-structure).
135
- - Read our [Medium Article](https://medium.com/@paudang/nodejs-quickstart-generator-93c276d60e0b) for tutorials.
156
+ If this tool helped you build your project faster, please support us:
157
+ - Give us a ⭐ on [GitHub](https://github.com/paudang/nodejs-quickstart-structure) to help us reach our next milestone!
158
+ - Read our [Medium Series](https://medium.com/@paudang/nodejs-quickstart-generator-93c276d60e0b) for architecture deep-dives.
136
159
 
137
160
  ### Roadmap
138
161
  Track our progress and vote for features on our public board:
@@ -140,6 +163,18 @@ Track our progress and vote for features on our public board:
140
163
 
141
164
  ---
142
165
 
166
+ ## ⭐ Why Star us?
167
+
168
+ We are on a mission to build the best AI-Native Node.js scaffolding experience. Your star is not just a "like"—it's a vote of confidence that helps us:
169
+
170
+ 1. **Attract Contributors**: More stars attract professional maintainers to keep this project secure and up-to-date.
171
+ 2. **AI Model Awareness**: Popular repositories are weighted higher by AI coding assistants (Cursor, Copilot, etc.), making the generated code even better.
172
+ 3. **Open Source Sustainability**: It motivates us to keep building and shipping "Enterprise-Grade" features for free.
173
+
174
+ If this tool saved you hours of work, **[please give us a Star!](https://github.com/paudang/nodejs-quickstart-structure)** 🚀
175
+
176
+ ---
177
+
143
178
  ## License
144
179
 
145
180
  ISC
package/bin/index.js CHANGED
@@ -31,6 +31,7 @@ program
31
31
  .option('-c, --communication <communication>', 'Communication (REST APIs, GraphQL, Kafka)')
32
32
  .option('--ci-provider <provider>', 'CI/CD Provider (None, GitHub Actions, Jenkins, GitLab CI)')
33
33
  .option('--include-security', 'Include Enterprise Security Hardening')
34
+ .option('--no-include-security', 'Exclude Enterprise Security Hardening')
34
35
  .option('--caching <type>', 'Caching Layer (None/Redis)')
35
36
  .action(async (options) => {
36
37
  // Fix for Commander camelCase conversion
@@ -74,7 +75,12 @@ program
74
75
 
75
76
  console.log(chalk.cyan(`\nNext steps:\n cd ${answers.projectName}\n npm install\n docker-compose up\n-----------------------${manualStartInstructions}\n\n${chalk.yellow('Production (PM2):')}\n npm run build\n npm run deploy\n npx pm2 logs`));
76
77
 
77
- console.log(chalk.yellow(`\n If this tool saved you 5 minutes, please give us a star on GitHub: ${chalk.underline('https://github.com/paudang/nodejs-quickstart-structure')}`));
78
+ console.log(chalk.magenta('\n' + '★'.repeat(50)));
79
+ console.log(chalk.white.bold(' Enjoying the Node.js Quickstart Generator?'));
80
+ console.log(chalk.white(` If this tool saved you 4+ hours of architecture setup,`));
81
+ console.log(chalk.white(` please help us grow by giving us a ⭐ on GitHub!`));
82
+ console.log(chalk.white(`\n 👉 ${chalk.underline.bold('https://github.com/paudang/nodejs-quickstart-structure')}`));
83
+ console.log(chalk.magenta('★'.repeat(50) + '\n'));
78
84
 
79
85
  } catch (error) {
80
86
  if (error.name === 'ExitPromptError') {
package/lib/generator.js CHANGED
@@ -1,139 +1,139 @@
1
- import path from 'path';
2
- import { fileURLToPath } from 'url';
3
- import { setupProjectDirectory, copyBaseStructure, copyCommonFiles } from './modules/project-setup.js';
4
- import { renderPackageJson, renderDockerCompose, renderReadme, renderDockerfile, renderProfessionalConfig, setupCiCd, renderTestSample, renderEnvExample, renderPm2Config, renderAiNativeFiles } from './modules/config-files.js';
5
- import { renderIndexFile, renderEnvConfig, renderErrorMiddleware, renderDynamicComponents, renderSwaggerConfig, setupViews as setupSrcViews, processAllTests } from './modules/app-setup.js';
6
- import { setupDatabase } from './modules/database-setup.js';
7
- import { setupKafka, setupViews } from './modules/kafka-setup.js';
8
- import { setupCaching } from './modules/caching-setup.js';
9
-
10
- const __filename = fileURLToPath(import.meta.url);
11
- const __dirname = path.dirname(__filename);
12
-
13
- export const generateProject = async (config) => {
14
- // 0. Normalize configuration with defaults
15
- config = {
16
- viewEngine: 'None',
17
- caching: 'None',
18
- dbName: 'demo',
19
- ciProvider: 'GitHub Actions',
20
- communication: 'REST APIs',
21
- database: 'None',
22
- includeSecurity: false,
23
- ...config
24
- };
25
-
26
- const { projectName, architecture, language } = config;
27
- const targetDir = path.resolve(process.cwd(), projectName);
28
- const templatesDir = path.join(__dirname, '../templates');
29
-
30
- // 1. Create project directory
31
- await setupProjectDirectory(targetDir, projectName);
32
-
33
- // 2. Select & Copy Base Structure
34
- const { templatePath } = await copyBaseStructure(templatesDir, targetDir, architecture, language);
35
-
36
- // 3. Render package.json
37
- await renderPackageJson(templatesDir, targetDir, config);
38
-
39
- // 4. Render docker-compose.yml
40
- await renderDockerCompose(templatesDir, targetDir, config);
41
-
42
- // 5. Render README.md
43
- await renderReadme(templatesDir, targetDir, config);
44
-
45
- // 6. Render index file (ts/js)
46
- await renderIndexFile(templatePath, targetDir, config);
47
-
48
- // 6a. Render Environment Configuration
49
- await renderEnvConfig(templatePath, targetDir, config);
50
-
51
- // 6a. Render error middleware
52
- await renderErrorMiddleware(templatePath, targetDir, config);
53
-
54
- // 7. Render Dynamic Components (Controllers/Repos/Server)
55
- await renderDynamicComponents(templatePath, targetDir, config);
56
-
57
- // 8. Kafka Setup
58
- await setupKafka(templatesDir, targetDir, config);
59
-
60
- // 9. Common Files (.gitignore, Dockerfile, tsconfig)
61
- await copyCommonFiles(templatesDir, targetDir, language);
62
- await renderDockerfile(templatesDir, targetDir, config);
63
-
64
- // 10. Database Setup (Migrations, Config, Models)
65
- // Note: logic for detailed view copying is also handled nicely if we ensure setupDatabase checks correctly,
66
- // or we can move strict view logic to setupViews.
67
- // In strict refactor, database-setup handles the content that was in the DB block.
68
- await setupDatabase(templatesDir, targetDir, config);
69
-
70
- // 10a. Caching Setup
71
- await setupCaching(templatesDir, targetDir, config);
72
-
73
- // 11. View Engine Public Assets (MVC)
74
- await setupViews(templatesDir, targetDir, config);
75
- // Copy src/views (MVC)
76
- await setupSrcViews(templatesDir, targetDir, config);
77
-
78
- // 12. Swagger Config
79
- await renderSwaggerConfig(templatesDir, targetDir, config);
80
-
81
- // 13. Professional Config & Tests
82
- await renderProfessionalConfig(templatesDir, targetDir, config);
83
- await renderTestSample(templatesDir, targetDir, config);
84
-
85
- // 13.5 AI-Native Scaffolding
86
- await renderAiNativeFiles(templatesDir, targetDir, config);
87
-
88
- // 14. CI/CD
89
- await setupCiCd(templatesDir, targetDir, config);
90
-
91
- // 15. Env Example
92
- await renderEnvExample(templatesDir, targetDir, config);
93
-
94
- // 16. PM2 Configuration
95
- await renderPm2Config(templatesDir, targetDir, config);
96
-
97
- // 17. Process All Tests
98
- await processAllTests(targetDir, config);
99
-
100
- console.log(`
101
- ====================================================
102
- Node.js Project Created Successfully!
103
- ====================================================
104
-
105
- Project: ${projectName}
106
- Architecture: ${architecture}
107
- Language: ${language}
108
- Database: ${config.database}
109
- Communication: ${config.communication}${config.caching && config.caching === 'Redis' ? `\n Caching: ${config.caching}` : ''}
110
-
111
- ----------------------------------------------------
112
- ✨ High-Quality Standards Applied:
113
- ----------------------------------------------------
114
- ✅ Linting & Formatting: Eslint + Prettier configured
115
- ✅ Git Hooks: Husky + Lint-Staged ready
116
- ✅ Security: Helmet, CORS, Rate-Limiting added${config.includeSecurity ? '\n ✅ Enterprise Security: Snyk (SCA) & SonarCloud (SAST) integration' : ''}
117
- ✅ Testing: Jest setup for Unit/Integration tests
118
- ✅ Docker: Production-ready multi-stage build
119
- ${config.ciProvider !== 'None' ? `✅ CI/CD: ${config.ciProvider} Workflow ready` : '❌ CI/CD: Skipped (User preferred)'}
120
-
121
- ----------------------------------------------------
122
- 🚀 Project is AI-Ready!
123
- ----------------------------------------------------
124
- 🤖 We detected you are using AI tools.
125
- 📍 Use Cursor? We've configured '.cursorrules' for you.
126
- 📍 Use ChatGPT/Gemini? Check the 'prompts/' folder for Agent Skills.
127
-
128
- ----------------------------------------------------
129
- 👉 Next Steps:
130
- ----------------------------------------------------
131
- 1. cd ${projectName}
132
- 2. git init
133
- 3. npm install
134
- 4. npm run prepare (To setup Husky hooks)
135
- 5. docker-compose up -d${config.database !== 'None' ? ' db' : ''}${config.caching === 'Redis' ? ' redis' : ''}${config.communication === 'Kafka' ? ' kafka' : ''} (To start DB/Infrastructure)
136
- 6. npm run dev (To start development server)
137
- 7. npm test (To run tests)
138
- `);
139
- };
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ import { setupProjectDirectory, copyBaseStructure, copyCommonFiles } from './modules/project-setup.js';
4
+ import { renderPackageJson, renderDockerCompose, renderReadme, renderDockerfile, renderProfessionalConfig, setupCiCd, renderTestSample, renderEnvExample, renderPm2Config, renderAiNativeFiles } from './modules/config-files.js';
5
+ import { renderIndexFile, renderEnvConfig, renderErrorMiddleware, renderDynamicComponents, renderSwaggerConfig, setupViews as setupSrcViews, processAllTests } from './modules/app-setup.js';
6
+ import { setupDatabase } from './modules/database-setup.js';
7
+ import { setupKafka, setupViews } from './modules/kafka-setup.js';
8
+ import { setupCaching } from './modules/caching-setup.js';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+
13
+ export const generateProject = async (config) => {
14
+ // 0. Normalize configuration with defaults
15
+ config = {
16
+ viewEngine: 'None',
17
+ caching: 'None',
18
+ dbName: 'demo',
19
+ ciProvider: 'GitHub Actions',
20
+ communication: 'REST APIs',
21
+ database: 'None',
22
+ includeSecurity: false,
23
+ ...config
24
+ };
25
+
26
+ const { projectName, architecture, language } = config;
27
+ const targetDir = path.resolve(process.cwd(), projectName);
28
+ const templatesDir = path.join(__dirname, '../templates');
29
+
30
+ // 1. Create project directory
31
+ await setupProjectDirectory(targetDir, projectName);
32
+
33
+ // 2. Select & Copy Base Structure
34
+ const { templatePath } = await copyBaseStructure(templatesDir, targetDir, architecture, language);
35
+
36
+ // 3. Render package.json
37
+ await renderPackageJson(templatesDir, targetDir, config);
38
+
39
+ // 4. Render docker-compose.yml
40
+ await renderDockerCompose(templatesDir, targetDir, config);
41
+
42
+ // 5. Render README.md
43
+ await renderReadme(templatesDir, targetDir, config);
44
+
45
+ // 6. Render index file (ts/js)
46
+ await renderIndexFile(templatePath, targetDir, config);
47
+
48
+ // 6a. Render Environment Configuration
49
+ await renderEnvConfig(templatePath, targetDir, config);
50
+
51
+ // 6a. Render error middleware
52
+ await renderErrorMiddleware(templatePath, targetDir, config);
53
+
54
+ // 7. Render Dynamic Components (Controllers/Repos/Server)
55
+ await renderDynamicComponents(templatePath, targetDir, config);
56
+
57
+ // 8. Kafka Setup
58
+ await setupKafka(templatesDir, targetDir, config);
59
+
60
+ // 9. Common Files (.gitignore, Dockerfile, tsconfig)
61
+ await copyCommonFiles(templatesDir, targetDir, language);
62
+ await renderDockerfile(templatesDir, targetDir, config);
63
+
64
+ // 10. Database Setup (Migrations, Config, Models)
65
+ // Note: logic for detailed view copying is also handled nicely if we ensure setupDatabase checks correctly,
66
+ // or we can move strict view logic to setupViews.
67
+ // In strict refactor, database-setup handles the content that was in the DB block.
68
+ await setupDatabase(templatesDir, targetDir, config);
69
+
70
+ // 10a. Caching Setup
71
+ await setupCaching(templatesDir, targetDir, config);
72
+
73
+ // 11. View Engine Public Assets (MVC)
74
+ await setupViews(templatesDir, targetDir, config);
75
+ // Copy src/views (MVC)
76
+ await setupSrcViews(templatesDir, targetDir, config);
77
+
78
+ // 12. Swagger Config
79
+ await renderSwaggerConfig(templatesDir, targetDir, config);
80
+
81
+ // 13. Professional Config & Tests
82
+ await renderProfessionalConfig(templatesDir, targetDir, config);
83
+ await renderTestSample(templatesDir, targetDir, config);
84
+
85
+ // 13.5 AI-Native Scaffolding
86
+ await renderAiNativeFiles(templatesDir, targetDir, config);
87
+
88
+ // 14. CI/CD
89
+ await setupCiCd(templatesDir, targetDir, config);
90
+
91
+ // 15. Env Example
92
+ await renderEnvExample(templatesDir, targetDir, config);
93
+
94
+ // 16. PM2 Configuration
95
+ await renderPm2Config(templatesDir, targetDir, config);
96
+
97
+ // 17. Process All Tests
98
+ await processAllTests(targetDir, config);
99
+
100
+ console.log(`
101
+ ====================================================
102
+ Node.js Project Created Successfully!
103
+ ====================================================
104
+
105
+ Project: ${projectName}
106
+ Architecture: ${architecture}
107
+ Language: ${language}
108
+ Database: ${config.database}
109
+ Communication: ${config.communication}${config.caching && config.caching === 'Redis' ? `\n Caching: ${config.caching}` : ''}
110
+
111
+ ----------------------------------------------------
112
+ ✨ High-Quality Standards Applied:
113
+ ----------------------------------------------------
114
+ ✅ Linting & Formatting: Eslint + Prettier configured
115
+ ✅ Git Hooks: Husky + Lint-Staged ready
116
+ ✅ Security: Helmet, CORS, Rate-Limiting added${config.includeSecurity ? '\n ✅ Enterprise Security: Snyk (SCA) & SonarCloud (SAST) integration' : ''}
117
+ ✅ Testing: Jest setup for Unit/Integration tests
118
+ ✅ Docker: Production-ready multi-stage build
119
+ ${config.ciProvider !== 'None' ? `✅ CI/CD: ${config.ciProvider} Workflow ready` : '❌ CI/CD: Skipped (User preferred)'}
120
+
121
+ ----------------------------------------------------
122
+ 🚀 Project is AI-Ready!
123
+ ----------------------------------------------------
124
+ 🤖 We detected you are using AI tools.
125
+ 📍 Use Cursor? We've configured '.cursorrules' for you.
126
+ 📍 Use ChatGPT/Gemini? Check the 'prompts/' folder for Agent Skills.
127
+
128
+ ----------------------------------------------------
129
+ 👉 Next Steps:
130
+ ----------------------------------------------------
131
+ 1. cd ${projectName}
132
+ 2. git init
133
+ 3. npm install
134
+ 4. npm run prepare (To setup Husky hooks)
135
+ 5. docker-compose up -d${config.database !== 'None' ? ' db' : ''}${config.caching === 'Redis' ? ' redis' : ''}${config.communication === 'Kafka' ? ' kafka' : ''} (To start DB/Infrastructure)
136
+ 6. npm run dev (To start development server)
137
+ 7. npm test (To run tests)
138
+ `);
139
+ };