(binaries: Record<string, string>)
| 525 | // --------------------------------------------------------------------------- |
| 526 | |
| 527 | const buildWrapperPackage = async (binaries: Record<string, string>) => { |
| 528 | const meta = await readMetadata(); |
| 529 | const wrapperDir = join(distDir, meta.name); |
| 530 | const binDir = join(wrapperDir, "bin"); |
| 531 | |
| 532 | await mkdir(binDir, { recursive: true }); |
| 533 | |
| 534 | // Node.js launcher — resolves the platform binary via require.resolve |
| 535 | // against optionalDependencies and execs it. No postinstall: the binary |
| 536 | // ships as an os/cpu-filtered optional dep, the launcher resolves it at |
| 537 | // runtime. This works whether or not the package manager runs postinstalls |
| 538 | // (bun blocks them by default). |
| 539 | await writeFile(join(binDir, "executor"), NODE_SHIM); |
| 540 | await chmod(join(binDir, "executor"), 0o755); |
| 541 | |
| 542 | await writeFile( |
| 543 | join(wrapperDir, "package.json"), |
| 544 | JSON.stringify( |
| 545 | { |
| 546 | name: meta.name, |
| 547 | version: meta.version, |
| 548 | description: meta.description, |
| 549 | keywords: meta.keywords, |
| 550 | homepage: meta.homepage, |
| 551 | bugs: meta.bugs, |
| 552 | repository: meta.repository, |
| 553 | license: meta.license, |
| 554 | bin: { executor: "bin/executor" }, |
| 555 | // Per-platform compiled binaries published as platform-tagged |
| 556 | // versions of `executor` itself, referenced via npm:alias specs: |
| 557 | // "executor-linux-x64": "npm:executor@1.4.14-linux-x64" |
| 558 | // npm/bun fetch only the variant matching the current os/cpu (set |
| 559 | // on each variant's package.json); everything else is a no-op. |
| 560 | // The local alias name on the left is what the launcher passes to |
| 561 | // require.resolve at runtime — npm puts the variant at |
| 562 | // `node_modules/executor-<plat>-<arch>/` so resolution just works. |
| 563 | optionalDependencies: binaries, |
| 564 | engines: { |
| 565 | node: ">=20", |
| 566 | }, |
| 567 | }, |
| 568 | null, |
| 569 | 2, |
| 570 | ) + "\n", |
| 571 | ); |
| 572 | |
| 573 | const readmePath = join(repoRoot, "README.md"); |
| 574 | if (existsSync(readmePath)) { |
| 575 | await cp(readmePath, join(wrapperDir, "README.md")); |
| 576 | } |
| 577 | |
| 578 | console.log(`\nWrapper package: ${wrapperDir}`); |
| 579 | console.log(` ${meta.name}@${meta.version}`); |
| 580 | console.log(` optionalDependencies: ${Object.keys(binaries).join(", ")}`); |
| 581 | }; |
| 582 | |
| 583 | // --------------------------------------------------------------------------- |
| 584 | // Preview wrapper — a slim npm package for pkg.pr.new previews that fetches |
no test coverage detected