everything-dev 1.51.1 → 1.51.2
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/cli/upgrade.cjs +98 -1
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +98 -1
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/contract.d.cts +16 -16
- package/dist/contract.d.mts +16 -16
- package/dist/plugin.d.cts +7 -7
- package/dist/plugin.d.mts +7 -7
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/package.json +1 -1
package/dist/cli/upgrade.cjs
CHANGED
|
@@ -631,8 +631,104 @@ async function rewriteLegacyUiImports(projectDir) {
|
|
|
631
631
|
return migrated;
|
|
632
632
|
}
|
|
633
633
|
const LEGACY_DIST_IMPORT_REWRITES = [["from \"everything-dev/dist/", "from \"everything-dev/"], ["from 'everything-dev/dist/", "from 'everything-dev/"]];
|
|
634
|
+
function escapeRegex(s) {
|
|
635
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
636
|
+
}
|
|
637
|
+
function balancedParenEnd(source, openIdx) {
|
|
638
|
+
let depth = 1;
|
|
639
|
+
let i = openIdx;
|
|
640
|
+
while (i < source.length) {
|
|
641
|
+
const ch = source[i];
|
|
642
|
+
if (ch === "(") depth++;
|
|
643
|
+
else if (ch === ")") {
|
|
644
|
+
depth--;
|
|
645
|
+
if (depth === 0) return i;
|
|
646
|
+
}
|
|
647
|
+
i++;
|
|
648
|
+
}
|
|
649
|
+
return -1;
|
|
650
|
+
}
|
|
651
|
+
function deriveTagFromLayerExpr(layerExpr) {
|
|
652
|
+
const m = layerExpr.match(/^\s*([A-Z]\w*)/);
|
|
653
|
+
if (!m) return null;
|
|
654
|
+
const name = m[1];
|
|
655
|
+
if (name.endsWith("Live")) return `${name.slice(0, -4)}Tag`;
|
|
656
|
+
if (name.endsWith("Layer")) return `${name.slice(0, -5)}Tag`;
|
|
657
|
+
return null;
|
|
658
|
+
}
|
|
659
|
+
function findAllPipeEffectProvideCalls(source) {
|
|
660
|
+
const out = [];
|
|
661
|
+
const needle = "Effect.provide(";
|
|
662
|
+
let searchFrom = 0;
|
|
663
|
+
while (true) {
|
|
664
|
+
const provideIdx = source.indexOf(needle, searchFrom);
|
|
665
|
+
if (provideIdx === -1) break;
|
|
666
|
+
const argStart = provideIdx + 15;
|
|
667
|
+
const endIdx = balancedParenEnd(source, argStart);
|
|
668
|
+
if (endIdx === -1) {
|
|
669
|
+
searchFrom = argStart;
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
672
|
+
let p = provideIdx - 1;
|
|
673
|
+
while (p >= 0 && /\s/.test(source[p])) p--;
|
|
674
|
+
if (p < 0 || source[p] !== "(") {
|
|
675
|
+
searchFrom = endIdx + 1;
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
p--;
|
|
679
|
+
if (p - 5 + 1 < 0 || source.slice(p - 5 + 1, p + 1) !== ".pipe") {
|
|
680
|
+
searchFrom = endIdx + 1;
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
const dotIdx = p - 5 + 1;
|
|
684
|
+
let q = endIdx + 1;
|
|
685
|
+
while (q < source.length && /\s/.test(source[q])) q++;
|
|
686
|
+
if (q < source.length && source[q] === ",") q++;
|
|
687
|
+
while (q < source.length && /\s/.test(source[q])) q++;
|
|
688
|
+
if (q >= source.length || source[q] !== ")") {
|
|
689
|
+
searchFrom = endIdx + 1;
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
out.push({
|
|
693
|
+
argStart,
|
|
694
|
+
endIdx,
|
|
695
|
+
dotIdx,
|
|
696
|
+
pipeCloseEnd: q + 1
|
|
697
|
+
});
|
|
698
|
+
searchFrom = q + 1;
|
|
699
|
+
}
|
|
700
|
+
return out;
|
|
701
|
+
}
|
|
702
|
+
function rewritePipeEffectProvideForm(source, relPath) {
|
|
703
|
+
const calls = findAllPipeEffectProvideCalls(source);
|
|
704
|
+
if (calls.length === 0) return source;
|
|
705
|
+
let result = source;
|
|
706
|
+
for (let k = calls.length - 1; k >= 0; k--) {
|
|
707
|
+
const call = calls[k];
|
|
708
|
+
const layerExpr = result.slice(call.argStart, call.endIdx).trim();
|
|
709
|
+
const tagName = deriveTagFromLayerExpr(layerExpr);
|
|
710
|
+
if (!tagName) {
|
|
711
|
+
console.warn(`[Upgrade] ${relPath}: found .pipe(Effect.provide(${layerExpr})) but could not derive a tag name — skipping. Migrate manually to tools.buildService(<Tag>, ${layerExpr}).`);
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
const tagUseRe = new RegExp(`(yield\\*\\s+)${escapeRegex(tagName)}(\\s*;?)`, "g");
|
|
715
|
+
const tagMatches = [...result.matchAll(tagUseRe)];
|
|
716
|
+
if (tagMatches.length !== 1) {
|
|
717
|
+
console.warn(`[Upgrade] ${relPath}: found .pipe(Effect.provide(${layerExpr})) expecting a single \`yield* ${tagName}\`, but found ${tagMatches.length} — skipping. Migrate manually.`);
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
const tm = tagMatches[0];
|
|
721
|
+
const tagStart = tm.index ?? -1;
|
|
722
|
+
if (tagStart < 0) continue;
|
|
723
|
+
const tagLen = tm[0].length;
|
|
724
|
+
const replacement = `${tm[1]}tools.buildService(${tagName}, ${layerExpr})${tm[2]}`;
|
|
725
|
+
if (tagStart < call.dotIdx) result = result.slice(0, tagStart) + replacement + result.slice(tagStart + tagLen, call.dotIdx) + result.slice(call.pipeCloseEnd);
|
|
726
|
+
else result = result.slice(0, call.dotIdx) + result.slice(call.pipeCloseEnd, tagStart) + replacement + result.slice(tagStart + tagLen);
|
|
727
|
+
}
|
|
728
|
+
return result;
|
|
729
|
+
}
|
|
634
730
|
async function rewriteLegacyPluginScopedLayerPatterns(projectDir) {
|
|
635
|
-
const files = await (0, glob.glob)("plugins/*/src/index.ts", {
|
|
731
|
+
const files = await (0, glob.glob)(["plugins/*/src/index.ts", "api/src/index.ts"], {
|
|
636
732
|
cwd: projectDir,
|
|
637
733
|
nodir: true,
|
|
638
734
|
dot: false,
|
|
@@ -646,6 +742,7 @@ async function rewriteLegacyPluginScopedLayerPatterns(projectDir) {
|
|
|
646
742
|
const original = (0, node_fs.readFileSync)(filePath, "utf-8");
|
|
647
743
|
let next = original;
|
|
648
744
|
next = next.replaceAll(effectProvidePattern, "yield* tools.buildService(");
|
|
745
|
+
next = rewritePipeEffectProvideForm(next, file);
|
|
649
746
|
if (next.includes("tools.buildService(")) next = next.replace(/(initialize:\s*)\((\w+)(?:,\s*(\w+))?\s*\)\s*=>/g, (_match, prefix, p1, p2) => {
|
|
650
747
|
if (p2) return `${prefix}(${p1}, ${p2}, tools) =>`;
|
|
651
748
|
return `${prefix}(${p1}, _plugins, tools) =>`;
|
package/dist/cli/upgrade.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.cjs","names":["fetchParentConfig","resolveCatalogChainSource","resolveExtendsRef","saveBosConfig","process","p","readInstalledFrameworkVersion","buildChildRootScripts","timePhase","syncTemplate","loadResolvedConfig","syncResolvedSharedDeps","runBunInstallForUpgrade","runTypesGen"],"sources":["../../src/cli/upgrade.ts"],"sourcesContent":["import { 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 { loadResolvedConfig } from \"../config\";\nimport type { PhaseTiming, UpgradeOptions, UpgradeResult } from \"../contract\";\nimport { resolveExtendsRef } from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { readInstalledFrameworkVersion } from \"./framework-version\";\nimport {\n buildChildRootScripts,\n fetchParentConfig,\n resolveCatalogChainSource,\n runBunInstallForUpgrade,\n runTypesGen,\n} from \"./init\";\nimport { syncTemplate } from \"./sync\";\nimport { timePhase } from \"./timing\";\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/renovate.json\",\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 readJsonFile<T>(filePath: string): T {\n return JSON.parse(readFileSync(filePath, \"utf-8\")) as T;\n}\n\nfunction readRootPackageJson(projectDir: string): Record<string, unknown> {\n return readJsonFile<Record<string, unknown>>(join(projectDir, \"package.json\"));\n}\n\nfunction readRootCatalogEntry(projectDir: string, packageName: string): string | undefined {\n const pkg = readRootPackageJson(projectDir) as {\n workspaces?: { catalog?: Record<string, string> };\n };\n return pkg.workspaces?.catalog?.[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 pkgPath = join(projectDir, \"package.json\");\n const pkg = readJsonFile<Record<string, unknown>>(pkgPath);\n let modified = syncPackageObjectCatalogRefs(pkg, Object.keys(parentCatalog));\n\n if (!pkg.workspaces || typeof pkg.workspaces !== \"object\") {\n pkg.workspaces = { packages: [], catalog: {} };\n modified = true;\n }\n\n const workspaces = pkg.workspaces as { packages?: string[]; catalog?: Record<string, string> };\n if (!workspaces.catalog || typeof workspaces.catalog !== \"object\") {\n workspaces.catalog = {};\n modified = true;\n }\n\n for (const [packageName, version] of Object.entries(parentCatalog)) {\n if (workspaces.catalog[packageName] !== version) {\n workspaces.catalog[packageName] = version;\n modified = true;\n }\n }\n\n if (modified) {\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return modified;\n}\n\nasync function readExtendedRootSource(projectDir: string): Promise<ExtendedRootSource> {\n const configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return { catalog: {}, extendsChain: [] };\n }\n\n const localConfig = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\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 getExtendsRef(config: Record<string, unknown>): string | undefined {\n if (typeof config.extends === \"string\") {\n return config.extends;\n }\n\n if (config.extends && typeof config.extends === \"object\") {\n return resolveExtendsRef(config.extends as Record<string, string>, \"production\");\n }\n\n return undefined;\n}\n\nfunction parseBosRef(ref: string): { account: string; gateway: string } | null {\n const match = ref.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!match?.[1] || !match[2]) return null;\n return { account: match[1], gateway: match[2] };\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 configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return null;\n }\n\n const localConfig = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\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 rootPkgPath = join(projectDir, \"package.json\");\n if (!existsSync(rootPkgPath)) return [];\n\n const rootPkg = JSON.parse(readFileSync(rootPkgPath, \"utf-8\")) as Record<string, unknown>;\n const workspaceConfig = rootPkg.workspaces as { packages?: string[] } | string[] | undefined;\n\n const patterns: string[] = [];\n if (Array.isArray(workspaceConfig)) {\n patterns.push(...workspaceConfig);\n } else if (workspaceConfig?.packages && Array.isArray(workspaceConfig.packages)) {\n patterns.push(...workspaceConfig.packages);\n }\n\n if (patterns.length === 0) return [];\n\n const pkgPaths: string[] = [];\n for (const pattern of patterns) {\n const matches = await glob(pattern, { cwd: projectDir, dot: false, absolute: false });\n for (const match of matches) {\n const pkgPath = join(projectDir, match, \"package.json\");\n if (existsSync(pkgPath) && statSync(pkgPath).isFile()) {\n pkgPaths.push(pkgPath);\n }\n }\n }\n\n return [...new Set(pkgPaths)];\n}\n\nexport async function migrateChildRootPackageJson(projectDir: string): Promise<boolean> {\n const configPath = join(projectDir, \"bos.config.json\");\n const pkgPath = join(projectDir, \"package.json\");\n if (!existsSync(configPath) || !existsSync(pkgPath)) {\n return false;\n }\n\n const config = readJsonFile<Record<string, unknown>>(configPath);\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 [\"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\nasync function rewriteLegacyPluginScopedLayerPatterns(projectDir: string): Promise<string[]> {\n const files = await glob(\"plugins/*/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 const effectProvidePattern = /\\byield\\*\\s*Effect\\.provide\\(/g;\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) → yield* tools.buildService(Tag, LayerExpr)\n next = next.replaceAll(effectProvidePattern, \"yield* tools.buildService(\");\n\n // Add tools as third argument to initialize if it only has (config) or (config, plugins)\n const hasEffectProvideOrServiceBuild = next.includes(\"tools.buildService(\");\n\n if (hasEffectProvideOrServiceBuild) {\n // Rewrite initialize: (config, plugins) => or initialize: (config) =>\n // to include tools\n next = next.replace(\n /(initialize:\\s*)\\((\\w+)(?:,\\s*(\\w+))?\\s*\\)\\s*=>/g,\n (_match, prefix: string, p1: string, p2: string | undefined) => {\n if (p2) {\n return `${prefix}(${p1}, ${p2}, tools) =>`;\n }\n return `${prefix}(${p1}, _plugins, tools) =>`;\n },\n );\n }\n\n if (next !== original) {\n writeFileSync(filePath, next);\n migrated.push(file);\n }\n }\n\n return migrated;\n}\n\nasync 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\nexport async function upgradeTemplate(\n projectDir: string,\n options: UpgradeOptions,\n): Promise<UpgradeResult> {\n const timings: PhaseTiming[] = [];\n const pkgPath = join(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 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 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) {\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 }),\n );\n\n if (inheritedCatalogPackageNames.length > 0) {\n syncRootCatalogWithParent(projectDir, sourceRootCatalog);\n }\n }\n\n const sharedSync = await timePhase(timings, \"sync shared deps\", async () => {\n const configResult = await loadResolvedConfig({ cwd: projectDir });\n if (!configResult) {\n throw new Error(\"No bos.config.json found in current directory\");\n }\n\n return syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n bosConfig: configResult.config,\n });\n });\n\n if ((hasUpdates || addedPlugins.length > 0 || sharedSync.catalogChanged) && !options.noInstall) {\n await timePhase(timings, \"install dependencies\", () => runBunInstallForUpgrade(projectDir));\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 = 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 return {\n status: \"upgraded\",\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n sync: syncResult,\n migrated: migratedFiles.length > 0 ? migratedFiles : undefined,\n selectedPlugins: addedPlugins.length > 0 ? addedPlugins : undefined,\n timings,\n changelogUrl,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,MAAM,qBAAqB,CAAC,kBAAkB,eAAe;AAC7D,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;CACjC;CACA;CACA;CACA;CACD;AACD,MAAM,4BAA4B;CAChC,CAAC,mBAAiB,iBAAe;CACjC,CAAC,iBAAiB,eAAe;CACjC,CAAC,6BAA2B,sBAAoB;CAChD,CAAC,2BAA2B,oBAAoB;CAChD,CAAC,iCAA+B,iBAAe;CAC/C,CAAC,+BAA+B,eAAe;CAC/C,CAAC,6BAA2B,iBAAe;CAC3C,CAAC,2BAA2B,eAAe;CAC5C;AACD,MAAM,iBAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAQD,SAAS,cAAc,OAA0C;AAC/D,KAAI,CAAC,MAAO,QAAO;AAEnB,QADc,MAAM,MAAM,oCACd,GAAG,MAAM;;AAGvB,SAAS,aAAgB,UAAqB;AAC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AAS,IAAI,eAAe;EAC1D;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"upgrade.cjs","names":["fetchParentConfig","resolveCatalogChainSource","resolveExtendsRef","saveBosConfig","process","p","readInstalledFrameworkVersion","buildChildRootScripts","timePhase","syncTemplate","loadResolvedConfig","syncResolvedSharedDeps","runBunInstallForUpgrade","runTypesGen"],"sources":["../../src/cli/upgrade.ts"],"sourcesContent":["import { 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 { loadResolvedConfig } from \"../config\";\nimport type { PhaseTiming, UpgradeOptions, UpgradeResult } from \"../contract\";\nimport { resolveExtendsRef } from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { readInstalledFrameworkVersion } from \"./framework-version\";\nimport {\n buildChildRootScripts,\n fetchParentConfig,\n resolveCatalogChainSource,\n runBunInstallForUpgrade,\n runTypesGen,\n} from \"./init\";\nimport { syncTemplate } from \"./sync\";\nimport { timePhase } from \"./timing\";\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/renovate.json\",\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 readJsonFile<T>(filePath: string): T {\n return JSON.parse(readFileSync(filePath, \"utf-8\")) as T;\n}\n\nfunction readRootPackageJson(projectDir: string): Record<string, unknown> {\n return readJsonFile<Record<string, unknown>>(join(projectDir, \"package.json\"));\n}\n\nfunction readRootCatalogEntry(projectDir: string, packageName: string): string | undefined {\n const pkg = readRootPackageJson(projectDir) as {\n workspaces?: { catalog?: Record<string, string> };\n };\n return pkg.workspaces?.catalog?.[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 pkgPath = join(projectDir, \"package.json\");\n const pkg = readJsonFile<Record<string, unknown>>(pkgPath);\n let modified = syncPackageObjectCatalogRefs(pkg, Object.keys(parentCatalog));\n\n if (!pkg.workspaces || typeof pkg.workspaces !== \"object\") {\n pkg.workspaces = { packages: [], catalog: {} };\n modified = true;\n }\n\n const workspaces = pkg.workspaces as { packages?: string[]; catalog?: Record<string, string> };\n if (!workspaces.catalog || typeof workspaces.catalog !== \"object\") {\n workspaces.catalog = {};\n modified = true;\n }\n\n for (const [packageName, version] of Object.entries(parentCatalog)) {\n if (workspaces.catalog[packageName] !== version) {\n workspaces.catalog[packageName] = version;\n modified = true;\n }\n }\n\n if (modified) {\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return modified;\n}\n\nasync function readExtendedRootSource(projectDir: string): Promise<ExtendedRootSource> {\n const configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return { catalog: {}, extendsChain: [] };\n }\n\n const localConfig = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\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 getExtendsRef(config: Record<string, unknown>): string | undefined {\n if (typeof config.extends === \"string\") {\n return config.extends;\n }\n\n if (config.extends && typeof config.extends === \"object\") {\n return resolveExtendsRef(config.extends as Record<string, string>, \"production\");\n }\n\n return undefined;\n}\n\nfunction parseBosRef(ref: string): { account: string; gateway: string } | null {\n const match = ref.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!match?.[1] || !match[2]) return null;\n return { account: match[1], gateway: match[2] };\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 configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return null;\n }\n\n const localConfig = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\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 rootPkgPath = join(projectDir, \"package.json\");\n if (!existsSync(rootPkgPath)) return [];\n\n const rootPkg = JSON.parse(readFileSync(rootPkgPath, \"utf-8\")) as Record<string, unknown>;\n const workspaceConfig = rootPkg.workspaces as { packages?: string[] } | string[] | undefined;\n\n const patterns: string[] = [];\n if (Array.isArray(workspaceConfig)) {\n patterns.push(...workspaceConfig);\n } else if (workspaceConfig?.packages && Array.isArray(workspaceConfig.packages)) {\n patterns.push(...workspaceConfig.packages);\n }\n\n if (patterns.length === 0) return [];\n\n const pkgPaths: string[] = [];\n for (const pattern of patterns) {\n const matches = await glob(pattern, { cwd: projectDir, dot: false, absolute: false });\n for (const match of matches) {\n const pkgPath = join(projectDir, match, \"package.json\");\n if (existsSync(pkgPath) && statSync(pkgPath).isFile()) {\n pkgPaths.push(pkgPath);\n }\n }\n }\n\n return [...new Set(pkgPaths)];\n}\n\nexport async function migrateChildRootPackageJson(projectDir: string): Promise<boolean> {\n const configPath = join(projectDir, \"bos.config.json\");\n const pkgPath = join(projectDir, \"package.json\");\n if (!existsSync(configPath) || !existsSync(pkgPath)) {\n return false;\n }\n\n const config = readJsonFile<Record<string, unknown>>(configPath);\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 [\"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 tools.buildService(<Tag>, ${layerExpr}).`,\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 = `${tm[1]}tools.buildService(${tagName}, ${layerExpr})${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\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 const effectProvidePattern = /\\byield\\*\\s*Effect\\.provide\\(/g;\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) → yield* tools.buildService(Tag, LayerExpr)\n next = next.replaceAll(effectProvidePattern, \"yield* tools.buildService(\");\n\n // Rewrite the .pipe(Effect.provide(<LayerExpr>)) form: move <LayerExpr> into a\n // tools.buildService(<Tag>, <LayerExpr>) call replacing the bare `yield* <Tag>`\n // inside the generator, and drop the trailing .pipe(Effect.provide(...)).\n next = rewritePipeEffectProvideForm(next, file);\n\n // Add tools as third argument to initialize if it only has (config) or (config, plugins)\n const hasEffectProvideOrServiceBuild = next.includes(\"tools.buildService(\");\n\n if (hasEffectProvideOrServiceBuild) {\n // Rewrite initialize: (config, plugins) => or initialize: (config) =>\n // to include tools\n next = next.replace(\n /(initialize:\\s*)\\((\\w+)(?:,\\s*(\\w+))?\\s*\\)\\s*=>/g,\n (_match, prefix: string, p1: string, p2: string | undefined) => {\n if (p2) {\n return `${prefix}(${p1}, ${p2}, tools) =>`;\n }\n return `${prefix}(${p1}, _plugins, tools) =>`;\n },\n );\n }\n\n if (next !== original) {\n writeFileSync(filePath, next);\n migrated.push(file);\n }\n }\n\n return migrated;\n}\n\nasync 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\nexport async function upgradeTemplate(\n projectDir: string,\n options: UpgradeOptions,\n): Promise<UpgradeResult> {\n const timings: PhaseTiming[] = [];\n const pkgPath = join(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 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 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) {\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 }),\n );\n\n if (inheritedCatalogPackageNames.length > 0) {\n syncRootCatalogWithParent(projectDir, sourceRootCatalog);\n }\n }\n\n const sharedSync = await timePhase(timings, \"sync shared deps\", async () => {\n const configResult = await loadResolvedConfig({ cwd: projectDir });\n if (!configResult) {\n throw new Error(\"No bos.config.json found in current directory\");\n }\n\n return syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n bosConfig: configResult.config,\n });\n });\n\n if ((hasUpdates || addedPlugins.length > 0 || sharedSync.catalogChanged) && !options.noInstall) {\n await timePhase(timings, \"install dependencies\", () => runBunInstallForUpgrade(projectDir));\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 = 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 return {\n status: \"upgraded\",\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n sync: syncResult,\n migrated: migratedFiles.length > 0 ? migratedFiles : undefined,\n selectedPlugins: addedPlugins.length > 0 ? addedPlugins : undefined,\n timings,\n changelogUrl,\n };\n}\n"],"mappings":";;;;;;;;;;;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A0B,CAAC,eAAe,GAAG,EAAE;GACnD,GAAI,MAAM,uBAAuB,WAAW;GAC5C,GAAI,MAAM,uCAAuC,WAAW;GAC5D,GAAI,MAAM,yBAAyB,WAAW;GAC/C;AACD,OAAK,MAAM,QAAQ,gBAAgB;GACjC,MAAM,+BAAgB,YAAY,KAAK;AACvC,+BAAe,SAAS,EAAE;AACxB,wBAAO,SAAS;AAChB,sBAAkB,KAAK,KAAK;;;EAIhC,MAAM,sBAAsB,qBAAW,kDAAkD;GACvF,KAAK;GACL,OAAO;GACP,KAAK;GACL,UAAU;GACX,CAAC;AACF,OAAK,MAAM,QAAQ,qBAAqB;AACtC,2CAAY,YAAY,KAAK,CAAC;AAC9B,qBAAkB,KAAK,KAAK;;AAG9B,SAAO;GACP;CAEF,IAAI;CACJ,MAAM,UAAU,SAAS,MAAM,MAAM,EAAE,SAAS,iBAAiB;AACjE,KAAI,SAAS,QAAQ,QAAQ,SAAS,QAAQ,GAC5C,gBAAe,kBAAkB,QAAQ,MAAM,QAAQ,IAAI,aAAa,WAAW;AAGrF,QAAO;EACL,QAAQ;EACR,UAAU,CACR,GAAG,UACH,GAAG,sBAAsB,KAAK,OAAO;GAAE,MAAM,EAAE;GAAM,MAAM,EAAE;GAAM,IAAI,EAAE;GAAI,EAAE,CAChF;EACD,MAAM;EACN,UAAU,cAAc,SAAS,IAAI,gBAAgB;EACrD,iBAAiB,aAAa,SAAS,IAAI,eAAe;EAC1D;EACA;EACD"}
|
package/dist/cli/upgrade.mjs
CHANGED
|
@@ -628,8 +628,104 @@ async function rewriteLegacyUiImports(projectDir) {
|
|
|
628
628
|
return migrated;
|
|
629
629
|
}
|
|
630
630
|
const LEGACY_DIST_IMPORT_REWRITES = [["from \"everything-dev/dist/", "from \"everything-dev/"], ["from 'everything-dev/dist/", "from 'everything-dev/"]];
|
|
631
|
+
function escapeRegex(s) {
|
|
632
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
633
|
+
}
|
|
634
|
+
function balancedParenEnd(source, openIdx) {
|
|
635
|
+
let depth = 1;
|
|
636
|
+
let i = openIdx;
|
|
637
|
+
while (i < source.length) {
|
|
638
|
+
const ch = source[i];
|
|
639
|
+
if (ch === "(") depth++;
|
|
640
|
+
else if (ch === ")") {
|
|
641
|
+
depth--;
|
|
642
|
+
if (depth === 0) return i;
|
|
643
|
+
}
|
|
644
|
+
i++;
|
|
645
|
+
}
|
|
646
|
+
return -1;
|
|
647
|
+
}
|
|
648
|
+
function deriveTagFromLayerExpr(layerExpr) {
|
|
649
|
+
const m = layerExpr.match(/^\s*([A-Z]\w*)/);
|
|
650
|
+
if (!m) return null;
|
|
651
|
+
const name = m[1];
|
|
652
|
+
if (name.endsWith("Live")) return `${name.slice(0, -4)}Tag`;
|
|
653
|
+
if (name.endsWith("Layer")) return `${name.slice(0, -5)}Tag`;
|
|
654
|
+
return null;
|
|
655
|
+
}
|
|
656
|
+
function findAllPipeEffectProvideCalls(source) {
|
|
657
|
+
const out = [];
|
|
658
|
+
const needle = "Effect.provide(";
|
|
659
|
+
let searchFrom = 0;
|
|
660
|
+
while (true) {
|
|
661
|
+
const provideIdx = source.indexOf(needle, searchFrom);
|
|
662
|
+
if (provideIdx === -1) break;
|
|
663
|
+
const argStart = provideIdx + 15;
|
|
664
|
+
const endIdx = balancedParenEnd(source, argStart);
|
|
665
|
+
if (endIdx === -1) {
|
|
666
|
+
searchFrom = argStart;
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
669
|
+
let p = provideIdx - 1;
|
|
670
|
+
while (p >= 0 && /\s/.test(source[p])) p--;
|
|
671
|
+
if (p < 0 || source[p] !== "(") {
|
|
672
|
+
searchFrom = endIdx + 1;
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
p--;
|
|
676
|
+
if (p - 5 + 1 < 0 || source.slice(p - 5 + 1, p + 1) !== ".pipe") {
|
|
677
|
+
searchFrom = endIdx + 1;
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
const dotIdx = p - 5 + 1;
|
|
681
|
+
let q = endIdx + 1;
|
|
682
|
+
while (q < source.length && /\s/.test(source[q])) q++;
|
|
683
|
+
if (q < source.length && source[q] === ",") q++;
|
|
684
|
+
while (q < source.length && /\s/.test(source[q])) q++;
|
|
685
|
+
if (q >= source.length || source[q] !== ")") {
|
|
686
|
+
searchFrom = endIdx + 1;
|
|
687
|
+
continue;
|
|
688
|
+
}
|
|
689
|
+
out.push({
|
|
690
|
+
argStart,
|
|
691
|
+
endIdx,
|
|
692
|
+
dotIdx,
|
|
693
|
+
pipeCloseEnd: q + 1
|
|
694
|
+
});
|
|
695
|
+
searchFrom = q + 1;
|
|
696
|
+
}
|
|
697
|
+
return out;
|
|
698
|
+
}
|
|
699
|
+
function rewritePipeEffectProvideForm(source, relPath) {
|
|
700
|
+
const calls = findAllPipeEffectProvideCalls(source);
|
|
701
|
+
if (calls.length === 0) return source;
|
|
702
|
+
let result = source;
|
|
703
|
+
for (let k = calls.length - 1; k >= 0; k--) {
|
|
704
|
+
const call = calls[k];
|
|
705
|
+
const layerExpr = result.slice(call.argStart, call.endIdx).trim();
|
|
706
|
+
const tagName = deriveTagFromLayerExpr(layerExpr);
|
|
707
|
+
if (!tagName) {
|
|
708
|
+
console.warn(`[Upgrade] ${relPath}: found .pipe(Effect.provide(${layerExpr})) but could not derive a tag name — skipping. Migrate manually to tools.buildService(<Tag>, ${layerExpr}).`);
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
const tagUseRe = new RegExp(`(yield\\*\\s+)${escapeRegex(tagName)}(\\s*;?)`, "g");
|
|
712
|
+
const tagMatches = [...result.matchAll(tagUseRe)];
|
|
713
|
+
if (tagMatches.length !== 1) {
|
|
714
|
+
console.warn(`[Upgrade] ${relPath}: found .pipe(Effect.provide(${layerExpr})) expecting a single \`yield* ${tagName}\`, but found ${tagMatches.length} — skipping. Migrate manually.`);
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
const tm = tagMatches[0];
|
|
718
|
+
const tagStart = tm.index ?? -1;
|
|
719
|
+
if (tagStart < 0) continue;
|
|
720
|
+
const tagLen = tm[0].length;
|
|
721
|
+
const replacement = `${tm[1]}tools.buildService(${tagName}, ${layerExpr})${tm[2]}`;
|
|
722
|
+
if (tagStart < call.dotIdx) result = result.slice(0, tagStart) + replacement + result.slice(tagStart + tagLen, call.dotIdx) + result.slice(call.pipeCloseEnd);
|
|
723
|
+
else result = result.slice(0, call.dotIdx) + result.slice(call.pipeCloseEnd, tagStart) + replacement + result.slice(tagStart + tagLen);
|
|
724
|
+
}
|
|
725
|
+
return result;
|
|
726
|
+
}
|
|
631
727
|
async function rewriteLegacyPluginScopedLayerPatterns(projectDir) {
|
|
632
|
-
const files = await glob("plugins/*/src/index.ts", {
|
|
728
|
+
const files = await glob(["plugins/*/src/index.ts", "api/src/index.ts"], {
|
|
633
729
|
cwd: projectDir,
|
|
634
730
|
nodir: true,
|
|
635
731
|
dot: false,
|
|
@@ -643,6 +739,7 @@ async function rewriteLegacyPluginScopedLayerPatterns(projectDir) {
|
|
|
643
739
|
const original = readFileSync(filePath, "utf-8");
|
|
644
740
|
let next = original;
|
|
645
741
|
next = next.replaceAll(effectProvidePattern, "yield* tools.buildService(");
|
|
742
|
+
next = rewritePipeEffectProvideForm(next, file);
|
|
646
743
|
if (next.includes("tools.buildService(")) next = next.replace(/(initialize:\s*)\((\w+)(?:,\s*(\w+))?\s*\)\s*=>/g, (_match, prefix, p1, p2) => {
|
|
647
744
|
if (p2) return `${prefix}(${p1}, ${p2}, tools) =>`;
|
|
648
745
|
return `${prefix}(${p1}, _plugins, tools) =>`;
|
package/dist/cli/upgrade.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.mjs","names":[],"sources":["../../src/cli/upgrade.ts"],"sourcesContent":["import { 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 { loadResolvedConfig } from \"../config\";\nimport type { PhaseTiming, UpgradeOptions, UpgradeResult } from \"../contract\";\nimport { resolveExtendsRef } from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { readInstalledFrameworkVersion } from \"./framework-version\";\nimport {\n buildChildRootScripts,\n fetchParentConfig,\n resolveCatalogChainSource,\n runBunInstallForUpgrade,\n runTypesGen,\n} from \"./init\";\nimport { syncTemplate } from \"./sync\";\nimport { timePhase } from \"./timing\";\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/renovate.json\",\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 readJsonFile<T>(filePath: string): T {\n return JSON.parse(readFileSync(filePath, \"utf-8\")) as T;\n}\n\nfunction readRootPackageJson(projectDir: string): Record<string, unknown> {\n return readJsonFile<Record<string, unknown>>(join(projectDir, \"package.json\"));\n}\n\nfunction readRootCatalogEntry(projectDir: string, packageName: string): string | undefined {\n const pkg = readRootPackageJson(projectDir) as {\n workspaces?: { catalog?: Record<string, string> };\n };\n return pkg.workspaces?.catalog?.[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 pkgPath = join(projectDir, \"package.json\");\n const pkg = readJsonFile<Record<string, unknown>>(pkgPath);\n let modified = syncPackageObjectCatalogRefs(pkg, Object.keys(parentCatalog));\n\n if (!pkg.workspaces || typeof pkg.workspaces !== \"object\") {\n pkg.workspaces = { packages: [], catalog: {} };\n modified = true;\n }\n\n const workspaces = pkg.workspaces as { packages?: string[]; catalog?: Record<string, string> };\n if (!workspaces.catalog || typeof workspaces.catalog !== \"object\") {\n workspaces.catalog = {};\n modified = true;\n }\n\n for (const [packageName, version] of Object.entries(parentCatalog)) {\n if (workspaces.catalog[packageName] !== version) {\n workspaces.catalog[packageName] = version;\n modified = true;\n }\n }\n\n if (modified) {\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return modified;\n}\n\nasync function readExtendedRootSource(projectDir: string): Promise<ExtendedRootSource> {\n const configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return { catalog: {}, extendsChain: [] };\n }\n\n const localConfig = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\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 getExtendsRef(config: Record<string, unknown>): string | undefined {\n if (typeof config.extends === \"string\") {\n return config.extends;\n }\n\n if (config.extends && typeof config.extends === \"object\") {\n return resolveExtendsRef(config.extends as Record<string, string>, \"production\");\n }\n\n return undefined;\n}\n\nfunction parseBosRef(ref: string): { account: string; gateway: string } | null {\n const match = ref.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!match?.[1] || !match[2]) return null;\n return { account: match[1], gateway: match[2] };\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 configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return null;\n }\n\n const localConfig = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\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 rootPkgPath = join(projectDir, \"package.json\");\n if (!existsSync(rootPkgPath)) return [];\n\n const rootPkg = JSON.parse(readFileSync(rootPkgPath, \"utf-8\")) as Record<string, unknown>;\n const workspaceConfig = rootPkg.workspaces as { packages?: string[] } | string[] | undefined;\n\n const patterns: string[] = [];\n if (Array.isArray(workspaceConfig)) {\n patterns.push(...workspaceConfig);\n } else if (workspaceConfig?.packages && Array.isArray(workspaceConfig.packages)) {\n patterns.push(...workspaceConfig.packages);\n }\n\n if (patterns.length === 0) return [];\n\n const pkgPaths: string[] = [];\n for (const pattern of patterns) {\n const matches = await glob(pattern, { cwd: projectDir, dot: false, absolute: false });\n for (const match of matches) {\n const pkgPath = join(projectDir, match, \"package.json\");\n if (existsSync(pkgPath) && statSync(pkgPath).isFile()) {\n pkgPaths.push(pkgPath);\n }\n }\n }\n\n return [...new Set(pkgPaths)];\n}\n\nexport async function migrateChildRootPackageJson(projectDir: string): Promise<boolean> {\n const configPath = join(projectDir, \"bos.config.json\");\n const pkgPath = join(projectDir, \"package.json\");\n if (!existsSync(configPath) || !existsSync(pkgPath)) {\n return false;\n }\n\n const config = readJsonFile<Record<string, unknown>>(configPath);\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 [\"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\nasync function rewriteLegacyPluginScopedLayerPatterns(projectDir: string): Promise<string[]> {\n const files = await glob(\"plugins/*/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 const effectProvidePattern = /\\byield\\*\\s*Effect\\.provide\\(/g;\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) → yield* tools.buildService(Tag, LayerExpr)\n next = next.replaceAll(effectProvidePattern, \"yield* tools.buildService(\");\n\n // Add tools as third argument to initialize if it only has (config) or (config, plugins)\n const hasEffectProvideOrServiceBuild = next.includes(\"tools.buildService(\");\n\n if (hasEffectProvideOrServiceBuild) {\n // Rewrite initialize: (config, plugins) => or initialize: (config) =>\n // to include tools\n next = next.replace(\n /(initialize:\\s*)\\((\\w+)(?:,\\s*(\\w+))?\\s*\\)\\s*=>/g,\n (_match, prefix: string, p1: string, p2: string | undefined) => {\n if (p2) {\n return `${prefix}(${p1}, ${p2}, tools) =>`;\n }\n return `${prefix}(${p1}, _plugins, tools) =>`;\n },\n );\n }\n\n if (next !== original) {\n writeFileSync(filePath, next);\n migrated.push(file);\n }\n }\n\n return migrated;\n}\n\nasync 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\nexport async function upgradeTemplate(\n projectDir: string,\n options: UpgradeOptions,\n): Promise<UpgradeResult> {\n const timings: PhaseTiming[] = [];\n const pkgPath = join(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 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 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) {\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 }),\n );\n\n if (inheritedCatalogPackageNames.length > 0) {\n syncRootCatalogWithParent(projectDir, sourceRootCatalog);\n }\n }\n\n const sharedSync = await timePhase(timings, \"sync shared deps\", async () => {\n const configResult = await loadResolvedConfig({ cwd: projectDir });\n if (!configResult) {\n throw new Error(\"No bos.config.json found in current directory\");\n }\n\n return syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n bosConfig: configResult.config,\n });\n });\n\n if ((hasUpdates || addedPlugins.length > 0 || sharedSync.catalogChanged) && !options.noInstall) {\n await timePhase(timings, \"install dependencies\", () => runBunInstallForUpgrade(projectDir));\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 = 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 return {\n status: \"upgraded\",\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n sync: syncResult,\n migrated: migratedFiles.length > 0 ? migratedFiles : undefined,\n selectedPlugins: addedPlugins.length > 0 ? addedPlugins : undefined,\n timings,\n changelogUrl,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAM,qBAAqB,CAAC,kBAAkB,eAAe;AAC7D,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;CACjC;CACA;CACA;CACA;CACD;AACD,MAAM,4BAA4B;CAChC,CAAC,mBAAiB,iBAAe;CACjC,CAAC,iBAAiB,eAAe;CACjC,CAAC,6BAA2B,sBAAoB;CAChD,CAAC,2BAA2B,oBAAoB;CAChD,CAAC,iCAA+B,i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AACF,OAAK,MAAM,QAAQ,qBAAqB;AACtC,UAAO,KAAK,YAAY,KAAK,CAAC;AAC9B,qBAAkB,KAAK,KAAK;;AAG9B,SAAO;GACP;CAEF,IAAI;CACJ,MAAM,UAAU,SAAS,MAAM,MAAM,EAAE,SAAS,iBAAiB;AACjE,KAAI,SAAS,QAAQ,QAAQ,SAAS,QAAQ,GAC5C,gBAAe,kBAAkB,QAAQ,MAAM,QAAQ,IAAI,aAAa,WAAW;AAGrF,QAAO;EACL,QAAQ;EACR,UAAU,CACR,GAAG,UACH,GAAG,sBAAsB,KAAK,OAAO;GAAE,MAAM,EAAE;GAAM,MAAM,EAAE;GAAM,IAAI,EAAE;GAAI,EAAE,CAChF;EACD,MAAM;EACN,UAAU,cAAc,SAAS,IAAI,gBAAgB;EACrD,iBAAiB,aAAa,SAAS,IAAI,eAAe;EAC1D;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"upgrade.mjs","names":[],"sources":["../../src/cli/upgrade.ts"],"sourcesContent":["import { 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 { loadResolvedConfig } from \"../config\";\nimport type { PhaseTiming, UpgradeOptions, UpgradeResult } from \"../contract\";\nimport { resolveExtendsRef } from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { readInstalledFrameworkVersion } from \"./framework-version\";\nimport {\n buildChildRootScripts,\n fetchParentConfig,\n resolveCatalogChainSource,\n runBunInstallForUpgrade,\n runTypesGen,\n} from \"./init\";\nimport { syncTemplate } from \"./sync\";\nimport { timePhase } from \"./timing\";\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/renovate.json\",\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 readJsonFile<T>(filePath: string): T {\n return JSON.parse(readFileSync(filePath, \"utf-8\")) as T;\n}\n\nfunction readRootPackageJson(projectDir: string): Record<string, unknown> {\n return readJsonFile<Record<string, unknown>>(join(projectDir, \"package.json\"));\n}\n\nfunction readRootCatalogEntry(projectDir: string, packageName: string): string | undefined {\n const pkg = readRootPackageJson(projectDir) as {\n workspaces?: { catalog?: Record<string, string> };\n };\n return pkg.workspaces?.catalog?.[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 pkgPath = join(projectDir, \"package.json\");\n const pkg = readJsonFile<Record<string, unknown>>(pkgPath);\n let modified = syncPackageObjectCatalogRefs(pkg, Object.keys(parentCatalog));\n\n if (!pkg.workspaces || typeof pkg.workspaces !== \"object\") {\n pkg.workspaces = { packages: [], catalog: {} };\n modified = true;\n }\n\n const workspaces = pkg.workspaces as { packages?: string[]; catalog?: Record<string, string> };\n if (!workspaces.catalog || typeof workspaces.catalog !== \"object\") {\n workspaces.catalog = {};\n modified = true;\n }\n\n for (const [packageName, version] of Object.entries(parentCatalog)) {\n if (workspaces.catalog[packageName] !== version) {\n workspaces.catalog[packageName] = version;\n modified = true;\n }\n }\n\n if (modified) {\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n return modified;\n}\n\nasync function readExtendedRootSource(projectDir: string): Promise<ExtendedRootSource> {\n const configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return { catalog: {}, extendsChain: [] };\n }\n\n const localConfig = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\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 getExtendsRef(config: Record<string, unknown>): string | undefined {\n if (typeof config.extends === \"string\") {\n return config.extends;\n }\n\n if (config.extends && typeof config.extends === \"object\") {\n return resolveExtendsRef(config.extends as Record<string, string>, \"production\");\n }\n\n return undefined;\n}\n\nfunction parseBosRef(ref: string): { account: string; gateway: string } | null {\n const match = ref.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!match?.[1] || !match[2]) return null;\n return { account: match[1], gateway: match[2] };\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 configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return null;\n }\n\n const localConfig = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\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 rootPkgPath = join(projectDir, \"package.json\");\n if (!existsSync(rootPkgPath)) return [];\n\n const rootPkg = JSON.parse(readFileSync(rootPkgPath, \"utf-8\")) as Record<string, unknown>;\n const workspaceConfig = rootPkg.workspaces as { packages?: string[] } | string[] | undefined;\n\n const patterns: string[] = [];\n if (Array.isArray(workspaceConfig)) {\n patterns.push(...workspaceConfig);\n } else if (workspaceConfig?.packages && Array.isArray(workspaceConfig.packages)) {\n patterns.push(...workspaceConfig.packages);\n }\n\n if (patterns.length === 0) return [];\n\n const pkgPaths: string[] = [];\n for (const pattern of patterns) {\n const matches = await glob(pattern, { cwd: projectDir, dot: false, absolute: false });\n for (const match of matches) {\n const pkgPath = join(projectDir, match, \"package.json\");\n if (existsSync(pkgPath) && statSync(pkgPath).isFile()) {\n pkgPaths.push(pkgPath);\n }\n }\n }\n\n return [...new Set(pkgPaths)];\n}\n\nexport async function migrateChildRootPackageJson(projectDir: string): Promise<boolean> {\n const configPath = join(projectDir, \"bos.config.json\");\n const pkgPath = join(projectDir, \"package.json\");\n if (!existsSync(configPath) || !existsSync(pkgPath)) {\n return false;\n }\n\n const config = readJsonFile<Record<string, unknown>>(configPath);\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 [\"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 tools.buildService(<Tag>, ${layerExpr}).`,\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 = `${tm[1]}tools.buildService(${tagName}, ${layerExpr})${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\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 const effectProvidePattern = /\\byield\\*\\s*Effect\\.provide\\(/g;\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) → yield* tools.buildService(Tag, LayerExpr)\n next = next.replaceAll(effectProvidePattern, \"yield* tools.buildService(\");\n\n // Rewrite the .pipe(Effect.provide(<LayerExpr>)) form: move <LayerExpr> into a\n // tools.buildService(<Tag>, <LayerExpr>) call replacing the bare `yield* <Tag>`\n // inside the generator, and drop the trailing .pipe(Effect.provide(...)).\n next = rewritePipeEffectProvideForm(next, file);\n\n // Add tools as third argument to initialize if it only has (config) or (config, plugins)\n const hasEffectProvideOrServiceBuild = next.includes(\"tools.buildService(\");\n\n if (hasEffectProvideOrServiceBuild) {\n // Rewrite initialize: (config, plugins) => or initialize: (config) =>\n // to include tools\n next = next.replace(\n /(initialize:\\s*)\\((\\w+)(?:,\\s*(\\w+))?\\s*\\)\\s*=>/g,\n (_match, prefix: string, p1: string, p2: string | undefined) => {\n if (p2) {\n return `${prefix}(${p1}, ${p2}, tools) =>`;\n }\n return `${prefix}(${p1}, _plugins, tools) =>`;\n },\n );\n }\n\n if (next !== original) {\n writeFileSync(filePath, next);\n migrated.push(file);\n }\n }\n\n return migrated;\n}\n\nasync 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\nexport async function upgradeTemplate(\n projectDir: string,\n options: UpgradeOptions,\n): Promise<UpgradeResult> {\n const timings: PhaseTiming[] = [];\n const pkgPath = join(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 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 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) {\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 }),\n );\n\n if (inheritedCatalogPackageNames.length > 0) {\n syncRootCatalogWithParent(projectDir, sourceRootCatalog);\n }\n }\n\n const sharedSync = await timePhase(timings, \"sync shared deps\", async () => {\n const configResult = await loadResolvedConfig({ cwd: projectDir });\n if (!configResult) {\n throw new Error(\"No bos.config.json found in current directory\");\n }\n\n return syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n bosConfig: configResult.config,\n });\n });\n\n if ((hasUpdates || addedPlugins.length > 0 || sharedSync.catalogChanged) && !options.noInstall) {\n await timePhase(timings, \"install dependencies\", () => runBunInstallForUpgrade(projectDir));\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 = 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 return {\n status: \"upgraded\",\n packages: [\n ...packages,\n ...catalogVersionUpdates.map((u) => ({ name: u.name, from: u.from, to: u.to })),\n ],\n sync: syncResult,\n migrated: migratedFiles.length > 0 ? migratedFiles : undefined,\n selectedPlugins: addedPlugins.length > 0 ? addedPlugins : undefined,\n timings,\n changelogUrl,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAM,qBAAqB,CAAC,kBAAkB,eAAe;AAC7D,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;CACjC;CACA;CACA;CACA;CACD;AACD,MAAM,4BAA4B;CAChC,CAAC,mBAAiB,iBAAe;CACjC,CAAC,iBAAiB,eAAe;CACjC,CAAC,6BAA2B,sBAAoB;CAChD,CAAC,2BAA2B,oBAAoB;CAChD,CAAC,iCAA+B,iBAAe;CAC/C,CAAC,+BAA+B,eAAe;CAC/C,CAAC,6BAA2B,iBAAe;CAC3C,CAAC,2BAA2B,eAAe;CAC5C;AACD,MAAM,iBAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAQD,SAAS,cAAc,OAA0C;AAC/D,KAAI,CAAC,MAAO,QAAO;AAEnB,QADc,MAAM,MAAM,oCACd,GAAG,MAAM;;AAGvB,SAAS,aAAgB,UAAqB;AAC5C,QAAO,KAAK,MAAM,aAAa,UAAU,QAAQ,CAAC;;AAGpD,SAAS,oBAAoB,YAA6C;AACxE,QAAO,aAAsC,KAAK,YAAY,eAAe,CAAC;;AAGhF,SAAS,qBAAqB,YAAoB,aAAyC;AAIzF,QAHY,oBAAoB,WAGtB,CAAC,YAAY,UAAU;;AAGnC,SAAS,4BAA4B,YAAoB,aAAy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KAAK,OAAO;GAAE,MAAM,EAAE;GAAM,MAAM,EAAE;GAAM,IAAI,EAAE;GAAI,EAAE,CAChF;EACD,MAAM;EACN,UAAU,cAAc,SAAS,IAAI,gBAAgB;EACrD,iBAAiB,aAAa,SAAS,IAAI,eAAe;EAC1D;EACA;EACD"}
|
package/dist/contract.d.cts
CHANGED
|
@@ -36,8 +36,8 @@ declare const DevOptionsSchema: z.ZodObject<{
|
|
|
36
36
|
}, z.core.$strip>;
|
|
37
37
|
declare const DevResultSchema: z.ZodObject<{
|
|
38
38
|
status: z.ZodEnum<{
|
|
39
|
-
error: "error";
|
|
40
39
|
started: "started";
|
|
40
|
+
error: "error";
|
|
41
41
|
}>;
|
|
42
42
|
description: z.ZodString;
|
|
43
43
|
processes: z.ZodArray<z.ZodString>;
|
|
@@ -377,20 +377,20 @@ declare const KeyPublishResultSchema: z.ZodObject<{
|
|
|
377
377
|
error: z.ZodOptional<z.ZodString>;
|
|
378
378
|
}, z.core.$strip>;
|
|
379
379
|
declare const OverrideSectionSchema: z.ZodEnum<{
|
|
380
|
-
plugins: "plugins";
|
|
381
|
-
ui: "ui";
|
|
382
380
|
host: "host";
|
|
381
|
+
ui: "ui";
|
|
383
382
|
api: "api";
|
|
383
|
+
plugins: "plugins";
|
|
384
384
|
}>;
|
|
385
385
|
declare const RuntimeOverrideTargetBaseSchema: z.ZodEnum<{
|
|
386
|
-
plugins: "plugins";
|
|
387
386
|
ui: "ui";
|
|
388
387
|
api: "api";
|
|
388
|
+
plugins: "plugins";
|
|
389
389
|
}>;
|
|
390
390
|
declare const RuntimeOverrideTargetSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
391
|
-
plugins: "plugins";
|
|
392
391
|
ui: "ui";
|
|
393
392
|
api: "api";
|
|
393
|
+
plugins: "plugins";
|
|
394
394
|
}>, z.ZodString]>;
|
|
395
395
|
declare const InitOptionsSchema: z.ZodObject<{
|
|
396
396
|
extends: z.ZodOptional<z.ZodString>;
|
|
@@ -400,10 +400,10 @@ declare const InitOptionsSchema: z.ZodObject<{
|
|
|
400
400
|
source: z.ZodOptional<z.ZodString>;
|
|
401
401
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
402
402
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
403
|
-
plugins: "plugins";
|
|
404
|
-
ui: "ui";
|
|
405
403
|
host: "host";
|
|
404
|
+
ui: "ui";
|
|
406
405
|
api: "api";
|
|
406
|
+
plugins: "plugins";
|
|
407
407
|
}>>>;
|
|
408
408
|
noInteractive: z.ZodDefault<z.ZodBoolean>;
|
|
409
409
|
noInstall: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -420,10 +420,10 @@ declare const InitResultSchema: z.ZodObject<{
|
|
|
420
420
|
extends: z.ZodString;
|
|
421
421
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
422
422
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
423
|
-
plugins: "plugins";
|
|
424
|
-
ui: "ui";
|
|
425
423
|
host: "host";
|
|
424
|
+
ui: "ui";
|
|
426
425
|
api: "api";
|
|
426
|
+
plugins: "plugins";
|
|
427
427
|
}>>>;
|
|
428
428
|
filesCopied: z.ZodNumber;
|
|
429
429
|
timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -511,8 +511,8 @@ declare const StatusResultSchema: z.ZodObject<{
|
|
|
511
511
|
}, z.core.$strip>;
|
|
512
512
|
declare const TypesGenOptionsSchema: z.ZodObject<{
|
|
513
513
|
env: z.ZodOptional<z.ZodEnum<{
|
|
514
|
-
development: "development";
|
|
515
514
|
production: "production";
|
|
515
|
+
development: "development";
|
|
516
516
|
}>>;
|
|
517
517
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
518
518
|
}, z.core.$strip>;
|
|
@@ -698,8 +698,8 @@ declare const bosContract: {
|
|
|
698
698
|
interactive: z.ZodOptional<z.ZodBoolean>;
|
|
699
699
|
}, z.core.$strip>, z.ZodObject<{
|
|
700
700
|
status: z.ZodEnum<{
|
|
701
|
-
error: "error";
|
|
702
701
|
started: "started";
|
|
702
|
+
error: "error";
|
|
703
703
|
}>;
|
|
704
704
|
description: z.ZodString;
|
|
705
705
|
processes: z.ZodArray<z.ZodString>;
|
|
@@ -1024,10 +1024,10 @@ declare const bosContract: {
|
|
|
1024
1024
|
source: z.ZodOptional<z.ZodString>;
|
|
1025
1025
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1026
1026
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
1027
|
-
plugins: "plugins";
|
|
1028
|
-
ui: "ui";
|
|
1029
1027
|
host: "host";
|
|
1028
|
+
ui: "ui";
|
|
1030
1029
|
api: "api";
|
|
1030
|
+
plugins: "plugins";
|
|
1031
1031
|
}>>>;
|
|
1032
1032
|
noInteractive: z.ZodDefault<z.ZodBoolean>;
|
|
1033
1033
|
noInstall: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -1043,10 +1043,10 @@ declare const bosContract: {
|
|
|
1043
1043
|
extends: z.ZodString;
|
|
1044
1044
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1045
1045
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
1046
|
-
plugins: "plugins";
|
|
1047
|
-
ui: "ui";
|
|
1048
1046
|
host: "host";
|
|
1047
|
+
ui: "ui";
|
|
1049
1048
|
api: "api";
|
|
1049
|
+
plugins: "plugins";
|
|
1050
1050
|
}>>>;
|
|
1051
1051
|
filesCopied: z.ZodNumber;
|
|
1052
1052
|
timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -1132,8 +1132,8 @@ declare const bosContract: {
|
|
|
1132
1132
|
}, z.core.$strip>, _$_orpc_contract0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
1133
1133
|
typesGen: _$_orpc_contract0.ContractProcedure<z.ZodObject<{
|
|
1134
1134
|
env: z.ZodOptional<z.ZodEnum<{
|
|
1135
|
-
development: "development";
|
|
1136
1135
|
production: "production";
|
|
1136
|
+
development: "development";
|
|
1137
1137
|
}>>;
|
|
1138
1138
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
1139
1139
|
}, z.core.$strip>, z.ZodObject<{
|
package/dist/contract.d.mts
CHANGED
|
@@ -36,8 +36,8 @@ declare const DevOptionsSchema: z.ZodObject<{
|
|
|
36
36
|
}, z.core.$strip>;
|
|
37
37
|
declare const DevResultSchema: z.ZodObject<{
|
|
38
38
|
status: z.ZodEnum<{
|
|
39
|
-
error: "error";
|
|
40
39
|
started: "started";
|
|
40
|
+
error: "error";
|
|
41
41
|
}>;
|
|
42
42
|
description: z.ZodString;
|
|
43
43
|
processes: z.ZodArray<z.ZodString>;
|
|
@@ -377,20 +377,20 @@ declare const KeyPublishResultSchema: z.ZodObject<{
|
|
|
377
377
|
error: z.ZodOptional<z.ZodString>;
|
|
378
378
|
}, z.core.$strip>;
|
|
379
379
|
declare const OverrideSectionSchema: z.ZodEnum<{
|
|
380
|
-
plugins: "plugins";
|
|
381
|
-
ui: "ui";
|
|
382
380
|
host: "host";
|
|
381
|
+
ui: "ui";
|
|
383
382
|
api: "api";
|
|
383
|
+
plugins: "plugins";
|
|
384
384
|
}>;
|
|
385
385
|
declare const RuntimeOverrideTargetBaseSchema: z.ZodEnum<{
|
|
386
|
-
plugins: "plugins";
|
|
387
386
|
ui: "ui";
|
|
388
387
|
api: "api";
|
|
388
|
+
plugins: "plugins";
|
|
389
389
|
}>;
|
|
390
390
|
declare const RuntimeOverrideTargetSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
391
|
-
plugins: "plugins";
|
|
392
391
|
ui: "ui";
|
|
393
392
|
api: "api";
|
|
393
|
+
plugins: "plugins";
|
|
394
394
|
}>, z.ZodString]>;
|
|
395
395
|
declare const InitOptionsSchema: z.ZodObject<{
|
|
396
396
|
extends: z.ZodOptional<z.ZodString>;
|
|
@@ -400,10 +400,10 @@ declare const InitOptionsSchema: z.ZodObject<{
|
|
|
400
400
|
source: z.ZodOptional<z.ZodString>;
|
|
401
401
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
402
402
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
403
|
-
plugins: "plugins";
|
|
404
|
-
ui: "ui";
|
|
405
403
|
host: "host";
|
|
404
|
+
ui: "ui";
|
|
406
405
|
api: "api";
|
|
406
|
+
plugins: "plugins";
|
|
407
407
|
}>>>;
|
|
408
408
|
noInteractive: z.ZodDefault<z.ZodBoolean>;
|
|
409
409
|
noInstall: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -420,10 +420,10 @@ declare const InitResultSchema: z.ZodObject<{
|
|
|
420
420
|
extends: z.ZodString;
|
|
421
421
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
422
422
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
423
|
-
plugins: "plugins";
|
|
424
|
-
ui: "ui";
|
|
425
423
|
host: "host";
|
|
424
|
+
ui: "ui";
|
|
426
425
|
api: "api";
|
|
426
|
+
plugins: "plugins";
|
|
427
427
|
}>>>;
|
|
428
428
|
filesCopied: z.ZodNumber;
|
|
429
429
|
timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -511,8 +511,8 @@ declare const StatusResultSchema: z.ZodObject<{
|
|
|
511
511
|
}, z.core.$strip>;
|
|
512
512
|
declare const TypesGenOptionsSchema: z.ZodObject<{
|
|
513
513
|
env: z.ZodOptional<z.ZodEnum<{
|
|
514
|
-
development: "development";
|
|
515
514
|
production: "production";
|
|
515
|
+
development: "development";
|
|
516
516
|
}>>;
|
|
517
517
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
518
518
|
}, z.core.$strip>;
|
|
@@ -698,8 +698,8 @@ declare const bosContract: {
|
|
|
698
698
|
interactive: z.ZodOptional<z.ZodBoolean>;
|
|
699
699
|
}, z.core.$strip>, z.ZodObject<{
|
|
700
700
|
status: z.ZodEnum<{
|
|
701
|
-
error: "error";
|
|
702
701
|
started: "started";
|
|
702
|
+
error: "error";
|
|
703
703
|
}>;
|
|
704
704
|
description: z.ZodString;
|
|
705
705
|
processes: z.ZodArray<z.ZodString>;
|
|
@@ -1024,10 +1024,10 @@ declare const bosContract: {
|
|
|
1024
1024
|
source: z.ZodOptional<z.ZodString>;
|
|
1025
1025
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1026
1026
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
1027
|
-
plugins: "plugins";
|
|
1028
|
-
ui: "ui";
|
|
1029
1027
|
host: "host";
|
|
1028
|
+
ui: "ui";
|
|
1030
1029
|
api: "api";
|
|
1030
|
+
plugins: "plugins";
|
|
1031
1031
|
}>>>;
|
|
1032
1032
|
noInteractive: z.ZodDefault<z.ZodBoolean>;
|
|
1033
1033
|
noInstall: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -1043,10 +1043,10 @@ declare const bosContract: {
|
|
|
1043
1043
|
extends: z.ZodString;
|
|
1044
1044
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1045
1045
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
1046
|
-
plugins: "plugins";
|
|
1047
|
-
ui: "ui";
|
|
1048
1046
|
host: "host";
|
|
1047
|
+
ui: "ui";
|
|
1049
1048
|
api: "api";
|
|
1049
|
+
plugins: "plugins";
|
|
1050
1050
|
}>>>;
|
|
1051
1051
|
filesCopied: z.ZodNumber;
|
|
1052
1052
|
timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -1132,8 +1132,8 @@ declare const bosContract: {
|
|
|
1132
1132
|
}, z.core.$strip>, _$_orpc_contract0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
1133
1133
|
typesGen: _$_orpc_contract0.ContractProcedure<z.ZodObject<{
|
|
1134
1134
|
env: z.ZodOptional<z.ZodEnum<{
|
|
1135
|
-
development: "development";
|
|
1136
1135
|
production: "production";
|
|
1136
|
+
development: "development";
|
|
1137
1137
|
}>>;
|
|
1138
1138
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
1139
1139
|
}, z.core.$strip>, z.ZodObject<{
|
package/dist/plugin.d.cts
CHANGED
|
@@ -64,8 +64,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
64
64
|
interactive: z.ZodOptional<z.ZodBoolean>;
|
|
65
65
|
}, z.core.$strip>, z.ZodObject<{
|
|
66
66
|
status: z.ZodEnum<{
|
|
67
|
-
error: "error";
|
|
68
67
|
started: "started";
|
|
68
|
+
error: "error";
|
|
69
69
|
}>;
|
|
70
70
|
description: z.ZodString;
|
|
71
71
|
processes: z.ZodArray<z.ZodString>;
|
|
@@ -390,10 +390,10 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
390
390
|
source: z.ZodOptional<z.ZodString>;
|
|
391
391
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
392
392
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
393
|
-
plugins: "plugins";
|
|
394
|
-
ui: "ui";
|
|
395
393
|
host: "host";
|
|
394
|
+
ui: "ui";
|
|
396
395
|
api: "api";
|
|
396
|
+
plugins: "plugins";
|
|
397
397
|
}>>>;
|
|
398
398
|
noInteractive: z.ZodDefault<z.ZodBoolean>;
|
|
399
399
|
noInstall: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -409,10 +409,10 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
409
409
|
extends: z.ZodString;
|
|
410
410
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
411
411
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
412
|
-
plugins: "plugins";
|
|
413
|
-
ui: "ui";
|
|
414
412
|
host: "host";
|
|
413
|
+
ui: "ui";
|
|
415
414
|
api: "api";
|
|
415
|
+
plugins: "plugins";
|
|
416
416
|
}>>>;
|
|
417
417
|
filesCopied: z.ZodNumber;
|
|
418
418
|
timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -498,8 +498,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
498
498
|
}, z.core.$strip>, _$_orpc_contract0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
499
499
|
typesGen: _$_orpc_contract0.ContractProcedure<z.ZodObject<{
|
|
500
500
|
env: z.ZodOptional<z.ZodEnum<{
|
|
501
|
-
development: "development";
|
|
502
501
|
production: "production";
|
|
502
|
+
development: "development";
|
|
503
503
|
}>>;
|
|
504
504
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
505
505
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -737,7 +737,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
737
737
|
}> | undefined;
|
|
738
738
|
} | null;
|
|
739
739
|
runtimeConfig: {
|
|
740
|
-
env: "
|
|
740
|
+
env: "production" | "staging" | "development";
|
|
741
741
|
account: string;
|
|
742
742
|
networkId: "testnet" | "mainnet";
|
|
743
743
|
host: {
|
package/dist/plugin.d.mts
CHANGED
|
@@ -64,8 +64,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
64
64
|
interactive: z.ZodOptional<z.ZodBoolean>;
|
|
65
65
|
}, z.core.$strip>, z.ZodObject<{
|
|
66
66
|
status: z.ZodEnum<{
|
|
67
|
-
error: "error";
|
|
68
67
|
started: "started";
|
|
68
|
+
error: "error";
|
|
69
69
|
}>;
|
|
70
70
|
description: z.ZodString;
|
|
71
71
|
processes: z.ZodArray<z.ZodString>;
|
|
@@ -390,10 +390,10 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
390
390
|
source: z.ZodOptional<z.ZodString>;
|
|
391
391
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
392
392
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
393
|
-
plugins: "plugins";
|
|
394
|
-
ui: "ui";
|
|
395
393
|
host: "host";
|
|
394
|
+
ui: "ui";
|
|
396
395
|
api: "api";
|
|
396
|
+
plugins: "plugins";
|
|
397
397
|
}>>>;
|
|
398
398
|
noInteractive: z.ZodDefault<z.ZodBoolean>;
|
|
399
399
|
noInstall: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -409,10 +409,10 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
409
409
|
extends: z.ZodString;
|
|
410
410
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
411
411
|
overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
412
|
-
plugins: "plugins";
|
|
413
|
-
ui: "ui";
|
|
414
412
|
host: "host";
|
|
413
|
+
ui: "ui";
|
|
415
414
|
api: "api";
|
|
415
|
+
plugins: "plugins";
|
|
416
416
|
}>>>;
|
|
417
417
|
filesCopied: z.ZodNumber;
|
|
418
418
|
timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -498,8 +498,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
498
498
|
}, z.core.$strip>, _$_orpc_contract0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
499
499
|
typesGen: _$_orpc_contract0.ContractProcedure<z.ZodObject<{
|
|
500
500
|
env: z.ZodOptional<z.ZodEnum<{
|
|
501
|
-
development: "development";
|
|
502
501
|
production: "production";
|
|
502
|
+
development: "development";
|
|
503
503
|
}>>;
|
|
504
504
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
505
505
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -737,7 +737,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
737
737
|
}> | undefined;
|
|
738
738
|
} | null;
|
|
739
739
|
runtimeConfig: {
|
|
740
|
-
env: "
|
|
740
|
+
env: "production" | "staging" | "development";
|
|
741
741
|
account: string;
|
|
742
742
|
networkId: "testnet" | "mainnet";
|
|
743
743
|
host: {
|
package/dist/types.d.cts
CHANGED
|
@@ -379,9 +379,9 @@ declare const BosConfigSchema: z.ZodObject<{
|
|
|
379
379
|
type BosConfig = z.infer<typeof BosConfigSchema>;
|
|
380
380
|
declare const RuntimeConfigSchema: z.ZodObject<{
|
|
381
381
|
env: z.ZodEnum<{
|
|
382
|
-
development: "development";
|
|
383
382
|
production: "production";
|
|
384
383
|
staging: "staging";
|
|
384
|
+
development: "development";
|
|
385
385
|
}>;
|
|
386
386
|
account: z.ZodString;
|
|
387
387
|
domain: z.ZodOptional<z.ZodString>;
|
|
@@ -508,9 +508,9 @@ declare const RuntimeConfigSchema: z.ZodObject<{
|
|
|
508
508
|
type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
|
|
509
509
|
declare const ClientRuntimeConfigSchema: z.ZodObject<{
|
|
510
510
|
env: z.ZodEnum<{
|
|
511
|
-
development: "development";
|
|
512
511
|
production: "production";
|
|
513
512
|
staging: "staging";
|
|
513
|
+
development: "development";
|
|
514
514
|
}>;
|
|
515
515
|
account: z.ZodString;
|
|
516
516
|
networkId: z.ZodEnum<{
|
package/dist/types.d.mts
CHANGED
|
@@ -379,9 +379,9 @@ declare const BosConfigSchema: z.ZodObject<{
|
|
|
379
379
|
type BosConfig = z.infer<typeof BosConfigSchema>;
|
|
380
380
|
declare const RuntimeConfigSchema: z.ZodObject<{
|
|
381
381
|
env: z.ZodEnum<{
|
|
382
|
-
development: "development";
|
|
383
382
|
production: "production";
|
|
384
383
|
staging: "staging";
|
|
384
|
+
development: "development";
|
|
385
385
|
}>;
|
|
386
386
|
account: z.ZodString;
|
|
387
387
|
domain: z.ZodOptional<z.ZodString>;
|
|
@@ -508,9 +508,9 @@ declare const RuntimeConfigSchema: z.ZodObject<{
|
|
|
508
508
|
type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
|
|
509
509
|
declare const ClientRuntimeConfigSchema: z.ZodObject<{
|
|
510
510
|
env: z.ZodEnum<{
|
|
511
|
-
development: "development";
|
|
512
511
|
production: "production";
|
|
513
512
|
staging: "staging";
|
|
513
|
+
development: "development";
|
|
514
514
|
}>;
|
|
515
515
|
account: z.ZodString;
|
|
516
516
|
networkId: z.ZodEnum<{
|