Files
reverse-engineering-anything/scripts/verify-release-artifact.mjs
T
morluto 011cd93619 refactor(verify): give the package and release verifiers' roots to VerifierFixture (#11175)
* refactor(verify): give the package and release verifiers' roots to VerifierFixture

* fix(verify): import VerifierFixture at the published-package verifier's top level
2026-11-15 22:01:49 +08:00

55 lines
1.8 KiB
JavaScript

import { createPackageVerifierCommands } from "./lib/verify-package-commands.mjs";
import { withVerifierCleanup } from "./lib/verifier-cleanup.mjs";
import { join, resolve } from "node:path";
import { valid } from "semver";
import {
installCanaryPackage,
verifyInstalledCanaryPackage,
} from "./lib/release-package-canary.mjs";
import { completeVerifierRun, createVerifierRun } from "./lib/verifier-run.mjs";
import { VerifierFixture } from "./lib/verifier-fixture.mjs";
const [tarball, version, ...extra] = process.argv.slice(2);
if (
tarball === undefined ||
typeof version !== "string" ||
valid(version) !== version ||
extra.length
)
throw new Error(
"Usage: node scripts/verify-release-artifact.mjs <qualified-tarball> <version>",
);
const source = resolve(tarball);
const verifierRun = createVerifierRun();
// npm and the package's children write beneath the root, as under the former mkdtemp.
const fixture = await VerifierFixture.open({
prefix: "rea-release-rehearsal-",
private: false,
});
const workspace = fixture.path;
const environment = {
...process.env,
npm_config_cache: join(workspace, "npm-cache"),
};
delete environment.HOPPER_TARGET_PATH;
const commands = await createPackageVerifierCommands({
// The package command owner releases the fixture after its commands close.
workspace: { path: workspace, close: () => fixture.release() },
});
let result;
await withVerifierCleanup(async () => {
const packageRoot = await installCanaryPackage(
source,
workspace,
environment,
commands,
);
result = await verifyInstalledCanaryPackage(packageRoot, version, workspace, {
environment: environment,
commands,
});
}, [() => commands.close()]);
process.stdout.write(
`${JSON.stringify({ verifier_run: await completeVerifierRun(verifierRun), package: "rea-agents", version, source, ...result })}\n`,
);