create-nextspark-app 0.1.0-beta.3 → 0.1.0-beta.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 +39 -9
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import path from "path";
9
9
  import fs from "fs-extra";
10
10
  import chalk from "chalk";
11
11
  import ora from "ora";
12
- import { execSync } from "child_process";
12
+ import { execSync, spawnSync } from "child_process";
13
13
  async function createProject(options) {
14
14
  const { projectName, projectPath, preset } = options;
15
15
  if (await fs.pathExists(projectPath)) {
@@ -32,26 +32,50 @@ async function createProject(options) {
32
32
  };
33
33
  await fs.writeJson(path.join(projectPath, "package.json"), packageJson, { spaces: 2 });
34
34
  pkgSpinner.succeed(" package.json created");
35
- const coreSpinner = ora(" Installing @nextsparkjs/core...").start();
35
+ const cliSpinner = ora(" Installing @nextsparkjs/cli...").start();
36
36
  try {
37
- execSync("pnpm add @nextsparkjs/core", {
37
+ execSync("pnpm add @nextsparkjs/cli", {
38
38
  cwd: projectPath,
39
39
  stdio: "pipe"
40
40
  });
41
- coreSpinner.succeed(" @nextsparkjs/core installed");
41
+ cliSpinner.succeed(" @nextsparkjs/cli installed");
42
42
  } catch (error) {
43
- coreSpinner.fail(" Failed to install @nextsparkjs/core");
43
+ cliSpinner.fail(" Failed to install @nextsparkjs/cli");
44
44
  throw error;
45
45
  }
46
46
  console.log();
47
47
  console.log(chalk.blue(" Starting NextSpark wizard..."));
48
48
  console.log();
49
- const presetArg = preset ? ` --preset=${preset}` : "";
50
- execSync(`npx nextspark init${presetArg}`, {
49
+ const initArgs = ["nextspark", "init"];
50
+ if (preset) {
51
+ initArgs.push("--preset", preset);
52
+ }
53
+ if (options.name) {
54
+ initArgs.push("--name", options.name);
55
+ }
56
+ if (options.slug) {
57
+ initArgs.push("--slug", options.slug);
58
+ }
59
+ if (options.description) {
60
+ initArgs.push("--description", options.description);
61
+ }
62
+ if (options.theme) {
63
+ initArgs.push("--theme", options.theme);
64
+ }
65
+ if (options.plugins) {
66
+ initArgs.push("--plugins", options.plugins);
67
+ }
68
+ if (options.yes) {
69
+ initArgs.push("--yes");
70
+ }
71
+ const result = spawnSync("npx", initArgs, {
51
72
  cwd: projectPath,
52
73
  stdio: "inherit"
53
74
  // Interactive mode
54
75
  });
76
+ if (result.status !== 0) {
77
+ throw new Error(`Wizard failed with exit code ${result.status}`);
78
+ }
55
79
  const installSpinner = ora(" Installing dependencies...").start();
56
80
  try {
57
81
  execSync("pnpm install", {
@@ -129,7 +153,7 @@ async function getProjectOptions(projectName, skipPrompts) {
129
153
 
130
154
  // src/index.ts
131
155
  var program = new Command();
132
- program.name("create-nextspark-app").description("Create a new NextSpark SaaS project").version("0.1.0-beta.1").argument("[project-name]", "Name of the project").option("--preset <preset>", "Use a preset (saas, blog, crm)").option("-y, --yes", "Skip prompts and use defaults", false).action(async (projectName, options) => {
156
+ program.name("create-nextspark-app").description("Create a new NextSpark SaaS project").version("0.1.0-beta.4").argument("[project-name]", "Name of the project").option("--preset <preset>", "Use a preset (saas, blog, crm)").option("--name <name>", "Project name (non-interactive mode)").option("--slug <slug>", "Project slug (non-interactive mode)").option("--description <desc>", "Project description (non-interactive mode)").option("--theme <theme>", "Theme to use (default, blog, crm, productivity, none)").option("--plugins <plugins>", "Plugins to install (comma-separated)").option("-y, --yes", "Skip prompts and use defaults", false).action(async (projectName, options) => {
133
157
  console.log();
134
158
  console.log(chalk2.bold.cyan(" NextSpark"));
135
159
  console.log(chalk2.dim(" Create a new SaaS project"));
@@ -138,7 +162,13 @@ program.name("create-nextspark-app").description("Create a new NextSpark SaaS pr
138
162
  const projectOptions = await getProjectOptions(projectName, options.yes);
139
163
  await createProject({
140
164
  ...projectOptions,
141
- preset: options.preset
165
+ preset: options.preset,
166
+ name: options.name,
167
+ slug: options.slug,
168
+ description: options.description,
169
+ theme: options.theme,
170
+ plugins: options.plugins,
171
+ yes: options.yes
142
172
  });
143
173
  } catch (error) {
144
174
  if (error instanceof Error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nextspark-app",
3
- "version": "0.1.0-beta.3",
3
+ "version": "0.1.0-beta.5",
4
4
  "description": "Create a new NextSpark SaaS project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,10 +11,6 @@
11
11
  "bin",
12
12
  "dist"
13
13
  ],
14
- "scripts": {
15
- "build": "tsup src/index.ts --format esm --outDir dist",
16
- "dev": "tsup src/index.ts --format esm --watch --outDir dist"
17
- },
18
14
  "dependencies": {
19
15
  "commander": "^12.0.0",
20
16
  "chalk": "^5.3.0",
@@ -46,5 +42,9 @@
46
42
  },
47
43
  "engines": {
48
44
  "node": ">=18.0.0"
45
+ },
46
+ "scripts": {
47
+ "build": "tsup src/index.ts --format esm --outDir dist",
48
+ "dev": "tsup src/index.ts --format esm --watch --outDir dist"
49
49
  }
50
- }
50
+ }