create-nextjs-cms 0.5.28 → 0.5.29

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/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import fs from 'fs-extra';
3
3
  import { execSync } from 'node:child_process';
4
4
  import { fileURLToPath } from 'node:url';
5
+ import { randomBytes } from 'node:crypto';
5
6
  import path, { dirname, resolve, relative, basename } from 'node:path';
6
7
  import { Command } from 'commander';
7
8
  import prompts from 'prompts';
@@ -166,6 +167,37 @@ export default hasItemsSection({
166
167
  await fs.writeFile(blogSectionPath, blogSectionContent, 'utf-8');
167
168
  console.log('✅ Blog section created successfully!');
168
169
  }
170
+ /**
171
+ * Generates a random secret string using crypto.randomBytes
172
+ */
173
+ function generateSecret() {
174
+ return randomBytes(32).toString('hex');
175
+ }
176
+ /**
177
+ * Updates .env file with generated random secrets
178
+ */
179
+ async function updateEnvSecrets(targetDir) {
180
+ const envPath = path.join(targetDir, '.env');
181
+ if (!(await fs.pathExists(envPath))) {
182
+ console.warn('⚠️ No .env file found; skipping secret generation.');
183
+ return;
184
+ }
185
+ try {
186
+ let envContent = await fs.readFile(envPath, 'utf-8');
187
+ // Replace placeholder secrets with generated ones
188
+ envContent = envContent.replace(/ACCESS_TOKEN_SECRET=.*/, `ACCESS_TOKEN_SECRET=${generateSecret()}`);
189
+ envContent = envContent.replace(/REFRESH_TOKEN_SECRET=.*/, `REFRESH_TOKEN_SECRET=${generateSecret()}`);
190
+ envContent = envContent.replace(/CSRF_TOKEN_SECRET=.*/, `CSRF_TOKEN_SECRET=${generateSecret()}`);
191
+ envContent = envContent.replace(/ACCESS_TOKEN_EXPIRATION=.*/, 'ACCESS_TOKEN_EXPIRATION=2h');
192
+ envContent = envContent.replace(/REFRESH_TOKEN_EXPIRATION=.*/, 'REFRESH_TOKEN_EXPIRATION=1y');
193
+ await fs.writeFile(envPath, envContent, 'utf-8');
194
+ console.log('🔐 Generated random secrets and set token expirations in .env file');
195
+ }
196
+ catch (e) {
197
+ console.warn('⚠️ Could not update .env secrets automatically.');
198
+ console.warn(` Error: ${e instanceof Error ? e.message : 'Unknown error'}`);
199
+ }
200
+ }
169
201
  async function createNextjsCms() {
170
202
  console.log('🚀 Welcome to NextJS CMS!');
171
203
  console.log('Creating your new CMS project...\n');
@@ -291,6 +323,8 @@ async function createNextjsCms() {
291
323
  errorOnExist: false,
292
324
  });
293
325
  console.log('✅ Template copied successfully!');
326
+ // Generate random secrets for .env file
327
+ await updateEnvSecrets(options.targetDir);
294
328
  // npm excludes .gitignore from packages, so we rename it back from _gitignore
295
329
  const gitignoreTemplatePath = path.join(options.targetDir, '_gitignore');
296
330
  const gitignorePath = path.join(options.targetDir, '.gitignore');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nextjs-cms",
3
- "version": "0.5.28",
3
+ "version": "0.5.29",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "create-nextjs-cms": "./dist/index.js"
@@ -26,8 +26,8 @@
26
26
  "tsx": "^4.20.6",
27
27
  "typescript": "^5.9.2",
28
28
  "@lzcms/eslint-config": "0.3.0",
29
- "@lzcms/tsconfig": "0.1.0",
30
- "@lzcms/prettier-config": "0.1.0"
29
+ "@lzcms/prettier-config": "0.1.0",
30
+ "@lzcms/tsconfig": "0.1.0"
31
31
  },
32
32
  "prettier": "@lzcms/prettier-config",
33
33
  "scripts": {
@@ -70,7 +70,7 @@
70
70
  "nanoid": "^5.1.2",
71
71
  "next": "^15.5.5",
72
72
  "next-themes": "^0.4.6",
73
- "nextjs-cms": "0.5.28",
73
+ "nextjs-cms": "0.5.29",
74
74
  "plaiceholder": "^3.0.0",
75
75
  "prettier-plugin-tailwindcss": "^0.7.2",
76
76
  "qrcode": "^1.5.4",
@@ -103,7 +103,7 @@
103
103
  "eslint-config-prettier": "^10.0.1",
104
104
  "eslint-plugin-prettier": "^5.2.3",
105
105
  "fs-extra": "^11.3.3",
106
- "nextjs-cms-kit": "0.5.28",
106
+ "nextjs-cms-kit": "0.5.29",
107
107
  "postcss": "^8.5.1",
108
108
  "prettier": "3.5.0",
109
109
  "tailwindcss": "^4.1.18",