create-nextspark-app 0.1.0-beta.3 → 0.1.0-beta.31
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 +38 -37
- 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,36 +32,49 @@ 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
|
|
35
|
+
const cliSpinner = ora(" Installing @nextsparkjs/core and @nextsparkjs/cli...").start();
|
|
36
36
|
try {
|
|
37
|
-
execSync("pnpm add @nextsparkjs/core", {
|
|
37
|
+
execSync("pnpm add @nextsparkjs/core @nextsparkjs/cli", {
|
|
38
38
|
cwd: projectPath,
|
|
39
39
|
stdio: "pipe"
|
|
40
40
|
});
|
|
41
|
-
|
|
41
|
+
cliSpinner.succeed(" @nextsparkjs/core and @nextsparkjs/cli installed");
|
|
42
42
|
} catch (error) {
|
|
43
|
-
|
|
43
|
+
cliSpinner.fail(" Failed to install @nextsparkjs/core and @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
|
|
50
|
-
|
|
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
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
execSync("pnpm install", {
|
|
58
|
-
cwd: projectPath,
|
|
59
|
-
stdio: "pipe"
|
|
60
|
-
});
|
|
61
|
-
installSpinner.succeed(" Dependencies installed");
|
|
62
|
-
} catch (error) {
|
|
63
|
-
installSpinner.fail(" Failed to install dependencies");
|
|
64
|
-
throw error;
|
|
76
|
+
if (result.status !== 0) {
|
|
77
|
+
throw new Error(`Wizard failed with exit code ${result.status}`);
|
|
65
78
|
}
|
|
66
79
|
console.log();
|
|
67
80
|
console.log(chalk.gray(` To start developing:`));
|
|
@@ -103,24 +116,6 @@ async function getProjectOptions(projectName, skipPrompts) {
|
|
|
103
116
|
);
|
|
104
117
|
projectName = response.projectName;
|
|
105
118
|
}
|
|
106
|
-
if (!skipPrompts) {
|
|
107
|
-
const confirmResponse = await prompts(
|
|
108
|
-
{
|
|
109
|
-
type: "confirm",
|
|
110
|
-
name: "confirm",
|
|
111
|
-
message: `Create project "${projectName}" in current directory?`,
|
|
112
|
-
initial: true
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
onCancel: () => {
|
|
116
|
-
throw new Error("PROMPT_CANCELLED");
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
if (!confirmResponse.confirm) {
|
|
121
|
-
throw new Error("PROMPT_CANCELLED");
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
119
|
return {
|
|
125
120
|
projectName,
|
|
126
121
|
projectPath: path2.resolve(process.cwd(), projectName)
|
|
@@ -129,7 +124,7 @@ async function getProjectOptions(projectName, skipPrompts) {
|
|
|
129
124
|
|
|
130
125
|
// src/index.ts
|
|
131
126
|
var program = new Command();
|
|
132
|
-
program.name("create-nextspark-app").description("Create a new NextSpark SaaS project").version("0.1.0-beta.
|
|
127
|
+
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
128
|
console.log();
|
|
134
129
|
console.log(chalk2.bold.cyan(" NextSpark"));
|
|
135
130
|
console.log(chalk2.dim(" Create a new SaaS project"));
|
|
@@ -138,7 +133,13 @@ program.name("create-nextspark-app").description("Create a new NextSpark SaaS pr
|
|
|
138
133
|
const projectOptions = await getProjectOptions(projectName, options.yes);
|
|
139
134
|
await createProject({
|
|
140
135
|
...projectOptions,
|
|
141
|
-
preset: options.preset
|
|
136
|
+
preset: options.preset,
|
|
137
|
+
name: options.name,
|
|
138
|
+
slug: options.slug,
|
|
139
|
+
description: options.description,
|
|
140
|
+
theme: options.theme,
|
|
141
|
+
plugins: options.plugins,
|
|
142
|
+
yes: options.yes
|
|
142
143
|
});
|
|
143
144
|
} catch (error) {
|
|
144
145
|
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
|
+
"version": "0.1.0-beta.31",
|
|
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
|
+
}
|