create-nextspark-app 0.1.0-beta.2 → 0.1.0-beta.25
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 +40 -31
- 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,33 +32,54 @@ 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
|
});
|
|
76
|
+
if (result.status !== 0) {
|
|
77
|
+
throw new Error(`Wizard failed with exit code ${result.status}`);
|
|
78
|
+
}
|
|
55
79
|
console.log();
|
|
56
|
-
console.log(chalk.
|
|
57
|
-
console.log();
|
|
58
|
-
console.log(" Next steps:");
|
|
80
|
+
console.log(chalk.gray(` To start developing:`));
|
|
59
81
|
console.log();
|
|
60
82
|
console.log(chalk.cyan(` cd ${projectName}`));
|
|
61
|
-
console.log(chalk.cyan(" pnpm dev"));
|
|
62
83
|
console.log();
|
|
63
84
|
}
|
|
64
85
|
|
|
@@ -95,24 +116,6 @@ async function getProjectOptions(projectName, skipPrompts) {
|
|
|
95
116
|
);
|
|
96
117
|
projectName = response.projectName;
|
|
97
118
|
}
|
|
98
|
-
if (!skipPrompts) {
|
|
99
|
-
const confirmResponse = await prompts(
|
|
100
|
-
{
|
|
101
|
-
type: "confirm",
|
|
102
|
-
name: "confirm",
|
|
103
|
-
message: `Create project "${projectName}" in current directory?`,
|
|
104
|
-
initial: true
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
onCancel: () => {
|
|
108
|
-
throw new Error("PROMPT_CANCELLED");
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
|
-
if (!confirmResponse.confirm) {
|
|
113
|
-
throw new Error("PROMPT_CANCELLED");
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
119
|
return {
|
|
117
120
|
projectName,
|
|
118
121
|
projectPath: path2.resolve(process.cwd(), projectName)
|
|
@@ -121,7 +124,7 @@ async function getProjectOptions(projectName, skipPrompts) {
|
|
|
121
124
|
|
|
122
125
|
// src/index.ts
|
|
123
126
|
var program = new Command();
|
|
124
|
-
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) => {
|
|
125
128
|
console.log();
|
|
126
129
|
console.log(chalk2.bold.cyan(" NextSpark"));
|
|
127
130
|
console.log(chalk2.dim(" Create a new SaaS project"));
|
|
@@ -130,7 +133,13 @@ program.name("create-nextspark-app").description("Create a new NextSpark SaaS pr
|
|
|
130
133
|
const projectOptions = await getProjectOptions(projectName, options.yes);
|
|
131
134
|
await createProject({
|
|
132
135
|
...projectOptions,
|
|
133
|
-
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
|
|
134
143
|
});
|
|
135
144
|
} catch (error) {
|
|
136
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.25",
|
|
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
|
+
}
|