create-express-kickstart 1.0.2 → 1.1.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 (2) hide show
  1. package/bin/cli.js +35 -8
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -65,6 +65,13 @@ async function init() {
65
65
  installPinoPretty = (await question('Include pino-pretty for clean development logs? [Y/n] ')).toLowerCase() !== 'n';
66
66
  }
67
67
 
68
+ const packageManagerChoice = await question('\nšŸ‘‰ Which package manager would you like to use? [npm/yarn/pnpm/bun] (default: npm): ');
69
+ const packageManager = ['yarn', 'pnpm', 'bun'].includes(packageManagerChoice.trim().toLowerCase())
70
+ ? packageManagerChoice.trim().toLowerCase()
71
+ : 'npm';
72
+
73
+ const initGit = (await question('\nšŸ‘‰ Initialize a git repository? [Y/n] ')).toLowerCase() !== 'n';
74
+
68
75
  rl.close();
69
76
 
70
77
  console.log(`\nšŸš€ Creating a new Node.js Express API in ${projectPath}...`);
@@ -128,13 +135,13 @@ async function init() {
128
135
  packageJsonTemplate.scripts.format = "prettier --write \"src/**/*.{js,json}\"";
129
136
  }
130
137
 
131
- // Remove the readline dependency from the generated boilerplate if mistakenly mixed
138
+ // Write package.json
132
139
  fs.writeFileSync(
133
140
  path.join(projectPath, 'package.json'),
134
141
  JSON.stringify(packageJsonTemplate, null, 2)
135
142
  );
136
143
 
137
- // 4. Install Dependencies
144
+ // Install Dependencies
138
145
  const dependenciesToInstall = Object.keys(deps).filter(dep => deps[dep] && dep !== 'prettier');
139
146
  if (deps['pino-http']) {
140
147
  dependenciesToInstall.push('pino');
@@ -148,30 +155,50 @@ async function init() {
148
155
 
149
156
  console.log(`\nā³ Installing selected core dependencies (${dependenciesToInstall.join(', ')}). This might take a minute...`);
150
157
  try {
158
+ let installCmd = packageManager === 'yarn' ? 'yarn add'
159
+ : packageManager === 'pnpm' ? 'pnpm add'
160
+ : packageManager === 'bun' ? 'bun add'
161
+ : 'npm install';
162
+
163
+ let installDevCmd = packageManager === 'yarn' ? 'yarn add -D'
164
+ : packageManager === 'pnpm' ? 'pnpm add -D'
165
+ : packageManager === 'bun' ? 'bun add -d'
166
+ : 'npm install --save-dev';
167
+
151
168
  if (depString) {
152
- execSync(`npm install ${depString}`, {
169
+ execSync(`${installCmd} ${depString}`, {
153
170
  cwd: projectPath,
154
171
  stdio: 'inherit'
155
172
  });
156
173
  }
157
174
 
158
175
  console.log(`\nā³ Installing latest dev dependencies (${devDepString})...`);
159
- execSync(`npm install ${devDepString} --save-dev`, {
176
+ execSync(`${installDevCmd} ${devDepString}`, {
160
177
  cwd: projectPath,
161
178
  stdio: 'inherit'
162
179
  });
163
180
 
181
+ if (initGit) {
182
+ console.log(`\n🌱 Initializing Git repository...`);
183
+ execSync('git init', { cwd: projectPath, stdio: 'inherit' });
184
+ // Create .gitignore
185
+ const gitignoreContent = "node_modules\n.env\ndist\nbuild\ncoverage\n";
186
+ fs.writeFileSync(path.join(projectPath, '.gitignore'), gitignoreContent);
187
+ execSync('git add .', { cwd: projectPath, stdio: 'inherit' });
188
+ execSync('git commit -m "initial commit"', { cwd: projectPath, stdio: 'inherit' });
189
+ }
190
+
164
191
  console.log(`\nāœ… Success! Created "${projectName}" at ${projectPath}`);
165
192
  console.log('\nInside that directory, you can run several commands:');
166
- console.log('\n npm run dev');
193
+ console.log(`\n ${packageManager === 'npm' ? 'npm run' : packageManager} dev`);
167
194
  console.log(' Starts the development server on localhost.');
168
- console.log('\n npm start');
195
+ console.log(`\n ${packageManager === 'npm' ? 'npm' : packageManager} start`);
169
196
  console.log(' Starts the production server.');
170
197
  console.log('\nWe suggest that you begin by typing:');
171
198
  console.log(`\n cd ${projectName}`);
172
- console.log(' npm run dev\n');
199
+ console.log(` ${packageManager === 'npm' ? 'npm run' : packageManager} dev\n`);
173
200
  } catch (err) {
174
- console.error('\nāŒ Failed to install dependencies. You may need to run npm install manually inside the folder.', err);
201
+ console.error('\nāŒ Failed to install dependencies. You may need to install them manually inside the folder.', err);
175
202
  }
176
203
  }
177
204
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-express-kickstart",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Production-ready CLI starter for Express APIs",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {