History

fix bun global executor installs

Rhys Sullivan committed 7 months agov1.4.0-beta.2

Commit efc1e6b1 parent 1bdf9904 files · +36 −5Browse files

Unified · Split

4 files
  1. .changeset/pre.json +1 −0
  2. apps/cli/package.json +1 −1
  3. apps/cli/src/build.ts +32 −3
  4. bun.lock +2 −1
.changeset/pre.json+1−0
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 "@executor/ui": "1.4.0-beta.0"
2727 },
2828 "changesets": [
29+ "funny-buses-count",
2930 "ripe-yaks-sniff"
3031 ]
3132 }
apps/cli/package.json+1−1
@@ -1,6 +1,6 @@
11 {
22 "name": "executor",
3− "version": "1.4.0-beta.1",
3+ "version": "1.4.0-beta.2",
44 "private": true,
55 "type": "module",
66 "bin": {
apps/cli/src/build.ts+32−3
@@ -203,7 +203,7 @@ const buildWrapperPackage = async (binaries: Record<string, string>) => { · 202 unmodified lines
203203 await chmod(join(binDir, "executor"), 0o755);
204204
205205 // Postinstall downloads the matching release asset from GitHub Releases
206− await writeFile(join(wrapperDir, "postinstall.mjs"), POSTINSTALL_SCRIPT);
206+ await writeFile(join(wrapperDir, "postinstall.cjs"), POSTINSTALL_SCRIPT);
207207
208208 // Package.json
209209 await writeFile(
@@ -220,7 +220,7 @@ const buildWrapperPackage = async (binaries: Record<string, string>) => { · 10 unmodified lines
220220 license: meta.license,
221221 bin: { executor: "bin/executor" },
222222 scripts: {
223− postinstall: "node ./postinstall.mjs",
223+ postinstall: "node ./postinstall.cjs",
224224 },
225225 engines: {
226226 node: ">=20",
@@ -339,7 +339,36 @@ if (process.env.EXECUTOR_BIN_PATH) run(process.env.EXECUTOR_BIN_PATH); · 112 unmodified lines
339339
340340 const scriptDir = path.dirname(fs.realpathSync(__filename));
341341 const cached = path.join(scriptDir, process.platform === "win32" ? ".executor.exe" : ".executor");
342−if (!fs.existsSync(cached)) {
342+
343+const installIfNeeded = () => {
344+ if (fs.existsSync(cached)) {
345+ return true;
346+ }
347+
348+ const installer = path.resolve(scriptDir, "..", "postinstall.cjs");
349+ if (!fs.existsSync(installer)) {
350+ return false;
351+ }
352+
353+ console.error("executor binary is missing; downloading release asset...");
354+ const result = childProcess.spawnSync(process.execPath, [installer], {
355+ stdio: "inherit",
356+ env: process.env,
357+ });
358+
359+ if (result.error) {
360+ console.error(result.error.message);
361+ process.exit(1);
362+ }
363+
364+ if (typeof result.status === "number" && result.status !== 0) {
365+ process.exit(result.status);
366+ }
367+
368+ return fs.existsSync(cached);
369+};
370+
371+if (!installIfNeeded()) {
343372 console.error("executor binary is missing. Reinstall the package or run 'npm rebuild executor'.");
344373 process.exit(1);
345374 }
bun.lock+2−1
@@ -1,5 +1,6 @@
11 {
22 "lockfileVersion": 1,
3+ "configVersion": 0,
34 "workspaces": {
45 "": {
56 "name": "v4-executor",
@@ -17,7 +18,7 @@ · 11 unmodified lines
1718 },
1819 "apps/cli": {
1920 "name": "executor",
20− "version": "1.4.0-beta.1",
21+ "version": "1.4.0-beta.2",
2122 "bin": {
2223 "executor": "./bin/executor.ts",
2324 },