nodejs-quickstart-structure 1.17.0 → 1.18.1

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/CHANGELOG.md CHANGED
@@ -1,9 +1,30 @@
1
- # Changelog
1
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2
2
 
3
- All notable changes to this project will be documented in this file.
3
+ ## [1.18.1] - 2026-03-27
4
4
 
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
+ ### Fixed
6
+ - **Template Security Hardening**: Resolved 29 vulnerabilities in `package.json.ejs` by upgrading `Apollo Server`, `Jest`, and `ESLint`.
7
+ - **Apollo Server 5 Compatibility**: Migrated GraphQL integration to use `@as-integrations/express4`, resolving breaking changes in the latest Apollo release.
8
+ - **Surgical Security Overrides**: Implemented targeted `overrides` for `brace-expansion`, `jake`, and `micromatch`. Removed global `glob/minimatch` overrides to maintain compatibility with Jest's internal APIs while preserving a "Zero-Vulnerability" status.
9
+ - **E2E Validated**: Verified the entire "Secure-by-Default" ecosystem via Windows E2E tests, achieving 100% pass rate.
10
+ - **Enterprise Standards**: Synchronized all generator templates with the latest secure dependency standards across MVC and Clean Architecture.
11
+ ### Changed
12
+ - **Readme**: Standardize Generated Project README.
13
+
14
+ ## [1.18.0] - 2026-03-25
15
+
16
+ ### Added
17
+ - **Enterprise-Grade Security Hardening**: Integrated **Snyk (SCA)** and **SonarQube (SAST)** into the project scaffolding, providing "Big Tech" industry-standard security analysis out of the box.
18
+ - **Automated Security Workflows**: Pre-configured CI/CD stages for security scanning across GitHub Actions, GitLab CI, and Jenkins.
19
+ - **Pre-commit Security Gates**: Integrated **Husky** and **lint-staged** to automatically enforce code quality and security standards locally before every commit.
20
+ - **Security Standard Enforcement**: Added a standardized `SECURITY.md` policy and automated quality gates to ensure code resilience.
21
+ - **Comprehensive Security Guide**: Created a new documentation guide detailing the setup and operational workflows for the enterprise security features.
22
+
23
+ ### Changed
24
+ - **Matrix Expansion**: Updated the CLI to support over **1,680+ project combinations** by adding a conditional security hardening layer across all CI/CD providers.
25
+
26
+ ### Fixed
27
+ - **Docker Node Version**: Updated Docker node version to 22.22.2-trixie-slim
7
28
 
8
29
  ## [1.17.0] - 2026-03-23
9
30
 
package/README.md CHANGED
@@ -1,135 +1,144 @@
1
- # Node.js Quickstart Generator
2
-
3
- [![npm version](https://img.shields.io/npm/v/nodejs-quickstart-structure.svg?style=flat-square)](https://www.npmjs.com/package/nodejs-quickstart-structure)
4
- [![npm total downloads](https://img.shields.io/npm/dt/nodejs-quickstart-structure.svg?style=flat-square)](https://www.npmjs.com/package/nodejs-quickstart-structure)
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
- [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg?style=flat-square)](https://opensource.org/licenses/ISC)
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.
9
-
10
- ![Demo](docs/demo.gif)
11
-
12
- ## Features
13
-
14
- - **Interactive CLI**: Easy-to-use prompts to configure your project.
15
- - **Multiple Architectures**: Supports both **MVC** (Model-View-Controller) and **Clean Architecture**.
16
- - **Language Support**: Choose between **JavaScript** and **TypeScript**.
17
- - **Database Integration**: Pre-configured setup for **MySQL**, **PostgreSQL**, or **MongoDB**.
18
- - **Communication Flow**: Scaffold APIs using **REST**, **GraphQL** (with Apollo Server), or **Kafka** (event-driven).
19
- - **Caching Layer**: Choose between **Redis** or built-in **Memory Cache** for data caching.
20
- - **Centralized Error Handling**: Every project ships with a global error handler, custom error classes and structured JSON error responses — consistent across REST & GraphQL.
21
- - **Dockerized**: Automatically generates `docker-compose.yml` for DB, Kafka, and Redis.
22
- - **Database Migrations/Schemas**: Integrated **Flyway** for SQL migrations or **Mongoose** schemas for MongoDB.
23
- - **Professional Standards**: Generated projects come with highly professional, industry-standard tooling.
24
-
25
- ## 🌟 Why developers love this?
26
-
27
- - **Community Trusted**: Over **3,000+** projects bootstrapped within the first month.
28
- - **Actively Maintained**: Constant updates and optimizations (30+ versions released) based on real-world developer feedback.
29
- - **Resilience First**: Unlike basic boilerplates, our generated code focuses on infrastructure stability (Retry logic, Health checks, and Graceful shutdowns).
30
-
31
- ## 🏆 Professional Standards (New)
32
-
33
- We don't just generate boilerplate; we generate **production-ready** foundations. Every project includes:
34
-
35
- - **🔍 Code Quality**: Pre-configured `Eslint` and `Prettier` for consistent coding standards.
36
- - **🛡️ Security**: Built-in `Helmet`, `HPP`, `CORS`, and Rate-Limiting middleware.
37
- - **🚨 Error Handling**: Centralized global error middleware with custom error classes and structured JSON responses. GraphQL uses Apollo's `formatError` hook; REST uses Express error middleware.
38
- - **🧪 Testing Excellence**: Integrated `Jest` and `Supertest`. Every generated project maintains **>80% Unit Test coverage** for controllers, services, and resolvers out of the box.
39
- - **🔄 CI/CD Integration**: Pre-configured workflows for **GitHub Actions**, **Jenkins**, and **GitLab CI**.
40
- - **⚓ Git Hooks**: `Husky` and `Lint-Staged` to ensure no bad code is ever committed.
41
- - **🤝 Reliability**: Health Checks (`/health`) with deep database pings, Infrastructure Retry Logic (handling Docker startup delays), and Graceful Shutdown workflows.
42
- - **🐳 DevOps**: Highly optimized **Multi-Stage Dockerfile** for small, secure production images.
43
- - **🚀 Deployment**: Ship confidently with an integrated **PM2 Ecosystem Configuration** for zero-downtime reloads and robust process management.
44
-
45
- ## 🧩 480+ Project Combinations
46
-
47
- The CLI supports a massive number of configurations to fit your exact needs:
48
-
49
- - **240 Core Combinations**:
50
- - **MVC Architecture**: 180 variants (Languages × View Engines × Databases × Communication Patterns × Caching)
51
- - **Clean Architecture**: 60 variants (Languages × Databases × Communication Patterns × Caching)
52
- - **480 Total Scenarios**:
53
- - Every combination can be generated with or without (**GitHub Actions CI/CD** / **Jenkins** or **GitLab CI**), tripling the possibilities.
54
- - Every single one of these 480 scenarios is verified to be compatible with our 80% Coverage Threshold policy.
55
-
56
- For a detailed list of all supported cases, check out [docs/generateCase.md](docs/generateCase.md).
57
-
58
- ## Installation
59
-
60
- You can install the tool globally directly from npm:
61
-
62
- ```bash
63
- npm install -g nodejs-quickstart-structure
64
- ```
65
-
66
- ## Usage
67
-
68
- Once installed, simply run the following command in any directory where you want to create a new project:
69
-
70
- ```bash
71
- nodejs-quickstart init
72
- ```
73
-
74
- ## Quick Start (Recommended)
75
-
76
- You can run the generator directly without installing it globally:
77
-
78
- ```bash
79
- npx nodejs-quickstart-structure@latest init
80
- ```
81
-
82
- ### Configuration Options
83
-
84
- The CLI will guide you through the following steps:
85
-
86
- 1. **Project Name**: The name of the folder to create.
87
- 2. **Language**: `JavaScript` or `TypeScript`.
88
- 3. **Architecture**: `MVC` or `Clean Architecture`.
89
- 4. **Database**: `MySQL`, `PostgreSQL`, or `MongoDB`.
90
- 5. **Database Name**: The name of the initial database.
91
- 6. **Communication**: `REST APIs` (default), `GraphQL`, or `Kafka`.
92
- 7. **Caching**: `None`, `Redis`, or `Memory Cache`.
93
- 8. **CI/CD**: `GitHub Actions`, `Jenkins`, `GitLab CI` or `None`.
94
-
95
- ## Generated Project Structure
96
-
97
- The generated project will include:
98
-
99
- - `src/`: Source code (controllers, routes, services/use-cases).
100
- - `src/errors/`: Custom error classes — `ApiError`, `NotFoundError`, `BadRequestError`.
101
- - `flyway/sql/`: SQL migration scripts (if SQL database selected).
102
- - `docker-compose.yml`: Services configuration for DB, Flyway, and Kafka.
103
- - `package.json`: Dependencies and scripts (`start`, `dev`, `build`).
104
- - `tsconfig.json`: (If TypeScript is selected) Type checking configuration.
105
-
106
- ### Getting Started with the Generated App
107
-
108
- ```bash
109
- cd <your-project-name>
110
-
111
- # Start infrastructure (DB, etc.)
112
- npm install
113
-
114
- docker-compose up
115
- ```
116
-
117
- ## ❤️ Support the Project
118
-
119
- We just hit **3,000 downloads**! If this tool helped you save hours of setup time, please consider:
120
- - Giving us a ⭐ on [GitHub](https://github.com/paudang/nodejs-quickstart-structure) to help others find it.
121
- - Following the [Medium Article](https://medium.com/@paudang/nodejs-quickstart-generator-93c276d60e0b) for deep-dive tutorials.
122
-
123
- ## License
124
-
125
- ISC
126
-
127
- ## 🚀 Roadmap & Upcoming Features
128
-
129
- We are constantly working to improve `nodejs-quickstart-structure` and make it the most robust boilerplate generator for Node.js.
130
-
131
- You can track our current progress, see what features are being worked on, and vote for your favorites on our public Trello board:
132
-
133
- 👉 **[View our Public Roadmap on Trello](https://trello.com/b/TPTo8ylF/nodejs-quickstart-structure-product)**
134
-
135
- If you have a feature request or want to contribute, feel free to check the board and open an issue or pull request!
1
+ # Node.js Quickstart Generator
2
+
3
+ [![npm version](https://img.shields.io/npm/v/nodejs-quickstart-structure.svg?style=flat-square)](https://www.npmjs.com/package/nodejs-quickstart-structure)
4
+ [![npm total downloads](https://img.shields.io/npm/dt/nodejs-quickstart-structure?style=flat-square&color=emerald&label=Downloads)](https://www.npmjs.com/package/nodejs-quickstart-structure)
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
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg?style=flat-square)](https://opensource.org/licenses/ISC)
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.
9
+
10
+ ![Demo](docs/demo.gif)
11
+
12
+ ---
13
+
14
+ ## 📌 Table of Contents
15
+
16
+ - [🚀 Quick Start](#-quick-start)
17
+ - [✨ Key Features](#-key-features)
18
+ - [🛡️ Professional Standards](#-professional-standards)
19
+ - [🧩 1,680+ Project Combinations](#-1680-project-combinations)
20
+ - [⚙️ Configuration Options](#-configuration-options)
21
+ - [🏗️ Generated Project Structure](#-generated-project-structure)
22
+ - [📖 Documentation](#-documentation)
23
+ - [🗺️ Roadmap & Support](#️-roadmap--support)
24
+
25
+ ---
26
+
27
+ ## 🚀 Quick Start
28
+
29
+ Generate your professional Node.js project in seconds without installing anything globally:
30
+
31
+ ```bash
32
+ npx nodejs-quickstart-structure@latest init
33
+ ```
34
+
35
+ ### Installation (Optional)
36
+
37
+ If you prefer to install it globally:
38
+
39
+ ```bash
40
+ npm install -g nodejs-quickstart-structure
41
+ # Then run:
42
+ nodejs-quickstart init
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Key Features
48
+
49
+ - **Interactive CLI**: Smooth, guided configuration process.
50
+ - **Multiple Architectures**: Supports both **MVC** and **Clean Architecture**.
51
+ - **Modern Languages**: Choice of **JavaScript** or **TypeScript**.
52
+ - **Database Ready**: Pre-configured for **MySQL**, **PostgreSQL**, or **MongoDB**.
53
+ - **Communication Patterns**: Supports **REST**, **GraphQL** (Apollo), and **Kafka** (Event-driven).
54
+ - **Multi-layer Caching**: Integrated **Redis** or built-in **Memory Cache**.
55
+ - **AI-Native Optimized**: specifically designed for **Cursor** and AI agents, including built-in `.cursorrules` and Agent Skill prompts. 🚀
56
+
57
+ ---
58
+
59
+ ## 🛡️ Professional Standards
60
+
61
+ We don't just generate boilerplate; we generate **production-ready** foundations. Every project includes:
62
+
63
+ - **🔍 Code Quality**: Pre-configured `Eslint` and `Prettier`.
64
+ - **🛡️ Enterprise Security**: Integrated **Snyk (SCA)**, **SonarCloud (SAST)**, `Helmet`, `HPP`, and Rate-Limiting.
65
+ - **🚨 Robust Error Handling**: Centralized global error middleware with custom error classes (`ApiError`, `NotFoundError`, etc.) — consistent across REST & GraphQL.
66
+ - **🧪 Testing Excellence**: Integrated `Jest` and `Supertest` with **>80% Unit Test coverage** out of the box.
67
+ - **🔄 DevOps & CI/CD**: Optimized **Multi-Stage Dockerfiles**, health checks, infrastructure retry logic, and workflows for **GitHub Actions**, **Jenkins**, and **GitLab CI**.
68
+ - **🚀 Scalable Deployment**: Integrated **PM2 Ecosystem** config for zero-downtime reloads.
69
+
70
+ ---
71
+
72
+ ## 🧩 1,680+ Project Combinations
73
+
74
+ The CLI supports a massive number of configurations to fit your exact needs:
75
+
76
+ - **240 Core Combinations**:
77
+ - **MVC Architecture**: 180 variants (Languages × View Engines × Databases × Communication Patterns × Caching)
78
+ - **Clean Architecture**: 60 variants (Languages × Databases × Communication Patterns × Caching)
79
+ - **1,680+ Total Scenarios**:
80
+ - Every combination can be generated across 3 CI/CD providers.
81
+ - Optional **Enterprise-Grade Security Hardening** doubles the scenarios.
82
+ - Every single scenario is verified to be compatible with our **80% Coverage Threshold** policy.
83
+
84
+ ---
85
+
86
+ ## ⚙️ Configuration Options
87
+
88
+ The CLI will guide you through:
89
+ 1. **Project Name**
90
+ 2. **Language**: `JavaScript` | `TypeScript`
91
+ 3. **Architecture**: `MVC` | `Clean Architecture`
92
+ 4. **View Engine**: (MVC only) `None` | `EJS` | `Pug`
93
+ 5. **Database**: `MySQL` | `PostgreSQL` | `MongoDB`
94
+ 6. **Communication**: `REST` | `GraphQL` | `Kafka`
95
+ 7. **Caching**: `None` | `Redis` | `Memory Cache`
96
+ 8. **CI/CD**: `GitHub Actions` | `Jenkins` | `GitLab CI`
97
+ 9. **Security**: (Optional) Snyk & SonarCloud Hardening
98
+
99
+ ---
100
+
101
+ ## 🏗️ Generated Project Structure
102
+
103
+ A typical generated project (TypeScript + Clean Architecture) looks like this:
104
+
105
+ ```text
106
+ .
107
+ ├── src/
108
+ │ ├── application/ # Use cases & Business logic
109
+ │ ├── domain/ # Entities & Repository interfaces
110
+ │ ├── infrastructure/ # DB, External services, Repositories
111
+ │ ├── interfaces/ # Controllers, Routes, GraphQL, Kafka
112
+ │ ├── errors/ # Custom Error Classes
113
+ │ └── index.ts # Entry point
114
+ ├── flyway/sql/ # SQL migrations (if applicable)
115
+ ├── docker-compose.yml # Infrastructure services
116
+ ├── package.json # Scripts and dependencies
117
+ ├── tsconfig.json # TypeScript config
118
+ └── .cursorrules # AI assistance rules
119
+ ```
120
+
121
+ ---
122
+
123
+ ## 📖 Documentation
124
+
125
+ For full guides, architecture deep-dives, and feature references, visit our **[Official Documentation Site](https://paudang.github.io/nodejs-quickstart-structure/)**.
126
+
127
+ ---
128
+
129
+ ## ❤️ Support & 🗺️ Roadmap
130
+
131
+ ### Support the Project
132
+ We just hit **3,000+ downloads**! If this tool helped you, please:
133
+ - Give us a on [GitHub](https://github.com/paudang/nodejs-quickstart-structure).
134
+ - Read our [Medium Article](https://medium.com/@paudang/nodejs-quickstart-generator-93c276d60e0b) for tutorials.
135
+
136
+ ### Roadmap
137
+ Track our progress and vote for features on our public board:
138
+ 👉 **[View our Public Roadmap on Trello](https://trello.com/b/TPTo8ylF/nodejs-quickstart-structure-product)**
139
+
140
+ ---
141
+
142
+ ## License
143
+
144
+ ISC
package/bin/index.js CHANGED
@@ -1,90 +1,93 @@
1
- #!/usr/bin/env node
2
-
3
- import { Command } from 'commander';
4
- import chalk from 'chalk';
5
- import { getProjectDetails } from '../lib/prompts.js';
6
- import { generateProject } from '../lib/generator.js';
7
- import { readFileSync } from 'fs';
8
- import { join, dirname } from 'path';
9
- import { fileURLToPath } from 'url';
10
-
11
- const __dirname = dirname(fileURLToPath(import.meta.url));
12
- const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
13
-
14
- const program = new Command();
15
-
16
- program
17
- .name('nodejs-quickstart')
18
- .description('🚀 CLI to scaffold production-ready Node.js microservices.\n\nGenerates projects with:\n- MVC or Clean Architecture\n- REST or Kafka\n- MySQL, PostgreSQL, or MongoDB\n- Docker, Flyway & Mongoose support')
19
- .version(pkg.version, '-v, --version', 'Output the current version')
20
- .addHelpText('after', `\n${chalk.yellow('Example:')}\n $ nodejs-quickstart init ${chalk.gray('# Start the interactive setup')}\n`);
21
-
22
- program
23
- .command('init')
24
- .description('Initialize a new Node.js project')
25
- .option('-n, --project-name <name>', 'Project name')
26
- .option('-l, --language <language>', 'Language (JavaScript, TypeScript)')
27
- .option('-a, --architecture <architecture>', 'Architecture (MVC, Clean Architecture)')
28
- .option('--view-engine <view>', 'View Engine (None, EJS, Pug) - MVC only')
29
- .option('-d, --database <database>', 'Database (MySQL, PostgreSQL)')
30
- .option('--db-name <name>', 'Database name')
31
- .option('-c, --communication <communication>', 'Communication (REST APIs, GraphQL, Kafka)')
32
- .option('--ci-provider <provider>', 'CI/CD Provider (None, GitHub Actions, Jenkins)')
33
- .option('--caching <type>', 'Caching Layer (None/Redis)')
34
- .action(async (options) => {
35
- // Fix for Commander camelCase conversion
36
- if (options.ciProvider) {
37
- options.ciProvider = options.ciProvider;
38
- }
39
-
40
- console.log(chalk.blue('Welcome to the Node.js Quickstart Generator!'));
41
-
42
- try {
43
- const answers = await getProjectDetails(options);
44
- console.log(chalk.green('\nConfiguration received:'));
45
- console.log(JSON.stringify(answers, null, 2));
46
-
47
- console.log(chalk.yellow('\nGenerating project...'));
48
- await generateProject(answers);
49
-
50
- console.log(chalk.green('\n✔ Project generated successfully!'));
51
-
52
- console.log(chalk.magenta('\n🚀 Project is AI-Ready!'));
53
- console.log(chalk.magenta('-----------------------------------------'));
54
- console.log(chalk.magenta('🤖 We detected you are using AI tools.'));
55
- console.log(chalk.magenta(`📍 Use Cursor? We've configured '.cursorrules' for you.`));
56
- console.log(chalk.magenta(`📍 Use ChatGPT/Gemini? Check the 'prompts/' folder for Agent Skills.`));
57
- console.log(chalk.magenta('-----------------------------------------'));
58
-
59
- let manualStartInstructions = `\n${chalk.yellow('Development:')}\n cd ${answers.projectName}\n npm install`;
60
-
61
- const needsInfrastructure = answers.database !== 'None' || answers.caching === 'Redis' || answers.communication === 'Kafka';
62
-
63
- if (needsInfrastructure) {
64
- let servicesToStart = '';
65
- if (answers.database === 'MongoDB') servicesToStart += ' db';
66
- else if (answers.database !== 'None') servicesToStart += ' db flyway';
67
- if (answers.caching === 'Redis') servicesToStart += ' redis';
68
- if (answers.communication === 'Kafka') servicesToStart += ' kafka';
69
-
70
- manualStartInstructions += `\n docker-compose up -d${servicesToStart} # Start infrastructure first\n npm run dev`;
71
- } else {
72
- manualStartInstructions += `\n npm run dev`;
73
- }
74
-
75
- 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
- } catch (error) {
78
- if (error.name === 'ExitPromptError') {
79
- console.log(chalk.yellow('\n\n👋 Goodbye! Setup cancelled.'));
80
- process.exit(0);
81
- }
82
- console.error(chalk.red('Error generating project:'), error);
83
- process.exit(1);
84
- }
85
- });
86
- program.parse(process.argv);
87
-
88
- if (!process.argv.slice(2).length) {
89
- program.outputHelp();
90
- }
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from 'commander';
4
+ import chalk from 'chalk';
5
+ import { getProjectDetails } from '../lib/prompts.js';
6
+ import { generateProject } from '../lib/generator.js';
7
+ import { readFileSync } from 'fs';
8
+ import { join, dirname } from 'path';
9
+ import { fileURLToPath } from 'url';
10
+
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+ const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
13
+
14
+ const program = new Command();
15
+
16
+ program
17
+ .name('nodejs-quickstart')
18
+ .description('🚀 CLI to scaffold production-ready Node.js microservices.\n\nGenerates projects with:\n- MVC or Clean Architecture\n- REST or Kafka\n- MySQL, PostgreSQL, or MongoDB\n- Docker, Flyway & Mongoose support')
19
+ .version(pkg.version, '-v, --version', 'Output the current version')
20
+ .addHelpText('after', `\n${chalk.yellow('Example:')}\n $ nodejs-quickstart init ${chalk.gray('# Start the interactive setup')}\n`);
21
+
22
+ program
23
+ .command('init')
24
+ .description('Initialize a new Node.js project')
25
+ .option('-n, --project-name <name>', 'Project name')
26
+ .option('-l, --language <language>', 'Language (JavaScript, TypeScript)')
27
+ .option('-a, --architecture <architecture>', 'Architecture (MVC, Clean Architecture)')
28
+ .option('--view-engine <view>', 'View Engine (None, EJS, Pug) - MVC only')
29
+ .option('-d, --database <database>', 'Database (MySQL, PostgreSQL)')
30
+ .option('--db-name <name>', 'Database name')
31
+ .option('-c, --communication <communication>', 'Communication (REST APIs, GraphQL, Kafka)')
32
+ .option('--ci-provider <provider>', 'CI/CD Provider (None, GitHub Actions, Jenkins, GitLab CI)')
33
+ .option('--include-security', 'Include Enterprise Security Hardening')
34
+ .option('--caching <type>', 'Caching Layer (None/Redis)')
35
+ .action(async (options) => {
36
+ // Fix for Commander camelCase conversion
37
+ if (options.ciProvider) {
38
+ options.ciProvider = options.ciProvider;
39
+ }
40
+
41
+ console.log(chalk.blue('Welcome to the Node.js Quickstart Generator!'));
42
+
43
+ try {
44
+ const answers = await getProjectDetails(options);
45
+ console.log(chalk.blue(`\n🚀 Preparing to generate ${chalk.bold(answers.projectName)} (${answers.architecture})...`));
46
+
47
+ console.log(chalk.yellow('\nGenerating project files...'));
48
+ await generateProject(answers);
49
+
50
+ console.log(chalk.green('\n✔ Project generated successfully!'));
51
+
52
+ console.log(chalk.magenta('\n🚀 Project is AI-Ready!'));
53
+ console.log(chalk.magenta('-----------------------------------------'));
54
+ console.log(chalk.magenta('🤖 We detected you are using AI tools.'));
55
+ console.log(chalk.magenta(`📍 Use Cursor? We've configured '.cursorrules' for you.`));
56
+ console.log(chalk.magenta(`📍 Use ChatGPT/Gemini? Check the 'prompts/' folder for Agent Skills.`));
57
+ console.log(chalk.magenta('-----------------------------------------'));
58
+
59
+ let manualStartInstructions = `\n${chalk.yellow('Development:')}\n cd ${answers.projectName}\n npm install`;
60
+
61
+ const needsInfrastructure = answers.database !== 'None' || answers.caching === 'Redis' || answers.communication === 'Kafka';
62
+
63
+ if (needsInfrastructure) {
64
+ let servicesToStart = '';
65
+ if (answers.database === 'MongoDB') servicesToStart += ' db';
66
+ else if (answers.database !== 'None') servicesToStart += ' db flyway';
67
+ if (answers.caching === 'Redis') servicesToStart += ' redis';
68
+ if (answers.communication === 'Kafka') servicesToStart += ' kafka';
69
+
70
+ manualStartInstructions += `\n docker-compose up -d${servicesToStart} # Start infrastructure first\n npm run dev`;
71
+ } else {
72
+ manualStartInstructions += `\n npm run dev`;
73
+ }
74
+
75
+ 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
+ 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
+
79
+ } catch (error) {
80
+ if (error.name === 'ExitPromptError') {
81
+ console.log(chalk.yellow('\n\n👋 Goodbye! Setup cancelled.'));
82
+ process.exit(0);
83
+ }
84
+ console.error(chalk.red('Error generating project:'), error);
85
+ process.exit(1);
86
+ }
87
+ });
88
+
89
+ program.parse(process.argv);
90
+
91
+ if (!process.argv.slice(2).length) {
92
+ program.outputHelp();
93
+ }
package/lib/generator.js CHANGED
@@ -16,9 +16,10 @@ export const generateProject = async (config) => {
16
16
  viewEngine: 'None',
17
17
  caching: 'None',
18
18
  dbName: 'demo',
19
- ciProvider: 'None',
19
+ ciProvider: 'GitHub Actions',
20
20
  communication: 'REST APIs',
21
21
  database: 'None',
22
+ includeSecurity: false,
22
23
  ...config
23
24
  };
24
25
 
@@ -112,7 +113,7 @@ export const generateProject = async (config) => {
112
113
  ----------------------------------------------------
113
114
  ✅ Linting & Formatting: Eslint + Prettier configured
114
115
  ✅ Git Hooks: Husky + Lint-Staged ready
115
- ✅ Security: Helmet, CORS, Rate-Limiting added
116
+ ✅ Security: Helmet, CORS, Rate-Limiting added${config.includeSecurity ? '\n ✅ Enterprise Security: Snyk (SCA) & SonarCloud (SAST) integration' : ''}
116
117
  ✅ Testing: Jest setup for Unit/Integration tests
117
118
  ✅ Docker: Production-ready multi-stage build
118
119
  ${config.ciProvider !== 'None' ? `✅ CI/CD: ${config.ciProvider} Workflow ready` : '❌ CI/CD: Skipped (User preferred)'}
@@ -131,7 +132,7 @@ export const generateProject = async (config) => {
131
132
  2. git init
132
133
  3. npm install
133
134
  4. npm run prepare (To setup Husky hooks)
134
- 5. docker-compose up -d (To start DB/Infrastructure)
135
+ 5. docker-compose up -d${config.database !== 'None' ? ' db' : ''}${config.caching === 'Redis' ? ' redis' : ''}${config.communication === 'Kafka' ? ' kafka' : ''} (To start DB/Infrastructure)
135
136
  6. npm run dev (To start development server)
136
137
  7. npm test (To run tests)
137
138
  `);
@@ -52,6 +52,24 @@ export const renderProfessionalConfig = async (templatesDir, targetDir, config)
52
52
  const jestE2eTemplate = await fs.readFile(path.join(templatesDir, 'common', 'jest.e2e.config.js.ejs'), 'utf-8');
53
53
  const jestE2eContent = ejs.render(jestE2eTemplate, { ...config });
54
54
  await fs.writeFile(path.join(targetDir, 'jest.e2e.config.js'), jestE2eContent);
55
+
56
+ // 1. Setup Husky pre-commit (Always for Professional Standard)
57
+ const huskyDir = path.join(targetDir, '.husky');
58
+ await fs.ensureDir(huskyDir);
59
+ await fs.copy(path.join(templatesDir, 'common', '_husky', 'pre-commit'), path.join(huskyDir, 'pre-commit'));
60
+
61
+ // 2. Enterprise Security Hardening (Optional)
62
+ if (config.includeSecurity) {
63
+ await fs.copy(path.join(templatesDir, 'common', 'SECURITY.md'), path.join(targetDir, 'SECURITY.md'));
64
+
65
+ const sonarTemplate = await fs.readFile(path.join(templatesDir, 'common', 'sonar-project.properties.ejs'), 'utf-8');
66
+ const sonarContent = ejs.render(sonarTemplate, { ...config });
67
+ await fs.writeFile(path.join(targetDir, 'sonar-project.properties'), sonarContent);
68
+
69
+ const snykTemplate = await fs.readFile(path.join(templatesDir, 'common', '.snyk.ejs'), 'utf-8');
70
+ const snykContent = ejs.render(snykTemplate, { ...config });
71
+ await fs.writeFile(path.join(targetDir, '.snyk'), snykContent);
72
+ }
55
73
  };
56
74
 
57
75
  export const renderAiNativeFiles = async (templatesDir, targetDir, config) => {
@@ -80,10 +98,20 @@ export const renderAiNativeFiles = async (templatesDir, targetDir, config) => {
80
98
  };
81
99
 
82
100
  export const setupCiCd = async (templatesDir, targetDir, config) => {
83
- const { ciProvider } = config;
101
+ const { ciProvider, includeSecurity } = config;
84
102
  if (ciProvider === 'GitHub Actions') {
85
- await fs.ensureDir(path.join(targetDir, '.github/workflows'));
86
- await fs.copy(path.join(templatesDir, 'common', '_github/workflows/ci.yml'), path.join(targetDir, '.github/workflows/ci.yml'));
103
+ const workflowsDir = path.join(targetDir, '.github/workflows');
104
+ await fs.ensureDir(workflowsDir);
105
+
106
+ const ciTemplate = await fs.readFile(path.join(templatesDir, 'common', '_github/workflows/ci.yml.ejs'), 'utf-8');
107
+ const ciContent = ejs.render(ciTemplate, { ...config });
108
+ await fs.writeFile(path.join(workflowsDir, 'ci.yml'), ciContent);
109
+
110
+ if (includeSecurity) {
111
+ const securityTemplate = await fs.readFile(path.join(templatesDir, 'common', '_github/workflows/security.yml.ejs'), 'utf-8');
112
+ const securityContent = ejs.render(securityTemplate, { ...config });
113
+ await fs.writeFile(path.join(workflowsDir, 'security.yml'), securityContent);
114
+ }
87
115
  } else if (ciProvider === 'Jenkins') {
88
116
  const jenkinsTemplate = await fs.readFile(path.join(templatesDir, 'common', 'Jenkinsfile.ejs'), 'utf-8');
89
117
  const jenkinsContent = ejs.render(jenkinsTemplate, { ...config });
package/lib/prompts.js CHANGED
@@ -77,9 +77,24 @@ export const getProjectDetails = async (options = {}) => {
77
77
  choices: ['None', 'GitHub Actions', 'Jenkins', 'GitLab CI'],
78
78
  default: 'None',
79
79
  when: !options.ciProvider
80
+ },
81
+ {
82
+ type: 'select',
83
+ name: 'includeSecurity',
84
+ message: 'Include Enterprise Security Hardening (Big Tech Standard: Snyk, SonarQube)?',
85
+ choices: ['No', 'Yes'],
86
+ default: "No",
87
+ when: (answers) => !options.includeSecurity && (options.ciProvider || answers.ciProvider) !== 'None'
80
88
  }
81
89
  ];
82
90
 
83
91
  const answers = await inquirer.prompt(questions);
84
- return { ...options, ...answers };
92
+ const result = { ...options, ...answers };
93
+
94
+ // Normalize includeSecurity to boolean if it's a string from the select prompt
95
+ if (typeof result.includeSecurity === 'string') {
96
+ result.includeSecurity = result.includeSecurity === 'Yes';
97
+ }
98
+
99
+ return result;
85
100
  };