@codabytez/create-next-template 0.1.4 → 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.
Files changed (2) hide show
  1. package/dist/index.js +86 -12
  2. package/package.json +1 -1
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"));
@@ -248,6 +248,77 @@ export default function RootLayout({
248
248
  await import_fs_extra4.default.writeFile(import_path4.default.join(appDir, "layout.tsx"), layoutContent);
249
249
  }
250
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
+
251
322
  // src/installer.ts
252
323
  var FEATURE_TEMPLATE_MAP = {
253
324
  animations: "animations",
@@ -269,7 +340,7 @@ async function runInstaller({
269
340
  }) {
270
341
  const s = p.spinner();
271
342
  if (!inPlace) {
272
- if (await import_fs_extra5.default.pathExists(projectPath)) {
343
+ if (await import_fs_extra6.default.pathExists(projectPath)) {
273
344
  const overwrite = await p.confirm({
274
345
  message: `Directory "${projectName}" already exists. Overwrite?`
275
346
  });
@@ -277,9 +348,9 @@ async function runInstaller({
277
348
  p.cancel("Operation cancelled");
278
349
  process.exit(0);
279
350
  }
280
- await import_fs_extra5.default.remove(projectPath);
351
+ await import_fs_extra6.default.remove(projectPath);
281
352
  }
282
- await import_fs_extra5.default.ensureDir(projectPath);
353
+ await import_fs_extra6.default.ensureDir(projectPath);
283
354
  }
284
355
  s.start("Scaffolding project structure");
285
356
  await copyTemplate("base", projectPath);
@@ -290,12 +361,13 @@ async function runInstaller({
290
361
  }
291
362
  }
292
363
  await generateLayout(projectPath, features);
364
+ await generateReadme(projectPath, projectName, packageManager, features);
293
365
  await mergeEnvExamples(projectPath, features);
294
- const huskyDir = import_path5.default.join(projectPath, ".husky");
366
+ const huskyDir = import_path6.default.join(projectPath, ".husky");
295
367
  for (const hook of ["pre-commit", "pre-push"]) {
296
- const hookPath = import_path5.default.join(huskyDir, hook);
297
- if (await import_fs_extra5.default.pathExists(hookPath)) {
298
- 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);
299
371
  }
300
372
  }
301
373
  s.stop("Project structure scaffolded");
@@ -312,6 +384,8 @@ async function runInstaller({
312
384
  }
313
385
  s.start("Initializing git repository");
314
386
  await runCommand("git", ["init"], projectPath);
387
+ await runCommand("git", ["rm", "-r", "--cached", "--quiet", "."], projectPath).catch(() => {
388
+ });
315
389
  await runCommand("git", ["add", "-A"], projectPath);
316
390
  await runCommand(
317
391
  "git",
@@ -366,7 +440,7 @@ async function main() {
366
440
  p2.intro(import_chalk2.default.bgCyan(import_chalk2.default.black(" create-next-template ")));
367
441
  const dirArg = args.find((a) => !a.startsWith("-"));
368
442
  const inPlace = dirArg === ".";
369
- 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;
370
444
  const projectName = await p2.text({
371
445
  message: "What is your project name?",
372
446
  placeholder: "my-next-app",
@@ -430,7 +504,7 @@ async function main() {
430
504
  `You selected multiple databases (${dbChoices.join(", ")}). This is supported but may require manual configuration.`
431
505
  );
432
506
  }
433
- 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);
434
508
  await runInstaller({
435
509
  projectName,
436
510
  projectPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codabytez/create-next-template",
3
- "version": "0.1.4",
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"