create-zenith 0.1.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.
Files changed (2) hide show
  1. package/index.js +40 -12
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -3,25 +3,53 @@
3
3
  * create-zenith
4
4
  *
5
5
  * Thin resolver adapter for bun/npm/npx/pnpm create zenith.
6
- * Delegates directly to @zenithbuild/cli with all arguments.
6
+ * Delegates directly to @zenithbuild/cli create with all arguments.
7
7
  *
8
8
  * This package contains NO framework logic, NO build logic, NO scaffolding logic.
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
- // If no subcommand provided, default to "create"
17
- const finalArgs = args.length === 0 || !args[0].startsWith("-")
18
- ? ["create", ...args]
19
- : args;
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
+ }
20
29
 
21
- const child = spawn(
22
- process.platform === "win32" ? "npx.cmd" : "npx",
23
- ["@zenithbuild/cli", ...finalArgs],
24
- { stdio: "inherit" }
25
- );
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
+ }
26
39
 
27
- child.on("exit", (code) => process.exit(code ?? 0));
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.1.0",
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": "^0.1.0"
22
+ "@zenithbuild/cli": "github:zenithbuild/zenith-cli"
23
23
  }
24
- }
24
+ }