everything-dev 1.26.1 → 1.28.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.
Files changed (166) hide show
  1. package/dist/api-contract.cjs.map +1 -1
  2. package/dist/api-contract.mjs.map +1 -1
  3. package/dist/cli/catalog.cjs.map +1 -1
  4. package/dist/cli/catalog.mjs.map +1 -1
  5. package/dist/cli/framework-version.cjs.map +1 -1
  6. package/dist/cli/framework-version.mjs.map +1 -1
  7. package/dist/cli/infra.cjs +1 -1
  8. package/dist/cli/infra.cjs.map +1 -1
  9. package/dist/cli/infra.mjs +1 -1
  10. package/dist/cli/infra.mjs.map +1 -1
  11. package/dist/cli/init.cjs +127 -121
  12. package/dist/cli/init.cjs.map +1 -1
  13. package/dist/cli/init.d.cts +6 -6
  14. package/dist/cli/init.d.cts.map +1 -1
  15. package/dist/cli/init.d.mts +6 -6
  16. package/dist/cli/init.d.mts.map +1 -1
  17. package/dist/cli/init.mjs +125 -121
  18. package/dist/cli/init.mjs.map +1 -1
  19. package/dist/cli/parse.cjs.map +1 -1
  20. package/dist/cli/parse.mjs.map +1 -1
  21. package/dist/cli/prompts.cjs +29 -25
  22. package/dist/cli/prompts.cjs.map +1 -1
  23. package/dist/cli/prompts.mjs +28 -25
  24. package/dist/cli/prompts.mjs.map +1 -1
  25. package/dist/cli/status.cjs.map +1 -1
  26. package/dist/cli/status.mjs.map +1 -1
  27. package/dist/cli/sync.cjs +46 -93
  28. package/dist/cli/sync.cjs.map +1 -1
  29. package/dist/cli/sync.mjs +49 -96
  30. package/dist/cli/sync.mjs.map +1 -1
  31. package/dist/cli/timing.cjs.map +1 -1
  32. package/dist/cli/timing.mjs.map +1 -1
  33. package/dist/cli/upgrade.cjs +41 -20
  34. package/dist/cli/upgrade.cjs.map +1 -1
  35. package/dist/cli/upgrade.mjs +43 -22
  36. package/dist/cli/upgrade.mjs.map +1 -1
  37. package/dist/cli.cjs +187 -12
  38. package/dist/cli.cjs.map +1 -1
  39. package/dist/cli.mjs +187 -12
  40. package/dist/cli.mjs.map +1 -1
  41. package/dist/components/dev-view.cjs.map +1 -1
  42. package/dist/components/dev-view.mjs.map +1 -1
  43. package/dist/components/streaming-view.cjs.map +1 -1
  44. package/dist/components/streaming-view.mjs.map +1 -1
  45. package/dist/config.cjs.map +1 -1
  46. package/dist/config.mjs.map +1 -1
  47. package/dist/contract.cjs +174 -173
  48. package/dist/contract.cjs.map +1 -1
  49. package/dist/contract.d.cts +48 -44
  50. package/dist/contract.d.cts.map +1 -1
  51. package/dist/contract.d.mts +48 -44
  52. package/dist/contract.d.mts.map +1 -1
  53. package/dist/contract.mjs +3 -1
  54. package/dist/contract.mjs.map +1 -1
  55. package/dist/dev-logs.cjs.map +1 -1
  56. package/dist/dev-logs.mjs.map +1 -1
  57. package/dist/dev-session.cjs +0 -1
  58. package/dist/dev-session.mjs +1 -1
  59. package/dist/fastkv.cjs.map +1 -1
  60. package/dist/fastkv.mjs.map +1 -1
  61. package/dist/index.cjs +2 -4
  62. package/dist/index.d.cts +3 -3
  63. package/dist/index.d.mts +3 -3
  64. package/dist/index.mjs +1 -2
  65. package/dist/integrity.cjs.map +1 -1
  66. package/dist/integrity.mjs.map +1 -1
  67. package/dist/internal/manifest-normalizer.cjs.map +1 -1
  68. package/dist/internal/manifest-normalizer.mjs.map +1 -1
  69. package/dist/merge.cjs.map +1 -1
  70. package/dist/merge.mjs.map +1 -1
  71. package/dist/near-cli.cjs +1 -1
  72. package/dist/near-cli.cjs.map +1 -1
  73. package/dist/near-cli.mjs +1 -1
  74. package/dist/near-cli.mjs.map +1 -1
  75. package/dist/orchestrator.cjs +1 -1
  76. package/dist/orchestrator.cjs.map +1 -1
  77. package/dist/orchestrator.mjs +1 -1
  78. package/dist/orchestrator.mjs.map +1 -1
  79. package/dist/plugin.cjs +182 -171
  80. package/dist/plugin.cjs.map +1 -1
  81. package/dist/plugin.d.cts +72 -39
  82. package/dist/plugin.d.cts.map +1 -1
  83. package/dist/plugin.d.mts +71 -39
  84. package/dist/plugin.d.mts.map +1 -1
  85. package/dist/plugin.mjs +170 -160
  86. package/dist/plugin.mjs.map +1 -1
  87. package/dist/sdk.cjs +2 -2
  88. package/dist/sdk.d.cts +1 -1
  89. package/dist/sdk.d.mts +1 -1
  90. package/dist/sdk.mjs +1 -1
  91. package/dist/service-descriptor.d.cts +34 -0
  92. package/dist/service-descriptor.d.cts.map +1 -0
  93. package/dist/service-descriptor.d.mts +36 -0
  94. package/dist/service-descriptor.d.mts.map +1 -0
  95. package/dist/shared.cjs.map +1 -1
  96. package/dist/shared.mjs.map +1 -1
  97. package/dist/types.cjs +184 -184
  98. package/dist/types.cjs.map +1 -1
  99. package/dist/types.d.cts +5 -5
  100. package/dist/types.d.mts +5 -5
  101. package/dist/types.mjs +1 -1
  102. package/dist/types.mjs.map +1 -1
  103. package/dist/ui/types.d.cts +1 -0
  104. package/dist/ui/types.d.cts.map +1 -1
  105. package/dist/ui/types.d.mts +1 -0
  106. package/dist/ui/types.d.mts.map +1 -1
  107. package/dist/utils/banner.cjs.map +1 -1
  108. package/dist/utils/banner.mjs.map +1 -1
  109. package/dist/utils/run.cjs.map +1 -1
  110. package/dist/utils/run.mjs.map +1 -1
  111. package/package.json +3 -3
  112. package/skills/init-upgrade/SKILL.md +22 -16
  113. package/skills/publish-sync/SKILL.md +7 -18
  114. package/dist/utils/path-match.cjs +0 -18
  115. package/dist/utils/path-match.cjs.map +0 -1
  116. package/dist/utils/path-match.mjs +0 -17
  117. package/dist/utils/path-match.mjs.map +0 -1
  118. package/src/api-contract.ts +0 -623
  119. package/src/app.ts +0 -193
  120. package/src/cli/catalog.ts +0 -49
  121. package/src/cli/framework-version.ts +0 -61
  122. package/src/cli/help.ts +0 -13
  123. package/src/cli/infra.ts +0 -190
  124. package/src/cli/init.ts +0 -1202
  125. package/src/cli/parse.ts +0 -147
  126. package/src/cli/prompts.ts +0 -135
  127. package/src/cli/snapshot.ts +0 -46
  128. package/src/cli/status.ts +0 -99
  129. package/src/cli/sync.ts +0 -518
  130. package/src/cli/timing.ts +0 -63
  131. package/src/cli/upgrade.ts +0 -828
  132. package/src/cli.ts +0 -516
  133. package/src/components/dev-view.tsx +0 -352
  134. package/src/components/streaming-view.ts +0 -177
  135. package/src/config.ts +0 -893
  136. package/src/contract.meta.ts +0 -140
  137. package/src/contract.ts +0 -325
  138. package/src/dev-logs.ts +0 -92
  139. package/src/dev-session.ts +0 -283
  140. package/src/fastkv.ts +0 -181
  141. package/src/index.ts +0 -8
  142. package/src/integrity.ts +0 -138
  143. package/src/internal/manifest-normalizer.ts +0 -290
  144. package/src/merge.ts +0 -187
  145. package/src/mf.ts +0 -147
  146. package/src/near-cli.ts +0 -259
  147. package/src/network.ts +0 -3
  148. package/src/orchestrator.ts +0 -493
  149. package/src/plugin.ts +0 -1821
  150. package/src/sdk.ts +0 -14
  151. package/src/service-descriptor.ts +0 -281
  152. package/src/shared.ts +0 -249
  153. package/src/sidebar.ts +0 -140
  154. package/src/types.ts +0 -330
  155. package/src/ui/head.ts +0 -83
  156. package/src/ui/index.ts +0 -5
  157. package/src/ui/metadata.ts +0 -95
  158. package/src/ui/router.ts +0 -88
  159. package/src/ui/runtime.ts +0 -42
  160. package/src/ui/types.ts +0 -64
  161. package/src/utils/banner.ts +0 -21
  162. package/src/utils/linkify.ts +0 -11
  163. package/src/utils/path-match.ts +0 -16
  164. package/src/utils/run.ts +0 -31
  165. package/src/utils/save-config.ts +0 -20
  166. package/src/utils/theme.ts +0 -39
@@ -1 +1 @@
1
- {"version":3,"file":"status.cjs","names":["readInstalledFrameworkVersion","fetchBosConfigFromFastKv","readSnapshot"],"sources":["../../src/cli/status.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { StatusResult } from \"../contract\";\nimport { fetchBosConfigFromFastKv } from \"../fastkv\";\nimport { readInstalledFrameworkVersion } from \"./framework-version\";\nimport { readSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_PACKAGES = [\"everything-dev\", \"every-plugin\"];\n\nconst CATALOG_TOOL_PACKAGES = [\n \"@rspack/core\",\n \"@rspack/cli\",\n \"@rsbuild/core\",\n \"@rsbuild/plugin-react\",\n \"@module-federation/enhanced\",\n \"@module-federation/node\",\n \"@module-federation/rsbuild-plugin\",\n \"@module-federation/runtime-core\",\n \"@module-federation/sdk\",\n \"@module-federation/dts-plugin\",\n] as const;\n\nasync function fetchLatestNpmVersion(packageName: string): Promise<string | null> {\n try {\n const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {\n headers: { Accept: \"application/json\" },\n signal: AbortSignal.timeout(10_000),\n });\n if (!response.ok) return null;\n const data = (await response.json()) as { version: string };\n return data.version;\n } catch {\n return null;\n }\n}\n\nfunction readInstalledVersion(projectDir: string, packageName: string): string | undefined {\n return readInstalledFrameworkVersion(projectDir, packageName);\n}\n\nfunction checkEnvFile(projectDir: string): \"found\" | \"missing\" | \"example-only\" {\n if (existsSync(join(projectDir, \".env\"))) return \"found\";\n if (existsSync(join(projectDir, \".env.example\"))) return \"example-only\";\n return \"missing\";\n}\n\nasync function checkParentReachable(extendsRef: string | undefined): Promise<boolean | undefined> {\n if (!extendsRef?.startsWith(\"bos://\")) return undefined;\n try {\n const config = await fetchBosConfigFromFastKv(extendsRef);\n return config !== null;\n } catch {\n return false;\n }\n}\n\nexport async function getStatus(projectDir: string): Promise<StatusResult> {\n const configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return {\n status: \"error\",\n error: \"No bos.config.json found in current directory\",\n packages: [],\n envFile: \"missing\",\n };\n }\n\n const config = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\n\n const packages = [];\n for (const name of FRAMEWORK_PACKAGES) {\n const installed = readInstalledVersion(projectDir, name);\n const latest = await fetchLatestNpmVersion(name);\n packages.push({ name, installed, latest: latest ?? undefined });\n }\n\n for (const name of CATALOG_TOOL_PACKAGES) {\n const installed = readInstalledVersion(projectDir, name);\n if (!installed) continue;\n const latest = await fetchLatestNpmVersion(name);\n packages.push({ name, installed, latest: latest ?? undefined });\n }\n\n const snapshot = await readSnapshot(projectDir);\n\n const extendsRef = config.extends as string | undefined;\n const parentReachable = await checkParentReachable(extendsRef);\n\n return {\n status: \"ok\",\n extends: extendsRef,\n account: config.account as string | undefined,\n domain: config.domain as string | undefined,\n packages,\n lastSync: snapshot?.timestamp,\n envFile: checkEnvFile(projectDir),\n parentReachable,\n };\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,qBAAqB,CAAC,kBAAkB,eAAe;AAE7D,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,eAAe,sBAAsB,aAA6C;AAChF,KAAI;EACF,MAAM,WAAW,MAAM,MAAM,8BAA8B,YAAY,UAAU;GAC/E,SAAS,EAAE,QAAQ,oBAAoB;GACvC,QAAQ,YAAY,QAAQ,IAAO;GACpC,CAAC;AACF,MAAI,CAAC,SAAS,GAAI,QAAO;AAEzB,UADc,MAAM,SAAS,MAAM,EACvB;SACN;AACN,SAAO;;;AAIX,SAAS,qBAAqB,YAAoB,aAAyC;AACzF,QAAOA,wDAA8B,YAAY,YAAY;;AAG/D,SAAS,aAAa,YAA0D;AAC9E,iDAAoB,YAAY,OAAO,CAAC,CAAE,QAAO;AACjD,iDAAoB,YAAY,eAAe,CAAC,CAAE,QAAO;AACzD,QAAO;;AAGT,eAAe,qBAAqB,YAA8D;AAChG,KAAI,CAAC,YAAY,WAAW,SAAS,CAAE,QAAO;AAC9C,KAAI;AAEF,SADe,MAAMC,wCAAyB,WAAW,KACvC;SACZ;AACN,SAAO;;;AAIX,eAAsB,UAAU,YAA2C;CACzE,MAAM,iCAAkB,YAAY,kBAAkB;AACtD,KAAI,yBAAY,WAAW,CACzB,QAAO;EACL,QAAQ;EACR,OAAO;EACP,UAAU,EAAE;EACZ,SAAS;EACV;CAGH,MAAM,SAAS,KAAK,gCAAmB,YAAY,QAAQ,CAAC;CAE5D,MAAM,WAAW,EAAE;AACnB,MAAK,MAAM,QAAQ,oBAAoB;EACrC,MAAM,YAAY,qBAAqB,YAAY,KAAK;EACxD,MAAM,SAAS,MAAM,sBAAsB,KAAK;AAChD,WAAS,KAAK;GAAE;GAAM;GAAW,QAAQ,UAAU;GAAW,CAAC;;AAGjE,MAAK,MAAM,QAAQ,uBAAuB;EACxC,MAAM,YAAY,qBAAqB,YAAY,KAAK;AACxD,MAAI,CAAC,UAAW;EAChB,MAAM,SAAS,MAAM,sBAAsB,KAAK;AAChD,WAAS,KAAK;GAAE;GAAM;GAAW,QAAQ,UAAU;GAAW,CAAC;;CAGjE,MAAM,WAAW,MAAMC,8BAAa,WAAW;CAE/C,MAAM,aAAa,OAAO;CAC1B,MAAM,kBAAkB,MAAM,qBAAqB,WAAW;AAE9D,QAAO;EACL,QAAQ;EACR,SAAS;EACT,SAAS,OAAO;EAChB,QAAQ,OAAO;EACf;EACA,UAAU,UAAU;EACpB,SAAS,aAAa,WAAW;EACjC;EACD"}
1
+ {"version":3,"file":"status.cjs","names":["readInstalledFrameworkVersion","fetchBosConfigFromFastKv","readSnapshot"],"sources":["../../src/cli/status.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { StatusResult } from \"../contract\";\nimport { fetchBosConfigFromFastKv } from \"../fastkv\";\nimport { readInstalledFrameworkVersion } from \"./framework-version\";\nimport { readSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_PACKAGES = [\"everything-dev\", \"every-plugin\"];\n\nconst CATALOG_TOOL_PACKAGES = [\n \"@rspack/core\",\n \"@rspack/cli\",\n \"@rsbuild/core\",\n \"@rsbuild/plugin-react\",\n \"@module-federation/enhanced\",\n \"@module-federation/node\",\n \"@module-federation/rsbuild-plugin\",\n \"@module-federation/runtime-core\",\n \"@module-federation/sdk\",\n \"@module-federation/dts-plugin\",\n] as const;\n\nasync function fetchLatestNpmVersion(packageName: string): Promise<string | null> {\n try {\n const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {\n headers: { Accept: \"application/json\" },\n signal: AbortSignal.timeout(10_000),\n });\n if (!response.ok) return null;\n const data = (await response.json()) as { version: string };\n return data.version;\n } catch {\n return null;\n }\n}\n\nfunction readInstalledVersion(projectDir: string, packageName: string): string | undefined {\n return readInstalledFrameworkVersion(projectDir, packageName);\n}\n\nfunction checkEnvFile(projectDir: string): \"found\" | \"missing\" | \"example-only\" {\n if (existsSync(join(projectDir, \".env\"))) return \"found\";\n if (existsSync(join(projectDir, \".env.example\"))) return \"example-only\";\n return \"missing\";\n}\n\nasync function checkParentReachable(extendsRef: string | undefined): Promise<boolean | undefined> {\n if (!extendsRef?.startsWith(\"bos://\")) return undefined;\n try {\n const config = await fetchBosConfigFromFastKv(extendsRef);\n return config !== null;\n } catch {\n return false;\n }\n}\n\nexport async function getStatus(projectDir: string): Promise<StatusResult> {\n const configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return {\n status: \"error\",\n error: \"No bos.config.json found in current directory\",\n packages: [],\n envFile: \"missing\",\n };\n }\n\n const config = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\n\n const packages = [];\n for (const name of FRAMEWORK_PACKAGES) {\n const installed = readInstalledVersion(projectDir, name);\n const latest = await fetchLatestNpmVersion(name);\n packages.push({ name, installed, latest: latest ?? undefined });\n }\n\n for (const name of CATALOG_TOOL_PACKAGES) {\n const installed = readInstalledVersion(projectDir, name);\n if (!installed) continue;\n const latest = await fetchLatestNpmVersion(name);\n packages.push({ name, installed, latest: latest ?? undefined });\n }\n\n const snapshot = await readSnapshot(projectDir);\n\n const extendsRef = config.extends as string | undefined;\n const parentReachable = await checkParentReachable(extendsRef);\n\n return {\n status: \"ok\",\n extends: extendsRef,\n account: config.account as string | undefined,\n domain: config.domain as string | undefined,\n packages,\n lastSync: snapshot?.timestamp,\n envFile: checkEnvFile(projectDir),\n parentReachable,\n };\n}\n"],"mappings":";;;;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B,MAAM,SAAS,MAAM,sBAAsB,KAAK;AAChD,WAAS,KAAK;GAAE;GAAM;GAAW,QAAQ,UAAU;GAAW,CAAC;;CAGjE,MAAM,WAAW,MAAMC,8BAAa,WAAW;CAE/C,MAAM,aAAa,OAAO;CAC1B,MAAM,kBAAkB,MAAM,qBAAqB,WAAW;AAE9D,QAAO;EACL,QAAQ;EACR,SAAS;EACT,SAAS,OAAO;EAChB,QAAQ,OAAO;EACf;EACA,UAAU,UAAU;EACpB,SAAS,aAAa,WAAW;EACjC;EACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"status.mjs","names":[],"sources":["../../src/cli/status.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { StatusResult } from \"../contract\";\nimport { fetchBosConfigFromFastKv } from \"../fastkv\";\nimport { readInstalledFrameworkVersion } from \"./framework-version\";\nimport { readSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_PACKAGES = [\"everything-dev\", \"every-plugin\"];\n\nconst CATALOG_TOOL_PACKAGES = [\n \"@rspack/core\",\n \"@rspack/cli\",\n \"@rsbuild/core\",\n \"@rsbuild/plugin-react\",\n \"@module-federation/enhanced\",\n \"@module-federation/node\",\n \"@module-federation/rsbuild-plugin\",\n \"@module-federation/runtime-core\",\n \"@module-federation/sdk\",\n \"@module-federation/dts-plugin\",\n] as const;\n\nasync function fetchLatestNpmVersion(packageName: string): Promise<string | null> {\n try {\n const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {\n headers: { Accept: \"application/json\" },\n signal: AbortSignal.timeout(10_000),\n });\n if (!response.ok) return null;\n const data = (await response.json()) as { version: string };\n return data.version;\n } catch {\n return null;\n }\n}\n\nfunction readInstalledVersion(projectDir: string, packageName: string): string | undefined {\n return readInstalledFrameworkVersion(projectDir, packageName);\n}\n\nfunction checkEnvFile(projectDir: string): \"found\" | \"missing\" | \"example-only\" {\n if (existsSync(join(projectDir, \".env\"))) return \"found\";\n if (existsSync(join(projectDir, \".env.example\"))) return \"example-only\";\n return \"missing\";\n}\n\nasync function checkParentReachable(extendsRef: string | undefined): Promise<boolean | undefined> {\n if (!extendsRef?.startsWith(\"bos://\")) return undefined;\n try {\n const config = await fetchBosConfigFromFastKv(extendsRef);\n return config !== null;\n } catch {\n return false;\n }\n}\n\nexport async function getStatus(projectDir: string): Promise<StatusResult> {\n const configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return {\n status: \"error\",\n error: \"No bos.config.json found in current directory\",\n packages: [],\n envFile: \"missing\",\n };\n }\n\n const config = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\n\n const packages = [];\n for (const name of FRAMEWORK_PACKAGES) {\n const installed = readInstalledVersion(projectDir, name);\n const latest = await fetchLatestNpmVersion(name);\n packages.push({ name, installed, latest: latest ?? undefined });\n }\n\n for (const name of CATALOG_TOOL_PACKAGES) {\n const installed = readInstalledVersion(projectDir, name);\n if (!installed) continue;\n const latest = await fetchLatestNpmVersion(name);\n packages.push({ name, installed, latest: latest ?? undefined });\n }\n\n const snapshot = await readSnapshot(projectDir);\n\n const extendsRef = config.extends as string | undefined;\n const parentReachable = await checkParentReachable(extendsRef);\n\n return {\n status: \"ok\",\n extends: extendsRef,\n account: config.account as string | undefined,\n domain: config.domain as string | undefined,\n packages,\n lastSync: snapshot?.timestamp,\n envFile: checkEnvFile(projectDir),\n parentReachable,\n };\n}\n"],"mappings":";;;;;;;AAOA,MAAM,qBAAqB,CAAC,kBAAkB,eAAe;AAE7D,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,eAAe,sBAAsB,aAA6C;AAChF,KAAI;EACF,MAAM,WAAW,MAAM,MAAM,8BAA8B,YAAY,UAAU;GAC/E,SAAS,EAAE,QAAQ,oBAAoB;GACvC,QAAQ,YAAY,QAAQ,IAAO;GACpC,CAAC;AACF,MAAI,CAAC,SAAS,GAAI,QAAO;AAEzB,UADc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,aAAa,WAAW;EACjC;EACD"}
1
+ {"version":3,"file":"status.mjs","names":[],"sources":["../../src/cli/status.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { StatusResult } from \"../contract\";\nimport { fetchBosConfigFromFastKv } from \"../fastkv\";\nimport { readInstalledFrameworkVersion } from \"./framework-version\";\nimport { readSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_PACKAGES = [\"everything-dev\", \"every-plugin\"];\n\nconst CATALOG_TOOL_PACKAGES = [\n \"@rspack/core\",\n \"@rspack/cli\",\n \"@rsbuild/core\",\n \"@rsbuild/plugin-react\",\n \"@module-federation/enhanced\",\n \"@module-federation/node\",\n \"@module-federation/rsbuild-plugin\",\n \"@module-federation/runtime-core\",\n \"@module-federation/sdk\",\n \"@module-federation/dts-plugin\",\n] as const;\n\nasync function fetchLatestNpmVersion(packageName: string): Promise<string | null> {\n try {\n const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {\n headers: { Accept: \"application/json\" },\n signal: AbortSignal.timeout(10_000),\n });\n if (!response.ok) return null;\n const data = (await response.json()) as { version: string };\n return data.version;\n } catch {\n return null;\n }\n}\n\nfunction readInstalledVersion(projectDir: string, packageName: string): string | undefined {\n return readInstalledFrameworkVersion(projectDir, packageName);\n}\n\nfunction checkEnvFile(projectDir: string): \"found\" | \"missing\" | \"example-only\" {\n if (existsSync(join(projectDir, \".env\"))) return \"found\";\n if (existsSync(join(projectDir, \".env.example\"))) return \"example-only\";\n return \"missing\";\n}\n\nasync function checkParentReachable(extendsRef: string | undefined): Promise<boolean | undefined> {\n if (!extendsRef?.startsWith(\"bos://\")) return undefined;\n try {\n const config = await fetchBosConfigFromFastKv(extendsRef);\n return config !== null;\n } catch {\n return false;\n }\n}\n\nexport async function getStatus(projectDir: string): Promise<StatusResult> {\n const configPath = join(projectDir, \"bos.config.json\");\n if (!existsSync(configPath)) {\n return {\n status: \"error\",\n error: \"No bos.config.json found in current directory\",\n packages: [],\n envFile: \"missing\",\n };\n }\n\n const config = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\n\n const packages = [];\n for (const name of FRAMEWORK_PACKAGES) {\n const installed = readInstalledVersion(projectDir, name);\n const latest = await fetchLatestNpmVersion(name);\n packages.push({ name, installed, latest: latest ?? undefined });\n }\n\n for (const name of CATALOG_TOOL_PACKAGES) {\n const installed = readInstalledVersion(projectDir, name);\n if (!installed) continue;\n const latest = await fetchLatestNpmVersion(name);\n packages.push({ name, installed, latest: latest ?? undefined });\n }\n\n const snapshot = await readSnapshot(projectDir);\n\n const extendsRef = config.extends as string | undefined;\n const parentReachable = await checkParentReachable(extendsRef);\n\n return {\n status: \"ok\",\n extends: extendsRef,\n account: config.account as string | undefined,\n domain: config.domain as string | undefined,\n packages,\n lastSync: snapshot?.timestamp,\n envFile: checkEnvFile(projectDir),\n parentReachable,\n };\n}\n"],"mappings":";;;;;;;AAOA,MAAM,qBAAqB,CAAC,kBAAkB,eAAe;AAE7D,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,eAAe,sBAAsB,aAA6C;AAChF,KAAI;EACF,MAAM,WAAW,MAAM,MAAM,8BAA8B,YAAY,UAAU;GAC/E,SAAS,EAAE,QAAQ,oBAAoB;GACvC,QAAQ,YAAY,QAAQ,IAAO;GACpC,CAAC;AACF,MAAI,CAAC,SAAS,GAAI,QAAO;AAEzB,UAAO,MADa,SAAS,MAAM,EACvB;SACN;AACN,SAAO;;;AAIX,SAAS,qBAAqB,YAAoB,aAAyC;AACzF,QAAO,8BAA8B,YAAY,YAAY;;AAG/D,SAAS,aAAa,YAA0D;AAC9E,KAAI,WAAW,KAAK,YAAY,OAAO,CAAC,CAAE,QAAO;AACjD,KAAI,WAAW,KAAK,YAAY,eAAe,CAAC,CAAE,QAAO;AACzD,QAAO;;AAGT,eAAe,qBAAqB,YAA8D;AAChG,KAAI,CAAC,YAAY,WAAW,SAAS,CAAE,QAAO;AAC9C,KAAI;AAEF,SAAO,MADc,yBAAyB,WAAW,KACvC;SACZ;AACN,SAAO;;;AAIX,eAAsB,UAAU,YAA2C;CACzE,MAAM,aAAa,KAAK,YAAY,kBAAkB;AACtD,KAAI,CAAC,WAAW,WAAW,CACzB,QAAO;EACL,QAAQ;EACR,OAAO;EACP,UAAU,EAAE;EACZ,SAAS;EACV;CAGH,MAAM,SAAS,KAAK,MAAM,aAAa,YAAY,QAAQ,CAAC;CAE5D,MAAM,WAAW,EAAE;AACnB,MAAK,MAAM,QAAQ,oBAAoB;EACrC,MAAM,YAAY,qBAAqB,YAAY,KAAK;EACxD,MAAM,SAAS,MAAM,sBAAsB,KAAK;AAChD,WAAS,KAAK;GAAE;GAAM;GAAW,QAAQ,UAAU;GAAW,CAAC;;AAGjE,MAAK,MAAM,QAAQ,uBAAuB;EACxC,MAAM,YAAY,qBAAqB,YAAY,KAAK;AACxD,MAAI,CAAC,UAAW;EAChB,MAAM,SAAS,MAAM,sBAAsB,KAAK;AAChD,WAAS,KAAK;GAAE;GAAM;GAAW,QAAQ,UAAU;GAAW,CAAC;;CAGjE,MAAM,WAAW,MAAM,aAAa,WAAW;CAE/C,MAAM,aAAa,OAAO;CAC1B,MAAM,kBAAkB,MAAM,qBAAqB,WAAW;AAE9D,QAAO;EACL,QAAQ;EACR,SAAS;EACT,SAAS,OAAO;EAChB,QAAQ,OAAO;EACf;EACA,UAAU,UAAU;EACpB,SAAS,aAAa,WAAW;EACjC;EACD"}
package/dist/cli/sync.cjs CHANGED
@@ -2,30 +2,34 @@ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
2
  const require_merge = require('../merge.cjs');
3
3
  const require_config = require('../config.cjs');
4
4
  const require_infra = require('./infra.cjs');
5
- const require_path_match = require('../utils/path-match.cjs');
6
5
  const require_snapshot = require('./snapshot.cjs');
7
6
  const require_cli_init = require('./init.cjs');
8
7
  let node_fs = require("node:fs");
9
8
  let node_path = require("node:path");
10
9
  let node_crypto = require("node:crypto");
11
- let glob = require("glob");
12
10
 
13
11
  //#region src/cli/sync.ts
14
12
  const FRAMEWORK_OWNED_SYNC_FILES = new Set([
15
13
  ".env.example",
16
14
  ".gitignore",
15
+ "AGENTS.md",
17
16
  "biome.json",
18
17
  "bos.config.json",
18
+ "bunfig.toml",
19
+ "CONTRIBUTING.md",
19
20
  "package.json",
20
- "docker-compose.yml",
21
+ ".changeset/config.json",
22
+ ".changeset/README.md",
21
23
  ".github/renovate.json",
22
24
  ".github/workflows/ci.yml",
23
25
  ".github/workflows/release-sync.yml",
26
+ ".opencode/skills/everything-dev/SKILL.md",
24
27
  "ui/package.json",
25
28
  "ui/postcss.config.mjs",
26
29
  "ui/rsbuild.config.ts",
27
30
  "ui/tsconfig.json",
28
31
  "ui/src/app.ts",
32
+ "ui/src/globals.d.ts",
29
33
  "ui/src/hydrate.tsx",
30
34
  "ui/src/lib/api.ts",
31
35
  "ui/src/lib/auth.ts",
@@ -39,19 +43,6 @@ const FRAMEWORK_OWNED_SYNC_FILES = new Set([
39
43
  "api/tsconfig.json",
40
44
  "api/src/lib/auth.ts"
41
45
  ]);
42
- function isFrameworkOwnedSyncFile(filePath) {
43
- return FRAMEWORK_OWNED_SYNC_FILES.has(filePath);
44
- }
45
- function readExcludeFile(filePath) {
46
- if (!(0, node_fs.existsSync)(filePath)) return [];
47
- return (0, node_fs.readFileSync)(filePath, "utf-8").split("\n").map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
48
- }
49
- async function readTemplatesyncExclude(sourceDir) {
50
- return readExcludeFile((0, node_path.join)(sourceDir, ".templatesync-exclude"));
51
- }
52
- function readLocalSyncExcludes(projectDir) {
53
- return readExcludeFile((0, node_path.join)(projectDir, ".bos", "sync-local-exclude"));
54
- }
55
46
  function computeLocalHash(projectDir, filePath) {
56
47
  const fullPath = (0, node_path.join)(projectDir, filePath);
57
48
  if (!(0, node_fs.existsSync)(fullPath)) return null;
@@ -87,6 +78,10 @@ function mergeWorkspacePackages(local, template) {
87
78
  const ordered = /* @__PURE__ */ new Set();
88
79
  for (const entry of templatePackages) if (typeof entry === "string" && entry.length > 0) ordered.add(entry);
89
80
  for (const entry of localPackages) if (typeof entry === "string" && entry.length > 0) ordered.add(entry);
81
+ if ([...ordered].some((e) => e.startsWith("plugins/") && e !== "plugins/*")) {
82
+ for (const entry of [...ordered]) if (entry.startsWith("plugins/") && entry !== "plugins/*") ordered.delete(entry);
83
+ ordered.add("plugins/*");
84
+ }
90
85
  return ordered.size > 0 ? [...ordered] : void 0;
91
86
  }
92
87
  function mergePackageJson(filePath, local, template) {
@@ -137,7 +132,15 @@ function mergePackageJson(filePath, local, template) {
137
132
  return merged;
138
133
  }
139
134
  function toDestPath(filePath) {
140
- return filePath.startsWith(".github/templates/") ? filePath.replace(/^\.github\/templates\//, ".github/") : filePath;
135
+ return require_cli_init.sourcePathToDestinationPath(filePath);
136
+ }
137
+ function toSourcePath(sourceDir, destPath) {
138
+ if ((0, node_fs.existsSync)((0, node_path.join)(sourceDir, destPath))) return destPath;
139
+ if (destPath.startsWith(".github/")) {
140
+ const templatePath = destPath.replace(/^\.github\//, ".github/templates/");
141
+ if ((0, node_fs.existsSync)((0, node_path.join)(sourceDir, templatePath))) return templatePath;
142
+ }
143
+ return null;
141
144
  }
142
145
  function writeSyncedFile(sourceDir, projectDir, filePath) {
143
146
  const src = (0, node_path.join)(sourceDir, filePath);
@@ -191,60 +194,25 @@ async function syncTemplate(projectDir, options) {
191
194
  extendsGateway
192
195
  });
193
196
  try {
194
- const patterns = await require_cli_init.readTemplatekeep(sourceDir);
195
- if (patterns.length === 0) return {
196
- status: "error",
197
- updated: [],
198
- skipped: [],
199
- added: [],
200
- error: "No .templatekeep found in template source"
201
- };
202
- const parentExcludes = await readTemplatesyncExclude(sourceDir);
203
- const localExcludes = readLocalSyncExcludes(projectDir);
204
- const excludePatterns = [...parentExcludes, ...localExcludes];
205
- const allTemplateFiles = /* @__PURE__ */ new Set();
206
- for (const pattern of patterns) {
207
- const matches = await (0, glob.glob)(pattern, {
208
- cwd: sourceDir,
209
- nodir: true,
210
- dot: true,
211
- absolute: false
212
- });
213
- for (const match of matches) allTemplateFiles.add(match);
214
- }
215
197
  const childPlugins = localConfig.plugins && typeof localConfig.plugins === "object" ? Object.keys(localConfig.plugins) : [];
216
- const pluginRoutes = {};
217
- const parentRuntime = await require_config.loadConfig({ cwd: sourceDir });
218
- for (const [key, plugin] of Object.entries(parentRuntime?.runtime.plugins ?? {})) if (plugin.routes && plugin.routes.length > 0) pluginRoutes[key] = plugin.routes;
219
- const excludedRoutePatterns = [];
220
- for (const [pluginKey, routePatterns] of Object.entries(pluginRoutes)) if (!childPlugins.includes(pluginKey)) excludedRoutePatterns.push(...routePatterns);
198
+ const withUi = (0, node_fs.existsSync)((0, node_path.join)(projectDir, "ui", "package.json"));
199
+ const withApi = (0, node_fs.existsSync)((0, node_path.join)(projectDir, "api", "package.json"));
200
+ const withHost = (0, node_fs.existsSync)((0, node_path.join)(projectDir, "host", "package.json"));
221
201
  const filteredFiles = /* @__PURE__ */ new Set();
222
- for (const filePath of allTemplateFiles) {
223
- const pluginMatch = filePath.match(/^plugins\/([^/]+)/);
224
- if (pluginMatch && !childPlugins.includes(pluginMatch[1])) continue;
225
- if (require_path_match.isPathExcluded(filePath, excludedRoutePatterns)) continue;
226
- filteredFiles.add(filePath);
227
- }
228
- for (const [pluginKey, routePatterns] of Object.entries(pluginRoutes)) {
229
- if (!childPlugins.includes(pluginKey)) continue;
230
- for (const rp of routePatterns) {
231
- const matches = await (0, glob.glob)(rp, {
232
- cwd: sourceDir,
233
- nodir: true,
234
- dot: true,
235
- absolute: false
236
- });
237
- for (const match of matches) if (!require_path_match.isPathExcluded(match, excludedRoutePatterns)) filteredFiles.add(match);
238
- }
202
+ const destToSource = /* @__PURE__ */ new Map();
203
+ for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {
204
+ if (destPath.startsWith("ui/") && !withUi) continue;
205
+ if (destPath.startsWith("api/") && !withApi) continue;
206
+ if (destPath.startsWith("host/") && !withHost) continue;
207
+ const sourcePath = toSourcePath(sourceDir, destPath);
208
+ if (!sourcePath) continue;
209
+ filteredFiles.add(sourcePath);
210
+ destToSource.set(destPath, sourcePath);
239
211
  }
240
- const snapshot = await require_snapshot.readSnapshot(projectDir);
241
212
  const updated = [];
242
213
  const skipped = [];
243
214
  const added = [];
244
- for (const filePath of filteredFiles) {
245
- const destPath = toDestPath(filePath);
246
- const frameworkOwned = isFrameworkOwnedSyncFile(destPath);
247
- if (require_path_match.isPathExcluded(destPath, excludePatterns) && !frameworkOwned) continue;
215
+ for (const [destPath, filePath] of destToSource.entries()) {
248
216
  const localHash = computeLocalHash(projectDir, destPath);
249
217
  const sourceContent = (0, node_fs.readFileSync)((0, node_path.join)(sourceDir, filePath));
250
218
  const sourceHash = (0, node_crypto.createHash)("sha256").update(sourceContent).digest("hex").substring(0, 16);
@@ -252,19 +220,7 @@ async function syncTemplate(projectDir, options) {
252
220
  added.push(destPath);
253
221
  continue;
254
222
  }
255
- if (localHash === sourceHash) continue;
256
- if (frameworkOwned) {
257
- updated.push(destPath);
258
- continue;
259
- }
260
- const snapshotHash = snapshot?.files[destPath];
261
- if (snapshotHash === void 0) {
262
- updated.push(destPath);
263
- continue;
264
- }
265
- if (localHash === snapshotHash) updated.push(destPath);
266
- else if (options.force) updated.push(destPath);
267
- else skipped.push(destPath);
223
+ if (localHash !== sourceHash) updated.push(destPath);
268
224
  }
269
225
  if (options.dryRun) return {
270
226
  status: "dry-run",
@@ -272,37 +228,34 @@ async function syncTemplate(projectDir, options) {
272
228
  skipped,
273
229
  added
274
230
  };
275
- const filesToWrite = [...updated, ...added].filter((f) => isFrameworkOwnedSyncFile(f) || !require_path_match.isPathExcluded(f, excludePatterns));
276
- const destToSource = /* @__PURE__ */ new Map();
277
- for (const filePath of filteredFiles) destToSource.set(toDestPath(filePath), filePath);
231
+ const filesToWrite = [...updated, ...added];
278
232
  if (filesToWrite.length > 0) {
279
233
  backupFiles(projectDir, filesToWrite);
280
234
  for (const destPath of filesToWrite) writeSyncedFile(sourceDir, projectDir, destToSource.get(destPath) ?? destPath);
281
235
  }
282
236
  const newSnapshotFiles = {};
283
237
  for (const filePath of filteredFiles) {
284
- const src = (0, node_path.join)(sourceDir, filePath);
285
- if (!(0, node_fs.lstatSync)(src).isFile()) continue;
286
- const content = (0, node_fs.readFileSync)(src);
238
+ const content = (0, node_fs.readFileSync)((0, node_path.join)(sourceDir, filePath));
287
239
  newSnapshotFiles[toDestPath(filePath)] = (0, node_crypto.createHash)("sha256").update(content).digest("hex").substring(0, 16);
288
240
  }
289
241
  await require_snapshot.writeSnapshot(projectDir, {
290
242
  parentRef: `bos://${extendsAccount}/${extendsGateway}`,
291
243
  files: newSnapshotFiles
292
244
  });
245
+ const account = localConfig.account || extendsAccount;
246
+ const domain = localConfig.domain || extendsGateway;
247
+ const overrides = [];
248
+ if (withUi) overrides.push("ui");
249
+ if (withApi) overrides.push("api");
250
+ if (withHost) overrides.push("host");
251
+ if (childPlugins.length > 0) overrides.push("plugins");
293
252
  await require_cli_init.personalizeConfig(projectDir, {
294
253
  extendsAccount,
295
254
  extendsGateway,
296
- account: localConfig.account || extendsAccount,
297
- domain: localConfig.domain || extendsGateway,
255
+ account,
256
+ domain,
257
+ overrides,
298
258
  plugins: childPlugins,
299
- pluginRoutes,
300
- overrides: [
301
- "ui",
302
- "api",
303
- "host",
304
- "plugins"
305
- ],
306
259
  workspaceOpts: { sourceDir },
307
260
  mode: "sync"
308
261
  });
@@ -1 +1 @@
1
- {"version":3,"file":"sync.cjs","names":["mergeBosConfigWithTemplate","isPlainObjectFromMerge","resolveExtendsRef","resolveSourceDir","readTemplatekeep","loadConfig","isPathExcluded","readSnapshot","writeSnapshot","personalizeConfig","runBunInstall","runTypesGen"],"sources":["../../src/cli/sync.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport {\n copyFileSync,\n existsSync,\n lstatSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { glob } from \"glob\";\nimport { loadConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { isPathExcluded } from \"../utils/path-match\";\nimport { writeGeneratedInfra } from \"./infra\";\nimport {\n personalizeConfig,\n readTemplatekeep,\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 \"package.json\",\n \"docker-compose.yml\",\n \".github/renovate.json\",\n \".github/workflows/ci.yml\",\n \".github/workflows/release-sync.yml\",\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/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]);\n\ntype PackageJson = Record<string, unknown>;\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n return FRAMEWORK_OWNED_SYNC_FILES.has(filePath);\n}\n\nfunction readExcludeFile(filePath: string): string[] {\n if (!existsSync(filePath)) return [];\n const content = readFileSync(filePath, \"utf-8\");\n return content\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => line.length > 0 && !line.startsWith(\"#\"));\n}\n\nexport async function readTemplatesyncExclude(sourceDir: string): Promise<string[]> {\n return readExcludeFile(join(sourceDir, \".templatesync-exclude\"));\n}\n\nexport function readLocalSyncExcludes(projectDir: string): string[] {\n return readExcludeFile(join(projectDir, \".bos\", \"sync-local-exclude\"));\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 createHash(\"sha256\").update(content).digest(\"hex\").substring(0, 16);\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 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 toDestPath(filePath: string): string {\n return filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath;\n}\n\nfunction writeSyncedFile(sourceDir: string, projectDir: string, filePath: string): void {\n const src = join(sourceDir, filePath);\n const destPath = 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\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 writeFileSync(dest, `${JSON.stringify(merged, null, 2)}\\n`);\n return;\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 writeFileSync(dest, `${JSON.stringify(merged, null, 2)}\\n`);\n return;\n }\n }\n\n writeFileSync(dest, readFileSync(src));\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 patterns = await readTemplatekeep(sourceDir);\n if (patterns.length === 0) {\n return {\n status: \"error\",\n updated: [],\n skipped: [],\n added: [],\n error: \"No .templatekeep found in template source\",\n };\n }\n\n const parentExcludes = await readTemplatesyncExclude(sourceDir);\n const localExcludes = readLocalSyncExcludes(projectDir);\n const excludePatterns = [...parentExcludes, ...localExcludes];\n\n const allTemplateFiles = new Set<string>();\n for (const pattern of patterns) {\n const matches = await glob(pattern, {\n cwd: sourceDir,\n nodir: true,\n dot: true,\n absolute: false,\n });\n for (const match of matches) {\n allTemplateFiles.add(match);\n }\n }\n\n const childPlugins =\n localConfig.plugins && typeof localConfig.plugins === \"object\"\n ? Object.keys(localConfig.plugins as Record<string, unknown>)\n : [];\n\n const pluginRoutes: Record<string, string[]> = {};\n const parentRuntime = await loadConfig({ cwd: sourceDir });\n for (const [key, plugin] of Object.entries(parentRuntime?.runtime.plugins ?? {})) {\n if (plugin.routes && plugin.routes.length > 0) {\n pluginRoutes[key] = plugin.routes;\n }\n }\n\n const excludedRoutePatterns: string[] = [];\n for (const [pluginKey, routePatterns] of Object.entries(pluginRoutes)) {\n if (!childPlugins.includes(pluginKey)) {\n excludedRoutePatterns.push(...routePatterns);\n }\n }\n\n const filteredFiles = new Set<string>();\n for (const filePath of allTemplateFiles) {\n const pluginMatch = filePath.match(/^plugins\\/([^/]+)/);\n if (pluginMatch && !childPlugins.includes(pluginMatch[1])) continue;\n if (isPathExcluded(filePath, excludedRoutePatterns)) continue;\n filteredFiles.add(filePath);\n }\n\n for (const [pluginKey, routePatterns] of Object.entries(pluginRoutes)) {\n if (!childPlugins.includes(pluginKey)) continue;\n for (const rp of routePatterns) {\n const matches = await glob(rp, {\n cwd: sourceDir,\n nodir: true,\n dot: true,\n absolute: false,\n });\n for (const match of matches) {\n if (!isPathExcluded(match, excludedRoutePatterns)) {\n filteredFiles.add(match);\n }\n }\n }\n }\n\n const snapshot = await readSnapshot(projectDir);\n\n const updated: string[] = [];\n const skipped: string[] = [];\n const added: string[] = [];\n\n for (const filePath of filteredFiles) {\n const destPath = toDestPath(filePath);\n const frameworkOwned = isFrameworkOwnedSyncFile(destPath);\n if (isPathExcluded(destPath, excludePatterns) && !frameworkOwned) continue;\n\n const localHash = computeLocalHash(projectDir, destPath);\n const sourceContent = readFileSync(join(sourceDir, filePath));\n const sourceHash = createHash(\"sha256\").update(sourceContent).digest(\"hex\").substring(0, 16);\n\n if (localHash === null) {\n added.push(destPath);\n continue;\n }\n\n if (localHash === sourceHash) continue;\n\n if (frameworkOwned) {\n updated.push(destPath);\n continue;\n }\n\n const snapshotHash = snapshot?.files[destPath];\n\n if (snapshotHash === undefined) {\n updated.push(destPath);\n continue;\n }\n\n if (localHash === snapshotHash) {\n updated.push(destPath);\n } else {\n if (options.force) {\n updated.push(destPath);\n } else {\n skipped.push(destPath);\n }\n }\n }\n\n if (options.dryRun) {\n return {\n status: \"dry-run\",\n updated,\n skipped,\n added,\n };\n }\n\n const filesToWrite = [...updated, ...added].filter(\n (f) => isFrameworkOwnedSyncFile(f) || !isPathExcluded(f, excludePatterns),\n );\n\n const destToSource = new Map<string, string>();\n for (const filePath of filteredFiles) {\n destToSource.set(toDestPath(filePath), filePath);\n }\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);\n }\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const filePath of filteredFiles) {\n const src = join(sourceDir, filePath);\n const stat = lstatSync(src);\n if (!stat.isFile()) continue;\n const content = readFileSync(src);\n newSnapshotFiles[toDestPath(filePath)] = createHash(\"sha256\")\n .update(content)\n .digest(\"hex\")\n .substring(0, 16);\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\n });\n\n const account = (localConfig.account as string) || extendsAccount;\n const domain = (localConfig.domain as string) || extendsGateway;\n\n await personalizeConfig(projectDir, {\n extendsAccount,\n extendsGateway,\n account,\n domain,\n plugins: childPlugins,\n pluginRoutes,\n overrides: [\"ui\", \"api\", \"host\", \"plugins\"],\n workspaceOpts: { sourceDir },\n mode: \"sync\",\n });\n\n const syncedConfig = await loadConfig({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n writeGeneratedInfra(projectDir, syncedConfig.runtime);\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":";;;;;;;;;;;;;AA6BA,MAAM,6BAA6B,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;CACD,CAAC;AAIF,SAAgB,yBAAyB,UAA2B;AAClE,QAAO,2BAA2B,IAAI,SAAS;;AAGjD,SAAS,gBAAgB,UAA4B;AACnD,KAAI,yBAAY,SAAS,CAAE,QAAO,EAAE;AAEpC,kCAD6B,UAAU,QAAQ,CAE5C,MAAM,KAAK,CACX,KAAK,SAAS,KAAK,MAAM,CAAC,CAC1B,QAAQ,SAAS,KAAK,SAAS,KAAK,CAAC,KAAK,WAAW,IAAI,CAAC;;AAG/D,eAAsB,wBAA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ANe,YAAY,WAAsB;GAOjD,QANc,YAAY,UAAqB;GAO/C,SAAS;GACT;GACA,WAAW;IAAC;IAAM;IAAO;IAAQ;IAAU;GAC3C,eAAe,EAAE,WAAW;GAC5B,MAAM;GACP,CAAC;EAEF,MAAM,eAAe,MAAMJ,0BAAW,EAAE,KAAK,YAAY,CAAC;AAC1D,MAAI,cAAc,QAChB,mCAAoB,YAAY,aAAa,QAAQ;AAGvD,MAAI,CAAC,QAAQ,WAAW;AACtB,SAAMK,+BAAc,WAAW;AAC/B,SAAMC,6BAAY,WAAW;;AAG/B,SAAO;GACL,QAAQ;GACR;GACA;GACA;GACD;WACO;AACR,QAAM,SAAS"}
1
+ {"version":3,"file":"sync.cjs","names":["sourcePathToDestinationPath","mergeBosConfigWithTemplate","isPlainObjectFromMerge","resolveExtendsRef","resolveSourceDir","writeSnapshot","personalizeConfig","loadConfig","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 { loadConfig } from \"../config\";\nimport type { SyncOptions, SyncResult } from \"../contract\";\nimport {\n isPlainObject as isPlainObjectFromMerge,\n mergeBosConfigWithTemplate,\n resolveExtendsRef,\n} from \"../merge\";\nimport { writeGeneratedInfra } from \"./infra\";\nimport {\n personalizeConfig,\n resolveSourceDir,\n runBunInstall,\n runTypesGen,\n sourcePathToDestinationPath,\n} from \"./init\";\nimport { writeSnapshot } from \"./snapshot\";\n\nconst FRAMEWORK_OWNED_SYNC_FILES = new Set([\n \".env.example\",\n \".gitignore\",\n \"AGENTS.md\",\n \"biome.json\",\n \"bos.config.json\",\n \"bunfig.toml\",\n \"CONTRIBUTING.md\",\n \"package.json\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \".github/renovate.json\",\n \".github/workflows/ci.yml\",\n \".github/workflows/release-sync.yml\",\n \".opencode/skills/everything-dev/SKILL.md\",\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]);\n\ntype PackageJson = Record<string, unknown>;\n\nexport function isFrameworkOwnedSyncFile(filePath: string): boolean {\n return FRAMEWORK_OWNED_SYNC_FILES.has(filePath);\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 createHash(\"sha256\").update(content).digest(\"hex\").substring(0, 16);\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 toDestPath(filePath: string): string {\n return sourcePathToDestinationPath(filePath);\n}\n\nfunction toSourcePath(sourceDir: string, destPath: string): string | null {\n const directPath = join(sourceDir, destPath);\n if (existsSync(directPath)) {\n return destPath;\n }\n\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 return null;\n}\n\nfunction writeSyncedFile(sourceDir: string, projectDir: string, filePath: string): void {\n const src = join(sourceDir, filePath);\n const destPath = 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\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 writeFileSync(dest, `${JSON.stringify(merged, null, 2)}\\n`);\n return;\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 writeFileSync(dest, `${JSON.stringify(merged, null, 2)}\\n`);\n return;\n }\n }\n\n writeFileSync(dest, readFileSync(src));\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 =\n localConfig.plugins && typeof localConfig.plugins === \"object\"\n ? Object.keys(localConfig.plugins as Record<string, unknown>)\n : [];\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\n const filteredFiles = new Set<string>();\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 filteredFiles.add(sourcePath);\n destToSource.set(destPath, sourcePath);\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 sourceContent = readFileSync(join(sourceDir, filePath));\n const sourceHash = createHash(\"sha256\").update(sourceContent).digest(\"hex\").substring(0, 16);\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 if (options.dryRun) {\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);\n }\n }\n\n const newSnapshotFiles: Record<string, string> = {};\n for (const filePath of filteredFiles) {\n const src = join(sourceDir, filePath);\n const content = readFileSync(src);\n newSnapshotFiles[toDestPath(filePath)] = createHash(\"sha256\")\n .update(content)\n .digest(\"hex\")\n .substring(0, 16);\n }\n\n await writeSnapshot(projectDir, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: newSnapshotFiles,\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 (childPlugins.length > 0) overrides.push(\"plugins\");\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 });\n\n const syncedConfig = await loadConfig({ cwd: projectDir });\n if (syncedConfig?.runtime) {\n writeGeneratedInfra(projectDir, syncedConfig.runtime);\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":";;;;;;;;;;;AAoBA,MAAM,6BAA6B,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;CACD,CAAC;AAQF,SAAS,iBAAiB,YAAoB,UAAiC;CAC7E,MAAM,+BAAgB,YAAY,SAAS;AAC3C,KAAI,yBAAY,SAAS,CAAE,QAAO;AAClC,KAAI;EACF,MAAM,oCAAuB,SAAS;AACtC,qCAAkB,SAAS,CAAC,OAAO,QAAQ,CAAC,OAAO,MAAM,CAAC,UAAU,GAAG,GAAG;SACpE;AACN,SAAO;;;AAIX,SAAS,YAAY,YAAoB,WAAoC;CAC3E,MAAM,gBAAgB,UAAU,QAAQ,kDAAsB,YAAY,EAAE,CAAC,CAAC;AAC9E,KAAI,cAAc,WAAW,EAAG,QAAO;CAGvC,MAAM,gCAAiB,YAAY,QAAQ,gCADzB,IAAI,MAAM,EAAC,aAAa,CAAC,QAAQ,SAAS,IACO,CAAC;AAEpE,MAAK,MAAM,YAAY,eAAe;EACpC,MAAM,0BAAW,YAAY,SAAS;EACtC,MAAM,2BAAY,WAAW,SAAS;AACtC,gDAAkB,KAAK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ED
@@ -1,30 +1,34 @@
1
1
  import { isPlainObject, mergeBosConfigWithTemplate, resolveExtendsRef } from "../merge.mjs";
2
2
  import { loadConfig } from "../config.mjs";
3
3
  import { writeGeneratedInfra } from "./infra.mjs";
4
- import { isPathExcluded } from "../utils/path-match.mjs";
5
- import { readSnapshot, writeSnapshot } from "./snapshot.mjs";
6
- import { personalizeConfig, readTemplatekeep, resolveSourceDir, runBunInstall, runTypesGen } from "./init.mjs";
7
- import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
+ import { writeSnapshot } from "./snapshot.mjs";
5
+ import { personalizeConfig, resolveSourceDir, runBunInstall, runTypesGen, sourcePathToDestinationPath } from "./init.mjs";
6
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
8
7
  import { dirname, join } from "node:path";
9
8
  import { createHash } from "node:crypto";
10
- import { glob } from "glob";
11
9
 
12
10
  //#region src/cli/sync.ts
13
11
  const FRAMEWORK_OWNED_SYNC_FILES = new Set([
14
12
  ".env.example",
15
13
  ".gitignore",
14
+ "AGENTS.md",
16
15
  "biome.json",
17
16
  "bos.config.json",
17
+ "bunfig.toml",
18
+ "CONTRIBUTING.md",
18
19
  "package.json",
19
- "docker-compose.yml",
20
+ ".changeset/config.json",
21
+ ".changeset/README.md",
20
22
  ".github/renovate.json",
21
23
  ".github/workflows/ci.yml",
22
24
  ".github/workflows/release-sync.yml",
25
+ ".opencode/skills/everything-dev/SKILL.md",
23
26
  "ui/package.json",
24
27
  "ui/postcss.config.mjs",
25
28
  "ui/rsbuild.config.ts",
26
29
  "ui/tsconfig.json",
27
30
  "ui/src/app.ts",
31
+ "ui/src/globals.d.ts",
28
32
  "ui/src/hydrate.tsx",
29
33
  "ui/src/lib/api.ts",
30
34
  "ui/src/lib/auth.ts",
@@ -38,19 +42,6 @@ const FRAMEWORK_OWNED_SYNC_FILES = new Set([
38
42
  "api/tsconfig.json",
39
43
  "api/src/lib/auth.ts"
40
44
  ]);
41
- function isFrameworkOwnedSyncFile(filePath) {
42
- return FRAMEWORK_OWNED_SYNC_FILES.has(filePath);
43
- }
44
- function readExcludeFile(filePath) {
45
- if (!existsSync(filePath)) return [];
46
- return readFileSync(filePath, "utf-8").split("\n").map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
47
- }
48
- async function readTemplatesyncExclude(sourceDir) {
49
- return readExcludeFile(join(sourceDir, ".templatesync-exclude"));
50
- }
51
- function readLocalSyncExcludes(projectDir) {
52
- return readExcludeFile(join(projectDir, ".bos", "sync-local-exclude"));
53
- }
54
45
  function computeLocalHash(projectDir, filePath) {
55
46
  const fullPath = join(projectDir, filePath);
56
47
  if (!existsSync(fullPath)) return null;
@@ -86,6 +77,10 @@ function mergeWorkspacePackages(local, template) {
86
77
  const ordered = /* @__PURE__ */ new Set();
87
78
  for (const entry of templatePackages) if (typeof entry === "string" && entry.length > 0) ordered.add(entry);
88
79
  for (const entry of localPackages) if (typeof entry === "string" && entry.length > 0) ordered.add(entry);
80
+ if ([...ordered].some((e) => e.startsWith("plugins/") && e !== "plugins/*")) {
81
+ for (const entry of [...ordered]) if (entry.startsWith("plugins/") && entry !== "plugins/*") ordered.delete(entry);
82
+ ordered.add("plugins/*");
83
+ }
89
84
  return ordered.size > 0 ? [...ordered] : void 0;
90
85
  }
91
86
  function mergePackageJson(filePath, local, template) {
@@ -136,7 +131,15 @@ function mergePackageJson(filePath, local, template) {
136
131
  return merged;
137
132
  }
138
133
  function toDestPath(filePath) {
139
- return filePath.startsWith(".github/templates/") ? filePath.replace(/^\.github\/templates\//, ".github/") : filePath;
134
+ return sourcePathToDestinationPath(filePath);
135
+ }
136
+ function toSourcePath(sourceDir, destPath) {
137
+ if (existsSync(join(sourceDir, destPath))) return destPath;
138
+ if (destPath.startsWith(".github/")) {
139
+ const templatePath = destPath.replace(/^\.github\//, ".github/templates/");
140
+ if (existsSync(join(sourceDir, templatePath))) return templatePath;
141
+ }
142
+ return null;
140
143
  }
141
144
  function writeSyncedFile(sourceDir, projectDir, filePath) {
142
145
  const src = join(sourceDir, filePath);
@@ -190,60 +193,25 @@ async function syncTemplate(projectDir, options) {
190
193
  extendsGateway
191
194
  });
192
195
  try {
193
- const patterns = await readTemplatekeep(sourceDir);
194
- if (patterns.length === 0) return {
195
- status: "error",
196
- updated: [],
197
- skipped: [],
198
- added: [],
199
- error: "No .templatekeep found in template source"
200
- };
201
- const parentExcludes = await readTemplatesyncExclude(sourceDir);
202
- const localExcludes = readLocalSyncExcludes(projectDir);
203
- const excludePatterns = [...parentExcludes, ...localExcludes];
204
- const allTemplateFiles = /* @__PURE__ */ new Set();
205
- for (const pattern of patterns) {
206
- const matches = await glob(pattern, {
207
- cwd: sourceDir,
208
- nodir: true,
209
- dot: true,
210
- absolute: false
211
- });
212
- for (const match of matches) allTemplateFiles.add(match);
213
- }
214
196
  const childPlugins = localConfig.plugins && typeof localConfig.plugins === "object" ? Object.keys(localConfig.plugins) : [];
215
- const pluginRoutes = {};
216
- const parentRuntime = await loadConfig({ cwd: sourceDir });
217
- for (const [key, plugin] of Object.entries(parentRuntime?.runtime.plugins ?? {})) if (plugin.routes && plugin.routes.length > 0) pluginRoutes[key] = plugin.routes;
218
- const excludedRoutePatterns = [];
219
- for (const [pluginKey, routePatterns] of Object.entries(pluginRoutes)) if (!childPlugins.includes(pluginKey)) excludedRoutePatterns.push(...routePatterns);
197
+ const withUi = existsSync(join(projectDir, "ui", "package.json"));
198
+ const withApi = existsSync(join(projectDir, "api", "package.json"));
199
+ const withHost = existsSync(join(projectDir, "host", "package.json"));
220
200
  const filteredFiles = /* @__PURE__ */ new Set();
221
- for (const filePath of allTemplateFiles) {
222
- const pluginMatch = filePath.match(/^plugins\/([^/]+)/);
223
- if (pluginMatch && !childPlugins.includes(pluginMatch[1])) continue;
224
- if (isPathExcluded(filePath, excludedRoutePatterns)) continue;
225
- filteredFiles.add(filePath);
226
- }
227
- for (const [pluginKey, routePatterns] of Object.entries(pluginRoutes)) {
228
- if (!childPlugins.includes(pluginKey)) continue;
229
- for (const rp of routePatterns) {
230
- const matches = await glob(rp, {
231
- cwd: sourceDir,
232
- nodir: true,
233
- dot: true,
234
- absolute: false
235
- });
236
- for (const match of matches) if (!isPathExcluded(match, excludedRoutePatterns)) filteredFiles.add(match);
237
- }
201
+ const destToSource = /* @__PURE__ */ new Map();
202
+ for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {
203
+ if (destPath.startsWith("ui/") && !withUi) continue;
204
+ if (destPath.startsWith("api/") && !withApi) continue;
205
+ if (destPath.startsWith("host/") && !withHost) continue;
206
+ const sourcePath = toSourcePath(sourceDir, destPath);
207
+ if (!sourcePath) continue;
208
+ filteredFiles.add(sourcePath);
209
+ destToSource.set(destPath, sourcePath);
238
210
  }
239
- const snapshot = await readSnapshot(projectDir);
240
211
  const updated = [];
241
212
  const skipped = [];
242
213
  const added = [];
243
- for (const filePath of filteredFiles) {
244
- const destPath = toDestPath(filePath);
245
- const frameworkOwned = isFrameworkOwnedSyncFile(destPath);
246
- if (isPathExcluded(destPath, excludePatterns) && !frameworkOwned) continue;
214
+ for (const [destPath, filePath] of destToSource.entries()) {
247
215
  const localHash = computeLocalHash(projectDir, destPath);
248
216
  const sourceContent = readFileSync(join(sourceDir, filePath));
249
217
  const sourceHash = createHash("sha256").update(sourceContent).digest("hex").substring(0, 16);
@@ -251,19 +219,7 @@ async function syncTemplate(projectDir, options) {
251
219
  added.push(destPath);
252
220
  continue;
253
221
  }
254
- if (localHash === sourceHash) continue;
255
- if (frameworkOwned) {
256
- updated.push(destPath);
257
- continue;
258
- }
259
- const snapshotHash = snapshot?.files[destPath];
260
- if (snapshotHash === void 0) {
261
- updated.push(destPath);
262
- continue;
263
- }
264
- if (localHash === snapshotHash) updated.push(destPath);
265
- else if (options.force) updated.push(destPath);
266
- else skipped.push(destPath);
222
+ if (localHash !== sourceHash) updated.push(destPath);
267
223
  }
268
224
  if (options.dryRun) return {
269
225
  status: "dry-run",
@@ -271,37 +227,34 @@ async function syncTemplate(projectDir, options) {
271
227
  skipped,
272
228
  added
273
229
  };
274
- const filesToWrite = [...updated, ...added].filter((f) => isFrameworkOwnedSyncFile(f) || !isPathExcluded(f, excludePatterns));
275
- const destToSource = /* @__PURE__ */ new Map();
276
- for (const filePath of filteredFiles) destToSource.set(toDestPath(filePath), filePath);
230
+ const filesToWrite = [...updated, ...added];
277
231
  if (filesToWrite.length > 0) {
278
232
  backupFiles(projectDir, filesToWrite);
279
233
  for (const destPath of filesToWrite) writeSyncedFile(sourceDir, projectDir, destToSource.get(destPath) ?? destPath);
280
234
  }
281
235
  const newSnapshotFiles = {};
282
236
  for (const filePath of filteredFiles) {
283
- const src = join(sourceDir, filePath);
284
- if (!lstatSync(src).isFile()) continue;
285
- const content = readFileSync(src);
237
+ const content = readFileSync(join(sourceDir, filePath));
286
238
  newSnapshotFiles[toDestPath(filePath)] = createHash("sha256").update(content).digest("hex").substring(0, 16);
287
239
  }
288
240
  await writeSnapshot(projectDir, {
289
241
  parentRef: `bos://${extendsAccount}/${extendsGateway}`,
290
242
  files: newSnapshotFiles
291
243
  });
244
+ const account = localConfig.account || extendsAccount;
245
+ const domain = localConfig.domain || extendsGateway;
246
+ const overrides = [];
247
+ if (withUi) overrides.push("ui");
248
+ if (withApi) overrides.push("api");
249
+ if (withHost) overrides.push("host");
250
+ if (childPlugins.length > 0) overrides.push("plugins");
292
251
  await personalizeConfig(projectDir, {
293
252
  extendsAccount,
294
253
  extendsGateway,
295
- account: localConfig.account || extendsAccount,
296
- domain: localConfig.domain || extendsGateway,
254
+ account,
255
+ domain,
256
+ overrides,
297
257
  plugins: childPlugins,
298
- pluginRoutes,
299
- overrides: [
300
- "ui",
301
- "api",
302
- "host",
303
- "plugins"
304
- ],
305
258
  workspaceOpts: { sourceDir },
306
259
  mode: "sync"
307
260
  });