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

Function publishPacked

scripts/publish-packages.ts:329–354  ·  view source on GitHub ↗
(packed: PackedPackage)

Source from the content-addressed store, hash-verified

327};
328
329const publishPacked = async (packed: PackedPackage) => {
330 // Skip publishing already-shipped versions. The pack still ran above so
331 // smoke tests / pkg-pr-new previews always have a fresh tarball.
332 if (await packageAlreadyPublished(packed.name, packed.version)) {
333 console.log(`[skip] ${packed.name}@${packed.version} already on npm`);
334 return;
335 }
336
337 console.log(`[publish] ${packed.name}@${packed.version} (${packed.channel})`);
338
339 const args = ["publish", packed.tarball, "--access", "public", "--tag", packed.channel];
340 if (process.env.GITHUB_ACTIONS === "true") {
341 args.push("--provenance");
342 }
343
344 // Buffer output and replay it prefixed: several publishes run at once and
345 // interleaved npm output is unreadable.
346 const result = await $`npm ${args}`.cwd(packed.pkgDir).nothrow().quiet();
347 const output = `${result.stdout.toString()}${result.stderr.toString()}`.trim();
348 if (output.length > 0) {
349 console.log(output.replace(/^/gm, `[${packed.name}] `));
350 }
351 if (result.exitCode !== 0) {
352 throw new Error(`npm publish failed for ${packed.name} (exit ${result.exitCode})`);
353 }
354};
355
356/** Publish concurrently: these are distinct packages, so no two publishes
357 * touch the same npm packument (the 409 hazard that forces the executor CLI

Callers 1

publishAllFunction · 0.85

Calls 5

logMethod · 0.80
pushMethod · 0.80
toStringMethod · 0.80
packageAlreadyPublishedFunction · 0.70
replaceMethod · 0.65

Tested by

no test coverage detected