@reddoorla/maintenance 0.83.0 → 0.84.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/bin.js
CHANGED
|
@@ -138,7 +138,7 @@ cli.command(
|
|
|
138
138
|
"Add the Prismic model delivery workflow to a site via PR (one PR per repo; never pushes to main)."
|
|
139
139
|
).option("--dry", "List the sites that would be offered the workflow, without opening any PR").option("--fleet <inventory>", 'Inventory file (.json or .mjs/.js), or "airtable"').option("--workdir <path>", "Clone target for fleet mode (default ~/.reddoor-maint/sites)").action(
|
|
140
140
|
async (site, opts) => runOrExit(
|
|
141
|
-
async () => (await import("../prismic-ci-
|
|
141
|
+
async () => (await import("../prismic-ci-4PDATHU6.js")).runPrismicCiCommand(site, opts),
|
|
142
142
|
opts
|
|
143
143
|
)
|
|
144
144
|
);
|
|
@@ -49,8 +49,8 @@ import { readdir } from "fs/promises";
|
|
|
49
49
|
import { resolve } from "path";
|
|
50
50
|
|
|
51
51
|
// src/recipes/prismic-ci/index.ts
|
|
52
|
-
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
53
|
-
import { dirname, join } from "path";
|
|
52
|
+
import { mkdir, readFile as readFile2, writeFile } from "fs/promises";
|
|
53
|
+
import { dirname, join as join2 } from "path";
|
|
54
54
|
|
|
55
55
|
// src/recipes/prismic-ci/template.ts
|
|
56
56
|
var WORKFLOW_PATH = ".github/workflows/prismic-models.yml";
|
|
@@ -111,6 +111,75 @@ jobs:
|
|
|
111
111
|
}
|
|
112
112
|
var PRISMIC_CI_WORKFLOW = prismicCiWorkflow(REUSABLE_WORKFLOW_PIN);
|
|
113
113
|
|
|
114
|
+
// src/recipes/prismic-ci/cli-version.ts
|
|
115
|
+
import { readFile } from "fs/promises";
|
|
116
|
+
import { join } from "path";
|
|
117
|
+
var MIN_CLI_VERSION = "0.83.0";
|
|
118
|
+
var PACKAGE = "@reddoorla/maintenance";
|
|
119
|
+
function atLeast(version, min) {
|
|
120
|
+
const parse = (v) => {
|
|
121
|
+
const [core = "", ...rest] = v.split("-");
|
|
122
|
+
return {
|
|
123
|
+
nums: core.split(".").map((n) => Number.parseInt(n, 10) || 0),
|
|
124
|
+
pre: rest.length > 0
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
const a = parse(version);
|
|
128
|
+
const b = parse(min);
|
|
129
|
+
for (let i = 0; i < 3; i++) {
|
|
130
|
+
const av = a.nums[i] ?? 0;
|
|
131
|
+
const bv = b.nums[i] ?? 0;
|
|
132
|
+
if (av !== bv) return av > bv;
|
|
133
|
+
}
|
|
134
|
+
if (a.pre && !b.pre) return false;
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
async function readLockedCliVersion(repoRoot) {
|
|
138
|
+
let raw;
|
|
139
|
+
try {
|
|
140
|
+
raw = await readFile(join(repoRoot, "pnpm-lock.yaml"), "utf-8");
|
|
141
|
+
} catch (err) {
|
|
142
|
+
const code = err.code;
|
|
143
|
+
if (code === "ENOENT") {
|
|
144
|
+
return {
|
|
145
|
+
ok: false,
|
|
146
|
+
reason: `no pnpm-lock.yaml in the checkout \u2014 cannot tell which ${PACKAGE} version CI would run`
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return { ok: false, reason: `pnpm-lock.yaml is present but unreadable (${String(err)})` };
|
|
150
|
+
}
|
|
151
|
+
const lines = raw.split("\n");
|
|
152
|
+
const importersAt = lines.findIndex((l) => /^importers:\s*$/.test(l));
|
|
153
|
+
if (importersAt === -1) {
|
|
154
|
+
return {
|
|
155
|
+
ok: false,
|
|
156
|
+
reason: "pnpm-lock.yaml has no `importers:` section \u2014 unrecognised lockfile shape"
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const end = lines.findIndex((l, i) => i > importersAt && /^[a-zA-Z]/.test(l));
|
|
160
|
+
const importers = lines.slice(importersAt + 1, end === -1 ? lines.length : end);
|
|
161
|
+
const found = /* @__PURE__ */ new Set();
|
|
162
|
+
for (let i = 0; i < importers.length; i++) {
|
|
163
|
+
if (!new RegExp(`^\\s+'?${PACKAGE.replace("/", "\\/")}'?:\\s*$`).test(importers[i])) continue;
|
|
164
|
+
for (let j = i + 1; j < Math.min(i + 4, importers.length); j++) {
|
|
165
|
+
const m = /^\s+version:\s*(\S+)\s*$/.exec(importers[j]);
|
|
166
|
+
if (!m) continue;
|
|
167
|
+
found.add(m[1].split("(")[0]);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (found.size === 0) {
|
|
172
|
+
return { ok: false, reason: `${PACKAGE} is not a dependency in this repo's lockfile` };
|
|
173
|
+
}
|
|
174
|
+
if (found.size > 1) {
|
|
175
|
+
return {
|
|
176
|
+
ok: false,
|
|
177
|
+
reason: `lockfile resolves ${PACKAGE} to more than one version (${[...found].sort().join(", ")}) \u2014 refusing to guess which one CI would run`
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
return { ok: true, version: [...found][0] };
|
|
181
|
+
}
|
|
182
|
+
|
|
114
183
|
// src/recipes/prismic-ci/index.ts
|
|
115
184
|
var BRANCH_PREFIX = "maint/prismic-ci-";
|
|
116
185
|
var PRETTIER_TIMEOUT_MS = 6e4;
|
|
@@ -154,6 +223,21 @@ async function prismicCi(site, deps = {}) {
|
|
|
154
223
|
);
|
|
155
224
|
}
|
|
156
225
|
const workflow = pin === REUSABLE_WORKFLOW_PIN ? PRISMIC_CI_WORKFLOW : prismicCiWorkflow(pin);
|
|
226
|
+
const locked = await readLockedCliVersion(site.path);
|
|
227
|
+
if (!locked.ok) {
|
|
228
|
+
return resultOf(
|
|
229
|
+
site,
|
|
230
|
+
"failed",
|
|
231
|
+
`cannot establish which @reddoorla/maintenance version this repo's CI would run (${locked.reason}) \u2014 refusing to install a workflow that may not run`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
if (!atLeast(locked.version, MIN_CLI_VERSION)) {
|
|
235
|
+
return resultOf(
|
|
236
|
+
site,
|
|
237
|
+
"failed",
|
|
238
|
+
`this repo's lockfile pins @reddoorla/maintenance ${locked.version}, which has no \`prismic-models\` command (first shipped in ${MIN_CLI_VERSION}) \u2014 bump the dependency and commit the lockfile first, or the workflow fails on its first model PR`
|
|
239
|
+
);
|
|
240
|
+
}
|
|
157
241
|
const ghConfig = readGitHubConfig();
|
|
158
242
|
if (!deps.github && !ghConfig) return resultOf(site, "failed", "GITHUB_TOKEN not set");
|
|
159
243
|
const gh = deps.github ?? makeGitHub({ token: ghConfig.token });
|
|
@@ -213,7 +297,7 @@ async function prismicCi(site, deps = {}) {
|
|
|
213
297
|
let pushedOrOpened = false;
|
|
214
298
|
try {
|
|
215
299
|
await createBranch(site.path, branch);
|
|
216
|
-
const dest =
|
|
300
|
+
const dest = join2(site.path, WORKFLOW_PATH);
|
|
217
301
|
await mkdir(dirname(dest), { recursive: true });
|
|
218
302
|
await writeFile(dest, workflow, "utf-8");
|
|
219
303
|
const notes = [];
|
|
@@ -225,7 +309,7 @@ async function prismicCi(site, deps = {}) {
|
|
|
225
309
|
timeoutMs: PRETTIER_TIMEOUT_MS
|
|
226
310
|
})) {
|
|
227
311
|
notes.push(PRETTIER_FLAG_NOTE);
|
|
228
|
-
} else if (!sameWorkflow(await
|
|
312
|
+
} else if (!sameWorkflow(await readFile2(dest, "utf-8"), workflow)) {
|
|
229
313
|
notes.push(
|
|
230
314
|
"this site's prettier reformatted the workflow \u2014 re-runs will not match it as current"
|
|
231
315
|
);
|
|
@@ -360,4 +444,4 @@ export {
|
|
|
360
444
|
formatPrismicCiResults,
|
|
361
445
|
runPrismicCiCommand
|
|
362
446
|
};
|
|
363
|
-
//# sourceMappingURL=prismic-ci-
|
|
447
|
+
//# sourceMappingURL=prismic-ci-4PDATHU6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/prismic-ci.ts","../src/recipes/prismic-ci/index.ts","../src/recipes/prismic-ci/template.ts","../src/recipes/prismic-ci/cli-version.ts"],"sourcesContent":["// The fleet face of the `prismic-ci` recipe: land the Prismic model delivery\n// workflow across the fleet, as ONE PULL REQUEST PER REPOSITORY.\n//\n// The blast radius is fifteen live client repositories, and the failure this\n// file is written against is not a bad PR — the recipe's gates handle that, and\n// nothing here can push to a client's main. It is the QUIET one: a run that\n// touched nothing and exited 0, read as a finished rollout. Three facts only the\n// fleet layer can get wrong produce it, and each has a refusal below:\n//\n// - an inventory that resolved NOBODY prints \"0 applied, 0 noop, 0 failed.\"\n// and exits 0, which is indistinguishable from a fleet with nothing left to\n// do. The Airtable inventory is view-filtered; one filter change empties it\n// with no error anywhere.\n// - a site that could not be PREPARED is isolated into `skipped` by\n// `prepareFleetSites` (correctly — one bad row must not abort the fleet) and\n// then disappears from a summary built out of `prepared` alone. It gets a\n// `failed` ROW, because the count is the only thing a machine reads.\n// - a checkout holding `.git` and nothing else answers \"not a Prismic site\" to\n// every read inside it, so the site noops out of the rollout for good — a\n// fleet workdir reuses any non-empty directory forever. Guarded BEFORE the\n// recipe runs: a tree nobody established is not a tree to branch from.\n//\n// SEQUENTIAL, one site at a time, like every other fleet recipe command — see\n// `runRecipeOverSites`. Each site does git work in its own checkout plus a\n// handful of GitHub calls; there is no Airtable write on this path (so the\n// fleet's ≤4.5 req/s throttle does not apply) and nothing parallelism would buy\n// except a burst of writes against fifteen repositories at once.\nimport { readdir } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { prismicCi } from \"../../recipes/prismic-ci/index.js\";\nimport {\n REUSABLE_WORKFLOW_PIN,\n isPinResolved,\n type ReusableWorkflowPin,\n} from \"../../recipes/prismic-ci/template.js\";\nimport type { RecipeResult, Site } from \"../../types.js\";\nimport { fleetWorkdir } from \"../../util/fleet-workdir.js\";\nimport { siteLabel } from \"../../util/site.js\";\nimport { noWorkingTreeFailure } from \"../../util/working-tree.js\";\nimport { appendSkipNotice, prepareFleetSites, type SkippedSite } from \"../fleet/prepare-sites.js\";\nimport { resolveSites } from \"../fleet/resolve-sites.js\";\nimport { runRecipeOverSites } from \"../fleet/run-recipe-over-sites.js\";\n\nexport type PrismicCiCommandOptions = {\n fleet?: string;\n workdir?: string;\n dry?: boolean;\n cwd?: string;\n};\n\n/** Injected only by tests, so the fleet layer's aggregation — counts, exit code,\n * refusals — is exercised without git, GitHub or a network. Production runs the\n * real recipe. */\nexport type PrismicCiCommandDeps = {\n runRecipe?: (site: Site) => Promise<RecipeResult>;\n /**\n * Which `reddoorla/.github` commit this run would pin. Injected only by tests;\n * production uses the shipped {@link REUSABLE_WORKFLOW_PIN}.\n *\n * It is injectable because the unresolved-pin refusal is a SAFETY behaviour\n * that must be tested in both directions at all times, and a test that reads\n * the shipped constant can only ever exercise whichever direction the constant\n * currently happens to be in. Two tests here did exactly that, and the release\n * that resolved the pin turned them from \"the refusal works\" into a red suite\n * with the refusal itself no longer covered by anything.\n */\n pin?: ReusableWorkflowPin;\n};\n\nconst messageOf = (err: unknown): string => (err instanceof Error ? err.message : String(err));\n\nconst failedRow = (site: string, notes: string): RecipeResult => ({\n recipe: \"prismic-ci\",\n site,\n status: \"failed\",\n commits: [],\n notes,\n});\n\n/**\n * One line per site plus a counts summary — the shape every fleet rollout\n * prints, so a sweep over fifteen repos is scannable.\n *\n * The banner above the counts is not decoration. A rollout in which every site\n * failed prints fifteen `[site] failed:` lines and then an arithmetic exercise;\n * the one fact an operator needs from that run — NOT ONE repository got the\n * workflow — has to be stated. It is keyed on \"sites were attempted and none was\n * applied\", not on \"nothing was applied\": a fleet that is already fully\n * delivered applies nothing every time it runs, and a banner that shouts at that\n * run is a banner nobody reads at the run above.\n */\nexport function formatPrismicCiResults(results: RecipeResult[]): string {\n const lines = results.map((r) => `[${r.site}] ${r.status}: ${r.notes ?? \"\"}`.trimEnd());\n const n = (s: RecipeResult[\"status\"]) => results.filter((r) => r.status === s).length;\n const failed = n(\"failed\");\n lines.push(\"\");\n if (failed > 0 && n(\"applied\") === 0) {\n lines.push(\n `⛔ NO SITE GOT THE DELIVERY WORKFLOW. ${failed} of ${results.length} site(s) failed and` +\n ` not one pull request was opened, so no site's model changes reach Prismic on merge.` +\n ` Do NOT read this run as a rollout.`,\n );\n lines.push(\"\");\n }\n lines.push(`${n(\"applied\")} applied, ${n(\"noop\")} noop, ${failed} failed.`);\n return lines.join(\"\\n\");\n}\n\n/**\n * Is there a checkout here at all, or the named reason there is not?\n *\n * Runs BEFORE the recipe, for both the reason in {@link noWorkingTreeFailure}\n * and one this command adds: the recipe's next steps create a branch, write a\n * file and commit it. A directory nobody managed to check out is not a tree to\n * do that in, and the answer the recipe would otherwise reach — \"not a Prismic\n * site\" — is the one answer that quietly removes the site from the rollout.\n *\n * A `readdir` that THROWS is its own failure and never the skip: a path that\n * does not exist, or one this process cannot read, is not a repo without\n * Prismic in it.\n */\nasync function checkoutFailure(repoRoot: string): Promise<string | null> {\n let entries: string[];\n try {\n entries = await readdir(repoRoot);\n } catch (e) {\n return `cannot read this checkout at ${repoRoot}: ${messageOf(e)}`;\n }\n return noWorkingTreeFailure(\n repoRoot,\n entries,\n \"No delivery workflow was proposed for it and no pull request was opened\",\n );\n}\n\n/**\n * Roll the delivery workflow out to one site or to the fleet.\n *\n * `resolveSites` is allowed to THROW (a positional site alongside `--fleet`, an\n * unsupported inventory extension, an Airtable read that failed). Those are \"the\n * fleet itself could not be established\", which has no per-site row to live in\n * and must not be reported as a rollout across zero sites; `bin.ts` prints the\n * message and exits with the error's own `exitCode`.\n */\nexport async function runPrismicCiCommand(\n site: string | undefined,\n opts: PrismicCiCommandOptions,\n deps: PrismicCiCommandDeps = {},\n): Promise<{ output: string; code: number }> {\n const cwd = opts.cwd ? resolve(opts.cwd) : process.cwd();\n let sites = await resolveSites({\n ...(site !== undefined ? { site } : {}),\n ...(opts.fleet !== undefined ? { fleet: opts.fleet } : {}),\n // Passed through because `--fleet airtable` derives each site's path from\n // it; without it the keyword inventory would resolve paths under a different\n // workdir than the one this run then prepares and commits in.\n ...(opts.workdir !== undefined ? { workdir: opts.workdir } : {}),\n cwd,\n });\n\n // NOTHING RESOLVED IS NOT A DELIVERED FLEET — the refusal `runFleetSweep` and\n // the token doctor both open with, for the same reason: the summary below\n // would print \"0 applied, 0 noop, 0 failed.\" over no rows at all and exit 0,\n // which is exactly what a finished rollout looks like.\n if (sites.length === 0) {\n return {\n output:\n `the inventory resolved NO SITES, so no site was offered the delivery workflow.` +\n ` This is not a delivered fleet — check the inventory (an Airtable view filter, an` +\n ` empty JSON file, a dynamic inventory returning []). Do NOT read this exit as a` +\n ` rollout.`,\n code: 1,\n };\n }\n\n let skipped: SkippedSite[] = [];\n if (opts.fleet) {\n const prep = await prepareFleetSites(sites, { workdir: opts.workdir ?? fleetWorkdir() });\n sites = prep.prepared;\n skipped = prep.skipped;\n }\n\n // THE PIN, checked here as well as in the recipe — not a second copy of the\n // gate but the same exported predicate on the same pin, asked at the one point\n // the recipe cannot answer for: a `--dry` run never reaches the recipe at all,\n // and a preview that promised fifteen pull requests the real run would refuse\n // is a preview of something that cannot happen.\n //\n // ONE pin object serves both this preview and the recipe below, so the preview\n // can never be answering about a different pin than the run it previews.\n const pin = deps.pin ?? REUSABLE_WORKFLOW_PIN;\n const pinUnresolved = !isPinResolved(pin)\n ? `⛔ the reusable-workflow pin is unresolved (${pin.sha}) — every site` +\n ` below would be REFUSED, not delivered. Publish and tag the workflow in` +\n ` reddoorla/.github, then set REUSABLE_WORKFLOW_PIN.`\n : \"\";\n\n if (opts.dry) {\n const lines = sites.map(\n (s) =>\n `[${siteLabel(s)}] would be offered the delivery workflow (no gate was evaluated:` +\n ` the secret, default-branch and already-delivered checks run only on a real run)`,\n );\n return {\n output: appendSkipNotice(\n [pinUnresolved, lines.join(\"\\n\")].filter((s) => s !== \"\").join(\"\\n\\n\"),\n skipped,\n ),\n code: pinUnresolved === \"\" ? 0 : 1,\n };\n }\n\n const run = deps.runRecipe ?? ((s: Site) => prismicCi(s, { pin }));\n const results = await runRecipeOverSites(\"prismic-ci\", sites, async (s) => {\n const failure = await checkoutFailure(s.path);\n return failure ? failedRow(siteLabel(s), failure) : run(s);\n });\n\n // A SITE THAT COULD NOT BE PREPARED IS A SITE THAT DID NOT GET THE WORKFLOW,\n // and it gets a row. `prepareFleetSites` isolates the clone failure into\n // `skipped`, which is right and is also exactly how a site disappears: a\n // summary walking `prepared` alone counts a fleet-wide clone outage — an\n // expired App token, GitHub down, a full disk — as \"0 applied, 0 failed\",\n // exit 0. The notice below stays; the row is what makes the site countable.\n for (const s of skipped) {\n results.push(\n failedRow(\n s.site,\n `could not prepare this checkout: ${s.reason}. No delivery workflow was proposed` +\n ` for it — this is NOT \"this site already has one\".`,\n ),\n );\n }\n\n return {\n output: appendSkipNotice(formatPrismicCiResults(results), skipped),\n code: results.some((r) => r.status === \"failed\") ? 1 : 0,\n };\n}\n","import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { defaultSpawn, type SpawnFn } from \"../../audits/util/spawn.js\";\nimport { readGitHubConfig } from \"../../github/config.js\";\nimport { makeGitHub, type GitHub } from \"../../github/gh.js\";\nimport { readPrismicConfig } from \"../../prismic/models/index.js\";\nimport type { RecipeResult, Site } from \"../../types.js\";\nimport {\n branchName,\n checkoutBranch,\n commit as gitCommit,\n createBranch,\n currentBranch,\n deleteBranch,\n isOwnerRepo,\n isWorkingTreeClean,\n push as gitPush,\n} from \"../../util/git.js\";\nimport { siteLabel } from \"../../util/site.js\";\nimport { formatWithPrettier, resolveTargetPrettier, PRETTIER_FLAG_NOTE } from \"../_prettier.js\";\nimport {\n APPLY_BRANCH,\n PRISMIC_CI_WORKFLOW,\n REUSABLE_WORKFLOW_PIN,\n SECRET,\n WORKFLOW_PATH,\n isPinResolved,\n prismicCiWorkflow,\n type ReusableWorkflowPin,\n} from \"./template.js\";\nimport { MIN_CLI_VERSION, atLeast, readLockedCliVersion } from \"./cli-version.js\";\n\n/** Head-branch prefix of every PR this recipe opens. `branchName(\"prismic-ci\")`\n * produces `maint/prismic-ci-<timestamp>`, and the re-run guard matches on this\n * prefix — the same idiom as `findOpenSelfUpdatingPR`. */\nconst BRANCH_PREFIX = \"maint/prismic-ci-\";\n\n/** How long the target's prettier gets. Also what makes the fleet's default\n * spawn detach the child, so the kill reaches prettier and not just a wrapper.\n * Matches the pull-down path's budget in `src/prismic/models/write.ts`. */\nconst PRETTIER_TIMEOUT_MS = 60_000;\n\n/** Just the GitHub surface this recipe touches, so a test fake is five methods\n * rather than thirty. `makeGitHub()` satisfies it structurally. */\nexport type PrismicCiGitHub = Pick<\n GitHub,\n \"defaultBranch\" | \"secretExists\" | \"fileContentsOnBranch\" | \"openPullRequest\" | \"openPullRequests\"\n>;\n\nexport type PrismicCiDeps = {\n github?: PrismicCiGitHub;\n pushBranch?: (cwd: string, branch: string) => Promise<void>;\n spawn?: SpawnFn;\n /** Resolve the TARGET repo's own prettier. Injected so a test can assert the\n * absolute-path spawn without a populated `node_modules`. */\n resolvePrettier?: (repoRoot: string) => Promise<string | null>;\n /** Which `reddoorla/.github` commit the written workflow pins. Injected only\n * by tests; production uses the shipped pin. */\n pin?: ReusableWorkflowPin;\n};\n\nconst resultOf = (\n site: Site,\n status: RecipeResult[\"status\"],\n notes: string,\n commits: string[] = [],\n): RecipeResult => ({\n recipe: \"prismic-ci\",\n site: siteLabel(site),\n status,\n commits,\n notes,\n});\n\nconst messageOf = (err: unknown): string => (err instanceof Error ? err.message : String(err));\n\n/** Same normalization as `self-updating`'s config comparison: CRLF and a stray\n * trailing newline are not drift, and treating them as drift opens a needless\n * PR on every run. Any real content difference still differs. */\nfunction sameWorkflow(current: string, canonical: string): boolean {\n const norm = (s: string) => s.replace(/\\r\\n/g, \"\\n\").replace(/\\s+$/, \"\");\n return norm(current) === norm(canonical);\n}\n\n/**\n * Land the Prismic model delivery workflow in one repo, as a pull request.\n *\n * Everything before the first mutation is a gate, and the gates exist because\n * this recipe's output is the only path in the project that writes to a live\n * client's Prismic repository. Two of them are worth naming:\n *\n * - THE SECRET. A workflow whose `PRISMIC_WRITE_TOKEN` does not exist yet goes\n * red on the repo's first model PR. Landing 15 of those turns a rollout into\n * 15 red repos, so a definitively-absent secret FAILS the site rather than\n * nooping it: \"this site was skipped and a human must act\" is not the same\n * report as \"this site was already done\", and a rollout summary where those\n * two look alike is how a site silently never gets model delivery. A secret\n * whose existence could not be DETERMINED fails too, with different wording —\n * they are different facts and the operator's next move differs.\n *\n * - THE DEFAULT BRANCH. The reusable workflow's apply job hard-codes\n * `refs/heads/main`. On a repo whose default branch is anything else, every\n * model PR would merge green and never reach Prismic. Refuse instead.\n *\n * Nothing here can delete a model: the workflow it installs calls a module that\n * exports no delete path.\n */\nexport async function prismicCi(site: Site, deps: PrismicCiDeps = {}): Promise<RecipeResult> {\n // 1. Repo identity. `failed`, not `noop`: a rollout that silently skips a site\n // is the failure this whole recipe is guarding against one level up. The\n // strict shape check runs BEFORE the first `gh` call, so a typo'd or\n // attacker-controlled value can never be interpolated into an API path.\n const repo = site.gitRepo;\n if (!repo) {\n return resultOf(site, \"failed\", \"no Git repo on this site (set Airtable 'Git repo')\");\n }\n if (!isOwnerRepo(repo)) {\n return resultOf(\n site,\n \"failed\",\n `refusing to act on malformed repo identity: expected \"owner/repo\", got ${JSON.stringify(repo)}`,\n );\n }\n\n // 2. Is this a Prismic site? `readPrismicConfig` returns null for \"no Prismic\n // here\" and THROWS for a present-but-unreadable config — the distinction is\n // the point, so the throw becomes `failed` rather than being caught into\n // the skip branch.\n let isPrismic: boolean;\n try {\n isPrismic = (await readPrismicConfig(site.path)) !== null;\n } catch (err) {\n return resultOf(site, \"failed\", `could not read the Prismic config: ${messageOf(err)}`);\n }\n if (!isPrismic) return resultOf(site, \"noop\", \"not a Prismic site (no repositoryName) — skipped\");\n\n // 3. The pin. Checked before any network call: while it is unresolved NOTHING\n // can roll out, and 15 pointless API round-trips are not worth spending to\n // find that out per site.\n const pin = deps.pin ?? REUSABLE_WORKFLOW_PIN;\n if (!isPinResolved(pin)) {\n return resultOf(\n site,\n \"failed\",\n `reusable-workflow pin is unresolved (${pin.sha}) — publish + tag the workflow in ` +\n `reddoorla/.github and set REUSABLE_WORKFLOW_PIN before rolling out`,\n );\n }\n const workflow = pin === REUSABLE_WORKFLOW_PIN ? PRISMIC_CI_WORKFLOW : prismicCiWorkflow(pin);\n\n // 3b. THE BINARY THAT WILL ACTUALLY RUN. The reusable workflow does not\n // install this CLI — it runs `pnpm install --frozen-lockfile` and then the\n // site's OWN installed bin, so the version that executes is whatever this\n // repo's lockfile pins. Installing the caller next to a binary with no\n // `prismic-models` command yields a workflow that fails on the first model\n // PR, in a client repo, with an error naming an unknown command rather\n // than a rollout that ran too early.\n //\n // Local and cheap, so it sits with the pin gate ahead of the first network\n // call. And it is a REFUSAL on \"could not establish\", not a pass: the\n // asymmetry is deliberate, because the cost of waiting is a re-run and the\n // cost of being wrong is broken CI on someone else's repository.\n const locked = await readLockedCliVersion(site.path);\n if (!locked.ok) {\n return resultOf(\n site,\n \"failed\",\n `cannot establish which @reddoorla/maintenance version this repo's CI would run ` +\n `(${locked.reason}) — refusing to install a workflow that may not run`,\n );\n }\n if (!atLeast(locked.version, MIN_CLI_VERSION)) {\n return resultOf(\n site,\n \"failed\",\n `this repo's lockfile pins @reddoorla/maintenance ${locked.version}, which has no ` +\n `\\`prismic-models\\` command (first shipped in ${MIN_CLI_VERSION}) — bump the dependency ` +\n `and commit the lockfile first, or the workflow fails on its first model PR`,\n );\n }\n\n const ghConfig = readGitHubConfig();\n if (!deps.github && !ghConfig) return resultOf(site, \"failed\", \"GITHUB_TOKEN not set\");\n const gh = deps.github ?? makeGitHub({ token: ghConfig!.token });\n const spawn = deps.spawn ?? defaultSpawn;\n\n // 4. The secret. Absent and unreadable are separate answers with separate\n // wording; neither proceeds.\n let hasSecret: boolean;\n try {\n hasSecret = await gh.secretExists(repo, SECRET);\n } catch (err) {\n return resultOf(\n site,\n \"failed\",\n `could not determine whether ${repo} has the ${SECRET} secret (${messageOf(err)}) — ` +\n `refusing to install a workflow that may have no token`,\n );\n }\n if (!hasSecret) {\n return resultOf(\n site,\n \"failed\",\n `${repo} has no ${SECRET} Actions secret — the workflow reds the repo on its first ` +\n `model PR without it. Mint one, then: gh secret set ${SECRET} --repo ${repo}`,\n );\n }\n\n // 5. The default branch. NOT `.catch(() => \"main\")`: \"I could not read the\n // default branch\" and \"the default branch is main\" are opposite facts, and\n // guessing the second targets a PR (and an apply gate) at a branch nobody\n // confirmed.\n let base: string;\n try {\n base = await gh.defaultBranch(repo);\n } catch (err) {\n return resultOf(\n site,\n \"failed\",\n `could not read the default branch of ${repo}: ${messageOf(err)}`,\n );\n }\n if (base !== APPLY_BRANCH) {\n return resultOf(\n site,\n \"failed\",\n `default branch of ${repo} is ${base}, not ${APPLY_BRANCH} — the reusable workflow's ` +\n `apply job guards refs/heads/${APPLY_BRANCH}, so merged model changes would never reach Prismic`,\n );\n }\n\n // 6. Already delivered? Content-compared, not existence-compared, so a\n // present-but-STALE workflow (an older pin) is corrected rather than left\n // forever.\n const existing = await gh.fileContentsOnBranch(repo, base, WORKFLOW_PATH);\n if (existing !== null && sameWorkflow(existing, workflow)) {\n return resultOf(site, \"noop\", `delivery workflow already current on ${base}`);\n }\n\n // 7. Already proposed? Without this, every run before the PR merges opens\n // another one. `fileContentsOnBranch` also answers null for a read it could\n // not perform (gh exits non-zero on both a 404 and an auth failure), which\n // makes this the backstop for that collapse as well.\n const open = (await gh.openPullRequests(repo)).find((pr) => pr.headRef.startsWith(BRANCH_PREFIX));\n if (open) {\n return resultOf(site, \"noop\", `delivery workflow PR already open: ${open.url}`);\n }\n\n if (!(await isWorkingTreeClean(site.path))) {\n return resultOf(site, \"failed\", \"working tree not clean — commit or stash first\");\n }\n\n // Capture the operator's branch BEFORE creating ours so the `finally` can put\n // them back. Best-effort: if we cannot read it we skip the restore rather than\n // guess at a branch to check out.\n let original: string | null = null;\n try {\n original = await currentBranch(site.path);\n } catch {\n // Stays null (detached HEAD, git error) — the restore below is then skipped\n // rather than aiming a checkout at a branch name we had to invent.\n }\n const branch = branchName(\"prismic-ci\");\n const commits: string[] = [];\n let pushedOrOpened = false;\n\n try {\n await createBranch(site.path, branch);\n const dest = join(site.path, WORKFLOW_PATH);\n await mkdir(dirname(dest), { recursive: true });\n await writeFile(dest, workflow, \"utf-8\");\n\n // Format with the SITE's own prettier, resolved POSITIVELY and run by\n // absolute path. `pnpm exec prettier` here would run a full `pnpm install`\n // in the client's repo first (an unrequested mutation of a live client repo\n // by a rollout that is supposed to add one file), and in a repo without\n // prettier would then format with the CALLING repo's binary and exit 0.\n const notes: string[] = [];\n const bin = await (deps.resolvePrettier ?? resolveTargetPrettier)(site.path);\n if (bin === null) {\n notes.push(PRETTIER_FLAG_NOTE);\n } else if (\n !(await formatWithPrettier(spawn, site.path, [WORKFLOW_PATH], {\n bin,\n timeoutMs: PRETTIER_TIMEOUT_MS,\n }))\n ) {\n notes.push(PRETTIER_FLAG_NOTE);\n } else if (!sameWorkflow(await readFile(dest, \"utf-8\"), workflow)) {\n // The site's prettier config disagrees with the template's shape (single\n // quotes, a different tab width). Harmless for the workflow — but the\n // step-6 comparison is byte-based, so this site will not recognise its own\n // delivered workflow as current and will propose it again after each\n // merge. Say so rather than let it be discovered as a mystery PR.\n notes.push(\n \"this site's prettier reformatted the workflow — re-runs will not match it as current\",\n );\n }\n\n const sha = await gitCommit(site.path, \"ci: deliver Prismic model changes from merged PRs\");\n if (!sha) {\n // Git saw no change: the checkout already holds this exact workflow even\n // though the default branch does not. Nothing to push and nothing to\n // review — and pushing a commit-less branch would fail at PR creation.\n return resultOf(\n site,\n \"noop\",\n `${WORKFLOW_PATH} already present and identical in the checkout`,\n );\n }\n commits.push(sha);\n pushedOrOpened = true;\n await (deps.pushBranch ?? gitPush)(site.path, branch);\n const pr = await gh.openPullRequest(repo, {\n head: branch,\n base,\n title: \"Deliver Prismic model changes from merged PRs\",\n body:\n \"Adds the `prismic-models` workflow. On a PR touching `customtypes/**` or \" +\n \"`src/lib/slices/**/model.json` it comments the model delta and writes nothing; \" +\n \"on merge to main it pushes those models to Prismic. It can create and update \" +\n \"models but never delete — a model present only in Prismic is reported, not touched.\",\n });\n notes.unshift(`opened PR ${pr.url}`);\n return resultOf(site, \"applied\", notes.join(\"; \"), commits);\n } catch (err) {\n return resultOf(site, \"failed\", messageOf(err), commits);\n } finally {\n // Restore the operator's branch on success AND on failure — otherwise a push\n // error strands the checkout on the recipe branch with an unpushed commit,\n // and the retry dies at createBranch. Best-effort; never masks the result.\n if (original !== null && original !== branch) {\n try {\n await checkoutBranch(site.path, original);\n // Nothing was pushed and no PR exists, so the local branch is litter and\n // a re-run would leave another. Only ever the branch WE created.\n if (!pushedOrOpened) await deleteBranch(site.path, branch);\n } catch (err) {\n console.warn(\n `warning: could not restore branch ${original} after prismic-ci: ${messageOf(err)}`,\n );\n }\n }\n }\n}\n","/**\n * The caller workflow every Prismic site gets.\n *\n * Fully generic — no per-site values — because the token is the site's own\n * `PRISMIC_WRITE_TOKEN` secret, the name every site's code already reads.\n * Contrast `ci.yml`, which is deliberately NOT templated anywhere in this\n * package because it carries per-site `netlify-site:` / `node-version:` values\n * a byte template would strip fleet-wide.\n */\n\n/** Where the file lands in a site repo. Also the `gh api .../contents/<path>`\n * segment, so it must stay traversal-free (`assertUrlSegment` re-checks). */\nexport const WORKFLOW_PATH = \".github/workflows/prismic-models.yml\";\n\n/** The Actions secret the reusable workflow declares as `required: true`, and\n * the environment variable the CLI reads. Spelled ONCE, here, because the\n * failure mode of a second spelling is silent: a caller passing a name the\n * callee never declared supplies nothing, and the callee's required secret\n * arrives empty at the one step that writes to a live client's Prismic repo. */\nexport const SECRET = \"PRISMIC_WRITE_TOKEN\";\n\n/** The reusable workflow, without a ref. */\nexport const REUSABLE_WORKFLOW = \"reddoorla/.github/.github/workflows/prismic-models.yml\";\n\n/**\n * The ONE branch this delivery path can run its apply job on.\n *\n * Not a preference — the reusable workflow's apply job hard-codes\n * `github.ref == 'refs/heads/main'`. On a repo whose default branch is anything\n * else, a merged model PR would produce a green check and never reach Prismic,\n * which is why the recipe refuses such a repo instead of installing a workflow\n * that silently cannot fire.\n */\nexport const APPLY_BRANCH = \"main\";\n\n/** A commit in `reddoorla/.github`, plus the release tag that commit carries.\n * Both are written into the workflow: the SHA is what Actions resolves, the tag\n * is what a human (and Renovate's github-actions manager) reads. */\nexport type ReusableWorkflowPin = { sha: string; tag: string };\n\n/**\n * What the shipped pin says while the reusable workflow has not been published\n * to `reddoorla/.github` and tagged yet (plan Task 25).\n *\n * DELIBERATELY NOT 40 HEX CHARACTERS. A placeholder shaped like a real SHA is\n * indistinguishable from a real one in review, and would install a workflow\n * referencing a commit that does not exist into 15 client repositories — where\n * it fails at workflow-load time, on every model PR, with an error that names\n * neither this file nor the reason. Unresolved must be unmistakable, and\n * {@link isPinResolved} is what the recipe gates on.\n */\nexport const UNRESOLVED_PIN_SHA = \"UNRESOLVED-publish-and-tag-reddoorla-dot-github-first\";\n\n/**\n * The pin the fleet rolls out.\n *\n * RESOLVED 2026-08-14. `reddoorla/.github#30` merged as\n * 558395431ddcb481ecba3dd84b78b38c338cfa03 and that commit was tagged v1.4.0;\n * `gh api repos/reddoorla/.github/commits/v1.4.0 --jq .sha` returns the SHA\n * below. `validate` (the digest-pinning + Renovate-preset check that is the\n * only CI in that repo) passed on the merge commit.\n *\n * TO RE-RESOLVE after a future `reddoorla/.github` release: set `sha` to\n * `gh api repos/reddoorla/.github/commits/<tag> --jq .sha` and `tag` to that\n * tag. Nothing else changes. Renovate's github-actions manager bumps the\n * already-installed `uses:` line per site repo; this constant is what NEW\n * rollouts install, so a stale value here is not a broken fleet, only a fleet\n * whose newest members start one version behind.\n */\nexport const REUSABLE_WORKFLOW_PIN: ReusableWorkflowPin = {\n sha: \"558395431ddcb481ecba3dd84b78b38c338cfa03\",\n tag: \"v1.4.0\",\n};\n\n/**\n * Is this pin a real commit reference?\n *\n * A full 40-hex SHA and nothing else. Not a tag, not a branch: this repo pins\n * every `uses:` to a commit (see `src/recipes/sync-configs/templates.ts`, whose\n * renovate template spells out why — a retagged `@v3` runs attacker code with\n * whatever token the workflow holds), and Renovate's github-actions manager\n * bumps the pin per repo when `reddoorla/.github` tags a new version.\n */\nexport function isPinResolved(pin: ReusableWorkflowPin): boolean {\n return /^[0-9a-f]{40}$/.test(pin.sha);\n}\n\n/**\n * Render the caller workflow for a pin.\n *\n * Path-filtered on both triggers: this must not run on every commit, only when\n * a model changes.\n */\nexport function prismicCiWorkflow(pin: ReusableWorkflowPin): string {\n return `# Delivers this site's Prismic model changes. Managed by @reddoorla/maintenance\n# (\\`reddoor-maint prismic-ci\\`) — change it there and re-run, not here.\n#\n# On a PR touching a model: comment the delta, write nothing.\n# On merge to ${APPLY_BRANCH}: push those models to Prismic. Never delete.\n#\n# THE BRANCH FILTER ON \\`push:\\` IS LOAD-BEARING, not tidiness. The reusable\n# workflow's apply job also guards \\`github.ref == 'refs/heads/${APPLY_BRANCH}'\\`,\n# and its comment calls this the other half of that gate: an unfiltered\n# \\`on: push:\\` fires on every branch AND every tag, so a feature branch's models\n# would reach production with no pull request and therefore no review anywhere in\n# the sequence. Keep both halves.\nname: prismic-models\n\non:\n # No branch filter here, deliberately: a model PR into any base deserves its\n # delta comment, and the dry job is INCAPABLE of writing — it never passes\n # \\`--apply\\`, and it holds no job that does.\n pull_request:\n paths:\n - \"customtypes/**\"\n - \"src/lib/slices/**/model.json\"\n push:\n branches: [${APPLY_BRANCH}]\n paths:\n - \"customtypes/**\"\n - \"src/lib/slices/**/model.json\"\n\njobs:\n prismic-models:\n # A called workflow's jobs can only NARROW what the caller granted, so the\n # PR-comment permission has to be granted here as well as there. Nothing in\n # either job pushes code, so \\`contents\\` stays read.\n permissions:\n contents: read\n pull-requests: write\n uses: ${REUSABLE_WORKFLOW}@${pin.sha} # ${pin.tag}\n secrets:\n # Spelled exactly as the reusable workflow declares it. A workflow-local\n # alias would not be a rename — it would be an undeclared secret, and the\n # required one would arrive empty.\n ${SECRET}: \\${{ secrets.${SECRET} }}\n`;\n}\n\n/** The workflow as currently shipped. Unusable — and refused by the recipe —\n * until {@link REUSABLE_WORKFLOW_PIN} is resolved. */\nexport const PRISMIC_CI_WORKFLOW = prismicCiWorkflow(REUSABLE_WORKFLOW_PIN);\n","import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\n/**\n * The first published version whose `reddoor-maint` bin carries `prismic-models`.\n *\n * VERIFIED BY INSTALLING IT, not by reading a changelog: `npm i\n * @reddoorla/maintenance@0.83.0` in an empty directory, then `reddoor-maint\n * prismic-models --help`, prints the command's usage. Every earlier published\n * version — 0.82.0 included — exits with \"unknown command\".\n *\n * This matters because the reusable workflow does NOT install the CLI. It runs\n * `pnpm install --frozen-lockfile` and then the site's own installed bin, so the\n * version that executes in a client repo is whatever that repo's lockfile pins.\n * Installing the caller workflow next to an older binary produces a workflow\n * that fails at the first model PR, in a client repo, with an error about an\n * unknown command rather than about a rollout that ran too early.\n */\nexport const MIN_CLI_VERSION = \"0.83.0\";\n\n/** The dependency whose version decides whether the workflow can run at all. */\nconst PACKAGE = \"@reddoorla/maintenance\";\n\n/**\n * `version >= min`, compared NUMERICALLY, position by position.\n *\n * Not a string comparison, and not `localeCompare`: as strings `\"0.9.0\" >\n * \"0.83.0\"`, so a lexicographic gate waves through a site pinned seventy-four\n * releases before the command existed. That is the single most likely way for\n * this gate to be wrong while looking right.\n *\n * A prerelease (`0.83.0-beta.1`) sorts BELOW the release it precedes, per\n * semver. The fleet publishes no prereleases today; the rule is here so that if\n * one ever appears it is not silently treated as the release.\n */\nexport function atLeast(version: string, min: string): boolean {\n const parse = (v: string): { nums: number[]; pre: boolean } => {\n const [core = \"\", ...rest] = v.split(\"-\");\n return {\n nums: core.split(\".\").map((n) => Number.parseInt(n, 10) || 0),\n pre: rest.length > 0,\n };\n };\n const a = parse(version);\n const b = parse(min);\n for (let i = 0; i < 3; i++) {\n const av = a.nums[i] ?? 0;\n const bv = b.nums[i] ?? 0;\n if (av !== bv) return av > bv;\n }\n // Cores equal: a prerelease of the minimum is below it; anything else is equal.\n if (a.pre && !b.pre) return false;\n return true;\n}\n\n/** Either the version pnpm resolved, or WHY that could not be established.\n * The two are deliberately different shapes: a caller cannot read \"I could not\n * tell\" as a version by forgetting to check a flag. */\nexport type LockedCliVersion = { ok: true; version: string } | { ok: false; reason: string };\n\n/**\n * The version of {@link PACKAGE} the repo's committed pnpm lockfile resolves.\n *\n * Reads the LOCKFILE, never `package.json`. The declared range is not what\n * executes: espada declares `^0.81.0` and its lockfile resolves 0.69.0, and CI\n * installs `--frozen-lockfile`. A gate reading the range would pass a site whose\n * install is two dozen releases behind it.\n *\n * Parsed with a targeted scan rather than a YAML dependency — this needs one\n * field out of one block, the repo carries no YAML parser, and adding one to\n * read a single `version:` line is not a trade worth making. The scan is\n * deliberately narrow: it reads only `importers:` entries (what is installed),\n * never the `packages:`/`snapshots:` sections, which list every transitively\n * resolvable version and would happily report one nobody installed.\n *\n * Every failure is a NAMED reason, never a version and never a silent default.\n * A gate that cannot tell \"too old\" from \"could not read\" reports one as the\n * other, which is the absent-vs-unreadable collapse this whole feature exists to\n * prevent — arriving here at the last step before writing to a client repo.\n */\nexport async function readLockedCliVersion(repoRoot: string): Promise<LockedCliVersion> {\n let raw: string;\n try {\n raw = await readFile(join(repoRoot, \"pnpm-lock.yaml\"), \"utf-8\");\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n // ENOENT is the only error meaning \"this repo has no lockfile\". EACCES and\n // friends mean it is there and unreadable — a different answer, and one that\n // must not read as \"not a pnpm site\".\n if (code === \"ENOENT\") {\n return {\n ok: false,\n reason: `no pnpm-lock.yaml in the checkout — cannot tell which ${PACKAGE} version CI would run`,\n };\n }\n return { ok: false, reason: `pnpm-lock.yaml is present but unreadable (${String(err)})` };\n }\n\n // Only inside `importers:` — see the note above on packages:/snapshots:.\n const lines = raw.split(\"\\n\");\n const importersAt = lines.findIndex((l) => /^importers:\\s*$/.test(l));\n if (importersAt === -1) {\n return {\n ok: false,\n reason: \"pnpm-lock.yaml has no `importers:` section — unrecognised lockfile shape\",\n };\n }\n const end = lines.findIndex((l, i) => i > importersAt && /^[a-zA-Z]/.test(l));\n const importers = lines.slice(importersAt + 1, end === -1 ? lines.length : end);\n\n const found = new Set<string>();\n for (let i = 0; i < importers.length; i++) {\n if (!new RegExp(`^\\\\s+'?${PACKAGE.replace(\"/\", \"\\\\/\")}'?:\\\\s*$`).test(importers[i]!)) continue;\n // The entry's own `version:` sits within the next few lines, alongside\n // `specifier:`. Bounded so a malformed block cannot walk into the next\n // dependency and attribute its version to this one.\n for (let j = i + 1; j < Math.min(i + 4, importers.length); j++) {\n const m = /^\\s+version:\\s*(\\S+)\\s*$/.exec(importers[j]!);\n if (!m) continue;\n // Strip the peer-dependency suffix: real fleet lockfiles run it past 400\n // characters after the semver.\n found.add(m[1]!.split(\"(\")[0]!);\n break;\n }\n }\n\n if (found.size === 0) {\n return { ok: false, reason: `${PACKAGE} is not a dependency in this repo's lockfile` };\n }\n if (found.size > 1) {\n // Picking one would be a coin flip deciding whether a client repo gets a\n // workflow its binary cannot run.\n return {\n ok: false,\n reason: `lockfile resolves ${PACKAGE} to more than one version (${[...found].sort().join(\", \")}) — refusing to guess which one CI would run`,\n };\n }\n return { ok: true, version: [...found][0]! };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,eAAe;AACxB,SAAS,eAAe;;;AC5BxB,SAAS,OAAO,YAAAA,WAAU,iBAAiB;AAC3C,SAAS,SAAS,QAAAC,aAAY;;;ACWvB,IAAM,gBAAgB;AAOtB,IAAM,SAAS;AAGf,IAAM,oBAAoB;AAW1B,IAAM,eAAe;AAoCrB,IAAM,wBAA6C;AAAA,EACxD,KAAK;AAAA,EACL,KAAK;AACP;AAWO,SAAS,cAAc,KAAmC;AAC/D,SAAO,iBAAiB,KAAK,IAAI,GAAG;AACtC;AAQO,SAAS,kBAAkB,KAAkC;AAClE,SAAO;AAAA;AAAA;AAAA;AAAA,gBAIO,YAA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AC;AACvF,YAAQ,KAAK;AACb,cAAU,KAAK;AAAA,EACjB;AAUA,QAAM,MAAM,KAAK,OAAO;AACxB,QAAM,gBAAgB,CAAC,cAAc,GAAG,IACpC,mDAA8C,IAAI,GAAG,kJAGrD;AAEJ,MAAI,KAAK,KAAK;AACZ,UAAM,QAAQ,MAAM;AAAA,MAClB,CAAC,MACC,IAAI,UAAU,CAAC,CAAC;AAAA,IAEpB;AACA,WAAO;AAAA,MACL,QAAQ;AAAA,QACN,CAAC,eAAe,MAAM,KAAK,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,MAAM,EAAE,EAAE,KAAK,MAAM;AAAA,QACrE;AAAA,MACF;AAAA,MACA,MAAM,kBAAkB,KAAK,IAAI;AAAA,IACnC;AAAA,EACF;AAEA,QAAM,MAAM,KAAK,cAAc,CAAC,MAAY,UAAU,GAAG,EAAE,IAAI,CAAC;AAChE,QAAM,UAAU,MAAM,mBAAmB,cAAc,OAAO,OAAO,MAAM;AACzE,UAAM,UAAU,MAAM,gBAAgB,EAAE,IAAI;AAC5C,WAAO,UAAU,UAAU,UAAU,CAAC,GAAG,OAAO,IAAI,IAAI,CAAC;AAAA,EAC3D,CAAC;AAQD,aAAW,KAAK,SAAS;AACvB,YAAQ;AAAA,MACN;AAAA,QACE,EAAE;AAAA,QACF,oCAAoC,EAAE,MAAM;AAAA,MAE9C;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,QAAQ,iBAAiB,uBAAuB,OAAO,GAAG,OAAO;AAAA,IACjE,MAAM,QAAQ,KAAK,CAAC,MAAM,EAAE,WAAW,QAAQ,IAAI,IAAI;AAAA,EACzD;AACF;","names":["readFile","join","join","readFile","messageOf"]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/commands/prismic-ci.ts","../src/recipes/prismic-ci/index.ts","../src/recipes/prismic-ci/template.ts"],"sourcesContent":["// The fleet face of the `prismic-ci` recipe: land the Prismic model delivery\n// workflow across the fleet, as ONE PULL REQUEST PER REPOSITORY.\n//\n// The blast radius is fifteen live client repositories, and the failure this\n// file is written against is not a bad PR — the recipe's gates handle that, and\n// nothing here can push to a client's main. It is the QUIET one: a run that\n// touched nothing and exited 0, read as a finished rollout. Three facts only the\n// fleet layer can get wrong produce it, and each has a refusal below:\n//\n// - an inventory that resolved NOBODY prints \"0 applied, 0 noop, 0 failed.\"\n// and exits 0, which is indistinguishable from a fleet with nothing left to\n// do. The Airtable inventory is view-filtered; one filter change empties it\n// with no error anywhere.\n// - a site that could not be PREPARED is isolated into `skipped` by\n// `prepareFleetSites` (correctly — one bad row must not abort the fleet) and\n// then disappears from a summary built out of `prepared` alone. It gets a\n// `failed` ROW, because the count is the only thing a machine reads.\n// - a checkout holding `.git` and nothing else answers \"not a Prismic site\" to\n// every read inside it, so the site noops out of the rollout for good — a\n// fleet workdir reuses any non-empty directory forever. Guarded BEFORE the\n// recipe runs: a tree nobody established is not a tree to branch from.\n//\n// SEQUENTIAL, one site at a time, like every other fleet recipe command — see\n// `runRecipeOverSites`. Each site does git work in its own checkout plus a\n// handful of GitHub calls; there is no Airtable write on this path (so the\n// fleet's ≤4.5 req/s throttle does not apply) and nothing parallelism would buy\n// except a burst of writes against fifteen repositories at once.\nimport { readdir } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { prismicCi } from \"../../recipes/prismic-ci/index.js\";\nimport {\n REUSABLE_WORKFLOW_PIN,\n isPinResolved,\n type ReusableWorkflowPin,\n} from \"../../recipes/prismic-ci/template.js\";\nimport type { RecipeResult, Site } from \"../../types.js\";\nimport { fleetWorkdir } from \"../../util/fleet-workdir.js\";\nimport { siteLabel } from \"../../util/site.js\";\nimport { noWorkingTreeFailure } from \"../../util/working-tree.js\";\nimport { appendSkipNotice, prepareFleetSites, type SkippedSite } from \"../fleet/prepare-sites.js\";\nimport { resolveSites } from \"../fleet/resolve-sites.js\";\nimport { runRecipeOverSites } from \"../fleet/run-recipe-over-sites.js\";\n\nexport type PrismicCiCommandOptions = {\n fleet?: string;\n workdir?: string;\n dry?: boolean;\n cwd?: string;\n};\n\n/** Injected only by tests, so the fleet layer's aggregation — counts, exit code,\n * refusals — is exercised without git, GitHub or a network. Production runs the\n * real recipe. */\nexport type PrismicCiCommandDeps = {\n runRecipe?: (site: Site) => Promise<RecipeResult>;\n /**\n * Which `reddoorla/.github` commit this run would pin. Injected only by tests;\n * production uses the shipped {@link REUSABLE_WORKFLOW_PIN}.\n *\n * It is injectable because the unresolved-pin refusal is a SAFETY behaviour\n * that must be tested in both directions at all times, and a test that reads\n * the shipped constant can only ever exercise whichever direction the constant\n * currently happens to be in. Two tests here did exactly that, and the release\n * that resolved the pin turned them from \"the refusal works\" into a red suite\n * with the refusal itself no longer covered by anything.\n */\n pin?: ReusableWorkflowPin;\n};\n\nconst messageOf = (err: unknown): string => (err instanceof Error ? err.message : String(err));\n\nconst failedRow = (site: string, notes: string): RecipeResult => ({\n recipe: \"prismic-ci\",\n site,\n status: \"failed\",\n commits: [],\n notes,\n});\n\n/**\n * One line per site plus a counts summary — the shape every fleet rollout\n * prints, so a sweep over fifteen repos is scannable.\n *\n * The banner above the counts is not decoration. A rollout in which every site\n * failed prints fifteen `[site] failed:` lines and then an arithmetic exercise;\n * the one fact an operator needs from that run — NOT ONE repository got the\n * workflow — has to be stated. It is keyed on \"sites were attempted and none was\n * applied\", not on \"nothing was applied\": a fleet that is already fully\n * delivered applies nothing every time it runs, and a banner that shouts at that\n * run is a banner nobody reads at the run above.\n */\nexport function formatPrismicCiResults(results: RecipeResult[]): string {\n const lines = results.map((r) => `[${r.site}] ${r.status}: ${r.notes ?? \"\"}`.trimEnd());\n const n = (s: RecipeResult[\"status\"]) => results.filter((r) => r.status === s).length;\n const failed = n(\"failed\");\n lines.push(\"\");\n if (failed > 0 && n(\"applied\") === 0) {\n lines.push(\n `⛔ NO SITE GOT THE DELIVERY WORKFLOW. ${failed} of ${results.length} site(s) failed and` +\n ` not one pull request was opened, so no site's model changes reach Prismic on merge.` +\n ` Do NOT read this run as a rollout.`,\n );\n lines.push(\"\");\n }\n lines.push(`${n(\"applied\")} applied, ${n(\"noop\")} noop, ${failed} failed.`);\n return lines.join(\"\\n\");\n}\n\n/**\n * Is there a checkout here at all, or the named reason there is not?\n *\n * Runs BEFORE the recipe, for both the reason in {@link noWorkingTreeFailure}\n * and one this command adds: the recipe's next steps create a branch, write a\n * file and commit it. A directory nobody managed to check out is not a tree to\n * do that in, and the answer the recipe would otherwise reach — \"not a Prismic\n * site\" — is the one answer that quietly removes the site from the rollout.\n *\n * A `readdir` that THROWS is its own failure and never the skip: a path that\n * does not exist, or one this process cannot read, is not a repo without\n * Prismic in it.\n */\nasync function checkoutFailure(repoRoot: string): Promise<string | null> {\n let entries: string[];\n try {\n entries = await readdir(repoRoot);\n } catch (e) {\n return `cannot read this checkout at ${repoRoot}: ${messageOf(e)}`;\n }\n return noWorkingTreeFailure(\n repoRoot,\n entries,\n \"No delivery workflow was proposed for it and no pull request was opened\",\n );\n}\n\n/**\n * Roll the delivery workflow out to one site or to the fleet.\n *\n * `resolveSites` is allowed to THROW (a positional site alongside `--fleet`, an\n * unsupported inventory extension, an Airtable read that failed). Those are \"the\n * fleet itself could not be established\", which has no per-site row to live in\n * and must not be reported as a rollout across zero sites; `bin.ts` prints the\n * message and exits with the error's own `exitCode`.\n */\nexport async function runPrismicCiCommand(\n site: string | undefined,\n opts: PrismicCiCommandOptions,\n deps: PrismicCiCommandDeps = {},\n): Promise<{ output: string; code: number }> {\n const cwd = opts.cwd ? resolve(opts.cwd) : process.cwd();\n let sites = await resolveSites({\n ...(site !== undefined ? { site } : {}),\n ...(opts.fleet !== undefined ? { fleet: opts.fleet } : {}),\n // Passed through because `--fleet airtable` derives each site's path from\n // it; without it the keyword inventory would resolve paths under a different\n // workdir than the one this run then prepares and commits in.\n ...(opts.workdir !== undefined ? { workdir: opts.workdir } : {}),\n cwd,\n });\n\n // NOTHING RESOLVED IS NOT A DELIVERED FLEET — the refusal `runFleetSweep` and\n // the token doctor both open with, for the same reason: the summary below\n // would print \"0 applied, 0 noop, 0 failed.\" over no rows at all and exit 0,\n // which is exactly what a finished rollout looks like.\n if (sites.length === 0) {\n return {\n output:\n `the inventory resolved NO SITES, so no site was offered the delivery workflow.` +\n ` This is not a delivered fleet — check the inventory (an Airtable view filter, an` +\n ` empty JSON file, a dynamic inventory returning []). Do NOT read this exit as a` +\n ` rollout.`,\n code: 1,\n };\n }\n\n let skipped: SkippedSite[] = [];\n if (opts.fleet) {\n const prep = await prepareFleetSites(sites, { workdir: opts.workdir ?? fleetWorkdir() });\n sites = prep.prepared;\n skipped = prep.skipped;\n }\n\n // THE PIN, checked here as well as in the recipe — not a second copy of the\n // gate but the same exported predicate on the same pin, asked at the one point\n // the recipe cannot answer for: a `--dry` run never reaches the recipe at all,\n // and a preview that promised fifteen pull requests the real run would refuse\n // is a preview of something that cannot happen.\n //\n // ONE pin object serves both this preview and the recipe below, so the preview\n // can never be answering about a different pin than the run it previews.\n const pin = deps.pin ?? REUSABLE_WORKFLOW_PIN;\n const pinUnresolved = !isPinResolved(pin)\n ? `⛔ the reusable-workflow pin is unresolved (${pin.sha}) — every site` +\n ` below would be REFUSED, not delivered. Publish and tag the workflow in` +\n ` reddoorla/.github, then set REUSABLE_WORKFLOW_PIN.`\n : \"\";\n\n if (opts.dry) {\n const lines = sites.map(\n (s) =>\n `[${siteLabel(s)}] would be offered the delivery workflow (no gate was evaluated:` +\n ` the secret, default-branch and already-delivered checks run only on a real run)`,\n );\n return {\n output: appendSkipNotice(\n [pinUnresolved, lines.join(\"\\n\")].filter((s) => s !== \"\").join(\"\\n\\n\"),\n skipped,\n ),\n code: pinUnresolved === \"\" ? 0 : 1,\n };\n }\n\n const run = deps.runRecipe ?? ((s: Site) => prismicCi(s, { pin }));\n const results = await runRecipeOverSites(\"prismic-ci\", sites, async (s) => {\n const failure = await checkoutFailure(s.path);\n return failure ? failedRow(siteLabel(s), failure) : run(s);\n });\n\n // A SITE THAT COULD NOT BE PREPARED IS A SITE THAT DID NOT GET THE WORKFLOW,\n // and it gets a row. `prepareFleetSites` isolates the clone failure into\n // `skipped`, which is right and is also exactly how a site disappears: a\n // summary walking `prepared` alone counts a fleet-wide clone outage — an\n // expired App token, GitHub down, a full disk — as \"0 applied, 0 failed\",\n // exit 0. The notice below stays; the row is what makes the site countable.\n for (const s of skipped) {\n results.push(\n failedRow(\n s.site,\n `could not prepare this checkout: ${s.reason}. No delivery workflow was proposed` +\n ` for it — this is NOT \"this site already has one\".`,\n ),\n );\n }\n\n return {\n output: appendSkipNotice(formatPrismicCiResults(results), skipped),\n code: results.some((r) => r.status === \"failed\") ? 1 : 0,\n };\n}\n","import { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { defaultSpawn, type SpawnFn } from \"../../audits/util/spawn.js\";\nimport { readGitHubConfig } from \"../../github/config.js\";\nimport { makeGitHub, type GitHub } from \"../../github/gh.js\";\nimport { readPrismicConfig } from \"../../prismic/models/index.js\";\nimport type { RecipeResult, Site } from \"../../types.js\";\nimport {\n branchName,\n checkoutBranch,\n commit as gitCommit,\n createBranch,\n currentBranch,\n deleteBranch,\n isOwnerRepo,\n isWorkingTreeClean,\n push as gitPush,\n} from \"../../util/git.js\";\nimport { siteLabel } from \"../../util/site.js\";\nimport { formatWithPrettier, resolveTargetPrettier, PRETTIER_FLAG_NOTE } from \"../_prettier.js\";\nimport {\n APPLY_BRANCH,\n PRISMIC_CI_WORKFLOW,\n REUSABLE_WORKFLOW_PIN,\n SECRET,\n WORKFLOW_PATH,\n isPinResolved,\n prismicCiWorkflow,\n type ReusableWorkflowPin,\n} from \"./template.js\";\n\n/** Head-branch prefix of every PR this recipe opens. `branchName(\"prismic-ci\")`\n * produces `maint/prismic-ci-<timestamp>`, and the re-run guard matches on this\n * prefix — the same idiom as `findOpenSelfUpdatingPR`. */\nconst BRANCH_PREFIX = \"maint/prismic-ci-\";\n\n/** How long the target's prettier gets. Also what makes the fleet's default\n * spawn detach the child, so the kill reaches prettier and not just a wrapper.\n * Matches the pull-down path's budget in `src/prismic/models/write.ts`. */\nconst PRETTIER_TIMEOUT_MS = 60_000;\n\n/** Just the GitHub surface this recipe touches, so a test fake is five methods\n * rather than thirty. `makeGitHub()` satisfies it structurally. */\nexport type PrismicCiGitHub = Pick<\n GitHub,\n \"defaultBranch\" | \"secretExists\" | \"fileContentsOnBranch\" | \"openPullRequest\" | \"openPullRequests\"\n>;\n\nexport type PrismicCiDeps = {\n github?: PrismicCiGitHub;\n pushBranch?: (cwd: string, branch: string) => Promise<void>;\n spawn?: SpawnFn;\n /** Resolve the TARGET repo's own prettier. Injected so a test can assert the\n * absolute-path spawn without a populated `node_modules`. */\n resolvePrettier?: (repoRoot: string) => Promise<string | null>;\n /** Which `reddoorla/.github` commit the written workflow pins. Injected only\n * by tests; production uses the shipped pin. */\n pin?: ReusableWorkflowPin;\n};\n\nconst resultOf = (\n site: Site,\n status: RecipeResult[\"status\"],\n notes: string,\n commits: string[] = [],\n): RecipeResult => ({\n recipe: \"prismic-ci\",\n site: siteLabel(site),\n status,\n commits,\n notes,\n});\n\nconst messageOf = (err: unknown): string => (err instanceof Error ? err.message : String(err));\n\n/** Same normalization as `self-updating`'s config comparison: CRLF and a stray\n * trailing newline are not drift, and treating them as drift opens a needless\n * PR on every run. Any real content difference still differs. */\nfunction sameWorkflow(current: string, canonical: string): boolean {\n const norm = (s: string) => s.replace(/\\r\\n/g, \"\\n\").replace(/\\s+$/, \"\");\n return norm(current) === norm(canonical);\n}\n\n/**\n * Land the Prismic model delivery workflow in one repo, as a pull request.\n *\n * Everything before the first mutation is a gate, and the gates exist because\n * this recipe's output is the only path in the project that writes to a live\n * client's Prismic repository. Two of them are worth naming:\n *\n * - THE SECRET. A workflow whose `PRISMIC_WRITE_TOKEN` does not exist yet goes\n * red on the repo's first model PR. Landing 15 of those turns a rollout into\n * 15 red repos, so a definitively-absent secret FAILS the site rather than\n * nooping it: \"this site was skipped and a human must act\" is not the same\n * report as \"this site was already done\", and a rollout summary where those\n * two look alike is how a site silently never gets model delivery. A secret\n * whose existence could not be DETERMINED fails too, with different wording —\n * they are different facts and the operator's next move differs.\n *\n * - THE DEFAULT BRANCH. The reusable workflow's apply job hard-codes\n * `refs/heads/main`. On a repo whose default branch is anything else, every\n * model PR would merge green and never reach Prismic. Refuse instead.\n *\n * Nothing here can delete a model: the workflow it installs calls a module that\n * exports no delete path.\n */\nexport async function prismicCi(site: Site, deps: PrismicCiDeps = {}): Promise<RecipeResult> {\n // 1. Repo identity. `failed`, not `noop`: a rollout that silently skips a site\n // is the failure this whole recipe is guarding against one level up. The\n // strict shape check runs BEFORE the first `gh` call, so a typo'd or\n // attacker-controlled value can never be interpolated into an API path.\n const repo = site.gitRepo;\n if (!repo) {\n return resultOf(site, \"failed\", \"no Git repo on this site (set Airtable 'Git repo')\");\n }\n if (!isOwnerRepo(repo)) {\n return resultOf(\n site,\n \"failed\",\n `refusing to act on malformed repo identity: expected \"owner/repo\", got ${JSON.stringify(repo)}`,\n );\n }\n\n // 2. Is this a Prismic site? `readPrismicConfig` returns null for \"no Prismic\n // here\" and THROWS for a present-but-unreadable config — the distinction is\n // the point, so the throw becomes `failed` rather than being caught into\n // the skip branch.\n let isPrismic: boolean;\n try {\n isPrismic = (await readPrismicConfig(site.path)) !== null;\n } catch (err) {\n return resultOf(site, \"failed\", `could not read the Prismic config: ${messageOf(err)}`);\n }\n if (!isPrismic) return resultOf(site, \"noop\", \"not a Prismic site (no repositoryName) — skipped\");\n\n // 3. The pin. Checked before any network call: while it is unresolved NOTHING\n // can roll out, and 15 pointless API round-trips are not worth spending to\n // find that out per site.\n const pin = deps.pin ?? REUSABLE_WORKFLOW_PIN;\n if (!isPinResolved(pin)) {\n return resultOf(\n site,\n \"failed\",\n `reusable-workflow pin is unresolved (${pin.sha}) — publish + tag the workflow in ` +\n `reddoorla/.github and set REUSABLE_WORKFLOW_PIN before rolling out`,\n );\n }\n const workflow = pin === REUSABLE_WORKFLOW_PIN ? PRISMIC_CI_WORKFLOW : prismicCiWorkflow(pin);\n\n const ghConfig = readGitHubConfig();\n if (!deps.github && !ghConfig) return resultOf(site, \"failed\", \"GITHUB_TOKEN not set\");\n const gh = deps.github ?? makeGitHub({ token: ghConfig!.token });\n const spawn = deps.spawn ?? defaultSpawn;\n\n // 4. The secret. Absent and unreadable are separate answers with separate\n // wording; neither proceeds.\n let hasSecret: boolean;\n try {\n hasSecret = await gh.secretExists(repo, SECRET);\n } catch (err) {\n return resultOf(\n site,\n \"failed\",\n `could not determine whether ${repo} has the ${SECRET} secret (${messageOf(err)}) — ` +\n `refusing to install a workflow that may have no token`,\n );\n }\n if (!hasSecret) {\n return resultOf(\n site,\n \"failed\",\n `${repo} has no ${SECRET} Actions secret — the workflow reds the repo on its first ` +\n `model PR without it. Mint one, then: gh secret set ${SECRET} --repo ${repo}`,\n );\n }\n\n // 5. The default branch. NOT `.catch(() => \"main\")`: \"I could not read the\n // default branch\" and \"the default branch is main\" are opposite facts, and\n // guessing the second targets a PR (and an apply gate) at a branch nobody\n // confirmed.\n let base: string;\n try {\n base = await gh.defaultBranch(repo);\n } catch (err) {\n return resultOf(\n site,\n \"failed\",\n `could not read the default branch of ${repo}: ${messageOf(err)}`,\n );\n }\n if (base !== APPLY_BRANCH) {\n return resultOf(\n site,\n \"failed\",\n `default branch of ${repo} is ${base}, not ${APPLY_BRANCH} — the reusable workflow's ` +\n `apply job guards refs/heads/${APPLY_BRANCH}, so merged model changes would never reach Prismic`,\n );\n }\n\n // 6. Already delivered? Content-compared, not existence-compared, so a\n // present-but-STALE workflow (an older pin) is corrected rather than left\n // forever.\n const existing = await gh.fileContentsOnBranch(repo, base, WORKFLOW_PATH);\n if (existing !== null && sameWorkflow(existing, workflow)) {\n return resultOf(site, \"noop\", `delivery workflow already current on ${base}`);\n }\n\n // 7. Already proposed? Without this, every run before the PR merges opens\n // another one. `fileContentsOnBranch` also answers null for a read it could\n // not perform (gh exits non-zero on both a 404 and an auth failure), which\n // makes this the backstop for that collapse as well.\n const open = (await gh.openPullRequests(repo)).find((pr) => pr.headRef.startsWith(BRANCH_PREFIX));\n if (open) {\n return resultOf(site, \"noop\", `delivery workflow PR already open: ${open.url}`);\n }\n\n if (!(await isWorkingTreeClean(site.path))) {\n return resultOf(site, \"failed\", \"working tree not clean — commit or stash first\");\n }\n\n // Capture the operator's branch BEFORE creating ours so the `finally` can put\n // them back. Best-effort: if we cannot read it we skip the restore rather than\n // guess at a branch to check out.\n let original: string | null = null;\n try {\n original = await currentBranch(site.path);\n } catch {\n // Stays null (detached HEAD, git error) — the restore below is then skipped\n // rather than aiming a checkout at a branch name we had to invent.\n }\n const branch = branchName(\"prismic-ci\");\n const commits: string[] = [];\n let pushedOrOpened = false;\n\n try {\n await createBranch(site.path, branch);\n const dest = join(site.path, WORKFLOW_PATH);\n await mkdir(dirname(dest), { recursive: true });\n await writeFile(dest, workflow, \"utf-8\");\n\n // Format with the SITE's own prettier, resolved POSITIVELY and run by\n // absolute path. `pnpm exec prettier` here would run a full `pnpm install`\n // in the client's repo first (an unrequested mutation of a live client repo\n // by a rollout that is supposed to add one file), and in a repo without\n // prettier would then format with the CALLING repo's binary and exit 0.\n const notes: string[] = [];\n const bin = await (deps.resolvePrettier ?? resolveTargetPrettier)(site.path);\n if (bin === null) {\n notes.push(PRETTIER_FLAG_NOTE);\n } else if (\n !(await formatWithPrettier(spawn, site.path, [WORKFLOW_PATH], {\n bin,\n timeoutMs: PRETTIER_TIMEOUT_MS,\n }))\n ) {\n notes.push(PRETTIER_FLAG_NOTE);\n } else if (!sameWorkflow(await readFile(dest, \"utf-8\"), workflow)) {\n // The site's prettier config disagrees with the template's shape (single\n // quotes, a different tab width). Harmless for the workflow — but the\n // step-6 comparison is byte-based, so this site will not recognise its own\n // delivered workflow as current and will propose it again after each\n // merge. Say so rather than let it be discovered as a mystery PR.\n notes.push(\n \"this site's prettier reformatted the workflow — re-runs will not match it as current\",\n );\n }\n\n const sha = await gitCommit(site.path, \"ci: deliver Prismic model changes from merged PRs\");\n if (!sha) {\n // Git saw no change: the checkout already holds this exact workflow even\n // though the default branch does not. Nothing to push and nothing to\n // review — and pushing a commit-less branch would fail at PR creation.\n return resultOf(\n site,\n \"noop\",\n `${WORKFLOW_PATH} already present and identical in the checkout`,\n );\n }\n commits.push(sha);\n pushedOrOpened = true;\n await (deps.pushBranch ?? gitPush)(site.path, branch);\n const pr = await gh.openPullRequest(repo, {\n head: branch,\n base,\n title: \"Deliver Prismic model changes from merged PRs\",\n body:\n \"Adds the `prismic-models` workflow. On a PR touching `customtypes/**` or \" +\n \"`src/lib/slices/**/model.json` it comments the model delta and writes nothing; \" +\n \"on merge to main it pushes those models to Prismic. It can create and update \" +\n \"models but never delete — a model present only in Prismic is reported, not touched.\",\n });\n notes.unshift(`opened PR ${pr.url}`);\n return resultOf(site, \"applied\", notes.join(\"; \"), commits);\n } catch (err) {\n return resultOf(site, \"failed\", messageOf(err), commits);\n } finally {\n // Restore the operator's branch on success AND on failure — otherwise a push\n // error strands the checkout on the recipe branch with an unpushed commit,\n // and the retry dies at createBranch. Best-effort; never masks the result.\n if (original !== null && original !== branch) {\n try {\n await checkoutBranch(site.path, original);\n // Nothing was pushed and no PR exists, so the local branch is litter and\n // a re-run would leave another. Only ever the branch WE created.\n if (!pushedOrOpened) await deleteBranch(site.path, branch);\n } catch (err) {\n console.warn(\n `warning: could not restore branch ${original} after prismic-ci: ${messageOf(err)}`,\n );\n }\n }\n }\n}\n","/**\n * The caller workflow every Prismic site gets.\n *\n * Fully generic — no per-site values — because the token is the site's own\n * `PRISMIC_WRITE_TOKEN` secret, the name every site's code already reads.\n * Contrast `ci.yml`, which is deliberately NOT templated anywhere in this\n * package because it carries per-site `netlify-site:` / `node-version:` values\n * a byte template would strip fleet-wide.\n */\n\n/** Where the file lands in a site repo. Also the `gh api .../contents/<path>`\n * segment, so it must stay traversal-free (`assertUrlSegment` re-checks). */\nexport const WORKFLOW_PATH = \".github/workflows/prismic-models.yml\";\n\n/** The Actions secret the reusable workflow declares as `required: true`, and\n * the environment variable the CLI reads. Spelled ONCE, here, because the\n * failure mode of a second spelling is silent: a caller passing a name the\n * callee never declared supplies nothing, and the callee's required secret\n * arrives empty at the one step that writes to a live client's Prismic repo. */\nexport const SECRET = \"PRISMIC_WRITE_TOKEN\";\n\n/** The reusable workflow, without a ref. */\nexport const REUSABLE_WORKFLOW = \"reddoorla/.github/.github/workflows/prismic-models.yml\";\n\n/**\n * The ONE branch this delivery path can run its apply job on.\n *\n * Not a preference — the reusable workflow's apply job hard-codes\n * `github.ref == 'refs/heads/main'`. On a repo whose default branch is anything\n * else, a merged model PR would produce a green check and never reach Prismic,\n * which is why the recipe refuses such a repo instead of installing a workflow\n * that silently cannot fire.\n */\nexport const APPLY_BRANCH = \"main\";\n\n/** A commit in `reddoorla/.github`, plus the release tag that commit carries.\n * Both are written into the workflow: the SHA is what Actions resolves, the tag\n * is what a human (and Renovate's github-actions manager) reads. */\nexport type ReusableWorkflowPin = { sha: string; tag: string };\n\n/**\n * What the shipped pin says while the reusable workflow has not been published\n * to `reddoorla/.github` and tagged yet (plan Task 25).\n *\n * DELIBERATELY NOT 40 HEX CHARACTERS. A placeholder shaped like a real SHA is\n * indistinguishable from a real one in review, and would install a workflow\n * referencing a commit that does not exist into 15 client repositories — where\n * it fails at workflow-load time, on every model PR, with an error that names\n * neither this file nor the reason. Unresolved must be unmistakable, and\n * {@link isPinResolved} is what the recipe gates on.\n */\nexport const UNRESOLVED_PIN_SHA = \"UNRESOLVED-publish-and-tag-reddoorla-dot-github-first\";\n\n/**\n * The pin the fleet rolls out.\n *\n * RESOLVED 2026-08-14. `reddoorla/.github#30` merged as\n * 558395431ddcb481ecba3dd84b78b38c338cfa03 and that commit was tagged v1.4.0;\n * `gh api repos/reddoorla/.github/commits/v1.4.0 --jq .sha` returns the SHA\n * below. `validate` (the digest-pinning + Renovate-preset check that is the\n * only CI in that repo) passed on the merge commit.\n *\n * TO RE-RESOLVE after a future `reddoorla/.github` release: set `sha` to\n * `gh api repos/reddoorla/.github/commits/<tag> --jq .sha` and `tag` to that\n * tag. Nothing else changes. Renovate's github-actions manager bumps the\n * already-installed `uses:` line per site repo; this constant is what NEW\n * rollouts install, so a stale value here is not a broken fleet, only a fleet\n * whose newest members start one version behind.\n */\nexport const REUSABLE_WORKFLOW_PIN: ReusableWorkflowPin = {\n sha: \"558395431ddcb481ecba3dd84b78b38c338cfa03\",\n tag: \"v1.4.0\",\n};\n\n/**\n * Is this pin a real commit reference?\n *\n * A full 40-hex SHA and nothing else. Not a tag, not a branch: this repo pins\n * every `uses:` to a commit (see `src/recipes/sync-configs/templates.ts`, whose\n * renovate template spells out why — a retagged `@v3` runs attacker code with\n * whatever token the workflow holds), and Renovate's github-actions manager\n * bumps the pin per repo when `reddoorla/.github` tags a new version.\n */\nexport function isPinResolved(pin: ReusableWorkflowPin): boolean {\n return /^[0-9a-f]{40}$/.test(pin.sha);\n}\n\n/**\n * Render the caller workflow for a pin.\n *\n * Path-filtered on both triggers: this must not run on every commit, only when\n * a model changes.\n */\nexport function prismicCiWorkflow(pin: ReusableWorkflowPin): string {\n return `# Delivers this site's Prismic model changes. Managed by @reddoorla/maintenance\n# (\\`reddoor-maint prismic-ci\\`) — change it there and re-run, not here.\n#\n# On a PR touching a model: comment the delta, write nothing.\n# On merge to ${APPLY_BRANCH}: push those models to Prismic. Never delete.\n#\n# THE BRANCH FILTER ON \\`push:\\` IS LOAD-BEARING, not tidiness. The reusable\n# workflow's apply job also guards \\`github.ref == 'refs/heads/${APPLY_BRANCH}'\\`,\n# and its comment calls this the other half of that gate: an unfiltered\n# \\`on: push:\\` fires on every branch AND every tag, so a feature branch's models\n# would reach production with no pull request and therefore no review anywhere in\n# the sequence. Keep both halves.\nname: prismic-models\n\non:\n # No branch filter here, deliberately: a model PR into any base deserves its\n # delta comment, and the dry job is INCAPABLE of writing — it never passes\n # \\`--apply\\`, and it holds no job that does.\n pull_request:\n paths:\n - \"customtypes/**\"\n - \"src/lib/slices/**/model.json\"\n push:\n branches: [${APPLY_BRANCH}]\n paths:\n - \"customtypes/**\"\n - \"src/lib/slices/**/model.json\"\n\njobs:\n prismic-models:\n # A called workflow's jobs can only NARROW what the caller granted, so the\n # PR-comment permission has to be granted here as well as there. Nothing in\n # either job pushes code, so \\`contents\\` stays read.\n permissions:\n contents: read\n pull-requests: write\n uses: ${REUSABLE_WORKFLOW}@${pin.sha} # ${pin.tag}\n secrets:\n # Spelled exactly as the reusable workflow declares it. A workflow-local\n # alias would not be a rename — it would be an undeclared secret, and the\n # required one would arrive empty.\n ${SECRET}: \\${{ secrets.${SECRET} }}\n`;\n}\n\n/** The workflow as currently shipped. Unusable — and refused by the recipe —\n * until {@link REUSABLE_WORKFLOW_PIN} is resolved. */\nexport const PRISMIC_CI_WORKFLOW = prismicCiWorkflow(REUSABLE_WORKFLOW_PIN);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,eAAe;AACxB,SAAS,eAAe;;;AC5BxB,SAAS,OAAO,UAAU,iBAAiB;AAC3C,SAAS,SAAS,YAAY;;;ACWvB,IAAM,gBAAgB;AAOtB,IAAM,SAAS;AAGf,IAAM,oBAAoB;AAW1B,IAAM,eAAe;AAoCrB,IAAM,wBAA6C;AAAA,EACxD,KAAK;AAAA,EACL,KAAK;AACP;AAWO,SAAS,cAAc,KAAmC;AAC/D,SAAO,iBAAiB,KAAK,IAAI,GAAG;AACtC;AAQO,SAAS,kBAAkB,KAAkC;AAClE,SAAO;AAAA;AAAA;AAAA;AAAA,gBAIO,YAAY;AAAA;AAAA;AAAA,iEAGqC,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAgB5D,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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