create-nextspark-app 0.1.0-beta.8 → 0.1.0-beta.80
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/bin/index.js +10 -0
- package/dist/index.js +40 -3
- package/package.json +6 -6
package/bin/index.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Check Node.js version before importing anything
|
|
4
|
+
const nodeVersion = parseInt(process.versions.node.split('.')[0], 10);
|
|
5
|
+
if (nodeVersion < 18) {
|
|
6
|
+
console.error('\x1b[31m✗ NextSpark requires Node.js 18 or higher\x1b[0m');
|
|
7
|
+
console.error(` Current version: ${process.versions.node}`);
|
|
8
|
+
console.error(' Please upgrade Node.js: https://nodejs.org/');
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
|
|
2
12
|
import '../dist/index.js'
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
import chalk2 from "chalk";
|
|
6
|
+
import { readFileSync } from "fs";
|
|
6
7
|
|
|
7
8
|
// src/create.ts
|
|
8
9
|
import path from "path";
|
|
@@ -10,6 +11,27 @@ import fs from "fs-extra";
|
|
|
10
11
|
import chalk from "chalk";
|
|
11
12
|
import ora from "ora";
|
|
12
13
|
import { execSync, spawnSync } from "child_process";
|
|
14
|
+
function findLocalTarball(packageName) {
|
|
15
|
+
const tarballPrefix = packageName.replace("@", "").replace("/", "-");
|
|
16
|
+
const searchPaths = [
|
|
17
|
+
path.join(process.cwd(), ".packages"),
|
|
18
|
+
path.join(process.cwd(), "..", ".packages"),
|
|
19
|
+
path.join(process.cwd(), "..", "repo", ".packages"),
|
|
20
|
+
// projects/ -> repo/.packages
|
|
21
|
+
path.join(process.cwd(), "..", "..", ".packages"),
|
|
22
|
+
path.join(process.cwd(), "..", "..", "repo", ".packages")
|
|
23
|
+
];
|
|
24
|
+
for (const searchPath of searchPaths) {
|
|
25
|
+
if (fs.existsSync(searchPath)) {
|
|
26
|
+
const files = fs.readdirSync(searchPath);
|
|
27
|
+
const tarball = files.find((f) => f.startsWith(tarballPrefix) && f.endsWith(".tgz"));
|
|
28
|
+
if (tarball) {
|
|
29
|
+
return path.join(searchPath, tarball);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
13
35
|
async function createProject(options) {
|
|
14
36
|
const { projectName, projectPath, preset } = options;
|
|
15
37
|
if (await fs.pathExists(projectPath)) {
|
|
@@ -34,7 +56,16 @@ async function createProject(options) {
|
|
|
34
56
|
pkgSpinner.succeed(" package.json created");
|
|
35
57
|
const cliSpinner = ora(" Installing @nextsparkjs/core and @nextsparkjs/cli...").start();
|
|
36
58
|
try {
|
|
37
|
-
|
|
59
|
+
const localCoreTarball = findLocalTarball("@nextsparkjs/core");
|
|
60
|
+
const localCliTarball = findLocalTarball("@nextsparkjs/cli");
|
|
61
|
+
let corePackage = "@nextsparkjs/core";
|
|
62
|
+
let cliPackage = "@nextsparkjs/cli";
|
|
63
|
+
if (localCoreTarball && localCliTarball) {
|
|
64
|
+
corePackage = localCoreTarball;
|
|
65
|
+
cliPackage = localCliTarball;
|
|
66
|
+
cliSpinner.text = " Installing @nextsparkjs/core and @nextsparkjs/cli from local tarballs...";
|
|
67
|
+
}
|
|
68
|
+
execSync(`pnpm add ${corePackage} ${cliPackage}`, {
|
|
38
69
|
cwd: projectPath,
|
|
39
70
|
stdio: "pipe"
|
|
40
71
|
});
|
|
@@ -50,6 +81,9 @@ async function createProject(options) {
|
|
|
50
81
|
if (preset) {
|
|
51
82
|
initArgs.push("--preset", preset);
|
|
52
83
|
}
|
|
84
|
+
if (options.type) {
|
|
85
|
+
initArgs.push("--type", options.type);
|
|
86
|
+
}
|
|
53
87
|
if (options.name) {
|
|
54
88
|
initArgs.push("--name", options.name);
|
|
55
89
|
}
|
|
@@ -70,8 +104,9 @@ async function createProject(options) {
|
|
|
70
104
|
}
|
|
71
105
|
const result = spawnSync("npx", initArgs, {
|
|
72
106
|
cwd: projectPath,
|
|
73
|
-
stdio: "inherit"
|
|
107
|
+
stdio: "inherit",
|
|
74
108
|
// Interactive mode
|
|
109
|
+
shell: true
|
|
75
110
|
});
|
|
76
111
|
if (result.status !== 0) {
|
|
77
112
|
throw new Error(`Wizard failed with exit code ${result.status}`);
|
|
@@ -123,8 +158,9 @@ async function getProjectOptions(projectName, skipPrompts) {
|
|
|
123
158
|
}
|
|
124
159
|
|
|
125
160
|
// src/index.ts
|
|
161
|
+
var pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
126
162
|
var program = new Command();
|
|
127
|
-
program.name("create-nextspark-app").description("Create a new NextSpark SaaS project").version(
|
|
163
|
+
program.name("create-nextspark-app").description("Create a new NextSpark SaaS project").version(pkg.version).argument("[project-name]", "Name of the project").option("--preset <preset>", "Use a preset (saas, blog, crm)").option("--type <type>", "Project type: web or web-mobile").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) => {
|
|
128
164
|
console.log();
|
|
129
165
|
console.log(chalk2.bold.cyan(" NextSpark"));
|
|
130
166
|
console.log(chalk2.dim(" Create a new SaaS project"));
|
|
@@ -134,6 +170,7 @@ program.name("create-nextspark-app").description("Create a new NextSpark SaaS pr
|
|
|
134
170
|
await createProject({
|
|
135
171
|
...projectOptions,
|
|
136
172
|
preset: options.preset,
|
|
173
|
+
type: options.type,
|
|
137
174
|
name: options.name,
|
|
138
175
|
slug: options.slug,
|
|
139
176
|
description: options.description,
|
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.80",
|
|
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
|
+
}
|