create-express-kickstart 1.2.11 → 1.3.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.
Files changed (2) hide show
  1. package/bin/cli.js +34 -7
  2. package/package.json +5 -2
package/bin/cli.js CHANGED
@@ -56,7 +56,7 @@ async function init() {
56
56
  'cookie-parser': (await question('Include cookie-parser? [Y/n] ')).toLowerCase() !== 'n',
57
57
  'pino-http': (await question('Include Pino (HTTP Logger)? [Y/n] ')).toLowerCase() !== 'n',
58
58
  'express-rate-limit': (await question('Include Rate Limiting? [Y/n] ')).toLowerCase() !== 'n',
59
- dotenv: (await question('Include dotenv (Environment variables)? [Y/n] ')).toLowerCase() !== 'n',
59
+ dotenv: (await question('Include dotenvx (Environment variables)? [Y/n] ')).toLowerCase() !== 'n',
60
60
  prettier: (await question('Include Prettier (Code formatter)? [Y/n] ')).toLowerCase() !== 'n'
61
61
  };
62
62
 
@@ -111,7 +111,7 @@ async function init() {
111
111
  const envExamplePath = path.join(__dirname, '..', '.env.example');
112
112
  if (fs.existsSync(envExamplePath)) {
113
113
  fs.copyFileSync(envExamplePath, path.join(projectPath, '.env.example'));
114
- fs.copyFileSync(envExamplePath, path.join(projectPath, '.env'));
114
+ fs.copyFileSync(envExamplePath, path.join(projectPath, '.env.local'));
115
115
  }
116
116
 
117
117
  if (initDocker) {
@@ -157,7 +157,7 @@ JWT_SECRET=supersecretjwtkey123
157
157
  JWT_EXPIRES_IN=1d
158
158
  `;
159
159
  fs.appendFileSync(path.join(projectPath, '.env.example'), authEnvConfig);
160
- fs.appendFileSync(path.join(projectPath, '.env'), authEnvConfig);
160
+ fs.appendFileSync(path.join(projectPath, '.env.local'), authEnvConfig);
161
161
 
162
162
  const utilsPath = path.join(projectPath, 'src', 'utils');
163
163
  if (!fs.existsSync(utilsPath)) {
@@ -270,8 +270,8 @@ export const verifyToken = (token) => {
270
270
  main: "src/server.js",
271
271
  type: "module",
272
272
  scripts: {
273
- "start": "node src/server.js",
274
- "dev": deps.dotenv ? "nodemon -r dotenv/config src/server.js" : "nodemon src/server.js"
273
+ "start": deps.dotenv ? "dotenvx run -f .env.local -- node src/server.js" : "node src/server.js",
274
+ "dev": deps.dotenv ? "dotenvx run -f .env.local -- nodemon src/server.js" : "nodemon src/server.js"
275
275
  },
276
276
  imports: {
277
277
  "#*": "./src/*"
@@ -297,6 +297,7 @@ export const verifyToken = (token) => {
297
297
 
298
298
  // Install Dependencies
299
299
  const dependenciesToInstall = Object.keys(deps).filter(dep => deps[dep] && dep !== 'prettier' && dep !== 'dotenv');
300
+ if (deps.dotenv) dependenciesToInstall.push('@dotenvx/dotenvx');
300
301
  if (deps['pino-http']) {
301
302
  dependenciesToInstall.push('pino');
302
303
  }
@@ -306,7 +307,6 @@ export const verifyToken = (token) => {
306
307
 
307
308
  const devDependenciesToInstall = ['nodemon'];
308
309
  if (deps.prettier) devDependenciesToInstall.push('prettier');
309
- if (deps.dotenv) devDependenciesToInstall.push('dotenv');
310
310
  if (installPinoPretty) devDependenciesToInstall.push('pino-pretty');
311
311
  if (initTests) {
312
312
  devDependenciesToInstall.push('jest', 'supertest');
@@ -336,11 +336,38 @@ export const verifyToken = (token) => {
336
336
  const installTriggerCmd = packageManager === 'npm' ? 'npm install' : `${packageManager} install`;
337
337
  execSync(installTriggerCmd, execConfig);
338
338
 
339
+ // Update package.json with the actual installed versions instead of "latest"
340
+ try {
341
+ const installedPackageJson = JSON.parse(fs.readFileSync(finalPackageJsonPath, 'utf8'));
342
+
343
+ const getInstalledVersion = (dep) => {
344
+ try {
345
+ const depPkgPath = path.join(projectPath, 'node_modules', dep, 'package.json');
346
+ const depPkgCode = JSON.parse(fs.readFileSync(depPkgPath, 'utf8'));
347
+ return `^${depPkgCode.version}`;
348
+ } catch (err) {
349
+ return 'latest';
350
+ }
351
+ };
352
+
353
+ dependenciesToInstall.forEach(d => {
354
+ installedPackageJson.dependencies[d] = getInstalledVersion(d);
355
+ });
356
+
357
+ devDependenciesToInstall.forEach(d => {
358
+ installedPackageJson.devDependencies[d] = getInstalledVersion(d);
359
+ });
360
+
361
+ fs.writeFileSync(finalPackageJsonPath, JSON.stringify(installedPackageJson, null, 2));
362
+ } catch (err) {
363
+ // Silently fall back to 'latest' if parsing fails
364
+ }
365
+
339
366
  if (initGit) {
340
367
  console.log(`\n Initializing Git repository...`);
341
368
  execSync('git init', { cwd: projectPath, stdio: 'inherit' });
342
369
  // Create .gitignore
343
- const gitignoreContent = "node_modules\n.env\ndist\nbuild\ncoverage\n";
370
+ const gitignoreContent = "node_modules\n.env\n.env.keys\n.env.local\ndist\nbuild\ncoverage\n";
344
371
  fs.writeFileSync(path.join(projectPath, '.gitignore'), gitignoreContent);
345
372
  execSync('git add .', { cwd: projectPath, stdio: 'inherit' });
346
373
  execSync('git commit -m "initial commit"', { cwd: projectPath, stdio: 'inherit' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-express-kickstart",
3
- "version": "1.2.11",
3
+ "version": "1.3.1",
4
4
  "description": "Production-ready CLI starter for Express APIs",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {
@@ -28,5 +28,8 @@
28
28
  "bugs": {
29
29
  "url": "https://github.com/aasifashraf/create-express-kickstart/issues"
30
30
  },
31
- "homepage": "https://github.com/aasifashraf/create-express-kickstart#readme"
31
+ "homepage": "https://github.com/aasifashraf/create-express-kickstart#readme",
32
+ "dependencies": {
33
+ "@dotenvx/dotenvx": "^1.52.0"
34
+ }
32
35
  }