@sachin-thakur/create-nodejs-app 1.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.
@@ -0,0 +1,277 @@
1
+ function generateReadme(projectName, config) {
2
+ const isTypeScript = config.language === "typescript";
3
+
4
+ return `# ${projectName}
5
+
6
+ A production-ready ${config.projectType.toUpperCase()} application built with Node.js and ${
7
+ isTypeScript ? "TypeScript" : "JavaScript"
8
+ }.
9
+
10
+ ## ๐Ÿš€ Features
11
+
12
+ - โšก **${
13
+ config.language === "typescript" ? "TypeScript" : "JavaScript"
14
+ }** - Type safety and modern syntax
15
+ - ๐Ÿ—๏ธ **${config.architecture.toUpperCase()} Architecture** - Clean and maintainable code structure
16
+ ${
17
+ config.database !== "none"
18
+ ? `- ๐Ÿ—„๏ธ **${
19
+ config.database.charAt(0).toUpperCase() + config.database.slice(1)
20
+ }** - Database integration`
21
+ : ""
22
+ }
23
+ ${
24
+ config.features.includes("auth")
25
+ ? "- ๐Ÿ” **JWT Authentication** - Secure user authentication"
26
+ : ""
27
+ }
28
+ ${
29
+ config.features.includes("validation")
30
+ ? "- โœ… **Request Validation** - Input validation with Zod"
31
+ : ""
32
+ }
33
+ ${
34
+ config.features.includes("logging")
35
+ ? "- ๐Ÿ“ **Logging** - Structured logging with Winston"
36
+ : ""
37
+ }
38
+ ${
39
+ config.features.includes("swagger")
40
+ ? "- ๐Ÿ“š **API Documentation** - Auto-generated Swagger docs"
41
+ : ""
42
+ }
43
+ ${
44
+ config.features.includes("rate-limit")
45
+ ? "- ๐Ÿ›ก๏ธ **Rate Limiting** - API rate limiting protection"
46
+ : ""
47
+ }
48
+ ${
49
+ config.features.includes("cors")
50
+ ? "- ๐ŸŒ **CORS** - Cross-origin resource sharing configuration"
51
+ : ""
52
+ }
53
+ ${
54
+ config.features.includes("cache")
55
+ ? "- โšก **Redis Caching** - Fast data caching"
56
+ : ""
57
+ }
58
+ ${
59
+ config.features.includes("jobs")
60
+ ? "- ๐Ÿ”„ **Background Jobs** - Task queue with Bull"
61
+ : ""
62
+ }
63
+ ${
64
+ config.features.includes("email")
65
+ ? "- ๐Ÿ“ง **Email Service** - Email sending with Nodemailer"
66
+ : ""
67
+ }
68
+ ${
69
+ config.features.includes("file-upload")
70
+ ? "- ๐Ÿ“ **File Upload** - File upload handling"
71
+ : ""
72
+ }
73
+ ${
74
+ config.testing !== "none"
75
+ ? `- ๐Ÿงช **Testing** - Unit and integration tests with ${
76
+ config.testing.charAt(0).toUpperCase() + config.testing.slice(1)
77
+ }`
78
+ : ""
79
+ }
80
+ ${config.docker ? "- ๐Ÿณ **Docker** - Containerization ready" : ""}
81
+ ${config.cicd ? "- ๐Ÿ”„ **CI/CD** - GitHub Actions workflow" : ""}
82
+
83
+ ## ๐Ÿ“‹ Prerequisites
84
+
85
+ - Node.js >= 16.x
86
+ - npm or yarn
87
+ ${config.database === "postgresql" ? "- PostgreSQL >= 13.x" : ""}
88
+ ${config.database === "mongodb" ? "- MongoDB >= 5.x" : ""}
89
+ ${config.database === "mysql" ? "- MySQL >= 8.x" : ""}
90
+ ${
91
+ config.features.includes("cache") || config.features.includes("jobs")
92
+ ? "- Redis >= 6.x"
93
+ : ""
94
+ }
95
+ ${config.docker ? "- Docker and Docker Compose (optional)" : ""}
96
+
97
+ ## ๐Ÿ› ๏ธ Installation
98
+
99
+ 1. Clone the repository:
100
+ \`\`\`bash
101
+ git clone <repository-url>
102
+ cd ${projectName}
103
+ \`\`\`
104
+
105
+ 2. Install dependencies:
106
+ \`\`\`bash
107
+ npm install
108
+ \`\`\`
109
+
110
+ 3. Set up environment variables:
111
+ \`\`\`bash
112
+ cp .env.example .env
113
+ \`\`\`
114
+ Edit the \`.env\` file with your configuration.
115
+
116
+ ${
117
+ config.database !== "none"
118
+ ? `4. Set up the database:
119
+ \`\`\`bash
120
+ # Create database
121
+ ${
122
+ config.database === "postgresql"
123
+ ? "createdb myapp_db"
124
+ : config.database === "mongodb"
125
+ ? "# MongoDB will create the database automatically"
126
+ : "# Create MySQL database"
127
+ }
128
+ \`\`\`
129
+ `
130
+ : ""
131
+ }
132
+
133
+ ## ๐Ÿš€ Running the Application
134
+
135
+ ### Development mode:
136
+ \`\`\`bash
137
+ npm run dev
138
+ \`\`\`
139
+
140
+ ### Production mode:
141
+ \`\`\`bash
142
+ ${isTypeScript ? "npm run build\n" : ""}npm start
143
+ \`\`\`
144
+
145
+ ${
146
+ config.docker
147
+ ? `### Using Docker:
148
+ \`\`\`bash
149
+ docker-compose up
150
+ \`\`\`
151
+ `
152
+ : ""
153
+ }
154
+
155
+ The application will be running at \`http://localhost:3000\`
156
+
157
+ ${
158
+ config.features.includes("swagger")
159
+ ? `## ๐Ÿ“š API Documentation
160
+
161
+ Once the server is running, visit:
162
+ - Swagger UI: \`http://localhost:3000/api-docs\`
163
+ `
164
+ : ""
165
+ }
166
+
167
+ ## ๐Ÿงช Testing
168
+
169
+ ${
170
+ config.testing !== "none"
171
+ ? `Run tests:
172
+ \`\`\`bash
173
+ npm test
174
+ \`\`\`
175
+
176
+ Run tests in watch mode:
177
+ \`\`\`bash
178
+ npm run test:watch
179
+ \`\`\`
180
+
181
+ Generate coverage report:
182
+ \`\`\`bash
183
+ npm run test:coverage
184
+ \`\`\`
185
+ `
186
+ : "Testing framework not included. Add your preferred testing framework."
187
+ }
188
+
189
+ ## ๐Ÿ“ Project Structure
190
+
191
+ \`\`\`
192
+ ${projectName}/
193
+ โ”œโ”€โ”€ src/
194
+ ${
195
+ config.architecture === "mvc"
196
+ ? `โ”‚ โ”œโ”€โ”€ config/ # Configuration files
197
+ โ”‚ โ”œโ”€โ”€ controllers/ # Request handlers
198
+ โ”‚ โ”œโ”€โ”€ models/ # Data models
199
+ โ”‚ โ”œโ”€โ”€ routes/ # API routes
200
+ โ”‚ โ”œโ”€โ”€ middlewares/ # Custom middlewares
201
+ โ”‚ โ”œโ”€โ”€ services/ # Business logic
202
+ โ”‚ โ”œโ”€โ”€ utils/ # Utility functions
203
+ โ”‚ โ””โ”€โ”€ index.${isTypeScript ? "ts" : "js"} # Application entry point`
204
+ : ""
205
+ }
206
+ ${
207
+ config.architecture === "clean"
208
+ ? `โ”‚ โ”œโ”€โ”€ domain/ # Business entities
209
+ โ”‚ โ”œโ”€โ”€ application/ # Use cases
210
+ โ”‚ โ”œโ”€โ”€ infrastructure/ # External services
211
+ โ”‚ โ”œโ”€โ”€ presentation/ # Controllers & routes
212
+ โ”‚ โ””โ”€โ”€ index.${isTypeScript ? "ts" : "js"} # Application entry point`
213
+ : ""
214
+ }
215
+ ${
216
+ config.architecture === "feature-based"
217
+ ? `โ”‚ โ”œโ”€โ”€ features/ # Feature modules
218
+ โ”‚ โ”œโ”€โ”€ shared/ # Shared utilities
219
+ โ”‚ โ”œโ”€โ”€ config/ # Configuration
220
+ โ”‚ โ””โ”€โ”€ index.${isTypeScript ? "ts" : "js"} # Application entry point`
221
+ : ""
222
+ }
223
+ โ”œโ”€โ”€ tests/ # Test files
224
+ ${
225
+ isTypeScript
226
+ ? "โ”œโ”€โ”€ dist/ # Compiled JavaScript (generated)\n"
227
+ : ""
228
+ }โ”œโ”€โ”€ .env.example # Environment variables template
229
+ โ”œโ”€โ”€ .gitignore
230
+ โ”œโ”€โ”€ package.json
231
+ ${isTypeScript ? "โ”œโ”€โ”€ tsconfig.json # TypeScript configuration\n" : ""}${
232
+ config.docker ? "โ”œโ”€โ”€ Dockerfile\nโ”œโ”€โ”€ docker-compose.yml\n" : ""
233
+ }โ””โ”€โ”€ README.md
234
+ \`\`\`
235
+
236
+ ## ๐Ÿ”ง Available Scripts
237
+
238
+ - \`npm start\` - Start production server
239
+ - \`npm run dev\` - Start development server with hot reload
240
+ ${
241
+ isTypeScript ? "- `npm run build` - Build for production\n" : ""
242
+ }- \`npm run lint\` - Run ESLint
243
+ - \`npm run lint:fix\` - Fix ESLint errors
244
+ - \`npm run format\` - Format code with Prettier
245
+ ${
246
+ config.testing !== "none"
247
+ ? "- `npm test` - Run tests\n- `npm run test:watch` - Run tests in watch mode\n- `npm run test:coverage` - Generate coverage report"
248
+ : ""
249
+ }
250
+
251
+ ## ๐ŸŒ Environment Variables
252
+
253
+ See \`.env.example\` for all available environment variables.
254
+
255
+ ## ๐Ÿค Contributing
256
+
257
+ 1. Fork the repository
258
+ 2. Create your feature branch (\`git checkout -b feature/amazing-feature\`)
259
+ 3. Commit your changes (\`git commit -m 'Add some amazing feature'\`)
260
+ 4. Push to the branch (\`git push origin feature/amazing-feature\`)
261
+ 5. Open a Pull Request
262
+
263
+ ## ๐Ÿ“ License
264
+
265
+ This project is licensed under the MIT License.
266
+
267
+ ## ๐Ÿ‘จโ€๐Ÿ’ป Author
268
+
269
+ Your Name
270
+
271
+ ## ๐Ÿ™ Acknowledgments
272
+
273
+ - Generated with [create-nodejs-app](https://github.com/yourusername/create-nodejs-app)
274
+ `;
275
+ }
276
+
277
+ module.exports = { generateReadme };
package/test.sh ADDED
@@ -0,0 +1,40 @@
1
+ #!/bin/bash
2
+
3
+ # Quick test script for create-nodejs-app
4
+ # This script tests the CLI by creating a sample project
5
+
6
+ echo "๐Ÿงช Testing create-nodejs-app CLI..."
7
+ echo ""
8
+
9
+ # Create a temporary directory
10
+ TEST_DIR="/tmp/test-create-nodejs-app-$(date +%s)"
11
+ mkdir -p "$TEST_DIR"
12
+ cd "$TEST_DIR"
13
+
14
+ echo "๐Ÿ“ Test directory: $TEST_DIR"
15
+ echo ""
16
+
17
+ # Run the CLI (you'll need to answer the prompts)
18
+ echo "๐Ÿš€ Running CLI..."
19
+ echo "Please answer the prompts to create a test project"
20
+ echo ""
21
+
22
+ node /home/claude/create-nodejs-app/bin/cli.js test-project
23
+
24
+ # Check if project was created
25
+ if [ -d "test-project" ]; then
26
+ echo ""
27
+ echo "โœ… Project created successfully!"
28
+ echo ""
29
+ echo "๐Ÿ“ฆ Project structure:"
30
+ tree -L 2 test-project/ || ls -la test-project/
31
+ echo ""
32
+ echo "๐Ÿ“„ Files created:"
33
+ find test-project -type f | head -20
34
+ echo ""
35
+ echo "๐ŸŽ‰ Test completed! Check the project at: $TEST_DIR/test-project"
36
+ else
37
+ echo ""
38
+ echo "โŒ Project creation failed!"
39
+ exit 1
40
+ fi