everything-dev 2.0.0-rc.1 → 2.0.0-rc.4
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/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/cli/init.cjs +4 -4
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.mjs +4 -4
- 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 -1
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +1 -1
- 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 -16
- package/dist/commands/deploy.cjs.map +1 -1
- package/dist/commands/deploy.mjs +26 -16
- 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 +1 -1
- package/dist/commands/upgrade.mjs +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 +10 -2
- package/dist/dev-program.cjs.map +1 -1
- package/dist/dev-program.mjs +10 -2
- package/dist/dev-program.mjs.map +1 -1
- package/dist/image-deploy.cjs +65 -17
- package/dist/image-deploy.cjs.map +1 -1
- package/dist/image-deploy.mjs +64 -18
- 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/types.d.cts +31 -1
- package/dist/types.d.mts +31 -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 +11 -10
package/dist/cli/sync.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.mjs","names":["computeHash","parseYaml","isPlainObjectFromMerge"],"sources":["../../src/cli/sync.ts"],"sourcesContent":["import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, relative } from \"node:path\";\nimport { glob } from \"glob\";\nimport { parse as parseYaml } from \"yaml\";\nimport { loadAppDescriptorConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport { materializeViaLayer } from \"../infra/materializer\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { openResolution } from \"../resolution/session\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { computeSnapshotHash as computeHash } from \"../utils/snapshot-hash\";\nimport { findWorkspaceRoot } from \"../workspace\";\nimport {\n buildChildAgentsMd,\n buildChildRootScripts,\n extractSkillsBlock,\n personalizeConfig,\n resolveSourceDir,\n runPnpmInstall,\n runTypesGen,\n} from \"./init\";\nimport { readSnapshot, writeSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_OWNED_SYNC_FILES = new Set([\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bos.config.json\",\n \"package.json\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \".github/workflows/ci.yml\",\n \".github/workflows/deploy.yml\",\n \".github/workflows/staging.yml\",\n \".github/workflows/release.yml\",\n \"railway.toml\",\n \"ui/package.json\",\n \"ui/postcss.config.mjs\",\n \"ui/tsconfig.json\",\n \"api/package.json\",\n \"api/plugin.dev.ts\",\n \"api/rspack.config.js\",\n \"api/tsconfig.json\",\n \"api/src/lib/context.ts\",\n \"api/drizzle.config.ts\",\n \"api/src/db/index.ts\",\n \"api/src/db/layer.ts\",\n \"api/src/db/migrate.ts\",\n \"api/src/global.d.ts\",\n \"api/tests/types.d.ts\",\n]);\n\n/**\n * Files the scaffold previously sync-owned but has retired (ADR 0023) — the\n * generated `.gen` bootstrap stubs replaced them. During sync: a local copy\n * whose hash still matches the sync snapshot is deleted silently; a\n * hand-modified (or never-snapshotted) copy is backed up, then deleted. The\n * app's authored ui files (router.tsx, app.ts, lib, routes, components) are\n * NOT retired — they leave the sync list as app-owned files, untouched.\n */\nexport const RETIRED_SYNC_FILES = new Set([\n \"ui/src/entry.ts\",\n \"ui/src/globals.d.ts\",\n \"ui/src/hydrate.tsx\",\n \"ui/src/router.server.tsx\",\n \"ui/src/compose.ts\",\n]);\n\ntype PackageJson = Record<string, unknown>;\n\nconst AGENT_SYNC_GLOBS = [\".agents/skills/**\", \"docs/agents/**\", \"skills-lock.json\"];\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n if (FRAMEWORK_OWNED_SYNC_FILES.has(filePath)) return true;\n if (\n filePath.startsWith(\".agents/skills/\") ||\n filePath.startsWith(\"docs/agents/\") ||\n filePath === \"skills-lock.json\"\n )\n return true;\n // lib/auth.ts is NOT sync-owned since #207: the middleware factory lives in\n // everything-dev/api (framework home); projects import it, they don't own a copy.\n if (/^plugins\\/[^/]+\\/src\\/lib\\/context\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/db\\/(index|layer|migrate)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/rspack\\.config\\.js$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/drizzle\\.config\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/global\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tests\\/types\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.json$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.contract\\.json$/.test(filePath)) return true;\n return false;\n}\n\nfunction computeLocalHash(projectDir: string, filePath: string): string | null {\n const fullPath = join(projectDir, filePath);\n if (!existsSync(fullPath)) return null;\n try {\n const content = readFileSync(fullPath);\n return computeHash(content);\n } catch {\n return null;\n }\n}\n\nfunction backupFiles(projectDir: string, filePaths: string[]): string | null {\n const filesToBackup = filePaths.filter((f) => existsSync(join(projectDir, f)));\n if (filesToBackup.length === 0) return null;\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupDir = join(projectDir, \".bos\", \"sync-backup\", timestamp);\n\n for (const filePath of filesToBackup) {\n const src = join(projectDir, filePath);\n const dest = join(backupDir, filePath);\n mkdirSync(dirname(dest), { recursive: true });\n copyFileSync(src, dest);\n }\n\n return backupDir;\n}\n\nexport interface RetiredSyncFilesResult {\n /** unmodified stub copies — deleted (in a real run) */\n retired: string[];\n /** hand-modified or never-snapshotted stub copies — backed up, then deleted */\n retiredConflicted: string[];\n backupDir: string | null;\n}\n\n/**\n * Migrate a child off the retired bootstrap stub files (ADR 0023): unmodified\n * copies are deleted silently, hand-modified copies are backed up first. In\n * dry-run the actions are reported without touching the tree.\n */\nexport function retireSyncedFiles(\n projectDir: string,\n snapshotFiles: Record<string, string>,\n opts: { dryRun: boolean },\n): RetiredSyncFilesResult {\n const retired: string[] = [];\n const retiredConflicted: string[] = [];\n\n for (const destPath of RETIRED_SYNC_FILES) {\n const localHash = computeLocalHash(projectDir, destPath);\n if (localHash === null) continue;\n if (localHash === snapshotFiles[destPath]) {\n retired.push(destPath);\n } else {\n retiredConflicted.push(destPath);\n }\n }\n\n if (opts.dryRun || (retired.length === 0 && retiredConflicted.length === 0)) {\n return { retired, retiredConflicted, backupDir: null };\n }\n\n const backupDir = backupFiles(projectDir, retiredConflicted);\n for (const destPath of [...retired, ...retiredConflicted]) {\n rmSync(join(projectDir, destPath));\n }\n return { retired, retiredConflicted, backupDir };\n}\n\nfunction mergeStringMaps(\n local: Record<string, string> | undefined,\n template: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!local && !template) return undefined;\n\n const merged: Record<string, string> = { ...local };\n for (const [name, value] of Object.entries(template ?? {})) {\n merged[name] = value;\n }\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction mergeWorkspacePackages(local: unknown, template: unknown): string[] | undefined {\n const localPackages = Array.isArray(local) ? local : [];\n const templatePackages = Array.isArray(template) ? template : [];\n if (localPackages.length === 0 && templatePackages.length === 0) return undefined;\n\n const ordered = new Set<string>();\n for (const entry of templatePackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n for (const entry of localPackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n\n const hasPluginEntry = [...ordered].some((e) => e.startsWith(\"plugins/\") && e !== \"plugins/*\");\n if (hasPluginEntry) {\n for (const entry of ordered) {\n if (entry.startsWith(\"plugins/\") && entry !== \"plugins/*\") {\n ordered.delete(entry);\n }\n }\n ordered.add(\"plugins/*\");\n }\n\n return ordered.size > 0 ? [...ordered] : undefined;\n}\n\nexport function mergePackageJson(\n filePath: string,\n local: PackageJson,\n template: PackageJson,\n childScripts?: Record<string, string>,\n): PackageJson {\n const merged: PackageJson = { ...local, ...template };\n\n if (filePath === \"package.json\") {\n for (const key of [\"name\", \"private\", \"version\"] as const) {\n if (key in local) {\n merged[key] = local[key];\n }\n }\n } else if (\"version\" in local) {\n merged.version = local.version;\n }\n\n for (const depField of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"overrides\",\n ] as const) {\n const localDeps = local[depField] as Record<string, string> | undefined;\n const templateDeps = template[depField] as Record<string, string> | undefined;\n\n const mergedDeps = mergeStringMaps(localDeps, templateDeps);\n if (mergedDeps) {\n merged[depField] = mergedDeps;\n } else {\n delete merged[depField];\n }\n }\n\n if (\n (local.scripts && typeof local.scripts === \"object\") ||\n (template.scripts && typeof template.scripts === \"object\") ||\n childScripts\n ) {\n const mergedScripts = mergeStringMaps(\n local.scripts as Record<string, string> | undefined,\n filePath === \"package.json\" && childScripts\n ? childScripts\n : (template.scripts as Record<string, string> | undefined),\n );\n if (mergedScripts) {\n merged.scripts = mergedScripts;\n } else {\n delete merged.scripts;\n }\n }\n\n if (\n (local.workspaces && typeof local.workspaces === \"object\") ||\n (template.workspaces && typeof template.workspaces === \"object\")\n ) {\n const localWorkspaces = (local.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n const templateWorkspaces = (template.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n\n const mergedWorkspaces: { packages?: string[]; catalog?: Record<string, string> } = {\n ...localWorkspaces,\n ...templateWorkspaces,\n };\n\n const mergedPackages = mergeWorkspacePackages(\n localWorkspaces.packages,\n templateWorkspaces.packages,\n );\n if (mergedPackages) {\n mergedWorkspaces.packages = mergedPackages;\n } else {\n delete mergedWorkspaces.packages;\n }\n\n const mergedCatalog = mergeStringMaps(localWorkspaces.catalog, templateWorkspaces.catalog);\n if (mergedCatalog) {\n mergedWorkspaces.catalog = mergedCatalog;\n } else {\n delete mergedWorkspaces.catalog;\n }\n\n if (Object.keys(mergedWorkspaces).length > 0) {\n merged.workspaces = mergedWorkspaces;\n } else {\n delete merged.workspaces;\n }\n }\n\n return merged;\n}\n\nfunction toSourcePath(sourceDir: string, destPath: string): string | null {\n if (destPath.startsWith(\".github/\")) {\n const templatePath = destPath.replace(/^\\.github\\//, \".github/templates/\");\n if (existsSync(join(sourceDir, templatePath))) {\n return templatePath;\n }\n }\n\n const directPath = join(sourceDir, destPath);\n if (existsSync(directPath)) {\n return destPath;\n }\n\n return null;\n}\n\nfunction buildSyncedFileContent(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n childScripts?: Record<string, string>,\n): string | Uint8Array {\n const src = join(sourceDir, filePath);\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n\n if (filePath.endsWith(\"bos.config.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergeBosConfigWithTemplate(local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n if (filePath.endsWith(\"package.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergePackageJson(destPath, local, template, childScripts);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n return readFileSync(src);\n}\n\nfunction writeSyncedFile(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n childScripts?: Record<string, string>,\n): void {\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n writeFileSync(\n dest,\n buildSyncedFileContent(sourceDir, projectDir, filePath, destPath, childScripts),\n );\n}\n\nasync function getSelectedChildPlugins(\n projectDir: string,\n localConfig: Record<string, unknown>,\n): Promise<string[]> {\n if (!localConfig.plugins || typeof localConfig.plugins !== \"object\") {\n return [];\n }\n\n const pluginDirs = new Set(\n (\n await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n })\n )\n .map((file) => file.match(/^plugins\\/([^/]+)\\/package\\.json$/)?.[1])\n .filter((key): key is string => Boolean(key)),\n );\n\n const selected: string[] = [];\n for (const [pluginKey, rawEntry] of Object.entries(\n localConfig.plugins as Record<string, unknown>,\n )) {\n if (typeof rawEntry === \"string\") {\n if (!rawEntry.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, rawEntry.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n continue;\n }\n\n if (!rawEntry || typeof rawEntry !== \"object\") {\n selected.push(pluginKey);\n continue;\n }\n\n const entry = rawEntry as Record<string, unknown>;\n const development = typeof entry.development === \"string\" ? entry.development : undefined;\n if (!development?.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, development.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n }\n\n return selected;\n}\n\nfunction hasPluginsWorkspace(projectDir: string): boolean {\n const root = findWorkspaceRoot(projectDir);\n if (!root) return false;\n const rel = relative(root.dir, projectDir);\n const baseDir = rel.startsWith(\"..\") || rel === \"\" ? root.dir : projectDir;\n for (const manifest of [\"pnpm-workspace.yaml\", \"package.json\"]) {\n const manifestPath = join(baseDir, manifest);\n if (!existsSync(manifestPath)) continue;\n try {\n const content = readFileSync(manifestPath, \"utf-8\");\n const packages =\n manifest === \"pnpm-workspace.yaml\"\n ? (parseYaml(content) as { packages?: unknown } | null)?.packages\n : (\n JSON.parse(content) as {\n workspaces?: { packages?: string[] } | string[];\n }\n ).workspaces;\n const globs = Array.isArray(packages)\n ? packages\n : Array.isArray((packages as { packages?: string[] })?.packages)\n ? (packages as { packages?: string[] }).packages\n : [];\n if (globs.includes(\"plugins/*\")) return true;\n } catch {\n return false;\n }\n }\n return false;\n}\n\nexport async function syncTemplate(projectDir: string, options: SyncOptions): Promise<SyncResult> {\n // Sync reads the user's authored config — the raw bos.config.json, or the\n // materialized bos.app.ts descriptor for TS-form children — not the\n // resolved config: it needs the user's explicit local settings (their\n // extends ref, selected plugins, etc.). The resolved config is the merged\n // result and would include inherited parent values that the user didn't\n // explicitly choose, which would break sync filtering.\n const tsFormChild = existsSync(join(projectDir, \"bos.app.ts\"));\n const localConfig = (\n tsFormChild\n ? await loadAppDescriptorConfig(join(projectDir, \"bos.app.ts\"))\n : JSON.parse(readFileSync(join(projectDir, \"bos.config.json\"), \"utf-8\"))\n ) as Record<string, unknown>;\n\n let extendsRef: string | undefined;\n if (typeof localConfig.extends === \"string\") {\n extendsRef = localConfig.extends;\n } else if (isPlainObjectFromMerge(localConfig.extends)) {\n extendsRef = resolveExtendsRef(localConfig.extends as Record<string, string>, \"production\");\n }\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n conflicted: [],\n error: \"No extends field found in bos.config.json — cannot determine parent\",\n };\n }\n\n const extendsMatch = extendsRef.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!extendsMatch) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n conflicted: [],\n error: `Invalid extends reference: ${extendsRef}`,\n };\n }\n\n const extendsAccount = extendsMatch[1];\n const extendsGateway = extendsMatch[2];\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n });\n\n try {\n const childPlugins = await getSelectedChildPlugins(projectDir, localConfig);\n const withUi = existsSync(join(projectDir, \"ui\", \"package.json\"));\n const withApi = existsSync(join(projectDir, \"api\", \"package.json\"));\n const withHost = existsSync(join(projectDir, \"host\", \"package.json\"));\n const withPlugins = childPlugins.length > 0 || hasPluginsWorkspace(projectDir);\n\n const childScripts = buildChildRootScripts({\n ui: withUi,\n api: withApi,\n host: withHost,\n plugins: withPlugins,\n });\n\n const destToSource = new Map<string, string>();\n // TS-form children author bos.app.ts — the parent's JSON config must\n // never sync into them.\n const tsFormChild = !existsSync(join(projectDir, \"bos.config.json\"));\n for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {\n if (destPath === \"bos.config.json\" && tsFormChild) continue;\n if (destPath.startsWith(\"ui/\") && !withUi) continue;\n if (destPath.startsWith(\"api/\") && !withApi) continue;\n if (destPath.startsWith(\"host/\") && !withHost) continue;\n const sourcePath = toSourcePath(sourceDir, destPath);\n if (!sourcePath) continue;\n destToSource.set(destPath, sourcePath);\n }\n\n for (const destPath of await glob(AGENT_SYNC_GLOBS, {\n cwd: sourceDir,\n nodir: true,\n dot: true,\n absolute: false,\n ignore: [\"**/node_modules/**\", \"**/.git/**\", \"**/dist/**\", \"**/.bos/**\"],\n })) {\n destToSource.set(destPath, destPath);\n }\n\n // Sync api/src/lib/{auth,context}.ts into each plugin's src/lib/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n for (const libFile of [\"auth.ts\", \"context.ts\"]) {\n const sourceFile = `api/src/lib/${libFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/lib/${libFile}`, sourceFile);\n }\n }\n\n // Sync api/src/global.d.ts into each plugin's src/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n const sourceFile = \"api/src/global.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/global.d.ts`, sourceFile);\n }\n\n // Sync tests/types.d.ts into each plugin's tests/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/tests/types.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/tests/types.d.ts`, sourceFile);\n }\n\n // Sync api/src/db/{index,layer,migrate}.ts into each plugin's src/db/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n for (const dbFile of [\"index.ts\", \"layer.ts\", \"migrate.ts\"]) {\n const sourceFile = `api/src/db/${dbFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/db/${dbFile}`, sourceFile);\n }\n }\n\n // Sync rspack.config.js from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/rspack.config.js\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/rspack.config.js`, sourceFile);\n }\n\n // Sync drizzle.config.ts from api into each DB-enabled plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n const sourceFile = \"api/drizzle.config.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);\n }\n\n // Sync tsconfig from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/tsconfig.json\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/tsconfig.json`, sourceFile);\n }\n\n const updated: string[] = [];\n const skipped: string[] = [];\n const added: string[] = [];\n const conflicted: string[] = [];\n\n const snapshot = await readSnapshot(projectDir);\n const snapshotFiles = snapshot?.files ?? {};\n\n for (const [destPath, filePath] of destToSource.entries()) {\n if (!existsSync(join(sourceDir, filePath))) {\n // The template no longer ships this file — it was retired from the\n // scaffold. Leave the local copy untouched rather than crashing the\n // sync (the old-CLI + new-template transitional combo).\n skipped.push(destPath);\n continue;\n }\n const localHash = computeLocalHash(projectDir, destPath);\n const sourceHash = computeHash(\n buildSyncedFileContent(sourceDir, projectDir, filePath, undefined, childScripts),\n );\n\n if (localHash === null) {\n added.push(destPath);\n continue;\n }\n\n if (localHash === sourceHash) {\n skipped.push(destPath);\n continue;\n }\n\n const snapshotHash = snapshotFiles[destPath];\n if (!snapshotHash) {\n updated.push(destPath);\n continue;\n }\n\n if (localHash === snapshotHash) {\n updated.push(destPath);\n continue;\n }\n\n if (sourceHash === snapshotHash) {\n skipped.push(destPath);\n continue;\n }\n\n conflicted.push(destPath);\n }\n\n const account = (localConfig.account as string) || extendsAccount;\n const domain = (localConfig.domain as string) || extendsGateway;\n const overrides: Array<\"ui\" | \"api\" | \"host\" | \"plugins\"> = [];\n if (withUi) overrides.push(\"ui\");\n if (withApi) overrides.push(\"api\");\n if (withHost) overrides.push(\"host\");\n if (withPlugins) overrides.push(\"plugins\");\n\n if (options.dryRun) {\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n updated.push(\"AGENTS.md\");\n }\n }\n }\n\n const retirement = retireSyncedFiles(projectDir, snapshotFiles, { dryRun: true });\n\n return {\n status: \"dry-run\",\n updated,\n skipped,\n added,\n conflicted,\n retired: retirement.retired,\n retiredConflicted: retirement.retiredConflicted,\n };\n }\n\n // Migrate the child off the retired bootstrap stubs (ADR 0023) before any\n // writes — a retired file is never in destToSource, so its snapshot entry\n // drops out at the next writeSnapshot.\n const retirement = retireSyncedFiles(projectDir, snapshotFiles, { dryRun: false });\n\n const filesToWrite = [...updated, ...added, ...conflicted];\n\n let backupDir: string | undefined = retirement.backupDir ?? undefined;\n if (filesToWrite.length > 0) {\n backupDir = backupFiles(projectDir, filesToWrite) ?? backupDir;\n\n for (const destPath of filesToWrite) {\n const sourcePath = destToSource.get(destPath) ?? destPath;\n writeSyncedFile(sourceDir, projectDir, sourcePath, destPath, childScripts);\n }\n }\n\n await personalizeConfig(projectDir, {\n extendsAccount,\n extendsGateway,\n account,\n domain,\n overrides,\n plugins: childPlugins,\n workspaceOpts: { sourceDir },\n mode: \"sync\",\n existingConfig: localConfig,\n });\n\n await syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n });\n\n const syncedConfig = await openResolution({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n await materializeViaLayer(projectDir, syncedConfig.runtime!);\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const destPath of destToSource.keys()) {\n const hash = computeLocalHash(projectDir, destPath);\n if (hash) {\n newSnapshotFiles[destPath] = hash;\n }\n }\n\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n writeFileSync(join(projectDir, \"AGENTS.md\"), expectedContent);\n updated.push(\"AGENTS.md\");\n }\n\n newSnapshotFiles[\"AGENTS.md\"] = expectedHash;\n }\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\n });\n\n if (!options.noInstall) {\n await runPnpmInstall(findWorkspaceRoot(projectDir)?.dir ?? projectDir);\n await runTypesGen(projectDir);\n }\n\n return {\n status: \"synced\",\n updated,\n skipped,\n added,\n conflicted,\n retired: retirement.retired,\n retiredConflicted: retirement.retiredConflicted,\n retiredBackupDir: retirement.backupDir ?? undefined,\n backupDir,\n };\n } finally {\n await cleanup();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAM,6CAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;AAUD,MAAa,qCAAqB,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,MAAM,mBAAmB;CAAC;CAAqB;CAAkB;AAAkB;AAEnF,SAAgB,yBAAyB,UAA2B;CAClE,IAAI,2BAA2B,IAAI,QAAQ,GAAG,OAAO;CACrD,IACE,SAAS,WAAW,iBAAiB,KACrC,SAAS,WAAW,cAAc,KAClC,aAAa,oBAEb,OAAO;CAGT,IAAI,0CAA0C,KAAK,QAAQ,G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,MAAM,uBAAuB;GAC3B,WAAW;GACX,UAAU;EACZ,CAAC;EAED,MAAM,eAAe,MAAM,eAAe,EAAE,KAAK,WAAW,CAAC;EAC7D,IAAI,cAAc,SAChB,MAAM,oBAAoB,YAAY,aAAa,OAAQ;EAG7D,MAAM,mBAA2C,CAAC;EAClD,KAAK,MAAM,YAAY,aAAa,KAAK,GAAG;GAC1C,MAAM,OAAO,iBAAiB,YAAY,QAAQ;GAClD,IAAI,MACF,iBAAiB,YAAY;EAEjC;EAEA,MAAM,qBAAqB,aAAa,WAAW,WAAW;EAC9D,IAAI,oBAAoB;GACtB,MAAM,wBAAwB,aAAa,KAAK,WAAW,kBAAkB,GAAG,OAAO;GACvF,MAAM,cAAc,mBAAmB,qBAAqB;GAC5D,IAAI,aAAa;IACf,MAAM,kBAAkB,mBAAmB,aAAa;KACtD;KACA,SAAS;IACX,CAAC;IACD,MAAM,eAAeA,oBAAY,eAAe;IAGhD,IAD0B,iBAAiB,YAAY,WACnC,MAAM,cAAc;KACtC,cAAc,KAAK,YAAY,WAAW,GAAG,eAAe;KAC5D,QAAQ,KAAK,WAAW;IAC1B;IAEA,iBAAiB,eAAe;GAClC;EACF;EAEA,MAAM,cAAc,YAAY;GAC9B,WAAW,SAAS,eAAe,GAAG;GACtC,OAAO;EACT,CAAC;EAED,IAAI,CAAC,QAAQ,WAAW;GACtB,MAAM,eAAe,kBAAkB,UAAU,CAAC,EAAE,OAAO,UAAU;GACrE,MAAM,YAAY,UAAU;EAC9B;EAEA,OAAO;GACL,QAAQ;GACR;GACA;GACA;GACA;GACA,SAAS,WAAW;GACpB,mBAAmB,WAAW;GAC9B,kBAAkB,WAAW,aAAa;GAC1C;EACF;CACF,UAAU;EACR,MAAM,QAAQ;CAChB;AACF"}
|
|
1
|
+
{"version":3,"file":"sync.mjs","names":["computeHash","parseYaml","isPlainObjectFromMerge"],"sources":["../../src/cli/sync.ts"],"sourcesContent":["import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, relative } from \"node:path\";\nimport { glob } from \"glob\";\nimport { parse as parseYaml } from \"yaml\";\nimport { loadAppDescriptorConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport { materializeViaLayer } from \"../infra/materializer\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { openResolution } from \"../resolution/session\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { computeSnapshotHash as computeHash } from \"../utils/snapshot-hash\";\nimport { findWorkspaceRoot } from \"../workspace\";\nimport {\n buildChildAgentsMd,\n buildChildRootScripts,\n extractSkillsBlock,\n personalizeConfig,\n resolveSourceDir,\n runPnpmInstall,\n runTypesGen,\n} from \"./init\";\nimport { readSnapshot, writeSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_OWNED_SYNC_FILES = new Set([\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bos.config.json\",\n \"package.json\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \".github/workflows/ci.yml\",\n \".github/workflows/deploy.yml\",\n \".github/workflows/staging.yml\",\n \".github/workflows/release.yml\",\n \"railway.toml\",\n \"ui/package.json\",\n \"ui/postcss.config.mjs\",\n \"ui/tsconfig.json\",\n \"api/package.json\",\n \"api/plugin.dev.ts\",\n \"api/rspack.config.js\",\n \"api/tsconfig.json\",\n \"api/src/lib/context.ts\",\n \"api/drizzle.config.ts\",\n \"api/src/db/index.ts\",\n \"api/src/db/layer.ts\",\n \"api/src/db/migrate.ts\",\n \"api/src/global.d.ts\",\n \"api/tests/types.d.ts\",\n]);\n\n/**\n * Files the scaffold previously sync-owned but has retired (ADR 0023) — the\n * generated `.gen` bootstrap stubs replaced them. During sync: a local copy\n * whose hash still matches the sync snapshot is deleted silently; a\n * hand-modified (or never-snapshotted) copy is backed up, then deleted. The\n * app's authored ui files (router.tsx, app.ts, lib, routes, components) are\n * NOT retired — they leave the sync list as app-owned files, untouched.\n */\nexport const RETIRED_SYNC_FILES = new Set([\n \"ui/src/entry.ts\",\n \"ui/src/globals.d.ts\",\n \"ui/src/hydrate.tsx\",\n \"ui/src/router.server.tsx\",\n \"ui/src/compose.ts\",\n]);\n\ntype PackageJson = Record<string, unknown>;\n\nconst AGENT_SYNC_GLOBS = [\".agents/skills/**\", \"docs/agents/**\", \"skills-lock.json\"];\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n if (FRAMEWORK_OWNED_SYNC_FILES.has(filePath)) return true;\n if (\n filePath.startsWith(\".agents/skills/\") ||\n filePath.startsWith(\"docs/agents/\") ||\n filePath === \"skills-lock.json\"\n )\n return true;\n // lib/auth.ts is NOT sync-owned since #207: the middleware factory lives in\n // everything-dev/api (framework home); projects import it, they don't own a copy.\n if (/^plugins\\/[^/]+\\/src\\/lib\\/context\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/db\\/(index|layer|migrate)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/rspack\\.config\\.js$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/drizzle\\.config\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/global\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tests\\/types\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.json$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.contract\\.json$/.test(filePath)) return true;\n return false;\n}\n\nfunction computeLocalHash(projectDir: string, filePath: string): string | null {\n const fullPath = join(projectDir, filePath);\n if (!existsSync(fullPath)) return null;\n try {\n const content = readFileSync(fullPath);\n return computeHash(content);\n } catch {\n return null;\n }\n}\n\nfunction backupFiles(projectDir: string, filePaths: string[]): string | null {\n const filesToBackup = filePaths.filter((f) => existsSync(join(projectDir, f)));\n if (filesToBackup.length === 0) return null;\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupDir = join(projectDir, \".bos\", \"sync-backup\", timestamp);\n\n for (const filePath of filesToBackup) {\n const src = join(projectDir, filePath);\n const dest = join(backupDir, filePath);\n mkdirSync(dirname(dest), { recursive: true });\n copyFileSync(src, dest);\n }\n\n return backupDir;\n}\n\nexport interface RetiredSyncFilesResult {\n /** unmodified stub copies — deleted (in a real run) */\n retired: string[];\n /** hand-modified or never-snapshotted stub copies — backed up, then deleted */\n retiredConflicted: string[];\n backupDir: string | null;\n}\n\n/**\n * Migrate a child off the retired bootstrap stub files (ADR 0023): unmodified\n * copies are deleted silently, hand-modified copies are backed up first. In\n * dry-run the actions are reported without touching the tree.\n */\nexport function retireSyncedFiles(\n projectDir: string,\n snapshotFiles: Record<string, string>,\n opts: { dryRun: boolean },\n): RetiredSyncFilesResult {\n const retired: string[] = [];\n const retiredConflicted: string[] = [];\n\n for (const destPath of RETIRED_SYNC_FILES) {\n const localHash = computeLocalHash(projectDir, destPath);\n if (localHash === null) continue;\n if (localHash === snapshotFiles[destPath]) {\n retired.push(destPath);\n } else {\n retiredConflicted.push(destPath);\n }\n }\n\n if (opts.dryRun || (retired.length === 0 && retiredConflicted.length === 0)) {\n return { retired, retiredConflicted, backupDir: null };\n }\n\n const backupDir = backupFiles(projectDir, retiredConflicted);\n for (const destPath of [...retired, ...retiredConflicted]) {\n rmSync(join(projectDir, destPath));\n }\n return { retired, retiredConflicted, backupDir };\n}\n\nfunction mergeStringMaps(\n local: Record<string, string> | undefined,\n template: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!local && !template) return undefined;\n\n const merged: Record<string, string> = { ...local };\n for (const [name, value] of Object.entries(template ?? {})) {\n merged[name] = value;\n }\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction mergeWorkspacePackages(local: unknown, template: unknown): string[] | undefined {\n const localPackages = Array.isArray(local) ? local : [];\n const templatePackages = Array.isArray(template) ? template : [];\n if (localPackages.length === 0 && templatePackages.length === 0) return undefined;\n\n const ordered = new Set<string>();\n for (const entry of templatePackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n for (const entry of localPackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n\n const hasPluginEntry = [...ordered].some((e) => e.startsWith(\"plugins/\") && e !== \"plugins/*\");\n if (hasPluginEntry) {\n for (const entry of ordered) {\n if (entry.startsWith(\"plugins/\") && entry !== \"plugins/*\") {\n ordered.delete(entry);\n }\n }\n ordered.add(\"plugins/*\");\n }\n\n return ordered.size > 0 ? [...ordered] : undefined;\n}\n\nexport function mergePackageJson(\n filePath: string,\n local: PackageJson,\n template: PackageJson,\n childScripts?: Record<string, string>,\n): PackageJson {\n const merged: PackageJson = { ...local, ...template };\n\n if (filePath === \"package.json\") {\n for (const key of [\"name\", \"private\", \"version\"] as const) {\n if (key in local) {\n merged[key] = local[key];\n }\n }\n } else if (\"version\" in local) {\n merged.version = local.version;\n }\n\n for (const depField of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"overrides\",\n ] as const) {\n const localDeps = local[depField] as Record<string, string> | undefined;\n const templateDeps = template[depField] as Record<string, string> | undefined;\n\n const mergedDeps = mergeStringMaps(localDeps, templateDeps);\n if (mergedDeps) {\n merged[depField] = mergedDeps;\n } else {\n delete merged[depField];\n }\n }\n\n if (\n (local.scripts && typeof local.scripts === \"object\") ||\n (template.scripts && typeof template.scripts === \"object\") ||\n childScripts\n ) {\n const mergedScripts = mergeStringMaps(\n local.scripts as Record<string, string> | undefined,\n filePath === \"package.json\" && childScripts\n ? childScripts\n : (template.scripts as Record<string, string> | undefined),\n );\n if (mergedScripts) {\n merged.scripts = mergedScripts;\n } else {\n delete merged.scripts;\n }\n }\n\n if (\n (local.workspaces && typeof local.workspaces === \"object\") ||\n (template.workspaces && typeof template.workspaces === \"object\")\n ) {\n const localWorkspaces = (local.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n const templateWorkspaces = (template.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n\n const mergedWorkspaces: { packages?: string[]; catalog?: Record<string, string> } = {\n ...localWorkspaces,\n ...templateWorkspaces,\n };\n\n const mergedPackages = mergeWorkspacePackages(\n localWorkspaces.packages,\n templateWorkspaces.packages,\n );\n if (mergedPackages) {\n mergedWorkspaces.packages = mergedPackages;\n } else {\n delete mergedWorkspaces.packages;\n }\n\n const mergedCatalog = mergeStringMaps(localWorkspaces.catalog, templateWorkspaces.catalog);\n if (mergedCatalog) {\n mergedWorkspaces.catalog = mergedCatalog;\n } else {\n delete mergedWorkspaces.catalog;\n }\n\n if (Object.keys(mergedWorkspaces).length > 0) {\n merged.workspaces = mergedWorkspaces;\n } else {\n delete merged.workspaces;\n }\n }\n\n return merged;\n}\n\nfunction toSourcePath(sourceDir: string, destPath: string): string | null {\n if (destPath.startsWith(\".github/\")) {\n const templatePath = destPath.replace(/^\\.github\\//, \".github/templates/\");\n if (existsSync(join(sourceDir, templatePath))) {\n return templatePath;\n }\n }\n\n const directPath = join(sourceDir, destPath);\n if (existsSync(directPath)) {\n return destPath;\n }\n\n return null;\n}\n\nfunction buildSyncedFileContent(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n childScripts?: Record<string, string>,\n): string | Uint8Array {\n const src = join(sourceDir, filePath);\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n\n if (filePath.endsWith(\"bos.config.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergeBosConfigWithTemplate(local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n if (filePath.endsWith(\"package.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergePackageJson(destPath, local, template, childScripts);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n return readFileSync(src);\n}\n\nfunction writeSyncedFile(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n childScripts?: Record<string, string>,\n): void {\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n writeFileSync(\n dest,\n buildSyncedFileContent(sourceDir, projectDir, filePath, destPath, childScripts),\n );\n}\n\nasync function getSelectedChildPlugins(\n projectDir: string,\n localConfig: Record<string, unknown>,\n): Promise<string[]> {\n if (!localConfig.plugins || typeof localConfig.plugins !== \"object\") {\n return [];\n }\n\n const pluginDirs = new Set(\n (\n await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n })\n )\n .map((file) => file.match(/^plugins\\/([^/]+)\\/package\\.json$/)?.[1])\n .filter((key): key is string => Boolean(key)),\n );\n\n const selected: string[] = [];\n for (const [pluginKey, rawEntry] of Object.entries(\n localConfig.plugins as Record<string, unknown>,\n )) {\n if (typeof rawEntry === \"string\") {\n if (!rawEntry.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, rawEntry.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n continue;\n }\n\n if (!rawEntry || typeof rawEntry !== \"object\") {\n selected.push(pluginKey);\n continue;\n }\n\n const entry = rawEntry as Record<string, unknown>;\n const development = typeof entry.development === \"string\" ? entry.development : undefined;\n if (!development?.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, development.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n }\n\n return selected;\n}\n\nfunction hasPluginsWorkspace(projectDir: string): boolean {\n const root = findWorkspaceRoot(projectDir);\n if (!root) return false;\n const rel = relative(root.dir, projectDir);\n const baseDir = rel.startsWith(\"..\") || rel === \"\" ? root.dir : projectDir;\n for (const manifest of [\"pnpm-workspace.yaml\", \"package.json\"]) {\n const manifestPath = join(baseDir, manifest);\n if (!existsSync(manifestPath)) continue;\n try {\n const content = readFileSync(manifestPath, \"utf-8\");\n const packages =\n manifest === \"pnpm-workspace.yaml\"\n ? (parseYaml(content) as { packages?: unknown } | null)?.packages\n : (\n JSON.parse(content) as {\n workspaces?: { packages?: string[] } | string[];\n }\n ).workspaces;\n const globs: string[] = Array.isArray(packages)\n ? packages\n : Array.isArray((packages as { packages?: string[] })?.packages)\n ? ((packages as { packages?: string[] }).packages ?? [])\n : [];\n if (globs.includes(\"plugins/*\")) return true;\n } catch {\n return false;\n }\n }\n return false;\n}\n\nexport async function syncTemplate(projectDir: string, options: SyncOptions): Promise<SyncResult> {\n // Sync reads the user's authored config — the raw bos.config.json, or the\n // materialized bos.app.ts descriptor for TS-form children — not the\n // resolved config: it needs the user's explicit local settings (their\n // extends ref, selected plugins, etc.). The resolved config is the merged\n // result and would include inherited parent values that the user didn't\n // explicitly choose, which would break sync filtering.\n const tsFormChild = existsSync(join(projectDir, \"bos.app.ts\"));\n const localConfig = (\n tsFormChild\n ? await loadAppDescriptorConfig(join(projectDir, \"bos.app.ts\"))\n : JSON.parse(readFileSync(join(projectDir, \"bos.config.json\"), \"utf-8\"))\n ) as Record<string, unknown>;\n\n let extendsRef: string | undefined;\n if (typeof localConfig.extends === \"string\") {\n extendsRef = localConfig.extends;\n } else if (isPlainObjectFromMerge(localConfig.extends)) {\n extendsRef = resolveExtendsRef(localConfig.extends as Record<string, string>, \"production\");\n }\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n conflicted: [],\n error: \"No extends field found in bos.config.json — cannot determine parent\",\n };\n }\n\n const extendsMatch = extendsRef.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!extendsMatch) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n conflicted: [],\n error: `Invalid extends reference: ${extendsRef}`,\n };\n }\n\n const extendsAccount = extendsMatch[1];\n const extendsGateway = extendsMatch[2];\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n });\n\n try {\n const childPlugins = await getSelectedChildPlugins(projectDir, localConfig);\n const withUi = existsSync(join(projectDir, \"ui\", \"package.json\"));\n const withApi = existsSync(join(projectDir, \"api\", \"package.json\"));\n const withHost = existsSync(join(projectDir, \"host\", \"package.json\"));\n const withPlugins = childPlugins.length > 0 || hasPluginsWorkspace(projectDir);\n\n const childScripts = buildChildRootScripts({\n ui: withUi,\n api: withApi,\n host: withHost,\n plugins: withPlugins,\n });\n\n const destToSource = new Map<string, string>();\n // TS-form children author bos.app.ts — the parent's JSON config must\n // never sync into them.\n const tsFormChild = !existsSync(join(projectDir, \"bos.config.json\"));\n for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {\n if (destPath === \"bos.config.json\" && tsFormChild) continue;\n if (destPath.startsWith(\"ui/\") && !withUi) continue;\n if (destPath.startsWith(\"api/\") && !withApi) continue;\n if (destPath.startsWith(\"host/\") && !withHost) continue;\n const sourcePath = toSourcePath(sourceDir, destPath);\n if (!sourcePath) continue;\n destToSource.set(destPath, sourcePath);\n }\n\n for (const destPath of await glob(AGENT_SYNC_GLOBS, {\n cwd: sourceDir,\n nodir: true,\n dot: true,\n absolute: false,\n ignore: [\"**/node_modules/**\", \"**/.git/**\", \"**/dist/**\", \"**/.bos/**\"],\n })) {\n destToSource.set(destPath, destPath);\n }\n\n // Sync api/src/lib/{auth,context}.ts into each plugin's src/lib/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n for (const libFile of [\"auth.ts\", \"context.ts\"]) {\n const sourceFile = `api/src/lib/${libFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/lib/${libFile}`, sourceFile);\n }\n }\n\n // Sync api/src/global.d.ts into each plugin's src/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n const sourceFile = \"api/src/global.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/global.d.ts`, sourceFile);\n }\n\n // Sync tests/types.d.ts into each plugin's tests/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/tests/types.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/tests/types.d.ts`, sourceFile);\n }\n\n // Sync api/src/db/{index,layer,migrate}.ts into each plugin's src/db/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n for (const dbFile of [\"index.ts\", \"layer.ts\", \"migrate.ts\"]) {\n const sourceFile = `api/src/db/${dbFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/db/${dbFile}`, sourceFile);\n }\n }\n\n // Sync rspack.config.js from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/rspack.config.js\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/rspack.config.js`, sourceFile);\n }\n\n // Sync drizzle.config.ts from api into each DB-enabled plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n const sourceFile = \"api/drizzle.config.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);\n }\n\n // Sync tsconfig from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/tsconfig.json\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/tsconfig.json`, sourceFile);\n }\n\n const updated: string[] = [];\n const skipped: string[] = [];\n const added: string[] = [];\n const conflicted: string[] = [];\n\n const snapshot = await readSnapshot(projectDir);\n const snapshotFiles = snapshot?.files ?? {};\n\n for (const [destPath, filePath] of destToSource.entries()) {\n if (!existsSync(join(sourceDir, filePath))) {\n // The template no longer ships this file — it was retired from the\n // scaffold. Leave the local copy untouched rather than crashing the\n // sync (the old-CLI + new-template transitional combo).\n skipped.push(destPath);\n continue;\n }\n const localHash = computeLocalHash(projectDir, destPath);\n const sourceHash = computeHash(\n buildSyncedFileContent(sourceDir, projectDir, filePath, undefined, childScripts),\n );\n\n if (localHash === null) {\n added.push(destPath);\n continue;\n }\n\n if (localHash === sourceHash) {\n skipped.push(destPath);\n continue;\n }\n\n const snapshotHash = snapshotFiles[destPath];\n if (!snapshotHash) {\n updated.push(destPath);\n continue;\n }\n\n if (localHash === snapshotHash) {\n updated.push(destPath);\n continue;\n }\n\n if (sourceHash === snapshotHash) {\n skipped.push(destPath);\n continue;\n }\n\n conflicted.push(destPath);\n }\n\n const account = (localConfig.account as string) || extendsAccount;\n const domain = (localConfig.domain as string) || extendsGateway;\n const overrides: Array<\"ui\" | \"api\" | \"host\" | \"plugins\"> = [];\n if (withUi) overrides.push(\"ui\");\n if (withApi) overrides.push(\"api\");\n if (withHost) overrides.push(\"host\");\n if (withPlugins) overrides.push(\"plugins\");\n\n if (options.dryRun) {\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n updated.push(\"AGENTS.md\");\n }\n }\n }\n\n const retirement = retireSyncedFiles(projectDir, snapshotFiles, { dryRun: true });\n\n return {\n status: \"dry-run\",\n updated,\n skipped,\n added,\n conflicted,\n retired: retirement.retired,\n retiredConflicted: retirement.retiredConflicted,\n };\n }\n\n // Migrate the child off the retired bootstrap stubs (ADR 0023) before any\n // writes — a retired file is never in destToSource, so its snapshot entry\n // drops out at the next writeSnapshot.\n const retirement = retireSyncedFiles(projectDir, snapshotFiles, { dryRun: false });\n\n const filesToWrite = [...updated, ...added, ...conflicted];\n\n let backupDir: string | undefined = retirement.backupDir ?? undefined;\n if (filesToWrite.length > 0) {\n backupDir = backupFiles(projectDir, filesToWrite) ?? backupDir;\n\n for (const destPath of filesToWrite) {\n const sourcePath = destToSource.get(destPath) ?? destPath;\n writeSyncedFile(sourceDir, projectDir, sourcePath, destPath, childScripts);\n }\n }\n\n await personalizeConfig(projectDir, {\n extendsAccount,\n extendsGateway,\n account,\n domain,\n overrides,\n plugins: childPlugins,\n workspaceOpts: { sourceDir },\n mode: \"sync\",\n existingConfig: localConfig,\n });\n\n await syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n });\n\n const syncedConfig = await openResolution({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n await materializeViaLayer(projectDir, syncedConfig.runtime!);\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const destPath of destToSource.keys()) {\n const hash = computeLocalHash(projectDir, destPath);\n if (hash) {\n newSnapshotFiles[destPath] = hash;\n }\n }\n\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n writeFileSync(join(projectDir, \"AGENTS.md\"), expectedContent);\n updated.push(\"AGENTS.md\");\n }\n\n newSnapshotFiles[\"AGENTS.md\"] = expectedHash;\n }\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\n });\n\n if (!options.noInstall) {\n await runPnpmInstall(findWorkspaceRoot(projectDir)?.dir ?? projectDir);\n await runTypesGen(projectDir);\n }\n\n return {\n status: \"synced\",\n updated,\n skipped,\n added,\n conflicted,\n retired: retirement.retired,\n retiredConflicted: retirement.retiredConflicted,\n retiredBackupDir: retirement.backupDir ?? undefined,\n backupDir,\n };\n } finally {\n await cleanup();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAM,6CAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;AAUD,MAAa,qCAAqB,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,MAAM,mBAAmB;CAAC;CAAqB;CAAkB;AAAkB;AAEnF,SAAgB,yBAAyB,UAA2B;CAClE,IAAI,2BAA2B,IAAI,QAA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"}
|
package/dist/cli/upgrade.cjs
CHANGED
|
@@ -407,13 +407,13 @@ async function migrateBosConfigFiles(projectDir) {
|
|
|
407
407
|
try {
|
|
408
408
|
rootChanged = mergePluginConfigIntoRoot(rootConfig, pluginKey, JSON.parse((0, node_fs.readFileSync)(filePath, "utf-8"))) || rootChanged;
|
|
409
409
|
} catch (e) {
|
|
410
|
-
console.warn(`[Upgrade] Failed to parse plugin config at ${filePath}: ${e}`);
|
|
410
|
+
console.warn(`[Upgrade] Failed to parse plugin config at ${filePath}: ${String(e)}`);
|
|
411
411
|
}
|
|
412
412
|
try {
|
|
413
413
|
(0, node_fs.rmSync)(filePath);
|
|
414
414
|
migrated.push(relativePath);
|
|
415
415
|
} catch (e) {
|
|
416
|
-
console.warn(`[Upgrade] Failed to remove migrated plugin config at ${filePath}: ${e}`);
|
|
416
|
+
console.warn(`[Upgrade] Failed to remove migrated plugin config at ${filePath}: ${String(e)}`);
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
if (rootConfig.plugins && typeof rootConfig.plugins === "object") for (const pluginKey of Object.keys(rootConfig.plugins)) rootChanged = migratePluginProviderConfig(rootConfig, pluginKey) || rootChanged;
|
package/dist/cli/upgrade.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.cjs","names":["findWorkspaceRoot","readJsonFile","join","readWorkspaceCatalog","readAuthoredConfigInput","getExtendsRef","parseBosRef","fetchParentConfig","resolveCatalogChainSource","existsSync","readFileSync","saveBosConfig","process","p","readInstalledFrameworkVersion","statSync","buildChildRootScripts","getParentOnlyScriptKeys","timePhase","syncTemplate","openResolution","MISSING_CONFIG_MESSAGE","syncResolvedSharedDeps","runTypesGen","runPnpmInstallForUpgrade","spawnSync"],"sources":["../../src/cli/upgrade.ts"],"sourcesContent":["import { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync, rmSync, statSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport process from \"node:process\";\nimport * as p from \"@clack/prompts\";\nimport { glob } from \"glob\";\nimport { MISSING_CONFIG_MESSAGE, readAuthoredConfigInput } from \"../config\";\nimport type { PhaseTiming, UpgradeOptions, UpgradeResult } from \"../contract\";\nimport { openResolution } from \"../resolution/session\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { findWorkspaceRoot } from \"../workspace\";\nimport { readWorkspaceCatalog, writeWorkspaceCatalog } from \"../workspace-catalog\";\nimport { readInstalledFrameworkVersion } from \"./framework-version\";\nimport {\n buildChildRootScripts,\n fetchParentConfig,\n getParentOnlyScriptKeys,\n resolveCatalogChainSource,\n runPnpmInstallForUpgrade,\n runTypesGen,\n} from \"./init\";\nimport { syncTemplate } from \"./sync\";\nimport { timePhase } from \"./timing\";\nimport { getExtendsRef, parseBosRef, readJsonFile } from \"./utils/helpers\";\n\nconst FRAMEWORK_PACKAGES = [\"everything-dev\", \"every-plugin\"];\nconst AUTH_CORE_PACKAGE = \"@better-auth/core\";\nconst AUTH_CORE_TRIGGER_PACKAGES = [\n \"better-auth\",\n \"better-near-auth\",\n \"@better-auth/api-key\",\n \"@better-auth/passkey\",\n] as const;\nconst LEGACY_UI_IMPORT_REWRITES = [\n ['from \"@/auth\"', 'from \"@/app\"'],\n [\"from '@/auth'\", \"from '@/app'\"],\n ['from \"@/lib/auth-utils\"', 'from \"@/lib/auth\"'],\n [\"from '@/lib/auth-utils'\", \"from '@/lib/auth'\"],\n ['from \"@/lib/use-api-client\"', 'from \"@/app\"'],\n [\"from '@/lib/use-api-client'\", \"from '@/app'\"],\n ['from \"@/lib/api-client\"', 'from \"@/app\"'],\n [\"from '@/lib/api-client'\", \"from '@/app'\"],\n] as const;\nconst OBSOLETE_FILES = [\n \"api/src/lib/plugins.ts\",\n \"ui/src/auth.ts\",\n \"ui/src/auth-types.gen.ts\",\n \"ui/src/lib/api-client.ts\",\n \"ui/src/lib/use-api-client.ts\",\n \"ui/src/lib/auth-utils.ts\",\n \"ui/src/api-contract.ts\",\n \"ui/src/api-contract.gen.ts\",\n \"ui/src/lib/auth-client.ts\",\n \"ui/src/lib/session.ts\",\n \"ui/scripts/generate-metadata.ts\",\n \".github/dependabot.yml\",\n \".github/templates/dependabot.yml\",\n \".github/workflows/packages-release.yml\",\n \".github/workflows/publish.yml\",\n \".github/workflows/release-sync.yml\",\n \"api/src/db/migrator.ts\",\n \"api/src/db/load-migrations.ts\",\n \"packages/everything-dev/cli.js\",\n \".templatekeep\",\n \".templatesync-exclude\",\n];\n\ninterface ExtendedRootSource {\n catalog: Record<string, string>;\n repository?: string;\n extendsChain: string[];\n}\n\nfunction extractSemver(value: string | undefined): string | null {\n if (!value) return null;\n const match = value.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match?.[0] ?? null;\n}\n\nfunction workspaceDirOf(projectDir: string): string {\n return findWorkspaceRoot(projectDir)?.dir ?? projectDir;\n}\n\nfunction readRootPackageJson(projectDir: string): Record<string, unknown> {\n return readJsonFile<Record<string, unknown>>(join(workspaceDirOf(projectDir), \"package.json\"));\n}\n\nfunction readRootCatalogEntry(projectDir: string, packageName: string): string | undefined {\n return readWorkspaceCatalog(workspaceDirOf(projectDir))[packageName];\n}\n\nfunction readCurrentPackageSpecifier(projectDir: string, packageName: string): string | undefined {\n const pkg = readRootPackageJson(projectDir);\n\n for (const fieldName of [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const) {\n const field = pkg[fieldName] as Record<string, string> | undefined;\n const value = field?.[packageName];\n if (!value) continue;\n\n if (value === \"catalog:\") {\n return (\n readRootCatalogEntry(projectDir, packageName) ??\n readInstalledVersion(projectDir, packageName)\n );\n }\n\n if (value.startsWith(\"workspace:\") || value.startsWith(\"file:\") || value.startsWith(\"link:\")) {\n return readInstalledVersion(projectDir, packageName);\n }\n\n return value;\n }\n\n return (\n readRootCatalogEntry(projectDir, packageName) ?? readInstalledVersion(projectDir, packageName)\n );\n}\n\nfunction setCatalogRefs(\n field: Record<string, string> | undefined,\n packageNames: ReadonlyArray<string>,\n): boolean {\n if (!field) return false;\n\n let modified = false;\n for (const packageName of packageNames) {\n if (setCatalogRef(field, packageName)) {\n modified = true;\n }\n }\n\n return modified;\n}\n\nfunction syncPackageObjectCatalogRefs(\n pkg: Record<string, unknown>,\n packageNames: ReadonlyArray<string>,\n): boolean {\n let modified = false;\n\n for (const fieldName of [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const) {\n const field = pkg[fieldName] as Record<string, string> | undefined;\n if (setCatalogRefs(field, packageNames)) {\n modified = true;\n }\n }\n\n return modified;\n}\n\nfunction findPackageFieldWithAnyDependency(\n pkg: Record<string, unknown>,\n packageNames: ReadonlyArray<string>,\n): Record<string, string> | undefined {\n for (const fieldName of [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const) {\n const field = pkg[fieldName] as Record<string, string> | undefined;\n if (!field) continue;\n if (packageNames.some((packageName) => typeof field[packageName] === \"string\")) {\n return field;\n }\n }\n\n return undefined;\n}\n\nfunction packageObjectNeedsAuthCoreCatalogRef(pkg: Record<string, unknown>): boolean {\n const targetField = findPackageFieldWithAnyDependency(pkg, AUTH_CORE_TRIGGER_PACKAGES);\n if (!targetField) return false;\n\n for (const fieldName of [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const) {\n const field = pkg[fieldName] as Record<string, string> | undefined;\n if (field?.[AUTH_CORE_PACKAGE]) return false;\n }\n\n return true;\n}\n\nfunction ensureAuthCoreCatalogRef(pkg: Record<string, unknown>): boolean {\n if (!packageObjectNeedsAuthCoreCatalogRef(pkg)) return false;\n\n const targetField = findPackageFieldWithAnyDependency(pkg, AUTH_CORE_TRIGGER_PACKAGES);\n if (!targetField) return false;\n\n targetField[AUTH_CORE_PACKAGE] = \"catalog:\";\n return true;\n}\n\nfunction packageObjectNeedsCatalogRefs(\n pkg: Record<string, unknown>,\n packageNames: ReadonlyArray<string>,\n): boolean {\n for (const fieldName of [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const) {\n const field = pkg[fieldName] as Record<string, string> | undefined;\n if (!field) continue;\n\n for (const packageName of packageNames) {\n const value = field[packageName];\n if (!value) continue;\n if (value !== \"catalog:\" && !value.startsWith(\"file:\") && !value.startsWith(\"link:\")) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nfunction packageFileNeedsCatalogRefs(\n filePath: string,\n packageNames: ReadonlyArray<string>,\n): boolean {\n return packageObjectNeedsCatalogRefs(\n readJsonFile<Record<string, unknown>>(filePath),\n packageNames,\n );\n}\n\nfunction updatePackageFileCatalogRefs(\n filePath: string,\n packageNames: ReadonlyArray<string>,\n): boolean {\n const pkg = readJsonFile<Record<string, unknown>>(filePath);\n const modified = syncPackageObjectCatalogRefs(pkg, packageNames);\n\n if (modified) {\n writeFileSync(filePath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return modified;\n}\n\nfunction updatePackageFileAuthCoreRef(filePath: string): boolean {\n const pkg = readJsonFile<Record<string, unknown>>(filePath);\n const modified = ensureAuthCoreCatalogRef(pkg);\n\n if (modified) {\n writeFileSync(filePath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return modified;\n}\n\nfunction syncRootCatalogWithParent(\n projectDir: string,\n parentCatalog: Record<string, string>,\n): boolean {\n const workspaceDir = workspaceDirOf(projectDir);\n const pkgPath = join(workspaceDir, \"package.json\");\n const pkg = readJsonFile<Record<string, unknown>>(pkgPath);\n const modified = syncPackageObjectCatalogRefs(pkg, Object.keys(parentCatalog));\n\n let catalogChanged = false;\n const catalog = readWorkspaceCatalog(workspaceDir);\n for (const [packageName, version] of Object.entries(parentCatalog)) {\n if (catalog[packageName] !== version) {\n catalog[packageName] = version;\n catalogChanged = true;\n }\n }\n if (catalogChanged) {\n writeWorkspaceCatalog(workspaceDir, catalog);\n }\n\n if (modified) {\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return modified || catalogChanged;\n}\n\nasync function readExtendedRootSource(projectDir: string): Promise<ExtendedRootSource> {\n const localConfig = (await readAuthoredConfigInput(projectDir)) as Record<string, unknown> | null;\n if (!localConfig) {\n return { catalog: {}, extendsChain: [] };\n }\n\n let extendsRef = getExtendsRef(localConfig);\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n catalog: {},\n repository: typeof localConfig.repository === \"string\" ? localConfig.repository : undefined,\n extendsChain: [],\n };\n }\n\n const extendsChain: string[] = [];\n const visited = new Set<string>();\n let repository = typeof localConfig.repository === \"string\" ? localConfig.repository : undefined;\n let rootRef = extendsRef;\n\n while (extendsRef?.startsWith(\"bos://\")) {\n if (visited.has(extendsRef)) {\n throw new Error(`Circular extends detected while resolving upgrade source: ${extendsRef}`);\n }\n visited.add(extendsRef);\n extendsChain.push(extendsRef);\n\n const parsed = parseBosRef(extendsRef);\n if (!parsed) {\n break;\n }\n\n rootRef = extendsRef;\n\n let parentConfig: Record<string, unknown>;\n try {\n parentConfig = (await fetchParentConfig(parsed.account, parsed.gateway)) as Record<\n string,\n unknown\n >;\n } catch {\n break;\n }\n\n if (typeof parentConfig.repository === \"string\") {\n repository = parentConfig.repository;\n }\n\n const nextExtendsRef = getExtendsRef(parentConfig);\n if (!nextExtendsRef?.startsWith(\"bos://\")) {\n break;\n }\n\n extendsRef = nextExtendsRef;\n }\n\n const parsed = parseBosRef(rootRef);\n if (!parsed) {\n return { catalog: {}, repository, extendsChain };\n }\n\n const source = await resolveCatalogChainSource({\n extendsAccount: parsed.account,\n extendsGateway: parsed.gateway,\n });\n\n return {\n catalog: source.catalog,\n repository: source.repository ?? repository,\n extendsChain: source.extendsChain.length > 0 ? source.extendsChain : extendsChain,\n };\n}\n\nfunction parseTargetedRef(ref: string): { configRef: string; targetPath?: string } {\n const hashIndex = ref.indexOf(\"#\");\n if (hashIndex === -1) {\n return { configRef: ref };\n }\n return {\n configRef: ref.slice(0, hashIndex),\n targetPath: ref.slice(hashIndex + 1) || undefined,\n };\n}\n\nfunction ensureTargetedRef(ref: string, targetPath: string): string {\n const parsed = parseTargetedRef(ref);\n if (parsed.targetPath) return ref;\n return `${parsed.configRef}#${targetPath}`;\n}\n\nfunction rewriteExtendsTarget(\n entry: Record<string, unknown> | undefined,\n targetPath: string,\n): boolean {\n if (!entry?.extends) return false;\n\n if (typeof entry.extends === \"string\") {\n const next = ensureTargetedRef(entry.extends, targetPath);\n if (next === entry.extends) return false;\n entry.extends = next;\n return true;\n }\n\n if (typeof entry.extends === \"object\") {\n let changed = false;\n for (const [key, value] of Object.entries(entry.extends as Record<string, unknown>)) {\n if (typeof value !== \"string\") continue;\n const next = ensureTargetedRef(value, targetPath);\n if (next !== value) {\n (entry.extends as Record<string, unknown>)[key] = next;\n changed = true;\n }\n }\n return changed;\n }\n\n return false;\n}\n\nfunction migrateRootConfigTargets(config: Record<string, unknown>): boolean {\n let changed = false;\n const app =\n config.app && typeof config.app === \"object\"\n ? (config.app as Record<string, unknown>)\n : undefined;\n\n if (app?.api && typeof app.api === \"object\") {\n changed = rewriteExtendsTarget(app.api as Record<string, unknown>, \"app.api\") || changed;\n }\n if (app?.auth && typeof app.auth === \"object\") {\n changed = rewriteExtendsTarget(app.auth as Record<string, unknown>, \"app.auth\") || changed;\n }\n\n if (config.plugins && typeof config.plugins === \"object\") {\n for (const [pluginKey, pluginValue] of Object.entries(\n config.plugins as Record<string, unknown>,\n )) {\n if (typeof pluginValue === \"string\") {\n const next = ensureTargetedRef(pluginValue, `plugins.${pluginKey}`);\n if (next !== pluginValue) {\n (config.plugins as Record<string, unknown>)[pluginKey] = next;\n changed = true;\n }\n continue;\n }\n if (!pluginValue || typeof pluginValue !== \"object\") continue;\n changed =\n rewriteExtendsTarget(pluginValue as Record<string, unknown>, `plugins.${pluginKey}`) ||\n changed;\n }\n }\n\n return changed;\n}\n\nfunction migratePluginProviderConfig(config: Record<string, unknown>, pluginKey: string): boolean {\n let changed = false;\n if (!config.plugins || typeof config.plugins !== \"object\") {\n return false;\n }\n\n const plugins = config.plugins as Record<string, unknown>;\n const entry = plugins[pluginKey];\n if (!entry || typeof entry !== \"object\") return false;\n\n const pluginEntry = entry as Record<string, unknown>;\n\n if (\"name\" in pluginEntry) {\n delete pluginEntry.name;\n changed = true;\n }\n\n if (typeof pluginEntry.development === \"string\" && pluginEntry.development.startsWith(\"local:\")) {\n if (\"extends\" in pluginEntry) {\n delete pluginEntry.extends;\n changed = true;\n }\n }\n\n changed = rewriteExtendsTarget(pluginEntry, `plugins.${pluginKey}`) || changed;\n\n return changed;\n}\n\nfunction mergePluginConfigIntoRoot(\n rootConfig: Record<string, unknown>,\n pluginKey: string,\n pluginConfig: Record<string, unknown>,\n): boolean {\n let changed = false;\n\n if (!rootConfig.plugins || typeof rootConfig.plugins !== \"object\") {\n rootConfig.plugins = {};\n changed = true;\n }\n const plugins = rootConfig.plugins as Record<string, unknown>;\n if (!plugins[pluginKey] || typeof plugins[pluginKey] !== \"object\") {\n plugins[pluginKey] = {};\n changed = true;\n }\n\n const entry = plugins[pluginKey] as Record<string, unknown>;\n\n const pluginData = extractPluginEntry(pluginConfig, pluginKey);\n\n const apiData = getApiEntry(pluginConfig);\n\n if (pluginData) {\n for (const key of [\n \"secrets\",\n \"variables\",\n \"routes\",\n \"production\",\n \"integrity\",\n \"proxy\",\n ] as const) {\n if (pluginData[key] !== undefined && entry[key] === undefined) {\n entry[key] = pluginData[key];\n changed = true;\n }\n }\n\n if (typeof pluginData.development === \"string\" && pluginData.development.startsWith(\"local:\")) {\n pluginData.development = `local:plugins/${pluginKey}`;\n }\n if (entry.development === undefined && pluginData.development !== undefined) {\n entry.development = pluginData.development;\n changed = true;\n }\n }\n\n if (apiData) {\n for (const key of [\n \"production\",\n \"integrity\",\n \"proxy\",\n \"variables\",\n \"secrets\",\n \"routes\",\n ] as const) {\n if (apiData[key] !== undefined && entry[key] === undefined) {\n entry[key] = apiData[key];\n changed = true;\n }\n }\n }\n\n if (\"extends\" in entry) {\n const extendsStr = typeof entry.extends === \"string\" ? entry.extends : undefined;\n if (!extendsStr || extendsStr.includes(`#plugins.${pluginKey}`)) {\n delete entry.extends;\n changed = true;\n }\n }\n\n if (\"name\" in entry) {\n delete entry.name;\n changed = true;\n }\n\n if (configHasTopLevelFields(pluginConfig, pluginKey)) {\n if (entry.routes === undefined && Array.isArray(pluginConfig.routes)) {\n entry.routes = pluginConfig.routes;\n changed = true;\n }\n const api = getApiEntry(pluginConfig);\n if (api) {\n if (entry.routes === undefined && Array.isArray(api.routes)) {\n entry.routes = api.routes;\n changed = true;\n }\n }\n }\n\n return changed;\n}\n\nfunction extractPluginEntry(\n pluginConfig: Record<string, unknown>,\n pluginKey: string,\n): Record<string, unknown> | null {\n if (\n pluginConfig.plugins &&\n typeof pluginConfig.plugins === \"object\" &&\n (pluginConfig.plugins as Record<string, unknown>)[pluginKey] &&\n typeof (pluginConfig.plugins as Record<string, unknown>)[pluginKey] === \"object\"\n ) {\n return (pluginConfig.plugins as Record<string, unknown>)[pluginKey] as Record<string, unknown>;\n }\n\n if (pluginConfig.routes !== undefined) {\n return { routes: pluginConfig.routes };\n }\n\n return null;\n}\n\nfunction configHasTopLevelFields(\n pluginConfig: Record<string, unknown>,\n _pluginKey: string,\n): boolean {\n return (\n (pluginConfig.routes !== undefined && Array.isArray(pluginConfig.routes)) ||\n getApiEntry(pluginConfig) !== null\n );\n}\n\nfunction getApiEntry(pluginConfig: Record<string, unknown>): Record<string, unknown> | null {\n if (!pluginConfig.app || typeof pluginConfig.app !== \"object\") return null;\n const app = pluginConfig.app as Record<string, unknown>;\n if (!app.api || typeof app.api !== \"object\") return null;\n return app.api as Record<string, unknown>;\n}\n\nexport async function migrateBosConfigFiles(projectDir: string): Promise<string[]> {\n const migrated: string[] = [];\n const rootConfigPath = join(projectDir, \"bos.config.json\");\n\n if (existsSync(rootConfigPath)) {\n const rootConfig = JSON.parse(readFileSync(rootConfigPath, \"utf-8\")) as Record<string, unknown>;\n let rootChanged = migrateRootConfigTargets(rootConfig);\n\n const pluginConfigPaths = await glob(\"plugins/*/bos.config.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n });\n\n for (const relativePath of pluginConfigPaths) {\n const match = relativePath.match(/^plugins\\/([^/]+)\\/bos\\.config\\.json$/);\n const pluginKey = match?.[1];\n if (!pluginKey) continue;\n\n const filePath = join(projectDir, relativePath);\n try {\n const pluginConfig = JSON.parse(readFileSync(filePath, \"utf-8\")) as Record<string, unknown>;\n rootChanged = mergePluginConfigIntoRoot(rootConfig, pluginKey, pluginConfig) || rootChanged;\n } catch (e) {\n console.warn(`[Upgrade] Failed to parse plugin config at ${filePath}: ${e}`);\n }\n\n try {\n rmSync(filePath);\n migrated.push(relativePath);\n } catch (e) {\n console.warn(`[Upgrade] Failed to remove migrated plugin config at ${filePath}: ${e}`);\n }\n }\n\n if (rootConfig.plugins && typeof rootConfig.plugins === \"object\") {\n for (const pluginKey of Object.keys(rootConfig.plugins as Record<string, unknown>)) {\n rootChanged = migratePluginProviderConfig(rootConfig, pluginKey) || rootChanged;\n }\n }\n\n if (rootChanged || migrated.length > 0) {\n await saveBosConfig(projectDir, rootConfig);\n if (!migrated.includes(\"bos.config.json\")) {\n migrated.push(\"bos.config.json\");\n }\n }\n }\n\n return migrated;\n}\n\nasync function loadParentPluginOptions(projectDir: string): Promise<{\n localConfig: Record<string, unknown>;\n parentPlugins: Record<string, unknown>;\n newPluginKeys: string[];\n} | null> {\n const localConfig = (await readAuthoredConfigInput(projectDir)) as Record<string, unknown> | null;\n if (!localConfig) {\n return null;\n }\n const extendsRef = getExtendsRef(localConfig);\n if (!extendsRef?.startsWith(\"bos://\")) {\n return null;\n }\n\n const parsed = parseBosRef(extendsRef);\n if (!parsed) {\n return null;\n }\n\n let parentConfig: Record<string, unknown>;\n try {\n parentConfig = await fetchParentConfig(parsed.account, parsed.gateway);\n } catch {\n return null;\n }\n\n const parentPlugins =\n parentConfig.plugins && typeof parentConfig.plugins === \"object\"\n ? (parentConfig.plugins as Record<string, unknown>)\n : {};\n const localPlugins =\n localConfig.plugins && typeof localConfig.plugins === \"object\"\n ? (localConfig.plugins as Record<string, unknown>)\n : {};\n\n const newPluginKeys = Object.keys(parentPlugins).filter((key) => !(key in localPlugins));\n return { localConfig, parentPlugins, newPluginKeys };\n}\n\nasync function addSelectedParentPlugins(projectDir: string): Promise<string[]> {\n if (!process.stdin.isTTY || !process.stdout.isTTY) {\n return [];\n }\n\n const pluginOptions = await loadParentPluginOptions(projectDir);\n if (!pluginOptions || pluginOptions.newPluginKeys.length === 0) {\n return [];\n }\n\n const selectedValue = await p.multiselect({\n message: \"Select new plugins from parent:\",\n options: pluginOptions.newPluginKeys.map((key) => ({ value: key, label: key })),\n required: false,\n });\n\n if (p.isCancel(selectedValue)) {\n process.exit(0);\n }\n\n const selected = selectedValue as string[];\n if (selected.length === 0) {\n return [];\n }\n\n const localPlugins =\n pluginOptions.localConfig.plugins && typeof pluginOptions.localConfig.plugins === \"object\"\n ? (pluginOptions.localConfig.plugins as Record<string, unknown>)\n : {};\n const nextPlugins = { ...localPlugins };\n for (const key of selected) {\n const parentPlugin = pluginOptions.parentPlugins[key];\n if (parentPlugin && typeof parentPlugin === \"object\") {\n const nextPlugin = structuredClone(parentPlugin as Record<string, unknown>);\n rewriteExtendsTarget(nextPlugin, `plugins.${key}`);\n nextPlugins[key] = nextPlugin;\n } else if (typeof parentPlugin === \"string\") {\n nextPlugins[key] = ensureTargetedRef(parentPlugin, `plugins.${key}`);\n } else {\n nextPlugins[key] = parentPlugin;\n }\n }\n\n pluginOptions.localConfig.plugins = nextPlugins;\n await saveBosConfig(projectDir, pluginOptions.localConfig);\n\n return selected;\n}\n\nfunction readInstalledVersion(projectDir: string, packageName: string): string | undefined {\n return readInstalledFrameworkVersion(projectDir, packageName);\n}\n\nfunction setCatalogRef(field: Record<string, string> | undefined, packageName: string): boolean {\n if (!field || !(packageName in field)) return false;\n if (field[packageName] === \"catalog:\" || field[packageName].startsWith(\"file:\")) return false;\n field[packageName] = \"catalog:\";\n return true;\n}\n\nasync function findWorkspacePackageJsons(projectDir: string): Promise<string[]> {\n const root = findWorkspaceRoot(projectDir);\n if (!root) return [];\n\n const pkgPaths: string[] = [];\n for (const member of root.members) {\n const pkgPath = join(member.dir, \"package.json\");\n if (existsSync(pkgPath) && statSync(pkgPath).isFile()) {\n pkgPaths.push(pkgPath);\n }\n }\n\n return [...new Set(pkgPaths)];\n}\n\nexport async function migrateChildRootPackageJson(projectDir: string): Promise<boolean> {\n const config = (await readAuthoredConfigInput(projectDir)) as Record<string, unknown> | null;\n const pkgPath = join(workspaceDirOf(projectDir), \"package.json\");\n if (!config || !existsSync(pkgPath)) {\n return false;\n }\n\n const extendsRef = getExtendsRef(config);\n if (!extendsRef?.startsWith(\"bos://\")) {\n return false;\n }\n\n const pkg = readJsonFile<Record<string, unknown>>(pkgPath);\n let changed = false;\n\n if (pkg.private !== true) {\n pkg.private = true;\n changed = true;\n }\n if (pkg.type !== \"module\") {\n pkg.type = \"module\";\n changed = true;\n }\n if (\"module\" in pkg) {\n delete pkg.module;\n changed = true;\n }\n\n const pluginPackageJsons = await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n });\n const childScripts = buildChildRootScripts({\n ui: existsSync(join(projectDir, \"ui\", \"package.json\")),\n api: existsSync(join(projectDir, \"api\", \"package.json\")),\n host: existsSync(join(projectDir, \"host\", \"package.json\")),\n plugins: pluginPackageJsons.length > 0,\n });\n\n if (!pkg.scripts || typeof pkg.scripts !== \"object\") {\n pkg.scripts = {};\n changed = true;\n }\n const scripts = pkg.scripts as Record<string, string>;\n for (const [key, value] of Object.entries(childScripts)) {\n if (scripts[key] !== value) {\n scripts[key] = value;\n changed = true;\n }\n }\n for (const obsoleteScript of [...getParentOnlyScriptKeys(projectDir), \"sync-catalog\", \"init\"]) {\n if (obsoleteScript in scripts) {\n delete scripts[obsoleteScript];\n changed = true;\n }\n }\n\n const workspaces = pkg.workspaces;\n if (workspaces && typeof workspaces === \"object\") {\n const workspaceConfig = workspaces as { packages?: string[] };\n if (Array.isArray(workspaceConfig.packages)) {\n const nextPackages = workspaceConfig.packages.filter(\n (entry) => entry !== \"packages/everything-dev\" && entry !== \"packages/every-plugin\",\n );\n if (nextPackages.length !== workspaceConfig.packages.length) {\n workspaceConfig.packages = nextPackages;\n changed = true;\n }\n }\n }\n\n if (pkg.overrides && typeof pkg.overrides === \"object\") {\n const overrides = pkg.overrides as Record<string, string>;\n for (const packageName of FRAMEWORK_PACKAGES) {\n const value = overrides[packageName];\n if (typeof value === \"string\" && value.startsWith(\"file:packages/\")) {\n delete overrides[packageName];\n changed = true;\n }\n }\n if (Object.keys(overrides).length === 0) {\n delete pkg.overrides;\n changed = true;\n }\n }\n\n if (ensureAuthCoreCatalogRef(pkg)) {\n changed = true;\n }\n\n const workspacePackageJsons = await findWorkspacePackageJsons(projectDir);\n for (const workspacePkgPath of workspacePackageJsons) {\n if (updatePackageFileAuthCoreRef(workspacePkgPath)) {\n changed = true;\n }\n }\n\n if (changed) {\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return changed;\n}\n\nfunction buildChangelogUrl(\n oldVersion: string | undefined,\n newVersion: string,\n repository: string | undefined,\n): string | undefined {\n const fromVersion = extractSemver(oldVersion);\n const toVersion = extractSemver(newVersion);\n if (!fromVersion || !toVersion || fromVersion === toVersion) return undefined;\n\n const repoUrl = repository;\n if (!repoUrl) return undefined;\n\n const githubMatch = repoUrl.match(/^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?$/);\n if (!githubMatch) return undefined;\n\n const [, owner, repo] = githubMatch;\n return `https://github.com/${owner}/${repo}/compare/v${fromVersion}...v${toVersion}`;\n}\n\nasync function rewriteLegacyUiImports(projectDir: string): Promise<string[]> {\n const files = await glob(\"ui/src/**/*.{ts,tsx}\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n });\n const migrated: string[] = [];\n\n for (const file of files) {\n const filePath = join(projectDir, file);\n const original = readFileSync(filePath, \"utf-8\");\n let next = original;\n\n for (const [from, to] of LEGACY_UI_IMPORT_REWRITES) {\n next = next.replaceAll(from, to);\n }\n\n if (next !== original) {\n writeFileSync(filePath, next);\n migrated.push(file);\n }\n }\n\n return migrated;\n}\n\nconst LEGACY_DIST_IMPORT_REWRITES = [\n ['from \"everything-dev/dist/', 'from \"everything-dev/'],\n [\"from 'everything-dev/dist/\", \"from 'everything-dev/\"],\n] as const;\n\nfunction escapeRegex(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction balancedParenEnd(source: string, openIdx: number): number {\n let depth = 1;\n let i = openIdx;\n while (i < source.length) {\n const ch = source[i];\n if (ch === \"(\") depth++;\n else if (ch === \")\") {\n depth--;\n if (depth === 0) return i;\n }\n i++;\n }\n return -1;\n}\n\nfunction deriveTagFromLayerExpr(layerExpr: string): string | null {\n const m = layerExpr.match(/^\\s*([A-Z]\\w*)/);\n if (!m) return null;\n const name = m[1];\n if (name.endsWith(\"Live\")) return `${name.slice(0, -4)}Tag`;\n if (name.endsWith(\"Layer\")) return `${name.slice(0, -5)}Tag`;\n return null;\n}\n\ntype PipeProvideCall = {\n argStart: number;\n endIdx: number;\n dotIdx: number;\n pipeCloseEnd: number;\n};\n\nfunction findAllPipeEffectProvideCalls(source: string): PipeProvideCall[] {\n const out: PipeProvideCall[] = [];\n const needle = \"Effect.provide(\";\n let searchFrom = 0;\n while (true) {\n const provideIdx = source.indexOf(needle, searchFrom);\n if (provideIdx === -1) break;\n const argStart = provideIdx + needle.length;\n const endIdx = balancedParenEnd(source, argStart);\n if (endIdx === -1) {\n searchFrom = argStart;\n continue;\n }\n let p = provideIdx - 1;\n while (p >= 0 && /\\s/.test(source[p])) p--;\n if (p < 0 || source[p] !== \"(\") {\n searchFrom = endIdx + 1;\n continue;\n }\n p--;\n const pipeWord = \".pipe\";\n if (p - pipeWord.length + 1 < 0 || source.slice(p - pipeWord.length + 1, p + 1) !== pipeWord) {\n searchFrom = endIdx + 1;\n continue;\n }\n const dotIdx = p - pipeWord.length + 1;\n let q = endIdx + 1;\n while (q < source.length && /\\s/.test(source[q])) q++;\n if (q < source.length && source[q] === \",\") q++;\n while (q < source.length && /\\s/.test(source[q])) q++;\n if (q >= source.length || source[q] !== \")\") {\n searchFrom = endIdx + 1;\n continue;\n }\n out.push({ argStart, endIdx, dotIdx, pipeCloseEnd: q + 1 });\n searchFrom = q + 1;\n }\n return out;\n}\n\nfunction rewritePipeEffectProvideForm(source: string, relPath: string): string {\n const calls = findAllPipeEffectProvideCalls(source);\n if (calls.length === 0) return source;\n\n let result = source;\n\n for (let k = calls.length - 1; k >= 0; k--) {\n const call = calls[k];\n const layerExpr = result.slice(call.argStart, call.endIdx).trim();\n const tagName = deriveTagFromLayerExpr(layerExpr);\n if (!tagName) {\n console.warn(\n `[Upgrade] ${relPath}: found .pipe(Effect.provide(${layerExpr})) but could not derive a tag name — skipping. Migrate manually to Layer.buildWithScope(${layerExpr}, yield* Effect.scope) + Context.get.`,\n );\n continue;\n }\n const tagUseRe = new RegExp(`(yield\\\\*\\\\s+)${escapeRegex(tagName)}(\\\\s*;?)`, \"g\");\n const tagMatches = [...result.matchAll(tagUseRe)];\n if (tagMatches.length !== 1) {\n console.warn(\n `[Upgrade] ${relPath}: found .pipe(Effect.provide(${layerExpr})) expecting a single \\`yield* ${tagName}\\`, but found ${tagMatches.length} — skipping. Migrate manually.`,\n );\n continue;\n }\n const tm = tagMatches[0];\n const tagStart = tm.index ?? -1;\n if (tagStart < 0) continue;\n const tagLen = tm[0].length;\n const replacement =\n `${tm[1]}Layer.buildWithScope(${layerExpr}, yield* Effect.scope)` +\n `.pipe(Effect.map((context) => Context.get(context, ${tagName})))${tm[2]}`;\n if (tagStart < call.dotIdx) {\n result =\n result.slice(0, tagStart) +\n replacement +\n result.slice(tagStart + tagLen, call.dotIdx) +\n result.slice(call.pipeCloseEnd);\n } else {\n result =\n result.slice(0, call.dotIdx) +\n result.slice(call.pipeCloseEnd, tagStart) +\n replacement +\n result.slice(tagStart + tagLen);\n }\n }\n\n return result;\n}\n\nfunction rewriteTwoArgEffectProvideForm(source: string, relPath: string): string {\n const matches = [...source.matchAll(/\\byield\\*\\s*Effect\\.provide\\(/g)];\n if (matches.length === 0) return source;\n\n let result = source;\n\n for (let k = matches.length - 1; k >= 0; k--) {\n const m = matches[k];\n const openIdx = (m.index ?? -1) + m[0].length - 1;\n if (openIdx < 0) continue;\n const closeIdx = balancedParenEnd(source, openIdx + 1);\n if (closeIdx === -1) continue;\n\n const inner = source.slice(openIdx + 1, closeIdx);\n const commaIdx = findTopLevelComma(inner);\n if (commaIdx === -1) {\n console.warn(\n `[Upgrade] ${relPath}: found \\`yield* Effect.provide(...)\\` without a top-level Tag, Layer argument pair — skipping. Migrate manually to Layer.buildWithScope + Context.get.`,\n );\n continue;\n }\n\n const tagExpr = inner.slice(0, commaIdx).trim();\n const layerExpr = inner.slice(commaIdx + 1).trim();\n const prefix = m[0].replace(/Effect\\.provide\\($/, \"\");\n const replacement =\n `${prefix}Layer.buildWithScope(${layerExpr}, yield* Effect.scope)` +\n `.pipe(Effect.map((context) => Context.get(context, ${tagExpr})))`;\n result = result.slice(0, m.index) + replacement + result.slice(closeIdx + 1);\n }\n\n return result;\n}\n\nfunction findTopLevelComma(inner: string): number {\n let depth = 0;\n for (let i = 0; i < inner.length; i++) {\n const ch = inner[i];\n if (ch === \"(\" || ch === \"[\" || ch === \"{\") depth++;\n else if (ch === \")\" || ch === \"]\" || ch === \"}\") depth--;\n else if (ch === \",\" && depth === 0) return i;\n }\n return -1;\n}\n\nfunction ensureEffectImports(source: string): string {\n const m = source.match(/import\\s*\\{([^}]*)\\}\\s*from\\s*[\"']every-plugin\\/effect[\"']/);\n if (!m) return source;\n const names = m[1]\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean);\n if (!names.includes(\"Context\")) names.push(\"Context\");\n if (!names.includes(\"Layer\")) names.push(\"Layer\");\n names.sort((a, b) => a.localeCompare(b));\n return source.replace(m[0], `import { ${names.join(\", \")} } from \"effect\"`);\n}\n\nexport async function rewriteLegacyPluginScopedLayerPatterns(\n projectDir: string,\n): Promise<string[]> {\n const files = await glob([\"plugins/*/src/index.ts\", \"api/src/index.ts\"], {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n });\n\n if (files.length === 0) return [];\n\n const migrated: string[] = [];\n\n for (const file of files) {\n const filePath = join(projectDir, file);\n const original = readFileSync(filePath, \"utf-8\");\n let next = original;\n\n // Rewrite yield* Effect.provide(Tag, LayerExpr) → Layer.buildWithScope + Context.get\n next = rewriteTwoArgEffectProvideForm(next, file);\n\n // Rewrite the .pipe(Effect.provide(<LayerExpr>)) form: move <LayerExpr> into a\n // Layer.buildWithScope(...) + Context.get call replacing the bare `yield* <Tag>`\n // inside the generator, and drop the trailing .pipe(Effect.provide(...)).\n next = rewritePipeEffectProvideForm(next, file);\n\n if (next !== original) {\n next = ensureEffectImports(next);\n writeFileSync(filePath, next);\n migrated.push(file);\n }\n }\n\n return migrated;\n}\n\nexport async function rewriteLegacyDistImports(projectDir: string): Promise<string[]> {\n const files = await glob(\"**/*.{ts,tsx,js,jsx,mjs,cjs}\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n ignore: [\"node_modules/**\", \"dist/**\"],\n });\n\n const migrated: string[] = [];\n\n for (const file of files) {\n const filePath = join(projectDir, file);\n const original = readFileSync(filePath, \"utf-8\");\n let next = original;\n\n for (const [from, to] of LEGACY_DIST_IMPORT_REWRITES) {\n next = next.replaceAll(from, to);\n }\n\n if (next !== original) {\n writeFileSync(filePath, next);\n migrated.push(file);\n }\n }\n\n return migrated;\n}\n\nasync function runMigrationPhase(\n projectDir: string,\n options: UpgradeOptions,\n parentSource: ExtendedRootSource,\n): Promise<UpgradeResult> {\n const timings: PhaseTiming[] = [];\n\n const migratedBosConfigs = await timePhase(timings, \"migrate bos configs\", () =>\n migrateBosConfigFiles(projectDir),\n );\n const migratedRootPackageJson = await timePhase(timings, \"migrate root package\", () =>\n migrateChildRootPackageJson(projectDir),\n );\n\n let syncResult: UpgradeResult[\"sync\"];\n let addedPlugins: string[] = [];\n if (!options.noSync && parentSource.extendsChain.length > 0) {\n addedPlugins = await timePhase(timings, \"discover parent plugins\", async () => {\n if (options.dryRun) return [];\n return addSelectedParentPlugins(projectDir);\n });\n\n syncResult = await timePhase(timings, \"sync template\", () =>\n syncTemplate(projectDir, {\n dryRun: false,\n noInstall: true,\n json: false,\n }),\n );\n }\n\n await timePhase(timings, \"sync shared deps\", async () => {\n const configSession = await openResolution({ cwd: projectDir });\n if (!configSession?.config) {\n throw new Error(`${MISSING_CONFIG_MESSAGE} in current directory`);\n }\n\n return syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n bosConfig: configSession.config,\n });\n });\n\n if (!options.noInstall) {\n await timePhase(timings, \"generate types\", () => runTypesGen(projectDir));\n }\n\n const migratedFiles = await timePhase(timings, \"clean obsolete files\", async () => {\n const nextMigratedFiles = [\n ...migratedBosConfigs,\n ...(migratedRootPackageJson ? [\"package.json\"] : []),\n ...(await rewriteLegacyUiImports(projectDir)),\n ...(await rewriteLegacyPluginScopedLayerPatterns(projectDir)),\n ...(await rewriteLegacyDistImports(projectDir)),\n ];\n for (const file of OBSOLETE_FILES) {\n const filePath = join(projectDir, file);\n if (existsSync(filePath)) {\n rmSync(filePath);\n nextMigratedFiles.push(file);\n }\n }\n\n const legacyPluginDbFiles = await glob(\"plugins/*/src/db/{migrator,load-migrations}.ts\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n });\n for (const file of legacyPluginDbFiles) {\n rmSync(join(projectDir, file));\n nextMigratedFiles.push(file);\n }\n\n return nextMigratedFiles;\n });\n\n let changelogUrl: string | undefined;\n const mainPkg = parentSource.catalog[\"everything-dev\"];\n if (mainPkg) {\n changelogUrl = buildChangelogUrl(undefined, mainPkg, parentSource.repository);\n }\n\n return {\n status: \"upgraded\",\n packages: [],\n sync: syncResult,\n migrated: migratedFiles.length > 0 ? migratedFiles : undefined,\n selectedPlugins: addedPlugins.length > 0 ? addedPlugins : undefined,\n timings,\n changelogUrl,\n };\n}\n\nexport async function upgradeTemplate(\n projectDir: string,\n options: UpgradeOptions,\n): Promise<UpgradeResult> {\n const timings: PhaseTiming[] = [];\n const pkgPath = join(workspaceDirOf(projectDir), \"package.json\");\n if (!existsSync(pkgPath)) {\n return {\n status: \"error\",\n packages: [],\n timings,\n error: \"No package.json found in current directory\",\n };\n }\n\n const parentSource = await readExtendedRootSource(projectDir);\n const sourceRootCatalog = parentSource.catalog;\n const inheritedCatalogPackageNames = Object.keys(sourceRootCatalog);\n const currentRootCatalog = readRootPackageJson(projectDir) as {\n workspaces?: { catalog?: Record<string, string> };\n };\n const currentCatalogEntries = currentRootCatalog.workspaces?.catalog ?? {};\n const workspacePkgPaths = await findWorkspacePackageJsons(projectDir);\n const hasCatalogRefRewrites =\n inheritedCatalogPackageNames.length > 0 &&\n (packageObjectNeedsCatalogRefs(readRootPackageJson(projectDir), inheritedCatalogPackageNames) ||\n workspacePkgPaths.some((pkgPath) =>\n packageFileNeedsCatalogRefs(pkgPath, inheritedCatalogPackageNames),\n ));\n const hasAuthCoreRefRewrites =\n packageObjectNeedsAuthCoreCatalogRef(readRootPackageJson(projectDir)) ||\n workspacePkgPaths.some((pkgPath) =>\n packageObjectNeedsAuthCoreCatalogRef(readJsonFile<Record<string, unknown>>(pkgPath)),\n );\n\n const { packages, catalogVersionUpdates } = await timePhase(\n timings,\n \"check package versions\",\n async () => {\n const nextPackages: UpgradeResult[\"packages\"] = [];\n\n for (const name of FRAMEWORK_PACKAGES) {\n const current = readCurrentPackageSpecifier(projectDir, name);\n const target = sourceRootCatalog[name] ?? current ?? \"unknown\";\n\n nextPackages.push({ name, from: current, to: target });\n }\n\n const nextCatalogVersionUpdates: Array<{\n name: string;\n from: string | undefined;\n to: string;\n }> = [];\n for (const [name, targetVersion] of Object.entries(sourceRootCatalog)) {\n if (FRAMEWORK_PACKAGES.includes(name)) continue;\n\n const currentVersion = currentCatalogEntries[name];\n if (currentVersion === targetVersion) continue;\n nextCatalogVersionUpdates.push({ name, from: currentVersion, to: targetVersion });\n }\n\n return { packages: nextPackages, catalogVersionUpdates: nextCatalogVersionUpdates };\n },\n );\n\n const hasFrameworkUpdates = packages.some((p) => p.from !== p.to && p.from !== undefined);\n const hasCatalogUpdates = catalogVersionUpdates.length > 0;\n const hasUpdates =\n hasFrameworkUpdates || hasCatalogUpdates || hasCatalogRefRewrites || hasAuthCoreRefRewrites;\n\n if (options.dryRun) {\n let changelogUrl: string | undefined;\n const pluginOptions = options.noSync\n ? null\n : await timePhase(timings, \"discover parent plugins\", () =>\n loadParentPluginOptions(projectDir),\n );\n if (hasUpdates) {\n const mainPkg = packages.find((p) => p.name === \"everything-dev\");\n if (mainPkg?.from && mainPkg.from !== mainPkg.to) {\n changelogUrl = buildChangelogUrl(mainPkg.from, mainPkg.to, parentSource.repository);\n }\n }\n\n return {\n status: \"dry-run\",\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n availablePlugins: pluginOptions?.newPluginKeys,\n timings,\n changelogUrl,\n };\n }\n\n if (options.migrationsOnly) {\n return await runMigrationPhase(projectDir, options, parentSource);\n }\n\n // Phase 1: apply package updates, install, then re-exec migrations from the new package\n await timePhase(timings, \"apply package updates\", async () => {\n if (inheritedCatalogPackageNames.length > 0) {\n syncRootCatalogWithParent(projectDir, sourceRootCatalog);\n }\n\n if (inheritedCatalogPackageNames.length > 0) {\n for (const pkgPath of workspacePkgPaths) {\n updatePackageFileCatalogRefs(pkgPath, inheritedCatalogPackageNames);\n }\n }\n });\n\n const needsInstall = (hasUpdates || hasCatalogUpdates) && !options.noInstall;\n\n if (needsInstall) {\n await timePhase(timings, \"install dependencies\", () =>\n runPnpmInstallForUpgrade(workspaceDirOf(projectDir)),\n );\n }\n\n // If we installed new framework packages, re-exec from the new package so migrations\n // run with the latest code instead of the old cached modules.\n if (needsInstall && hasFrameworkUpdates) {\n const bosPath = join(workspaceDirOf(projectDir), \"node_modules\", \".bin\", \"bos\");\n const childArgs = [\n \"upgrade\",\n \"--migrations-only\",\n \"--no-install\",\n ...(options.noSync ? [\"--no-sync\"] : []),\n \"--json\",\n ];\n\n const childResult = spawnSync(bosPath, childArgs, {\n cwd: projectDir,\n stdio: [\"inherit\", \"pipe\", \"pipe\"],\n encoding: \"utf-8\",\n env: { ...process.env, BOS_NO_BANNER: \"1\" },\n });\n\n if (childResult.status !== 0) {\n return {\n status: \"error\",\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n timings,\n error: `Migration phase failed: ${childResult.stderr || childResult.stdout || \"Unknown error\"}`,\n };\n }\n\n try {\n const childUpgrade: UpgradeResult = JSON.parse(childResult.stdout);\n const mainPkg = packages.find((p) => p.name === \"everything-dev\");\n const changelogUrl =\n mainPkg?.from && mainPkg.from !== mainPkg.to\n ? buildChangelogUrl(mainPkg.from, mainPkg.to, parentSource.repository)\n : undefined;\n return {\n ...childUpgrade,\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n timings: [...timings, ...(childUpgrade.timings ?? [])],\n changelogUrl,\n };\n } catch {\n return {\n status: \"error\",\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n timings,\n error: \"Failed to parse migration phase output\",\n };\n }\n }\n\n // No framework version change: run migrations inline (same-package, no re-exec needed)\n // runMigrationPhase handles types gen internally — no separate runTypesGen call needed here.\n\n const migrationResult = await runMigrationPhase(projectDir, options, parentSource);\n const mainPkg = packages.find((p) => p.name === \"everything-dev\");\n const changelogUrl =\n mainPkg?.from && mainPkg.from !== mainPkg.to\n ? buildChangelogUrl(mainPkg.from, mainPkg.to, parentSource.repository)\n : undefined;\n return {\n ...migrationResult,\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n timings: [...timings, ...(migrationResult.timings ?? [])],\n changelogUrl,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,qBAAqB,CAAC,kBAAkB,cAAc;AAC5D,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;CACjC;CACA;CACA;CACA;AACF;AACA,MAAM,4BAA4B;CAChC,CAAC,mBAAiB,gBAAc;CAChC,CAAC,iBAAiB,cAAc;CAChC,CAAC,6BAA2B,qBAAmB;CAC/C,CAAC,2BAA2B,mBAAmB;CAC/C,CAAC,iCAA+B,gBAAc;CAC9C,CAAC,+BAA+B,cAAc;CAC9C,CAAC,6BAA2B,gBAAc;CAC1C,CAAC,2BAA2B,cAAc;AAC5C;AACA,MAAM,iBAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAQA,SAAS,cAAc,OAA0C;CAC/D,IAAI,CAAC,OAAO,OAAO;CAEnB,OADc,MAAM,MAAM,mCACf,CAAC,GAAG,MAAM;AACvB;AAEA,SAAS,eAAe,YAA4B;CAClD,OAAOA,oCAAkB,UAAU,CAAC,EAAE,OAAO;AAC/C;AAEA,SAAS,oBAAoB,YAA6C;CACxE,OAAOC,iCAAsCC,gBAAK,eAAe,UAAU,GAAG,cAAc,CAAC;AAC/F;AAEA,SAAS,qBAAqB,YAAoB,aAAyC;CACzF,OAAOC,+CAAqB,eAAe,UAAU,CAAC,CAAC,CAAC;AAC1D;AAEA,SAAS,4BAA4B,YAAoB,aAAyC;CAChG,MAAM,MAAM,oBAAoB,UAAU;CAE1C,KAAK,MAAM,aAAa;EAAC;EAAgB;EAAmB;CAAkB,GAAY;EAExF,MAAM,QADQ,IAAI,UACC,GAAG;EACtB,IAAI,CAAC,OAAO;EAEZ,IAAI,UAAU,YACZ,OACE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,eACJ,SAAS,QAAQ,QAAQ,SAAS,QAAQ,KACtC,kBAAkB,QAAQ,MAAM,QAAQ,IAAI,aAAa,UAAU,IACnE;CACN,OAAO;EACL,GAAG;EACH,UAAU,CACR,GAAG,UACH,GAAG,sBAAsB,KAAK,OAAO;GAAE,MAAM,EAAE;GAAM,MAAM,EAAE;GAAM,IAAI,EAAE;EAAG,EAAE,CAChF;EACA,SAAS,CAAC,GAAG,SAAS,GAAI,gBAAgB,WAAW,CAAC,CAAE;EACxD;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"upgrade.cjs","names":["findWorkspaceRoot","readJsonFile","join","readWorkspaceCatalog","readAuthoredConfigInput","getExtendsRef","parseBosRef","fetchParentConfig","resolveCatalogChainSource","existsSync","readFileSync","saveBosConfig","process","p","readInstalledFrameworkVersion","statSync","buildChildRootScripts","getParentOnlyScriptKeys","timePhase","syncTemplate","openResolution","MISSING_CONFIG_MESSAGE","syncResolvedSharedDeps","runTypesGen","runPnpmInstallForUpgrade","spawnSync"],"sources":["../../src/cli/upgrade.ts"],"sourcesContent":["import { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync, rmSync, statSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport process from \"node:process\";\nimport * as p from \"@clack/prompts\";\nimport { glob } from \"glob\";\nimport { MISSING_CONFIG_MESSAGE, readAuthoredConfigInput } from \"../config\";\nimport type { PhaseTiming, UpgradeOptions, UpgradeResult } from \"../contract\";\nimport { openResolution } from \"../resolution/session\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { findWorkspaceRoot } from \"../workspace\";\nimport { readWorkspaceCatalog, writeWorkspaceCatalog } from \"../workspace-catalog\";\nimport { readInstalledFrameworkVersion } from \"./framework-version\";\nimport {\n buildChildRootScripts,\n fetchParentConfig,\n getParentOnlyScriptKeys,\n resolveCatalogChainSource,\n runPnpmInstallForUpgrade,\n runTypesGen,\n} from \"./init\";\nimport { syncTemplate } from \"./sync\";\nimport { timePhase } from \"./timing\";\nimport { getExtendsRef, parseBosRef, readJsonFile } from \"./utils/helpers\";\n\nconst FRAMEWORK_PACKAGES = [\"everything-dev\", \"every-plugin\"];\nconst AUTH_CORE_PACKAGE = \"@better-auth/core\";\nconst AUTH_CORE_TRIGGER_PACKAGES = [\n \"better-auth\",\n \"better-near-auth\",\n \"@better-auth/api-key\",\n \"@better-auth/passkey\",\n] as const;\nconst LEGACY_UI_IMPORT_REWRITES = [\n ['from \"@/auth\"', 'from \"@/app\"'],\n [\"from '@/auth'\", \"from '@/app'\"],\n ['from \"@/lib/auth-utils\"', 'from \"@/lib/auth\"'],\n [\"from '@/lib/auth-utils'\", \"from '@/lib/auth'\"],\n ['from \"@/lib/use-api-client\"', 'from \"@/app\"'],\n [\"from '@/lib/use-api-client'\", \"from '@/app'\"],\n ['from \"@/lib/api-client\"', 'from \"@/app\"'],\n [\"from '@/lib/api-client'\", \"from '@/app'\"],\n] as const;\nconst OBSOLETE_FILES = [\n \"api/src/lib/plugins.ts\",\n \"ui/src/auth.ts\",\n \"ui/src/auth-types.gen.ts\",\n \"ui/src/lib/api-client.ts\",\n \"ui/src/lib/use-api-client.ts\",\n \"ui/src/lib/auth-utils.ts\",\n \"ui/src/api-contract.ts\",\n \"ui/src/api-contract.gen.ts\",\n \"ui/src/lib/auth-client.ts\",\n \"ui/src/lib/session.ts\",\n \"ui/scripts/generate-metadata.ts\",\n \".github/dependabot.yml\",\n \".github/templates/dependabot.yml\",\n \".github/workflows/packages-release.yml\",\n \".github/workflows/publish.yml\",\n \".github/workflows/release-sync.yml\",\n \"api/src/db/migrator.ts\",\n \"api/src/db/load-migrations.ts\",\n \"packages/everything-dev/cli.js\",\n \".templatekeep\",\n \".templatesync-exclude\",\n];\n\ninterface ExtendedRootSource {\n catalog: Record<string, string>;\n repository?: string;\n extendsChain: string[];\n}\n\nfunction extractSemver(value: string | undefined): string | null {\n if (!value) return null;\n const match = value.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match?.[0] ?? null;\n}\n\nfunction workspaceDirOf(projectDir: string): string {\n return findWorkspaceRoot(projectDir)?.dir ?? projectDir;\n}\n\nfunction readRootPackageJson(projectDir: string): Record<string, unknown> {\n return readJsonFile<Record<string, unknown>>(join(workspaceDirOf(projectDir), \"package.json\"));\n}\n\nfunction readRootCatalogEntry(projectDir: string, packageName: string): string | undefined {\n return readWorkspaceCatalog(workspaceDirOf(projectDir))[packageName];\n}\n\nfunction readCurrentPackageSpecifier(projectDir: string, packageName: string): string | undefined {\n const pkg = readRootPackageJson(projectDir);\n\n for (const fieldName of [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const) {\n const field = pkg[fieldName] as Record<string, string> | undefined;\n const value = field?.[packageName];\n if (!value) continue;\n\n if (value === \"catalog:\") {\n return (\n readRootCatalogEntry(projectDir, packageName) ??\n readInstalledVersion(projectDir, packageName)\n );\n }\n\n if (value.startsWith(\"workspace:\") || value.startsWith(\"file:\") || value.startsWith(\"link:\")) {\n return readInstalledVersion(projectDir, packageName);\n }\n\n return value;\n }\n\n return (\n readRootCatalogEntry(projectDir, packageName) ?? readInstalledVersion(projectDir, packageName)\n );\n}\n\nfunction setCatalogRefs(\n field: Record<string, string> | undefined,\n packageNames: ReadonlyArray<string>,\n): boolean {\n if (!field) return false;\n\n let modified = false;\n for (const packageName of packageNames) {\n if (setCatalogRef(field, packageName)) {\n modified = true;\n }\n }\n\n return modified;\n}\n\nfunction syncPackageObjectCatalogRefs(\n pkg: Record<string, unknown>,\n packageNames: ReadonlyArray<string>,\n): boolean {\n let modified = false;\n\n for (const fieldName of [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const) {\n const field = pkg[fieldName] as Record<string, string> | undefined;\n if (setCatalogRefs(field, packageNames)) {\n modified = true;\n }\n }\n\n return modified;\n}\n\nfunction findPackageFieldWithAnyDependency(\n pkg: Record<string, unknown>,\n packageNames: ReadonlyArray<string>,\n): Record<string, string> | undefined {\n for (const fieldName of [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const) {\n const field = pkg[fieldName] as Record<string, string> | undefined;\n if (!field) continue;\n if (packageNames.some((packageName) => typeof field[packageName] === \"string\")) {\n return field;\n }\n }\n\n return undefined;\n}\n\nfunction packageObjectNeedsAuthCoreCatalogRef(pkg: Record<string, unknown>): boolean {\n const targetField = findPackageFieldWithAnyDependency(pkg, AUTH_CORE_TRIGGER_PACKAGES);\n if (!targetField) return false;\n\n for (const fieldName of [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const) {\n const field = pkg[fieldName] as Record<string, string> | undefined;\n if (field?.[AUTH_CORE_PACKAGE]) return false;\n }\n\n return true;\n}\n\nfunction ensureAuthCoreCatalogRef(pkg: Record<string, unknown>): boolean {\n if (!packageObjectNeedsAuthCoreCatalogRef(pkg)) return false;\n\n const targetField = findPackageFieldWithAnyDependency(pkg, AUTH_CORE_TRIGGER_PACKAGES);\n if (!targetField) return false;\n\n targetField[AUTH_CORE_PACKAGE] = \"catalog:\";\n return true;\n}\n\nfunction packageObjectNeedsCatalogRefs(\n pkg: Record<string, unknown>,\n packageNames: ReadonlyArray<string>,\n): boolean {\n for (const fieldName of [\"dependencies\", \"devDependencies\", \"peerDependencies\"] as const) {\n const field = pkg[fieldName] as Record<string, string> | undefined;\n if (!field) continue;\n\n for (const packageName of packageNames) {\n const value = field[packageName];\n if (!value) continue;\n if (value !== \"catalog:\" && !value.startsWith(\"file:\") && !value.startsWith(\"link:\")) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nfunction packageFileNeedsCatalogRefs(\n filePath: string,\n packageNames: ReadonlyArray<string>,\n): boolean {\n return packageObjectNeedsCatalogRefs(\n readJsonFile<Record<string, unknown>>(filePath),\n packageNames,\n );\n}\n\nfunction updatePackageFileCatalogRefs(\n filePath: string,\n packageNames: ReadonlyArray<string>,\n): boolean {\n const pkg = readJsonFile<Record<string, unknown>>(filePath);\n const modified = syncPackageObjectCatalogRefs(pkg, packageNames);\n\n if (modified) {\n writeFileSync(filePath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return modified;\n}\n\nfunction updatePackageFileAuthCoreRef(filePath: string): boolean {\n const pkg = readJsonFile<Record<string, unknown>>(filePath);\n const modified = ensureAuthCoreCatalogRef(pkg);\n\n if (modified) {\n writeFileSync(filePath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return modified;\n}\n\nfunction syncRootCatalogWithParent(\n projectDir: string,\n parentCatalog: Record<string, string>,\n): boolean {\n const workspaceDir = workspaceDirOf(projectDir);\n const pkgPath = join(workspaceDir, \"package.json\");\n const pkg = readJsonFile<Record<string, unknown>>(pkgPath);\n const modified = syncPackageObjectCatalogRefs(pkg, Object.keys(parentCatalog));\n\n let catalogChanged = false;\n const catalog = readWorkspaceCatalog(workspaceDir);\n for (const [packageName, version] of Object.entries(parentCatalog)) {\n if (catalog[packageName] !== version) {\n catalog[packageName] = version;\n catalogChanged = true;\n }\n }\n if (catalogChanged) {\n writeWorkspaceCatalog(workspaceDir, catalog);\n }\n\n if (modified) {\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return modified || catalogChanged;\n}\n\nasync function readExtendedRootSource(projectDir: string): Promise<ExtendedRootSource> {\n const localConfig = (await readAuthoredConfigInput(projectDir)) as Record<string, unknown> | null;\n if (!localConfig) {\n return { catalog: {}, extendsChain: [] };\n }\n\n let extendsRef = getExtendsRef(localConfig);\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n catalog: {},\n repository: typeof localConfig.repository === \"string\" ? localConfig.repository : undefined,\n extendsChain: [],\n };\n }\n\n const extendsChain: string[] = [];\n const visited = new Set<string>();\n let repository = typeof localConfig.repository === \"string\" ? localConfig.repository : undefined;\n let rootRef = extendsRef;\n\n while (extendsRef?.startsWith(\"bos://\")) {\n if (visited.has(extendsRef)) {\n throw new Error(`Circular extends detected while resolving upgrade source: ${extendsRef}`);\n }\n visited.add(extendsRef);\n extendsChain.push(extendsRef);\n\n const parsed = parseBosRef(extendsRef);\n if (!parsed) {\n break;\n }\n\n rootRef = extendsRef;\n\n let parentConfig: Record<string, unknown>;\n try {\n parentConfig = (await fetchParentConfig(parsed.account, parsed.gateway)) as Record<\n string,\n unknown\n >;\n } catch {\n break;\n }\n\n if (typeof parentConfig.repository === \"string\") {\n repository = parentConfig.repository;\n }\n\n const nextExtendsRef = getExtendsRef(parentConfig);\n if (!nextExtendsRef?.startsWith(\"bos://\")) {\n break;\n }\n\n extendsRef = nextExtendsRef;\n }\n\n const parsed = parseBosRef(rootRef);\n if (!parsed) {\n return { catalog: {}, repository, extendsChain };\n }\n\n const source = await resolveCatalogChainSource({\n extendsAccount: parsed.account,\n extendsGateway: parsed.gateway,\n });\n\n return {\n catalog: source.catalog,\n repository: source.repository ?? repository,\n extendsChain: source.extendsChain.length > 0 ? source.extendsChain : extendsChain,\n };\n}\n\nfunction parseTargetedRef(ref: string): { configRef: string; targetPath?: string } {\n const hashIndex = ref.indexOf(\"#\");\n if (hashIndex === -1) {\n return { configRef: ref };\n }\n return {\n configRef: ref.slice(0, hashIndex),\n targetPath: ref.slice(hashIndex + 1) || undefined,\n };\n}\n\nfunction ensureTargetedRef(ref: string, targetPath: string): string {\n const parsed = parseTargetedRef(ref);\n if (parsed.targetPath) return ref;\n return `${parsed.configRef}#${targetPath}`;\n}\n\nfunction rewriteExtendsTarget(\n entry: Record<string, unknown> | undefined,\n targetPath: string,\n): boolean {\n if (!entry?.extends) return false;\n\n if (typeof entry.extends === \"string\") {\n const next = ensureTargetedRef(entry.extends, targetPath);\n if (next === entry.extends) return false;\n entry.extends = next;\n return true;\n }\n\n if (typeof entry.extends === \"object\") {\n let changed = false;\n for (const [key, value] of Object.entries(entry.extends as Record<string, unknown>)) {\n if (typeof value !== \"string\") continue;\n const next = ensureTargetedRef(value, targetPath);\n if (next !== value) {\n (entry.extends as Record<string, unknown>)[key] = next;\n changed = true;\n }\n }\n return changed;\n }\n\n return false;\n}\n\nfunction migrateRootConfigTargets(config: Record<string, unknown>): boolean {\n let changed = false;\n const app =\n config.app && typeof config.app === \"object\"\n ? (config.app as Record<string, unknown>)\n : undefined;\n\n if (app?.api && typeof app.api === \"object\") {\n changed = rewriteExtendsTarget(app.api as Record<string, unknown>, \"app.api\") || changed;\n }\n if (app?.auth && typeof app.auth === \"object\") {\n changed = rewriteExtendsTarget(app.auth as Record<string, unknown>, \"app.auth\") || changed;\n }\n\n if (config.plugins && typeof config.plugins === \"object\") {\n for (const [pluginKey, pluginValue] of Object.entries(\n config.plugins as Record<string, unknown>,\n )) {\n if (typeof pluginValue === \"string\") {\n const next = ensureTargetedRef(pluginValue, `plugins.${pluginKey}`);\n if (next !== pluginValue) {\n (config.plugins as Record<string, unknown>)[pluginKey] = next;\n changed = true;\n }\n continue;\n }\n if (!pluginValue || typeof pluginValue !== \"object\") continue;\n changed =\n rewriteExtendsTarget(pluginValue as Record<string, unknown>, `plugins.${pluginKey}`) ||\n changed;\n }\n }\n\n return changed;\n}\n\nfunction migratePluginProviderConfig(config: Record<string, unknown>, pluginKey: string): boolean {\n let changed = false;\n if (!config.plugins || typeof config.plugins !== \"object\") {\n return false;\n }\n\n const plugins = config.plugins as Record<string, unknown>;\n const entry = plugins[pluginKey];\n if (!entry || typeof entry !== \"object\") return false;\n\n const pluginEntry = entry as Record<string, unknown>;\n\n if (\"name\" in pluginEntry) {\n delete pluginEntry.name;\n changed = true;\n }\n\n if (typeof pluginEntry.development === \"string\" && pluginEntry.development.startsWith(\"local:\")) {\n if (\"extends\" in pluginEntry) {\n delete pluginEntry.extends;\n changed = true;\n }\n }\n\n changed = rewriteExtendsTarget(pluginEntry, `plugins.${pluginKey}`) || changed;\n\n return changed;\n}\n\nfunction mergePluginConfigIntoRoot(\n rootConfig: Record<string, unknown>,\n pluginKey: string,\n pluginConfig: Record<string, unknown>,\n): boolean {\n let changed = false;\n\n if (!rootConfig.plugins || typeof rootConfig.plugins !== \"object\") {\n rootConfig.plugins = {};\n changed = true;\n }\n const plugins = rootConfig.plugins as Record<string, unknown>;\n if (!plugins[pluginKey] || typeof plugins[pluginKey] !== \"object\") {\n plugins[pluginKey] = {};\n changed = true;\n }\n\n const entry = plugins[pluginKey] as Record<string, unknown>;\n\n const pluginData = extractPluginEntry(pluginConfig, pluginKey);\n\n const apiData = getApiEntry(pluginConfig);\n\n if (pluginData) {\n for (const key of [\n \"secrets\",\n \"variables\",\n \"routes\",\n \"production\",\n \"integrity\",\n \"proxy\",\n ] as const) {\n if (pluginData[key] !== undefined && entry[key] === undefined) {\n entry[key] = pluginData[key];\n changed = true;\n }\n }\n\n if (typeof pluginData.development === \"string\" && pluginData.development.startsWith(\"local:\")) {\n pluginData.development = `local:plugins/${pluginKey}`;\n }\n if (entry.development === undefined && pluginData.development !== undefined) {\n entry.development = pluginData.development;\n changed = true;\n }\n }\n\n if (apiData) {\n for (const key of [\n \"production\",\n \"integrity\",\n \"proxy\",\n \"variables\",\n \"secrets\",\n \"routes\",\n ] as const) {\n if (apiData[key] !== undefined && entry[key] === undefined) {\n entry[key] = apiData[key];\n changed = true;\n }\n }\n }\n\n if (\"extends\" in entry) {\n const extendsStr = typeof entry.extends === \"string\" ? entry.extends : undefined;\n if (!extendsStr || extendsStr.includes(`#plugins.${pluginKey}`)) {\n delete entry.extends;\n changed = true;\n }\n }\n\n if (\"name\" in entry) {\n delete entry.name;\n changed = true;\n }\n\n if (configHasTopLevelFields(pluginConfig, pluginKey)) {\n if (entry.routes === undefined && Array.isArray(pluginConfig.routes)) {\n entry.routes = pluginConfig.routes;\n changed = true;\n }\n const api = getApiEntry(pluginConfig);\n if (api) {\n if (entry.routes === undefined && Array.isArray(api.routes)) {\n entry.routes = api.routes;\n changed = true;\n }\n }\n }\n\n return changed;\n}\n\nfunction extractPluginEntry(\n pluginConfig: Record<string, unknown>,\n pluginKey: string,\n): Record<string, unknown> | null {\n if (\n pluginConfig.plugins &&\n typeof pluginConfig.plugins === \"object\" &&\n (pluginConfig.plugins as Record<string, unknown>)[pluginKey] &&\n typeof (pluginConfig.plugins as Record<string, unknown>)[pluginKey] === \"object\"\n ) {\n return (pluginConfig.plugins as Record<string, unknown>)[pluginKey] as Record<string, unknown>;\n }\n\n if (pluginConfig.routes !== undefined) {\n return { routes: pluginConfig.routes };\n }\n\n return null;\n}\n\nfunction configHasTopLevelFields(\n pluginConfig: Record<string, unknown>,\n _pluginKey: string,\n): boolean {\n return (\n (pluginConfig.routes !== undefined && Array.isArray(pluginConfig.routes)) ||\n getApiEntry(pluginConfig) !== null\n );\n}\n\nfunction getApiEntry(pluginConfig: Record<string, unknown>): Record<string, unknown> | null {\n if (!pluginConfig.app || typeof pluginConfig.app !== \"object\") return null;\n const app = pluginConfig.app as Record<string, unknown>;\n if (!app.api || typeof app.api !== \"object\") return null;\n return app.api as Record<string, unknown>;\n}\n\nexport async function migrateBosConfigFiles(projectDir: string): Promise<string[]> {\n const migrated: string[] = [];\n const rootConfigPath = join(projectDir, \"bos.config.json\");\n\n if (existsSync(rootConfigPath)) {\n const rootConfig = JSON.parse(readFileSync(rootConfigPath, \"utf-8\")) as Record<string, unknown>;\n let rootChanged = migrateRootConfigTargets(rootConfig);\n\n const pluginConfigPaths = await glob(\"plugins/*/bos.config.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n });\n\n for (const relativePath of pluginConfigPaths) {\n const match = relativePath.match(/^plugins\\/([^/]+)\\/bos\\.config\\.json$/);\n const pluginKey = match?.[1];\n if (!pluginKey) continue;\n\n const filePath = join(projectDir, relativePath);\n try {\n const pluginConfig = JSON.parse(readFileSync(filePath, \"utf-8\")) as Record<string, unknown>;\n rootChanged = mergePluginConfigIntoRoot(rootConfig, pluginKey, pluginConfig) || rootChanged;\n } catch (e) {\n console.warn(`[Upgrade] Failed to parse plugin config at ${filePath}: ${String(e)}`);\n }\n\n try {\n rmSync(filePath);\n migrated.push(relativePath);\n } catch (e) {\n console.warn(\n `[Upgrade] Failed to remove migrated plugin config at ${filePath}: ${String(e)}`,\n );\n }\n }\n\n if (rootConfig.plugins && typeof rootConfig.plugins === \"object\") {\n for (const pluginKey of Object.keys(rootConfig.plugins as Record<string, unknown>)) {\n rootChanged = migratePluginProviderConfig(rootConfig, pluginKey) || rootChanged;\n }\n }\n\n if (rootChanged || migrated.length > 0) {\n await saveBosConfig(projectDir, rootConfig);\n if (!migrated.includes(\"bos.config.json\")) {\n migrated.push(\"bos.config.json\");\n }\n }\n }\n\n return migrated;\n}\n\nasync function loadParentPluginOptions(projectDir: string): Promise<{\n localConfig: Record<string, unknown>;\n parentPlugins: Record<string, unknown>;\n newPluginKeys: string[];\n} | null> {\n const localConfig = (await readAuthoredConfigInput(projectDir)) as Record<string, unknown> | null;\n if (!localConfig) {\n return null;\n }\n const extendsRef = getExtendsRef(localConfig);\n if (!extendsRef?.startsWith(\"bos://\")) {\n return null;\n }\n\n const parsed = parseBosRef(extendsRef);\n if (!parsed) {\n return null;\n }\n\n let parentConfig: Record<string, unknown>;\n try {\n parentConfig = await fetchParentConfig(parsed.account, parsed.gateway);\n } catch {\n return null;\n }\n\n const parentPlugins =\n parentConfig.plugins && typeof parentConfig.plugins === \"object\"\n ? (parentConfig.plugins as Record<string, unknown>)\n : {};\n const localPlugins =\n localConfig.plugins && typeof localConfig.plugins === \"object\"\n ? (localConfig.plugins as Record<string, unknown>)\n : {};\n\n const newPluginKeys = Object.keys(parentPlugins).filter((key) => !(key in localPlugins));\n return { localConfig, parentPlugins, newPluginKeys };\n}\n\nasync function addSelectedParentPlugins(projectDir: string): Promise<string[]> {\n if (!process.stdin.isTTY || !process.stdout.isTTY) {\n return [];\n }\n\n const pluginOptions = await loadParentPluginOptions(projectDir);\n if (!pluginOptions || pluginOptions.newPluginKeys.length === 0) {\n return [];\n }\n\n const selectedValue = await p.multiselect({\n message: \"Select new plugins from parent:\",\n options: pluginOptions.newPluginKeys.map((key) => ({ value: key, label: key })),\n required: false,\n });\n\n if (p.isCancel(selectedValue)) {\n process.exit(0);\n }\n\n const selected = selectedValue as string[];\n if (selected.length === 0) {\n return [];\n }\n\n const localPlugins =\n pluginOptions.localConfig.plugins && typeof pluginOptions.localConfig.plugins === \"object\"\n ? (pluginOptions.localConfig.plugins as Record<string, unknown>)\n : {};\n const nextPlugins = { ...localPlugins };\n for (const key of selected) {\n const parentPlugin = pluginOptions.parentPlugins[key];\n if (parentPlugin && typeof parentPlugin === \"object\") {\n const nextPlugin = structuredClone(parentPlugin as Record<string, unknown>);\n rewriteExtendsTarget(nextPlugin, `plugins.${key}`);\n nextPlugins[key] = nextPlugin;\n } else if (typeof parentPlugin === \"string\") {\n nextPlugins[key] = ensureTargetedRef(parentPlugin, `plugins.${key}`);\n } else {\n nextPlugins[key] = parentPlugin;\n }\n }\n\n pluginOptions.localConfig.plugins = nextPlugins;\n await saveBosConfig(projectDir, pluginOptions.localConfig);\n\n return selected;\n}\n\nfunction readInstalledVersion(projectDir: string, packageName: string): string | undefined {\n return readInstalledFrameworkVersion(projectDir, packageName);\n}\n\nfunction setCatalogRef(field: Record<string, string> | undefined, packageName: string): boolean {\n if (!field || !(packageName in field)) return false;\n if (field[packageName] === \"catalog:\" || field[packageName].startsWith(\"file:\")) return false;\n field[packageName] = \"catalog:\";\n return true;\n}\n\nasync function findWorkspacePackageJsons(projectDir: string): Promise<string[]> {\n const root = findWorkspaceRoot(projectDir);\n if (!root) return [];\n\n const pkgPaths: string[] = [];\n for (const member of root.members) {\n const pkgPath = join(member.dir, \"package.json\");\n if (existsSync(pkgPath) && statSync(pkgPath).isFile()) {\n pkgPaths.push(pkgPath);\n }\n }\n\n return [...new Set(pkgPaths)];\n}\n\nexport async function migrateChildRootPackageJson(projectDir: string): Promise<boolean> {\n const config = (await readAuthoredConfigInput(projectDir)) as Record<string, unknown> | null;\n const pkgPath = join(workspaceDirOf(projectDir), \"package.json\");\n if (!config || !existsSync(pkgPath)) {\n return false;\n }\n\n const extendsRef = getExtendsRef(config);\n if (!extendsRef?.startsWith(\"bos://\")) {\n return false;\n }\n\n const pkg = readJsonFile<Record<string, unknown>>(pkgPath);\n let changed = false;\n\n if (pkg.private !== true) {\n pkg.private = true;\n changed = true;\n }\n if (pkg.type !== \"module\") {\n pkg.type = \"module\";\n changed = true;\n }\n if (\"module\" in pkg) {\n delete pkg.module;\n changed = true;\n }\n\n const pluginPackageJsons = await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n });\n const childScripts = buildChildRootScripts({\n ui: existsSync(join(projectDir, \"ui\", \"package.json\")),\n api: existsSync(join(projectDir, \"api\", \"package.json\")),\n host: existsSync(join(projectDir, \"host\", \"package.json\")),\n plugins: pluginPackageJsons.length > 0,\n });\n\n if (!pkg.scripts || typeof pkg.scripts !== \"object\") {\n pkg.scripts = {};\n changed = true;\n }\n const scripts = pkg.scripts as Record<string, string>;\n for (const [key, value] of Object.entries(childScripts)) {\n if (scripts[key] !== value) {\n scripts[key] = value;\n changed = true;\n }\n }\n for (const obsoleteScript of [...getParentOnlyScriptKeys(projectDir), \"sync-catalog\", \"init\"]) {\n if (obsoleteScript in scripts) {\n delete scripts[obsoleteScript];\n changed = true;\n }\n }\n\n const workspaces = pkg.workspaces;\n if (workspaces && typeof workspaces === \"object\") {\n const workspaceConfig = workspaces as { packages?: string[] };\n if (Array.isArray(workspaceConfig.packages)) {\n const nextPackages = workspaceConfig.packages.filter(\n (entry) => entry !== \"packages/everything-dev\" && entry !== \"packages/every-plugin\",\n );\n if (nextPackages.length !== workspaceConfig.packages.length) {\n workspaceConfig.packages = nextPackages;\n changed = true;\n }\n }\n }\n\n if (pkg.overrides && typeof pkg.overrides === \"object\") {\n const overrides = pkg.overrides as Record<string, string>;\n for (const packageName of FRAMEWORK_PACKAGES) {\n const value = overrides[packageName];\n if (typeof value === \"string\" && value.startsWith(\"file:packages/\")) {\n delete overrides[packageName];\n changed = true;\n }\n }\n if (Object.keys(overrides).length === 0) {\n delete pkg.overrides;\n changed = true;\n }\n }\n\n if (ensureAuthCoreCatalogRef(pkg)) {\n changed = true;\n }\n\n const workspacePackageJsons = await findWorkspacePackageJsons(projectDir);\n for (const workspacePkgPath of workspacePackageJsons) {\n if (updatePackageFileAuthCoreRef(workspacePkgPath)) {\n changed = true;\n }\n }\n\n if (changed) {\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return changed;\n}\n\nfunction buildChangelogUrl(\n oldVersion: string | undefined,\n newVersion: string,\n repository: string | undefined,\n): string | undefined {\n const fromVersion = extractSemver(oldVersion);\n const toVersion = extractSemver(newVersion);\n if (!fromVersion || !toVersion || fromVersion === toVersion) return undefined;\n\n const repoUrl = repository;\n if (!repoUrl) return undefined;\n\n const githubMatch = repoUrl.match(/^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?$/);\n if (!githubMatch) return undefined;\n\n const [, owner, repo] = githubMatch;\n return `https://github.com/${owner}/${repo}/compare/v${fromVersion}...v${toVersion}`;\n}\n\nasync function rewriteLegacyUiImports(projectDir: string): Promise<string[]> {\n const files = await glob(\"ui/src/**/*.{ts,tsx}\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n });\n const migrated: string[] = [];\n\n for (const file of files) {\n const filePath = join(projectDir, file);\n const original = readFileSync(filePath, \"utf-8\");\n let next = original;\n\n for (const [from, to] of LEGACY_UI_IMPORT_REWRITES) {\n next = next.replaceAll(from, to);\n }\n\n if (next !== original) {\n writeFileSync(filePath, next);\n migrated.push(file);\n }\n }\n\n return migrated;\n}\n\nconst LEGACY_DIST_IMPORT_REWRITES = [\n ['from \"everything-dev/dist/', 'from \"everything-dev/'],\n [\"from 'everything-dev/dist/\", \"from 'everything-dev/\"],\n] as const;\n\nfunction escapeRegex(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction balancedParenEnd(source: string, openIdx: number): number {\n let depth = 1;\n let i = openIdx;\n while (i < source.length) {\n const ch = source[i];\n if (ch === \"(\") depth++;\n else if (ch === \")\") {\n depth--;\n if (depth === 0) return i;\n }\n i++;\n }\n return -1;\n}\n\nfunction deriveTagFromLayerExpr(layerExpr: string): string | null {\n const m = layerExpr.match(/^\\s*([A-Z]\\w*)/);\n if (!m) return null;\n const name = m[1];\n if (name.endsWith(\"Live\")) return `${name.slice(0, -4)}Tag`;\n if (name.endsWith(\"Layer\")) return `${name.slice(0, -5)}Tag`;\n return null;\n}\n\ntype PipeProvideCall = {\n argStart: number;\n endIdx: number;\n dotIdx: number;\n pipeCloseEnd: number;\n};\n\nfunction findAllPipeEffectProvideCalls(source: string): PipeProvideCall[] {\n const out: PipeProvideCall[] = [];\n const needle = \"Effect.provide(\";\n let searchFrom = 0;\n while (true) {\n const provideIdx = source.indexOf(needle, searchFrom);\n if (provideIdx === -1) break;\n const argStart = provideIdx + needle.length;\n const endIdx = balancedParenEnd(source, argStart);\n if (endIdx === -1) {\n searchFrom = argStart;\n continue;\n }\n let p = provideIdx - 1;\n while (p >= 0 && /\\s/.test(source[p])) p--;\n if (p < 0 || source[p] !== \"(\") {\n searchFrom = endIdx + 1;\n continue;\n }\n p--;\n const pipeWord = \".pipe\";\n if (p - pipeWord.length + 1 < 0 || source.slice(p - pipeWord.length + 1, p + 1) !== pipeWord) {\n searchFrom = endIdx + 1;\n continue;\n }\n const dotIdx = p - pipeWord.length + 1;\n let q = endIdx + 1;\n while (q < source.length && /\\s/.test(source[q])) q++;\n if (q < source.length && source[q] === \",\") q++;\n while (q < source.length && /\\s/.test(source[q])) q++;\n if (q >= source.length || source[q] !== \")\") {\n searchFrom = endIdx + 1;\n continue;\n }\n out.push({ argStart, endIdx, dotIdx, pipeCloseEnd: q + 1 });\n searchFrom = q + 1;\n }\n return out;\n}\n\nfunction rewritePipeEffectProvideForm(source: string, relPath: string): string {\n const calls = findAllPipeEffectProvideCalls(source);\n if (calls.length === 0) return source;\n\n let result = source;\n\n for (let k = calls.length - 1; k >= 0; k--) {\n const call = calls[k];\n const layerExpr = result.slice(call.argStart, call.endIdx).trim();\n const tagName = deriveTagFromLayerExpr(layerExpr);\n if (!tagName) {\n console.warn(\n `[Upgrade] ${relPath}: found .pipe(Effect.provide(${layerExpr})) but could not derive a tag name — skipping. Migrate manually to Layer.buildWithScope(${layerExpr}, yield* Effect.scope) + Context.get.`,\n );\n continue;\n }\n const tagUseRe = new RegExp(`(yield\\\\*\\\\s+)${escapeRegex(tagName)}(\\\\s*;?)`, \"g\");\n const tagMatches = [...result.matchAll(tagUseRe)];\n if (tagMatches.length !== 1) {\n console.warn(\n `[Upgrade] ${relPath}: found .pipe(Effect.provide(${layerExpr})) expecting a single \\`yield* ${tagName}\\`, but found ${tagMatches.length} — skipping. Migrate manually.`,\n );\n continue;\n }\n const tm = tagMatches[0];\n const tagStart = tm.index ?? -1;\n if (tagStart < 0) continue;\n const tagLen = tm[0].length;\n const replacement =\n `${tm[1]}Layer.buildWithScope(${layerExpr}, yield* Effect.scope)` +\n `.pipe(Effect.map((context) => Context.get(context, ${tagName})))${tm[2]}`;\n if (tagStart < call.dotIdx) {\n result =\n result.slice(0, tagStart) +\n replacement +\n result.slice(tagStart + tagLen, call.dotIdx) +\n result.slice(call.pipeCloseEnd);\n } else {\n result =\n result.slice(0, call.dotIdx) +\n result.slice(call.pipeCloseEnd, tagStart) +\n replacement +\n result.slice(tagStart + tagLen);\n }\n }\n\n return result;\n}\n\nfunction rewriteTwoArgEffectProvideForm(source: string, relPath: string): string {\n const matches = [...source.matchAll(/\\byield\\*\\s*Effect\\.provide\\(/g)];\n if (matches.length === 0) return source;\n\n let result = source;\n\n for (let k = matches.length - 1; k >= 0; k--) {\n const m = matches[k];\n const openIdx = (m.index ?? -1) + m[0].length - 1;\n if (openIdx < 0) continue;\n const closeIdx = balancedParenEnd(source, openIdx + 1);\n if (closeIdx === -1) continue;\n\n const inner = source.slice(openIdx + 1, closeIdx);\n const commaIdx = findTopLevelComma(inner);\n if (commaIdx === -1) {\n console.warn(\n `[Upgrade] ${relPath}: found \\`yield* Effect.provide(...)\\` without a top-level Tag, Layer argument pair — skipping. Migrate manually to Layer.buildWithScope + Context.get.`,\n );\n continue;\n }\n\n const tagExpr = inner.slice(0, commaIdx).trim();\n const layerExpr = inner.slice(commaIdx + 1).trim();\n const prefix = m[0].replace(/Effect\\.provide\\($/, \"\");\n const replacement =\n `${prefix}Layer.buildWithScope(${layerExpr}, yield* Effect.scope)` +\n `.pipe(Effect.map((context) => Context.get(context, ${tagExpr})))`;\n result = result.slice(0, m.index) + replacement + result.slice(closeIdx + 1);\n }\n\n return result;\n}\n\nfunction findTopLevelComma(inner: string): number {\n let depth = 0;\n for (let i = 0; i < inner.length; i++) {\n const ch = inner[i];\n if (ch === \"(\" || ch === \"[\" || ch === \"{\") depth++;\n else if (ch === \")\" || ch === \"]\" || ch === \"}\") depth--;\n else if (ch === \",\" && depth === 0) return i;\n }\n return -1;\n}\n\nfunction ensureEffectImports(source: string): string {\n const m = source.match(/import\\s*\\{([^}]*)\\}\\s*from\\s*[\"']every-plugin\\/effect[\"']/);\n if (!m) return source;\n const names = m[1]\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean);\n if (!names.includes(\"Context\")) names.push(\"Context\");\n if (!names.includes(\"Layer\")) names.push(\"Layer\");\n names.sort((a, b) => a.localeCompare(b));\n return source.replace(m[0], `import { ${names.join(\", \")} } from \"effect\"`);\n}\n\nexport async function rewriteLegacyPluginScopedLayerPatterns(\n projectDir: string,\n): Promise<string[]> {\n const files = await glob([\"plugins/*/src/index.ts\", \"api/src/index.ts\"], {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n });\n\n if (files.length === 0) return [];\n\n const migrated: string[] = [];\n\n for (const file of files) {\n const filePath = join(projectDir, file);\n const original = readFileSync(filePath, \"utf-8\");\n let next = original;\n\n // Rewrite yield* Effect.provide(Tag, LayerExpr) → Layer.buildWithScope + Context.get\n next = rewriteTwoArgEffectProvideForm(next, file);\n\n // Rewrite the .pipe(Effect.provide(<LayerExpr>)) form: move <LayerExpr> into a\n // Layer.buildWithScope(...) + Context.get call replacing the bare `yield* <Tag>`\n // inside the generator, and drop the trailing .pipe(Effect.provide(...)).\n next = rewritePipeEffectProvideForm(next, file);\n\n if (next !== original) {\n next = ensureEffectImports(next);\n writeFileSync(filePath, next);\n migrated.push(file);\n }\n }\n\n return migrated;\n}\n\nexport async function rewriteLegacyDistImports(projectDir: string): Promise<string[]> {\n const files = await glob(\"**/*.{ts,tsx,js,jsx,mjs,cjs}\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n ignore: [\"node_modules/**\", \"dist/**\"],\n });\n\n const migrated: string[] = [];\n\n for (const file of files) {\n const filePath = join(projectDir, file);\n const original = readFileSync(filePath, \"utf-8\");\n let next = original;\n\n for (const [from, to] of LEGACY_DIST_IMPORT_REWRITES) {\n next = next.replaceAll(from, to);\n }\n\n if (next !== original) {\n writeFileSync(filePath, next);\n migrated.push(file);\n }\n }\n\n return migrated;\n}\n\nasync function runMigrationPhase(\n projectDir: string,\n options: UpgradeOptions,\n parentSource: ExtendedRootSource,\n): Promise<UpgradeResult> {\n const timings: PhaseTiming[] = [];\n\n const migratedBosConfigs = await timePhase(timings, \"migrate bos configs\", () =>\n migrateBosConfigFiles(projectDir),\n );\n const migratedRootPackageJson = await timePhase(timings, \"migrate root package\", () =>\n migrateChildRootPackageJson(projectDir),\n );\n\n let syncResult: UpgradeResult[\"sync\"];\n let addedPlugins: string[] = [];\n if (!options.noSync && parentSource.extendsChain.length > 0) {\n addedPlugins = await timePhase(timings, \"discover parent plugins\", async () => {\n if (options.dryRun) return [];\n return addSelectedParentPlugins(projectDir);\n });\n\n syncResult = await timePhase(timings, \"sync template\", () =>\n syncTemplate(projectDir, {\n dryRun: false,\n noInstall: true,\n json: false,\n }),\n );\n }\n\n await timePhase(timings, \"sync shared deps\", async () => {\n const configSession = await openResolution({ cwd: projectDir });\n if (!configSession?.config) {\n throw new Error(`${MISSING_CONFIG_MESSAGE} in current directory`);\n }\n\n return syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n bosConfig: configSession.config,\n });\n });\n\n if (!options.noInstall) {\n await timePhase(timings, \"generate types\", () => runTypesGen(projectDir));\n }\n\n const migratedFiles = await timePhase(timings, \"clean obsolete files\", async () => {\n const nextMigratedFiles = [\n ...migratedBosConfigs,\n ...(migratedRootPackageJson ? [\"package.json\"] : []),\n ...(await rewriteLegacyUiImports(projectDir)),\n ...(await rewriteLegacyPluginScopedLayerPatterns(projectDir)),\n ...(await rewriteLegacyDistImports(projectDir)),\n ];\n for (const file of OBSOLETE_FILES) {\n const filePath = join(projectDir, file);\n if (existsSync(filePath)) {\n rmSync(filePath);\n nextMigratedFiles.push(file);\n }\n }\n\n const legacyPluginDbFiles = await glob(\"plugins/*/src/db/{migrator,load-migrations}.ts\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n });\n for (const file of legacyPluginDbFiles) {\n rmSync(join(projectDir, file));\n nextMigratedFiles.push(file);\n }\n\n return nextMigratedFiles;\n });\n\n let changelogUrl: string | undefined;\n const mainPkg = parentSource.catalog[\"everything-dev\"];\n if (mainPkg) {\n changelogUrl = buildChangelogUrl(undefined, mainPkg, parentSource.repository);\n }\n\n return {\n status: \"upgraded\",\n packages: [],\n sync: syncResult,\n migrated: migratedFiles.length > 0 ? migratedFiles : undefined,\n selectedPlugins: addedPlugins.length > 0 ? addedPlugins : undefined,\n timings,\n changelogUrl,\n };\n}\n\nexport async function upgradeTemplate(\n projectDir: string,\n options: UpgradeOptions,\n): Promise<UpgradeResult> {\n const timings: PhaseTiming[] = [];\n const pkgPath = join(workspaceDirOf(projectDir), \"package.json\");\n if (!existsSync(pkgPath)) {\n return {\n status: \"error\",\n packages: [],\n timings,\n error: \"No package.json found in current directory\",\n };\n }\n\n const parentSource = await readExtendedRootSource(projectDir);\n const sourceRootCatalog = parentSource.catalog;\n const inheritedCatalogPackageNames = Object.keys(sourceRootCatalog);\n const currentRootCatalog = readRootPackageJson(projectDir) as {\n workspaces?: { catalog?: Record<string, string> };\n };\n const currentCatalogEntries = currentRootCatalog.workspaces?.catalog ?? {};\n const workspacePkgPaths = await findWorkspacePackageJsons(projectDir);\n const hasCatalogRefRewrites =\n inheritedCatalogPackageNames.length > 0 &&\n (packageObjectNeedsCatalogRefs(readRootPackageJson(projectDir), inheritedCatalogPackageNames) ||\n workspacePkgPaths.some((pkgPath) =>\n packageFileNeedsCatalogRefs(pkgPath, inheritedCatalogPackageNames),\n ));\n const hasAuthCoreRefRewrites =\n packageObjectNeedsAuthCoreCatalogRef(readRootPackageJson(projectDir)) ||\n workspacePkgPaths.some((pkgPath) =>\n packageObjectNeedsAuthCoreCatalogRef(readJsonFile<Record<string, unknown>>(pkgPath)),\n );\n\n const { packages, catalogVersionUpdates } = await timePhase(\n timings,\n \"check package versions\",\n async () => {\n const nextPackages: UpgradeResult[\"packages\"] = [];\n\n for (const name of FRAMEWORK_PACKAGES) {\n const current = readCurrentPackageSpecifier(projectDir, name);\n const target = sourceRootCatalog[name] ?? current ?? \"unknown\";\n\n nextPackages.push({ name, from: current, to: target });\n }\n\n const nextCatalogVersionUpdates: Array<{\n name: string;\n from: string | undefined;\n to: string;\n }> = [];\n for (const [name, targetVersion] of Object.entries(sourceRootCatalog)) {\n if (FRAMEWORK_PACKAGES.includes(name)) continue;\n\n const currentVersion = currentCatalogEntries[name];\n if (currentVersion === targetVersion) continue;\n nextCatalogVersionUpdates.push({ name, from: currentVersion, to: targetVersion });\n }\n\n return { packages: nextPackages, catalogVersionUpdates: nextCatalogVersionUpdates };\n },\n );\n\n const hasFrameworkUpdates = packages.some((p) => p.from !== p.to && p.from !== undefined);\n const hasCatalogUpdates = catalogVersionUpdates.length > 0;\n const hasUpdates =\n hasFrameworkUpdates || hasCatalogUpdates || hasCatalogRefRewrites || hasAuthCoreRefRewrites;\n\n if (options.dryRun) {\n let changelogUrl: string | undefined;\n const pluginOptions = options.noSync\n ? null\n : await timePhase(timings, \"discover parent plugins\", () =>\n loadParentPluginOptions(projectDir),\n );\n if (hasUpdates) {\n const mainPkg = packages.find((p) => p.name === \"everything-dev\");\n if (mainPkg?.from && mainPkg.from !== mainPkg.to) {\n changelogUrl = buildChangelogUrl(mainPkg.from, mainPkg.to, parentSource.repository);\n }\n }\n\n return {\n status: \"dry-run\",\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n availablePlugins: pluginOptions?.newPluginKeys,\n timings,\n changelogUrl,\n };\n }\n\n if (options.migrationsOnly) {\n return await runMigrationPhase(projectDir, options, parentSource);\n }\n\n // Phase 1: apply package updates, install, then re-exec migrations from the new package\n await timePhase(timings, \"apply package updates\", async () => {\n if (inheritedCatalogPackageNames.length > 0) {\n syncRootCatalogWithParent(projectDir, sourceRootCatalog);\n }\n\n if (inheritedCatalogPackageNames.length > 0) {\n for (const pkgPath of workspacePkgPaths) {\n updatePackageFileCatalogRefs(pkgPath, inheritedCatalogPackageNames);\n }\n }\n });\n\n const needsInstall = (hasUpdates || hasCatalogUpdates) && !options.noInstall;\n\n if (needsInstall) {\n await timePhase(timings, \"install dependencies\", () =>\n runPnpmInstallForUpgrade(workspaceDirOf(projectDir)),\n );\n }\n\n // If we installed new framework packages, re-exec from the new package so migrations\n // run with the latest code instead of the old cached modules.\n if (needsInstall && hasFrameworkUpdates) {\n const bosPath = join(workspaceDirOf(projectDir), \"node_modules\", \".bin\", \"bos\");\n const childArgs = [\n \"upgrade\",\n \"--migrations-only\",\n \"--no-install\",\n ...(options.noSync ? [\"--no-sync\"] : []),\n \"--json\",\n ];\n\n const childResult = spawnSync(bosPath, childArgs, {\n cwd: projectDir,\n stdio: [\"inherit\", \"pipe\", \"pipe\"],\n encoding: \"utf-8\",\n env: { ...process.env, BOS_NO_BANNER: \"1\" },\n });\n\n if (childResult.status !== 0) {\n return {\n status: \"error\",\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n timings,\n error: `Migration phase failed: ${childResult.stderr || childResult.stdout || \"Unknown error\"}`,\n };\n }\n\n try {\n const childUpgrade: UpgradeResult = JSON.parse(childResult.stdout);\n const mainPkg = packages.find((p) => p.name === \"everything-dev\");\n const changelogUrl =\n mainPkg?.from && mainPkg.from !== mainPkg.to\n ? buildChangelogUrl(mainPkg.from, mainPkg.to, parentSource.repository)\n : undefined;\n return {\n ...childUpgrade,\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n timings: [...timings, ...(childUpgrade.timings ?? [])],\n changelogUrl,\n };\n } catch {\n return {\n status: \"error\",\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n timings,\n error: \"Failed to parse migration phase output\",\n };\n }\n }\n\n // No framework version change: run migrations inline (same-package, no re-exec needed)\n // runMigrationPhase handles types gen internally — no separate runTypesGen call needed here.\n\n const migrationResult = await runMigrationPhase(projectDir, options, parentSource);\n const mainPkg = packages.find((p) => p.name === \"everything-dev\");\n const changelogUrl =\n mainPkg?.from && mainPkg.from !== mainPkg.to\n ? buildChangelogUrl(mainPkg.from, mainPkg.to, parentSource.repository)\n : undefined;\n return {\n ...migrationResult,\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n timings: [...timings, ...(migrationResult.timings ?? [])],\n changelogUrl,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,qBAAqB,CAAC,kBAAkB,cAAc;AAC5D,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;CACjC;CACA;CACA;CACA;AACF;AACA,MAAM,4BAA4B;CAChC,CAAC,mBAAiB,gBAAc;CAChC,CAAC,iBAAiB,cAAc;CAChC,CAAC,6BAA2B,qBAAmB;CAC/C,CAAC,2BAA2B,mBAAmB;CAC/C,CAAC,iCAA+B,gBAAc;CAC9C,CAAC,+BAA+B,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
|
405
405
|
rootChanged = mergePluginConfigIntoRoot(rootConfig, pluginKey, JSON.parse(readFileSync(filePath, "utf-8"))) || rootChanged;
|
|
406
406
|
} catch (e) {
|
|
407
|
-
console.warn(`[Upgrade] Failed to parse plugin config at ${filePath}: ${e}`);
|
|
407
|
+
console.warn(`[Upgrade] Failed to parse plugin config at ${filePath}: ${String(e)}`);
|
|
408
408
|
}
|
|
409
409
|
try {
|
|
410
410
|
rmSync(filePath);
|
|
411
411
|
migrated.push(relativePath);
|
|
412
412
|
} catch (e) {
|
|
413
|
-
console.warn(`[Upgrade] Failed to remove migrated plugin config at ${filePath}: ${e}`);
|
|
413
|
+
console.warn(`[Upgrade] Failed to remove migrated plugin config at ${filePath}: ${String(e)}`);
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
if (rootConfig.plugins && typeof rootConfig.plugins === "object") for (const pluginKey of Object.keys(rootConfig.plugins)) rootChanged = migratePluginProviderConfig(rootConfig, pluginKey) || rootChanged;
|