everything-dev 2.0.0-rc.4 → 2.0.0-rc.6
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/api-contract.cjs +3 -6
- package/dist/api-contract.cjs.map +1 -1
- package/dist/api-contract.mjs +3 -6
- package/dist/api-contract.mjs.map +1 -1
- package/dist/apps/upload/src/client.cjs +188 -0
- package/dist/apps/upload/src/client.cjs.map +1 -0
- package/dist/apps/upload/src/client.mjs +180 -0
- package/dist/apps/upload/src/client.mjs.map +1 -0
- package/dist/bundle-fs-resolve.cjs +37 -3
- package/dist/bundle-fs-resolve.cjs.map +1 -1
- package/dist/bundle-fs-resolve.mjs +37 -3
- package/dist/bundle-fs-resolve.mjs.map +1 -1
- package/dist/cdn-deploy.cjs +29 -11
- package/dist/cdn-deploy.cjs.map +1 -1
- package/dist/cdn-deploy.mjs +29 -11
- package/dist/cdn-deploy.mjs.map +1 -1
- package/dist/cli/infra.cjs +4 -2
- package/dist/cli/infra.cjs.map +1 -1
- package/dist/cli/infra.mjs +4 -2
- package/dist/cli/infra.mjs.map +1 -1
- package/dist/cli/init.cjs +0 -2
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +1 -1
- package/dist/cli/init.d.mts +1 -1
- package/dist/cli/init.mjs +0 -2
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/sync.cjs +0 -1
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +0 -1
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/commands/deploy.cjs +0 -2
- package/dist/commands/deploy.cjs.map +1 -1
- package/dist/commands/deploy.mjs +0 -2
- package/dist/commands/deploy.mjs.map +1 -1
- package/dist/commands/upgrade.cjs +30 -7
- package/dist/commands/upgrade.cjs.map +1 -1
- package/dist/commands/upgrade.mjs +30 -7
- package/dist/commands/upgrade.mjs.map +1 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.mjs.map +1 -1
- package/dist/contract.meta.cjs +1 -1
- package/dist/contract.meta.cjs.map +1 -1
- package/dist/contract.meta.d.cts +1 -1
- package/dist/contract.meta.d.mts +1 -1
- package/dist/contract.meta.mjs +1 -1
- package/dist/contract.meta.mjs.map +1 -1
- package/dist/dev-program.cjs +2 -2
- package/dist/dev-program.cjs.map +1 -1
- package/dist/dev-program.mjs +2 -3
- package/dist/dev-program.mjs.map +1 -1
- package/dist/image-deploy.cjs +38 -14
- package/dist/image-deploy.cjs.map +1 -1
- package/dist/image-deploy.mjs +39 -15
- package/dist/image-deploy.mjs.map +1 -1
- package/dist/orchestrator.cjs +22 -18
- package/dist/orchestrator.cjs.map +1 -1
- package/dist/orchestrator.mjs +22 -18
- package/dist/orchestrator.mjs.map +1 -1
- package/dist/storage-upload.cjs +7 -68
- package/dist/storage-upload.cjs.map +1 -1
- package/dist/storage-upload.mjs +7 -68
- package/dist/storage-upload.mjs.map +1 -1
- package/dist/ui/api.cjs +11 -69
- package/dist/ui/api.cjs.map +1 -1
- package/dist/ui/api.d.cts +2 -4
- package/dist/ui/api.d.mts +2 -4
- package/dist/ui/api.mjs +11 -69
- package/dist/ui/api.mjs.map +1 -1
- package/dist/ui/auth.d.cts +43 -43
- package/dist/ui/auth.d.mts +43 -43
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.mjs","names":[],"sources":["../../src/commands/deploy.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport process from \"node:process\";\nimport { Context } from \"effect\";\nimport { MISSING_CONFIG_MESSAGE } from \"../config\";\nimport {\n type ConfigHistoryEntry,\n fetchBosConfigFromFastKv,\n fetchConfigHistory,\n fetchDeployManifests,\n} from \"../fastkv\";\nimport {\n buildAndPushImage,\n deployImageToRailway,\n hasDocker,\n isValidImageDigest,\n resolveDeployImagePlan,\n resolveImageRef,\n} from \"../image-deploy\";\nimport { publishToFastKv } from \"../publish\";\nimport { openResolution } from \"../resolution/session\";\nimport { buildRollbackPayload, summarizeSlotPins, verifyRollbackSnapshot } from \"../rollback\";\nimport type { BosConfigInput } from \"../types\";\nimport { BosConfigSchema } from \"../types\";\nimport { colors, icons } from \"../utils/theme\";\nimport { type BosBuilder, BosDepsTag } from \"./shared\";\n\nexport function registerDeploy(builder: BosBuilder) {\n return {\n publish: builder.publish.handler(async ({ input, context }) => {\n const deps = Context.get(context[\"effect/context\"], BosDepsTag);\n const session = deps.session;\n if (!session?.config) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const result = await publishToFastKv({\n bosConfig: session.config,\n runtimeConfig: session.runtime,\n configDir: session.root,\n env: input.env,\n build: false,\n dryRun: input.dryRun,\n verbose: input.verbose,\n packages: \"all\",\n network: input.network,\n privateKey: input.privateKey,\n wallet: input.wallet,\n registry: input.registry,\n });\n\n return {\n status: result.status,\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n error: result.error,\n built: result.built,\n skipped: result.skipped,\n deployResults: result.deployResults,\n };\n }),\n\n rollback: builder.rollback.handler(async ({ input, context }) => {\n const deps = Context.get(context[\"effect/context\"], BosDepsTag);\n const session = deps.session;\n if (!session) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const { account, domain } = session.config ?? {};\n if (!account || !domain) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"authored config must define account and domain to roll back\",\n };\n }\n\n let history: ConfigHistoryEntry[];\n try {\n history = await fetchConfigHistory({\n accountId: account,\n gatewayId: domain,\n registry: input.registry,\n limit: input.limit,\n });\n } catch (error) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: `Failed to fetch publish history: ${error instanceof Error ? error.message : String(error)}`,\n };\n }\n\n if (history.length === 0) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: `No publish history for ${account}/${domain} — nothing to roll back to`,\n };\n }\n\n const historyEntries = history.map((entry) => ({\n blockHeight: entry.blockHeight,\n blockTimestamp: new Date(Number(entry.blockTimestampNs.slice(0, 13))).toISOString(),\n ...(entry.txHash ? { txHash: entry.txHash } : {}),\n summary: summarizeSlotPins(entry.value as BosConfigInput),\n }));\n\n if (input.listOnly) {\n return {\n status: \"list\" as const,\n registryUrl: \"\",\n history: historyEntries,\n };\n }\n\n const target =\n input.version !== undefined\n ? history.find((entry) => {\n const iso = new Date(Number(entry.blockTimestampNs.slice(0, 13))).toISOString();\n return (\n String(entry.blockHeight) === input.version ||\n iso.startsWith(input.version as string)\n );\n })\n : input.previous\n ? history[1]\n : undefined;\n\n if (!target) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n history: historyEntries,\n error: input.version\n ? `No history entry matches \"${input.version}\" — pick a block height from the listing`\n : \"Specify --version <block-height> or --previous (interactive selection happens CLI-side)\",\n };\n }\n\n let liveValue: unknown;\n try {\n liveValue = await fetchBosConfigFromFastKv<unknown>(\n `bos://${account}/${domain}`,\n input.registry,\n );\n } catch {\n liveValue = undefined;\n }\n if (liveValue && JSON.stringify(liveValue) === JSON.stringify(target.value)) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"The selected snapshot is identical to the live config — nothing to do\",\n };\n }\n\n const verification = await verifyRollbackSnapshot(target.value as BosConfigInput);\n const slotChecks = verification.slots.map((check) => ({\n slot: check.slot,\n ok: check.ok,\n ...(check.reason ? { reason: check.reason } : {}),\n }));\n if (!verification.ok && verification.verifiable) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n verification: slotChecks,\n error:\n \"Refusing to roll back — a pinned slot's bytes are gone or no longer match their SRI\",\n };\n }\n\n if (!verification.verifiable && !input.force) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error:\n \"Snapshot predates version manifests and cannot be verified — its bytes were overwritten in place. Re-run with --force to publish it anyway.\",\n };\n }\n\n const parsedTarget = BosConfigSchema.parse(target.value);\n const payload = buildRollbackPayload(parsedTarget, new Date().toISOString());\n\n const result = await publishToFastKv({\n bosConfig: payload,\n runtimeConfig: session.runtime,\n configDir: session.root,\n env: input.env,\n build: false,\n dryRun: input.dryRun,\n verbose: input.verbose,\n packages: \"all\",\n network: input.network,\n privateKey: input.privateKey,\n wallet: input.wallet,\n registry: input.registry,\n });\n\n return {\n status: result.status,\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n error: result.error,\n history: historyEntries,\n ...(slotChecks.length > 0 ? { verification: slotChecks } : {}),\n };\n }),\n\n deploy: builder.deploy.handler(async ({ input, context }) => {\n const deps = Context.get(context[\"effect/context\"], BosDepsTag);\n const session = deps.session;\n if (!session?.config) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n if (input.statusList) {\n if (!session.config?.account || !session.config.domain) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"authored config must define account and domain to list deploy manifests\",\n };\n }\n try {\n const manifests = await fetchDeployManifests({\n accountId: session.config.account,\n gatewayId: session.config.domain,\n registry: input.registry,\n });\n return {\n status: \"list\" as const,\n registryUrl: \"\",\n history: manifests.map((entry) => ({\n key: entry.key,\n blockHeight: entry.blockHeight,\n blockTimestamp: new Date(Number(entry.blockTimestampNs.slice(0, 13))).toISOString(),\n ...((entry.value as { txHash?: string } | undefined)?.txHash\n ? { txHash: (entry.value as { txHash?: string }).txHash }\n : {}),\n ...((entry.value as { publishedAt?: string } | undefined)?.publishedAt\n ? { publishedAt: (entry.value as { publishedAt?: string }).publishedAt }\n : {}),\n })),\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: `Failed to list deploy manifests: ${error instanceof Error ? error.message : String(error)}`,\n };\n }\n }\n\n const imageDigestInput = input.imageDigest ?? process.env.BOS_IMAGE_DIGEST;\n if (imageDigestInput && !isValidImageDigest(imageDigestInput)) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: `Invalid image digest \"${imageDigestInput}\" — expected sha256:<64 hex characters> (--image-digest / BOS_IMAGE_DIGEST)`,\n };\n }\n\n const result = await publishToFastKv({\n bosConfig: session.config,\n runtimeConfig: session.runtime,\n configDir: session.root,\n env: input.env,\n build: input.build,\n dryRun: input.dryRun,\n verbose: input.verbose,\n packages: input.packages,\n network: input.network,\n privateKey: input.privateKey,\n registry: input.registry,\n fullUpload: input.fullUpload,\n });\n\n if (result.status === \"error\") {\n return {\n status: \"error\" as const,\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n built: result.built,\n skipped: result.skipped,\n error: result.error,\n deployResults: result.deployResults,\n };\n }\n\n if (result.status === \"dry-run\") {\n return {\n status: \"dry-run\" as const,\n registryUrl: result.registryUrl,\n built: result.built,\n skipped: result.skipped,\n };\n }\n\n let nextSession = session;\n if (result.publishConfig) {\n const opened = await openResolution({ cwd: session.root });\n if (opened) {\n nextSession = opened;\n }\n }\n\n const configPublished = {\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n fingerprint: result.fingerprint,\n slotPins: result.slotPins,\n built: result.built,\n skipped: result.skipped,\n deployResults: result.deployResults,\n } as const;\n\n let image: string | undefined;\n let imageDigest: string | undefined;\n let service: string | undefined;\n\n const imagePlan = resolveDeployImagePlan({\n // A prebuilt digest pairs with the pushed ref (BOS_IMAGE from the CI\n // image job, or repository derivation) — ci.image is a build-time\n // choice, not a pin-time one; letting it win here could pin a digest\n // from a different image.\n imageRef: resolveImageRef({\n ciImage: imageDigestInput ? undefined : nextSession.config?.ci?.image,\n repository: nextSession.config?.repository,\n env: process.env,\n }),\n imageDigest: imageDigestInput,\n hasDocker: await hasDocker(),\n hasDockerfile: existsSync(join(session.root, \"Dockerfile\")),\n });\n\n if (imagePlan.kind === \"skip\") {\n console.log();\n console.log(colors.yellow(` Image skipped: ${imagePlan.reason}`));\n } else if (imagePlan.kind === \"prebuilt\") {\n image = imagePlan.image;\n imageDigest = imagePlan.digest;\n console.log();\n console.log(\n colors.green(\n ` ${icons.ok} Using pre-pushed image ${imagePlan.image}@${imagePlan.digest.slice(0, 19)}…`,\n ),\n );\n } else {\n console.log();\n try {\n const imageResult = await buildAndPushImage({\n image: imagePlan.image,\n configDir: session.root,\n verbose: input.verbose,\n });\n image = imageResult.image;\n imageDigest = imageResult.digest;\n console.log(\n colors.green(\n ` ${icons.ok} Image pushed ${imageResult.image}:${imageResult.tag}${imageResult.digest ? ` (${imageResult.digest.slice(0, 19)}…)` : \"\"}`,\n ),\n );\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n const imageError =\n message.includes(\"not found\") || message.includes(\"ENOENT\")\n ? \"Docker not found — install Docker to build the runtime image\"\n : `Image build/push failed: ${message}`;\n console.log(colors.yellow(` ${imageError}`));\n return {\n status: \"published\" as const,\n ...configPublished,\n error: `Config published but ${imageError}`,\n };\n }\n }\n\n if (process.env.RAILWAY_TOKEN) {\n const railwayService = input.service ?? nextSession.config?.ci?.railway?.service;\n if (!railwayService) {\n console.log();\n console.log(\n colors.yellow(\n \" Railway deploy skipped: ci.railway.service is not configured in bos.config.json\",\n ),\n );\n return {\n status: \"published\" as const,\n ...configPublished,\n image,\n error:\n \"Config published but Railway deploy failed: ci.railway.service is not configured in bos.config.json\",\n };\n }\n if (!image || !imageDigest) {\n console.log();\n console.log(\n colors.yellow(\n \" Railway deploy skipped: no runtime image digest — set ci.image (or pass BOS_IMAGE_DIGEST) and make the image available\",\n ),\n );\n return {\n status: \"published\" as const,\n ...configPublished,\n image,\n service: railwayService,\n error:\n \"Config published but Railway deploy requires a runtime image (set ci.image, or pass BOS_IMAGE_DIGEST for a pre-pushed image)\",\n };\n }\n\n service = railwayService;\n try {\n await deployImageToRailway({\n image,\n digest: imageDigest,\n service: railwayService,\n configDir: session.root,\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n const railError =\n message.includes(\"not found\") || message.includes(\"ENOENT\")\n ? \"Railway CLI not found. Install it: npm i -g @railway/cli\"\n : `Railway deploy failed: ${message}`;\n console.log(colors.yellow(` ${railError}`));\n return {\n status: \"published\" as const,\n ...configPublished,\n image,\n service,\n error: `Config published but ${railError}`,\n };\n }\n } else {\n console.log();\n console.log(colors.yellow(\" Railway deploy skipped (RAILWAY_TOKEN not set)\"));\n }\n\n return {\n status: \"deployed\" as const,\n ...configPublished,\n image,\n service,\n };\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,SAAgB,eAAe,SAAqB;CAClD,OAAO;EACL,SAAS,QAAQ,QAAQ,QAAQ,OAAO,EAAE,OAAO,cAAc;GAE7D,MAAM,UADO,QAAQ,IAAI,QAAQ,mBAAmB,UACjC,CAAC,CAAC;GACrB,IAAI,CAAC,SAAS,QACZ,OAAO;IACL,QAAQ;IACR,aAAa;IACb,OAAO;GACT;GAGF,MAAM,SAAS,MAAM,gBAAgB;IACnC,WAAW,QAAQ;IACnB,eAAe,QAAQ;IACvB,WAAW,QAAQ;IACnB,KAAK,MAAM;IACX,OAAO;IACP,QAAQ,MAAM;IACd,SAAS,MAAM;IACf,UAAU;IACV,SAAS,MAAM;IACf,YAAY,MAAM;IAClB,QAAQ,MAAM;IACd,UAAU,MAAM;GAClB,CAAC;GAED,OAAO;IACL,QAAQ,OAAO;IACf,aAAa,OAAO;IACpB,QAAQ,OAAO;IACf,OAAO,OAAO;IACd,OAAO,OAAO;IACd,SAAS,OAAO;IAChB,eAAe,OAAO;GACxB;EACF,CAAC;EAED,UAAU,QAAQ,SAAS,QAAQ,OAAO,EAAE,OAAO,cAAc;GAE/D,MAAM,UADO,QAAQ,IAAI,QAAQ,mBAAmB,UACjC,CAAC,CAAC;GACrB,IAAI,CAAC,SACH,OAAO;IACL,QAAQ;IACR,aAAa;IACb,OAAO;GACT;GAGF,MAAM,EAAE,SAAS,WAAW,QAAQ,UAAU,CAAC;GAC/C,IAAI,CAAC,WAAW,CAAC,QACf,OAAO;IACL,QAAQ;IACR,aAAa;IACb,OAAO;GACT;GAGF,IAAI;GACJ,IAAI;IACF,UAAU,MAAM,mBAAmB;KACjC,WAAW;KACX,WAAW;KACX,UAAU,MAAM;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|
|
1
|
+
{"version":3,"file":"deploy.mjs","names":[],"sources":["../../src/commands/deploy.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport process from \"node:process\";\nimport { Context } from \"effect\";\nimport { MISSING_CONFIG_MESSAGE } from \"../config\";\nimport {\n type ConfigHistoryEntry,\n fetchBosConfigFromFastKv,\n fetchConfigHistory,\n fetchDeployManifests,\n} from \"../fastkv\";\nimport {\n buildAndPushImage,\n deployImageToRailway,\n hasDocker,\n isValidImageDigest,\n resolveDeployImagePlan,\n resolveImageRef,\n} from \"../image-deploy\";\nimport { publishToFastKv } from \"../publish\";\nimport { openResolution } from \"../resolution/session\";\nimport { buildRollbackPayload, summarizeSlotPins, verifyRollbackSnapshot } from \"../rollback\";\nimport type { BosConfigInput } from \"../types\";\nimport { BosConfigSchema } from \"../types\";\nimport { colors, icons } from \"../utils/theme\";\nimport { type BosBuilder, BosDepsTag } from \"./shared\";\n\nexport function registerDeploy(builder: BosBuilder) {\n return {\n publish: builder.publish.handler(async ({ input, context }) => {\n const deps = Context.get(context[\"effect/context\"], BosDepsTag);\n const session = deps.session;\n if (!session?.config) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const result = await publishToFastKv({\n bosConfig: session.config,\n runtimeConfig: session.runtime,\n configDir: session.root,\n env: input.env,\n build: false,\n dryRun: input.dryRun,\n verbose: input.verbose,\n packages: \"all\",\n network: input.network,\n privateKey: input.privateKey,\n wallet: input.wallet,\n registry: input.registry,\n });\n\n return {\n status: result.status,\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n error: result.error,\n built: result.built,\n skipped: result.skipped,\n deployResults: result.deployResults,\n };\n }),\n\n rollback: builder.rollback.handler(async ({ input, context }) => {\n const deps = Context.get(context[\"effect/context\"], BosDepsTag);\n const session = deps.session;\n if (!session) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const { account, domain } = session.config ?? {};\n if (!account || !domain) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"authored config must define account and domain to roll back\",\n };\n }\n\n let history: ConfigHistoryEntry[];\n try {\n history = await fetchConfigHistory({\n accountId: account,\n gatewayId: domain,\n registry: input.registry,\n limit: input.limit,\n });\n } catch (error) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: `Failed to fetch publish history: ${error instanceof Error ? error.message : String(error)}`,\n };\n }\n\n if (history.length === 0) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: `No publish history for ${account}/${domain} — nothing to roll back to`,\n };\n }\n\n const historyEntries = history.map((entry) => ({\n blockHeight: entry.blockHeight,\n blockTimestamp: new Date(Number(entry.blockTimestampNs.slice(0, 13))).toISOString(),\n ...(entry.txHash ? { txHash: entry.txHash } : {}),\n summary: summarizeSlotPins(entry.value as BosConfigInput),\n }));\n\n if (input.listOnly) {\n return {\n status: \"list\" as const,\n registryUrl: \"\",\n history: historyEntries,\n };\n }\n\n const target =\n input.version !== undefined\n ? history.find((entry) => {\n const iso = new Date(Number(entry.blockTimestampNs.slice(0, 13))).toISOString();\n return (\n String(entry.blockHeight) === input.version ||\n iso.startsWith(input.version as string)\n );\n })\n : input.previous\n ? history[1]\n : undefined;\n\n if (!target) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n history: historyEntries,\n error: input.version\n ? `No history entry matches \"${input.version}\" — pick a block height from the listing`\n : \"Specify --version <block-height> or --previous (interactive selection happens CLI-side)\",\n };\n }\n\n let liveValue: unknown;\n try {\n liveValue = await fetchBosConfigFromFastKv<unknown>(\n `bos://${account}/${domain}`,\n input.registry,\n );\n } catch {\n liveValue = undefined;\n }\n if (liveValue && JSON.stringify(liveValue) === JSON.stringify(target.value)) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"The selected snapshot is identical to the live config — nothing to do\",\n };\n }\n\n const verification = await verifyRollbackSnapshot(target.value as BosConfigInput);\n const slotChecks = verification.slots.map((check) => ({\n slot: check.slot,\n ok: check.ok,\n ...(check.reason ? { reason: check.reason } : {}),\n }));\n if (!verification.ok && verification.verifiable) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n verification: slotChecks,\n error:\n \"Refusing to roll back — a pinned slot's bytes are gone or no longer match their SRI\",\n };\n }\n\n if (!verification.verifiable && !input.force) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error:\n \"Snapshot predates version manifests and cannot be verified — its bytes were overwritten in place. Re-run with --force to publish it anyway.\",\n };\n }\n\n const parsedTarget = BosConfigSchema.parse(target.value);\n const payload = buildRollbackPayload(parsedTarget, new Date().toISOString());\n\n const result = await publishToFastKv({\n bosConfig: payload,\n runtimeConfig: session.runtime,\n configDir: session.root,\n env: input.env,\n build: false,\n dryRun: input.dryRun,\n verbose: input.verbose,\n packages: \"all\",\n network: input.network,\n privateKey: input.privateKey,\n wallet: input.wallet,\n registry: input.registry,\n });\n\n return {\n status: result.status,\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n error: result.error,\n history: historyEntries,\n ...(slotChecks.length > 0 ? { verification: slotChecks } : {}),\n };\n }),\n\n deploy: builder.deploy.handler(async ({ input, context }) => {\n const deps = Context.get(context[\"effect/context\"], BosDepsTag);\n const session = deps.session;\n if (!session?.config) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n if (input.statusList) {\n if (!session.config?.account || !session.config.domain) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"authored config must define account and domain to list deploy manifests\",\n };\n }\n try {\n const manifests = await fetchDeployManifests({\n accountId: session.config.account,\n gatewayId: session.config.domain,\n registry: input.registry,\n });\n return {\n status: \"list\" as const,\n registryUrl: \"\",\n history: manifests.map((entry) => ({\n key: entry.key,\n blockHeight: entry.blockHeight,\n blockTimestamp: new Date(Number(entry.blockTimestampNs.slice(0, 13))).toISOString(),\n ...((entry.value as { txHash?: string } | undefined)?.txHash\n ? { txHash: (entry.value as { txHash?: string }).txHash }\n : {}),\n ...((entry.value as { publishedAt?: string } | undefined)?.publishedAt\n ? { publishedAt: (entry.value as { publishedAt?: string }).publishedAt }\n : {}),\n })),\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: `Failed to list deploy manifests: ${error instanceof Error ? error.message : String(error)}`,\n };\n }\n }\n\n const imageDigestInput = input.imageDigest ?? process.env.BOS_IMAGE_DIGEST;\n if (imageDigestInput && !isValidImageDigest(imageDigestInput)) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: `Invalid image digest \"${imageDigestInput}\" — expected sha256:<64 hex characters> (--image-digest / BOS_IMAGE_DIGEST)`,\n };\n }\n\n const result = await publishToFastKv({\n bosConfig: session.config,\n runtimeConfig: session.runtime,\n configDir: session.root,\n env: input.env,\n build: input.build,\n dryRun: input.dryRun,\n verbose: input.verbose,\n packages: input.packages,\n network: input.network,\n privateKey: input.privateKey,\n registry: input.registry,\n fullUpload: input.fullUpload,\n });\n\n if (result.status === \"error\") {\n return {\n status: \"error\" as const,\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n built: result.built,\n skipped: result.skipped,\n error: result.error,\n deployResults: result.deployResults,\n };\n }\n\n if (result.status === \"dry-run\") {\n return {\n status: \"dry-run\" as const,\n registryUrl: result.registryUrl,\n built: result.built,\n skipped: result.skipped,\n };\n }\n\n let nextSession = session;\n if (result.publishConfig) {\n const opened = await openResolution({ cwd: session.root });\n if (opened) {\n nextSession = opened;\n }\n }\n\n const configPublished = {\n registryUrl: result.registryUrl,\n txHash: result.txHash,\n fingerprint: result.fingerprint,\n slotPins: result.slotPins,\n built: result.built,\n skipped: result.skipped,\n deployResults: result.deployResults,\n } as const;\n\n let image: string | undefined;\n let imageDigest: string | undefined;\n let service: string | undefined;\n\n const imagePlan = resolveDeployImagePlan({\n // A prebuilt digest pairs with the pushed ref (BOS_IMAGE from the CI\n // image job, or repository derivation) — ci.image is a build-time\n // choice, not a pin-time one; letting it win here could pin a digest\n // from a different image.\n imageRef: resolveImageRef({\n ciImage: imageDigestInput ? undefined : nextSession.config?.ci?.image,\n repository: nextSession.config?.repository,\n env: process.env,\n }),\n imageDigest: imageDigestInput,\n hasDocker: await hasDocker(),\n hasDockerfile: existsSync(join(session.root, \"Dockerfile\")),\n });\n\n if (imagePlan.kind === \"skip\") {\n console.log();\n console.log(colors.yellow(` Image skipped: ${imagePlan.reason}`));\n } else if (imagePlan.kind === \"prebuilt\") {\n image = imagePlan.image;\n imageDigest = imagePlan.digest;\n console.log();\n console.log(\n colors.green(\n ` ${icons.ok} Using pre-pushed image ${imagePlan.image}@${imagePlan.digest.slice(0, 19)}…`,\n ),\n );\n } else {\n console.log();\n try {\n const imageResult = await buildAndPushImage({\n image: imagePlan.image,\n configDir: session.root,\n verbose: input.verbose,\n });\n image = imageResult.image;\n imageDigest = imageResult.digest;\n console.log(\n colors.green(\n ` ${icons.ok} Image pushed ${imageResult.image}:${imageResult.tag}${imageResult.digest ? ` (${imageResult.digest.slice(0, 19)}…)` : \"\"}`,\n ),\n );\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n const imageError =\n message.includes(\"not found\") || message.includes(\"ENOENT\")\n ? \"Docker not found — install Docker to build the runtime image\"\n : `Image build/push failed: ${message}`;\n console.log(colors.yellow(` ${imageError}`));\n return {\n status: \"published\" as const,\n ...configPublished,\n error: `Config published but ${imageError}`,\n };\n }\n }\n\n if (process.env.RAILWAY_TOKEN) {\n const railwayService = input.service ?? nextSession.config?.ci?.railway?.service;\n if (!railwayService) {\n console.log();\n console.log(\n colors.yellow(\n \" Railway deploy skipped: ci.railway.service is not configured in bos.config.json\",\n ),\n );\n return {\n status: \"published\" as const,\n ...configPublished,\n image,\n error:\n \"Config published but Railway deploy failed: ci.railway.service is not configured in bos.config.json\",\n };\n }\n if (!image || !imageDigest) {\n console.log();\n console.log(\n colors.yellow(\n \" Railway deploy skipped: no runtime image digest — set ci.image (or pass BOS_IMAGE_DIGEST) and make the image available\",\n ),\n );\n return {\n status: \"published\" as const,\n ...configPublished,\n image,\n service: railwayService,\n error:\n \"Config published but Railway deploy requires a runtime image (set ci.image, or pass BOS_IMAGE_DIGEST for a pre-pushed image)\",\n };\n }\n\n service = railwayService;\n try {\n await deployImageToRailway({\n service: railwayService,\n configDir: session.root,\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n const railError =\n message.includes(\"not found\") || message.includes(\"ENOENT\")\n ? \"Railway CLI not found. Install it: npm i -g @railway/cli\"\n : `Railway deploy failed: ${message}`;\n console.log(colors.yellow(` ${railError}`));\n return {\n status: \"published\" as const,\n ...configPublished,\n image,\n service,\n error: `Config published but ${railError}`,\n };\n }\n } else {\n console.log();\n console.log(colors.yellow(\" Railway deploy skipped (RAILWAY_TOKEN not set)\"));\n }\n\n return {\n status: \"deployed\" as const,\n ...configPublished,\n image,\n service,\n };\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,SAAgB,eAAe,SAAqB;CAClD,OAAO;EACL,SAAS,QAAQ,QAAQ,QAAQ,OAAO,EAAE,OAAO,cAAc;GAE7D,MAAM,UADO,QAAQ,IAAI,QAAQ,mBAAmB,UACjC,CAAC,CAAC;GACrB,IAAI,CAAC,SAAS,QACZ,OAAO;IACL,QAAQ;IACR,aAAa;IACb,OAAO;GACT;GAGF,MAAM,SAAS,MAAM,gBAAgB;IACnC,WAAW,QAAQ;IACnB,eAAe,QAAQ;IACvB,WAAW,QAAQ;IACnB,KAAK,MAAM;IACX,OAAO;IACP,QAAQ,MAAM;IACd,SAAS,MAAM;IACf,UAAU;IACV,SAAS,MAAM;IACf,YAAY,MAAM;IAClB,QAAQ,MAAM;IACd,UAAU,MAAM;GAClB,CAAC;GAED,OAAO;IACL,QAAQ,OAAO;IACf,aAAa,OAAO;IACpB,QAAQ,OAAO;IACf,OAAO,OAAO;IACd,OAAO,OAAO;IACd,SAAS,OAAO;IAChB,eAAe,OAAO;GACxB;EACF,CAAC;EA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MAAM,UAAU,OAAO,KAAK;KACrE,MAAM,YACJ,QAAQ,SAAS,WAAW,KAAK,QAAQ,SAAS,QAAQ,IACtD,6DACA,0BAA0B;KAChC,QAAQ,IAAI,OAAO,OAAO,KAAK,WAAW,CAAC;KAC3C,OAAO;MACL,QAAQ;MACR,GAAG;MACH;MACA;MACA,OAAO,wBAAwB;KACjC;IACF;GACF,OAAO;IACL,QAAQ,IAAI;IACZ,QAAQ,IAAI,OAAO,OAAO,kDAAkD,CAAC;GAC/E;GAEA,OAAO;IACL,QAAQ;IACR,GAAG;IACH;IACA;GACF;EACF,CAAC;CACH;AACF"}
|
|
@@ -5,6 +5,7 @@ const require_resolution_session = require('../resolution/session.cjs');
|
|
|
5
5
|
const require_mf = require('../mf.cjs');
|
|
6
6
|
const require_build = require('../build.cjs');
|
|
7
7
|
const require_code_artifacts = require('../code-artifacts.cjs');
|
|
8
|
+
const require_dev_program = require('../dev-program.cjs');
|
|
8
9
|
const require_sync = require('../cli/sync.cjs');
|
|
9
10
|
const require_upgrade = require('../cli/upgrade.cjs');
|
|
10
11
|
let node_fs = require("node:fs");
|
|
@@ -301,13 +302,35 @@ function registerUpgrade(builder) {
|
|
|
301
302
|
remotes: []
|
|
302
303
|
};
|
|
303
304
|
}
|
|
304
|
-
if (!authored)
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
305
|
+
if (!authored) {
|
|
306
|
+
const account = node_process.default.env.BOS_ACCOUNT;
|
|
307
|
+
const gateway = node_process.default.env.BOS_GATEWAY;
|
|
308
|
+
if (!account || !gateway) return {
|
|
309
|
+
status: "fail",
|
|
310
|
+
hostVersion: null,
|
|
311
|
+
hostReachable: false,
|
|
312
|
+
hostReason: require_config.MISSING_CONFIG_MESSAGE,
|
|
313
|
+
remotes: []
|
|
314
|
+
};
|
|
315
|
+
try {
|
|
316
|
+
authored = await require_dev_program.resolvePublishedConfig(account, gateway);
|
|
317
|
+
} catch (e) {
|
|
318
|
+
return {
|
|
319
|
+
status: "fail",
|
|
320
|
+
hostVersion: null,
|
|
321
|
+
hostReachable: false,
|
|
322
|
+
hostReason: e instanceof Error ? e.message : String(e),
|
|
323
|
+
remotes: []
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
if (!authored) return {
|
|
327
|
+
status: "fail",
|
|
328
|
+
hostVersion: null,
|
|
329
|
+
hostReachable: false,
|
|
330
|
+
hostReason: `No config found at bos://${account}/${gateway} — verify BOS_ACCOUNT/BOS_GATEWAY and that the config has been published.`,
|
|
331
|
+
remotes: []
|
|
332
|
+
};
|
|
333
|
+
}
|
|
311
334
|
const report = await require_mf.checkFederationCompat(authored, { timeoutMs: input.timeoutMs });
|
|
312
335
|
return {
|
|
313
336
|
status: report.ok ? "ok" : "fail",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.cjs","names":["findConfigPath","MISSING_CONFIG_MESSAGE","resolve","dirname","syncTemplate","openResolution","generateCodeArtifacts","upgradeTemplate","process","existsSync","join","relative","selectWorkspaceTargets","readFileSync","colors","spawnSync","readAuthoredConfigInput","checkFederationCompat"],"sources":["../../src/commands/upgrade.ts"],"sourcesContent":["import { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport process from \"node:process\";\nimport { selectWorkspaceTargets } from \"../build\";\nimport { syncTemplate } from \"../cli/sync\";\nimport { upgradeTemplate } from \"../cli/upgrade\";\nimport { generateCodeArtifacts } from \"../code-artifacts\";\nimport { findConfigPath, MISSING_CONFIG_MESSAGE, readAuthoredConfigInput } from \"../config\";\nimport { checkFederationCompat } from \"../mf\";\nimport { openResolution } from \"../resolution/session\";\nimport type { BosConfig } from \"../types\";\nimport { colors } from \"../utils/theme\";\nimport type { BosBuilder } from \"./shared\";\n\nexport function registerUpgrade(builder: BosBuilder) {\n return {\n sync: builder.sync.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n updated: [],\n skipped: [],\n added: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const result = await syncTemplate(projectDir, input);\n\n if (result.status === \"synced\" || result.status === \"dry-run\") {\n const syncedConfig = await openResolution({ cwd: projectDir });\n if (syncedConfig?.config) {\n await generateCodeArtifacts(projectDir, syncedConfig.config);\n }\n }\n\n return result;\n } catch (error) {\n return {\n status: \"error\" as const,\n updated: [],\n skipped: [],\n added: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n upgrade: builder.upgrade.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n packages: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n return await upgradeTemplate(projectDir, input);\n } catch (error) {\n return {\n status: \"error\" as const,\n packages: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n typesGen: builder.typesGen.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const env =\n input.env ?? (process.env.NODE_ENV === \"production\" ? \"production\" : \"development\");\n\n const refreshed = await openResolution({\n cwd: projectDir,\n env,\n remotePlugins: input.remotePlugins,\n });\n if (!refreshed?.config || !refreshed.runtime) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: \"Failed to load the authored config\",\n };\n }\n\n const runtime = refreshed.runtime;\n const resolvedConfig = refreshed.config;\n\n if (input.dryRun) {\n const pluginEntries = Object.entries(runtime.plugins ?? {});\n const fetched: string[] = [];\n const skipped: string[] = [];\n const hasLocalApiWorkspace = existsSync(join(projectDir, \"api\", \"src\"));\n\n if (runtime.api.source !== \"local\") {\n fetched.push(`api remote (${runtime.api.url})`);\n } else {\n const path = runtime.api.localPath\n ? ` (${relative(projectDir, runtime.api.localPath)})`\n : \"\";\n skipped.push(`api local${path}`);\n }\n\n if (runtime.auth) {\n if (runtime.auth.source !== \"local\") {\n fetched.push(`auth remote (${runtime.auth.url})`);\n } else {\n const path = runtime.auth.localPath\n ? ` (${relative(projectDir, runtime.auth.localPath)})`\n : \"\";\n skipped.push(`auth local${path}`);\n }\n }\n\n for (const [key, plugin] of pluginEntries) {\n if (plugin.url && plugin.source !== \"local\") {\n fetched.push(`${key} remote (${plugin.url})`);\n } else if (plugin.localPath) {\n skipped.push(`${key} local (${relative(projectDir, plugin.localPath)})`);\n } else {\n skipped.push(`${key} no URL resolved`);\n }\n }\n\n const generated = [\"ui/src/lib/api-types.gen.ts\", \"ui/src/lib/auth-types.gen.ts\"];\n if (hasLocalApiWorkspace) {\n generated.push(\"api/src/lib/plugins-types.gen.ts\", \"api/src/lib/auth-types.gen.ts\");\n }\n if (existsSync(join(projectDir, \"host\", \"src\"))) {\n generated.push(\"host/src/lib/auth-types.gen.ts\");\n }\n for (const [_key, plugin] of pluginEntries) {\n const localPath = plugin.localPath;\n if (!localPath) continue;\n const pluginSrc = join(localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(pluginSrc)) {\n generated.push(relative(projectDir, pluginSrc));\n }\n }\n if (runtime.auth?.localPath) {\n const authSrc = join(runtime.auth.localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(authSrc)) {\n generated.push(relative(projectDir, authSrc));\n }\n }\n\n return {\n status: \"success\" as const,\n generated,\n fetched,\n skipped,\n failed: [],\n };\n }\n\n const artifacts = await generateCodeArtifacts(projectDir, resolvedConfig, {\n runtimeConfig: runtime,\n });\n\n const hasLocalApiWorkspace = existsSync(join(projectDir, \"api\", \"src\"));\n const generated = [\"ui/src/lib/api-types.gen.ts\"];\n if (hasLocalApiWorkspace) {\n generated.push(\"api/src/lib/plugins-types.gen.ts\", \"api/src/lib/auth-types.gen.ts\");\n }\n if (runtime.auth && (runtime.auth.source !== \"local\" || runtime.auth.localPath)) {\n generated.push(\"ui/src/lib/auth-types.gen.ts\");\n }\n if (existsSync(join(projectDir, \"host\", \"src\"))) {\n generated.push(\"host/src/lib/auth-types.gen.ts\");\n }\n for (const [_key, plugin] of Object.entries(runtime.plugins ?? {})) {\n const localPath = plugin.localPath;\n if (!localPath) continue;\n const pluginSrc = join(localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(pluginSrc)) {\n generated.push(relative(projectDir, pluginSrc));\n }\n }\n if (runtime.auth?.localPath) {\n const authSrc = join(runtime.auth.localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(authSrc)) {\n generated.push(relative(projectDir, authSrc));\n }\n }\n\n const contractStatus = artifacts?.contractStatus ?? [];\n const fetched: string[] = [];\n const skipped: string[] = [];\n const failed: string[] = [];\n for (const entry of contractStatus) {\n if (entry.source === \"remote\") {\n fetched.push(entry.url ? `${entry.key} remote (${entry.url})` : entry.key);\n } else if (entry.source === \"local\") {\n const path = entry.localPath ? ` (${relative(projectDir, entry.localPath)})` : \"\";\n skipped.push(`${entry.key} local${path}`);\n } else if (entry.source === \"skipped\") {\n skipped.push(`${entry.key} no URL resolved`);\n } else if (entry.source === \"failed\") {\n const detail = entry.error ? `: ${entry.error}` : \"\";\n failed.push(`${entry.key}${detail}`);\n }\n }\n\n return {\n status: \"success\" as const,\n generated,\n fetched,\n skipped,\n failed,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n typecheck: builder.typecheck.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const refreshed = await openResolution({ cwd: projectDir });\n if (!refreshed?.config || !refreshed.runtime) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: \"Failed to load the authored config\",\n };\n }\n\n const runtime = refreshed.runtime;\n const resolvedConfig = refreshed.config;\n\n await generateCodeArtifacts(projectDir, resolvedConfig, {\n runtimeConfig: runtime,\n });\n type AppTarget = { source?: string; localPath?: string };\n const workspaceEntries: Array<{\n key: string;\n label: string;\n dir: string;\n }> = [];\n const skipped: Array<{ key: string; label: string }> = [];\n\n const appTargets: Array<{\n key: string;\n label: string;\n target: AppTarget | undefined;\n }> = [\n { key: \"host\", label: \"host\", target: runtime.host },\n { key: \"ui\", label: \"ui\", target: runtime.ui },\n { key: \"api\", label: \"api\", target: runtime.api },\n ];\n if (runtime.auth) {\n appTargets.push({ key: \"auth\", label: \"auth\", target: runtime.auth });\n }\n\n for (const entry of appTargets) {\n if (\n entry.target?.source === \"local\" &&\n entry.target.localPath &&\n existsSync(join(entry.target.localPath, \"tsconfig.json\"))\n ) {\n workspaceEntries.push({\n key: entry.key,\n label: entry.label,\n dir: entry.target.localPath,\n });\n } else {\n skipped.push({ key: entry.key, label: entry.label });\n }\n }\n\n for (const [key, plugin] of Object.entries(runtime.plugins ?? {})) {\n const label = `plugins/${key}`;\n if (\n plugin.source === \"local\" &&\n plugin.localPath &&\n existsSync(join(plugin.localPath, \"tsconfig.json\"))\n ) {\n workspaceEntries.push({ key, label, dir: plugin.localPath });\n } else {\n skipped.push({ key, label });\n }\n }\n\n const selected = selectWorkspaceTargets(input.packages, resolvedConfig);\n const targets =\n input.packages === \"all\"\n ? workspaceEntries\n : workspaceEntries.filter((entry) => selected.includes(entry.key));\n const skippedEntries =\n input.packages === \"all\"\n ? skipped\n : skipped.filter((entry) => selected.includes(entry.key));\n\n const checked: string[] = [];\n const results: Array<{\n workspace: string;\n passed: boolean;\n error?: string;\n }> = [];\n\n for (const entry of targets) {\n const packageJsonPath = join(entry.dir, \"package.json\");\n let args: string[] = [\"exec\", \"tsc\", \"--noEmit\"];\n if (existsSync(packageJsonPath)) {\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n scripts?: Record<string, string>;\n };\n if (pkg.scripts?.typecheck) {\n args = [\"run\", \"typecheck\"];\n }\n } catch {}\n }\n\n console.log(`\\n ${colors.dim(\"Checking\")} ${colors.cyan(entry.label)}`);\n const child = spawnSync(\"pnpm\", args, {\n cwd: entry.dir,\n stdio: \"inherit\",\n });\n const passed = child.status === 0;\n checked.push(entry.label);\n results.push({\n workspace: entry.label,\n passed,\n error: passed ? undefined : `typecheck failed (exit code ${child.status ?? \"n/a\"})`,\n });\n }\n\n return {\n status: \"success\" as const,\n checked,\n skipped: skippedEntries.map((entry) => entry.label),\n results,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n mfCheck: builder.mfCheck.handler(async ({ input }) => {\n let authored: BosConfig | null = null;\n try {\n authored = (await readAuthoredConfigInput()) as BosConfig | null;\n } catch (e) {\n return {\n status: \"fail\" as const,\n hostVersion: null,\n hostReachable: false,\n hostReason: e instanceof Error ? e.message : String(e),\n remotes: [],\n };\n }\n if (!authored) {\n return {\n status: \"fail\" as const,\n hostVersion: null,\n hostReachable: false,\n hostReason: MISSING_CONFIG_MESSAGE,\n remotes: [],\n };\n }\n\n const report = await checkFederationCompat(authored, {\n timeoutMs: input.timeoutMs,\n });\n return {\n status: report.ok ? (\"ok\" as const) : (\"fail\" as const),\n hostVersion: report.hostVersion,\n hostReachable: report.hostReachable,\n hostReason: report.hostReason,\n remotes: report.remotes,\n };\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAgB,gBAAgB,SAAqB;CACnD,OAAO;EACL,MAAM,QAAQ,KAAK,QAAQ,OAAO,EAA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OAAO,iBAAiB,QAAQ,MAAM,UAAU;IAClD;GACF;EACF,CAAC;EAED,SAAS,QAAQ,QAAQ,QAAQ,OAAO,EAAE,YAAY;GACpD,IAAI,WAA6B;GACjC,IAAI;IACF,WAAY,MAAMC,uCAAwB;GAC5C,SAAS,GAAG;IACV,OAAO;KACL,QAAQ;KACR,aAAa;KACb,eAAe;KACf,YAAY,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;KACrD,SAAS,CAAC;IACZ;GACF;GACA,IAAI,CAAC,UACH,OAAO;IACL,QAAQ;IACR,aAAa;IACb,eAAe;IACf,YAAYf;IACZ,SAAS,CAAC;GACZ;GAGF,MAAM,SAAS,MAAMgB,iCAAsB,UAAU,EACnD,WAAW,MAAM,UACnB,CAAC;GACD,OAAO;IACL,QAAQ,OAAO,KAAM,OAAkB;IACvC,aAAa,OAAO;IACpB,eAAe,OAAO;IACtB,YAAY,OAAO;IACnB,SAAS,OAAO;GAClB;EACF,CAAC;CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"upgrade.cjs","names":["findConfigPath","MISSING_CONFIG_MESSAGE","resolve","dirname","syncTemplate","openResolution","generateCodeArtifacts","upgradeTemplate","process","existsSync","join","relative","selectWorkspaceTargets","readFileSync","colors","spawnSync","readAuthoredConfigInput","resolvePublishedConfig","checkFederationCompat"],"sources":["../../src/commands/upgrade.ts"],"sourcesContent":["import { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport process from \"node:process\";\nimport { selectWorkspaceTargets } from \"../build\";\nimport { syncTemplate } from \"../cli/sync\";\nimport { upgradeTemplate } from \"../cli/upgrade\";\nimport { generateCodeArtifacts } from \"../code-artifacts\";\nimport { findConfigPath, MISSING_CONFIG_MESSAGE, readAuthoredConfigInput } from \"../config\";\nimport { resolvePublishedConfig } from \"../dev-program\";\nimport { checkFederationCompat } from \"../mf\";\nimport { openResolution } from \"../resolution/session\";\nimport type { BosConfig } from \"../types\";\nimport { colors } from \"../utils/theme\";\nimport type { BosBuilder } from \"./shared\";\n\nexport function registerUpgrade(builder: BosBuilder) {\n return {\n sync: builder.sync.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n updated: [],\n skipped: [],\n added: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const result = await syncTemplate(projectDir, input);\n\n if (result.status === \"synced\" || result.status === \"dry-run\") {\n const syncedConfig = await openResolution({ cwd: projectDir });\n if (syncedConfig?.config) {\n await generateCodeArtifacts(projectDir, syncedConfig.config);\n }\n }\n\n return result;\n } catch (error) {\n return {\n status: \"error\" as const,\n updated: [],\n skipped: [],\n added: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n upgrade: builder.upgrade.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n packages: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n return await upgradeTemplate(projectDir, input);\n } catch (error) {\n return {\n status: \"error\" as const,\n packages: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n typesGen: builder.typesGen.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const env =\n input.env ?? (process.env.NODE_ENV === \"production\" ? \"production\" : \"development\");\n\n const refreshed = await openResolution({\n cwd: projectDir,\n env,\n remotePlugins: input.remotePlugins,\n });\n if (!refreshed?.config || !refreshed.runtime) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: \"Failed to load the authored config\",\n };\n }\n\n const runtime = refreshed.runtime;\n const resolvedConfig = refreshed.config;\n\n if (input.dryRun) {\n const pluginEntries = Object.entries(runtime.plugins ?? {});\n const fetched: string[] = [];\n const skipped: string[] = [];\n const hasLocalApiWorkspace = existsSync(join(projectDir, \"api\", \"src\"));\n\n if (runtime.api.source !== \"local\") {\n fetched.push(`api remote (${runtime.api.url})`);\n } else {\n const path = runtime.api.localPath\n ? ` (${relative(projectDir, runtime.api.localPath)})`\n : \"\";\n skipped.push(`api local${path}`);\n }\n\n if (runtime.auth) {\n if (runtime.auth.source !== \"local\") {\n fetched.push(`auth remote (${runtime.auth.url})`);\n } else {\n const path = runtime.auth.localPath\n ? ` (${relative(projectDir, runtime.auth.localPath)})`\n : \"\";\n skipped.push(`auth local${path}`);\n }\n }\n\n for (const [key, plugin] of pluginEntries) {\n if (plugin.url && plugin.source !== \"local\") {\n fetched.push(`${key} remote (${plugin.url})`);\n } else if (plugin.localPath) {\n skipped.push(`${key} local (${relative(projectDir, plugin.localPath)})`);\n } else {\n skipped.push(`${key} no URL resolved`);\n }\n }\n\n const generated = [\"ui/src/lib/api-types.gen.ts\", \"ui/src/lib/auth-types.gen.ts\"];\n if (hasLocalApiWorkspace) {\n generated.push(\"api/src/lib/plugins-types.gen.ts\", \"api/src/lib/auth-types.gen.ts\");\n }\n if (existsSync(join(projectDir, \"host\", \"src\"))) {\n generated.push(\"host/src/lib/auth-types.gen.ts\");\n }\n for (const [_key, plugin] of pluginEntries) {\n const localPath = plugin.localPath;\n if (!localPath) continue;\n const pluginSrc = join(localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(pluginSrc)) {\n generated.push(relative(projectDir, pluginSrc));\n }\n }\n if (runtime.auth?.localPath) {\n const authSrc = join(runtime.auth.localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(authSrc)) {\n generated.push(relative(projectDir, authSrc));\n }\n }\n\n return {\n status: \"success\" as const,\n generated,\n fetched,\n skipped,\n failed: [],\n };\n }\n\n const artifacts = await generateCodeArtifacts(projectDir, resolvedConfig, {\n runtimeConfig: runtime,\n });\n\n const hasLocalApiWorkspace = existsSync(join(projectDir, \"api\", \"src\"));\n const generated = [\"ui/src/lib/api-types.gen.ts\"];\n if (hasLocalApiWorkspace) {\n generated.push(\"api/src/lib/plugins-types.gen.ts\", \"api/src/lib/auth-types.gen.ts\");\n }\n if (runtime.auth && (runtime.auth.source !== \"local\" || runtime.auth.localPath)) {\n generated.push(\"ui/src/lib/auth-types.gen.ts\");\n }\n if (existsSync(join(projectDir, \"host\", \"src\"))) {\n generated.push(\"host/src/lib/auth-types.gen.ts\");\n }\n for (const [_key, plugin] of Object.entries(runtime.plugins ?? {})) {\n const localPath = plugin.localPath;\n if (!localPath) continue;\n const pluginSrc = join(localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(pluginSrc)) {\n generated.push(relative(projectDir, pluginSrc));\n }\n }\n if (runtime.auth?.localPath) {\n const authSrc = join(runtime.auth.localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(authSrc)) {\n generated.push(relative(projectDir, authSrc));\n }\n }\n\n const contractStatus = artifacts?.contractStatus ?? [];\n const fetched: string[] = [];\n const skipped: string[] = [];\n const failed: string[] = [];\n for (const entry of contractStatus) {\n if (entry.source === \"remote\") {\n fetched.push(entry.url ? `${entry.key} remote (${entry.url})` : entry.key);\n } else if (entry.source === \"local\") {\n const path = entry.localPath ? ` (${relative(projectDir, entry.localPath)})` : \"\";\n skipped.push(`${entry.key} local${path}`);\n } else if (entry.source === \"skipped\") {\n skipped.push(`${entry.key} no URL resolved`);\n } else if (entry.source === \"failed\") {\n const detail = entry.error ? `: ${entry.error}` : \"\";\n failed.push(`${entry.key}${detail}`);\n }\n }\n\n return {\n status: \"success\" as const,\n generated,\n fetched,\n skipped,\n failed,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n typecheck: builder.typecheck.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const refreshed = await openResolution({ cwd: projectDir });\n if (!refreshed?.config || !refreshed.runtime) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: \"Failed to load the authored config\",\n };\n }\n\n const runtime = refreshed.runtime;\n const resolvedConfig = refreshed.config;\n\n await generateCodeArtifacts(projectDir, resolvedConfig, {\n runtimeConfig: runtime,\n });\n type AppTarget = { source?: string; localPath?: string };\n const workspaceEntries: Array<{\n key: string;\n label: string;\n dir: string;\n }> = [];\n const skipped: Array<{ key: string; label: string }> = [];\n\n const appTargets: Array<{\n key: string;\n label: string;\n target: AppTarget | undefined;\n }> = [\n { key: \"host\", label: \"host\", target: runtime.host },\n { key: \"ui\", label: \"ui\", target: runtime.ui },\n { key: \"api\", label: \"api\", target: runtime.api },\n ];\n if (runtime.auth) {\n appTargets.push({ key: \"auth\", label: \"auth\", target: runtime.auth });\n }\n\n for (const entry of appTargets) {\n if (\n entry.target?.source === \"local\" &&\n entry.target.localPath &&\n existsSync(join(entry.target.localPath, \"tsconfig.json\"))\n ) {\n workspaceEntries.push({\n key: entry.key,\n label: entry.label,\n dir: entry.target.localPath,\n });\n } else {\n skipped.push({ key: entry.key, label: entry.label });\n }\n }\n\n for (const [key, plugin] of Object.entries(runtime.plugins ?? {})) {\n const label = `plugins/${key}`;\n if (\n plugin.source === \"local\" &&\n plugin.localPath &&\n existsSync(join(plugin.localPath, \"tsconfig.json\"))\n ) {\n workspaceEntries.push({ key, label, dir: plugin.localPath });\n } else {\n skipped.push({ key, label });\n }\n }\n\n const selected = selectWorkspaceTargets(input.packages, resolvedConfig);\n const targets =\n input.packages === \"all\"\n ? workspaceEntries\n : workspaceEntries.filter((entry) => selected.includes(entry.key));\n const skippedEntries =\n input.packages === \"all\"\n ? skipped\n : skipped.filter((entry) => selected.includes(entry.key));\n\n const checked: string[] = [];\n const results: Array<{\n workspace: string;\n passed: boolean;\n error?: string;\n }> = [];\n\n for (const entry of targets) {\n const packageJsonPath = join(entry.dir, \"package.json\");\n let args: string[] = [\"exec\", \"tsc\", \"--noEmit\"];\n if (existsSync(packageJsonPath)) {\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n scripts?: Record<string, string>;\n };\n if (pkg.scripts?.typecheck) {\n args = [\"run\", \"typecheck\"];\n }\n } catch {}\n }\n\n console.log(`\\n ${colors.dim(\"Checking\")} ${colors.cyan(entry.label)}`);\n const child = spawnSync(\"pnpm\", args, {\n cwd: entry.dir,\n stdio: \"inherit\",\n });\n const passed = child.status === 0;\n checked.push(entry.label);\n results.push({\n workspace: entry.label,\n passed,\n error: passed ? undefined : `typecheck failed (exit code ${child.status ?? \"n/a\"})`,\n });\n }\n\n return {\n status: \"success\" as const,\n checked,\n skipped: skippedEntries.map((entry) => entry.label),\n results,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n mfCheck: builder.mfCheck.handler(async ({ input }) => {\n let authored: BosConfig | null = null;\n try {\n authored = (await readAuthoredConfigInput()) as BosConfig | null;\n } catch (e) {\n return {\n status: \"fail\" as const,\n hostVersion: null,\n hostReachable: false,\n hostReason: e instanceof Error ? e.message : String(e),\n remotes: [],\n };\n }\n if (!authored) {\n // No local authored config (the universal image carries none): fall\n // back to the registry identity — the same source `bos start` boots\n // from in a runtime container.\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 hostVersion: null,\n hostReachable: false,\n hostReason: MISSING_CONFIG_MESSAGE,\n remotes: [],\n };\n }\n try {\n authored = await resolvePublishedConfig(account, gateway);\n } catch (e) {\n return {\n status: \"fail\" as const,\n hostVersion: null,\n hostReachable: false,\n hostReason: e instanceof Error ? e.message : String(e),\n remotes: [],\n };\n }\n if (!authored) {\n return {\n status: \"fail\" as const,\n hostVersion: null,\n hostReachable: false,\n hostReason: `No config found at bos://${account}/${gateway} — verify BOS_ACCOUNT/BOS_GATEWAY and that the config has been published.`,\n remotes: [],\n };\n }\n }\n\n const report = await checkFederationCompat(authored, {\n timeoutMs: input.timeoutMs,\n });\n return {\n status: report.ok ? (\"ok\" as const) : (\"fail\" as const),\n hostVersion: report.hostVersion,\n hostReachable: report.hostReachable,\n hostReason: report.hostReason,\n remotes: report.remotes,\n };\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAgB,gBAAgB,SAAqB;CACnD,OAAO;EACL,MAAM,QAAQ,KAAK,QAAQ,OAAO,EAAE,YAAY;GAC9C,IAAI;IACF,MAAM,aAAaA,8BAAe;IAClC,IAAI,CAAC,YACH,OAAO;KACL,QAAQ;KACR,SAAS,CAAC;KACV,SAAS,CAAC;KACV,OAAO,CAAC;KACR,OAAO,GAAGC,sCAAuB;IACnC;IAGF,MAAM,iBAAaC,uBAAQC,mBAAQ,UAAU,CAAC;IAC9C,MAAM,SAAS,MAAMC,0BAAa,YAAY,KAAK;IAEnD,IAAI,OAAO,WAAW,YAAY,OAAO,WAAW,WAAW;KAC7D,MAAM,eAAe,MAAMC,0CAAe,EAAE,KAAK,WAAW,CAAC;KAC7D,IAAI,cAAc,QAChB,MAAMC,6CAAsB,YAAY,aAAa,MAAM;IAE/D;IAEA,OAAO;GACT,SAAS,OAAO;IACd,OAAO;KACL,QAAQ;KACR,SAAS,CAAC;KACV,SAAS,CAAC;KACV,OAAO,CAAC;KACR,OAAO,iBAAiB,QAAQ,MAAM,UAAU;IAClD;GACF;EACF,CAAC;EAED,SAAS,QAAQ,QAAQ,QAAQ,OAAO,EAAE,YAAY;GACpD,IAAI;IACF,MAAM,aAAaN,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,CAAC;KACZ;IACF;IACA,IAAI,CAAC,UACH,OAAO;KACL,QAAQ;KACR,aAAa;KACb,eAAe;KACf,YAAY,4BAA4B,QAAQ,GAAG,QAAQ;KAC3D,SAAS,CAAC;IACZ;GAEJ;GAEA,MAAM,SAAS,MAAMC,iCAAsB,UAAU,EACnD,WAAW,MAAM,UACnB,CAAC;GACD,OAAO;IACL,QAAQ,OAAO,KAAM,OAAkB;IACvC,aAAa,OAAO;IACpB,eAAe,OAAO;IACtB,YAAY,OAAO;IACnB,SAAS,OAAO;GAClB;EACF,CAAC;CACH;AACF"}
|
|
@@ -4,6 +4,7 @@ import { openResolution } from "../resolution/session.mjs";
|
|
|
4
4
|
import { checkFederationCompat } from "../mf.mjs";
|
|
5
5
|
import { selectWorkspaceTargets } from "../build.mjs";
|
|
6
6
|
import { generateCodeArtifacts } from "../code-artifacts.mjs";
|
|
7
|
+
import { resolvePublishedConfig } from "../dev-program.mjs";
|
|
7
8
|
import { syncTemplate } from "../cli/sync.mjs";
|
|
8
9
|
import { upgradeTemplate } from "../cli/upgrade.mjs";
|
|
9
10
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -299,13 +300,35 @@ function registerUpgrade(builder) {
|
|
|
299
300
|
remotes: []
|
|
300
301
|
};
|
|
301
302
|
}
|
|
302
|
-
if (!authored)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
303
|
+
if (!authored) {
|
|
304
|
+
const account = process.env.BOS_ACCOUNT;
|
|
305
|
+
const gateway = process.env.BOS_GATEWAY;
|
|
306
|
+
if (!account || !gateway) return {
|
|
307
|
+
status: "fail",
|
|
308
|
+
hostVersion: null,
|
|
309
|
+
hostReachable: false,
|
|
310
|
+
hostReason: MISSING_CONFIG_MESSAGE,
|
|
311
|
+
remotes: []
|
|
312
|
+
};
|
|
313
|
+
try {
|
|
314
|
+
authored = await resolvePublishedConfig(account, gateway);
|
|
315
|
+
} catch (e) {
|
|
316
|
+
return {
|
|
317
|
+
status: "fail",
|
|
318
|
+
hostVersion: null,
|
|
319
|
+
hostReachable: false,
|
|
320
|
+
hostReason: e instanceof Error ? e.message : String(e),
|
|
321
|
+
remotes: []
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
if (!authored) return {
|
|
325
|
+
status: "fail",
|
|
326
|
+
hostVersion: null,
|
|
327
|
+
hostReachable: false,
|
|
328
|
+
hostReason: `No config found at bos://${account}/${gateway} — verify BOS_ACCOUNT/BOS_GATEWAY and that the config has been published.`,
|
|
329
|
+
remotes: []
|
|
330
|
+
};
|
|
331
|
+
}
|
|
309
332
|
const report = await checkFederationCompat(authored, { timeoutMs: input.timeoutMs });
|
|
310
333
|
return {
|
|
311
334
|
status: report.ok ? "ok" : "fail",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.mjs","names":[],"sources":["../../src/commands/upgrade.ts"],"sourcesContent":["import { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport process from \"node:process\";\nimport { selectWorkspaceTargets } from \"../build\";\nimport { syncTemplate } from \"../cli/sync\";\nimport { upgradeTemplate } from \"../cli/upgrade\";\nimport { generateCodeArtifacts } from \"../code-artifacts\";\nimport { findConfigPath, MISSING_CONFIG_MESSAGE, readAuthoredConfigInput } from \"../config\";\nimport { checkFederationCompat } from \"../mf\";\nimport { openResolution } from \"../resolution/session\";\nimport type { BosConfig } from \"../types\";\nimport { colors } from \"../utils/theme\";\nimport type { BosBuilder } from \"./shared\";\n\nexport function registerUpgrade(builder: BosBuilder) {\n return {\n sync: builder.sync.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n updated: [],\n skipped: [],\n added: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const result = await syncTemplate(projectDir, input);\n\n if (result.status === \"synced\" || result.status === \"dry-run\") {\n const syncedConfig = await openResolution({ cwd: projectDir });\n if (syncedConfig?.config) {\n await generateCodeArtifacts(projectDir, syncedConfig.config);\n }\n }\n\n return result;\n } catch (error) {\n return {\n status: \"error\" as const,\n updated: [],\n skipped: [],\n added: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n upgrade: builder.upgrade.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n packages: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n return await upgradeTemplate(projectDir, input);\n } catch (error) {\n return {\n status: \"error\" as const,\n packages: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n typesGen: builder.typesGen.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const env =\n input.env ?? (process.env.NODE_ENV === \"production\" ? \"production\" : \"development\");\n\n const refreshed = await openResolution({\n cwd: projectDir,\n env,\n remotePlugins: input.remotePlugins,\n });\n if (!refreshed?.config || !refreshed.runtime) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: \"Failed to load the authored config\",\n };\n }\n\n const runtime = refreshed.runtime;\n const resolvedConfig = refreshed.config;\n\n if (input.dryRun) {\n const pluginEntries = Object.entries(runtime.plugins ?? {});\n const fetched: string[] = [];\n const skipped: string[] = [];\n const hasLocalApiWorkspace = existsSync(join(projectDir, \"api\", \"src\"));\n\n if (runtime.api.source !== \"local\") {\n fetched.push(`api remote (${runtime.api.url})`);\n } else {\n const path = runtime.api.localPath\n ? ` (${relative(projectDir, runtime.api.localPath)})`\n : \"\";\n skipped.push(`api local${path}`);\n }\n\n if (runtime.auth) {\n if (runtime.auth.source !== \"local\") {\n fetched.push(`auth remote (${runtime.auth.url})`);\n } else {\n const path = runtime.auth.localPath\n ? ` (${relative(projectDir, runtime.auth.localPath)})`\n : \"\";\n skipped.push(`auth local${path}`);\n }\n }\n\n for (const [key, plugin] of pluginEntries) {\n if (plugin.url && plugin.source !== \"local\") {\n fetched.push(`${key} remote (${plugin.url})`);\n } else if (plugin.localPath) {\n skipped.push(`${key} local (${relative(projectDir, plugin.localPath)})`);\n } else {\n skipped.push(`${key} no URL resolved`);\n }\n }\n\n const generated = [\"ui/src/lib/api-types.gen.ts\", \"ui/src/lib/auth-types.gen.ts\"];\n if (hasLocalApiWorkspace) {\n generated.push(\"api/src/lib/plugins-types.gen.ts\", \"api/src/lib/auth-types.gen.ts\");\n }\n if (existsSync(join(projectDir, \"host\", \"src\"))) {\n generated.push(\"host/src/lib/auth-types.gen.ts\");\n }\n for (const [_key, plugin] of pluginEntries) {\n const localPath = plugin.localPath;\n if (!localPath) continue;\n const pluginSrc = join(localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(pluginSrc)) {\n generated.push(relative(projectDir, pluginSrc));\n }\n }\n if (runtime.auth?.localPath) {\n const authSrc = join(runtime.auth.localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(authSrc)) {\n generated.push(relative(projectDir, authSrc));\n }\n }\n\n return {\n status: \"success\" as const,\n generated,\n fetched,\n skipped,\n failed: [],\n };\n }\n\n const artifacts = await generateCodeArtifacts(projectDir, resolvedConfig, {\n runtimeConfig: runtime,\n });\n\n const hasLocalApiWorkspace = existsSync(join(projectDir, \"api\", \"src\"));\n const generated = [\"ui/src/lib/api-types.gen.ts\"];\n if (hasLocalApiWorkspace) {\n generated.push(\"api/src/lib/plugins-types.gen.ts\", \"api/src/lib/auth-types.gen.ts\");\n }\n if (runtime.auth && (runtime.auth.source !== \"local\" || runtime.auth.localPath)) {\n generated.push(\"ui/src/lib/auth-types.gen.ts\");\n }\n if (existsSync(join(projectDir, \"host\", \"src\"))) {\n generated.push(\"host/src/lib/auth-types.gen.ts\");\n }\n for (const [_key, plugin] of Object.entries(runtime.plugins ?? {})) {\n const localPath = plugin.localPath;\n if (!localPath) continue;\n const pluginSrc = join(localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(pluginSrc)) {\n generated.push(relative(projectDir, pluginSrc));\n }\n }\n if (runtime.auth?.localPath) {\n const authSrc = join(runtime.auth.localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(authSrc)) {\n generated.push(relative(projectDir, authSrc));\n }\n }\n\n const contractStatus = artifacts?.contractStatus ?? [];\n const fetched: string[] = [];\n const skipped: string[] = [];\n const failed: string[] = [];\n for (const entry of contractStatus) {\n if (entry.source === \"remote\") {\n fetched.push(entry.url ? `${entry.key} remote (${entry.url})` : entry.key);\n } else if (entry.source === \"local\") {\n const path = entry.localPath ? ` (${relative(projectDir, entry.localPath)})` : \"\";\n skipped.push(`${entry.key} local${path}`);\n } else if (entry.source === \"skipped\") {\n skipped.push(`${entry.key} no URL resolved`);\n } else if (entry.source === \"failed\") {\n const detail = entry.error ? `: ${entry.error}` : \"\";\n failed.push(`${entry.key}${detail}`);\n }\n }\n\n return {\n status: \"success\" as const,\n generated,\n fetched,\n skipped,\n failed,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n typecheck: builder.typecheck.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const refreshed = await openResolution({ cwd: projectDir });\n if (!refreshed?.config || !refreshed.runtime) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: \"Failed to load the authored config\",\n };\n }\n\n const runtime = refreshed.runtime;\n const resolvedConfig = refreshed.config;\n\n await generateCodeArtifacts(projectDir, resolvedConfig, {\n runtimeConfig: runtime,\n });\n type AppTarget = { source?: string; localPath?: string };\n const workspaceEntries: Array<{\n key: string;\n label: string;\n dir: string;\n }> = [];\n const skipped: Array<{ key: string; label: string }> = [];\n\n const appTargets: Array<{\n key: string;\n label: string;\n target: AppTarget | undefined;\n }> = [\n { key: \"host\", label: \"host\", target: runtime.host },\n { key: \"ui\", label: \"ui\", target: runtime.ui },\n { key: \"api\", label: \"api\", target: runtime.api },\n ];\n if (runtime.auth) {\n appTargets.push({ key: \"auth\", label: \"auth\", target: runtime.auth });\n }\n\n for (const entry of appTargets) {\n if (\n entry.target?.source === \"local\" &&\n entry.target.localPath &&\n existsSync(join(entry.target.localPath, \"tsconfig.json\"))\n ) {\n workspaceEntries.push({\n key: entry.key,\n label: entry.label,\n dir: entry.target.localPath,\n });\n } else {\n skipped.push({ key: entry.key, label: entry.label });\n }\n }\n\n for (const [key, plugin] of Object.entries(runtime.plugins ?? {})) {\n const label = `plugins/${key}`;\n if (\n plugin.source === \"local\" &&\n plugin.localPath &&\n existsSync(join(plugin.localPath, \"tsconfig.json\"))\n ) {\n workspaceEntries.push({ key, label, dir: plugin.localPath });\n } else {\n skipped.push({ key, label });\n }\n }\n\n const selected = selectWorkspaceTargets(input.packages, resolvedConfig);\n const targets =\n input.packages === \"all\"\n ? workspaceEntries\n : workspaceEntries.filter((entry) => selected.includes(entry.key));\n const skippedEntries =\n input.packages === \"all\"\n ? skipped\n : skipped.filter((entry) => selected.includes(entry.key));\n\n const checked: string[] = [];\n const results: Array<{\n workspace: string;\n passed: boolean;\n error?: string;\n }> = [];\n\n for (const entry of targets) {\n const packageJsonPath = join(entry.dir, \"package.json\");\n let args: string[] = [\"exec\", \"tsc\", \"--noEmit\"];\n if (existsSync(packageJsonPath)) {\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n scripts?: Record<string, string>;\n };\n if (pkg.scripts?.typecheck) {\n args = [\"run\", \"typecheck\"];\n }\n } catch {}\n }\n\n console.log(`\\n ${colors.dim(\"Checking\")} ${colors.cyan(entry.label)}`);\n const child = spawnSync(\"pnpm\", args, {\n cwd: entry.dir,\n stdio: \"inherit\",\n });\n const passed = child.status === 0;\n checked.push(entry.label);\n results.push({\n workspace: entry.label,\n passed,\n error: passed ? undefined : `typecheck failed (exit code ${child.status ?? \"n/a\"})`,\n });\n }\n\n return {\n status: \"success\" as const,\n checked,\n skipped: skippedEntries.map((entry) => entry.label),\n results,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n mfCheck: builder.mfCheck.handler(async ({ input }) => {\n let authored: BosConfig | null = null;\n try {\n authored = (await readAuthoredConfigInput()) as BosConfig | null;\n } catch (e) {\n return {\n status: \"fail\" as const,\n hostVersion: null,\n hostReachable: false,\n hostReason: e instanceof Error ? e.message : String(e),\n remotes: [],\n };\n }\n if (!authored) {\n return {\n status: \"fail\" as const,\n hostVersion: null,\n hostReachable: false,\n hostReason: MISSING_CONFIG_MESSAGE,\n remotes: [],\n };\n }\n\n const report = await checkFederationCompat(authored, {\n timeoutMs: input.timeoutMs,\n });\n return {\n status: report.ok ? (\"ok\" as const) : (\"fail\" as const),\n hostVersion: report.hostVersion,\n hostReachable: report.hostReachable,\n hostReason: report.hostReason,\n remotes: report.remotes,\n };\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,gBAAgB,SAAqB;CACnD,OAAO;EACL,MAAM,QAAQ,KAAK,QAAQ,OAAO,EAAE,YAAY;GAC9C,IAAI;IACF,MAAM,aAAa,eAAe;IAClC,IAAI,CAAC,YACH,OAAO;KACL,QAAQ;KACR,SAAS,CAAC;KACV,SAAS,CAAC;KACV,OAAO,CAAC;KACR,OAAO,GAAG,uBAAuB;IACn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;IACZ;GACF;GACA,IAAI,CAAC,UACH,OAAO;IACL,QAAQ;IACR,aAAa;IACb,eAAe;IACf,YAAY;IACZ,SAAS,CAAC;GACZ;GAGF,MAAM,SAAS,MAAM,sBAAsB,UAAU,EACnD,WAAW,MAAM,UACnB,CAAC;GACD,OAAO;IACL,QAAQ,OAAO,KAAM,OAAkB;IACvC,aAAa,OAAO;IACpB,eAAe,OAAO;IACtB,YAAY,OAAO;IACnB,SAAS,OAAO;GAClB;EACF,CAAC;CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"upgrade.mjs","names":[],"sources":["../../src/commands/upgrade.ts"],"sourcesContent":["import { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport process from \"node:process\";\nimport { selectWorkspaceTargets } from \"../build\";\nimport { syncTemplate } from \"../cli/sync\";\nimport { upgradeTemplate } from \"../cli/upgrade\";\nimport { generateCodeArtifacts } from \"../code-artifacts\";\nimport { findConfigPath, MISSING_CONFIG_MESSAGE, readAuthoredConfigInput } from \"../config\";\nimport { resolvePublishedConfig } from \"../dev-program\";\nimport { checkFederationCompat } from \"../mf\";\nimport { openResolution } from \"../resolution/session\";\nimport type { BosConfig } from \"../types\";\nimport { colors } from \"../utils/theme\";\nimport type { BosBuilder } from \"./shared\";\n\nexport function registerUpgrade(builder: BosBuilder) {\n return {\n sync: builder.sync.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n updated: [],\n skipped: [],\n added: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const result = await syncTemplate(projectDir, input);\n\n if (result.status === \"synced\" || result.status === \"dry-run\") {\n const syncedConfig = await openResolution({ cwd: projectDir });\n if (syncedConfig?.config) {\n await generateCodeArtifacts(projectDir, syncedConfig.config);\n }\n }\n\n return result;\n } catch (error) {\n return {\n status: \"error\" as const,\n updated: [],\n skipped: [],\n added: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n upgrade: builder.upgrade.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n packages: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n return await upgradeTemplate(projectDir, input);\n } catch (error) {\n return {\n status: \"error\" as const,\n packages: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n typesGen: builder.typesGen.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const env =\n input.env ?? (process.env.NODE_ENV === \"production\" ? \"production\" : \"development\");\n\n const refreshed = await openResolution({\n cwd: projectDir,\n env,\n remotePlugins: input.remotePlugins,\n });\n if (!refreshed?.config || !refreshed.runtime) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: \"Failed to load the authored config\",\n };\n }\n\n const runtime = refreshed.runtime;\n const resolvedConfig = refreshed.config;\n\n if (input.dryRun) {\n const pluginEntries = Object.entries(runtime.plugins ?? {});\n const fetched: string[] = [];\n const skipped: string[] = [];\n const hasLocalApiWorkspace = existsSync(join(projectDir, \"api\", \"src\"));\n\n if (runtime.api.source !== \"local\") {\n fetched.push(`api remote (${runtime.api.url})`);\n } else {\n const path = runtime.api.localPath\n ? ` (${relative(projectDir, runtime.api.localPath)})`\n : \"\";\n skipped.push(`api local${path}`);\n }\n\n if (runtime.auth) {\n if (runtime.auth.source !== \"local\") {\n fetched.push(`auth remote (${runtime.auth.url})`);\n } else {\n const path = runtime.auth.localPath\n ? ` (${relative(projectDir, runtime.auth.localPath)})`\n : \"\";\n skipped.push(`auth local${path}`);\n }\n }\n\n for (const [key, plugin] of pluginEntries) {\n if (plugin.url && plugin.source !== \"local\") {\n fetched.push(`${key} remote (${plugin.url})`);\n } else if (plugin.localPath) {\n skipped.push(`${key} local (${relative(projectDir, plugin.localPath)})`);\n } else {\n skipped.push(`${key} no URL resolved`);\n }\n }\n\n const generated = [\"ui/src/lib/api-types.gen.ts\", \"ui/src/lib/auth-types.gen.ts\"];\n if (hasLocalApiWorkspace) {\n generated.push(\"api/src/lib/plugins-types.gen.ts\", \"api/src/lib/auth-types.gen.ts\");\n }\n if (existsSync(join(projectDir, \"host\", \"src\"))) {\n generated.push(\"host/src/lib/auth-types.gen.ts\");\n }\n for (const [_key, plugin] of pluginEntries) {\n const localPath = plugin.localPath;\n if (!localPath) continue;\n const pluginSrc = join(localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(pluginSrc)) {\n generated.push(relative(projectDir, pluginSrc));\n }\n }\n if (runtime.auth?.localPath) {\n const authSrc = join(runtime.auth.localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(authSrc)) {\n generated.push(relative(projectDir, authSrc));\n }\n }\n\n return {\n status: \"success\" as const,\n generated,\n fetched,\n skipped,\n failed: [],\n };\n }\n\n const artifacts = await generateCodeArtifacts(projectDir, resolvedConfig, {\n runtimeConfig: runtime,\n });\n\n const hasLocalApiWorkspace = existsSync(join(projectDir, \"api\", \"src\"));\n const generated = [\"ui/src/lib/api-types.gen.ts\"];\n if (hasLocalApiWorkspace) {\n generated.push(\"api/src/lib/plugins-types.gen.ts\", \"api/src/lib/auth-types.gen.ts\");\n }\n if (runtime.auth && (runtime.auth.source !== \"local\" || runtime.auth.localPath)) {\n generated.push(\"ui/src/lib/auth-types.gen.ts\");\n }\n if (existsSync(join(projectDir, \"host\", \"src\"))) {\n generated.push(\"host/src/lib/auth-types.gen.ts\");\n }\n for (const [_key, plugin] of Object.entries(runtime.plugins ?? {})) {\n const localPath = plugin.localPath;\n if (!localPath) continue;\n const pluginSrc = join(localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(pluginSrc)) {\n generated.push(relative(projectDir, pluginSrc));\n }\n }\n if (runtime.auth?.localPath) {\n const authSrc = join(runtime.auth.localPath, \"src\", \"lib\", \"plugins-client.gen.ts\");\n if (existsSync(authSrc)) {\n generated.push(relative(projectDir, authSrc));\n }\n }\n\n const contractStatus = artifacts?.contractStatus ?? [];\n const fetched: string[] = [];\n const skipped: string[] = [];\n const failed: string[] = [];\n for (const entry of contractStatus) {\n if (entry.source === \"remote\") {\n fetched.push(entry.url ? `${entry.key} remote (${entry.url})` : entry.key);\n } else if (entry.source === \"local\") {\n const path = entry.localPath ? ` (${relative(projectDir, entry.localPath)})` : \"\";\n skipped.push(`${entry.key} local${path}`);\n } else if (entry.source === \"skipped\") {\n skipped.push(`${entry.key} no URL resolved`);\n } else if (entry.source === \"failed\") {\n const detail = entry.error ? `: ${entry.error}` : \"\";\n failed.push(`${entry.key}${detail}`);\n }\n }\n\n return {\n status: \"success\" as const,\n generated,\n fetched,\n skipped,\n failed,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n generated: [],\n fetched: [],\n skipped: [],\n failed: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n typecheck: builder.typecheck.handler(async ({ input }) => {\n try {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const projectDir = resolve(dirname(configPath));\n const refreshed = await openResolution({ cwd: projectDir });\n if (!refreshed?.config || !refreshed.runtime) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: \"Failed to load the authored config\",\n };\n }\n\n const runtime = refreshed.runtime;\n const resolvedConfig = refreshed.config;\n\n await generateCodeArtifacts(projectDir, resolvedConfig, {\n runtimeConfig: runtime,\n });\n type AppTarget = { source?: string; localPath?: string };\n const workspaceEntries: Array<{\n key: string;\n label: string;\n dir: string;\n }> = [];\n const skipped: Array<{ key: string; label: string }> = [];\n\n const appTargets: Array<{\n key: string;\n label: string;\n target: AppTarget | undefined;\n }> = [\n { key: \"host\", label: \"host\", target: runtime.host },\n { key: \"ui\", label: \"ui\", target: runtime.ui },\n { key: \"api\", label: \"api\", target: runtime.api },\n ];\n if (runtime.auth) {\n appTargets.push({ key: \"auth\", label: \"auth\", target: runtime.auth });\n }\n\n for (const entry of appTargets) {\n if (\n entry.target?.source === \"local\" &&\n entry.target.localPath &&\n existsSync(join(entry.target.localPath, \"tsconfig.json\"))\n ) {\n workspaceEntries.push({\n key: entry.key,\n label: entry.label,\n dir: entry.target.localPath,\n });\n } else {\n skipped.push({ key: entry.key, label: entry.label });\n }\n }\n\n for (const [key, plugin] of Object.entries(runtime.plugins ?? {})) {\n const label = `plugins/${key}`;\n if (\n plugin.source === \"local\" &&\n plugin.localPath &&\n existsSync(join(plugin.localPath, \"tsconfig.json\"))\n ) {\n workspaceEntries.push({ key, label, dir: plugin.localPath });\n } else {\n skipped.push({ key, label });\n }\n }\n\n const selected = selectWorkspaceTargets(input.packages, resolvedConfig);\n const targets =\n input.packages === \"all\"\n ? workspaceEntries\n : workspaceEntries.filter((entry) => selected.includes(entry.key));\n const skippedEntries =\n input.packages === \"all\"\n ? skipped\n : skipped.filter((entry) => selected.includes(entry.key));\n\n const checked: string[] = [];\n const results: Array<{\n workspace: string;\n passed: boolean;\n error?: string;\n }> = [];\n\n for (const entry of targets) {\n const packageJsonPath = join(entry.dir, \"package.json\");\n let args: string[] = [\"exec\", \"tsc\", \"--noEmit\"];\n if (existsSync(packageJsonPath)) {\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n scripts?: Record<string, string>;\n };\n if (pkg.scripts?.typecheck) {\n args = [\"run\", \"typecheck\"];\n }\n } catch {}\n }\n\n console.log(`\\n ${colors.dim(\"Checking\")} ${colors.cyan(entry.label)}`);\n const child = spawnSync(\"pnpm\", args, {\n cwd: entry.dir,\n stdio: \"inherit\",\n });\n const passed = child.status === 0;\n checked.push(entry.label);\n results.push({\n workspace: entry.label,\n passed,\n error: passed ? undefined : `typecheck failed (exit code ${child.status ?? \"n/a\"})`,\n });\n }\n\n return {\n status: \"success\" as const,\n checked,\n skipped: skippedEntries.map((entry) => entry.label),\n results,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n checked: [],\n skipped: [],\n results: [],\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n mfCheck: builder.mfCheck.handler(async ({ input }) => {\n let authored: BosConfig | null = null;\n try {\n authored = (await readAuthoredConfigInput()) as BosConfig | null;\n } catch (e) {\n return {\n status: \"fail\" as const,\n hostVersion: null,\n hostReachable: false,\n hostReason: e instanceof Error ? e.message : String(e),\n remotes: [],\n };\n }\n if (!authored) {\n // No local authored config (the universal image carries none): fall\n // back to the registry identity — the same source `bos start` boots\n // from in a runtime container.\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 hostVersion: null,\n hostReachable: false,\n hostReason: MISSING_CONFIG_MESSAGE,\n remotes: [],\n };\n }\n try {\n authored = await resolvePublishedConfig(account, gateway);\n } catch (e) {\n return {\n status: \"fail\" as const,\n hostVersion: null,\n hostReachable: false,\n hostReason: e instanceof Error ? e.message : String(e),\n remotes: [],\n };\n }\n if (!authored) {\n return {\n status: \"fail\" as const,\n hostVersion: null,\n hostReachable: false,\n hostReason: `No config found at bos://${account}/${gateway} — verify BOS_ACCOUNT/BOS_GATEWAY and that the config has been published.`,\n remotes: [],\n };\n }\n }\n\n const report = await checkFederationCompat(authored, {\n timeoutMs: input.timeoutMs,\n });\n return {\n status: report.ok ? (\"ok\" as const) : (\"fail\" as const),\n hostVersion: report.hostVersion,\n hostReachable: report.hostReachable,\n hostReason: report.hostReason,\n remotes: report.remotes,\n };\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;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