/** * Points the bound projects' protected checks at this image (docs/cluster-poc-deployment.md): * a project migrated from the Mac still names the Mac's Node and check script, which no check Pod * has. The platform container runs this before the control plane starts; see clusterCheckCommands. */ import { readFile } from 'node:fs/promises'; import { PgStore } from '../apps/api/src/db/store.js'; import { touch } from '../apps/api/src/domain/control-plane.js'; import { localPocBindingSchema } from '../packages/runtime/src/index.js'; import type { Project } from '../packages/contracts/src/index.js'; import { clusterCheckCommands } from './cluster-poc-entry.mjs'; const bindings = [JSON.parse(await readFile(process.env.WF_LOCAL_POC_BINDING_FILE!, 'utf8'))] .flat() .map(binding => localPocBindingSchema.parse(binding)); const store = new PgStore(process.env.DATABASE_URL!); try { await store.assertSafeRole(); for (const binding of bindings) { const changed = await store.transaction(binding.tenantId, async tx => { const project = await tx.get('project', binding.projectId); if (!project) return false; const installCommands = clusterCheckCommands(project.installCommands, 'install'); const verificationCommands = clusterCheckCommands(project.verificationCommands, 'verify'); if (installCommands === project.installCommands && verificationCommands === project.verificationCommands) return false; await tx.put('project', touch({ ...project, installCommands, verificationCommands })); return true; }); console.log( changed ? `Pointed project ${binding.projectId}’s protected checks at this image.` : `Project ${binding.projectId}’s protected checks already point at this image.`, ); } } finally { await store.close(); }