everything-dev 2.0.0-rc.1 → 2.0.0-rc.5
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/auth-login.cjs +1 -1
- package/dist/auth-login.mjs +1 -1
- package/dist/build.cjs +2 -2
- package/dist/build.mjs +2 -2
- package/dist/bundle-fs-resolve.cjs +9 -17
- package/dist/bundle-fs-resolve.cjs.map +1 -1
- package/dist/bundle-fs-resolve.d.cts +6 -0
- package/dist/bundle-fs-resolve.d.mts +6 -0
- package/dist/bundle-fs-resolve.mjs +9 -17
- package/dist/bundle-fs-resolve.mjs.map +1 -1
- package/dist/bundle-path.cjs +48 -0
- package/dist/bundle-path.cjs.map +1 -0
- package/dist/bundle-path.mjs +45 -0
- package/dist/bundle-path.mjs.map +1 -0
- 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/init.cjs +4 -6
- 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 +4 -6
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/status.cjs +69 -3
- package/dist/cli/status.cjs.map +1 -1
- package/dist/cli/status.mjs +67 -4
- package/dist/cli/status.mjs.map +1 -1
- package/dist/cli/sync.cjs +1 -2
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +1 -2
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli/upgrade.cjs +2 -2
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +2 -2
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/cli.cjs +5 -7
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +5 -7
- package/dist/cli.mjs.map +1 -1
- package/dist/commands/deploy.cjs +26 -18
- package/dist/commands/deploy.cjs.map +1 -1
- package/dist/commands/deploy.mjs +26 -18
- package/dist/commands/deploy.mjs.map +1 -1
- package/dist/commands/init.cjs +1 -1
- package/dist/commands/init.cjs.map +1 -1
- package/dist/commands/init.mjs +1 -1
- package/dist/commands/init.mjs.map +1 -1
- package/dist/commands/plugins.cjs +2 -2
- package/dist/commands/plugins.cjs.map +1 -1
- package/dist/commands/plugins.mjs +2 -2
- package/dist/commands/plugins.mjs.map +1 -1
- package/dist/commands/upgrade.cjs +31 -8
- package/dist/commands/upgrade.cjs.map +1 -1
- package/dist/commands/upgrade.mjs +31 -8
- package/dist/commands/upgrade.mjs.map +1 -1
- package/dist/components/dev-render.cjs +1 -1
- package/dist/components/dev-render.mjs +1 -1
- package/dist/config.cjs +3 -3
- package/dist/config.cjs.map +1 -1
- package/dist/config.mjs +3 -3
- package/dist/config.mjs.map +1 -1
- package/dist/contract.cjs +2 -0
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +3 -0
- package/dist/contract.d.mts +3 -0
- package/dist/contract.meta.cjs +2 -1
- package/dist/contract.meta.cjs.map +1 -1
- package/dist/contract.meta.d.cts +4 -1
- package/dist/contract.meta.d.mts +4 -1
- package/dist/contract.meta.mjs +2 -1
- package/dist/contract.meta.mjs.map +1 -1
- package/dist/contract.mjs +2 -0
- package/dist/contract.mjs.map +1 -1
- package/dist/db/driver.cjs +22 -2
- package/dist/db/driver.cjs.map +1 -1
- package/dist/db/driver.d.cts +13 -2
- package/dist/db/driver.d.mts +13 -2
- package/dist/db/driver.mjs +22 -3
- package/dist/db/driver.mjs.map +1 -1
- package/dist/db/index.cjs +1 -0
- package/dist/db/index.d.cts +2 -2
- package/dist/db/index.d.mts +2 -2
- package/dist/db/index.mjs +2 -2
- package/dist/deploy-diff.cjs +1 -1
- package/dist/deploy-diff.cjs.map +1 -1
- package/dist/deploy-diff.mjs +1 -1
- package/dist/deploy-diff.mjs.map +1 -1
- package/dist/dev-program.cjs +11 -2
- package/dist/dev-program.cjs.map +1 -1
- package/dist/dev-program.mjs +11 -3
- package/dist/dev-program.mjs.map +1 -1
- package/dist/image-deploy.cjs +103 -31
- package/dist/image-deploy.cjs.map +1 -1
- package/dist/image-deploy.mjs +103 -33
- package/dist/image-deploy.mjs.map +1 -1
- package/dist/internal/manifest-normalizer.cjs.map +1 -1
- package/dist/internal/manifest-normalizer.mjs.map +1 -1
- package/dist/plugin.d.cts +902 -1
- package/dist/plugin.d.mts +902 -1
- package/dist/publish.cjs +51 -2
- package/dist/publish.cjs.map +1 -1
- package/dist/publish.mjs +51 -4
- package/dist/publish.mjs.map +1 -1
- package/dist/resolution/session.cjs.map +1 -1
- package/dist/resolution/session.d.cts +5 -5
- package/dist/resolution/session.d.mts +5 -5
- package/dist/resolution/session.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/types.d.cts +31 -1
- package/dist/types.d.mts +31 -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-guards.d.cts +78 -2
- package/dist/ui/auth-guards.d.mts +78 -2
- package/dist/ui/auth.cjs.map +1 -1
- package/dist/ui/auth.d.cts +4133 -7
- package/dist/ui/auth.d.mts +4133 -7
- package/dist/ui/auth.mjs.map +1 -1
- package/dist/ui/hydrate.cjs +2 -2
- package/dist/ui/hydrate.cjs.map +1 -1
- package/dist/ui/hydrate.mjs +2 -2
- package/dist/ui/hydrate.mjs.map +1 -1
- package/dist/utils/theme.cjs +2 -2
- package/dist/utils/theme.cjs.map +1 -1
- package/dist/utils/theme.mjs +2 -2
- package/dist/utils/theme.mjs.map +1 -1
- package/dist/version-manifest-resolve.cjs +55 -10
- package/dist/version-manifest-resolve.cjs.map +1 -1
- package/dist/version-manifest-resolve.mjs +53 -10
- package/dist/version-manifest-resolve.mjs.map +1 -1
- package/dist/workspace.cjs +26 -13
- package/dist/workspace.cjs.map +1 -1
- package/dist/workspace.mjs +26 -14
- package/dist/workspace.mjs.map +1 -1
- package/package.json +12 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["Context","BosDepsTag","MISSING_CONFIG_MESSAGE","saveBosConfig","generateCodeArtifacts","existsSync","join","publishToFastKv","openResolution","fetchRemotePluginManifest","basename","getPluginRef"],"sources":["../../src/commands/plugins.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport { Context } from \"effect\";\nimport { getPluginRef } from \"../build\";\nimport { generateCodeArtifacts } from \"../code-artifacts\";\nimport { MISSING_CONFIG_MESSAGE } from \"../config\";\nimport type { PluginListResult } from \"../contract\";\nimport { fetchRemotePluginManifest } from \"../fastkv\";\nimport { publishToFastKv } from \"../publish\";\nimport { openResolution } from \"../resolution/session\";\nimport type { BosConfig } from \"../types\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { type BosBuilder, BosDepsTag } from \"./shared\";\n\nexport function registerPlugins(builder: BosBuilder) {\n return {\n pluginAdd: builder.pluginAdd.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 key: \"\",\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const isBosRef = input.source.startsWith(\"bos://\");\n const isLocal = input.source.startsWith(\"local:\");\n const key = sanitizePluginKey(\n input.as ??\n (isBosRef ? (input.source.split(\"/\").pop() ?? \"plugin\") : defaultPluginKey(input.source)),\n );\n const existing = session.config.plugins?.[key];\n const existingEntry = existing && typeof existing === \"object\" ? existing : {};\n // Adding a source is a switch, not an additive patch: a remote URL (or\n // bos:// ref) replaces a conflicting local development ref. Dual-mode\n // (local in dev, production URL in prod) remains expressible by\n // hand-editing the authored config.\n const applyEntryDelta = (base: Record<string, unknown>): Record<string, unknown> => {\n if (isBosRef) {\n const { development: _dropped, ...rest } = base;\n return { ...rest, extends: input.source };\n }\n if (isLocal) {\n const { extends: _dropped, ...rest } = base;\n return { ...rest, development: input.source };\n }\n const { development: _dropped, ...rest } = base;\n return { ...rest, production: input.production ?? input.source };\n };\n const nextPlugins = { ...session.config.plugins };\n nextPlugins[key] = applyEntryDelta(existingEntry);\n\n const nextConfig: BosConfig = {\n ...session.config,\n plugins: nextPlugins,\n };\n\n const authored = session.rawConfig;\n if (authored) {\n // Authoring-surface save: the authored leaf input + delta, never the\n // resolved config (which would bake inherited values into the file).\n const authoredExisting = authored.plugins?.[key];\n const authoredBase: Record<string, unknown> =\n typeof authoredExisting === \"string\"\n ? { extends: authoredExisting }\n : authoredExisting && typeof authoredExisting === \"object\"\n ? (authoredExisting as Record<string, unknown>)\n : {};\n await saveBosConfig(session.root, {\n ...authored,\n plugins: {\n ...(authored.plugins ?? {}),\n [key]: applyEntryDelta(authoredBase),\n },\n });\n } else {\n await saveBosConfig(session.root, nextConfig);\n }\n await generateCodeArtifacts(session.root, nextConfig);\n\n const stored = nextConfig.plugins?.[key];\n const storedObj = stored && typeof stored === \"object\" ? stored : {};\n\n return {\n status: \"added\" as const,\n key,\n development: storedObj.development,\n production: storedObj.production,\n integrity: storedObj.integrity,\n version: storedObj.version,\n };\n }),\n\n pluginRemove: builder.pluginRemove.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 key: input.key,\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n if (!session.config.plugins?.[input.key]) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const nextPlugins = { ...session.config.plugins };\n delete nextPlugins[input.key];\n const nextConfig: BosConfig = {\n ...session.config,\n plugins: Object.keys(nextPlugins).length > 0 ? nextPlugins : undefined,\n };\n\n const authored = session.rawConfig;\n if (authored) {\n const authoredPlugins: Record<string, unknown> = { ...(authored.plugins ?? {}) };\n if (authoredPlugins[input.key] === undefined) {\n // Inherited from the parent runtime. JSON-form children can express\n // removal with a null sentinel (dropped by the extends merge); the\n // TS descriptor schema cannot, so only those error out.\n if (existsSync(join(session.root, \"bos.app.ts\"))) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `'${input.key}' is inherited from the parent runtime — remove it in the parent config or override it there (the authored descriptor cannot express removal)`,\n };\n }\n authoredPlugins[input.key] = null;\n } else {\n delete authoredPlugins[input.key];\n }\n await saveBosConfig(session.root, {\n ...authored,\n plugins: Object.keys(authoredPlugins).length > 0 ? authoredPlugins : undefined,\n });\n } else {\n await saveBosConfig(session.root, nextConfig);\n }\n await generateCodeArtifacts(session.root, nextConfig);\n\n return {\n status: \"removed\" as const,\n key: input.key,\n };\n }),\n\n pluginList: builder.pluginList.handler(async ({ context }) => {\n const deps = Context.get(context[\"effect/context\"], BosDepsTag);\n const plugins: PluginListResult[\"plugins\"] = listPluginAttachments(\n deps.session?.config ?? null,\n );\n return {\n status: \"listed\" as const,\n plugins,\n };\n }),\n\n pluginPublish: builder.pluginPublish.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 key: input.key,\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const attachment = session.config?.plugins?.[input.key];\n if (!attachment) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const localPath = pluginLocalPath(session.root, attachment);\n if (!localPath) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' does not have a local development path`,\n };\n }\n\n const result = await publishToFastKv({\n bosConfig: session.config,\n runtimeConfig: session.runtime,\n configDir: session.root,\n env: \"production\",\n build: true,\n dryRun: false,\n verbose: false,\n packages: input.key,\n });\n if (result.status === \"error\") {\n return {\n status: \"error\" as const,\n key: input.key,\n error: result.error,\n };\n }\n\n const nextSession = (await openResolution({ cwd: session.root })) ?? session;\n const production = (\n nextSession.config?.plugins?.[input.key] as\n | {\n production?: string;\n }\n | undefined\n )?.production;\n\n const manifest = production ? await fetchRemotePluginManifest(production) : null;\n if (production && nextSession.config) {\n await generateCodeArtifacts(session.root, nextSession.config);\n }\n\n return {\n status: \"published\" as const,\n key: input.key,\n path: localPath,\n production,\n fingerprint: result.fingerprint,\n version: manifest?.plugin.version,\n };\n }),\n };\n}\n\ntype PluginAttachmentConfig = NonNullable<BosConfig[\"plugins\"]>[string];\n\nfunction sanitizePluginKey(value: string): string {\n return value\n .replace(/[^A-Za-z0-9/_-]/g, \"-\")\n .replace(/\\/+/g, \"/\")\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => segment.replace(/[^A-Za-z0-9_-]/g, \"-\"))\n .join(\"/\")\n .replace(/^\\/+|\\/+$/g, \"\");\n}\n\nfunction defaultPluginKey(source: string): string {\n const normalized = source.replace(/^local:/, \"\").replace(/\\/$/, \"\");\n if (source.startsWith(\"local:\")) {\n return sanitizePluginKey(basename(normalized)) || \"plugin\";\n }\n\n try {\n const url = new URL(source);\n return sanitizePluginKey(basename(url.pathname) || url.hostname) || \"plugin\";\n } catch {\n return sanitizePluginKey(source) || \"plugin\";\n }\n}\n\nfunction pluginLocalPath(configDir: string, attachment: PluginAttachmentConfig): string | null {\n const ref = getPluginRef(attachment);\n const source = ref?.development ?? ref?.production;\n if (!source?.startsWith(\"local:\")) {\n return null;\n }\n\n return join(configDir, source.slice(\"local:\".length));\n}\n\nfunction listPluginAttachments(config: BosConfig | null) {\n return (Object.entries(config?.plugins ?? {}) as Array<[string, PluginAttachmentConfig]>)\n .map(([key, attachment]) => {\n const ref = getPluginRef(attachment);\n return {\n key,\n development: ref?.development,\n production: ref?.production,\n localPath: ref?.development?.startsWith(\"local:\")\n ? ref.development.slice(\"local:\".length)\n : undefined,\n source: ref?.development?.startsWith(\"local:\") ? (\"local\" as const) : (\"remote\" as const),\n integrity: ref?.integrity,\n version: ref?.version,\n name: ref?.name,\n };\n })\n .sort((a, b) => a.key.localeCompare(b.key));\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,gBAAgB,SAAqB;CACnD,OAAO;EACL,WAAW,QAAQ,UAAU,QAAQ,OAAO,EAAE,OAAO,cAAc;GAEjE,MAAM,UADOA,eAAQ,IAAI,QAAQ,mBAAmBC,yBACjC,CAAC,CAAC;GACrB,IAAI,CAAC,SAAS,QACZ,OAAO;IACL,QAAQ;IACR,KAAK;IACL,OAAOC;GACT;GAGF,MAAM,WAAW,MAAM,OAAO,WAAW,QAAQ;GACjD,MAAM,UAAU,MAAM,OAAO,WAAW,QAAQ;GAChD,MAAM,MAAM,kBACV,MAAM,OACH,WAAY,MAAM,OAAO,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,WAAY,iBAAiB,MAAM,MAAM,EAC3F;GACA,MAAM,WAAW,QAAQ,OAAO,UAAU;GAC1C,MAAM,gBAAgB,YAAY,OAAO,aAAa,WAAW,WAAW,CAAC;GAK7E,MAAM,mBAAmB,SAA2D;IAClF,IAAI,UAAU;KACZ,MAAM,EAAE,aAAa,UAAU,GAAG,SAAS;KAC3C,OAAO;MAAE,GAAG;MAAM,SAAS,MAAM;KAAO;IAC1C;IACA,IAAI,SAAS;KACX,MAAM,EAAE,SAAS,UAAU,GAAG,SAAS;KACvC,OAAO;MAAE,GAAG;MAAM,aAAa,MAAM;KAAO;IAC9C;IACA,MAAM,EAAE,aAAa,UAAU,GAAG,SAAS;IAC3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;EAC1B,OAAO,sBAAkBA,oBAAS,IAAI,QAAQ,KAAK,IAAI,QAAQ,KAAK;CACtE,QAAQ;EACN,OAAO,kBAAkB,MAAM,KAAK;CACtC;AACF;AAEA,SAAS,gBAAgB,WAAmB,YAAmD;CAC7F,MAAM,MAAMC,2BAAa,UAAU;CACnC,MAAM,SAAS,KAAK,eAAe,KAAK;CACxC,IAAI,CAAC,QAAQ,WAAW,QAAQ,GAC9B,OAAO;CAGT,WAAOL,gBAAK,WAAW,OAAO,MAAM,CAAe,CAAC;AACtD;AAEA,SAAS,sBAAsB,QAA0B;CACvD,OAAQ,OAAO,QAAQ,QAAQ,WAAW,CAAC,CAAC,CAAC,CAC1C,KAAK,CAAC,KAAK,gBAAgB;EAC1B,MAAM,MAAMK,2BAAa,UAAU;EACnC,OAAO;GACL;GACA,aAAa,KAAK;GAClB,YAAY,KAAK;GACjB,WAAW,KAAK,aAAa,WAAW,QAAQ,IAC5C,IAAI,YAAY,MAAM,CAAe,IACrC;GACJ,QAAQ,KAAK,aAAa,WAAW,QAAQ,IAAK,UAAqB;GACvE,WAAW,KAAK;GAChB,SAAS,KAAK;GACd,MAAM,KAAK;EACb;CACF,CAAC,CAAC,CACD,MAAM,GAAG,MAAM,EAAE,IAAI,cAAc,EAAE,GAAG,CAAC;AAC9C"}
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["Context","BosDepsTag","MISSING_CONFIG_MESSAGE","saveBosConfig","generateCodeArtifacts","existsSync","join","publishToFastKv","openResolution","fetchRemotePluginManifest","basename","getPluginRef"],"sources":["../../src/commands/plugins.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport { Context } from \"effect\";\nimport { getPluginRef } from \"../build\";\nimport { generateCodeArtifacts } from \"../code-artifacts\";\nimport { MISSING_CONFIG_MESSAGE } from \"../config\";\nimport type { PluginListResult } from \"../contract\";\nimport { fetchRemotePluginManifest } from \"../fastkv\";\nimport { publishToFastKv } from \"../publish\";\nimport { openResolution } from \"../resolution/session\";\nimport type { BosConfig } from \"../types\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { type BosBuilder, BosDepsTag } from \"./shared\";\n\nexport function registerPlugins(builder: BosBuilder) {\n return {\n pluginAdd: builder.pluginAdd.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 key: \"\",\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const isBosRef = input.source.startsWith(\"bos://\");\n const isLocal = input.source.startsWith(\"local:\");\n const key = sanitizePluginKey(\n input.as ??\n (isBosRef ? (input.source.split(\"/\").pop() ?? \"plugin\") : defaultPluginKey(input.source)),\n );\n const existing = session.config.plugins?.[key];\n const existingEntry = existing && typeof existing === \"object\" ? existing : {};\n // Adding a source is a switch, not an additive patch: a remote URL (or\n // bos:// ref) replaces a conflicting local development ref. Dual-mode\n // (local in dev, production URL in prod) remains expressible by\n // hand-editing the authored config.\n const applyEntryDelta = (base: Record<string, unknown>): Record<string, unknown> => {\n if (isBosRef) {\n const { development: _dropped, ...rest } = base;\n return { ...rest, extends: input.source };\n }\n if (isLocal) {\n const { extends: _dropped, ...rest } = base;\n return { ...rest, development: input.source };\n }\n const { development: _dropped, ...rest } = base;\n return { ...rest, production: input.production ?? input.source };\n };\n const nextPlugins = { ...session.config.plugins };\n nextPlugins[key] = applyEntryDelta(existingEntry);\n\n const nextConfig: BosConfig = {\n ...session.config,\n plugins: nextPlugins,\n };\n\n const authored = session.rawConfig;\n if (authored) {\n // Authoring-surface save: the authored leaf input + delta, never the\n // resolved config (which would bake inherited values into the file).\n const authoredExisting = authored.plugins?.[key];\n const authoredBase: Record<string, unknown> =\n typeof authoredExisting === \"string\"\n ? { extends: authoredExisting }\n : authoredExisting && typeof authoredExisting === \"object\"\n ? (authoredExisting as Record<string, unknown>)\n : {};\n await saveBosConfig(session.root, {\n ...authored,\n plugins: {\n ...authored.plugins,\n [key]: applyEntryDelta(authoredBase),\n },\n });\n } else {\n await saveBosConfig(session.root, nextConfig);\n }\n await generateCodeArtifacts(session.root, nextConfig);\n\n const stored = nextConfig.plugins?.[key];\n const storedObj = stored && typeof stored === \"object\" ? stored : {};\n\n return {\n status: \"added\" as const,\n key,\n development: storedObj.development,\n production: storedObj.production,\n integrity: storedObj.integrity,\n version: storedObj.version,\n };\n }),\n\n pluginRemove: builder.pluginRemove.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 key: input.key,\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n if (!session.config.plugins?.[input.key]) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const nextPlugins = { ...session.config.plugins };\n delete nextPlugins[input.key];\n const nextConfig: BosConfig = {\n ...session.config,\n plugins: Object.keys(nextPlugins).length > 0 ? nextPlugins : undefined,\n };\n\n const authored = session.rawConfig;\n if (authored) {\n const authoredPlugins: Record<string, unknown> = { ...authored.plugins };\n if (authoredPlugins[input.key] === undefined) {\n // Inherited from the parent runtime. JSON-form children can express\n // removal with a null sentinel (dropped by the extends merge); the\n // TS descriptor schema cannot, so only those error out.\n if (existsSync(join(session.root, \"bos.app.ts\"))) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `'${input.key}' is inherited from the parent runtime — remove it in the parent config or override it there (the authored descriptor cannot express removal)`,\n };\n }\n authoredPlugins[input.key] = null;\n } else {\n delete authoredPlugins[input.key];\n }\n await saveBosConfig(session.root, {\n ...authored,\n plugins: Object.keys(authoredPlugins).length > 0 ? authoredPlugins : undefined,\n });\n } else {\n await saveBosConfig(session.root, nextConfig);\n }\n await generateCodeArtifacts(session.root, nextConfig);\n\n return {\n status: \"removed\" as const,\n key: input.key,\n };\n }),\n\n pluginList: builder.pluginList.handler(async ({ context }) => {\n const deps = Context.get(context[\"effect/context\"], BosDepsTag);\n const plugins: PluginListResult[\"plugins\"] = listPluginAttachments(\n deps.session?.config ?? null,\n );\n return {\n status: \"listed\" as const,\n plugins,\n };\n }),\n\n pluginPublish: builder.pluginPublish.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 key: input.key,\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const attachment = session.config?.plugins?.[input.key];\n if (!attachment) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const localPath = pluginLocalPath(session.root, attachment);\n if (!localPath) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' does not have a local development path`,\n };\n }\n\n const result = await publishToFastKv({\n bosConfig: session.config,\n runtimeConfig: session.runtime,\n configDir: session.root,\n env: \"production\",\n build: true,\n dryRun: false,\n verbose: false,\n packages: input.key,\n });\n if (result.status === \"error\") {\n return {\n status: \"error\" as const,\n key: input.key,\n error: result.error,\n };\n }\n\n const nextSession = (await openResolution({ cwd: session.root })) ?? session;\n const production = (\n nextSession.config?.plugins?.[input.key] as\n | {\n production?: string;\n }\n | undefined\n )?.production;\n\n const manifest = production ? await fetchRemotePluginManifest(production) : null;\n if (production && nextSession.config) {\n await generateCodeArtifacts(session.root, nextSession.config);\n }\n\n return {\n status: \"published\" as const,\n key: input.key,\n path: localPath,\n production,\n fingerprint: result.fingerprint,\n version: manifest?.plugin.version,\n };\n }),\n };\n}\n\ntype PluginAttachmentConfig = NonNullable<BosConfig[\"plugins\"]>[string];\n\nfunction sanitizePluginKey(value: string): string {\n return value\n .replace(/[^A-Za-z0-9/_-]/g, \"-\")\n .replace(/\\/+/g, \"/\")\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => segment.replace(/[^A-Za-z0-9_-]/g, \"-\"))\n .join(\"/\")\n .replace(/^\\/+|\\/+$/g, \"\");\n}\n\nfunction defaultPluginKey(source: string): string {\n const normalized = source.replace(/^local:/, \"\").replace(/\\/$/, \"\");\n if (source.startsWith(\"local:\")) {\n return sanitizePluginKey(basename(normalized)) || \"plugin\";\n }\n\n try {\n const url = new URL(source);\n return sanitizePluginKey(basename(url.pathname) || url.hostname) || \"plugin\";\n } catch {\n return sanitizePluginKey(source) || \"plugin\";\n }\n}\n\nfunction pluginLocalPath(configDir: string, attachment: PluginAttachmentConfig): string | null {\n const ref = getPluginRef(attachment);\n const source = ref?.development ?? ref?.production;\n if (!source?.startsWith(\"local:\")) {\n return null;\n }\n\n return join(configDir, source.slice(\"local:\".length));\n}\n\nfunction listPluginAttachments(config: BosConfig | null) {\n return (Object.entries(config?.plugins ?? {}) as Array<[string, PluginAttachmentConfig]>)\n .map(([key, attachment]) => {\n const ref = getPluginRef(attachment);\n return {\n key,\n development: ref?.development,\n production: ref?.production,\n localPath: ref?.development?.startsWith(\"local:\")\n ? ref.development.slice(\"local:\".length)\n : undefined,\n source: ref?.development?.startsWith(\"local:\") ? (\"local\" as const) : (\"remote\" as const),\n integrity: ref?.integrity,\n version: ref?.version,\n name: ref?.name,\n };\n })\n .sort((a, b) => a.key.localeCompare(b.key));\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,gBAAgB,SAAqB;CACnD,OAAO;EACL,WAAW,QAAQ,UAAU,QAAQ,OAAO,EAAE,OAAO,cAAc;GAEjE,MAAM,UADOA,eAAQ,IAAI,QAAQ,mBAAmBC,yBACjC,CAAC,CAAC;GACrB,IAAI,CAAC,SAAS,QACZ,OAAO;IACL,QAAQ;IACR,KAAK;IACL,OAAOC;GACT;GAGF,MAAM,WAAW,MAAM,OAAO,WAAW,QAAQ;GACjD,MAAM,UAAU,MAAM,OAAO,WAAW,QAAQ;GAChD,MAAM,MAAM,kBACV,MAAM,OACH,WAAY,MAAM,OAAO,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,WAAY,iBAAiB,MAAM,MAAM,EAC3F;GACA,MAAM,WAAW,QAAQ,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
|
|
60
60
|
...authored,
|
|
61
61
|
plugins: {
|
|
62
|
-
...authored.plugins
|
|
62
|
+
...authored.plugins,
|
|
63
63
|
[key]: applyEntryDelta(authoredBase)
|
|
64
64
|
}
|
|
65
65
|
});
|
|
@@ -96,7 +96,7 @@ function registerPlugins(builder) {
|
|
|
96
96
|
};
|
|
97
97
|
const authored = session.rawConfig;
|
|
98
98
|
if (authored) {
|
|
99
|
-
const authoredPlugins = { ...authored.plugins
|
|
99
|
+
const authoredPlugins = { ...authored.plugins };
|
|
100
100
|
if (authoredPlugins[input.key] === void 0) {
|
|
101
101
|
if (existsSync(join(session.root, "bos.app.ts"))) return {
|
|
102
102
|
status: "error",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/commands/plugins.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport { Context } from \"effect\";\nimport { getPluginRef } from \"../build\";\nimport { generateCodeArtifacts } from \"../code-artifacts\";\nimport { MISSING_CONFIG_MESSAGE } from \"../config\";\nimport type { PluginListResult } from \"../contract\";\nimport { fetchRemotePluginManifest } from \"../fastkv\";\nimport { publishToFastKv } from \"../publish\";\nimport { openResolution } from \"../resolution/session\";\nimport type { BosConfig } from \"../types\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { type BosBuilder, BosDepsTag } from \"./shared\";\n\nexport function registerPlugins(builder: BosBuilder) {\n return {\n pluginAdd: builder.pluginAdd.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 key: \"\",\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const isBosRef = input.source.startsWith(\"bos://\");\n const isLocal = input.source.startsWith(\"local:\");\n const key = sanitizePluginKey(\n input.as ??\n (isBosRef ? (input.source.split(\"/\").pop() ?? \"plugin\") : defaultPluginKey(input.source)),\n );\n const existing = session.config.plugins?.[key];\n const existingEntry = existing && typeof existing === \"object\" ? existing : {};\n // Adding a source is a switch, not an additive patch: a remote URL (or\n // bos:// ref) replaces a conflicting local development ref. Dual-mode\n // (local in dev, production URL in prod) remains expressible by\n // hand-editing the authored config.\n const applyEntryDelta = (base: Record<string, unknown>): Record<string, unknown> => {\n if (isBosRef) {\n const { development: _dropped, ...rest } = base;\n return { ...rest, extends: input.source };\n }\n if (isLocal) {\n const { extends: _dropped, ...rest } = base;\n return { ...rest, development: input.source };\n }\n const { development: _dropped, ...rest } = base;\n return { ...rest, production: input.production ?? input.source };\n };\n const nextPlugins = { ...session.config.plugins };\n nextPlugins[key] = applyEntryDelta(existingEntry);\n\n const nextConfig: BosConfig = {\n ...session.config,\n plugins: nextPlugins,\n };\n\n const authored = session.rawConfig;\n if (authored) {\n // Authoring-surface save: the authored leaf input + delta, never the\n // resolved config (which would bake inherited values into the file).\n const authoredExisting = authored.plugins?.[key];\n const authoredBase: Record<string, unknown> =\n typeof authoredExisting === \"string\"\n ? { extends: authoredExisting }\n : authoredExisting && typeof authoredExisting === \"object\"\n ? (authoredExisting as Record<string, unknown>)\n : {};\n await saveBosConfig(session.root, {\n ...authored,\n plugins: {\n ...(authored.plugins ?? {}),\n [key]: applyEntryDelta(authoredBase),\n },\n });\n } else {\n await saveBosConfig(session.root, nextConfig);\n }\n await generateCodeArtifacts(session.root, nextConfig);\n\n const stored = nextConfig.plugins?.[key];\n const storedObj = stored && typeof stored === \"object\" ? stored : {};\n\n return {\n status: \"added\" as const,\n key,\n development: storedObj.development,\n production: storedObj.production,\n integrity: storedObj.integrity,\n version: storedObj.version,\n };\n }),\n\n pluginRemove: builder.pluginRemove.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 key: input.key,\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n if (!session.config.plugins?.[input.key]) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const nextPlugins = { ...session.config.plugins };\n delete nextPlugins[input.key];\n const nextConfig: BosConfig = {\n ...session.config,\n plugins: Object.keys(nextPlugins).length > 0 ? nextPlugins : undefined,\n };\n\n const authored = session.rawConfig;\n if (authored) {\n const authoredPlugins: Record<string, unknown> = { ...(authored.plugins ?? {}) };\n if (authoredPlugins[input.key] === undefined) {\n // Inherited from the parent runtime. JSON-form children can express\n // removal with a null sentinel (dropped by the extends merge); the\n // TS descriptor schema cannot, so only those error out.\n if (existsSync(join(session.root, \"bos.app.ts\"))) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `'${input.key}' is inherited from the parent runtime — remove it in the parent config or override it there (the authored descriptor cannot express removal)`,\n };\n }\n authoredPlugins[input.key] = null;\n } else {\n delete authoredPlugins[input.key];\n }\n await saveBosConfig(session.root, {\n ...authored,\n plugins: Object.keys(authoredPlugins).length > 0 ? authoredPlugins : undefined,\n });\n } else {\n await saveBosConfig(session.root, nextConfig);\n }\n await generateCodeArtifacts(session.root, nextConfig);\n\n return {\n status: \"removed\" as const,\n key: input.key,\n };\n }),\n\n pluginList: builder.pluginList.handler(async ({ context }) => {\n const deps = Context.get(context[\"effect/context\"], BosDepsTag);\n const plugins: PluginListResult[\"plugins\"] = listPluginAttachments(\n deps.session?.config ?? null,\n );\n return {\n status: \"listed\" as const,\n plugins,\n };\n }),\n\n pluginPublish: builder.pluginPublish.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 key: input.key,\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const attachment = session.config?.plugins?.[input.key];\n if (!attachment) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const localPath = pluginLocalPath(session.root, attachment);\n if (!localPath) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' does not have a local development path`,\n };\n }\n\n const result = await publishToFastKv({\n bosConfig: session.config,\n runtimeConfig: session.runtime,\n configDir: session.root,\n env: \"production\",\n build: true,\n dryRun: false,\n verbose: false,\n packages: input.key,\n });\n if (result.status === \"error\") {\n return {\n status: \"error\" as const,\n key: input.key,\n error: result.error,\n };\n }\n\n const nextSession = (await openResolution({ cwd: session.root })) ?? session;\n const production = (\n nextSession.config?.plugins?.[input.key] as\n | {\n production?: string;\n }\n | undefined\n )?.production;\n\n const manifest = production ? await fetchRemotePluginManifest(production) : null;\n if (production && nextSession.config) {\n await generateCodeArtifacts(session.root, nextSession.config);\n }\n\n return {\n status: \"published\" as const,\n key: input.key,\n path: localPath,\n production,\n fingerprint: result.fingerprint,\n version: manifest?.plugin.version,\n };\n }),\n };\n}\n\ntype PluginAttachmentConfig = NonNullable<BosConfig[\"plugins\"]>[string];\n\nfunction sanitizePluginKey(value: string): string {\n return value\n .replace(/[^A-Za-z0-9/_-]/g, \"-\")\n .replace(/\\/+/g, \"/\")\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => segment.replace(/[^A-Za-z0-9_-]/g, \"-\"))\n .join(\"/\")\n .replace(/^\\/+|\\/+$/g, \"\");\n}\n\nfunction defaultPluginKey(source: string): string {\n const normalized = source.replace(/^local:/, \"\").replace(/\\/$/, \"\");\n if (source.startsWith(\"local:\")) {\n return sanitizePluginKey(basename(normalized)) || \"plugin\";\n }\n\n try {\n const url = new URL(source);\n return sanitizePluginKey(basename(url.pathname) || url.hostname) || \"plugin\";\n } catch {\n return sanitizePluginKey(source) || \"plugin\";\n }\n}\n\nfunction pluginLocalPath(configDir: string, attachment: PluginAttachmentConfig): string | null {\n const ref = getPluginRef(attachment);\n const source = ref?.development ?? ref?.production;\n if (!source?.startsWith(\"local:\")) {\n return null;\n }\n\n return join(configDir, source.slice(\"local:\".length));\n}\n\nfunction listPluginAttachments(config: BosConfig | null) {\n return (Object.entries(config?.plugins ?? {}) as Array<[string, PluginAttachmentConfig]>)\n .map(([key, attachment]) => {\n const ref = getPluginRef(attachment);\n return {\n key,\n development: ref?.development,\n production: ref?.production,\n localPath: ref?.development?.startsWith(\"local:\")\n ? ref.development.slice(\"local:\".length)\n : undefined,\n source: ref?.development?.startsWith(\"local:\") ? (\"local\" as const) : (\"remote\" as const),\n integrity: ref?.integrity,\n version: ref?.version,\n name: ref?.name,\n };\n })\n .sort((a, b) => a.key.localeCompare(b.key));\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,gBAAgB,SAAqB;CACnD,OAAO;EACL,WAAW,QAAQ,UAAU,QAAQ,OAAO,EAAE,OAAO,cAAc;GAEjE,MAAM,UADO,QAAQ,IAAI,QAAQ,mBAAmB,UACjC,CAAC,CAAC;GACrB,IAAI,CAAC,SAAS,QACZ,OAAO;IACL,QAAQ;IACR,KAAK;IACL,OAAO;GACT;GAGF,MAAM,WAAW,MAAM,OAAO,WAAW,QAAQ;GACjD,MAAM,UAAU,MAAM,OAAO,WAAW,QAAQ;GAChD,MAAM,MAAM,kBACV,MAAM,OACH,WAAY,MAAM,OAAO,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,WAAY,iBAAiB,MAAM,MAAM,EAC3F;GACA,MAAM,WAAW,QAAQ,OAAO,UAAU;GAC1C,MAAM,gBAAgB,YAAY,OAAO,aAAa,WAAW,WAAW,CAAC;GAK7E,MAAM,mBAAmB,SAA2D;IAClF,IAAI,UAAU;KACZ,MAAM,EAAE,aAAa,UAAU,GAAG,SAAS;KAC3C,OAAO;MAAE,GAAG;MAAM,SAAS,MAAM;KAAO;IAC1C;IACA,IAAI,SAAS;KACX,MAAM,EAAE,SAAS,UAAU,GAAG,SAAS;KACvC,OAAO;MAAE,GAAG;MAAM,aAAa,MAAM;KAAO;IAC9C;IACA,MAAM,EAAE,aAAa,UAAU,GAAG,SAAS;IAC3C,OAAO;KAAE,GAAG;KAAM,YAAY,MAAM,cAAc,MAAM;IAAO;GACjE;GACA,MAAM,cAAc,EAAE,GAAG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AAS,gBAAgB,WAAmB,YAAmD;CAC7F,MAAM,MAAM,aAAa,UAAU;CACnC,MAAM,SAAS,KAAK,eAAe,KAAK;CACxC,IAAI,CAAC,QAAQ,WAAW,QAAQ,GAC9B,OAAO;CAGT,OAAO,KAAK,WAAW,OAAO,MAAM,CAAe,CAAC;AACtD;AAEA,SAAS,sBAAsB,QAA0B;CACvD,OAAQ,OAAO,QAAQ,QAAQ,WAAW,CAAC,CAAC,CAAC,CAC1C,KAAK,CAAC,KAAK,gBAAgB;EAC1B,MAAM,MAAM,aAAa,UAAU;EACnC,OAAO;GACL;GACA,aAAa,KAAK;GAClB,YAAY,KAAK;GACjB,WAAW,KAAK,aAAa,WAAW,QAAQ,IAC5C,IAAI,YAAY,MAAM,CAAe,IACrC;GACJ,QAAQ,KAAK,aAAa,WAAW,QAAQ,IAAK,UAAqB;GACvE,WAAW,KAAK;GAChB,SAAS,KAAK;GACd,MAAM,KAAK;EACb;CACF,CAAC,CAAC,CACD,MAAM,GAAG,MAAM,EAAE,IAAI,cAAc,EAAE,GAAG,CAAC;AAC9C"}
|
|
1
|
+
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/commands/plugins.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport { Context } from \"effect\";\nimport { getPluginRef } from \"../build\";\nimport { generateCodeArtifacts } from \"../code-artifacts\";\nimport { MISSING_CONFIG_MESSAGE } from \"../config\";\nimport type { PluginListResult } from \"../contract\";\nimport { fetchRemotePluginManifest } from \"../fastkv\";\nimport { publishToFastKv } from \"../publish\";\nimport { openResolution } from \"../resolution/session\";\nimport type { BosConfig } from \"../types\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { type BosBuilder, BosDepsTag } from \"./shared\";\n\nexport function registerPlugins(builder: BosBuilder) {\n return {\n pluginAdd: builder.pluginAdd.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 key: \"\",\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const isBosRef = input.source.startsWith(\"bos://\");\n const isLocal = input.source.startsWith(\"local:\");\n const key = sanitizePluginKey(\n input.as ??\n (isBosRef ? (input.source.split(\"/\").pop() ?? \"plugin\") : defaultPluginKey(input.source)),\n );\n const existing = session.config.plugins?.[key];\n const existingEntry = existing && typeof existing === \"object\" ? existing : {};\n // Adding a source is a switch, not an additive patch: a remote URL (or\n // bos:// ref) replaces a conflicting local development ref. Dual-mode\n // (local in dev, production URL in prod) remains expressible by\n // hand-editing the authored config.\n const applyEntryDelta = (base: Record<string, unknown>): Record<string, unknown> => {\n if (isBosRef) {\n const { development: _dropped, ...rest } = base;\n return { ...rest, extends: input.source };\n }\n if (isLocal) {\n const { extends: _dropped, ...rest } = base;\n return { ...rest, development: input.source };\n }\n const { development: _dropped, ...rest } = base;\n return { ...rest, production: input.production ?? input.source };\n };\n const nextPlugins = { ...session.config.plugins };\n nextPlugins[key] = applyEntryDelta(existingEntry);\n\n const nextConfig: BosConfig = {\n ...session.config,\n plugins: nextPlugins,\n };\n\n const authored = session.rawConfig;\n if (authored) {\n // Authoring-surface save: the authored leaf input + delta, never the\n // resolved config (which would bake inherited values into the file).\n const authoredExisting = authored.plugins?.[key];\n const authoredBase: Record<string, unknown> =\n typeof authoredExisting === \"string\"\n ? { extends: authoredExisting }\n : authoredExisting && typeof authoredExisting === \"object\"\n ? (authoredExisting as Record<string, unknown>)\n : {};\n await saveBosConfig(session.root, {\n ...authored,\n plugins: {\n ...authored.plugins,\n [key]: applyEntryDelta(authoredBase),\n },\n });\n } else {\n await saveBosConfig(session.root, nextConfig);\n }\n await generateCodeArtifacts(session.root, nextConfig);\n\n const stored = nextConfig.plugins?.[key];\n const storedObj = stored && typeof stored === \"object\" ? stored : {};\n\n return {\n status: \"added\" as const,\n key,\n development: storedObj.development,\n production: storedObj.production,\n integrity: storedObj.integrity,\n version: storedObj.version,\n };\n }),\n\n pluginRemove: builder.pluginRemove.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 key: input.key,\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n if (!session.config.plugins?.[input.key]) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const nextPlugins = { ...session.config.plugins };\n delete nextPlugins[input.key];\n const nextConfig: BosConfig = {\n ...session.config,\n plugins: Object.keys(nextPlugins).length > 0 ? nextPlugins : undefined,\n };\n\n const authored = session.rawConfig;\n if (authored) {\n const authoredPlugins: Record<string, unknown> = { ...authored.plugins };\n if (authoredPlugins[input.key] === undefined) {\n // Inherited from the parent runtime. JSON-form children can express\n // removal with a null sentinel (dropped by the extends merge); the\n // TS descriptor schema cannot, so only those error out.\n if (existsSync(join(session.root, \"bos.app.ts\"))) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `'${input.key}' is inherited from the parent runtime — remove it in the parent config or override it there (the authored descriptor cannot express removal)`,\n };\n }\n authoredPlugins[input.key] = null;\n } else {\n delete authoredPlugins[input.key];\n }\n await saveBosConfig(session.root, {\n ...authored,\n plugins: Object.keys(authoredPlugins).length > 0 ? authoredPlugins : undefined,\n });\n } else {\n await saveBosConfig(session.root, nextConfig);\n }\n await generateCodeArtifacts(session.root, nextConfig);\n\n return {\n status: \"removed\" as const,\n key: input.key,\n };\n }),\n\n pluginList: builder.pluginList.handler(async ({ context }) => {\n const deps = Context.get(context[\"effect/context\"], BosDepsTag);\n const plugins: PluginListResult[\"plugins\"] = listPluginAttachments(\n deps.session?.config ?? null,\n );\n return {\n status: \"listed\" as const,\n plugins,\n };\n }),\n\n pluginPublish: builder.pluginPublish.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 key: input.key,\n error: MISSING_CONFIG_MESSAGE,\n };\n }\n\n const attachment = session.config?.plugins?.[input.key];\n if (!attachment) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const localPath = pluginLocalPath(session.root, attachment);\n if (!localPath) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' does not have a local development path`,\n };\n }\n\n const result = await publishToFastKv({\n bosConfig: session.config,\n runtimeConfig: session.runtime,\n configDir: session.root,\n env: \"production\",\n build: true,\n dryRun: false,\n verbose: false,\n packages: input.key,\n });\n if (result.status === \"error\") {\n return {\n status: \"error\" as const,\n key: input.key,\n error: result.error,\n };\n }\n\n const nextSession = (await openResolution({ cwd: session.root })) ?? session;\n const production = (\n nextSession.config?.plugins?.[input.key] as\n | {\n production?: string;\n }\n | undefined\n )?.production;\n\n const manifest = production ? await fetchRemotePluginManifest(production) : null;\n if (production && nextSession.config) {\n await generateCodeArtifacts(session.root, nextSession.config);\n }\n\n return {\n status: \"published\" as const,\n key: input.key,\n path: localPath,\n production,\n fingerprint: result.fingerprint,\n version: manifest?.plugin.version,\n };\n }),\n };\n}\n\ntype PluginAttachmentConfig = NonNullable<BosConfig[\"plugins\"]>[string];\n\nfunction sanitizePluginKey(value: string): string {\n return value\n .replace(/[^A-Za-z0-9/_-]/g, \"-\")\n .replace(/\\/+/g, \"/\")\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => segment.replace(/[^A-Za-z0-9_-]/g, \"-\"))\n .join(\"/\")\n .replace(/^\\/+|\\/+$/g, \"\");\n}\n\nfunction defaultPluginKey(source: string): string {\n const normalized = source.replace(/^local:/, \"\").replace(/\\/$/, \"\");\n if (source.startsWith(\"local:\")) {\n return sanitizePluginKey(basename(normalized)) || \"plugin\";\n }\n\n try {\n const url = new URL(source);\n return sanitizePluginKey(basename(url.pathname) || url.hostname) || \"plugin\";\n } catch {\n return sanitizePluginKey(source) || \"plugin\";\n }\n}\n\nfunction pluginLocalPath(configDir: string, attachment: PluginAttachmentConfig): string | null {\n const ref = getPluginRef(attachment);\n const source = ref?.development ?? ref?.production;\n if (!source?.startsWith(\"local:\")) {\n return null;\n }\n\n return join(configDir, source.slice(\"local:\".length));\n}\n\nfunction listPluginAttachments(config: BosConfig | null) {\n return (Object.entries(config?.plugins ?? {}) as Array<[string, PluginAttachmentConfig]>)\n .map(([key, attachment]) => {\n const ref = getPluginRef(attachment);\n return {\n key,\n development: ref?.development,\n production: ref?.production,\n localPath: ref?.development?.startsWith(\"local:\")\n ? ref.development.slice(\"local:\".length)\n : undefined,\n source: ref?.development?.startsWith(\"local:\") ? (\"local\" as const) : (\"remote\" as const),\n integrity: ref?.integrity,\n version: ref?.version,\n name: ref?.name,\n };\n })\n .sort((a, b) => a.key.localeCompare(b.key));\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,gBAAgB,SAAqB;CACnD,OAAO;EACL,WAAW,QAAQ,UAAU,QAAQ,OAAO,EAAE,OAAO,cAAc;GAEjE,MAAM,UADO,QAAQ,IAAI,QAAQ,mBAAmB,UACjC,CAAC,CAAC;GACrB,IAAI,CAAC,SAAS,QACZ,OAAO;IACL,QAAQ;IACR,KAAK;IACL,OAAO;GACT;GAGF,MAAM,WAAW,MAAM,OAAO,WAAW,QAAQ;GACjD,MAAM,UAAU,MAAM,OAAO,WAAW,QAAQ;GAChD,MAAM,MAAM,kBACV,MAAM,OACH,WAAY,MAAM,OAAO,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,WAAY,iBAAiB,MAAM,MAAM,EAC3F;GACA,MAAM,WAAW,QAAQ,OAAO,UAAU;GAC1C,MAAM,gBAAgB,YAAY,OAAO,aAAa,WAAW,WAAW,CAAC;GAK7E,MAAM,mBAAmB,SAA2D;IAClF,IAAI,UAAU;KACZ,MAAM,EAAE,aAAa,UAAU,GAAG,SAAS;KAC3C,OAAO;MAAE,GAAG;MAAM,SAAS,MAAM;KAAO;IAC1C;IACA,IAAI,SAAS;KACX,MAAM,EAAE,SAAS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C,KAAK;CAGpD,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,MAAM;EAC1B,OAAO,kBAAkB,SAAS,IAAI,QAAQ,KAAK,IAAI,QAAQ,KAAK;CACtE,QAAQ;EACN,OAAO,kBAAkB,MAAM,KAAK;CACtC;AACF;AAEA,SAAS,gBAAgB,WAAmB,YAAmD;CAC7F,MAAM,MAAM,aAAa,UAAU;CACnC,MAAM,SAAS,KAAK,eAAe,KAAK;CACxC,IAAI,CAAC,QAAQ,WAAW,QAAQ,GAC9B,OAAO;CAGT,OAAO,KAAK,WAAW,OAAO,MAAM,CAAe,CAAC;AACtD;AAEA,SAAS,sBAAsB,QAA0B;CACvD,OAAQ,OAAO,QAAQ,QAAQ,WAAW,CAAC,CAAC,CAAC,CAC1C,KAAK,CAAC,KAAK,gBAAgB;EAC1B,MAAM,MAAM,aAAa,UAAU;EACnC,OAAO;GACL;GACA,aAAa,KAAK;GAClB,YAAY,KAAK;GACjB,WAAW,KAAK,aAAa,WAAW,QAAQ,IAC5C,IAAI,YAAY,MAAM,CAAe,IACrC;GACJ,QAAQ,KAAK,aAAa,WAAW,QAAQ,IAAK,UAAqB;GACvE,WAAW,KAAK;GAChB,SAAS,KAAK;GACd,MAAM,KAAK;EACb;CACF,CAAC,CAAC,CACD,MAAM,GAAG,MAAM,EAAE,IAAI,cAAc,EAAE,GAAG,CAAC;AAC9C"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
2
|
const require_config = require('../config.cjs');
|
|
3
|
+
const require_theme = require('../utils/theme.cjs');
|
|
3
4
|
const require_resolution_session = require('../resolution/session.cjs');
|
|
4
5
|
const require_mf = require('../mf.cjs');
|
|
5
|
-
const require_theme = require('../utils/theme.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,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,CAA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AAC;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;IA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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,UAAU;IAIb,MAAM,UAAUR,qBAAQ,IAAI;IAC5B,MAAM,UAAUA,qBAAQ,IAAI;IAC5B,IAAI,CAAC,WAAW,CAAC,SACf,OAAO;KACL,QAAQ;KACR,aAAa;KACb,eAAe;KACf,YAAYP;KACZ,SAAS,CAAC;IACZ;IAEF,IAAI;KACF,WAAW,MAAMgB,2CAAuB,SAAS,OAAO;IAC1D,SAAS,GAAG;KACV,OAAO;MACL,QAAQ;MACR,aAAa;MACb,eAAe;MACf,YAAY,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;MACrD,SAAS,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"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { MISSING_CONFIG_MESSAGE, findConfigPath, readAuthoredConfigInput } from "../config.mjs";
|
|
2
|
+
import { colors } from "../utils/theme.mjs";
|
|
2
3
|
import { openResolution } from "../resolution/session.mjs";
|
|
3
4
|
import { checkFederationCompat } from "../mf.mjs";
|
|
4
|
-
import { colors } from "../utils/theme.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;IACnC;IAGF,MAAM,aAAa,QAAQ,QAAQ,UAAU,CAAC;IAC9C,MAAM,SAAS,MAAM,aAAa,YAAY,KAAK;IAEnD,IAAI,OAAO,WAAW,YAAY,OAAO,WAAW,WAAW;KAC7D,MAAM,eAAe,MAAM,eAAe,EAAE,KAAK,WAAW,CAAC;KAC7D,IAAI,cAAc,QAChB,MAAM,sBAAsB,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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IAAI,OAAO,OAAO,IAAI,UAAU,EAAE,GAAG,OAAO,KAAK,MAAM,KAAK,GAAG;KACvE,MAAM,QAAQ,UAAU,QAAQ,MAAM;MACpC,KAAK,MAAM;MACX,OAAO;KACT,CAAC;KACD,MAAM,SAAS,MAAM,WAAW;KAChC,QAAQ,KAAK,MAAM,KAAK;KACxB,QAAQ,KAAK;MACX,WAAW,MAAM;MACjB;MACA,OAAO,SAAS,SAAY,+BAA+B,MAAM,UAAU,MAAM;KACnF,CAAC;IACH;IAEA,OAAO;KACL,QAAQ;KACR;KACA,SAAS,eAAe,KAAK,UAAU,MAAM,KAAK;KAClD;IACF;GACF,SAAS,OAAO;IACd,OAAO;KACL,QAAQ;KACR,SAAS,CAAC;KACV,SAAS,CAAC;KACV,SAAS,CAAC;KACV,OAAO,iBAAiB,QAAQ,MAAM,UAAU;IAClD;GACF;EACF,CAAC;EAED,SAAS,QAAQ,QAAQ,QAAQ,OAAO,EAAE,YAAY;GACpD,IAAI,WAA6B;GACjC,IAAI;IACF,WAAY,MAAM,wBAAwB;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,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":";;;;;;;;;;;;;;;AAgBA,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;IACnC;IAGF,MAAM,aAAa,QAAQ,QAAQ,UAAU,CAAC;IAC9C,MAAM,SAAS,MAAM,aAAa,YAAY,KAAK;IAEnD,IAAI,OAAO,WAAW,YAAY,OAAO,WAAW,WAAW;KAC7D,MAAM,eAAe,MAAM,eAAe,EAAE,KAAK,WAAW,CAAC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AS,CAAC;IACZ;IAEF,IAAI;KACF,WAAW,MAAM,uBAAuB,SAAS,OAAO;IAC1D,SAAS,GAAG;KACV,OAAO;MACL,QAAQ;MACR,aAAa;MACb,eAAe;MACf,YAAY,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;MACrD,SAAS,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,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,6 +1,6 @@
|
|
|
1
1
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_dev_log_pipeline = require('../dev-log-pipeline.cjs');
|
|
3
2
|
const require_theme = require('../utils/theme.cjs');
|
|
3
|
+
const require_dev_log_pipeline = require('../dev-log-pipeline.cjs');
|
|
4
4
|
const require_linkify = require('../utils/linkify.cjs');
|
|
5
5
|
let chalk = require("chalk");
|
|
6
6
|
chalk = require_runtime.__toESM(chalk, 1);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { stripAnsi } from "../dev-log-pipeline.mjs";
|
|
2
1
|
import { colors, divider, frames, gradients, icons } from "../utils/theme.mjs";
|
|
2
|
+
import { stripAnsi } from "../dev-log-pipeline.mjs";
|
|
3
3
|
import { linkify } from "../utils/linkify.mjs";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
|
package/dist/config.cjs
CHANGED
|
@@ -298,7 +298,7 @@ async function readBosConfigForBuild(configDir) {
|
|
|
298
298
|
return configData;
|
|
299
299
|
}
|
|
300
300
|
} catch (e) {
|
|
301
|
-
console.warn(`[Config] Failed to parse _resolved.json, falling back to the authored config: ${e}`);
|
|
301
|
+
console.warn(`[Config] Failed to parse _resolved.json, falling back to the authored config: ${String(e)}`);
|
|
302
302
|
}
|
|
303
303
|
const authored = await readLocalAuthoredConfigInput(configDir);
|
|
304
304
|
if (authored) return authored;
|
|
@@ -772,7 +772,7 @@ function resolveUiRuntimeName(uiConfig, localPath, apiName) {
|
|
|
772
772
|
const pkg = JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf-8"));
|
|
773
773
|
if (typeof pkg.name === "string" && pkg.name.length > 0) return (0, every_plugin_ui_manifest_contract.sanitizeContainerName)(pkg.name);
|
|
774
774
|
} catch (e) {
|
|
775
|
-
console.warn(`[Config] Could not read package.json at ${pkgPath}: ${e}`);
|
|
775
|
+
console.warn(`[Config] Could not read package.json at ${pkgPath}: ${String(e)}`);
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
778
|
return typeof uiConfig?.name === "string" ? uiConfig.name : `${apiName}-ui`;
|
|
@@ -785,7 +785,7 @@ function resolvePluginRuntimeName(explicitName, localPath, fallback) {
|
|
|
785
785
|
const packageJson = JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf-8"));
|
|
786
786
|
if (typeof packageJson.name === "string" && packageJson.name.length > 0) return packageJson.name;
|
|
787
787
|
} catch (e) {
|
|
788
|
-
console.warn(`[Config] Could not read package.json at ${localPath}: ${e}`);
|
|
788
|
+
console.warn(`[Config] Could not read package.json at ${localPath}: ${String(e)}`);
|
|
789
789
|
}
|
|
790
790
|
return fallback;
|
|
791
791
|
}
|