MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / buildWrapperPackage

Function buildWrapperPackage

apps/cli/src/build.ts:518–572  ·  view source on GitHub ↗
(binaries: Record<string, string>)

Source from the content-addressed store, hash-verified

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

Callers 1

build.tsFile · 0.85

Calls 2

readMetadataFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected