History

fallback when bun blocks postinstall

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

Commit a09601c1 parent efc1e6b5 files · +41 −20Browse files

Unified · Split

5 files
  1. .changeset/kind-cycles-hang.md +5 −0
  2. .changeset/pre.json +1 −1
  3. apps/cli/package.json +1 −1
  4. apps/cli/src/build.ts +33 −17
  5. bun.lock +1 −1
.changeset/kind-cycles-hang.md+5−0
@@ -0,0 +1,5 @@
1---
2"executor": patch
3---
4
5Fallback to downloading the platform binary on first run when package-manager postinstall scripts are blocked, including Bun global installs.
.changeset/pre.json+1−1
@@ -26,7 +26,7 @@ · 25 unmodified lines
26 "@executor/ui": "1.4.0-beta.0"26 "@executor/ui": "1.4.0-beta.0"
27 },27 },
28 "changesets": [28 "changesets": [
29 "funny-buses-count",29 "kind-cycles-hang",
30 "ripe-yaks-sniff"30 "ripe-yaks-sniff"
31 ]31 ]
32}32}
apps/cli/package.json+1−1
@@ -1,6 +1,6 @@
1{1{
2 "name": "executor",2 "name": "executor",
3 "version": "1.4.0-beta.2",3 "version": "1.4.0-beta.3",
4 "private": true,4 "private": true,
5 "type": "module",5 "type": "module",
6 "bin": {6 "bin": {
apps/cli/src/build.ts+33−17
@@ -338,16 +338,29 @@ function run(target) { · 337 unmodified lines
338if (process.env.EXECUTOR_BIN_PATH) run(process.env.EXECUTOR_BIN_PATH);338if (process.env.EXECUTOR_BIN_PATH) run(process.env.EXECUTOR_BIN_PATH);
339 339
340const scriptDir = path.dirname(fs.realpathSync(__filename));340const scriptDir = path.dirname(fs.realpathSync(__filename));
341const cached = path.join(scriptDir, process.platform === "win32" ? ".executor.exe" : ".executor");341const binary = process.platform === "win32" ? "executor.exe" : "executor";
342const runtimeBinary = path.join(scriptDir, "runtime", binary);
343const legacyCached = path.join(scriptDir, process.platform === "win32" ? ".executor.exe" : ".executor");
344
345const resolveInstalledBinary = () => {
346 if (fs.existsSync(runtimeBinary)) {
347 return runtimeBinary;
348 }
349 if (fs.existsSync(legacyCached)) {
350 return legacyCached;
351 }
352 return null;
353};
342 354
343const installIfNeeded = () => {355const installIfNeeded = () => {
344 if (fs.existsSync(cached)) {356 const existing = resolveInstalledBinary();
345 return true;357 if (existing) {
358 return existing;
346 }359 }
347 360
348 const installer = path.resolve(scriptDir, "..", "postinstall.cjs");361 const installer = path.resolve(scriptDir, "..", "postinstall.cjs");
349 if (!fs.existsSync(installer)) {362 if (!fs.existsSync(installer)) {
350 return false;363 return null;
351 }364 }
352 365
353 console.error("executor binary is missing; downloading release asset...");366 console.error("executor binary is missing; downloading release asset...");
@@ -365,15 +378,16 @@ const installIfNeeded = () => { · 11 unmodified lines
365 process.exit(result.status);378 process.exit(result.status);
366 }379 }
367 380
368 return fs.existsSync(cached);381 return resolveInstalledBinary();
369};382};
370 383
371if (!installIfNeeded()) {384const installedBinary = installIfNeeded();
385if (!installedBinary) {
372 console.error("executor binary is missing. Reinstall the package or run 'npm rebuild executor'.");386 console.error("executor binary is missing. Reinstall the package or run 'npm rebuild executor'.");
373 process.exit(1);387 process.exit(1);
374}388}
375 389
376run(cached);390run(installedBinary);
377`;391`;
378 392
379// ---------------------------------------------------------------------------393// ---------------------------------------------------------------------------
@@ -388,6 +402,7 @@ const os = require("os"); · 8 unmodified lines
388 402
389const packageDir = path.dirname(fs.realpathSync(__filename));403const packageDir = path.dirname(fs.realpathSync(__filename));
390const binDir = path.join(packageDir, "bin");404const binDir = path.join(packageDir, "bin");
405const runtimeDir = path.join(binDir, "runtime");
391const packageJson = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf8"));406const packageJson = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf8"));
392 407
393const repositoryUrl = typeof packageJson.repository === "string"408const repositoryUrl = typeof packageJson.repository === "string"
@@ -402,7 +417,8 @@ const platformMap = { darwin: "darwin", linux: "linux", win32: "windows" }; · 8 unmodified lines
402const platform = platformMap[os.platform()] || os.platform();417const platform = platformMap[os.platform()] || os.platform();
403const arch = os.arch() === "arm64" ? "arm64" : "x64";418const arch = os.arch() === "arm64" ? "arm64" : "x64";
404const binary = platform === "windows" ? "executor.exe" : "executor";419const binary = platform === "windows" ? "executor.exe" : "executor";
405const cachedBinary = path.join(binDir, platform === "win32" ? ".executor.exe" : ".executor");420const cachedBinary = path.join(runtimeDir, binary);
421const legacyCachedBinary = path.join(binDir, platform === "win32" ? ".executor.exe" : ".executor");
406 422
407const isMusl = (() => {423const isMusl = (() => {
408 if (platform !== "linux") return false;424 if (platform !== "linux") return false;
@@ -442,20 +458,22 @@ const download = async () => { · 33 unmodified lines
442 458
443const extract = () => {459const extract = () => {
444 fs.mkdirSync(binDir, { recursive: true });460 fs.mkdirSync(binDir, { recursive: true });
461 fs.rmSync(runtimeDir, { recursive: true, force: true });
462 fs.mkdirSync(runtimeDir, { recursive: true });
445 463
446 if (platform === "linux") {464 if (platform === "linux") {
447 run("tar", ["-xzf", archivePath, "-C", binDir]);465 run("tar", ["-xzf", archivePath, "-C", runtimeDir]);
448 return;466 return;
449 }467 }
450 468
451 if (platform === "darwin") {469 if (platform === "darwin") {
452 run("unzip", ["-o", archivePath, "-d", binDir]);470 run("unzip", ["-o", archivePath, "-d", runtimeDir]);
453 return;471 return;
454 }472 }
455 473
456 const command = [474 const command = [
457 "$ErrorActionPreference = 'Stop'",475 "$ErrorActionPreference = 'Stop'",
458 "Expand-Archive -LiteralPath '" + archivePath.replace(/'/g, "''") + "' -DestinationPath '" + binDir.replace(/'/g, "''") + "' -Force",476 "Expand-Archive -LiteralPath '" + archivePath.replace(/'/g, "''") + "' -DestinationPath '" + runtimeDir.replace(/'/g, "''") + "' -Force",
459 ].join("; ");477 ].join("; ");
460 run("powershell.exe", ["-NoLogo", "-NoProfile", "-Command", command]);478 run("powershell.exe", ["-NoLogo", "-NoProfile", "-Command", command]);
461};479};
@@ -465,15 +483,13 @@ const extract = () => { · 3 unmodified lines
465 await download();483 await download();
466 extract();484 extract();
467 485
468 const extractedBinary = path.join(binDir, binary);486 if (!fs.existsSync(cachedBinary)) {
469 if (!fs.existsSync(extractedBinary)) {487 throw new Error("Expected extracted binary at " + cachedBinary);
470 throw new Error("Expected extracted binary at " + extractedBinary);
471 }488 }
472 489
473 if (fs.existsSync(cachedBinary)) {490 if (fs.existsSync(legacyCachedBinary)) {
474 fs.unlinkSync(cachedBinary);491 fs.unlinkSync(legacyCachedBinary);
475 }492 }
476 fs.renameSync(extractedBinary, cachedBinary);
477 fs.chmodSync(cachedBinary, 0o755);493 fs.chmodSync(cachedBinary, 0o755);
478 fs.rmSync(archivePath, { force: true });494 fs.rmSync(archivePath, { force: true });
479 console.log("executor: installed " + assetBase + " from GitHub Releases");495 console.log("executor: installed " + assetBase + " from GitHub Releases");
bun.lock+1−1
@@ -18,7 +18,7 @@ · 17 unmodified lines
18 },18 },
19 "apps/cli": {19 "apps/cli": {
20 "name": "executor",20 "name": "executor",
21 "version": "1.4.0-beta.2",21 "version": "1.4.0-beta.3",
22 "bin": {22 "bin": {
23 "executor": "./bin/executor.ts",23 "executor": "./bin/executor.ts",
24 },24 },

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t