create-zenith 0.2.0 → 0.2.2
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/index.js +40 -8
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -9,15 +9,47 @@
|
|
|
9
9
|
* It is a permanent proxy and should never grow features.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { spawn } from "node:child_process";
|
|
12
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
13
|
+
import { existsSync } from "node:fs";
|
|
14
|
+
import { dirname, join } from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
13
16
|
|
|
17
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
18
|
const args = process.argv.slice(2);
|
|
15
19
|
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
// Check if we're in the monorepo development context
|
|
21
|
+
// (zenith-cli is a sibling directory)
|
|
22
|
+
function getLocalCLIPath() {
|
|
23
|
+
const monorepoCliPath = join(__dirname, "..", "zenith-cli", "bin", "zenith");
|
|
24
|
+
if (existsSync(monorepoCliPath)) {
|
|
25
|
+
return monorepoCliPath;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
22
29
|
|
|
23
|
-
|
|
30
|
+
// Detect if Bun is available
|
|
31
|
+
function hasBun() {
|
|
32
|
+
try {
|
|
33
|
+
const result = spawnSync("bun", ["--version"], { stdio: "pipe" });
|
|
34
|
+
return result.status === 0;
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Try to find the zenith CLI
|
|
41
|
+
const localCLI = getLocalCLIPath();
|
|
42
|
+
|
|
43
|
+
if (localCLI) {
|
|
44
|
+
// Development mode: use local CLI directly
|
|
45
|
+
const child = spawn("bun", [localCLI, "create", ...args], { stdio: "inherit" });
|
|
46
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
47
|
+
} else {
|
|
48
|
+
// Production mode: use package manager to resolve @zenithbuild/cli
|
|
49
|
+
const useBun = hasBun();
|
|
50
|
+
const runner = useBun ? "bunx" : (process.platform === "win32" ? "npx.cmd" : "npx");
|
|
51
|
+
const runnerArgs = ["@zenithbuild/cli", "create", ...args];
|
|
52
|
+
|
|
53
|
+
const child = spawn(runner, runnerArgs, { stdio: "inherit" });
|
|
54
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
55
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-zenith",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Thin resolver for bun/npm create zenith - delegates to @zenithbuild/cli",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-zenith": "./index.js"
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
"cli"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@zenithbuild/cli": "
|
|
22
|
+
"@zenithbuild/cli": "github:zenithbuild/zenith-cli"
|
|
23
23
|
}
|
|
24
|
-
}
|
|
24
|
+
}
|