@codabytez/create-next-template 0.1.3 → 0.1.5

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
@@ -26,13 +26,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  // src/index.ts
27
27
  var p2 = __toESM(require("@clack/prompts"));
28
28
  var import_chalk2 = __toESM(require("chalk"));
29
- var import_path6 = __toESM(require("path"));
29
+ var import_path7 = __toESM(require("path"));
30
30
 
31
31
  // src/installer.ts
32
32
  var p = __toESM(require("@clack/prompts"));
33
33
  var import_chalk = __toESM(require("chalk"));
34
- var import_fs_extra5 = __toESM(require("fs-extra"));
35
- var import_path5 = __toESM(require("path"));
34
+ var import_fs_extra6 = __toESM(require("fs-extra"));
35
+ var import_path6 = __toESM(require("path"));
36
36
 
37
37
  // src/helpers/copy.ts
38
38
  var import_fs_extra = __toESM(require("fs-extra"));
@@ -42,6 +42,11 @@ async function copyTemplate(templateName, destPath) {
42
42
  const templatePath = import_path.default.join(TEMPLATES_DIR, templateName);
43
43
  if (!await import_fs_extra.default.pathExists(templatePath)) return;
44
44
  await import_fs_extra.default.copy(templatePath, destPath, { overwrite: true });
45
+ const bare = import_path.default.join(destPath, "gitignore");
46
+ const dot = import_path.default.join(destPath, ".gitignore");
47
+ if (await import_fs_extra.default.pathExists(bare)) {
48
+ await import_fs_extra.default.move(bare, dot, { overwrite: true });
49
+ }
45
50
  }
46
51
 
47
52
  // src/helpers/env.ts
@@ -243,6 +248,77 @@ export default function RootLayout({
243
248
  await import_fs_extra4.default.writeFile(import_path4.default.join(appDir, "layout.tsx"), layoutContent);
244
249
  }
245
250
 
251
+ // src/generators/readme.ts
252
+ var import_fs_extra5 = __toESM(require("fs-extra"));
253
+ var import_path5 = __toESM(require("path"));
254
+ var FEATURE_LABELS = {
255
+ animations: "Framer Motion",
256
+ dataFetching: "TanStack Query + Axios",
257
+ forms: "React Hook Form + Zod",
258
+ extraIcons: "Iconsax React",
259
+ auth: "Clerk",
260
+ prisma: "Prisma (PostgreSQL)",
261
+ convex: "Convex",
262
+ appwrite: "Appwrite",
263
+ ui: "shadcn/ui"
264
+ };
265
+ async function generateReadme(projectPath, projectName, packageManager, features) {
266
+ const featureList = features.filter((f) => FEATURE_LABELS[f]).map((f) => `- ${FEATURE_LABELS[f]}`).join("\n");
267
+ const hasPrisma = features.includes("prisma");
268
+ const hasConvex = features.includes("convex");
269
+ const hasAuth = features.includes("auth");
270
+ const hasShadcn = features.includes("ui");
271
+ const envSection = hasPrisma || hasConvex || hasAuth ? `
272
+ ## Environment Variables
273
+
274
+ Copy \`.env.example\` to \`.env\` and fill in the required values:
275
+
276
+ \`\`\`bash
277
+ cp .env.example .env
278
+ \`\`\`
279
+ ` : "";
280
+ const extraSteps = [];
281
+ if (hasShadcn) extraSteps.push(`npx shadcn@latest init`);
282
+ if (hasPrisma) extraSteps.push(`npx prisma migrate dev`);
283
+ if (hasConvex) extraSteps.push(`npx convex dev`);
284
+ const extraSection = extraSteps.length > 0 ? `
285
+ ## Additional Setup
286
+
287
+ \`\`\`bash
288
+ ${extraSteps.join("\n")}
289
+ \`\`\`
290
+ ` : "";
291
+ const content = `# ${projectName}
292
+
293
+ A [Next.js](https://nextjs.org) project bootstrapped with [create-next-template](https://github.com/codabytez/create-next-template).
294
+
295
+ ## Tech Stack
296
+
297
+ - [Next.js](https://nextjs.org)
298
+ - [TypeScript](https://www.typescriptlang.org)
299
+ - [Tailwind CSS](https://tailwindcss.com)
300
+ ${featureList ? featureList + "\n" : ""}
301
+ ## Getting Started
302
+
303
+ \`\`\`bash
304
+ ${packageManager} run dev
305
+ \`\`\`
306
+
307
+ Open [http://localhost:3000](http://localhost:3000) in your browser.
308
+ ${envSection}${extraSection}
309
+ ## Code Quality
310
+
311
+ This project uses ESLint, Prettier, and Husky pre-commit hooks to enforce consistent code style.
312
+
313
+ \`\`\`bash
314
+ ${packageManager} run lint # lint
315
+ ${packageManager} run format # format
316
+ ${packageManager} run check-types # type check
317
+ \`\`\`
318
+ `;
319
+ await import_fs_extra5.default.writeFile(import_path5.default.join(projectPath, "README.md"), content);
320
+ }
321
+
246
322
  // src/installer.ts
247
323
  var FEATURE_TEMPLATE_MAP = {
248
324
  animations: "animations",
@@ -264,7 +340,7 @@ async function runInstaller({
264
340
  }) {
265
341
  const s = p.spinner();
266
342
  if (!inPlace) {
267
- if (await import_fs_extra5.default.pathExists(projectPath)) {
343
+ if (await import_fs_extra6.default.pathExists(projectPath)) {
268
344
  const overwrite = await p.confirm({
269
345
  message: `Directory "${projectName}" already exists. Overwrite?`
270
346
  });
@@ -272,9 +348,9 @@ async function runInstaller({
272
348
  p.cancel("Operation cancelled");
273
349
  process.exit(0);
274
350
  }
275
- await import_fs_extra5.default.remove(projectPath);
351
+ await import_fs_extra6.default.remove(projectPath);
276
352
  }
277
- await import_fs_extra5.default.ensureDir(projectPath);
353
+ await import_fs_extra6.default.ensureDir(projectPath);
278
354
  }
279
355
  s.start("Scaffolding project structure");
280
356
  await copyTemplate("base", projectPath);
@@ -285,12 +361,13 @@ async function runInstaller({
285
361
  }
286
362
  }
287
363
  await generateLayout(projectPath, features);
364
+ await generateReadme(projectPath, projectName, packageManager, features);
288
365
  await mergeEnvExamples(projectPath, features);
289
- const huskyDir = import_path5.default.join(projectPath, ".husky");
366
+ const huskyDir = import_path6.default.join(projectPath, ".husky");
290
367
  for (const hook of ["pre-commit", "pre-push"]) {
291
- const hookPath = import_path5.default.join(huskyDir, hook);
292
- if (await import_fs_extra5.default.pathExists(hookPath)) {
293
- await import_fs_extra5.default.chmod(hookPath, 493);
368
+ const hookPath = import_path6.default.join(huskyDir, hook);
369
+ if (await import_fs_extra6.default.pathExists(hookPath)) {
370
+ await import_fs_extra6.default.chmod(hookPath, 493);
294
371
  }
295
372
  }
296
373
  s.stop("Project structure scaffolded");
@@ -307,6 +384,8 @@ async function runInstaller({
307
384
  }
308
385
  s.start("Initializing git repository");
309
386
  await runCommand("git", ["init"], projectPath);
387
+ await runCommand("git", ["rm", "-r", "--cached", "--quiet", "."], projectPath).catch(() => {
388
+ });
310
389
  await runCommand("git", ["add", "-A"], projectPath);
311
390
  await runCommand(
312
391
  "git",
@@ -361,7 +440,7 @@ async function main() {
361
440
  p2.intro(import_chalk2.default.bgCyan(import_chalk2.default.black(" create-next-template ")));
362
441
  const dirArg = args.find((a) => !a.startsWith("-"));
363
442
  const inPlace = dirArg === ".";
364
- const defaultName = inPlace ? import_path6.default.basename(process.cwd()) : dirArg ?? void 0;
443
+ const defaultName = inPlace ? import_path7.default.basename(process.cwd()) : dirArg ?? void 0;
365
444
  const projectName = await p2.text({
366
445
  message: "What is your project name?",
367
446
  placeholder: "my-next-app",
@@ -425,7 +504,7 @@ async function main() {
425
504
  `You selected multiple databases (${dbChoices.join(", ")}). This is supported but may require manual configuration.`
426
505
  );
427
506
  }
428
- const projectPath = inPlace ? process.cwd() : import_path6.default.resolve(process.cwd(), projectName);
507
+ const projectPath = inPlace ? process.cwd() : import_path7.default.resolve(process.cwd(), projectName);
429
508
  await runInstaller({
430
509
  projectName,
431
510
  projectPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codabytez/create-next-template",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "CLI to scaffold Next.js projects with your preferred stack",
5
5
  "bin": {
6
6
  "create-next-template": "./dist/index.js"
@@ -0,0 +1,78 @@
1
+ # ===========================
2
+ # Dependencies
3
+ # ===========================
4
+ node_modules/
5
+ .pnp
6
+ .pnp.js
7
+ .yarn/install-state.gz
8
+
9
+ # ===========================
10
+ # Next.js
11
+ # ===========================
12
+ .next/
13
+ out/
14
+ build/
15
+
16
+ # ===========================
17
+ # Environment variables
18
+ # ===========================
19
+ .env
20
+ .env.local
21
+ .env.development.local
22
+ .env.test.local
23
+ .env.production.local
24
+
25
+ # ===========================
26
+ # Package manager artifacts
27
+ # ===========================
28
+ npm-debug.log*
29
+ yarn-debug.log*
30
+ yarn-error.log*
31
+ pnpm-debug.log*
32
+ .pnpm-store/
33
+
34
+ # ===========================
35
+ # OS artifacts
36
+ # ===========================
37
+ .DS_Store
38
+ .DS_Store?
39
+ ._*
40
+ .Spotlight-V100
41
+ .Trashes
42
+ Thumbs.db
43
+ ehthumbs.db
44
+ Desktop.ini
45
+
46
+ # ===========================
47
+ # IDE / Editor
48
+ # ===========================
49
+ .vscode/
50
+ .idea/
51
+ *.suo
52
+ *.ntvs*
53
+ *.njsproj
54
+ *.sln
55
+ *.sw?
56
+ *.iml
57
+ .history/
58
+
59
+ # ===========================
60
+ # TypeScript
61
+ # ===========================
62
+ *.tsbuildinfo
63
+ next-env.d.ts
64
+
65
+ # ===========================
66
+ # Testing
67
+ # ===========================
68
+ coverage/
69
+ .nyc_output/
70
+ playwright-report/
71
+ test-results/
72
+
73
+ # ===========================
74
+ # Misc
75
+ # ===========================
76
+ *.pem
77
+ .vercel
78
+ *.local