Files
hyperframes/packages/aws-lambda/scripts/lock-runtime.ts
T
James RussoandClaude Opus 5.5 f9255e39a5 fix(aws-lambda): the handler ZIP installs its runtime from a committed lockfile with scripts off (#7485)
* fix(aws-lambda): the handler ZIP installs its runtime from a committed lockfile with scripts off

build-zip.ts ran `npm install --no-package-lock` in the publish job, so
transitive versions floated at release time and any dependency's install
script ran beside the release credentials. The ZIP now runs `npm ci
--ignore-scripts` from runtime-lock/<source>/package-lock.json (versions
and integrity for every package), and the build fails if that lock
disagrees with bun.lock instead of falling back to a range or "latest".
`bun packages/aws-lambda/scripts/lock-runtime.ts` regenerates it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(aws-lambda): check only direct runtime versions against bun.lock; Renovate refreshes the rest

The runtime lock's transitive tree is npm's own resolution, not bun.lock's (modern-tar
0.8.6 there vs 0.8.4 in bun.lock), so the parity claim now covers puppeteer-core and
@sparticuz/chromium only. Renovate's weekly lockFileMaintenance refreshes the transitive
tree; its direct-version bumps are off for these dirs because those follow bun.lock.

— Rames Jusso

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(aws-lambda): keep the maintainer-only lock-runtime script out of the package

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:41:20 +00:00

46 lines
1.7 KiB
TypeScript

/**
* Regenerates the committed lockfiles the Lambda handler ZIP installs from, one per Chrome source,
* with puppeteer-core and @sparticuz/chromium at the exact versions bun.lock resolved. npm resolves
* the transitive tree, and Renovate's weekly lockFileMaintenance keeps it current. Run after
* bumping puppeteer-core or @sparticuz/chromium:
* bun packages/aws-lambda/scripts/lock-runtime.ts
*/
import { spawnSync } from "node:child_process";
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import {
BUN_LOCK_PATH,
RUNTIME_LOCK_DIR,
RUNTIME_SOURCES,
bunLockVersion,
runtimePackages,
} from "./runtimeLock.js";
const bunLock = readFileSync(BUN_LOCK_PATH, "utf-8");
for (const source of RUNTIME_SOURCES) {
const dir = join(RUNTIME_LOCK_DIR, source);
mkdirSync(dir, { recursive: true });
rmSync(join(dir, "package-lock.json"), { force: true });
const dependencies = Object.fromEntries(
runtimePackages(source).map((name) => {
const version = bunLockVersion(bunLock, name);
if (!version) throw new Error(`[lock-runtime] bun.lock has no entry for ${name}`);
return [name, version];
}),
);
const pkg = {
name: "hyperframes-aws-lambda-bundled",
version: "0.0.0",
private: true,
dependencies,
};
writeFileSync(join(dir, "package.json"), `${JSON.stringify(pkg, null, 2)}\n`);
const result = spawnSync(
"npm",
["install", "--package-lock-only", "--ignore-scripts", "--no-audit", "--no-fund"],
{ cwd: dir, stdio: "inherit" },
);
if (result.status !== 0) throw new Error(`[lock-runtime] npm failed for ${source}`);
console.log(`[lock-runtime] ${source}: ${JSON.stringify(dependencies)}`);
}