everything-dev 1.51.7 → 1.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-contract.cjs +61 -16
- package/dist/api-contract.cjs.map +1 -1
- package/dist/api-contract.mjs +60 -17
- package/dist/api-contract.mjs.map +1 -1
- package/dist/app.cjs +1 -1
- package/dist/app.cjs.map +1 -1
- package/dist/app.mjs +1 -1
- package/dist/app.mjs.map +1 -1
- package/dist/cli/init.cjs +76 -52
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +15 -7
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +15 -7
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +70 -47
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/sync.cjs +34 -5
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +35 -6
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli/upgrade.cjs +151 -93
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +138 -80
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/cli/utils/helpers.cjs +25 -0
- package/dist/cli/utils/helpers.cjs.map +1 -0
- package/dist/cli/utils/helpers.mjs +23 -0
- package/dist/cli/utils/helpers.mjs.map +1 -0
- package/dist/cli.cjs +84 -72
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +84 -72
- package/dist/cli.mjs.map +1 -1
- package/dist/code-artifacts.cjs +1 -1
- package/dist/code-artifacts.mjs +1 -1
- package/dist/config.cjs +44 -4
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +1 -1
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +44 -4
- package/dist/config.mjs.map +1 -1
- package/dist/contract.cjs +9 -4
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +34 -24
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +34 -24
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.meta.cjs +2 -1
- package/dist/contract.meta.cjs.map +1 -1
- package/dist/contract.meta.d.cts +3 -0
- package/dist/contract.meta.d.mts +3 -0
- package/dist/contract.meta.mjs +2 -1
- package/dist/contract.meta.mjs.map +1 -1
- package/dist/contract.mjs +9 -4
- package/dist/contract.mjs.map +1 -1
- package/dist/dag.cjs +176 -0
- package/dist/dag.cjs.map +1 -0
- package/dist/dag.d.cts +24 -0
- package/dist/dag.d.cts.map +1 -0
- package/dist/dag.d.mts +24 -0
- package/dist/dag.d.mts.map +1 -0
- package/dist/dag.mjs +167 -0
- package/dist/dag.mjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/infra/planner.cjs +1 -1
- package/dist/infra/planner.mjs +1 -1
- package/dist/near-cli.cjs +1 -1
- package/dist/near-cli.mjs +1 -1
- package/dist/plugin.cjs +27 -18
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +57 -11
- package/dist/plugin.d.mts +57 -11
- package/dist/plugin.mjs +28 -19
- package/dist/plugin.mjs.map +1 -1
- package/dist/types.cjs +41 -6
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +118 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +118 -3
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +40 -7
- package/dist/types.mjs.map +1 -1
- package/package.json +6 -1
package/dist/cli/sync.cjs
CHANGED
|
@@ -228,6 +228,7 @@ async function syncTemplate(projectDir, options) {
|
|
|
228
228
|
updated: [],
|
|
229
229
|
skipped: [],
|
|
230
230
|
added: [],
|
|
231
|
+
conflicted: [],
|
|
231
232
|
error: "No extends field found in bos.config.json — cannot determine parent"
|
|
232
233
|
};
|
|
233
234
|
const extendsMatch = extendsRef.match(/^bos:\/\/([^/]+)\/(.+)$/);
|
|
@@ -236,6 +237,7 @@ async function syncTemplate(projectDir, options) {
|
|
|
236
237
|
updated: [],
|
|
237
238
|
skipped: [],
|
|
238
239
|
added: [],
|
|
240
|
+
conflicted: [],
|
|
239
241
|
error: `Invalid extends reference: ${extendsRef}`
|
|
240
242
|
};
|
|
241
243
|
const extendsAccount = extendsMatch[1];
|
|
@@ -314,6 +316,8 @@ async function syncTemplate(projectDir, options) {
|
|
|
314
316
|
const updated = [];
|
|
315
317
|
const skipped = [];
|
|
316
318
|
const added = [];
|
|
319
|
+
const conflicted = [];
|
|
320
|
+
const snapshotFiles = (await require_snapshot.readSnapshot(projectDir))?.files ?? {};
|
|
317
321
|
for (const [destPath, filePath] of destToSource.entries()) {
|
|
318
322
|
const localHash = computeLocalHash(projectDir, destPath);
|
|
319
323
|
const sourceHash = computeHash(buildSyncedFileContent(sourceDir, projectDir, filePath));
|
|
@@ -321,7 +325,24 @@ async function syncTemplate(projectDir, options) {
|
|
|
321
325
|
added.push(destPath);
|
|
322
326
|
continue;
|
|
323
327
|
}
|
|
324
|
-
if (localHash
|
|
328
|
+
if (localHash === sourceHash) {
|
|
329
|
+
skipped.push(destPath);
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
const snapshotHash = snapshotFiles[destPath];
|
|
333
|
+
if (!snapshotHash) {
|
|
334
|
+
updated.push(destPath);
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (localHash === snapshotHash) {
|
|
338
|
+
updated.push(destPath);
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
if (sourceHash === snapshotHash) {
|
|
342
|
+
skipped.push(destPath);
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
conflicted.push(destPath);
|
|
325
346
|
}
|
|
326
347
|
const account = localConfig.account || extendsAccount;
|
|
327
348
|
const domain = localConfig.domain || extendsGateway;
|
|
@@ -346,12 +367,18 @@ async function syncTemplate(projectDir, options) {
|
|
|
346
367
|
status: "dry-run",
|
|
347
368
|
updated,
|
|
348
369
|
skipped,
|
|
349
|
-
added
|
|
370
|
+
added,
|
|
371
|
+
conflicted
|
|
350
372
|
};
|
|
351
373
|
}
|
|
352
|
-
const filesToWrite = [
|
|
374
|
+
const filesToWrite = [
|
|
375
|
+
...updated,
|
|
376
|
+
...added,
|
|
377
|
+
...conflicted
|
|
378
|
+
];
|
|
379
|
+
let backupDir;
|
|
353
380
|
if (filesToWrite.length > 0) {
|
|
354
|
-
backupFiles(projectDir, filesToWrite);
|
|
381
|
+
backupDir = backupFiles(projectDir, filesToWrite) ?? void 0;
|
|
355
382
|
for (const destPath of filesToWrite) writeSyncedFile(sourceDir, projectDir, destToSource.get(destPath) ?? destPath, destPath);
|
|
356
383
|
}
|
|
357
384
|
await require_cli_init.personalizeConfig(projectDir, {
|
|
@@ -404,7 +431,9 @@ async function syncTemplate(projectDir, options) {
|
|
|
404
431
|
status: "synced",
|
|
405
432
|
updated,
|
|
406
433
|
skipped,
|
|
407
|
-
added
|
|
434
|
+
added,
|
|
435
|
+
conflicted,
|
|
436
|
+
backupDir
|
|
408
437
|
};
|
|
409
438
|
} finally {
|
|
410
439
|
await cleanup();
|
package/dist/cli/sync.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.cjs","names":["mergeBosConfigWithTemplate","isPlainObjectFromMerge","resolveExtendsRef","resolveSourceDir","extractSkillsBlock","buildChildAgentsMd","personalizeConfig","syncResolvedSharedDeps","loadResolvedConfig","writeSnapshot","runBunInstall","runTypesGen"],"sources":["../../src/cli/sync.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { glob } from \"glob\";\nimport { loadResolvedConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { writeGeneratedInfra } from \"./infra\";\nimport {\n buildChildAgentsMd,\n extractSkillsBlock,\n personalizeConfig,\n resolveSourceDir,\n runBunInstall,\n runTypesGen,\n} from \"./init\";\nimport { writeSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_OWNED_SYNC_FILES = new Set([\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bos.config.json\",\n \"bunfig.toml\",\n \"package.json\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \".github/workflows/ci.yml\",\n \".github/workflows/deploy.yml\",\n \".github/workflows/staging.yml\",\n \".github/workflows/release.yml\",\n \"railway.toml\",\n \"ui/package.json\",\n \"ui/postcss.config.mjs\",\n \"ui/rsbuild.config.ts\",\n \"ui/tsconfig.json\",\n \"ui/src/app.ts\",\n \"ui/src/globals.d.ts\",\n \"ui/src/hydrate.tsx\",\n \"ui/src/lib/api.ts\",\n \"ui/src/lib/auth.ts\",\n \"ui/src/router.server.tsx\",\n \"ui/src/router.tsx\",\n \"ui/src/routes/__root.tsx\",\n \"api/package.json\",\n \"api/plugin.dev.ts\",\n \"api/rspack.config.js\",\n \"api/tsconfig.contract.json\",\n \"api/tsconfig.json\",\n \"api/src/lib/auth.ts\",\n \"api/src/lib/context.ts\",\n \"api/drizzle.config.ts\",\n \"api/src/db/index.ts\",\n \"api/src/db/layer.ts\",\n \"api/src/db/migrate.ts\",\n \"api/src/global.d.ts\",\n \"api/tests/types.d.ts\",\n]);\n\ntype PackageJson = Record<string, unknown>;\n\nfunction computeHash(content: string | Uint8Array): string {\n return createHash(\"sha256\").update(content).digest(\"hex\").substring(0, 16);\n}\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n if (FRAMEWORK_OWNED_SYNC_FILES.has(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/lib\\/(auth|context)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/db\\/(index|layer|migrate)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/rspack\\.config\\.js$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/drizzle\\.config\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/global\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tests\\/types\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.json$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.contract\\.json$/.test(filePath)) return true;\n return false;\n}\n\nfunction computeLocalHash(projectDir: string, filePath: string): string | null {\n const fullPath = join(projectDir, filePath);\n if (!existsSync(fullPath)) return null;\n try {\n const content = readFileSync(fullPath);\n return computeHash(content);\n } catch {\n return null;\n }\n}\n\nfunction backupFiles(projectDir: string, filePaths: string[]): string | null {\n const filesToBackup = filePaths.filter((f) => existsSync(join(projectDir, f)));\n if (filesToBackup.length === 0) return null;\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupDir = join(projectDir, \".bos\", \"sync-backup\", timestamp);\n\n for (const filePath of filesToBackup) {\n const src = join(projectDir, filePath);\n const dest = join(backupDir, filePath);\n mkdirSync(dirname(dest), { recursive: true });\n copyFileSync(src, dest);\n }\n\n return backupDir;\n}\n\nfunction mergeStringMaps(\n local: Record<string, string> | undefined,\n template: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!local && !template) return undefined;\n\n const merged: Record<string, string> = { ...(local ?? {}) };\n for (const [name, value] of Object.entries(template ?? {})) {\n merged[name] = value;\n }\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction mergeWorkspacePackages(local: unknown, template: unknown): string[] | undefined {\n const localPackages = Array.isArray(local) ? local : [];\n const templatePackages = Array.isArray(template) ? template : [];\n if (localPackages.length === 0 && templatePackages.length === 0) return undefined;\n\n const ordered = new Set<string>();\n for (const entry of templatePackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n for (const entry of localPackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n\n const hasPluginEntry = [...ordered].some((e) => e.startsWith(\"plugins/\") && e !== \"plugins/*\");\n if (hasPluginEntry) {\n for (const entry of [...ordered]) {\n if (entry.startsWith(\"plugins/\") && entry !== \"plugins/*\") {\n ordered.delete(entry);\n }\n }\n ordered.add(\"plugins/*\");\n }\n\n return ordered.size > 0 ? [...ordered] : undefined;\n}\n\nexport function mergePackageJson(\n filePath: string,\n local: PackageJson,\n template: PackageJson,\n): PackageJson {\n const merged: PackageJson = { ...local, ...template };\n\n if (filePath === \"package.json\") {\n for (const key of [\"name\", \"private\", \"version\"] as const) {\n if (key in local) {\n merged[key] = local[key];\n }\n }\n } else if (\"version\" in local) {\n merged.version = local.version;\n }\n\n for (const depField of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"overrides\",\n ] as const) {\n const localDeps = local[depField] as Record<string, string> | undefined;\n const templateDeps = template[depField] as Record<string, string> | undefined;\n\n const mergedDeps = mergeStringMaps(localDeps, templateDeps);\n if (mergedDeps) {\n merged[depField] = mergedDeps;\n } else {\n delete merged[depField];\n }\n }\n\n if (\n (local.scripts && typeof local.scripts === \"object\") ||\n (template.scripts && typeof template.scripts === \"object\")\n ) {\n const mergedScripts = mergeStringMaps(\n local.scripts as Record<string, string> | undefined,\n template.scripts as Record<string, string> | undefined,\n );\n if (mergedScripts) {\n merged.scripts = mergedScripts;\n } else {\n delete merged.scripts;\n }\n }\n\n if (\n (local.workspaces && typeof local.workspaces === \"object\") ||\n (template.workspaces && typeof template.workspaces === \"object\")\n ) {\n const localWorkspaces = (local.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n const templateWorkspaces = (template.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n\n const mergedWorkspaces: { packages?: string[]; catalog?: Record<string, string> } = {\n ...localWorkspaces,\n ...templateWorkspaces,\n };\n\n const mergedPackages = mergeWorkspacePackages(\n localWorkspaces.packages,\n templateWorkspaces.packages,\n );\n if (mergedPackages) {\n mergedWorkspaces.packages = mergedPackages;\n } else {\n delete mergedWorkspaces.packages;\n }\n\n const mergedCatalog = mergeStringMaps(localWorkspaces.catalog, templateWorkspaces.catalog);\n if (mergedCatalog) {\n mergedWorkspaces.catalog = mergedCatalog;\n } else {\n delete mergedWorkspaces.catalog;\n }\n\n if (Object.keys(mergedWorkspaces).length > 0) {\n merged.workspaces = mergedWorkspaces;\n } else {\n delete merged.workspaces;\n }\n }\n\n return merged;\n}\n\nfunction toSourcePath(sourceDir: string, destPath: string): string | null {\n if (destPath.startsWith(\".github/\")) {\n const templatePath = destPath.replace(/^\\.github\\//, \".github/templates/\");\n if (existsSync(join(sourceDir, templatePath))) {\n return templatePath;\n }\n }\n\n const directPath = join(sourceDir, destPath);\n if (existsSync(directPath)) {\n return destPath;\n }\n\n return null;\n}\n\nfunction buildSyncedFileContent(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): string | Uint8Array {\n const src = join(sourceDir, filePath);\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n\n if (filePath.endsWith(\"bos.config.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergeBosConfigWithTemplate(local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n if (filePath.endsWith(\"package.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergePackageJson(destPath, local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n return readFileSync(src);\n}\n\nfunction writeSyncedFile(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): void {\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n writeFileSync(dest, buildSyncedFileContent(sourceDir, projectDir, filePath, destPath));\n}\n\nasync function getSelectedChildPlugins(\n projectDir: string,\n localConfig: Record<string, unknown>,\n): Promise<string[]> {\n if (!localConfig.plugins || typeof localConfig.plugins !== \"object\") {\n return [];\n }\n\n const pluginDirs = new Set(\n (\n await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n })\n )\n .map((file) => file.match(/^plugins\\/([^/]+)\\/package\\.json$/)?.[1])\n .filter((key): key is string => Boolean(key)),\n );\n\n const selected: string[] = [];\n for (const [pluginKey, rawEntry] of Object.entries(\n localConfig.plugins as Record<string, unknown>,\n )) {\n if (typeof rawEntry === \"string\") {\n if (!rawEntry.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, rawEntry.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n continue;\n }\n\n if (!rawEntry || typeof rawEntry !== \"object\") {\n selected.push(pluginKey);\n continue;\n }\n\n const entry = rawEntry as Record<string, unknown>;\n const development = typeof entry.development === \"string\" ? entry.development : undefined;\n if (!development?.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, development.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n }\n\n return selected;\n}\n\nfunction hasPluginsWorkspace(projectDir: string): boolean {\n const packageJsonPath = join(projectDir, \"package.json\");\n if (!existsSync(packageJsonPath)) return false;\n\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n workspaces?: { packages?: string[] } | string[];\n };\n const workspaces = pkg.workspaces;\n const packages = Array.isArray(workspaces)\n ? workspaces\n : Array.isArray(workspaces?.packages)\n ? workspaces.packages\n : [];\n return packages.includes(\"plugins/*\");\n } catch {\n return false;\n }\n}\n\nexport async function syncTemplate(projectDir: string, options: SyncOptions): Promise<SyncResult> {\n // Sync reads the raw bos.config.json (not the resolved config) because it needs\n // the user's explicit local settings: their extends ref, selected plugins, etc.\n // The resolved config is the merged result and would include inherited parent\n // values that the user didn't explicitly choose, which would break sync filtering.\n const localConfig = JSON.parse(\n readFileSync(join(projectDir, \"bos.config.json\"), \"utf-8\"),\n ) as Record<string, unknown>;\n\n let extendsRef: string | undefined;\n if (typeof localConfig.extends === \"string\") {\n extendsRef = localConfig.extends;\n } else if (isPlainObjectFromMerge(localConfig.extends)) {\n extendsRef = resolveExtendsRef(localConfig.extends as Record<string, string>, \"production\");\n }\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: \"No extends field found in bos.config.json — cannot determine parent\",\n };\n }\n\n const extendsMatch = extendsRef.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!extendsMatch) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: `Invalid extends reference: ${extendsRef}`,\n };\n }\n\n const extendsAccount = extendsMatch[1];\n const extendsGateway = extendsMatch[2];\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n });\n\n try {\n const childPlugins = await getSelectedChildPlugins(projectDir, localConfig);\n const withUi = existsSync(join(projectDir, \"ui\", \"package.json\"));\n const withApi = existsSync(join(projectDir, \"api\", \"package.json\"));\n const withHost = existsSync(join(projectDir, \"host\", \"package.json\"));\n const withPlugins = childPlugins.length > 0 || hasPluginsWorkspace(projectDir);\n\n const destToSource = new Map<string, string>();\n for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {\n if (destPath.startsWith(\"ui/\") && !withUi) continue;\n if (destPath.startsWith(\"api/\") && !withApi) continue;\n if (destPath.startsWith(\"host/\") && !withHost) continue;\n const sourcePath = toSourcePath(sourceDir, destPath);\n if (!sourcePath) continue;\n destToSource.set(destPath, sourcePath);\n }\n\n // Sync api/src/lib/{auth,context}.ts into each plugin's src/lib/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n for (const libFile of [\"auth.ts\", \"context.ts\"]) {\n const sourceFile = `api/src/lib/${libFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/lib/${libFile}`, sourceFile);\n }\n }\n\n // Sync api/src/global.d.ts into each plugin's src/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n const sourceFile = \"api/src/global.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/global.d.ts`, sourceFile);\n }\n\n // Sync tests/types.d.ts into each plugin's tests/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/tests/types.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/tests/types.d.ts`, sourceFile);\n }\n\n // Sync api/src/db/{index,layer,migrate}.ts into each plugin's src/db/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n for (const dbFile of [\"index.ts\", \"layer.ts\", \"migrate.ts\"]) {\n const sourceFile = `api/src/db/${dbFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/db/${dbFile}`, sourceFile);\n }\n }\n\n // Sync rspack.config.js from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/rspack.config.js\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/rspack.config.js`, sourceFile);\n }\n\n // Sync drizzle.config.ts from api into each DB-enabled plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n const sourceFile = \"api/drizzle.config.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);\n }\n\n // Sync tsconfig files from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n for (const tsconfigFile of [\"tsconfig.json\", \"tsconfig.contract.json\"]) {\n const sourceFile = `plugins/_template/${tsconfigFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/${tsconfigFile}`, sourceFile);\n }\n }\n\n const updated: string[] = [];\n const skipped: string[] = [];\n const added: string[] = [];\n\n for (const [destPath, filePath] of destToSource.entries()) {\n const localHash = computeLocalHash(projectDir, destPath);\n const sourceHash = computeHash(buildSyncedFileContent(sourceDir, projectDir, filePath));\n\n if (localHash === null) {\n added.push(destPath);\n continue;\n }\n\n if (localHash !== sourceHash) {\n updated.push(destPath);\n }\n }\n\n const account = (localConfig.account as string) || extendsAccount;\n const domain = (localConfig.domain as string) || extendsGateway;\n const overrides: Array<\"ui\" | \"api\" | \"host\" | \"plugins\"> = [];\n if (withUi) overrides.push(\"ui\");\n if (withApi) overrides.push(\"api\");\n if (withHost) overrides.push(\"host\");\n if (withPlugins) overrides.push(\"plugins\");\n\n if (options.dryRun) {\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n updated.push(\"AGENTS.md\");\n }\n }\n }\n\n return {\n status: \"dry-run\",\n updated,\n skipped,\n added,\n };\n }\n\n const filesToWrite = [...updated, ...added];\n\n if (filesToWrite.length > 0) {\n backupFiles(projectDir, filesToWrite);\n\n for (const destPath of filesToWrite) {\n const sourcePath = destToSource.get(destPath) ?? destPath;\n writeSyncedFile(sourceDir, projectDir, sourcePath, destPath);\n }\n }\n\n await personalizeConfig(projectDir, {\n extendsAccount,\n extendsGateway,\n account,\n domain,\n overrides,\n plugins: childPlugins,\n workspaceOpts: { sourceDir },\n mode: \"sync\",\n existingConfig: localConfig,\n });\n\n await syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n });\n\n const syncedConfig = await loadResolvedConfig({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n writeGeneratedInfra(projectDir, syncedConfig.runtime);\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const destPath of destToSource.keys()) {\n const hash = computeLocalHash(projectDir, destPath);\n if (hash) {\n newSnapshotFiles[destPath] = hash;\n }\n }\n\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n writeFileSync(join(projectDir, \"AGENTS.md\"), expectedContent);\n updated.push(\"AGENTS.md\");\n }\n\n newSnapshotFiles[\"AGENTS.md\"] = expectedHash;\n }\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\n });\n\n if (!options.noInstall) {\n await runBunInstall(projectDir);\n await runTypesGen(projectDir);\n }\n\n return {\n status: \"synced\",\n updated,\n skipped,\n added,\n };\n } finally {\n await cleanup();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAM,6CAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,SAAS,YAAY,SAAsC;CACzD,mCAAkB,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,UAAU,GAAG,EAAE;AAC3E;AAeA,SAAS,iBAAiB,YAAoB,UAAiC;CAC7E,MAAM,+BAAgB,YAAY,QAAQ;CAC1C,IAAI,yBAAY,QAAQ,GAAG,OAAO;CAClC,IAAI;EAEF,OAAO,sCADsB,QACJ,CAAC;CAC5B,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,YAAY,YAAoB,WAAoC;CAC3E,MAAM,gBAAgB,UAAU,QAAQ,kDAAsB,YAAY,CAAC,CAAC,CAAC;CAC7E,IAAI,cAAc,WAAW,GAAG,OAAO;CAGvC,MAAM,gCAAiB,YAAY,QAAQ,gCADzB,IAAI,KAAK,EAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,SAAS,GACM,CAAC;CAEnE,KAAK,MAAM,YAAY,eAAe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tB,MAAMC,+BAAc,UAAU;GAC9B,MAAMC,6BAAY,UAAU;EAC9B;EAEA,OAAO;GACL,QAAQ;GACR;GACA;GACA;EACF;CACF,UAAU;EACR,MAAM,QAAQ;CAChB;AACF"}
|
|
1
|
+
{"version":3,"file":"sync.cjs","names":["mergeBosConfigWithTemplate","isPlainObjectFromMerge","resolveExtendsRef","resolveSourceDir","readSnapshot","extractSkillsBlock","buildChildAgentsMd","personalizeConfig","syncResolvedSharedDeps","loadResolvedConfig","writeSnapshot","runBunInstall","runTypesGen"],"sources":["../../src/cli/sync.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { glob } from \"glob\";\nimport { loadResolvedConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { writeGeneratedInfra } from \"./infra\";\nimport {\n buildChildAgentsMd,\n extractSkillsBlock,\n personalizeConfig,\n resolveSourceDir,\n runBunInstall,\n runTypesGen,\n} from \"./init\";\nimport { readSnapshot, writeSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_OWNED_SYNC_FILES = new Set([\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bos.config.json\",\n \"bunfig.toml\",\n \"package.json\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \".github/workflows/ci.yml\",\n \".github/workflows/deploy.yml\",\n \".github/workflows/staging.yml\",\n \".github/workflows/release.yml\",\n \"railway.toml\",\n \"ui/package.json\",\n \"ui/postcss.config.mjs\",\n \"ui/rsbuild.config.ts\",\n \"ui/tsconfig.json\",\n \"ui/src/app.ts\",\n \"ui/src/globals.d.ts\",\n \"ui/src/hydrate.tsx\",\n \"ui/src/lib/api.ts\",\n \"ui/src/lib/auth.ts\",\n \"ui/src/router.server.tsx\",\n \"ui/src/router.tsx\",\n \"ui/src/routes/__root.tsx\",\n \"api/package.json\",\n \"api/plugin.dev.ts\",\n \"api/rspack.config.js\",\n \"api/tsconfig.contract.json\",\n \"api/tsconfig.json\",\n \"api/src/lib/auth.ts\",\n \"api/src/lib/context.ts\",\n \"api/drizzle.config.ts\",\n \"api/src/db/index.ts\",\n \"api/src/db/layer.ts\",\n \"api/src/db/migrate.ts\",\n \"api/src/global.d.ts\",\n \"api/tests/types.d.ts\",\n]);\n\ntype PackageJson = Record<string, unknown>;\n\nfunction computeHash(content: string | Uint8Array): string {\n return createHash(\"sha256\").update(content).digest(\"hex\").substring(0, 16);\n}\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n if (FRAMEWORK_OWNED_SYNC_FILES.has(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/lib\\/(auth|context)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/db\\/(index|layer|migrate)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/rspack\\.config\\.js$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/drizzle\\.config\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/global\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tests\\/types\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.json$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.contract\\.json$/.test(filePath)) return true;\n return false;\n}\n\nfunction computeLocalHash(projectDir: string, filePath: string): string | null {\n const fullPath = join(projectDir, filePath);\n if (!existsSync(fullPath)) return null;\n try {\n const content = readFileSync(fullPath);\n return computeHash(content);\n } catch {\n return null;\n }\n}\n\nfunction backupFiles(projectDir: string, filePaths: string[]): string | null {\n const filesToBackup = filePaths.filter((f) => existsSync(join(projectDir, f)));\n if (filesToBackup.length === 0) return null;\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupDir = join(projectDir, \".bos\", \"sync-backup\", timestamp);\n\n for (const filePath of filesToBackup) {\n const src = join(projectDir, filePath);\n const dest = join(backupDir, filePath);\n mkdirSync(dirname(dest), { recursive: true });\n copyFileSync(src, dest);\n }\n\n return backupDir;\n}\n\nfunction mergeStringMaps(\n local: Record<string, string> | undefined,\n template: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!local && !template) return undefined;\n\n const merged: Record<string, string> = { ...(local ?? {}) };\n for (const [name, value] of Object.entries(template ?? {})) {\n merged[name] = value;\n }\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction mergeWorkspacePackages(local: unknown, template: unknown): string[] | undefined {\n const localPackages = Array.isArray(local) ? local : [];\n const templatePackages = Array.isArray(template) ? template : [];\n if (localPackages.length === 0 && templatePackages.length === 0) return undefined;\n\n const ordered = new Set<string>();\n for (const entry of templatePackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n for (const entry of localPackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n\n const hasPluginEntry = [...ordered].some((e) => e.startsWith(\"plugins/\") && e !== \"plugins/*\");\n if (hasPluginEntry) {\n for (const entry of [...ordered]) {\n if (entry.startsWith(\"plugins/\") && entry !== \"plugins/*\") {\n ordered.delete(entry);\n }\n }\n ordered.add(\"plugins/*\");\n }\n\n return ordered.size > 0 ? [...ordered] : undefined;\n}\n\nexport function mergePackageJson(\n filePath: string,\n local: PackageJson,\n template: PackageJson,\n): PackageJson {\n const merged: PackageJson = { ...local, ...template };\n\n if (filePath === \"package.json\") {\n for (const key of [\"name\", \"private\", \"version\"] as const) {\n if (key in local) {\n merged[key] = local[key];\n }\n }\n } else if (\"version\" in local) {\n merged.version = local.version;\n }\n\n for (const depField of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"overrides\",\n ] as const) {\n const localDeps = local[depField] as Record<string, string> | undefined;\n const templateDeps = template[depField] as Record<string, string> | undefined;\n\n const mergedDeps = mergeStringMaps(localDeps, templateDeps);\n if (mergedDeps) {\n merged[depField] = mergedDeps;\n } else {\n delete merged[depField];\n }\n }\n\n if (\n (local.scripts && typeof local.scripts === \"object\") ||\n (template.scripts && typeof template.scripts === \"object\")\n ) {\n const mergedScripts = mergeStringMaps(\n local.scripts as Record<string, string> | undefined,\n template.scripts as Record<string, string> | undefined,\n );\n if (mergedScripts) {\n merged.scripts = mergedScripts;\n } else {\n delete merged.scripts;\n }\n }\n\n if (\n (local.workspaces && typeof local.workspaces === \"object\") ||\n (template.workspaces && typeof template.workspaces === \"object\")\n ) {\n const localWorkspaces = (local.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n const templateWorkspaces = (template.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n\n const mergedWorkspaces: { packages?: string[]; catalog?: Record<string, string> } = {\n ...localWorkspaces,\n ...templateWorkspaces,\n };\n\n const mergedPackages = mergeWorkspacePackages(\n localWorkspaces.packages,\n templateWorkspaces.packages,\n );\n if (mergedPackages) {\n mergedWorkspaces.packages = mergedPackages;\n } else {\n delete mergedWorkspaces.packages;\n }\n\n const mergedCatalog = mergeStringMaps(localWorkspaces.catalog, templateWorkspaces.catalog);\n if (mergedCatalog) {\n mergedWorkspaces.catalog = mergedCatalog;\n } else {\n delete mergedWorkspaces.catalog;\n }\n\n if (Object.keys(mergedWorkspaces).length > 0) {\n merged.workspaces = mergedWorkspaces;\n } else {\n delete merged.workspaces;\n }\n }\n\n return merged;\n}\n\nfunction toSourcePath(sourceDir: string, destPath: string): string | null {\n if (destPath.startsWith(\".github/\")) {\n const templatePath = destPath.replace(/^\\.github\\//, \".github/templates/\");\n if (existsSync(join(sourceDir, templatePath))) {\n return templatePath;\n }\n }\n\n const directPath = join(sourceDir, destPath);\n if (existsSync(directPath)) {\n return destPath;\n }\n\n return null;\n}\n\nfunction buildSyncedFileContent(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): string | Uint8Array {\n const src = join(sourceDir, filePath);\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n\n if (filePath.endsWith(\"bos.config.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergeBosConfigWithTemplate(local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n if (filePath.endsWith(\"package.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergePackageJson(destPath, local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n return readFileSync(src);\n}\n\nfunction writeSyncedFile(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): void {\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n writeFileSync(dest, buildSyncedFileContent(sourceDir, projectDir, filePath, destPath));\n}\n\nasync function getSelectedChildPlugins(\n projectDir: string,\n localConfig: Record<string, unknown>,\n): Promise<string[]> {\n if (!localConfig.plugins || typeof localConfig.plugins !== \"object\") {\n return [];\n }\n\n const pluginDirs = new Set(\n (\n await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n })\n )\n .map((file) => file.match(/^plugins\\/([^/]+)\\/package\\.json$/)?.[1])\n .filter((key): key is string => Boolean(key)),\n );\n\n const selected: string[] = [];\n for (const [pluginKey, rawEntry] of Object.entries(\n localConfig.plugins as Record<string, unknown>,\n )) {\n if (typeof rawEntry === \"string\") {\n if (!rawEntry.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, rawEntry.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n continue;\n }\n\n if (!rawEntry || typeof rawEntry !== \"object\") {\n selected.push(pluginKey);\n continue;\n }\n\n const entry = rawEntry as Record<string, unknown>;\n const development = typeof entry.development === \"string\" ? entry.development : undefined;\n if (!development?.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, development.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n }\n\n return selected;\n}\n\nfunction hasPluginsWorkspace(projectDir: string): boolean {\n const packageJsonPath = join(projectDir, \"package.json\");\n if (!existsSync(packageJsonPath)) return false;\n\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n workspaces?: { packages?: string[] } | string[];\n };\n const workspaces = pkg.workspaces;\n const packages = Array.isArray(workspaces)\n ? workspaces\n : Array.isArray(workspaces?.packages)\n ? workspaces.packages\n : [];\n return packages.includes(\"plugins/*\");\n } catch {\n return false;\n }\n}\n\nexport async function syncTemplate(projectDir: string, options: SyncOptions): Promise<SyncResult> {\n // Sync reads the raw bos.config.json (not the resolved config) because it needs\n // the user's explicit local settings: their extends ref, selected plugins, etc.\n // The resolved config is the merged result and would include inherited parent\n // values that the user didn't explicitly choose, which would break sync filtering.\n const localConfig = JSON.parse(\n readFileSync(join(projectDir, \"bos.config.json\"), \"utf-8\"),\n ) as Record<string, unknown>;\n\n let extendsRef: string | undefined;\n if (typeof localConfig.extends === \"string\") {\n extendsRef = localConfig.extends;\n } else if (isPlainObjectFromMerge(localConfig.extends)) {\n extendsRef = resolveExtendsRef(localConfig.extends as Record<string, string>, \"production\");\n }\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n conflicted: [],\n error: \"No extends field found in bos.config.json — cannot determine parent\",\n };\n }\n\n const extendsMatch = extendsRef.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!extendsMatch) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n conflicted: [],\n error: `Invalid extends reference: ${extendsRef}`,\n };\n }\n\n const extendsAccount = extendsMatch[1];\n const extendsGateway = extendsMatch[2];\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n });\n\n try {\n const childPlugins = await getSelectedChildPlugins(projectDir, localConfig);\n const withUi = existsSync(join(projectDir, \"ui\", \"package.json\"));\n const withApi = existsSync(join(projectDir, \"api\", \"package.json\"));\n const withHost = existsSync(join(projectDir, \"host\", \"package.json\"));\n const withPlugins = childPlugins.length > 0 || hasPluginsWorkspace(projectDir);\n\n const destToSource = new Map<string, string>();\n for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {\n if (destPath.startsWith(\"ui/\") && !withUi) continue;\n if (destPath.startsWith(\"api/\") && !withApi) continue;\n if (destPath.startsWith(\"host/\") && !withHost) continue;\n const sourcePath = toSourcePath(sourceDir, destPath);\n if (!sourcePath) continue;\n destToSource.set(destPath, sourcePath);\n }\n\n // Sync api/src/lib/{auth,context}.ts into each plugin's src/lib/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n for (const libFile of [\"auth.ts\", \"context.ts\"]) {\n const sourceFile = `api/src/lib/${libFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/lib/${libFile}`, sourceFile);\n }\n }\n\n // Sync api/src/global.d.ts into each plugin's src/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n const sourceFile = \"api/src/global.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/global.d.ts`, sourceFile);\n }\n\n // Sync tests/types.d.ts into each plugin's tests/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/tests/types.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/tests/types.d.ts`, sourceFile);\n }\n\n // Sync api/src/db/{index,layer,migrate}.ts into each plugin's src/db/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n for (const dbFile of [\"index.ts\", \"layer.ts\", \"migrate.ts\"]) {\n const sourceFile = `api/src/db/${dbFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/db/${dbFile}`, sourceFile);\n }\n }\n\n // Sync rspack.config.js from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/rspack.config.js\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/rspack.config.js`, sourceFile);\n }\n\n // Sync drizzle.config.ts from api into each DB-enabled plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n const sourceFile = \"api/drizzle.config.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);\n }\n\n // Sync tsconfig files from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n for (const tsconfigFile of [\"tsconfig.json\", \"tsconfig.contract.json\"]) {\n const sourceFile = `plugins/_template/${tsconfigFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/${tsconfigFile}`, sourceFile);\n }\n }\n\n const updated: string[] = [];\n const skipped: string[] = [];\n const added: string[] = [];\n const conflicted: string[] = [];\n\n const snapshot = await readSnapshot(projectDir);\n const snapshotFiles = snapshot?.files ?? {};\n\n for (const [destPath, filePath] of destToSource.entries()) {\n const localHash = computeLocalHash(projectDir, destPath);\n const sourceHash = computeHash(buildSyncedFileContent(sourceDir, projectDir, filePath));\n\n if (localHash === null) {\n added.push(destPath);\n continue;\n }\n\n if (localHash === sourceHash) {\n skipped.push(destPath);\n continue;\n }\n\n const snapshotHash = snapshotFiles[destPath];\n if (!snapshotHash) {\n updated.push(destPath);\n continue;\n }\n\n if (localHash === snapshotHash) {\n updated.push(destPath);\n continue;\n }\n\n if (sourceHash === snapshotHash) {\n skipped.push(destPath);\n continue;\n }\n\n conflicted.push(destPath);\n }\n\n const account = (localConfig.account as string) || extendsAccount;\n const domain = (localConfig.domain as string) || extendsGateway;\n const overrides: Array<\"ui\" | \"api\" | \"host\" | \"plugins\"> = [];\n if (withUi) overrides.push(\"ui\");\n if (withApi) overrides.push(\"api\");\n if (withHost) overrides.push(\"host\");\n if (withPlugins) overrides.push(\"plugins\");\n\n if (options.dryRun) {\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n updated.push(\"AGENTS.md\");\n }\n }\n }\n\n return {\n status: \"dry-run\",\n updated,\n skipped,\n added,\n conflicted,\n };\n }\n\n const filesToWrite = [...updated, ...added, ...conflicted];\n\n let backupDir: string | undefined;\n if (filesToWrite.length > 0) {\n backupDir = backupFiles(projectDir, filesToWrite) ?? undefined;\n\n for (const destPath of filesToWrite) {\n const sourcePath = destToSource.get(destPath) ?? destPath;\n writeSyncedFile(sourceDir, projectDir, sourcePath, destPath);\n }\n }\n\n await personalizeConfig(projectDir, {\n extendsAccount,\n extendsGateway,\n account,\n domain,\n overrides,\n plugins: childPlugins,\n workspaceOpts: { sourceDir },\n mode: \"sync\",\n existingConfig: localConfig,\n });\n\n await syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n });\n\n const syncedConfig = await loadResolvedConfig({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n writeGeneratedInfra(projectDir, syncedConfig.runtime);\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const destPath of destToSource.keys()) {\n const hash = computeLocalHash(projectDir, destPath);\n if (hash) {\n newSnapshotFiles[destPath] = hash;\n }\n }\n\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n writeFileSync(join(projectDir, \"AGENTS.md\"), expectedContent);\n updated.push(\"AGENTS.md\");\n }\n\n newSnapshotFiles[\"AGENTS.md\"] = expectedHash;\n }\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\n });\n\n if (!options.noInstall) {\n await runBunInstall(projectDir);\n await runTypesGen(projectDir);\n }\n\n return {\n status: \"synced\",\n updated,\n skipped,\n added,\n conflicted,\n backupDir,\n };\n } finally {\n await cleanup();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAM,6CAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,SAAS,YAAY,SAAsC;CACzD,mCAAkB,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,UAAU,GAAG,EAAE;AAC3E;AAeA,SAAS,iBAAiB,YAAoB,UAAiC;CAC7E,MAAM,+BAAgB,YAAY,QAAQ;CAC1C,IAAI,yBAAY,QAAQ,GAAG,OAAO;CAClC,IAAI;EAEF,OAAO,sCADsB,QACJ,CAAC;CAC5B,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,YAAY,YAAoB,WAAoC;CAC3E,MAAM,gBAAgB,UAAU,QAAQ,kDAAsB,YAAY,CAAC,CAAC,CAAC;CAC7E,IAAI,cAAc,WAAW,GAAG,OAAO;CAGvC,MAAM,gCAAiB,YAAY,QAAQ,gCADzB,IAAI,KAAK,EAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,SAAS,GACM,CAAC;CAEnE,KAAK,MAAM,YAAY,eAAe;EACpC,MAAM,0BAAW,YAAY,QAAQ;EACrC,MAAM,2BAAY,WAAW,QAAQ;EACrC,8CAAkB,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;EAC5C,0BAAa,KAAK,IAAI;CACxB;CAEA,OAAO;AACT;AAEA,SAAS,gBACP,OACA,UACoC;CACpC,IAAI,CAAC,SAAS,CAAC,UAAU,OAAO;CAEhC,MAAM,SAAiC,EAAE,GAAI,SAAS,CAAC,EAAG;CAC1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;GAClC;EACF;EAEA,MAAMI,+BAAc,YAAY;GAC9B,WAAW,SAAS,eAAe,GAAG;GACtC,OAAO;EACT,CAAC;EAED,IAAI,CAAC,QAAQ,WAAW;GACtB,MAAMC,+BAAc,UAAU;GAC9B,MAAMC,6BAAY,UAAU;EAC9B;EAEA,OAAO;GACL,QAAQ;GACR;GACA;GACA;GACA;GACA;EACF;CACF,UAAU;EACR,MAAM,QAAQ;CAChB;AACF"}
|
package/dist/cli/sync.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { isPlainObject, mergeBosConfigWithTemplate, resolveExtendsRef } from "..
|
|
|
2
2
|
import { loadResolvedConfig } from "../config.mjs";
|
|
3
3
|
import { syncResolvedSharedDeps } from "../shared-deps.mjs";
|
|
4
4
|
import { writeGeneratedInfra } from "./infra.mjs";
|
|
5
|
-
import { writeSnapshot } from "./snapshot.mjs";
|
|
5
|
+
import { readSnapshot, writeSnapshot } from "./snapshot.mjs";
|
|
6
6
|
import { buildChildAgentsMd, extractSkillsBlock, personalizeConfig, resolveSourceDir, runBunInstall, runTypesGen } from "./init.mjs";
|
|
7
7
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { dirname, join } from "node:path";
|
|
@@ -228,6 +228,7 @@ async function syncTemplate(projectDir, options) {
|
|
|
228
228
|
updated: [],
|
|
229
229
|
skipped: [],
|
|
230
230
|
added: [],
|
|
231
|
+
conflicted: [],
|
|
231
232
|
error: "No extends field found in bos.config.json — cannot determine parent"
|
|
232
233
|
};
|
|
233
234
|
const extendsMatch = extendsRef.match(/^bos:\/\/([^/]+)\/(.+)$/);
|
|
@@ -236,6 +237,7 @@ async function syncTemplate(projectDir, options) {
|
|
|
236
237
|
updated: [],
|
|
237
238
|
skipped: [],
|
|
238
239
|
added: [],
|
|
240
|
+
conflicted: [],
|
|
239
241
|
error: `Invalid extends reference: ${extendsRef}`
|
|
240
242
|
};
|
|
241
243
|
const extendsAccount = extendsMatch[1];
|
|
@@ -314,6 +316,8 @@ async function syncTemplate(projectDir, options) {
|
|
|
314
316
|
const updated = [];
|
|
315
317
|
const skipped = [];
|
|
316
318
|
const added = [];
|
|
319
|
+
const conflicted = [];
|
|
320
|
+
const snapshotFiles = (await readSnapshot(projectDir))?.files ?? {};
|
|
317
321
|
for (const [destPath, filePath] of destToSource.entries()) {
|
|
318
322
|
const localHash = computeLocalHash(projectDir, destPath);
|
|
319
323
|
const sourceHash = computeHash(buildSyncedFileContent(sourceDir, projectDir, filePath));
|
|
@@ -321,7 +325,24 @@ async function syncTemplate(projectDir, options) {
|
|
|
321
325
|
added.push(destPath);
|
|
322
326
|
continue;
|
|
323
327
|
}
|
|
324
|
-
if (localHash
|
|
328
|
+
if (localHash === sourceHash) {
|
|
329
|
+
skipped.push(destPath);
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
const snapshotHash = snapshotFiles[destPath];
|
|
333
|
+
if (!snapshotHash) {
|
|
334
|
+
updated.push(destPath);
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (localHash === snapshotHash) {
|
|
338
|
+
updated.push(destPath);
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
if (sourceHash === snapshotHash) {
|
|
342
|
+
skipped.push(destPath);
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
conflicted.push(destPath);
|
|
325
346
|
}
|
|
326
347
|
const account = localConfig.account || extendsAccount;
|
|
327
348
|
const domain = localConfig.domain || extendsGateway;
|
|
@@ -346,12 +367,18 @@ async function syncTemplate(projectDir, options) {
|
|
|
346
367
|
status: "dry-run",
|
|
347
368
|
updated,
|
|
348
369
|
skipped,
|
|
349
|
-
added
|
|
370
|
+
added,
|
|
371
|
+
conflicted
|
|
350
372
|
};
|
|
351
373
|
}
|
|
352
|
-
const filesToWrite = [
|
|
374
|
+
const filesToWrite = [
|
|
375
|
+
...updated,
|
|
376
|
+
...added,
|
|
377
|
+
...conflicted
|
|
378
|
+
];
|
|
379
|
+
let backupDir;
|
|
353
380
|
if (filesToWrite.length > 0) {
|
|
354
|
-
backupFiles(projectDir, filesToWrite);
|
|
381
|
+
backupDir = backupFiles(projectDir, filesToWrite) ?? void 0;
|
|
355
382
|
for (const destPath of filesToWrite) writeSyncedFile(sourceDir, projectDir, destToSource.get(destPath) ?? destPath, destPath);
|
|
356
383
|
}
|
|
357
384
|
await personalizeConfig(projectDir, {
|
|
@@ -404,7 +431,9 @@ async function syncTemplate(projectDir, options) {
|
|
|
404
431
|
status: "synced",
|
|
405
432
|
updated,
|
|
406
433
|
skipped,
|
|
407
|
-
added
|
|
434
|
+
added,
|
|
435
|
+
conflicted,
|
|
436
|
+
backupDir
|
|
408
437
|
};
|
|
409
438
|
} finally {
|
|
410
439
|
await cleanup();
|
package/dist/cli/sync.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.mjs","names":["isPlainObjectFromMerge"],"sources":["../../src/cli/sync.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { glob } from \"glob\";\nimport { loadResolvedConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { writeGeneratedInfra } from \"./infra\";\nimport {\n buildChildAgentsMd,\n extractSkillsBlock,\n personalizeConfig,\n resolveSourceDir,\n runBunInstall,\n runTypesGen,\n} from \"./init\";\nimport { writeSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_OWNED_SYNC_FILES = new Set([\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bos.config.json\",\n \"bunfig.toml\",\n \"package.json\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \".github/workflows/ci.yml\",\n \".github/workflows/deploy.yml\",\n \".github/workflows/staging.yml\",\n \".github/workflows/release.yml\",\n \"railway.toml\",\n \"ui/package.json\",\n \"ui/postcss.config.mjs\",\n \"ui/rsbuild.config.ts\",\n \"ui/tsconfig.json\",\n \"ui/src/app.ts\",\n \"ui/src/globals.d.ts\",\n \"ui/src/hydrate.tsx\",\n \"ui/src/lib/api.ts\",\n \"ui/src/lib/auth.ts\",\n \"ui/src/router.server.tsx\",\n \"ui/src/router.tsx\",\n \"ui/src/routes/__root.tsx\",\n \"api/package.json\",\n \"api/plugin.dev.ts\",\n \"api/rspack.config.js\",\n \"api/tsconfig.contract.json\",\n \"api/tsconfig.json\",\n \"api/src/lib/auth.ts\",\n \"api/src/lib/context.ts\",\n \"api/drizzle.config.ts\",\n \"api/src/db/index.ts\",\n \"api/src/db/layer.ts\",\n \"api/src/db/migrate.ts\",\n \"api/src/global.d.ts\",\n \"api/tests/types.d.ts\",\n]);\n\ntype PackageJson = Record<string, unknown>;\n\nfunction computeHash(content: string | Uint8Array): string {\n return createHash(\"sha256\").update(content).digest(\"hex\").substring(0, 16);\n}\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n if (FRAMEWORK_OWNED_SYNC_FILES.has(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/lib\\/(auth|context)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/db\\/(index|layer|migrate)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/rspack\\.config\\.js$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/drizzle\\.config\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/global\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tests\\/types\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.json$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.contract\\.json$/.test(filePath)) return true;\n return false;\n}\n\nfunction computeLocalHash(projectDir: string, filePath: string): string | null {\n const fullPath = join(projectDir, filePath);\n if (!existsSync(fullPath)) return null;\n try {\n const content = readFileSync(fullPath);\n return computeHash(content);\n } catch {\n return null;\n }\n}\n\nfunction backupFiles(projectDir: string, filePaths: string[]): string | null {\n const filesToBackup = filePaths.filter((f) => existsSync(join(projectDir, f)));\n if (filesToBackup.length === 0) return null;\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupDir = join(projectDir, \".bos\", \"sync-backup\", timestamp);\n\n for (const filePath of filesToBackup) {\n const src = join(projectDir, filePath);\n const dest = join(backupDir, filePath);\n mkdirSync(dirname(dest), { recursive: true });\n copyFileSync(src, dest);\n }\n\n return backupDir;\n}\n\nfunction mergeStringMaps(\n local: Record<string, string> | undefined,\n template: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!local && !template) return undefined;\n\n const merged: Record<string, string> = { ...(local ?? {}) };\n for (const [name, value] of Object.entries(template ?? {})) {\n merged[name] = value;\n }\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction mergeWorkspacePackages(local: unknown, template: unknown): string[] | undefined {\n const localPackages = Array.isArray(local) ? local : [];\n const templatePackages = Array.isArray(template) ? template : [];\n if (localPackages.length === 0 && templatePackages.length === 0) return undefined;\n\n const ordered = new Set<string>();\n for (const entry of templatePackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n for (const entry of localPackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n\n const hasPluginEntry = [...ordered].some((e) => e.startsWith(\"plugins/\") && e !== \"plugins/*\");\n if (hasPluginEntry) {\n for (const entry of [...ordered]) {\n if (entry.startsWith(\"plugins/\") && entry !== \"plugins/*\") {\n ordered.delete(entry);\n }\n }\n ordered.add(\"plugins/*\");\n }\n\n return ordered.size > 0 ? [...ordered] : undefined;\n}\n\nexport function mergePackageJson(\n filePath: string,\n local: PackageJson,\n template: PackageJson,\n): PackageJson {\n const merged: PackageJson = { ...local, ...template };\n\n if (filePath === \"package.json\") {\n for (const key of [\"name\", \"private\", \"version\"] as const) {\n if (key in local) {\n merged[key] = local[key];\n }\n }\n } else if (\"version\" in local) {\n merged.version = local.version;\n }\n\n for (const depField of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"overrides\",\n ] as const) {\n const localDeps = local[depField] as Record<string, string> | undefined;\n const templateDeps = template[depField] as Record<string, string> | undefined;\n\n const mergedDeps = mergeStringMaps(localDeps, templateDeps);\n if (mergedDeps) {\n merged[depField] = mergedDeps;\n } else {\n delete merged[depField];\n }\n }\n\n if (\n (local.scripts && typeof local.scripts === \"object\") ||\n (template.scripts && typeof template.scripts === \"object\")\n ) {\n const mergedScripts = mergeStringMaps(\n local.scripts as Record<string, string> | undefined,\n template.scripts as Record<string, string> | undefined,\n );\n if (mergedScripts) {\n merged.scripts = mergedScripts;\n } else {\n delete merged.scripts;\n }\n }\n\n if (\n (local.workspaces && typeof local.workspaces === \"object\") ||\n (template.workspaces && typeof template.workspaces === \"object\")\n ) {\n const localWorkspaces = (local.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n const templateWorkspaces = (template.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n\n const mergedWorkspaces: { packages?: string[]; catalog?: Record<string, string> } = {\n ...localWorkspaces,\n ...templateWorkspaces,\n };\n\n const mergedPackages = mergeWorkspacePackages(\n localWorkspaces.packages,\n templateWorkspaces.packages,\n );\n if (mergedPackages) {\n mergedWorkspaces.packages = mergedPackages;\n } else {\n delete mergedWorkspaces.packages;\n }\n\n const mergedCatalog = mergeStringMaps(localWorkspaces.catalog, templateWorkspaces.catalog);\n if (mergedCatalog) {\n mergedWorkspaces.catalog = mergedCatalog;\n } else {\n delete mergedWorkspaces.catalog;\n }\n\n if (Object.keys(mergedWorkspaces).length > 0) {\n merged.workspaces = mergedWorkspaces;\n } else {\n delete merged.workspaces;\n }\n }\n\n return merged;\n}\n\nfunction toSourcePath(sourceDir: string, destPath: string): string | null {\n if (destPath.startsWith(\".github/\")) {\n const templatePath = destPath.replace(/^\\.github\\//, \".github/templates/\");\n if (existsSync(join(sourceDir, templatePath))) {\n return templatePath;\n }\n }\n\n const directPath = join(sourceDir, destPath);\n if (existsSync(directPath)) {\n return destPath;\n }\n\n return null;\n}\n\nfunction buildSyncedFileContent(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): string | Uint8Array {\n const src = join(sourceDir, filePath);\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n\n if (filePath.endsWith(\"bos.config.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergeBosConfigWithTemplate(local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n if (filePath.endsWith(\"package.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergePackageJson(destPath, local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n return readFileSync(src);\n}\n\nfunction writeSyncedFile(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): void {\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n writeFileSync(dest, buildSyncedFileContent(sourceDir, projectDir, filePath, destPath));\n}\n\nasync function getSelectedChildPlugins(\n projectDir: string,\n localConfig: Record<string, unknown>,\n): Promise<string[]> {\n if (!localConfig.plugins || typeof localConfig.plugins !== \"object\") {\n return [];\n }\n\n const pluginDirs = new Set(\n (\n await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n })\n )\n .map((file) => file.match(/^plugins\\/([^/]+)\\/package\\.json$/)?.[1])\n .filter((key): key is string => Boolean(key)),\n );\n\n const selected: string[] = [];\n for (const [pluginKey, rawEntry] of Object.entries(\n localConfig.plugins as Record<string, unknown>,\n )) {\n if (typeof rawEntry === \"string\") {\n if (!rawEntry.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, rawEntry.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n continue;\n }\n\n if (!rawEntry || typeof rawEntry !== \"object\") {\n selected.push(pluginKey);\n continue;\n }\n\n const entry = rawEntry as Record<string, unknown>;\n const development = typeof entry.development === \"string\" ? entry.development : undefined;\n if (!development?.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, development.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n }\n\n return selected;\n}\n\nfunction hasPluginsWorkspace(projectDir: string): boolean {\n const packageJsonPath = join(projectDir, \"package.json\");\n if (!existsSync(packageJsonPath)) return false;\n\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n workspaces?: { packages?: string[] } | string[];\n };\n const workspaces = pkg.workspaces;\n const packages = Array.isArray(workspaces)\n ? workspaces\n : Array.isArray(workspaces?.packages)\n ? workspaces.packages\n : [];\n return packages.includes(\"plugins/*\");\n } catch {\n return false;\n }\n}\n\nexport async function syncTemplate(projectDir: string, options: SyncOptions): Promise<SyncResult> {\n // Sync reads the raw bos.config.json (not the resolved config) because it needs\n // the user's explicit local settings: their extends ref, selected plugins, etc.\n // The resolved config is the merged result and would include inherited parent\n // values that the user didn't explicitly choose, which would break sync filtering.\n const localConfig = JSON.parse(\n readFileSync(join(projectDir, \"bos.config.json\"), \"utf-8\"),\n ) as Record<string, unknown>;\n\n let extendsRef: string | undefined;\n if (typeof localConfig.extends === \"string\") {\n extendsRef = localConfig.extends;\n } else if (isPlainObjectFromMerge(localConfig.extends)) {\n extendsRef = resolveExtendsRef(localConfig.extends as Record<string, string>, \"production\");\n }\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: \"No extends field found in bos.config.json — cannot determine parent\",\n };\n }\n\n const extendsMatch = extendsRef.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!extendsMatch) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: `Invalid extends reference: ${extendsRef}`,\n };\n }\n\n const extendsAccount = extendsMatch[1];\n const extendsGateway = extendsMatch[2];\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n });\n\n try {\n const childPlugins = await getSelectedChildPlugins(projectDir, localConfig);\n const withUi = existsSync(join(projectDir, \"ui\", \"package.json\"));\n const withApi = existsSync(join(projectDir, \"api\", \"package.json\"));\n const withHost = existsSync(join(projectDir, \"host\", \"package.json\"));\n const withPlugins = childPlugins.length > 0 || hasPluginsWorkspace(projectDir);\n\n const destToSource = new Map<string, string>();\n for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {\n if (destPath.startsWith(\"ui/\") && !withUi) continue;\n if (destPath.startsWith(\"api/\") && !withApi) continue;\n if (destPath.startsWith(\"host/\") && !withHost) continue;\n const sourcePath = toSourcePath(sourceDir, destPath);\n if (!sourcePath) continue;\n destToSource.set(destPath, sourcePath);\n }\n\n // Sync api/src/lib/{auth,context}.ts into each plugin's src/lib/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n for (const libFile of [\"auth.ts\", \"context.ts\"]) {\n const sourceFile = `api/src/lib/${libFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/lib/${libFile}`, sourceFile);\n }\n }\n\n // Sync api/src/global.d.ts into each plugin's src/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n const sourceFile = \"api/src/global.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/global.d.ts`, sourceFile);\n }\n\n // Sync tests/types.d.ts into each plugin's tests/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/tests/types.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/tests/types.d.ts`, sourceFile);\n }\n\n // Sync api/src/db/{index,layer,migrate}.ts into each plugin's src/db/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n for (const dbFile of [\"index.ts\", \"layer.ts\", \"migrate.ts\"]) {\n const sourceFile = `api/src/db/${dbFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/db/${dbFile}`, sourceFile);\n }\n }\n\n // Sync rspack.config.js from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/rspack.config.js\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/rspack.config.js`, sourceFile);\n }\n\n // Sync drizzle.config.ts from api into each DB-enabled plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n const sourceFile = \"api/drizzle.config.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);\n }\n\n // Sync tsconfig files from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n for (const tsconfigFile of [\"tsconfig.json\", \"tsconfig.contract.json\"]) {\n const sourceFile = `plugins/_template/${tsconfigFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/${tsconfigFile}`, sourceFile);\n }\n }\n\n const updated: string[] = [];\n const skipped: string[] = [];\n const added: string[] = [];\n\n for (const [destPath, filePath] of destToSource.entries()) {\n const localHash = computeLocalHash(projectDir, destPath);\n const sourceHash = computeHash(buildSyncedFileContent(sourceDir, projectDir, filePath));\n\n if (localHash === null) {\n added.push(destPath);\n continue;\n }\n\n if (localHash !== sourceHash) {\n updated.push(destPath);\n }\n }\n\n const account = (localConfig.account as string) || extendsAccount;\n const domain = (localConfig.domain as string) || extendsGateway;\n const overrides: Array<\"ui\" | \"api\" | \"host\" | \"plugins\"> = [];\n if (withUi) overrides.push(\"ui\");\n if (withApi) overrides.push(\"api\");\n if (withHost) overrides.push(\"host\");\n if (withPlugins) overrides.push(\"plugins\");\n\n if (options.dryRun) {\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n updated.push(\"AGENTS.md\");\n }\n }\n }\n\n return {\n status: \"dry-run\",\n updated,\n skipped,\n added,\n };\n }\n\n const filesToWrite = [...updated, ...added];\n\n if (filesToWrite.length > 0) {\n backupFiles(projectDir, filesToWrite);\n\n for (const destPath of filesToWrite) {\n const sourcePath = destToSource.get(destPath) ?? destPath;\n writeSyncedFile(sourceDir, projectDir, sourcePath, destPath);\n }\n }\n\n await personalizeConfig(projectDir, {\n extendsAccount,\n extendsGateway,\n account,\n domain,\n overrides,\n plugins: childPlugins,\n workspaceOpts: { sourceDir },\n mode: \"sync\",\n existingConfig: localConfig,\n });\n\n await syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n });\n\n const syncedConfig = await loadResolvedConfig({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n writeGeneratedInfra(projectDir, syncedConfig.runtime);\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const destPath of destToSource.keys()) {\n const hash = computeLocalHash(projectDir, destPath);\n if (hash) {\n newSnapshotFiles[destPath] = hash;\n }\n }\n\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n writeFileSync(join(projectDir, \"AGENTS.md\"), expectedContent);\n updated.push(\"AGENTS.md\");\n }\n\n newSnapshotFiles[\"AGENTS.md\"] = expectedHash;\n }\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\n });\n\n if (!options.noInstall) {\n await runBunInstall(projectDir);\n await runTypesGen(projectDir);\n }\n\n return {\n status: \"synced\",\n updated,\n skipped,\n added,\n };\n } finally {\n await cleanup();\n }\n}\n"],"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,OAAO;GACL,QAAQ;GACR;GACA;GACA;EACF;CACF,UAAU;EACR,MAAM,QAAQ;CAChB;AACF"}
|
|
1
|
+
{"version":3,"file":"sync.mjs","names":["isPlainObjectFromMerge"],"sources":["../../src/cli/sync.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { glob } from \"glob\";\nimport { loadResolvedConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { syncResolvedSharedDeps } from \"../shared-deps\";\nimport { writeGeneratedInfra } from \"./infra\";\nimport {\n buildChildAgentsMd,\n extractSkillsBlock,\n personalizeConfig,\n resolveSourceDir,\n runBunInstall,\n runTypesGen,\n} from \"./init\";\nimport { readSnapshot, writeSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_OWNED_SYNC_FILES = new Set([\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bos.config.json\",\n \"bunfig.toml\",\n \"package.json\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \".github/workflows/ci.yml\",\n \".github/workflows/deploy.yml\",\n \".github/workflows/staging.yml\",\n \".github/workflows/release.yml\",\n \"railway.toml\",\n \"ui/package.json\",\n \"ui/postcss.config.mjs\",\n \"ui/rsbuild.config.ts\",\n \"ui/tsconfig.json\",\n \"ui/src/app.ts\",\n \"ui/src/globals.d.ts\",\n \"ui/src/hydrate.tsx\",\n \"ui/src/lib/api.ts\",\n \"ui/src/lib/auth.ts\",\n \"ui/src/router.server.tsx\",\n \"ui/src/router.tsx\",\n \"ui/src/routes/__root.tsx\",\n \"api/package.json\",\n \"api/plugin.dev.ts\",\n \"api/rspack.config.js\",\n \"api/tsconfig.contract.json\",\n \"api/tsconfig.json\",\n \"api/src/lib/auth.ts\",\n \"api/src/lib/context.ts\",\n \"api/drizzle.config.ts\",\n \"api/src/db/index.ts\",\n \"api/src/db/layer.ts\",\n \"api/src/db/migrate.ts\",\n \"api/src/global.d.ts\",\n \"api/tests/types.d.ts\",\n]);\n\ntype PackageJson = Record<string, unknown>;\n\nfunction computeHash(content: string | Uint8Array): string {\n return createHash(\"sha256\").update(content).digest(\"hex\").substring(0, 16);\n}\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n if (FRAMEWORK_OWNED_SYNC_FILES.has(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/lib\\/(auth|context)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/db\\/(index|layer|migrate)\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/rspack\\.config\\.js$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/drizzle\\.config\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/src\\/global\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tests\\/types\\.d\\.ts$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.json$/.test(filePath)) return true;\n if (/^plugins\\/[^/]+\\/tsconfig\\.contract\\.json$/.test(filePath)) return true;\n return false;\n}\n\nfunction computeLocalHash(projectDir: string, filePath: string): string | null {\n const fullPath = join(projectDir, filePath);\n if (!existsSync(fullPath)) return null;\n try {\n const content = readFileSync(fullPath);\n return computeHash(content);\n } catch {\n return null;\n }\n}\n\nfunction backupFiles(projectDir: string, filePaths: string[]): string | null {\n const filesToBackup = filePaths.filter((f) => existsSync(join(projectDir, f)));\n if (filesToBackup.length === 0) return null;\n\n const timestamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const backupDir = join(projectDir, \".bos\", \"sync-backup\", timestamp);\n\n for (const filePath of filesToBackup) {\n const src = join(projectDir, filePath);\n const dest = join(backupDir, filePath);\n mkdirSync(dirname(dest), { recursive: true });\n copyFileSync(src, dest);\n }\n\n return backupDir;\n}\n\nfunction mergeStringMaps(\n local: Record<string, string> | undefined,\n template: Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!local && !template) return undefined;\n\n const merged: Record<string, string> = { ...(local ?? {}) };\n for (const [name, value] of Object.entries(template ?? {})) {\n merged[name] = value;\n }\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction mergeWorkspacePackages(local: unknown, template: unknown): string[] | undefined {\n const localPackages = Array.isArray(local) ? local : [];\n const templatePackages = Array.isArray(template) ? template : [];\n if (localPackages.length === 0 && templatePackages.length === 0) return undefined;\n\n const ordered = new Set<string>();\n for (const entry of templatePackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n for (const entry of localPackages) {\n if (typeof entry === \"string\" && entry.length > 0) ordered.add(entry);\n }\n\n const hasPluginEntry = [...ordered].some((e) => e.startsWith(\"plugins/\") && e !== \"plugins/*\");\n if (hasPluginEntry) {\n for (const entry of [...ordered]) {\n if (entry.startsWith(\"plugins/\") && entry !== \"plugins/*\") {\n ordered.delete(entry);\n }\n }\n ordered.add(\"plugins/*\");\n }\n\n return ordered.size > 0 ? [...ordered] : undefined;\n}\n\nexport function mergePackageJson(\n filePath: string,\n local: PackageJson,\n template: PackageJson,\n): PackageJson {\n const merged: PackageJson = { ...local, ...template };\n\n if (filePath === \"package.json\") {\n for (const key of [\"name\", \"private\", \"version\"] as const) {\n if (key in local) {\n merged[key] = local[key];\n }\n }\n } else if (\"version\" in local) {\n merged.version = local.version;\n }\n\n for (const depField of [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"overrides\",\n ] as const) {\n const localDeps = local[depField] as Record<string, string> | undefined;\n const templateDeps = template[depField] as Record<string, string> | undefined;\n\n const mergedDeps = mergeStringMaps(localDeps, templateDeps);\n if (mergedDeps) {\n merged[depField] = mergedDeps;\n } else {\n delete merged[depField];\n }\n }\n\n if (\n (local.scripts && typeof local.scripts === \"object\") ||\n (template.scripts && typeof template.scripts === \"object\")\n ) {\n const mergedScripts = mergeStringMaps(\n local.scripts as Record<string, string> | undefined,\n template.scripts as Record<string, string> | undefined,\n );\n if (mergedScripts) {\n merged.scripts = mergedScripts;\n } else {\n delete merged.scripts;\n }\n }\n\n if (\n (local.workspaces && typeof local.workspaces === \"object\") ||\n (template.workspaces && typeof template.workspaces === \"object\")\n ) {\n const localWorkspaces = (local.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n const templateWorkspaces = (template.workspaces ?? {}) as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n\n const mergedWorkspaces: { packages?: string[]; catalog?: Record<string, string> } = {\n ...localWorkspaces,\n ...templateWorkspaces,\n };\n\n const mergedPackages = mergeWorkspacePackages(\n localWorkspaces.packages,\n templateWorkspaces.packages,\n );\n if (mergedPackages) {\n mergedWorkspaces.packages = mergedPackages;\n } else {\n delete mergedWorkspaces.packages;\n }\n\n const mergedCatalog = mergeStringMaps(localWorkspaces.catalog, templateWorkspaces.catalog);\n if (mergedCatalog) {\n mergedWorkspaces.catalog = mergedCatalog;\n } else {\n delete mergedWorkspaces.catalog;\n }\n\n if (Object.keys(mergedWorkspaces).length > 0) {\n merged.workspaces = mergedWorkspaces;\n } else {\n delete merged.workspaces;\n }\n }\n\n return merged;\n}\n\nfunction toSourcePath(sourceDir: string, destPath: string): string | null {\n if (destPath.startsWith(\".github/\")) {\n const templatePath = destPath.replace(/^\\.github\\//, \".github/templates/\");\n if (existsSync(join(sourceDir, templatePath))) {\n return templatePath;\n }\n }\n\n const directPath = join(sourceDir, destPath);\n if (existsSync(directPath)) {\n return destPath;\n }\n\n return null;\n}\n\nfunction buildSyncedFileContent(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): string | Uint8Array {\n const src = join(sourceDir, filePath);\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n\n if (filePath.endsWith(\"bos.config.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergeBosConfigWithTemplate(local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n if (filePath.endsWith(\"package.json\")) {\n const localContent = existsSync(dest) ? readFileSync(dest, \"utf-8\") : null;\n const templateContent = readFileSync(src, \"utf-8\");\n\n if (localContent) {\n const local = JSON.parse(localContent) as Record<string, unknown>;\n const template = JSON.parse(templateContent) as Record<string, unknown>;\n const merged = mergePackageJson(destPath, local, template);\n return `${JSON.stringify(merged, null, 2)}\\n`;\n }\n }\n\n return readFileSync(src);\n}\n\nfunction writeSyncedFile(\n sourceDir: string,\n projectDir: string,\n filePath: string,\n explicitDestPath?: string,\n): void {\n const destPath =\n explicitDestPath ??\n (filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath);\n const dest = join(projectDir, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n writeFileSync(dest, buildSyncedFileContent(sourceDir, projectDir, filePath, destPath));\n}\n\nasync function getSelectedChildPlugins(\n projectDir: string,\n localConfig: Record<string, unknown>,\n): Promise<string[]> {\n if (!localConfig.plugins || typeof localConfig.plugins !== \"object\") {\n return [];\n }\n\n const pluginDirs = new Set(\n (\n await glob(\"plugins/*/package.json\", {\n cwd: projectDir,\n nodir: true,\n dot: false,\n absolute: false,\n })\n )\n .map((file) => file.match(/^plugins\\/([^/]+)\\/package\\.json$/)?.[1])\n .filter((key): key is string => Boolean(key)),\n );\n\n const selected: string[] = [];\n for (const [pluginKey, rawEntry] of Object.entries(\n localConfig.plugins as Record<string, unknown>,\n )) {\n if (typeof rawEntry === \"string\") {\n if (!rawEntry.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, rawEntry.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n continue;\n }\n\n if (!rawEntry || typeof rawEntry !== \"object\") {\n selected.push(pluginKey);\n continue;\n }\n\n const entry = rawEntry as Record<string, unknown>;\n const development = typeof entry.development === \"string\" ? entry.development : undefined;\n if (!development?.startsWith(\"local:\")) {\n selected.push(pluginKey);\n continue;\n }\n\n const localPath = join(projectDir, development.slice(\"local:\".length).trim());\n if (existsSync(localPath) || pluginDirs.has(pluginKey)) {\n selected.push(pluginKey);\n }\n }\n\n return selected;\n}\n\nfunction hasPluginsWorkspace(projectDir: string): boolean {\n const packageJsonPath = join(projectDir, \"package.json\");\n if (!existsSync(packageJsonPath)) return false;\n\n try {\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n workspaces?: { packages?: string[] } | string[];\n };\n const workspaces = pkg.workspaces;\n const packages = Array.isArray(workspaces)\n ? workspaces\n : Array.isArray(workspaces?.packages)\n ? workspaces.packages\n : [];\n return packages.includes(\"plugins/*\");\n } catch {\n return false;\n }\n}\n\nexport async function syncTemplate(projectDir: string, options: SyncOptions): Promise<SyncResult> {\n // Sync reads the raw bos.config.json (not the resolved config) because it needs\n // the user's explicit local settings: their extends ref, selected plugins, etc.\n // The resolved config is the merged result and would include inherited parent\n // values that the user didn't explicitly choose, which would break sync filtering.\n const localConfig = JSON.parse(\n readFileSync(join(projectDir, \"bos.config.json\"), \"utf-8\"),\n ) as Record<string, unknown>;\n\n let extendsRef: string | undefined;\n if (typeof localConfig.extends === \"string\") {\n extendsRef = localConfig.extends;\n } else if (isPlainObjectFromMerge(localConfig.extends)) {\n extendsRef = resolveExtendsRef(localConfig.extends as Record<string, string>, \"production\");\n }\n if (!extendsRef?.startsWith(\"bos://\")) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n conflicted: [],\n error: \"No extends field found in bos.config.json — cannot determine parent\",\n };\n }\n\n const extendsMatch = extendsRef.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!extendsMatch) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n conflicted: [],\n error: `Invalid extends reference: ${extendsRef}`,\n };\n }\n\n const extendsAccount = extendsMatch[1];\n const extendsGateway = extendsMatch[2];\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n extendsAccount,\n extendsGateway,\n });\n\n try {\n const childPlugins = await getSelectedChildPlugins(projectDir, localConfig);\n const withUi = existsSync(join(projectDir, \"ui\", \"package.json\"));\n const withApi = existsSync(join(projectDir, \"api\", \"package.json\"));\n const withHost = existsSync(join(projectDir, \"host\", \"package.json\"));\n const withPlugins = childPlugins.length > 0 || hasPluginsWorkspace(projectDir);\n\n const destToSource = new Map<string, string>();\n for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {\n if (destPath.startsWith(\"ui/\") && !withUi) continue;\n if (destPath.startsWith(\"api/\") && !withApi) continue;\n if (destPath.startsWith(\"host/\") && !withHost) continue;\n const sourcePath = toSourcePath(sourceDir, destPath);\n if (!sourcePath) continue;\n destToSource.set(destPath, sourcePath);\n }\n\n // Sync api/src/lib/{auth,context}.ts into each plugin's src/lib/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n for (const libFile of [\"auth.ts\", \"context.ts\"]) {\n const sourceFile = `api/src/lib/${libFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/lib/${libFile}`, sourceFile);\n }\n }\n\n // Sync api/src/global.d.ts into each plugin's src/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\"))) continue;\n const sourceFile = \"api/src/global.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/global.d.ts`, sourceFile);\n }\n\n // Sync tests/types.d.ts into each plugin's tests/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/tests/types.d.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/tests/types.d.ts`, sourceFile);\n }\n\n // Sync api/src/db/{index,layer,migrate}.ts into each plugin's src/db/\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n for (const dbFile of [\"index.ts\", \"layer.ts\", \"migrate.ts\"]) {\n const sourceFile = `api/src/db/${dbFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/src/db/${dbFile}`, sourceFile);\n }\n }\n\n // Sync rspack.config.js from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n const sourceFile = \"plugins/_template/rspack.config.js\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/rspack.config.js`, sourceFile);\n }\n\n // Sync drizzle.config.ts from api into each DB-enabled plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey, \"src\", \"db\"))) continue;\n const sourceFile = \"api/drizzle.config.ts\";\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/drizzle.config.ts`, sourceFile);\n }\n\n // Sync tsconfig files from the template into each plugin\n for (const pluginKey of childPlugins) {\n if (!existsSync(join(projectDir, \"plugins\", pluginKey))) continue;\n for (const tsconfigFile of [\"tsconfig.json\", \"tsconfig.contract.json\"]) {\n const sourceFile = `plugins/_template/${tsconfigFile}`;\n if (!existsSync(join(sourceDir, sourceFile))) continue;\n destToSource.set(`plugins/${pluginKey}/${tsconfigFile}`, sourceFile);\n }\n }\n\n const updated: string[] = [];\n const skipped: string[] = [];\n const added: string[] = [];\n const conflicted: string[] = [];\n\n const snapshot = await readSnapshot(projectDir);\n const snapshotFiles = snapshot?.files ?? {};\n\n for (const [destPath, filePath] of destToSource.entries()) {\n const localHash = computeLocalHash(projectDir, destPath);\n const sourceHash = computeHash(buildSyncedFileContent(sourceDir, projectDir, filePath));\n\n if (localHash === null) {\n added.push(destPath);\n continue;\n }\n\n if (localHash === sourceHash) {\n skipped.push(destPath);\n continue;\n }\n\n const snapshotHash = snapshotFiles[destPath];\n if (!snapshotHash) {\n updated.push(destPath);\n continue;\n }\n\n if (localHash === snapshotHash) {\n updated.push(destPath);\n continue;\n }\n\n if (sourceHash === snapshotHash) {\n skipped.push(destPath);\n continue;\n }\n\n conflicted.push(destPath);\n }\n\n const account = (localConfig.account as string) || extendsAccount;\n const domain = (localConfig.domain as string) || extendsGateway;\n const overrides: Array<\"ui\" | \"api\" | \"host\" | \"plugins\"> = [];\n if (withUi) overrides.push(\"ui\");\n if (withApi) overrides.push(\"api\");\n if (withHost) overrides.push(\"host\");\n if (withPlugins) overrides.push(\"plugins\");\n\n if (options.dryRun) {\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n updated.push(\"AGENTS.md\");\n }\n }\n }\n\n return {\n status: \"dry-run\",\n updated,\n skipped,\n added,\n conflicted,\n };\n }\n\n const filesToWrite = [...updated, ...added, ...conflicted];\n\n let backupDir: string | undefined;\n if (filesToWrite.length > 0) {\n backupDir = backupFiles(projectDir, filesToWrite) ?? undefined;\n\n for (const destPath of filesToWrite) {\n const sourcePath = destToSource.get(destPath) ?? destPath;\n writeSyncedFile(sourceDir, projectDir, sourcePath, destPath);\n }\n }\n\n await personalizeConfig(projectDir, {\n extendsAccount,\n extendsGateway,\n account,\n domain,\n overrides,\n plugins: childPlugins,\n workspaceOpts: { sourceDir },\n mode: \"sync\",\n existingConfig: localConfig,\n });\n\n await syncResolvedSharedDeps({\n configDir: projectDir,\n hostMode: \"local\",\n });\n\n const syncedConfig = await loadResolvedConfig({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n writeGeneratedInfra(projectDir, syncedConfig.runtime);\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const destPath of destToSource.keys()) {\n const hash = computeLocalHash(projectDir, destPath);\n if (hash) {\n newSnapshotFiles[destPath] = hash;\n }\n }\n\n const agentsMdSourcePath = toSourcePath(sourceDir, \"AGENTS.md\");\n if (agentsMdSourcePath) {\n const agentsMdSourceContent = readFileSync(join(sourceDir, agentsMdSourcePath), \"utf-8\");\n const skillsBlock = extractSkillsBlock(agentsMdSourceContent);\n if (skillsBlock) {\n const expectedContent = buildChildAgentsMd(skillsBlock, {\n overrides,\n plugins: childPlugins,\n });\n const expectedHash = computeHash(expectedContent);\n\n const agentsMdLocalHash = computeLocalHash(projectDir, \"AGENTS.md\");\n if (agentsMdLocalHash !== expectedHash) {\n writeFileSync(join(projectDir, \"AGENTS.md\"), expectedContent);\n updated.push(\"AGENTS.md\");\n }\n\n newSnapshotFiles[\"AGENTS.md\"] = expectedHash;\n }\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\n });\n\n if (!options.noInstall) {\n await runBunInstall(projectDir);\n await runTypesGen(projectDir);\n }\n\n return {\n status: \"synced\",\n updated,\n skipped,\n added,\n conflicted,\n backupDir,\n };\n } finally {\n await cleanup();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAM,6CAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAC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