everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
1 lines • 3.98 kB
Source Map (JSON)
{"version":3,"file":"verify.mjs","names":[],"sources":["../../src/handlers/verify.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { MISSING_CONFIG_MESSAGE, readAuthoredConfigInput } from \"../config\";\nimport {\n type VerifyFreshness,\n type VerifyRemoteResult,\n verifyPublishedPins,\n verifyReleaseFreshness,\n} from \"../services/deploy/verify\";\nimport { resolvePublishedConfig } from \"../services/registry/published\";\nimport type { BosConfig, BosConfigInput } from \"../types\";\nimport type { BosBuilder } from \"./shared\";\n\nexport function registerVerify(builder: BosBuilder) {\n return {\n verify: builder.verify.effect(function* (_opts, input) {\n return yield* Effect.promise(async () => {\n let authored: BosConfig | null = null;\n try {\n authored = (await readAuthoredConfigInput()) as BosConfig | null;\n } catch (error) {\n return {\n status: \"fail\" as const,\n remotes: [] as VerifyRemoteResult[],\n error: error instanceof Error ? error.message : String(error),\n };\n }\n if (!authored) {\n const account = process.env.BOS_ACCOUNT;\n const gateway = process.env.BOS_GATEWAY;\n if (!account || !gateway) {\n return {\n status: \"fail\" as const,\n remotes: [] as VerifyRemoteResult[],\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n try {\n authored = (await resolvePublishedConfig(account, gateway)) as BosConfig | null;\n } catch (error) {\n return {\n status: \"fail\" as const,\n remotes: [] as VerifyRemoteResult[],\n error: error instanceof Error ? error.message : String(error),\n };\n }\n if (!authored) {\n return {\n status: \"fail\" as const,\n remotes: [] as VerifyRemoteResult[],\n error: `No config found at bos://${account}/${gateway} — verify BOS_ACCOUNT/BOS_GATEWAY and that the config has been published.`,\n };\n }\n }\n\n const config: BosConfigInput = authored as unknown as BosConfigInput;\n const report = await verifyPublishedPins({ config });\n const freshness = await verifyReleaseFreshness({\n config,\n ...(input.registry ? { registry: input.registry } : {}),\n });\n const rot = report.remotes.some(\n (remote) => !remote.manifestOk || remote.mismatches.length > 0,\n );\n const behind = freshness?.behind === true;\n return {\n status: rot ? (\"fail\" as const) : behind ? (\"drift\" as const) : (\"ok\" as const),\n remotes: report.remotes,\n ...(freshness ? { freshness: freshness as VerifyFreshness } : {}),\n };\n });\n }),\n };\n}\n"],"mappings":";;;;;;AAYA,SAAgB,eAAe,SAAqB;CAClD,OAAO,EACL,QAAQ,QAAQ,OAAO,OAAO,WAAW,OAAO,OAAO;EACrD,OAAO,OAAO,OAAO,QAAQ,YAAY;GACvC,IAAI,WAA6B;GACjC,IAAI;IACF,WAAY,MAAM,wBAAwB;GAC5C,SAAS,OAAO;IACd,OAAO;KACL,QAAQ;KACR,SAAS,CAAC;KACV,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAC9D;GACF;GACA,IAAI,CAAC,UAAU;IACb,MAAM,UAAU,QAAQ,IAAI;IAC5B,MAAM,UAAU,QAAQ,IAAI;IAC5B,IAAI,CAAC,WAAW,CAAC,SACf,OAAO;KACL,QAAQ;KACR,SAAS,CAAC;KACV,OAAO;IACT;IAEF,IAAI;KACF,WAAY,MAAM,uBAAuB,SAAS,OAAO;IAC3D,SAAS,OAAO;KACd,OAAO;MACL,QAAQ;MACR,SAAS,CAAC;MACV,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;KAC9D;IACF;IACA,IAAI,CAAC,UACH,OAAO;KACL,QAAQ;KACR,SAAS,CAAC;KACV,OAAO,4BAA4B,QAAQ,GAAG,QAAQ;IACxD;GAEJ;GAEA,MAAM,SAAyB;GAC/B,MAAM,SAAS,MAAM,oBAAoB,EAAE,OAAO,CAAC;GACnD,MAAM,YAAY,MAAM,uBAAuB;IAC7C;IACA,GAAI,MAAM,WAAW,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;GACvD,CAAC;GACD,MAAM,MAAM,OAAO,QAAQ,MACxB,WAAW,CAAC,OAAO,cAAc,OAAO,WAAW,SAAS,CAC/D;GACA,MAAM,SAAS,WAAW,WAAW;GACrC,OAAO;IACL,QAAQ,MAAO,SAAmB,SAAU,UAAqB;IACjE,SAAS,OAAO;IAChB,GAAI,YAAY,EAAa,UAA6B,IAAI,CAAC;GACjE;EACF,CAAC;CACH,CAAC,EACH;AACF"}