create-nelsonlai-app 0.1.0 → 0.2.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.
@@ -1,8 +1,10 @@
1
1
  import path from "node:path";
2
2
  import { execa } from "execa";
3
- // src/actions/install-dependencies.ts
3
+ // src/actions/setup-commands.ts
4
4
  function formatSetupCommands(directory, commands) {
5
- const steps = commands.map((args) => ` pnpm ${args.join(" ")}`);
5
+ const steps = commands.map((command) => {
6
+ return ` ${command.map((arg) => arg.includes(" ") ? `"${arg}"` : arg).join(" ")}`;
7
+ });
6
8
  const relative = path.relative(process.cwd(), directory);
7
9
  if (relative) {
8
10
  if (process.platform === "win32") steps.unshift(` Set-Location -LiteralPath '${relative.replaceAll("'", "''")}'`);
@@ -14,9 +16,9 @@ function formatSetupCommands(directory, commands) {
14
16
  }
15
17
  return steps.join("\n");
16
18
  }
17
- async function installDependencies(directory, commands) {
18
- for (const [index, args] of commands.entries()) try {
19
- await execa("pnpm", args, {
19
+ async function runSetupCommands(directory, commands) {
20
+ for (const [index, [program, ...args]] of commands.entries()) try {
21
+ await execa(program, args, {
20
22
  cwd: directory,
21
23
  stdio: "inherit"
22
24
  });
@@ -24,6 +26,6 @@ async function installDependencies(directory, commands) {
24
26
  const remaining = formatSetupCommands(directory, commands.slice(index));
25
27
  throw new Error(`${String(error)}\nTo resume setup:\n${remaining}`, { cause: error });
26
28
  }
27
- return "Dependency and tool setup complete";
29
+ return "Project setup complete";
28
30
  }
29
- export { formatSetupCommands, installDependencies };
31
+ export { formatSetupCommands, runSetupCommands };
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import nodePlop from "node-plop";
8
8
  import { defaultFeatureNames, features, frameworks } from "./core/feature-resolver.js";
9
9
  // src/cli.ts
10
10
  const featureChoices = features.map(({ name }) => name);
11
- const program = new Command("create-nelsonlai-app").description("Scaffold a Next.js or TanStack Start project.").argument("[project-directory]", "Path to the project directory").option("--framework <name>", `Project framework: ${frameworks.join(" or ")}`).option("--features <list>", `Comma-separated features, or "" for none. Choices: ${featureChoices.join(", ")}`).option("--git", "Initialize a Git repository").option("--no-git", "Skip Git initialization").option("--install", "Install dependencies with pnpm and run tool setup").option("--no-install", "Skip installation and print the setup commands").parse();
11
+ const program = new Command("create-nelsonlai-app").description("Scaffold a Next.js or TanStack Start project.").argument("[project-directory]", "Path to the project directory").option("--framework <name>", `Project framework: ${frameworks.join(" or ")}`).option("--features <list>", `Comma-separated features, or "" for none. Choices: ${featureChoices.join(", ")}`).option("--git", "Initialize a Git repository and create the initial commit").option("--no-git", "Skip Git initialization").option("--install", "Install dependencies with pnpm and run tool setup").option("--no-install", "Skip installation and print the setup commands").parse();
12
12
  const options = program.opts();
13
13
  try {
14
14
  const directory = process.cwd();
package/dist/plopfile.js CHANGED
@@ -1,6 +1,5 @@
1
- import { execa } from "execa";
2
- import { formatSetupCommands, installDependencies } from "./actions/install-dependencies.js";
3
1
  import { mergePackageJson } from "./actions/merge-package-json.js";
2
+ import { formatSetupCommands, runSetupCommands } from "./actions/setup-commands.js";
4
3
  import { resolveFeatures } from "./core/feature-resolver.js";
5
4
  import { writeProjectFiles } from "./core/project-directory.js";
6
5
  import { configureLefthook } from "./features/lefthook/index.js";
@@ -55,22 +54,52 @@ function registerProject(plop) {
55
54
  writeProjectFiles(staging, destination);
56
55
  return "Project files created";
57
56
  });
58
- if (git) actions.push(async () => {
59
- await execa("git", ["init", "--quiet"], { cwd: destination });
60
- return "Git initialized";
61
- });
62
- const commands = [["install"]];
63
- if (tools.has("varlock")) commands.push(["run", "env:generate"]);
64
- if (framework === "tanstack-start") commands.push(["build"]);
65
- if (framework === "nextjs") commands.push([
57
+ const pnpmCommands = [["pnpm", "install"]];
58
+ if (tools.has("varlock")) pnpmCommands.push([
59
+ "pnpm",
60
+ "run",
61
+ "env:generate"
62
+ ]);
63
+ if (framework === "tanstack-start") pnpmCommands.push(["pnpm", "build"]);
64
+ if (framework === "nextjs") pnpmCommands.push([
65
+ "pnpm",
66
66
  "exec",
67
67
  "next",
68
68
  "typegen"
69
69
  ]);
70
- if (tools.has("oxfmt")) commands.push(["run", "format"]);
71
- if (git && tools.has("lefthook")) commands.push(["run", "hooks:install"]);
72
- if (install) actions.push("Installing dependencies with pnpm...", async () => installDependencies(destination, commands));
73
- const steps = formatSetupCommands(destination, [...install ? [] : commands, ["dev"]]);
70
+ if (tools.has("oxfmt")) pnpmCommands.push([
71
+ "pnpm",
72
+ "run",
73
+ "format"
74
+ ]);
75
+ if (git && tools.has("lefthook")) pnpmCommands.push([
76
+ "pnpm",
77
+ "run",
78
+ "hooks:install"
79
+ ]);
80
+ const commands = [];
81
+ if (git) commands.push([
82
+ "git",
83
+ "init",
84
+ "--quiet"
85
+ ]);
86
+ if (install) {
87
+ actions.push("Installing dependencies with pnpm...");
88
+ commands.push(...pnpmCommands);
89
+ }
90
+ if (git) commands.push([
91
+ "git",
92
+ "add",
93
+ "--all"
94
+ ], [
95
+ "git",
96
+ "commit",
97
+ "--quiet",
98
+ "-m",
99
+ "chore: initial commit"
100
+ ]);
101
+ if (commands.length > 0) actions.push(async () => runSetupCommands(destination, commands));
102
+ const steps = formatSetupCommands(destination, [...install ? [] : pnpmCommands, ["pnpm", "dev"]]);
74
103
  actions.push(`\nCreated ${name} in ${destination}.\n\n${steps}`);
75
104
  return actions;
76
105
  }
@@ -35,7 +35,7 @@ function projectPrompts(base) {
35
35
  {
36
36
  type: "confirm",
37
37
  name: "git",
38
- message: "Initialize Git?",
38
+ message: "Initialize Git and create the initial commit?",
39
39
  default: true
40
40
  },
41
41
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nelsonlai-app",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Scaffold a Next.js or TanStack Start app with your choice of development tools.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,7 @@ export default defineConfig({
12
12
  resolve: { tsconfigPaths: true },
13
13
  plugins: [
14
14
  {{#if varlock}}
15
- varlockVitePlugin({ ssrInjectMode: 'auto-load' }),
15
+ varlockVitePlugin(),
16
16
  {{/if}}
17
17
  {{#if tailwindcss}}
18
18
  tailwindcss(),