← Files ModRetro Chromatic PluginARCHIVED FILE
dist/toolchain-prepare.js
1.57 KB · Dec 3, 2026 · 18:19 UTC
import path from "node:path";
import { pathToFileURL } from "node:url";
import { readPlatformEnvironmentVariable } from "./platform.js";
/** Keep installation in the packaged setup manager: it owns locks, provenance and cancellation. */
export async function prepareToolchain(packageRoot, components, options = {}) {
const environment = options.environment ?? process.env;
const moduleUrl = pathToFileURL(path.join(packageRoot, "scripts/setup.mjs")).href;
const run = options.run ?? (await import(moduleUrl)).runSetup;
const args = ["--components", [...new Set(components)].join(","), "--json"];
const boundRoot = readPlatformEnvironmentVariable(environment, "GB_STUDIO_TOOLCHAIN_ROOT");
const context = { packageRoot, environment, signal: options.signal, boundToolchainRoot: boundRoot ? path.resolve(boundRoot) : undefined };
const plan = await run(["plan", ...args], context);
if (!plan.canApply)
return { success: false, stage: "blocked", plan, message: plan.rootIssue ?? "Game tools could not be prepared. Keep the existing installation and inspect the setup result." };
const result = await run(["apply", ...args, "--yes"], context);
return { success: result.status === "complete", stage: result.status === "complete" ? "ready" : "incomplete", result,
message: result.status === "complete" ? "Game tools are ready. Continue the original build or preview in this session."
: "Game tool setup did not finish. Completed components are preserved; inspect the failure before any retry." };
}
//# sourceMappingURL=toolchain-prepare.js.mapSHA-256: 3adda5c9faa40e0c2c7619280eb2a194a5d556ff8a72129362c6dec0559f9d5e