everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
1 lines • 3.24 kB
Source Map (JSON)
{"version":3,"file":"version-manifest-deploy.mjs","names":[],"sources":["../src/version-manifest-deploy.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { type BuildEntryReport, BuildEntryReportSchema } from \"every-plugin/build/artifact-names\";\nimport {\n composeVersionManifest,\n type WorkspaceVersionManifest,\n} from \"every-plugin/version-manifest\";\n\n/** Read a workspace dist's build-report.json (ticket 01's entry-name report). */\nexport function readBuildReport(distRoot: string): BuildEntryReport | null {\n const reportPath = join(distRoot, \"build-report.json\");\n if (!existsSync(reportPath)) return null;\n try {\n return BuildEntryReportSchema.parse(JSON.parse(readFileSync(reportPath, \"utf8\")));\n } catch {\n return null;\n }\n}\n\n/**\n * Compose the workspace's version manifest from the dist build reports and\n * the **server-computed** SRI map of the upload response (MAP decision 6 —\n * SRI is authoritative from the storage boundary, never computed\n * client-side). Returns null when the dist predates hashed entry names\n * (no report, or the SRI map lacks the entry) — the deploy leg then aborts:\n * uploaded workspaces must pin.\n */\nexport function composeWorkspaceVersionManifest(input: {\n report: BuildEntryReport;\n ssrReport?: BuildEntryReport | null;\n integrityMap: Record<string, string>;\n /** full per-file SRI map of the dist — recorded for the next deploy's diff */\n files?: Record<string, string>;\n}): WorkspaceVersionManifest | null {\n const { report, ssrReport, integrityMap, files } = input;\n\n const entryIntegrity = integrityMap[report.entry];\n if (!entryIntegrity) return null;\n\n const ssrEntry = ssrReport?.entry;\n const ssrIntegrity = ssrEntry ? integrityMap[`ssr/${ssrEntry}`] : undefined;\n\n return composeVersionManifest({\n entry: report.entry,\n entryIntegrity,\n ...(ssrEntry && ssrIntegrity\n ? { ssr: { entry: `ssr/${ssrEntry}`, integrity: ssrIntegrity } }\n : {}),\n ...(report.browserManifest && integrityMap[report.browserManifest]\n ? {\n browserManifest: {\n file: report.browserManifest,\n integrity: integrityMap[report.browserManifest]!,\n },\n }\n : {}),\n ...(report.css && integrityMap[report.css]\n ? { assets: { css: integrityMap[report.css]! } }\n : {}),\n ...(files ? { files } : {}),\n });\n}\n"],"mappings":";;;;;;;AASA,SAAgB,gBAAgB,UAA2C;CACzE,MAAM,aAAa,KAAK,UAAU,mBAAmB;CACrD,IAAI,CAAC,WAAW,UAAU,GAAG,OAAO;CACpC,IAAI;EACF,OAAO,uBAAuB,MAAM,KAAK,MAAM,aAAa,YAAY,MAAM,CAAC,CAAC;CAClF,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;AAUA,SAAgB,gCAAgC,OAMZ;CAClC,MAAM,EAAE,QAAQ,WAAW,cAAc,UAAU;CAEnD,MAAM,iBAAiB,aAAa,OAAO;CAC3C,IAAI,CAAC,gBAAgB,OAAO;CAE5B,MAAM,WAAW,WAAW;CAC5B,MAAM,eAAe,WAAW,aAAa,OAAO,cAAc;CAElE,OAAO,uBAAuB;EAC5B,OAAO,OAAO;EACd;EACA,GAAI,YAAY,eACZ,EAAE,KAAK;GAAE,OAAO,OAAO;GAAY,WAAW;EAAa,EAAE,IAC7D,CAAC;EACL,GAAI,OAAO,mBAAmB,aAAa,OAAO,mBAC9C,EACE,iBAAiB;GACf,MAAM,OAAO;GACb,WAAW,aAAa,OAAO;EACjC,EACF,IACA,CAAC;EACL,GAAI,OAAO,OAAO,aAAa,OAAO,OAClC,EAAE,QAAQ,EAAE,KAAK,aAAa,OAAO,KAAM,EAAE,IAC7C,CAAC;EACL,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AACH"}