openclaw/scripts/openclaw-postpack.mjs
Peter Steinberger 2d5fe992ab
fix(packaging): preserve package markers and clean up smoke layouts (#134835)
* fix(packaging): preserve markers across package lifecycle handoffs

Create the distribution inventory only after the existing package receipt
is acquired, and remove lifecycle markers before releasing that receipt.
Rejected contenders and finishing owners must not mutate the next package's
marker. Keep smoke validation before acquisition and retain its existing
failure behavior.

Cover contention, cleanup faults, successful and failed handoffs, selected
plugin restoration, and the frozen source writer. Production delta is zero.

* fix(packaging): clean up bundled channel smoke layouts

Return the child status from the temporary-layout owner so its finally
cleanup runs before the CLI exits. Cover setup in the same lifetime and
keep installed-layout selection and child failure behavior unchanged.

Extend the maintained fixture across source and installed layouts, checking
exit behavior, unchanged package bytes and caller-owned temporary siblings.
2026-09-01 03:47:17 -07:00

34 lines
1.2 KiB
JavaScript
Executable file

#!/usr/bin/env node
import { rm } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
import {
LEGACY_PACKAGE_INSTALL_GUARD_RELATIVE_PATH,
PACKAGE_LIFECYCLE_PENDING_RELATIVE_PATH,
} from "./lib/package-lifecycle-marker.mjs";
// Restores every source artifact temporarily rewritten for npm packaging.
import { restorePackageChangelog } from "./package-changelog.mjs";
import { restorePackageDocsMap } from "./package-docs-map.mjs";
import { restorePackageManifest } from "./package-manifest.mjs";
export async function restorePrepackArtifacts(cwd = process.cwd()) {
await restorePackageChangelog(cwd);
await restorePackageManifest(cwd);
await Promise.all(
[PACKAGE_LIFECYCLE_PENDING_RELATIVE_PATH, LEGACY_PACKAGE_INSTALL_GUARD_RELATIVE_PATH].map(
(relativePath) => rm(path.join(cwd, relativePath), { force: true }),
),
);
// Release the lifecycle receipt only after every other source mutation settles.
await restorePackageDocsMap(cwd);
}
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
try {
await restorePrepackArtifacts();
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}
}