@pushpalsdev/cli 1.1.30 → 1.1.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/bin/pushpals.cjs +43 -5
- package/package.json +1 -1
package/bin/pushpals.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
const { spawn, spawnSync } = require("node:child_process");
|
|
5
5
|
const { existsSync, mkdirSync, readFileSync, rmSync } = require("node:fs");
|
|
6
6
|
const { tmpdir } = require("node:os");
|
|
7
|
-
const { join, resolve } = require("node:path");
|
|
7
|
+
const { dirname, join, resolve } = require("node:path");
|
|
8
8
|
|
|
9
9
|
const bundledCliPath = resolve(__dirname, "..", "dist", "pushpals-cli.js");
|
|
10
10
|
const packageJsonPath = resolve(__dirname, "..", "package.json");
|
|
@@ -16,6 +16,7 @@ const BOOTSTRAP_TIMEOUT_ENV = "PUSHPALS_CLI_BOOTSTRAP_TIMEOUT_MS";
|
|
|
16
16
|
const BOOTSTRAP_READY_MARKER_ENV = "PUSHPALS_CLI_READY_MARKER";
|
|
17
17
|
let packageVersion = "";
|
|
18
18
|
let readyMarkerPath = "";
|
|
19
|
+
let resolvedBunCommand = "";
|
|
19
20
|
if (existsSync(packageJsonPath)) {
|
|
20
21
|
try {
|
|
21
22
|
const parsed = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
@@ -74,6 +75,42 @@ function killChildTree(child) {
|
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
function resolveWindowsBunCommand() {
|
|
79
|
+
try {
|
|
80
|
+
const where = spawnSync("where.exe", ["bun"], {
|
|
81
|
+
encoding: "utf8",
|
|
82
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
83
|
+
timeout: 5_000,
|
|
84
|
+
});
|
|
85
|
+
if (where.status !== 0) return "bun";
|
|
86
|
+
const candidates = String(where.stdout ?? "")
|
|
87
|
+
.split(/\r?\n/g)
|
|
88
|
+
.map((line) => line.trim())
|
|
89
|
+
.filter(Boolean);
|
|
90
|
+
|
|
91
|
+
for (const candidate of candidates) {
|
|
92
|
+
const lower = candidate.toLowerCase();
|
|
93
|
+
if (lower.endsWith(".exe") && existsSync(candidate)) return candidate;
|
|
94
|
+
|
|
95
|
+
// Bun installed through npm/nvm on Windows commonly exposes shell shims:
|
|
96
|
+
// <node-dir>\bun
|
|
97
|
+
// <node-dir>\bun.cmd
|
|
98
|
+
// Those shims delegate to <node-dir>\node_modules\bun\bin\bun.exe.
|
|
99
|
+
const shimTarget = join(dirname(candidate), "node_modules", "bun", "bin", "bun.exe");
|
|
100
|
+
if (existsSync(shimTarget)) return shimTarget;
|
|
101
|
+
}
|
|
102
|
+
} catch {
|
|
103
|
+
// Fall back to PATH/shell command resolution below.
|
|
104
|
+
}
|
|
105
|
+
return "bun";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function resolveBunCommand() {
|
|
109
|
+
if (resolvedBunCommand) return resolvedBunCommand;
|
|
110
|
+
resolvedBunCommand = process.platform === "win32" ? resolveWindowsBunCommand() : "bun";
|
|
111
|
+
return resolvedBunCommand;
|
|
112
|
+
}
|
|
113
|
+
|
|
77
114
|
if (!existsSync(bundledCliPath)) {
|
|
78
115
|
fail([
|
|
79
116
|
"[pushpals] CLI bundle is missing in this package install.",
|
|
@@ -85,7 +122,7 @@ if (!existsSync(bundledCliPath)) {
|
|
|
85
122
|
function probeBunRuntime() {
|
|
86
123
|
const timeout = parseBunProbeTimeoutMs();
|
|
87
124
|
const options = { stdio: "ignore", timeout };
|
|
88
|
-
const result = spawnSync(
|
|
125
|
+
const result = spawnSync(resolveBunCommand(), ["--version"], options);
|
|
89
126
|
return {
|
|
90
127
|
ok: result.status === 0,
|
|
91
128
|
timedOut: Boolean(result.error && result.error.code === "ETIMEDOUT"),
|
|
@@ -117,10 +154,11 @@ function spawnBunCli() {
|
|
|
117
154
|
[BOOTSTRAP_READY_MARKER_ENV]: readyMarkerPath,
|
|
118
155
|
};
|
|
119
156
|
|
|
120
|
-
|
|
157
|
+
const bunCommand = resolveBunCommand();
|
|
158
|
+
if (process.platform === "win32" && bunCommand === "bun") {
|
|
121
159
|
const quoteWindows = (value) => `"${String(value).replace(/"/g, '\\"')}"`;
|
|
122
160
|
const commandLine = [
|
|
123
|
-
|
|
161
|
+
bunCommand,
|
|
124
162
|
quoteWindows(bundledCliPath),
|
|
125
163
|
...process.argv.slice(2).map(quoteWindows),
|
|
126
164
|
].join(" ");
|
|
@@ -130,7 +168,7 @@ function spawnBunCli() {
|
|
|
130
168
|
env: childEnv,
|
|
131
169
|
});
|
|
132
170
|
}
|
|
133
|
-
return spawn(
|
|
171
|
+
return spawn(bunCommand, [bundledCliPath, ...process.argv.slice(2)], {
|
|
134
172
|
stdio: "inherit",
|
|
135
173
|
env: childEnv,
|
|
136
174
|
});
|