Files
scriptc/packages/cli/scripts/warm-cache.mjs
T
Chris Tate a523b615c1 feat(runtime): ship precompiled macOS artifacts
- Add a versioned macOS arm64 runtime pack with deterministic feature selection and artifact verification.
- Link LLVM helper objects against release-built runtime and vendor inputs without compiling user-machine C.
- Wire package publishing, cache validation, documentation, and full-gate coverage for the new path.
2026-08-27 16:46:35 -05:00

30 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
import { existsSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
// Workspace installs should stay cheap and deterministic: repository test
// images already manage cache warming explicitly. Published npm packages do
// not contain src/, so only installed consumers take this best-effort path.
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
if (
!existsSync(join(packageRoot, "src")) &&
process.env["SCRIPTC_NO_CACHE"] !== "1" &&
// The macOS arm64 install already carries immutable release/dev runtime
// artifacts. Do not compile a second toolchain-specific copy at install.
!(process.platform === "darwin" && process.arch === "arm64")
) {
try {
const { warmNativeCaches } = await import("@scriptc/compiler");
await warmNativeCaches();
} catch (error) {
// Installation must never depend on a native toolchain. A machine without
// clang/ar (or with lifecycle scripts disabled) retains ordinary lazy
// first-build behavior; explicit `scriptc cache warm` reports errors.
if (process.env["SCRIPTC_CACHE_WARM_DEBUG"] === "1") {
process.stderr.write(`scriptc: cache warm skipped: ${error instanceof Error ? error.message : String(error)}\n`);
}
}
}