everything-dev 1.12.4 → 1.14.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 (141) hide show
  1. package/dist/app.cjs +17 -5
  2. package/dist/app.cjs.map +1 -1
  3. package/dist/app.mjs +17 -5
  4. package/dist/app.mjs.map +1 -1
  5. package/dist/cli/init.cjs +151 -74
  6. package/dist/cli/init.cjs.map +1 -1
  7. package/dist/cli/init.d.cts +1 -1
  8. package/dist/cli/init.d.cts.map +1 -1
  9. package/dist/cli/init.d.mts +1 -1
  10. package/dist/cli/init.d.mts.map +1 -1
  11. package/dist/cli/init.mjs +152 -75
  12. package/dist/cli/init.mjs.map +1 -1
  13. package/dist/cli/prompts.cjs +3 -3
  14. package/dist/cli/prompts.cjs.map +1 -1
  15. package/dist/cli/prompts.mjs +3 -3
  16. package/dist/cli/prompts.mjs.map +1 -1
  17. package/dist/cli/status.cjs +22 -0
  18. package/dist/cli/status.cjs.map +1 -1
  19. package/dist/cli/status.mjs +22 -0
  20. package/dist/cli/status.mjs.map +1 -1
  21. package/dist/cli/sync.cjs +15 -56
  22. package/dist/cli/sync.cjs.map +1 -1
  23. package/dist/cli/sync.mjs +15 -56
  24. package/dist/cli/sync.mjs.map +1 -1
  25. package/dist/cli/upgrade.cjs +59 -5
  26. package/dist/cli/upgrade.cjs.map +1 -1
  27. package/dist/cli/upgrade.mjs +59 -5
  28. package/dist/cli/upgrade.mjs.map +1 -1
  29. package/dist/cli.cjs +1 -1
  30. package/dist/cli.cjs.map +1 -1
  31. package/dist/cli.mjs +1 -1
  32. package/dist/cli.mjs.map +1 -1
  33. package/dist/config.cjs +206 -69
  34. package/dist/config.cjs.map +1 -1
  35. package/dist/config.d.cts +13 -6
  36. package/dist/config.d.cts.map +1 -1
  37. package/dist/config.d.mts +13 -6
  38. package/dist/config.d.mts.map +1 -1
  39. package/dist/config.mjs +201 -71
  40. package/dist/config.mjs.map +1 -1
  41. package/dist/contract.d.cts +106 -10
  42. package/dist/contract.d.cts.map +1 -1
  43. package/dist/contract.d.mts +106 -10
  44. package/dist/contract.d.mts.map +1 -1
  45. package/dist/host.cjs +34 -1
  46. package/dist/host.cjs.map +1 -1
  47. package/dist/host.d.cts.map +1 -1
  48. package/dist/host.d.mts.map +1 -1
  49. package/dist/host.mjs +34 -1
  50. package/dist/host.mjs.map +1 -1
  51. package/dist/index.cjs +16 -0
  52. package/dist/index.d.cts +5 -3
  53. package/dist/index.d.mts +5 -3
  54. package/dist/index.mjs +5 -3
  55. package/dist/internal/manifest-normalizer.cjs +14 -1
  56. package/dist/internal/manifest-normalizer.cjs.map +1 -1
  57. package/dist/internal/manifest-normalizer.mjs +14 -1
  58. package/dist/internal/manifest-normalizer.mjs.map +1 -1
  59. package/dist/merge.cjs +113 -0
  60. package/dist/merge.cjs.map +1 -0
  61. package/dist/merge.d.cts +7 -0
  62. package/dist/merge.d.cts.map +1 -0
  63. package/dist/merge.d.mts +7 -0
  64. package/dist/merge.d.mts.map +1 -0
  65. package/dist/merge.mjs +107 -0
  66. package/dist/merge.mjs.map +1 -0
  67. package/dist/orchestrator.d.cts +1 -1
  68. package/dist/orchestrator.d.mts +1 -1
  69. package/dist/plugin.cjs +117 -105
  70. package/dist/plugin.cjs.map +1 -1
  71. package/dist/plugin.d.cts +115 -9
  72. package/dist/plugin.d.cts.map +1 -1
  73. package/dist/plugin.d.mts +115 -9
  74. package/dist/plugin.d.mts.map +1 -1
  75. package/dist/plugin.mjs +117 -105
  76. package/dist/plugin.mjs.map +1 -1
  77. package/dist/service-descriptor.cjs +21 -0
  78. package/dist/service-descriptor.cjs.map +1 -1
  79. package/dist/service-descriptor.d.cts +23 -1
  80. package/dist/service-descriptor.d.cts.map +1 -1
  81. package/dist/service-descriptor.d.mts +23 -1
  82. package/dist/service-descriptor.d.mts.map +1 -1
  83. package/dist/service-descriptor.mjs +21 -0
  84. package/dist/service-descriptor.mjs.map +1 -1
  85. package/dist/shared.cjs +24 -2
  86. package/dist/shared.cjs.map +1 -1
  87. package/dist/shared.d.cts +3 -0
  88. package/dist/shared.d.cts.map +1 -1
  89. package/dist/shared.d.mts +3 -0
  90. package/dist/shared.d.mts.map +1 -1
  91. package/dist/shared.mjs +25 -3
  92. package/dist/shared.mjs.map +1 -1
  93. package/dist/sidebar.cjs +124 -0
  94. package/dist/sidebar.cjs.map +1 -0
  95. package/dist/sidebar.d.cts +8 -0
  96. package/dist/sidebar.d.cts.map +1 -0
  97. package/dist/sidebar.d.mts +8 -0
  98. package/dist/sidebar.d.mts.map +1 -0
  99. package/dist/sidebar.mjs +122 -0
  100. package/dist/sidebar.mjs.map +1 -0
  101. package/dist/types.cjs +104 -10
  102. package/dist/types.cjs.map +1 -1
  103. package/dist/types.d.cts +256 -29
  104. package/dist/types.d.cts.map +1 -1
  105. package/dist/types.d.mts +256 -29
  106. package/dist/types.d.mts.map +1 -1
  107. package/dist/types.mjs +100 -11
  108. package/dist/types.mjs.map +1 -1
  109. package/dist/utils/path-match.cjs +18 -0
  110. package/dist/utils/path-match.cjs.map +1 -0
  111. package/dist/utils/path-match.mjs +17 -0
  112. package/dist/utils/path-match.mjs.map +1 -0
  113. package/dist/utils/save-config.cjs +19 -0
  114. package/dist/utils/save-config.cjs.map +1 -0
  115. package/dist/utils/save-config.mjs +18 -0
  116. package/dist/utils/save-config.mjs.map +1 -0
  117. package/package.json +6 -6
  118. package/skills/dev-workflow/SKILL.md +8 -0
  119. package/skills/extends-config/SKILL.md +132 -0
  120. package/skills/init-upgrade/SKILL.md +128 -0
  121. package/skills/publish-sync/SKILL.md +30 -0
  122. package/src/app.ts +15 -5
  123. package/src/cli/init.ts +207 -108
  124. package/src/cli/prompts.ts +2 -2
  125. package/src/cli/status.ts +20 -0
  126. package/src/cli/sync.ts +27 -96
  127. package/src/cli/upgrade.ts +65 -3
  128. package/src/cli.ts +1 -1
  129. package/src/config.ts +306 -119
  130. package/src/host.ts +45 -0
  131. package/src/index.ts +1 -0
  132. package/src/internal/manifest-normalizer.ts +16 -4
  133. package/src/merge.ts +198 -0
  134. package/src/plugin.ts +340 -318
  135. package/src/service-descriptor.ts +23 -0
  136. package/src/shared.ts +48 -5
  137. package/src/sidebar.ts +162 -0
  138. package/src/types.ts +134 -28
  139. package/src/utils/path-match.ts +16 -0
  140. package/src/utils/save-config.ts +20 -0
  141. package/cli.js +0 -10
@@ -1 +1 @@
1
- {"version":3,"file":"init.mjs","names":[],"sources":["../../src/cli/init.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport {\n createWriteStream,\n existsSync,\n lstatSync,\n mkdirSync,\n readFileSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { glob } from \"glob\";\nimport { fetchBosConfigFromFastKv } from \"../fastkv\";\nimport {\n loadManifestNormalizationSpec,\n normalizePackageManifestsInTree,\n} from \"../internal/manifest-normalizer\";\nimport type { BosConfig } from \"../types\";\nimport { writeSnapshot } from \"./snapshot\";\n\nconst require = createRequire(import.meta.url);\n\nconst BOS_CONFIG_ORDER = [\n \"extends\",\n \"account\",\n \"domain\",\n \"testnet\",\n \"staging\",\n \"repository\",\n \"app\",\n \"plugins\",\n \"shared\",\n];\n\nfunction rebuildOrderedConfig(config: Record<string, unknown>): Record<string, unknown> {\n const ordered: Record<string, unknown> = {};\n\n for (const key of BOS_CONFIG_ORDER) {\n if (key in config) {\n ordered[key] = config[key];\n }\n }\n\n for (const key of Object.keys(config)) {\n if (!BOS_CONFIG_ORDER.includes(key)) {\n ordered[key] = config[key];\n }\n }\n\n return ordered;\n}\n\ninterface SourceResult {\n sourceDir: string;\n parentConfig: BosConfig;\n cleanup: () => Promise<void>;\n}\n\nexport async function resolveSourceDir(opts: {\n extendsAccount: string;\n extendsGateway: string;\n source?: string;\n}): Promise<SourceResult> {\n if (opts.source) {\n const sourceDir = resolve(opts.source);\n if (!existsSync(join(sourceDir, \"bos.config.json\"))) {\n throw new Error(`No bos.config.json found in source directory: ${sourceDir}`);\n }\n const parentConfig = JSON.parse(\n readFileSync(join(sourceDir, \"bos.config.json\"), \"utf-8\"),\n ) as BosConfig;\n return { sourceDir, parentConfig, cleanup: async () => {} };\n }\n\n const parentConfig = await fetchParentConfig(opts.extendsAccount, opts.extendsGateway);\n\n if (!parentConfig.repository) {\n throw new Error(\"Parent config has no repository field — cannot locate template source\");\n }\n\n const { dir: sourceDir, cleanup } = await downloadTarball(parentConfig.repository);\n return { sourceDir, parentConfig, cleanup };\n}\n\nexport async function fetchParentConfig(\n extendsAccount: string,\n extendsGateway: string,\n): Promise<BosConfig> {\n const bosUrl = `bos://${extendsAccount}/${extendsGateway}`;\n return fetchBosConfigFromFastKv<BosConfig>(bosUrl);\n}\n\nexport async function downloadTarball(\n repoUrl: string,\n): Promise<{ dir: string; cleanup: () => Promise<void> }> {\n const parsed = parseGitHubUrl(repoUrl);\n if (!parsed) {\n throw new Error(`Cannot parse repository URL: ${repoUrl}`);\n }\n\n const { owner, repo, branch } = parsed;\n const tarballUrl = `https://api.github.com/repos/${owner}/${repo}/tarball/${branch}`;\n\n const tmpDir = mkTmpDir(\"bos-init-tarball-\");\n const tarballPath = join(tmpDir, \"source.tar.gz\");\n\n const response = await fetch(tarballUrl, {\n headers: { \"User-Agent\": \"everything-dev\" },\n redirect: \"follow\",\n });\n\n if (!response.ok) {\n rmSync(tmpDir, { recursive: true, force: true });\n throw new Error(`GitHub tarball download failed: ${response.status} ${response.statusText}`);\n }\n\n if (!response.body) {\n rmSync(tmpDir, { recursive: true, force: true });\n throw new Error(\"GitHub tarball download returned empty body\");\n }\n\n const fileStream = createWriteStream(tarballPath);\n const reader = response.body as unknown as NodeJS.ReadableStream;\n await pipeline(reader, fileStream);\n\n const extractDir = mkTmpDir(\"bos-init-extract-\");\n try {\n const tar = require(\"tar\") as {\n extract: (opts: { cwd: string; file: string; strip: number }) => Promise<void>;\n };\n await tar.extract({ cwd: extractDir, file: tarballPath, strip: 1 });\n } catch {\n await execCommand(\"tar\", [\"-xzf\", tarballPath, \"--strip-components=1\", \"-C\", extractDir]);\n }\n\n rmSync(tmpDir, { recursive: true, force: true });\n\n return {\n dir: extractDir,\n cleanup: async () => {\n rmSync(extractDir, { recursive: true, force: true });\n },\n };\n}\n\nfunction parseGitHubUrl(url: string): { owner: string; repo: string; branch: string } | null {\n const httpsMatch = url.match(/^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?(?:\\/.*)?$/);\n if (httpsMatch) {\n return { owner: httpsMatch[1], repo: httpsMatch[2], branch: \"main\" };\n }\n\n const sshMatch = url.match(/^git@github\\.com:([^/]+)\\/([^/]+?)(?:\\.git)?$/);\n if (sshMatch) {\n return { owner: sshMatch[1], repo: sshMatch[2], branch: \"main\" };\n }\n\n return null;\n}\n\nexport async function readTemplatekeep(sourceDir: string): Promise<string[]> {\n const keepFile = join(sourceDir, \".templatekeep\");\n if (!existsSync(keepFile)) {\n return [];\n }\n\n const content = readFileSync(keepFile, \"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 copyFilteredFiles(\n sourceDir: string,\n destination: string,\n patterns: string[],\n options: { withHost: boolean; plugins?: string[]; pluginRoutes?: Record<string, string[]> },\n): Promise<number> {\n if (patterns.length === 0) {\n return 0;\n }\n\n const effectivePatterns = options.withHost\n ? [...patterns, \"host/**\"]\n : patterns.filter((p) => !p.startsWith(\"host/\") && p !== \"host/**\");\n\n const filteredPatterns = effectivePatterns.filter((p) => {\n const pluginMatch = p.match(/^plugins\\/([^/]+)/);\n if (!pluginMatch) return true;\n const pluginName = pluginMatch[1];\n return options.plugins?.includes(pluginName) ?? true;\n });\n\n const excludedRoutePatterns: string[] = [];\n if (options.pluginRoutes) {\n for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) {\n if (!(options.plugins?.includes(pluginKey) ?? true)) {\n excludedRoutePatterns.push(...routePatterns);\n }\n }\n }\n\n const allFiles = new Set<string>();\n for (const pattern of filteredPatterns) {\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 const pluginMatch = match.match(/^plugins\\/([^/]+)/);\n if (pluginMatch) {\n const pluginName = pluginMatch[1];\n if (!(options.plugins?.includes(pluginName) ?? true)) continue;\n }\n if (isRouteExcluded(match, excludedRoutePatterns)) continue;\n allFiles.add(match);\n }\n }\n\n const routeFiles = new Set<string>();\n if (options.pluginRoutes) {\n for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) {\n if (!(options.plugins?.includes(pluginKey) ?? true)) 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 (!isRouteExcluded(match, excludedRoutePatterns)) {\n routeFiles.add(match);\n }\n }\n }\n }\n }\n\n for (const f of routeFiles) allFiles.add(f);\n\n mkdirSync(destination, { recursive: true });\n\n let count = 0;\n for (const filePath of allFiles) {\n const src = join(sourceDir, filePath);\n const stat = lstatSync(src);\n if (!stat.isFile()) continue;\n\n const destPath = filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath;\n const dest = join(destination, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n const content = readFileSync(src);\n writeFileSync(dest, content);\n count++;\n }\n\n return count;\n}\n\nfunction isRouteExcluded(filePath: string, excludedPatterns: string[]): boolean {\n if (excludedPatterns.length === 0) return false;\n for (const pattern of excludedPatterns) {\n if (pattern.endsWith(\"/**\")) {\n const prefix = pattern.slice(0, -3);\n if (filePath.startsWith(`${prefix}/`) || filePath === prefix) return true;\n } else if (filePath === pattern || filePath.startsWith(`${pattern}/`)) {\n return true;\n }\n }\n return false;\n}\n\nexport async function personalizeConfig(\n destination: string,\n opts: {\n extendsAccount: string;\n extendsGateway: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n pluginRoutes?: Record<string, string[]>;\n workspaceOpts?: { localOverrides?: boolean; sourceDir?: string };\n mode?: \"init\" | \"sync\";\n withHost?: boolean;\n },\n): Promise<void> {\n const isInit = opts.mode !== \"sync\";\n const configPath = join(destination, \"bos.config.json\");\n if (existsSync(configPath)) {\n const config = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\n\n config.extends = `bos://${opts.extendsAccount}/${opts.extendsGateway}`;\n\n if (opts.account) {\n config.account = opts.account;\n }\n if (opts.domain) {\n config.domain = opts.domain;\n }\n\n if (isInit && config.app && typeof config.app === \"object\") {\n const app = config.app as Record<string, unknown>;\n\n for (const entryKey of Object.keys(app)) {\n const entry = app[entryKey];\n if (entry && typeof entry === \"object\") {\n const e = entry as Record<string, unknown>;\n delete e.production;\n delete e.integrity;\n delete e.ssr;\n delete e.ssrIntegrity;\n }\n }\n }\n\n if (config.plugins && typeof config.plugins === \"object\") {\n const plugins = config.plugins as Record<string, unknown>;\n\n if (opts.plugins && opts.plugins.length > 0) {\n for (const pluginKey of Object.keys(plugins)) {\n if (!opts.plugins.includes(pluginKey)) {\n delete plugins[pluginKey];\n }\n }\n }\n\n if (isInit) {\n for (const pluginKey of Object.keys(plugins)) {\n const plugin = plugins[pluginKey];\n if (plugin && typeof plugin === \"object\") {\n const p = plugin as Record<string, unknown>;\n delete p.production;\n delete p.integrity;\n }\n }\n }\n\n if (Object.keys(plugins).length === 0) {\n config.plugins = {};\n }\n }\n\n writeFileSync(configPath, `${JSON.stringify(rebuildOrderedConfig(config), null, 2)}\\n`);\n }\n\n const pkgPath = join(destination, \"package.json\");\n if (existsSync(pkgPath)) {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as Record<string, unknown>;\n\n if (pkg.workspaces && typeof pkg.workspaces === \"object\") {\n const ws = pkg.workspaces as { packages?: string[] };\n if (Array.isArray(ws.packages)) {\n ws.packages = ws.packages.filter((p: string) => {\n if (p.startsWith(\"packages/\")) return false;\n if (p === \"host\") return opts.withHost ?? false;\n if (p === \"plugins/*\") return (opts.plugins?.length ?? 0) > 0;\n const pluginMatch = p.match(/^plugins\\/([^/]+)/);\n if (pluginMatch) return opts.plugins?.includes(pluginMatch[1]) ?? true;\n return true;\n });\n }\n }\n\n if (pkg.scripts && typeof pkg.scripts === \"object\") {\n const scripts = pkg.scripts as Record<string, string>;\n const rewrite = (key: string, from: string, to: string) => {\n if (scripts[key]?.includes(from)) {\n scripts[key] = scripts[key].replaceAll(from, to);\n }\n };\n rewrite(\"dev\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"dev:ui\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"dev:api\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"dev:proxy\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"build\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"deploy\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"publish\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n rewrite(\"start\", \"packages/everything-dev/cli.js\", \"node_modules/.bin/bos\");\n\n scripts.postinstall = \"node_modules/.bin/bos types gen || true\";\n scripts[\"types:gen\"] = \"node_modules/.bin/bos types gen\";\n if (scripts.typecheck) {\n scripts.typecheck = scripts.typecheck\n .replace(\"bun run types:gen && \", \"\")\n .replace(/bun run --cwd packages\\/everything-dev typecheck & ?/, \"\");\n if (!opts.withHost) {\n scripts.typecheck = scripts.typecheck.replace(/bun run --cwd host tsc --noEmit & ?/, \"\");\n }\n }\n }\n\n if (pkg.devDependencies && typeof pkg.devDependencies === \"object\") {\n const deps = pkg.devDependencies as Record<string, string>;\n delete deps[\"every-plugin\"];\n delete deps[\"everything-dev\"];\n }\n\n if (!pkg.workspaces || typeof pkg.workspaces !== \"object\") {\n pkg.workspaces = { packages: [], catalog: {} };\n }\n const workspaces = pkg.workspaces as { packages?: string[]; catalog?: Record<string, string> };\n if (!workspaces.catalog || typeof workspaces.catalog !== \"object\") {\n workspaces.catalog = {};\n }\n\n if (!pkg.dependencies) pkg.dependencies = {};\n const deps = pkg.dependencies as Record<string, string>;\n const spec = opts.workspaceOpts?.sourceDir\n ? loadManifestNormalizationSpec(opts.workspaceOpts.sourceDir)\n : null;\n if (spec) {\n workspaces.catalog[\"everything-dev\"] = spec.rootCatalog[\"everything-dev\"];\n workspaces.catalog[\"every-plugin\"] = spec.rootCatalog[\"every-plugin\"];\n }\n if (!deps[\"everything-dev\"] && spec) deps[\"everything-dev\"] = \"catalog:\";\n if (!deps[\"every-plugin\"] && spec) deps[\"every-plugin\"] = \"catalog:\";\n\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n const apiTsConfigPath = join(destination, \"api\", \"tsconfig.json\");\n if (existsSync(apiTsConfigPath)) {\n const apiTsConfig = JSON.parse(readFileSync(apiTsConfigPath, \"utf-8\")) as {\n files?: string[];\n [key: string]: unknown;\n };\n if (apiTsConfig.files) {\n const validFiles = apiTsConfig.files.filter((f) => existsSync(join(destination, \"api\", f)));\n if (validFiles.length !== apiTsConfig.files.length) {\n if (validFiles.length === 0) {\n delete apiTsConfig.files;\n } else {\n apiTsConfig.files = validFiles;\n }\n writeFileSync(apiTsConfigPath, `${JSON.stringify(apiTsConfig, null, 2)}\\n`);\n }\n }\n }\n\n await resolveWorkspaceRefs(destination, opts.workspaceOpts);\n\n const genContractPath = join(destination, \"ui\", \"src\", \"lib\", \"api-types.gen.ts\");\n if (!existsSync(genContractPath)) {\n mkdirSync(dirname(genContractPath), { recursive: true });\n writeFileSync(genContractPath, `export type ApiContract = Record<string, never>;\\n`);\n }\n\n const pluginsClientGenPath = join(destination, \"api\", \"src\", \"lib\", \"plugins-types.gen.ts\");\n if (!existsSync(pluginsClientGenPath)) {\n mkdirSync(dirname(pluginsClientGenPath), { recursive: true });\n writeFileSync(\n pluginsClientGenPath,\n `import type { ContractRouterClient, AnyContractRouter } from \"@orpc/contract\";\\ntype ClientFactory<C extends AnyContractRouter> = (context?: Record<string, unknown>) => ContractRouterClient<C>;\\nexport type PluginsClient = Record<string, never>;\\n`,\n );\n }\n\n const authTypesGenPath = join(destination, \"ui\", \"src\", \"lib\", \"auth-types.gen.ts\");\n if (!existsSync(authTypesGenPath)) {\n mkdirSync(dirname(authTypesGenPath), { recursive: true });\n writeFileSync(\n authTypesGenPath,\n `import type { Auth } from \"better-auth\";\\nexport type { Auth } from \"better-auth\";\\nexport type AuthSessionUser = NonNullable<Auth[\"$Infer\"][\"Session\"][\"user\"]> & {\\n role?: string | null;\\n isAnonymous?: boolean | null;\\n walletAddress?: string | null;\\n banned?: boolean | null;\\n};\\nexport type AuthSessionData = NonNullable<Auth[\"$Infer\"][\"Session\"][\"session\"]> & {\\n activeOrganizationId?: string | null;\\n};\\nexport type AuthSession = {\\n user: AuthSessionUser | null;\\n session: AuthSessionData | null;\\n};\\nexport interface AuthOrganizationContext {\\n activeOrganizationId: string | null;\\n organization: { id: string; name: string; slug: string; logo?: string | null; metadata?: Record<string, unknown> } | null;\\n member: { id: string; role: string } | null;\\n isPersonal: boolean;\\n hasOrganization: boolean;\\n}\\nexport interface AuthRequestContext {\\n user: AuthSessionUser | null;\\n userId: string | null;\\n isAuthenticated: boolean;\\n authMethod: \"session\" | \"apiKey\" | \"anonymous\" | \"none\";\\n near: {\\n primaryAccountId: string | null;\\n linkedAccounts: Array<{ accountId: string; network: string; publicKey: string; isPrimary: boolean }>;\\n hasNearAccount: boolean;\\n };\\n organization: AuthOrganizationContext;\\n organizations?: Array<{ id: string; role: string; name?: string; slug?: string }>;\\n}\\nexport type AuthActiveMember = { id: string | null; role: string | null; organizationId: string | null };\\nexport type AuthOrganization = NonNullable<AuthOrganizationContext[\"organization\"]>;\\nexport type AuthOrganizationMember = NonNullable<AuthOrganizationContext[\"member\"]>;\\nexport type AuthOrganizationSummary = NonNullable<AuthRequestContext[\"organizations\"]>[number];\\nexport type AuthBaseSession = Auth[\"$Infer\"][\"Session\"];\\nexport type createAuthInstance = never;\\nexport interface AuthServices {\\n auth: Auth;\\n db: unknown;\\n driver: { close(): Promise<void> };\\n handler: (req: Request) => Promise<Response>;\\n}\\n`,\n );\n }\n\n const apiAuthTypesGenPath = join(destination, \"api\", \"src\", \"lib\", \"auth-types.gen.ts\");\n if (!existsSync(apiAuthTypesGenPath)) {\n mkdirSync(dirname(apiAuthTypesGenPath), { recursive: true });\n writeFileSync(\n apiAuthTypesGenPath,\n `import type { Auth } from \"better-auth\";\\nexport type { Auth } from \"better-auth\";\\nexport type AuthSessionUser = NonNullable<Auth[\"$Infer\"][\"Session\"][\"user\"]> & {\\n role?: string | null;\\n isAnonymous?: boolean | null;\\n walletAddress?: string | null;\\n banned?: boolean | null;\\n};\\nexport type AuthSessionData = NonNullable<Auth[\"$Infer\"][\"Session\"][\"session\"]> & {\\n activeOrganizationId?: string | null;\\n};\\nexport type AuthSession = {\\n user: AuthSessionUser | null;\\n session: AuthSessionData | null;\\n};\\nexport interface AuthOrganizationContext {\\n activeOrganizationId: string | null;\\n organization: { id: string; name: string; slug: string; logo?: string | null; metadata?: Record<string, unknown> } | null;\\n member: { id: string; role: string } | null;\\n isPersonal: boolean;\\n hasOrganization: boolean;\\n}\\nexport interface AuthRequestContext {\\n user: AuthSessionUser | null;\\n userId: string | null;\\n isAuthenticated: boolean;\\n authMethod: \"session\" | \"apiKey\" | \"anonymous\" | \"none\";\\n near: {\\n primaryAccountId: string | null;\\n linkedAccounts: Array<{ accountId: string; network: string; publicKey: string; isPrimary: boolean }>;\\n hasNearAccount: boolean;\\n };\\n organization: AuthOrganizationContext;\\n organizations?: Array<{ id: string; role: string; name?: string; slug?: string }>;\\n}\\nexport type AuthActiveMember = { id: string | null; role: string | null; organizationId: string | null };\\nexport type AuthOrganization = NonNullable<AuthOrganizationContext[\"organization\"]>;\\nexport type AuthOrganizationMember = NonNullable<AuthOrganizationContext[\"member\"]>;\\nexport type AuthOrganizationSummary = NonNullable<AuthRequestContext[\"organizations\"]>[number];\\nexport type AuthBaseSession = Auth[\"$Infer\"][\"Session\"];\\nexport type createAuthInstance = never;\\nexport interface AuthServices {\\n auth: Auth;\\n db: unknown;\\n driver: { close(): Promise<void> };\\n handler: (req: Request) => Promise<Response>;\\n}\\n`,\n );\n }\n\n const hostAuthTypesGenPath = join(destination, \"host\", \"src\", \"lib\", \"auth-types.gen.ts\");\n if (existsSync(join(destination, \"host\", \"src\")) && !existsSync(hostAuthTypesGenPath)) {\n mkdirSync(dirname(hostAuthTypesGenPath), { recursive: true });\n writeFileSync(\n hostAuthTypesGenPath,\n `import type { Auth } from \"better-auth\";\\nexport type { Auth } from \"better-auth\";\\nexport type AuthSessionUser = NonNullable<Auth[\"$Infer\"][\"Session\"][\"user\"]> & {\\n role?: string | null;\\n isAnonymous?: boolean | null;\\n walletAddress?: string | null;\\n banned?: boolean | null;\\n};\\nexport type AuthSessionData = NonNullable<Auth[\"$Infer\"][\"Session\"][\"session\"]> & {\\n activeOrganizationId?: string | null;\\n};\\nexport type AuthSession = {\\n user: AuthSessionUser | null;\\n session: AuthSessionData | null;\\n};\\nexport interface AuthOrganizationContext {\\n activeOrganizationId: string | null;\\n organization: { id: string; name: string; slug: string; logo?: string | null; metadata?: Record<string, unknown> } | null;\\n member: { id: string; role: string } | null;\\n isPersonal: boolean;\\n hasOrganization: boolean;\\n}\\nexport interface AuthRequestContext {\\n user: AuthSessionUser | null;\\n userId: string | null;\\n isAuthenticated: boolean;\\n authMethod: \"session\" | \"apiKey\" | \"anonymous\" | \"none\";\\n near: {\\n primaryAccountId: string | null;\\n linkedAccounts: Array<{ accountId: string; network: string; publicKey: string; isPrimary: boolean }>;\\n hasNearAccount: boolean;\\n };\\n organization: AuthOrganizationContext;\\n organizations?: Array<{ id: string; role: string; name?: string; slug?: string }>;\\n}\\nexport type AuthActiveMember = { id: string | null; role: string | null; organizationId: string | null };\\nexport type AuthOrganization = NonNullable<AuthOrganizationContext[\"organization\"]>;\\nexport type AuthOrganizationMember = NonNullable<AuthOrganizationContext[\"member\"]>;\\nexport type AuthOrganizationSummary = NonNullable<AuthRequestContext[\"organizations\"]>[number];\\nexport type AuthBaseSession = Auth[\"$Infer\"][\"Session\"];\\nexport type createAuthInstance = never;\\nexport interface AuthServices {\\n auth: Auth;\\n db: unknown;\\n driver: { close(): Promise<void> };\\n handler: (req: Request) => Promise<Response>;\\n}\\n`,\n );\n }\n}\n\nexport async function runBunInstall(destination: string): Promise<void> {\n await execCommand(\"bun\", [\"install\", \"--ignore-scripts\"], destination);\n}\n\nexport async function runTypesGen(destination: string): Promise<void> {\n await execCommand(\"node_modules/.bin/bos\", [\"types\", \"gen\"], destination);\n}\n\nconst WORKSPACE_LOCAL_PATHS: Record<string, string> = {\n \"everything-dev\": \"packages/everything-dev\",\n \"every-plugin\": \"packages/every-plugin\",\n};\n\nasync function resolveWorkspaceRefs(\n destination: string,\n options?: { localOverrides?: boolean; sourceDir?: string },\n): Promise<void> {\n await normalizePackageManifestsInTree({\n sourceRootDir: options?.sourceDir ?? destination,\n targetDir: destination,\n resolveCatalogRefs: false,\n preserveCatalogRefs: true,\n removeWorkspaceDeps: [\"host\"],\n });\n\n if (options?.localOverrides && options.sourceDir) {\n const rootPkgPath = join(destination, \"package.json\");\n if (existsSync(rootPkgPath)) {\n const pkg = JSON.parse(readFileSync(rootPkgPath, \"utf-8\")) as Record<string, unknown>;\n if (!pkg.overrides) pkg.overrides = {};\n const overrides = pkg.overrides as Record<string, string>;\n\n const rootWorkspaces = ((pkg.workspaces as Record<string, string[]>)?.packages ?? []).filter(\n Boolean,\n );\n\n for (const [name, relPath] of Object.entries(WORKSPACE_LOCAL_PATHS)) {\n if (!rootWorkspaces.some((ws) => ws === relPath || ws === `plugins/${name}`)) {\n const srcPkgPath = join(options.sourceDir, relPath, \"package.json\");\n if (existsSync(srcPkgPath)) {\n overrides[name] = `file:${relPath}`;\n rootWorkspaces.push(relPath);\n }\n }\n }\n\n if (rootWorkspaces.length > 0) {\n if (!pkg.workspaces) pkg.workspaces = {};\n (pkg.workspaces as Record<string, string[]>).packages = rootWorkspaces;\n }\n\n writeFileSync(rootPkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n }\n}\n\nexport async function writeInitSnapshot(\n destination: string,\n extendsAccount: string,\n extendsGateway: string,\n sourceDir: string,\n patterns: string[],\n options: { withHost: boolean; plugins?: string[]; pluginRoutes?: Record<string, string[]> },\n): Promise<void> {\n const effectivePatterns = options.withHost\n ? [...patterns, \"host/**\"]\n : patterns.filter((p) => !p.startsWith(\"host/\") && p !== \"host/**\");\n\n const excludedRoutePatterns: string[] = [];\n if (options.pluginRoutes) {\n for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) {\n if (!(options.plugins?.includes(pluginKey) ?? true)) {\n excludedRoutePatterns.push(...routePatterns);\n }\n }\n }\n\n const allFiles = new Set<string>();\n for (const pattern of effectivePatterns) {\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 const pluginMatch = match.match(/^plugins\\/([^/]+)/);\n if (pluginMatch && !(options.plugins?.includes(pluginMatch[1]) ?? true)) continue;\n if (isRouteExcluded(match, excludedRoutePatterns)) continue;\n allFiles.add(match);\n }\n }\n\n if (options.pluginRoutes) {\n for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) {\n if (!(options.plugins?.includes(pluginKey) ?? true)) 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 (!isRouteExcluded(match, excludedRoutePatterns)) {\n allFiles.add(match);\n }\n }\n }\n }\n }\n\n const fileHashes: Record<string, string> = {};\n for (const filePath of allFiles) {\n const src = join(sourceDir, filePath);\n const stat = lstatSync(src);\n if (!stat.isFile()) continue;\n const content = readFileSync(src);\n const destPath = filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath;\n fileHashes[destPath] = computeHash(content);\n }\n\n await writeSnapshot(destination, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: fileHashes,\n });\n}\n\nfunction computeHash(data: Uint8Array): string {\n return createHash(\"sha256\").update(data).digest(\"hex\").substring(0, 16);\n}\n\nfunction mkTmpDir(prefix: string): string {\n const base = join(tmpdir(), prefix);\n let attempt = 0;\n while (true) {\n const dir = `${base}-${Date.now()}-${attempt}`;\n try {\n mkdirSync(dir, { recursive: true });\n return dir;\n } catch {\n attempt++;\n if (attempt > 10) throw new Error(\"Failed to create temp directory\");\n }\n }\n}\n\nexport async function generateDatabaseMigrations(destination: string): Promise<void> {\n const drizzleConfigs = await glob(\"**/drizzle.config.ts\", {\n cwd: destination,\n nodir: true,\n dot: false,\n absolute: false,\n ignore: [\"**/node_modules/**\"],\n });\n\n for (const configPath of drizzleConfigs) {\n const workspaceDir = dirname(configPath);\n const pkgPath = join(destination, workspaceDir, \"package.json\");\n if (!existsSync(pkgPath)) continue;\n\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as Record<string, unknown>;\n const scripts = pkg.scripts as Record<string, string> | undefined;\n if (!scripts?.[\"db:generate\"]) continue;\n\n const cwd = join(destination, workspaceDir);\n await execCommand(\"bun\", [\"run\", \"db:generate\"], cwd);\n }\n}\n\nexport function execCommand(command: string, args: string[], cwd?: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const child = spawn(command, args, {\n cwd,\n stdio: \"pipe\",\n shell: true,\n });\n let stderr = \"\";\n child.stderr?.on(\"data\", (data: Buffer) => {\n stderr += data.toString();\n });\n child.on(\"close\", (code) => {\n if (code === 0) resolve();\n else\n reject(\n new Error(\n `Command '${command} ${args.join(\" \")}' failed with exit code ${code}: ${stderr}`,\n ),\n );\n });\n child.on(\"error\", reject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B,2BAA2B,aAAoC;CACnF,MAAM,iBAAiB,MAAM,KAAK,wBAAwB;EACxD,KAAK;EACL,OAAO;EACP,KAAK;EACL,UAAU;EACV,QAAQ,CAAC,qBAAqB;EAC/B,CAAC;AAEF,MAAK,MAAM,cAAc,gBAAgB;EACvC,MAAM,eAAe,QAAQ,WAAW;EACxC,MAAM,UAAU,KAAK,aAAa,cAAc,eAAe;AAC/D,MAAI,CAAC,WAAW,QAAQ,CAAE;AAI1B,MAAI,CAFQ,KAAK,MAAM,aAAa,SAAS,QAAQ,CAAC,CAClC,UACL,eAAgB;AAG/B,QAAM,YAAY,OAAO,CAAC,OAAO,cAAc,EADnC,KAAK,aAAa,aAAa,CACU;;;AAIzD,SAAgB,YAAY,SAAiB,MAAgB,KAA6B;AACxF,QAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,QAAQ,MAAM,SAAS,MAAM;GACjC;GACA,OAAO;GACP,OAAO;GACR,CAAC;EACF,IAAI,SAAS;AACb,QAAM,QAAQ,GAAG,SAAS,SAAiB;AACzC,aAAU,KAAK,UAAU;IACzB;AACF,QAAM,GAAG,UAAU,SAAS;AAC1B,OAAI,SAAS,EAAG,UAAS;OAEvB,wBACE,IAAI,MACF,YAAY,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC,0BAA0B,KAAK,IAAI,SAC1E,CACF;IACH;AACF,QAAM,GAAG,SAAS,OAAO;GACzB"}
1
+ {"version":3,"file":"init.mjs","names":[],"sources":["../../src/cli/init.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport {\n createWriteStream,\n existsSync,\n lstatSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { glob } from \"glob\";\nimport { fetchBosConfigFromFastKv } from \"../fastkv\";\nimport {\n loadManifestNormalizationSpec,\n normalizePackageManifestsInTree,\n} from \"../internal/manifest-normalizer\";\nimport type { BosConfig } from \"../types\";\nimport { isPathExcluded } from \"../utils/path-match\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { writeSnapshot } from \"./snapshot\";\n\nconst require = createRequire(import.meta.url);\n\ninterface SourceResult {\n sourceDir: string;\n parentConfig: BosConfig;\n cleanup: () => Promise<void>;\n}\n\nexport async function resolveSourceDir(opts: {\n extendsAccount: string;\n extendsGateway: string;\n source?: string;\n}): Promise<SourceResult> {\n if (opts.source) {\n const sourceDir = resolve(opts.source);\n if (!existsSync(join(sourceDir, \"bos.config.json\"))) {\n throw new Error(`No bos.config.json found in source directory: ${sourceDir}`);\n }\n const parentConfig = JSON.parse(\n readFileSync(join(sourceDir, \"bos.config.json\"), \"utf-8\"),\n ) as BosConfig;\n return { sourceDir, parentConfig, cleanup: async () => {} };\n }\n\n const parentConfig = await fetchParentConfig(opts.extendsAccount, opts.extendsGateway);\n\n if (!parentConfig.repository) {\n throw new Error(\"Parent config has no repository field — cannot locate template source\");\n }\n\n const { dir: sourceDir, cleanup } = await downloadTarball(parentConfig.repository);\n return { sourceDir, parentConfig, cleanup };\n}\n\nexport async function readTemplatekeep(sourceDir: string): Promise<string[]> {\n const keepFile = join(sourceDir, \".templatekeep\");\n if (!existsSync(keepFile)) {\n return [];\n }\n\n const content = readFileSync(keepFile, \"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 fetchParentConfig(\n extendsAccount: string,\n extendsGateway: string,\n): Promise<BosConfig> {\n const bosUrl = `bos://${extendsAccount}/${extendsGateway}`;\n return fetchBosConfigFromFastKv<BosConfig>(bosUrl);\n}\n\nexport async function downloadTarball(\n repoUrl: string,\n): Promise<{ dir: string; cleanup: () => Promise<void> }> {\n const parsed = parseGitHubUrl(repoUrl);\n if (!parsed) {\n throw new Error(`Cannot parse repository URL: ${repoUrl}`);\n }\n\n const { owner, repo, branch } = parsed;\n const tarballUrl = `https://api.github.com/repos/${owner}/${repo}/tarball/${branch}`;\n\n const tmpDir = mkTmpDir(\"bos-init-tarball-\");\n const tarballPath = join(tmpDir, \"source.tar.gz\");\n\n const response = await fetch(tarballUrl, {\n headers: { \"User-Agent\": \"everything-dev\" },\n redirect: \"follow\",\n });\n\n if (!response.ok) {\n rmSync(tmpDir, { recursive: true, force: true });\n throw new Error(`GitHub tarball download failed: ${response.status} ${response.statusText}`);\n }\n\n if (!response.body) {\n rmSync(tmpDir, { recursive: true, force: true });\n throw new Error(\"GitHub tarball download returned empty body\");\n }\n\n const fileStream = createWriteStream(tarballPath);\n const reader = response.body as unknown as NodeJS.ReadableStream;\n await pipeline(reader, fileStream);\n\n const extractDir = mkTmpDir(\"bos-init-extract-\");\n try {\n const tar = require(\"tar\") as {\n extract: (opts: { cwd: string; file: string; strip: number }) => Promise<void>;\n };\n await tar.extract({ cwd: extractDir, file: tarballPath, strip: 1 });\n } catch {\n await execCommand(\"tar\", [\"-xzf\", tarballPath, \"--strip-components=1\", \"-C\", extractDir]);\n }\n\n rmSync(tmpDir, { recursive: true, force: true });\n\n return {\n dir: extractDir,\n cleanup: async () => {\n rmSync(extractDir, { recursive: true, force: true });\n },\n };\n}\n\nfunction parseGitHubUrl(url: string): { owner: string; repo: string; branch: string } | null {\n const httpsMatch = url.match(/^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?(?:\\/.*)?$/);\n if (httpsMatch) {\n return { owner: httpsMatch[1], repo: httpsMatch[2], branch: \"main\" };\n }\n\n const sshMatch = url.match(/^git@github\\.com:([^/]+)\\/([^/]+?)(?:\\.git)?$/);\n if (sshMatch) {\n return { owner: sshMatch[1], repo: sshMatch[2], branch: \"main\" };\n }\n\n return null;\n}\n\nexport async function copyFilteredFiles(\n sourceDir: string,\n destination: string,\n patterns: string[],\n options: { withHost: boolean; plugins?: string[]; pluginRoutes?: Record<string, string[]> },\n): Promise<number> {\n if (patterns.length === 0) {\n return 0;\n }\n\n const effectivePatterns = options.withHost\n ? [...patterns, \"host/**\"]\n : patterns.filter((p) => !p.startsWith(\"host/\") && p !== \"host/**\");\n\n const filteredPatterns = effectivePatterns.filter((p) => {\n const pluginMatch = p.match(/^plugins\\/([^/]+)/);\n if (!pluginMatch) return true;\n const pluginName = pluginMatch[1];\n return options.plugins?.includes(pluginName) ?? true;\n });\n\n const excludedRoutePatterns: string[] = [];\n if (options.pluginRoutes) {\n for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) {\n if (!(options.plugins?.includes(pluginKey) ?? true)) {\n excludedRoutePatterns.push(...routePatterns);\n }\n }\n }\n\n const allFiles = new Set<string>();\n for (const pattern of filteredPatterns) {\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 const pluginMatch = match.match(/^plugins\\/([^/]+)/);\n if (pluginMatch) {\n const pluginName = pluginMatch[1];\n if (!(options.plugins?.includes(pluginName) ?? true)) continue;\n }\n if (isPathExcluded(match, excludedRoutePatterns)) continue;\n allFiles.add(match);\n }\n }\n\n const routeFiles = new Set<string>();\n if (options.pluginRoutes) {\n for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) {\n if (!(options.plugins?.includes(pluginKey) ?? true)) 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 routeFiles.add(match);\n }\n }\n }\n }\n }\n\n for (const f of routeFiles) allFiles.add(f);\n\n mkdirSync(destination, { recursive: true });\n\n let count = 0;\n for (const filePath of allFiles) {\n const src = join(sourceDir, filePath);\n const stat = lstatSync(src);\n if (!stat.isFile()) continue;\n\n const destPath = filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath;\n const dest = join(destination, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n const content = readFileSync(src);\n writeFileSync(dest, content);\n count++;\n }\n\n return count;\n}\n\nexport async function personalizeConfig(\n destination: string,\n opts: {\n extendsAccount: string;\n extendsGateway: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n pluginRoutes?: Record<string, string[]>;\n workspaceOpts?: { localOverrides?: boolean; sourceDir?: string };\n mode?: \"init\" | \"sync\";\n withHost?: boolean;\n },\n): Promise<void> {\n const isInit = opts.mode !== \"sync\";\n const configPath = join(destination, \"bos.config.json\");\n if (existsSync(configPath)) {\n const config = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\n\n config.extends = `bos://${opts.extendsAccount}/${opts.extendsGateway}`;\n\n if (opts.account) {\n config.account = opts.account;\n }\n if (opts.domain) {\n config.domain = opts.domain;\n }\n\n if (isInit && config.app && typeof config.app === \"object\") {\n const app = config.app as Record<string, unknown>;\n\n for (const entryKey of Object.keys(app)) {\n const entry = app[entryKey];\n if (entry && typeof entry === \"object\") {\n const e = entry as Record<string, unknown>;\n delete e.production;\n delete e.integrity;\n delete e.ssr;\n delete e.ssrIntegrity;\n }\n }\n }\n\n if (config.plugins && typeof config.plugins === \"object\") {\n const plugins = config.plugins as Record<string, unknown>;\n\n if (opts.plugins && opts.plugins.length > 0) {\n for (const pluginKey of Object.keys(plugins)) {\n if (!opts.plugins.includes(pluginKey)) {\n delete plugins[pluginKey];\n }\n }\n }\n\n if (isInit) {\n const parentDomain = opts.extendsGateway;\n\n for (const pluginKey of Object.keys(plugins)) {\n const plugin = plugins[pluginKey];\n let pluginObj: Record<string, unknown>;\n\n if (typeof plugin === \"string\") {\n pluginObj = { extends: plugin };\n plugins[pluginKey] = pluginObj;\n } else if (plugin && typeof plugin === \"object\") {\n pluginObj = { ...(plugin as Record<string, unknown>) };\n } else {\n continue;\n }\n\n if (\n pluginObj.development &&\n typeof pluginObj.development === \"string\" &&\n pluginObj.development.startsWith(\"local:\")\n ) {\n const pluginDir = join(destination, pluginObj.development.slice(\"local:\".length));\n const pluginConfigPath = join(pluginDir, \"bos.config.json\");\n\n if (existsSync(pluginConfigPath)) {\n try {\n const pluginConfig = JSON.parse(readFileSync(pluginConfigPath, \"utf-8\")) as Record<\n string,\n unknown\n >;\n delete pluginConfig.extends;\n if (pluginConfig.app && typeof pluginConfig.app === \"object\") {\n const app = pluginConfig.app as Record<string, unknown>;\n for (const entryKey of Object.keys(app)) {\n const entry = app[entryKey];\n if (entry && typeof entry === \"object\") {\n const e = entry as Record<string, unknown>;\n delete e.production;\n delete e.integrity;\n }\n }\n }\n writeFileSync(pluginConfigPath, `${JSON.stringify(pluginConfig, null, 2)}\\n`);\n } catch {}\n } else if (existsSync(pluginDir)) {\n const pluginConfig: Record<string, unknown> = {};\n pluginConfig.domain = `${pluginKey}.${opts.domain ?? parentDomain}`;\n pluginConfig.app = { api: { development: \"local:.\" } };\n\n if (opts.pluginRoutes?.[pluginKey]) {\n pluginConfig.routes = opts.pluginRoutes[pluginKey];\n }\n if (pluginObj.sidebar) {\n pluginConfig.sidebar = pluginObj.sidebar;\n }\n\n mkdirSync(pluginDir, { recursive: true });\n writeFileSync(pluginConfigPath, `${JSON.stringify(pluginConfig, null, 2)}\\n`);\n }\n\n const cleanEntry: Record<string, unknown> = { development: pluginObj.development };\n if (pluginObj.extends) {\n cleanEntry.extends = pluginObj.extends;\n }\n if (pluginObj.secrets) {\n cleanEntry.secrets = pluginObj.secrets;\n }\n if (pluginObj.variables) {\n cleanEntry.variables = pluginObj.variables;\n }\n plugins[pluginKey] = cleanEntry;\n } else {\n delete pluginObj.production;\n delete pluginObj.integrity;\n delete pluginObj.sidebar;\n delete pluginObj.routes;\n }\n }\n } else {\n for (const pluginKey of Object.keys(plugins)) {\n const pluginDir = resolve(\n destination,\n (plugins[pluginKey] as Record<string, unknown>)?.development\n ?.toString()\n ?.slice(\"local:\".length) ?? \"\",\n );\n const pluginConfigPath = join(pluginDir, \"bos.config.json\");\n if (!existsSync(pluginConfigPath)) continue;\n\n try {\n const pluginConfig = JSON.parse(readFileSync(pluginConfigPath, \"utf-8\")) as Record<\n string,\n unknown\n >;\n let changed = false;\n\n if (\"extends\" in pluginConfig) {\n delete pluginConfig.extends;\n changed = true;\n }\n if (pluginConfig.app && typeof pluginConfig.app === \"object\") {\n const app = pluginConfig.app as Record<string, unknown>;\n for (const entryKey of Object.keys(app)) {\n const entry = app[entryKey];\n if (entry && typeof entry === \"object\") {\n const e = entry as Record<string, unknown>;\n if (\"production\" in e || \"integrity\" in e) {\n delete e.production;\n delete e.integrity;\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n writeFileSync(pluginConfigPath, `${JSON.stringify(pluginConfig, null, 2)}\\n`);\n }\n } catch {}\n }\n }\n\n if (Object.keys(plugins).length === 0) {\n config.plugins = {};\n }\n }\n\n await saveBosConfig(destination, config);\n }\n\n const pkgPath = join(destination, \"package.json\");\n if (existsSync(pkgPath)) {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as Record<string, unknown>;\n\n if (pkg.workspaces && typeof pkg.workspaces === \"object\") {\n const ws = pkg.workspaces as { packages?: string[] };\n if (Array.isArray(ws.packages)) {\n ws.packages = ws.packages.filter((p: string) => {\n if (p.startsWith(\"packages/\")) return false;\n if (p === \"host\") return opts.withHost ?? false;\n if (p === \"plugins/*\") return (opts.plugins?.length ?? 0) > 0;\n const pluginMatch = p.match(/^plugins\\/([^/]+)/);\n if (pluginMatch) return opts.plugins?.includes(pluginMatch[1]) ?? true;\n return true;\n });\n }\n }\n\n if (pkg.scripts && typeof pkg.scripts === \"object\") {\n const scripts = pkg.scripts as Record<string, string>;\n const rewrite = (key: string, from: string, to: string) => {\n if (scripts[key]?.includes(from)) {\n scripts[key] = scripts[key].replaceAll(from, to);\n }\n };\n rewrite(\"dev\", \"packages/everything-dev/src/cli.ts\", \"node_modules/.bin/bos\");\n rewrite(\"dev:ui\", \"packages/everything-dev/src/cli.ts\", \"node_modules/.bin/bos\");\n rewrite(\"dev:api\", \"packages/everything-dev/src/cli.ts\", \"node_modules/.bin/bos\");\n rewrite(\"dev:proxy\", \"packages/everything-dev/src/cli.ts\", \"node_modules/.bin/bos\");\n rewrite(\"build\", \"packages/everything-dev/src/cli.ts\", \"node_modules/.bin/bos\");\n rewrite(\"deploy\", \"packages/everything-dev/src/cli.ts\", \"node_modules/.bin/bos\");\n rewrite(\"publish\", \"packages/everything-dev/src/cli.ts\", \"node_modules/.bin/bos\");\n rewrite(\"start\", \"packages/everything-dev/src/cli.ts\", \"node_modules/.bin/bos\");\n\n scripts.postinstall = \"node_modules/.bin/bos types gen || true\";\n scripts[\"types:gen\"] = \"node_modules/.bin/bos types gen\";\n if (scripts.typecheck) {\n scripts.typecheck = scripts.typecheck\n .replace(\"bun run types:gen && \", \"\")\n .replace(/bun run --cwd packages\\/everything-dev typecheck & ?/, \"\");\n if (!opts.withHost) {\n scripts.typecheck = scripts.typecheck.replace(/bun run --cwd host tsc --noEmit & ?/, \"\");\n }\n }\n }\n\n if (pkg.devDependencies && typeof pkg.devDependencies === \"object\") {\n const deps = pkg.devDependencies as Record<string, string>;\n delete deps[\"every-plugin\"];\n delete deps[\"everything-dev\"];\n }\n\n if (!pkg.workspaces || typeof pkg.workspaces !== \"object\") {\n pkg.workspaces = { packages: [], catalog: {} };\n }\n const workspaces = pkg.workspaces as { packages?: string[]; catalog?: Record<string, string> };\n if (!workspaces.catalog || typeof workspaces.catalog !== \"object\") {\n workspaces.catalog = {};\n }\n\n if (!pkg.dependencies) pkg.dependencies = {};\n const deps = pkg.dependencies as Record<string, string>;\n const spec = opts.workspaceOpts?.sourceDir\n ? loadManifestNormalizationSpec(opts.workspaceOpts.sourceDir)\n : null;\n if (spec) {\n workspaces.catalog[\"everything-dev\"] = spec.rootCatalog[\"everything-dev\"];\n workspaces.catalog[\"every-plugin\"] = spec.rootCatalog[\"every-plugin\"];\n }\n if (!deps[\"everything-dev\"] && spec) deps[\"everything-dev\"] = \"catalog:\";\n if (!deps[\"every-plugin\"] && spec) deps[\"every-plugin\"] = \"catalog:\";\n\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n const apiTsConfigPath = join(destination, \"api\", \"tsconfig.json\");\n if (existsSync(apiTsConfigPath)) {\n const apiTsConfig = JSON.parse(readFileSync(apiTsConfigPath, \"utf-8\")) as {\n files?: string[];\n [key: string]: unknown;\n };\n if (apiTsConfig.files) {\n const validFiles = apiTsConfig.files.filter((f) => existsSync(join(destination, \"api\", f)));\n if (validFiles.length !== apiTsConfig.files.length) {\n if (validFiles.length === 0) {\n delete apiTsConfig.files;\n } else {\n apiTsConfig.files = validFiles;\n }\n writeFileSync(apiTsConfigPath, `${JSON.stringify(apiTsConfig, null, 2)}\\n`);\n }\n }\n }\n\n await resolveWorkspaceRefs(destination, opts.workspaceOpts);\n\n const genContractPath = join(destination, \"ui\", \"src\", \"lib\", \"api-types.gen.ts\");\n if (!existsSync(genContractPath)) {\n mkdirSync(dirname(genContractPath), { recursive: true });\n writeFileSync(genContractPath, `export type ApiContract = Record<string, never>;\\n`);\n }\n\n const pluginsClientGenPath = join(destination, \"api\", \"src\", \"lib\", \"plugins-types.gen.ts\");\n if (!existsSync(pluginsClientGenPath)) {\n mkdirSync(dirname(pluginsClientGenPath), { recursive: true });\n writeFileSync(\n pluginsClientGenPath,\n `import type { ContractRouterClient, AnyContractRouter } from \"@orpc/contract\";\\ntype ClientFactory<C extends AnyContractRouter> = (context?: Record<string, unknown>) => ContractRouterClient<C>;\\nexport type PluginsClient = Record<string, never>;\\n`,\n );\n }\n\n const authTypesContent = generateAuthTypesTemplate();\n const authTypesPaths = [\n join(destination, \"ui\", \"src\", \"lib\", \"auth-types.gen.ts\"),\n join(destination, \"api\", \"src\", \"lib\", \"auth-types.gen.ts\"),\n ];\n if (existsSync(join(destination, \"host\", \"src\"))) {\n authTypesPaths.push(join(destination, \"host\", \"src\", \"lib\", \"auth-types.gen.ts\"));\n }\n for (const authTypesGenPath of authTypesPaths) {\n if (!existsSync(authTypesGenPath)) {\n mkdirSync(dirname(authTypesGenPath), { recursive: true });\n writeFileSync(authTypesGenPath, authTypesContent);\n }\n }\n}\n\nfunction generateAuthTypesTemplate(): string {\n return `import type { Auth } from \"better-auth\";\nexport type { Auth } from \"better-auth\";\nexport type AuthSessionUser = NonNullable<Auth[\"$Infer\"][\"Session\"][\"user\"]> & {\n role?: string | null;\n isAnonymous?: boolean | null;\n walletAddress?: string | null;\n banned?: boolean | null;\n};\nexport type AuthSessionData = NonNullable<Auth[\"$Infer\"][\"Session\"][\"session\"]> & {\n activeOrganizationId?: string | null;\n};\nexport type AuthSession = {\n user: AuthSessionUser | null;\n session: AuthSessionData | null;\n};\nexport interface AuthOrganizationContext {\n activeOrganizationId: string | null;\n organization: { id: string; name: string; slug: string; logo?: string | null; metadata?: Record<string, unknown> } | null;\n member: { id: string; role: string } | null;\n isPersonal: boolean;\n hasOrganization: boolean;\n}\nexport interface AuthRequestContext {\n user: AuthSessionUser | null;\n userId: string | null;\n isAuthenticated: boolean;\n authMethod: \"session\" | \"apiKey\" | \"anonymous\" | \"none\";\n near: {\n primaryAccountId: string | null;\n linkedAccounts: Array<{ accountId: string; network: string; publicKey: string; isPrimary: boolean }>;\n hasNearAccount: boolean;\n };\n organization: AuthOrganizationContext;\n organizations?: Array<{ id: string; role: string; name?: string; slug?: string }>;\n}\nexport type AuthActiveMember = { id: string | null; role: string | null; organizationId: string | null };\nexport type AuthOrganization = NonNullable<AuthOrganizationContext[\"organization\"]>;\nexport type AuthOrganizationMember = NonNullable<AuthOrganizationContext[\"member\"]>;\nexport type AuthOrganizationSummary = NonNullable<AuthRequestContext[\"organizations\"]>[number];\nexport type AuthBaseSession = Auth[\"$Infer\"][\"Session\"];\nexport type createAuthInstance = never;\nexport interface AuthServices {\n auth: Auth;\n db: unknown;\n driver: { close(): Promise<void> };\n handler: (req: Request) => Promise<Response>;\n}\n`;\n}\n\nexport async function runBunInstall(destination: string): Promise<void> {\n await execCommand(\"bun\", [\"install\", \"--ignore-scripts\"], destination);\n}\n\nexport async function runTypesGen(destination: string): Promise<void> {\n await execCommand(\"node_modules/.bin/bos\", [\"types\", \"gen\"], destination);\n}\n\nconst WORKSPACE_LOCAL_PATHS: Record<string, string> = {\n \"everything-dev\": \"packages/everything-dev\",\n \"every-plugin\": \"packages/every-plugin\",\n};\n\nasync function resolveWorkspaceRefs(\n destination: string,\n options?: { localOverrides?: boolean; sourceDir?: string },\n): Promise<void> {\n await normalizePackageManifestsInTree({\n sourceRootDir: options?.sourceDir ?? destination,\n targetDir: destination,\n resolveCatalogRefs: false,\n preserveCatalogRefs: true,\n removeWorkspaceDeps: [\"host\"],\n });\n\n if (options?.localOverrides && options.sourceDir) {\n const rootPkgPath = join(destination, \"package.json\");\n if (existsSync(rootPkgPath)) {\n const pkg = JSON.parse(readFileSync(rootPkgPath, \"utf-8\")) as Record<string, unknown>;\n if (!pkg.overrides) pkg.overrides = {};\n const overrides = pkg.overrides as Record<string, string>;\n\n const rootWorkspaces = ((pkg.workspaces as Record<string, string[]>)?.packages ?? []).filter(\n Boolean,\n );\n\n for (const [name, relPath] of Object.entries(WORKSPACE_LOCAL_PATHS)) {\n if (!rootWorkspaces.some((ws) => ws === relPath || ws === `plugins/${name}`)) {\n const srcPkgPath = join(options.sourceDir, relPath, \"package.json\");\n if (existsSync(srcPkgPath)) {\n overrides[name] = `file:${relPath}`;\n rootWorkspaces.push(relPath);\n }\n }\n }\n\n if (rootWorkspaces.length > 0) {\n if (!pkg.workspaces) pkg.workspaces = {};\n (pkg.workspaces as Record<string, string[]>).packages = rootWorkspaces;\n }\n\n writeFileSync(rootPkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n }\n}\n\nexport async function writeInitSnapshot(\n destination: string,\n extendsAccount: string,\n extendsGateway: string,\n sourceDir: string,\n patterns: string[],\n options: { withHost: boolean; plugins?: string[]; pluginRoutes?: Record<string, string[]> },\n): Promise<void> {\n const effectivePatterns = options.withHost\n ? [...patterns, \"host/**\"]\n : patterns.filter((p) => !p.startsWith(\"host/\") && p !== \"host/**\");\n\n const excludedRoutePatterns: string[] = [];\n if (options.pluginRoutes) {\n for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) {\n if (!(options.plugins?.includes(pluginKey) ?? true)) {\n excludedRoutePatterns.push(...routePatterns);\n }\n }\n }\n\n const allFiles = new Set<string>();\n for (const pattern of effectivePatterns) {\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 const pluginMatch = match.match(/^plugins\\/([^/]+)/);\n if (pluginMatch && !(options.plugins?.includes(pluginMatch[1]) ?? true)) continue;\n if (isPathExcluded(match, excludedRoutePatterns)) continue;\n allFiles.add(match);\n }\n }\n\n if (options.pluginRoutes) {\n for (const [pluginKey, routePatterns] of Object.entries(options.pluginRoutes)) {\n if (!(options.plugins?.includes(pluginKey) ?? true)) 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 allFiles.add(match);\n }\n }\n }\n }\n }\n\n const fileHashes: Record<string, string> = {};\n for (const filePath of allFiles) {\n const src = join(sourceDir, filePath);\n const stat = lstatSync(src);\n if (!stat.isFile()) continue;\n const content = readFileSync(src);\n const destPath = filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath;\n fileHashes[destPath] = computeHash(content);\n }\n\n await writeSnapshot(destination, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: fileHashes,\n });\n}\n\nfunction computeHash(data: Uint8Array): string {\n return createHash(\"sha256\").update(data).digest(\"hex\").substring(0, 16);\n}\n\nfunction mkTmpDir(prefix: string): string {\n return mkdtempSync(join(tmpdir(), `${prefix}-`));\n}\n\nexport async function generateDatabaseMigrations(destination: string): Promise<void> {\n const drizzleConfigs = await glob(\"**/drizzle.config.ts\", {\n cwd: destination,\n nodir: true,\n dot: false,\n absolute: false,\n ignore: [\"**/node_modules/**\"],\n });\n\n for (const configPath of drizzleConfigs) {\n const workspaceDir = dirname(configPath);\n const pkgPath = join(destination, workspaceDir, \"package.json\");\n if (!existsSync(pkgPath)) continue;\n\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as Record<string, unknown>;\n const scripts = pkg.scripts as Record<string, string> | undefined;\n if (!scripts?.[\"db:generate\"]) continue;\n\n const cwd = join(destination, workspaceDir);\n await execCommand(\"bun\", [\"run\", \"db:generate\"], cwd);\n }\n}\n\nexport function execCommand(command: string, args: string[], cwd?: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const child = spawn(command, args, {\n cwd,\n stdio: \"pipe\",\n shell: true,\n });\n let stderr = \"\";\n child.stderr?.on(\"data\", (data: Buffer) => {\n stderr += data.toString();\n });\n child.on(\"close\", (code) => {\n if (code === 0) resolve();\n else\n reject(\n new Error(\n `Command '${command} ${args.join(\" \")}' failed with exit code ${code}: ${stderr}`,\n ),\n );\n });\n child.on(\"error\", reject);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAQ9C,eAAsB,iBAAiB,MAIb;AACxB,KAAI,KAAK,QAAQ;EACf,MAAM,YAAY,QAAQ,KAAK,OAAO;AACtC,MAAI,CAAC,WAAW,KAAK,WAAW,kBAAkB,CAAC,CACjD,OAAM,IAAI,MAAM,iDAAiD,YAAY;AAK/E,SAAO;GAAE;GAAW,cAHC,KAAK,MACxB,aAAa,KAAK,WAAW,kBAAkB,EAAE,QAAQ,CAC1D;GACiC,SAAS,YAAY;GAAI;;CAG7D,MAAM,eAAe,MAAM,kBAAkB,KAAK,gBAAgB,KAAK,eAAe;AAEtF,KAAI,CAAC,aAAa,WAChB,OAAM,IAAI,MAAM,wEAAwE;CAG1F,MAAM,EAAE,KAAK,WAAW,YAAY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zC,aAAU,KAAK,UAAU;IACzB;AACF,QAAM,GAAG,UAAU,SAAS;AAC1B,OAAI,SAAS,EAAG,UAAS;OAEvB,wBACE,IAAI,MACF,YAAY,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC,0BAA0B,KAAK,IAAI,SAC1E,CACF;IACH;AACF,QAAM,GAAG,SAAS,OAAO;GACzB"}
@@ -19,8 +19,8 @@ function deriveAccountFromDomain(domain, extendsAccount) {
19
19
  return `${firstSegment}.${extendsAccount.includes(".") ? extendsAccount.substring(extendsAccount.indexOf(".") + 1) : extendsAccount}`;
20
20
  }
21
21
  const AVAILABLE_PLUGINS = [{
22
- value: "_template",
23
- label: "template"
22
+ value: "settings",
23
+ label: "settings"
24
24
  }];
25
25
  async function promptInitOptions(input) {
26
26
  _clack_prompts.intro("Let's build an app...");
@@ -56,7 +56,7 @@ async function promptInitOptions(input) {
56
56
  const plugins = input.plugins ?? await _clack_prompts.multiselect({
57
57
  message: "Select plugins:",
58
58
  options: AVAILABLE_PLUGINS,
59
- initialValues: ["_template"],
59
+ initialValues: ["settings"],
60
60
  required: false
61
61
  });
62
62
  if (_clack_prompts.isCancel(plugins)) node_process.default.exit(0);
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.cjs","names":["p"],"sources":["../../src/cli/prompts.ts"],"sourcesContent":["import process from \"node:process\";\nimport * as p from \"@clack/prompts\";\n\nfunction parseExtendsRef(ref: string): { account: string; gateway: string } | null {\n const match = ref.match(/^(?:bos:\\/\\/)?([^/]+)\\/(.+)$/);\n if (!match) return null;\n return { account: match[1], gateway: match[2] };\n}\n\nfunction deriveAccountFromDomain(domain: string, extendsAccount: string): string {\n const firstSegment = domain.split(\".\")[0];\n if (!firstSegment) return \"\";\n const suffix = extendsAccount.includes(\".\")\n ? extendsAccount.substring(extendsAccount.indexOf(\".\") + 1)\n : extendsAccount;\n return `${firstSegment}.${suffix}`;\n}\n\nconst AVAILABLE_PLUGINS = [{ value: \"_template\", label: \"template\" }];\n\nexport async function promptInitOptions(input: {\n extendsAccount?: string;\n extendsGateway?: string;\n extends?: string;\n directory?: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n withHost?: boolean;\n}): Promise<{\n extendsAccount: string;\n extendsGateway: string;\n directory: string;\n account?: string;\n domain?: string;\n plugins: string[];\n withHost: boolean;\n}> {\n p.intro(\"Let's build an app...\");\n\n const domain =\n input.domain ??\n ((await p.text({\n message: \"Starting with a domain?\",\n placeholder: \"no\",\n })) as string);\n\n if (p.isCancel(domain)) process.exit(0);\n\n const extendsPlaceholder = \"bos://dev.everything.near/everything.dev\";\n const extendsInput =\n input.extends ??\n ((await p.text({\n message: \"Extending an existing app?\",\n placeholder: extendsPlaceholder,\n })) as string);\n\n if (p.isCancel(extendsInput)) process.exit(0);\n\n let extendsAccount = input.extendsAccount || \"\";\n let extendsGateway = input.extendsGateway || \"\";\n\n if (extendsInput) {\n const parsed = parseExtendsRef(extendsInput);\n if (parsed) {\n extendsAccount = extendsAccount || parsed.account;\n extendsGateway = extendsGateway || parsed.gateway;\n }\n }\n\n extendsAccount = extendsAccount || \"dev.everything.near\";\n extendsGateway = extendsGateway || \"everything.dev\";\n\n const accountDefault = domain ? deriveAccountFromDomain(domain, extendsAccount) : \"\";\n const account =\n input.account ??\n ((await p.text({\n message: \"What NEAR account will you publish from?\",\n placeholder: accountDefault || \"skip\",\n defaultValue: accountDefault,\n })) as string);\n\n if (p.isCancel(account)) process.exit(0);\n\n const directory = input.directory || domain || extendsGateway;\n\n const plugins =\n input.plugins ??\n ((await p.multiselect({\n message: \"Select plugins:\",\n options: AVAILABLE_PLUGINS,\n initialValues: [\"_template\"],\n required: false,\n })) as string[]);\n\n if (p.isCancel(plugins)) process.exit(0);\n\n const go =\n input.withHost !== undefined\n ? true\n : await p.confirm({\n message: \"GO!\",\n initialValue: true,\n });\n\n if (p.isCancel(go) || !go) process.exit(0);\n\n const withHost = input.withHost ?? false;\n\n return {\n extendsAccount,\n extendsGateway,\n directory,\n account: account || undefined,\n dom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AAC;AAEJ,KAAIA,eAAE,SAAS,QAAQ,CAAE,sBAAQ,KAAK,EAAE;CAExC,MAAM,YAAY,MAAM,aAAa,UAAU;CAE/C,MAAM,UACJ,MAAM,WACJ,MAAMA,eAAE,YAAY;EACpB,SAAS;EACT,SAAS;EACT,eAAe,CAAC,YAAY;EAC5B,UAAU;EACX,CAAC;AAEJ,KAAIA,eAAE,SAAS,QAAQ,CAAE,sBAAQ,KAAK,EAAE;CAExC,MAAM,KACJ,MAAM,aAAa,SACf,OACA,MAAMA,eAAE,QAAQ;EACd,SAAS;EACT,cAAc;EACf,CAAC;AAER,KAAIA,eAAE,SAAS,GAAG,IAAI,CAAC,GAAI,sBAAQ,KAAK,EAAE;CAE1C,MAAM,WAAW,MAAM,YAAY;AAEnC,QAAO;EACL;EACA;EACA;EACA,SAAS,WAAW;EACpB,QAAQ,UAAU;EAClB;EACA;EACD"}
1
+ {"version":3,"file":"prompts.cjs","names":["p"],"sources":["../../src/cli/prompts.ts"],"sourcesContent":["import process from \"node:process\";\nimport * as p from \"@clack/prompts\";\n\nfunction parseExtendsRef(ref: string): { account: string; gateway: string } | null {\n const match = ref.match(/^(?:bos:\\/\\/)?([^/]+)\\/(.+)$/);\n if (!match) return null;\n return { account: match[1], gateway: match[2] };\n}\n\nfunction deriveAccountFromDomain(domain: string, extendsAccount: string): string {\n const firstSegment = domain.split(\".\")[0];\n if (!firstSegment) return \"\";\n const suffix = extendsAccount.includes(\".\")\n ? extendsAccount.substring(extendsAccount.indexOf(\".\") + 1)\n : extendsAccount;\n return `${firstSegment}.${suffix}`;\n}\n\nconst AVAILABLE_PLUGINS = [{ value: \"settings\", label: \"settings\" }];\n\nexport async function promptInitOptions(input: {\n extendsAccount?: string;\n extendsGateway?: string;\n extends?: string;\n directory?: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n withHost?: boolean;\n}): Promise<{\n extendsAccount: string;\n extendsGateway: string;\n directory: string;\n account?: string;\n domain?: string;\n plugins: string[];\n withHost: boolean;\n}> {\n p.intro(\"Let's build an app...\");\n\n const domain =\n input.domain ??\n ((await p.text({\n message: \"Starting with a domain?\",\n placeholder: \"no\",\n })) as string);\n\n if (p.isCancel(domain)) process.exit(0);\n\n const extendsPlaceholder = \"bos://dev.everything.near/everything.dev\";\n const extendsInput =\n input.extends ??\n ((await p.text({\n message: \"Extending an existing app?\",\n placeholder: extendsPlaceholder,\n })) as string);\n\n if (p.isCancel(extendsInput)) process.exit(0);\n\n let extendsAccount = input.extendsAccount || \"\";\n let extendsGateway = input.extendsGateway || \"\";\n\n if (extendsInput) {\n const parsed = parseExtendsRef(extendsInput);\n if (parsed) {\n extendsAccount = extendsAccount || parsed.account;\n extendsGateway = extendsGateway || parsed.gateway;\n }\n }\n\n extendsAccount = extendsAccount || \"dev.everything.near\";\n extendsGateway = extendsGateway || \"everything.dev\";\n\n const accountDefault = domain ? deriveAccountFromDomain(domain, extendsAccount) : \"\";\n const account =\n input.account ??\n ((await p.text({\n message: \"What NEAR account will you publish from?\",\n placeholder: accountDefault || \"skip\",\n defaultValue: accountDefault,\n })) as string);\n\n if (p.isCancel(account)) process.exit(0);\n\n const directory = input.directory || domain || extendsGateway;\n\n const plugins =\n input.plugins ??\n ((await p.multiselect({\n message: \"Select plugins:\",\n options: AVAILABLE_PLUGINS,\n initialValues: [\"settings\"],\n required: false,\n })) as string[]);\n\n if (p.isCancel(plugins)) process.exit(0);\n\n const go =\n input.withHost !== undefined\n ? true\n : await p.confirm({\n message: \"GO!\",\n initialValue: true,\n });\n\n if (p.isCancel(go) || !go) process.exit(0);\n\n const withHost = input.withHost ?? false;\n\n return {\n extendsAccount,\n extendsGateway,\n directory,\n account: account || undefined,\n domain: domain || undefined,\n plugins,\n withHost,\n };\n}\n"],"mappings":";;;;;;;AAGA,SAAS,gBAAgB,KAA0D;CACjF,MAAM,QAAQ,IAAI,MAAM,+BAA+B;AACvD,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO;EAAE,SAAS,MAAM;EAAI,SAAS,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,WAAW;EAC3B,UAAU;EACX,CAAC;AAEJ,KAAIA,eAAE,SAAS,QAAQ,CAAE,sBAAQ,KAAK,EAAE;CAExC,MAAM,KACJ,MAAM,aAAa,SACf,OACA,MAAMA,eAAE,QAAQ;EACd,SAAS;EACT,cAAc;EACf,CAAC;AAER,KAAIA,eAAE,SAAS,GAAG,IAAI,CAAC,GAAI,sBAAQ,KAAK,EAAE;CAE1C,MAAM,WAAW,MAAM,YAAY;AAEnC,QAAO;EACL;EACA;EACA;EACA,SAAS,WAAW;EACpB,QAAQ,UAAU;EAClB;EACA;EACD"}
@@ -16,8 +16,8 @@ function deriveAccountFromDomain(domain, extendsAccount) {
16
16
  return `${firstSegment}.${extendsAccount.includes(".") ? extendsAccount.substring(extendsAccount.indexOf(".") + 1) : extendsAccount}`;
17
17
  }
18
18
  const AVAILABLE_PLUGINS = [{
19
- value: "_template",
20
- label: "template"
19
+ value: "settings",
20
+ label: "settings"
21
21
  }];
22
22
  async function promptInitOptions(input) {
23
23
  p.intro("Let's build an app...");
@@ -53,7 +53,7 @@ async function promptInitOptions(input) {
53
53
  const plugins = input.plugins ?? await p.multiselect({
54
54
  message: "Select plugins:",
55
55
  options: AVAILABLE_PLUGINS,
56
- initialValues: ["_template"],
56
+ initialValues: ["settings"],
57
57
  required: false
58
58
  });
59
59
  if (p.isCancel(plugins)) process.exit(0);
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.mjs","names":[],"sources":["../../src/cli/prompts.ts"],"sourcesContent":["import process from \"node:process\";\nimport * as p from \"@clack/prompts\";\n\nfunction parseExtendsRef(ref: string): { account: string; gateway: string } | null {\n const match = ref.match(/^(?:bos:\\/\\/)?([^/]+)\\/(.+)$/);\n if (!match) return null;\n return { account: match[1], gateway: match[2] };\n}\n\nfunction deriveAccountFromDomain(domain: string, extendsAccount: string): string {\n const firstSegment = domain.split(\".\")[0];\n if (!firstSegment) return \"\";\n const suffix = extendsAccount.includes(\".\")\n ? extendsAccount.substring(extendsAccount.indexOf(\".\") + 1)\n : extendsAccount;\n return `${firstSegment}.${suffix}`;\n}\n\nconst AVAILABLE_PLUGINS = [{ value: \"_template\", label: \"template\" }];\n\nexport async function promptInitOptions(input: {\n extendsAccount?: string;\n extendsGateway?: string;\n extends?: string;\n directory?: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n withHost?: boolean;\n}): Promise<{\n extendsAccount: string;\n extendsGateway: string;\n directory: string;\n account?: string;\n domain?: string;\n plugins: string[];\n withHost: boolean;\n}> {\n p.intro(\"Let's build an app...\");\n\n const domain =\n input.domain ??\n ((await p.text({\n message: \"Starting with a domain?\",\n placeholder: \"no\",\n })) as string);\n\n if (p.isCancel(domain)) process.exit(0);\n\n const extendsPlaceholder = \"bos://dev.everything.near/everything.dev\";\n const extendsInput =\n input.extends ??\n ((await p.text({\n message: \"Extending an existing app?\",\n placeholder: extendsPlaceholder,\n })) as string);\n\n if (p.isCancel(extendsInput)) process.exit(0);\n\n let extendsAccount = input.extendsAccount || \"\";\n let extendsGateway = input.extendsGateway || \"\";\n\n if (extendsInput) {\n const parsed = parseExtendsRef(extendsInput);\n if (parsed) {\n extendsAccount = extendsAccount || parsed.account;\n extendsGateway = extendsGateway || parsed.gateway;\n }\n }\n\n extendsAccount = extendsAccount || \"dev.everything.near\";\n extendsGateway = extendsGateway || \"everything.dev\";\n\n const accountDefault = domain ? deriveAccountFromDomain(domain, extendsAccount) : \"\";\n const account =\n input.account ??\n ((await p.text({\n message: \"What NEAR account will you publish from?\",\n placeholder: accountDefault || \"skip\",\n defaultValue: accountDefault,\n })) as string);\n\n if (p.isCancel(account)) process.exit(0);\n\n const directory = input.directory || domain || extendsGateway;\n\n const plugins =\n input.plugins ??\n ((await p.multiselect({\n message: \"Select plugins:\",\n options: AVAILABLE_PLUGINS,\n initialValues: [\"_template\"],\n required: false,\n })) as string[]);\n\n if (p.isCancel(plugins)) process.exit(0);\n\n const go =\n input.withHost !== undefined\n ? true\n : await p.confirm({\n message: \"GO!\",\n initialValue: true,\n });\n\n if (p.isCancel(go) || !go) process.exit(0);\n\n const withHost = input.withHost ?? false;\n\n return {\n extendsAccount,\n extendsGateway,\n directory,\n account: account || undefined,\n domain: domain || undefined,\n plugins,\n withHost,\n };\n}\n"],"mappings":";;;;AAGA,SAAS,gBAAgB,KAA0D;CACjF,MAAM,QAAQ,IAAI,MAAM,+BAA+B;AACvD,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO;EAAE,SAAS,MAAM;EAAI,SAAS,MAAM;EAAI;;AAGjD,SAAS,wBAAwB,QAAgB,gBAAgC;CAC/E,MAAM,eAAe,OAAO,MAAM,IAAI,CAAC;AACvC,KAAI,CAAC,aAAc,QAAO;AAI1B,QAAO,GAAG,aAAa,GAHR,eAAe,SAAS,IAAI,GACvC,eAAe,UAAU,eAAe,QAAQ,IAAI,GAAG,EAAE,GACzD;;AAIN,MAAM,oBAAoB,CAAC;CAAE,OAAO;CAAa,OAAO;CAAY,CAAC;AAErE,eAAsB,kBAAkB,OAiBrC;AACD,GAAE,MAAM,wBAAwB;CAEhC,MAAM,SACJ,MAAM,UACJ,MAAM,EAAE,KAAK;EACb,SAAS;EACT,aAAa;EACd,CAAC;AAEJ,KAAI,EAAE,SAAS,OAAO,CAAE,SAAQ,KAAK,EAAE;CAGvC,MAAM,eACJ,MAAM,WACJ,MAAM,EAAE,KAAK;EACb,SAAS;EACT,aALuB;EAMxB,CAAC;AAEJ,KAAI,EAAE,SAAS,aAAa,CAAE,SAAQ,KAAK,EAAE;CAE7C,IAAI,iBAAiB,MAAM,kBAAkB;CAC7C,IAAI,iBAAiB,MAAM,kBAAkB;AAE7C,KAAI,cAAc;EAChB,MAAM,SAAS,gBAAgB,aAAa;AAC5C,MAAI,QAAQ;AACV,oBAAiB,kBAAkB,OAAO;AAC1C,oBAAiB,kBAAkB,OAAO;;;AAI9C,kBAAiB,kBAAkB;AACnC,kBAAiB,kBAAkB;CAEnC,MAAM,iBAAiB,SAAS,wBAAwB,QAAQ,eAAe,GAAG;CAClF,MAAM,UACJ,MAAM,WACJ,MAAM,EAAE,KAAK;EACb,SAAS;EACT,aAAa,kBAAkB;EAC/B,cAAc;EACf,CAAC;AAEJ,KAAI,EAAE,SAAS,QAAQ,CAAE,SAAQ,KAAK,EAAE;CAExC,MAAM,YAAY,MAAM,aAAa,UAAU;CAE/C,MAAM,UACJ,MAAM,WACJ,MAAM,EAAE,YAAY;EACpB,SAAS;EACT,SAAS;EACT,eAAe,CAAC,YAAY;EAC5B,UAAU;EACX,CAAC;AAEJ,KAAI,EAAE,SAAS,QAAQ,CAAE,SAAQ,KAAK,EAAE;CAExC,MAAM,KACJ,MAAM,aAAa,SACf,OACA,MAAM,EAAE,QAAQ;EACd,SAAS;EACT,cAAc;EACf,CAAC;AAER,KAAI,EAAE,SAAS,GAAG,IAAI,CAAC,GAAI,SAAQ,KAAK,EAAE;CAE1C,MAAM,WAAW,MAAM,YAAY;AAEnC,QAAO;EACL;EACA;EACA;EACA,SAAS,WAAW;EACpB,QAAQ,UAAU;EAClB;EACA;EACD"}
1
+ {"version":3,"file":"prompts.mjs","names":[],"sources":["../../src/cli/prompts.ts"],"sourcesContent":["import process from \"node:process\";\nimport * as p from \"@clack/prompts\";\n\nfunction parseExtendsRef(ref: string): { account: string; gateway: string } | null {\n const match = ref.match(/^(?:bos:\\/\\/)?([^/]+)\\/(.+)$/);\n if (!match) return null;\n return { account: match[1], gateway: match[2] };\n}\n\nfunction deriveAccountFromDomain(domain: string, extendsAccount: string): string {\n const firstSegment = domain.split(\".\")[0];\n if (!firstSegment) return \"\";\n const suffix = extendsAccount.includes(\".\")\n ? extendsAccount.substring(extendsAccount.indexOf(\".\") + 1)\n : extendsAccount;\n return `${firstSegment}.${suffix}`;\n}\n\nconst AVAILABLE_PLUGINS = [{ value: \"settings\", label: \"settings\" }];\n\nexport async function promptInitOptions(input: {\n extendsAccount?: string;\n extendsGateway?: string;\n extends?: string;\n directory?: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n withHost?: boolean;\n}): Promise<{\n extendsAccount: string;\n extendsGateway: string;\n directory: string;\n account?: string;\n domain?: string;\n plugins: string[];\n withHost: boolean;\n}> {\n p.intro(\"Let's build an app...\");\n\n const domain =\n input.domain ??\n ((await p.text({\n message: \"Starting with a domain?\",\n placeholder: \"no\",\n })) as string);\n\n if (p.isCancel(domain)) process.exit(0);\n\n const extendsPlaceholder = \"bos://dev.everything.near/everything.dev\";\n const extendsInput =\n input.extends ??\n ((await p.text({\n message: \"Extending an existing app?\",\n placeholder: extendsPlaceholder,\n })) as string);\n\n if (p.isCancel(extendsInput)) process.exit(0);\n\n let extendsAccount = input.extendsAccount || \"\";\n let extendsGateway = input.extendsGateway || \"\";\n\n if (extendsInput) {\n const parsed = parseExtendsRef(extendsInput);\n if (parsed) {\n extendsAccount = extendsAccount || parsed.account;\n extendsGateway = extendsGateway || parsed.gateway;\n }\n }\n\n extendsAccount = extendsAccount || \"dev.everything.near\";\n extendsGateway = extendsGateway || \"everything.dev\";\n\n const accountDefault = domain ? deriveAccountFromDomain(domain, extendsAccount) : \"\";\n const account =\n input.account ??\n ((await p.text({\n message: \"What NEAR account will you publish from?\",\n placeholder: accountDefault || \"skip\",\n defaultValue: accountDefault,\n })) as string);\n\n if (p.isCancel(account)) process.exit(0);\n\n const directory = input.directory || domain || extendsGateway;\n\n const plugins =\n input.plugins ??\n ((await p.multiselect({\n message: \"Select plugins:\",\n options: AVAILABLE_PLUGINS,\n initialValues: [\"settings\"],\n required: false,\n })) as string[]);\n\n if (p.isCancel(plugins)) process.exit(0);\n\n const go =\n input.withHost !== undefined\n ? true\n : await p.confirm({\n message: \"GO!\",\n initialValue: true,\n });\n\n if (p.isCancel(go) || !go) process.exit(0);\n\n const withHost = input.withHost ?? false;\n\n return {\n extendsAccount,\n extendsGateway,\n directory,\n account: account || undefined,\n domain: domain || undefined,\n plugins,\n withHost,\n };\n}\n"],"mappings":";;;;AAGA,SAAS,gBAAgB,KAA0D;CACjF,MAAM,QAAQ,IAAI,MAAM,+B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M,WACJ,MAAM,EAAE,YAAY;EACpB,SAAS;EACT,SAAS;EACT,eAAe,CAAC,WAAW;EAC3B,UAAU;EACX,CAAC;AAEJ,KAAI,EAAE,SAAS,QAAQ,CAAE,SAAQ,KAAK,EAAE;CAExC,MAAM,KACJ,MAAM,aAAa,SACf,OACA,MAAM,EAAE,QAAQ;EACd,SAAS;EACT,cAAc;EACf,CAAC;AAER,KAAI,EAAE,SAAS,GAAG,IAAI,CAAC,GAAI,SAAQ,KAAK,EAAE;CAE1C,MAAM,WAAW,MAAM,YAAY;AAEnC,QAAO;EACL;EACA;EACA;EACA,SAAS,WAAW;EACpB,QAAQ,UAAU;EAClB;EACA;EACD"}
@@ -7,6 +7,18 @@ let node_path = require("node:path");
7
7
 
8
8
  //#region src/cli/status.ts
9
9
  const FRAMEWORK_PACKAGES = ["everything-dev", "every-plugin"];
10
+ const CATALOG_TOOL_PACKAGES = [
11
+ "@rspack/core",
12
+ "@rspack/cli",
13
+ "@rsbuild/core",
14
+ "@rsbuild/plugin-react",
15
+ "@module-federation/enhanced",
16
+ "@module-federation/node",
17
+ "@module-federation/rsbuild-plugin",
18
+ "@module-federation/runtime-core",
19
+ "@module-federation/sdk",
20
+ "@module-federation/dts-plugin"
21
+ ];
10
22
  async function fetchLatestNpmVersion(packageName) {
11
23
  try {
12
24
  const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
@@ -54,6 +66,16 @@ async function getStatus(projectDir) {
54
66
  latest: latest ?? void 0
55
67
  });
56
68
  }
69
+ for (const name of CATALOG_TOOL_PACKAGES) {
70
+ const installed = readInstalledVersion(projectDir, name);
71
+ if (!installed) continue;
72
+ const latest = await fetchLatestNpmVersion(name);
73
+ packages.push({
74
+ name,
75
+ installed,
76
+ latest: latest ?? void 0
77
+ });
78
+ }
57
79
  const snapshot = await require_snapshot.readSnapshot(projectDir);
58
80
  const extendsRef = config.extends;
59
81
  const parentReachable = await checkParentReachable(extendsRef);
@@ -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\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 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,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;;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":";;;;;;;;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;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"node:path";
6
6
 
7
7
  //#region src/cli/status.ts
8
8
  const FRAMEWORK_PACKAGES = ["everything-dev", "every-plugin"];
9
+ const CATALOG_TOOL_PACKAGES = [
10
+ "@rspack/core",
11
+ "@rspack/cli",
12
+ "@rsbuild/core",
13
+ "@rsbuild/plugin-react",
14
+ "@module-federation/enhanced",
15
+ "@module-federation/node",
16
+ "@module-federation/rsbuild-plugin",
17
+ "@module-federation/runtime-core",
18
+ "@module-federation/sdk",
19
+ "@module-federation/dts-plugin"
20
+ ];
9
21
  async function fetchLatestNpmVersion(packageName) {
10
22
  try {
11
23
  const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
@@ -53,6 +65,16 @@ async function getStatus(projectDir) {
53
65
  latest: latest ?? void 0
54
66
  });
55
67
  }
68
+ for (const name of CATALOG_TOOL_PACKAGES) {
69
+ const installed = readInstalledVersion(projectDir, name);
70
+ if (!installed) continue;
71
+ const latest = await fetchLatestNpmVersion(name);
72
+ packages.push({
73
+ name,
74
+ installed,
75
+ latest: latest ?? void 0
76
+ });
77
+ }
56
78
  const snapshot = await readSnapshot(projectDir);
57
79
  const extendsRef = config.extends;
58
80
  const parentReachable = await checkParentReachable(extendsRef);
@@ -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\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 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,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,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,SADe,MAAM,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;;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"}
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,MAAM,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,SADe,MAAM,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
@@ -1,4 +1,6 @@
1
1
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
+ const require_merge = require('../merge.cjs');
3
+ const require_path_match = require('../utils/path-match.cjs');
2
4
  const require_snapshot = require('./snapshot.cjs');
3
5
  const require_cli_init = require('./init.cjs');
4
6
  let node_fs = require("node:fs");
@@ -12,6 +14,8 @@ const FRAMEWORK_OWNED_SYNC_FILES = new Set([
12
14
  "biome.json",
13
15
  "bos.config.json",
14
16
  "package.json",
17
+ ".github/renovate.json",
18
+ ".github/workflows/ci.yml",
15
19
  ".github/workflows/release-sync.yml",
16
20
  "ui/package.json",
17
21
  "ui/postcss.config.mjs",
@@ -44,17 +48,6 @@ async function readTemplatesyncExclude(sourceDir) {
44
48
  function readLocalSyncExcludes(projectDir) {
45
49
  return readExcludeFile((0, node_path.join)(projectDir, ".bos", "sync-local-exclude"));
46
50
  }
47
- function isExcluded(filePath, excludePatterns) {
48
- for (const pattern of excludePatterns) if (pattern.endsWith("/**")) {
49
- const prefix = pattern.slice(0, -3);
50
- if (filePath.startsWith(`${prefix}/`) || filePath === prefix) return true;
51
- } else if (pattern.endsWith("/*")) {
52
- const prefix = pattern.slice(0, -2);
53
- const slashIdx = filePath.indexOf("/", prefix.length + 1);
54
- if (filePath.startsWith(`${prefix}/`) && slashIdx === -1) return true;
55
- } else if (filePath === pattern || filePath.startsWith(`${pattern}/`)) return true;
56
- return false;
57
- }
58
51
  function computeLocalHash(projectDir, filePath) {
59
52
  const fullPath = (0, node_path.join)(projectDir, filePath);
60
53
  if (!(0, node_fs.existsSync)(fullPath)) return null;
@@ -77,43 +70,6 @@ function backupFiles(projectDir, filePaths) {
77
70
  }
78
71
  return backupDir;
79
72
  }
80
- function isPlainObject(value) {
81
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
82
- }
83
- function mergeJsonValues(local, template) {
84
- if (isPlainObject(local) && isPlainObject(template)) {
85
- const merged = {};
86
- for (const key of Object.keys(local)) merged[key] = mergeJsonValues(local[key], template[key]);
87
- for (const key of Object.keys(template)) if (!(key in merged)) merged[key] = template[key];
88
- return merged;
89
- }
90
- return local ?? template;
91
- }
92
- function mergeBosConfig(local, template) {
93
- const merged = {};
94
- if (local.extends !== void 0) merged.extends = local.extends;
95
- else if (template.extends !== void 0) merged.extends = template.extends;
96
- const TRAIL_GROUP = [
97
- "app",
98
- "plugins",
99
- "shared"
100
- ];
101
- const localKeys = Object.keys(local).filter((k) => k !== "extends");
102
- const templateKeys = Object.keys(template).filter((k) => k !== "extends" && !localKeys.includes(k));
103
- const firstTrailIndex = localKeys.findIndex((k) => TRAIL_GROUP.includes(k));
104
- const orderedKeys = [];
105
- if (firstTrailIndex >= 0) {
106
- orderedKeys.push(...localKeys.slice(0, firstTrailIndex));
107
- orderedKeys.push(...templateKeys);
108
- for (const trailKey of TRAIL_GROUP) if (localKeys.includes(trailKey)) orderedKeys.push(trailKey);
109
- } else {
110
- orderedKeys.push(...localKeys);
111
- orderedKeys.push(...templateKeys);
112
- for (const trailKey of TRAIL_GROUP) if (templateKeys.includes(trailKey)) orderedKeys.push(trailKey);
113
- }
114
- for (const key of orderedKeys) merged[key] = mergeJsonValues(local[key], template[key]);
115
- return merged;
116
- }
117
73
  function mergeStringMaps(local, template) {
118
74
  if (!local && !template) return void 0;
119
75
  const merged = { ...local ?? {} };
@@ -188,7 +144,7 @@ function writeSyncedFile(sourceDir, projectDir, filePath) {
188
144
  const localContent = (0, node_fs.existsSync)(dest) ? (0, node_fs.readFileSync)(dest, "utf-8") : null;
189
145
  const templateContent = (0, node_fs.readFileSync)(src, "utf-8");
190
146
  if (localContent) {
191
- const merged = mergeBosConfig(JSON.parse(localContent), JSON.parse(templateContent));
147
+ const merged = require_merge.mergeBosConfigWithTemplate(JSON.parse(localContent), JSON.parse(templateContent));
192
148
  (0, node_fs.writeFileSync)(dest, `${JSON.stringify(merged, null, 2)}\n`);
193
149
  return;
194
150
  }
@@ -206,7 +162,9 @@ function writeSyncedFile(sourceDir, projectDir, filePath) {
206
162
  }
207
163
  async function syncTemplate(projectDir, options) {
208
164
  const localConfig = JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(projectDir, "bos.config.json"), "utf-8"));
209
- const extendsRef = localConfig.extends;
165
+ let extendsRef;
166
+ if (typeof localConfig.extends === "string") extendsRef = localConfig.extends;
167
+ else if (require_merge.isPlainObject(localConfig.extends)) extendsRef = require_merge.resolveExtendsRef(localConfig.extends, "production");
210
168
  if (!extendsRef?.startsWith("bos://")) return {
211
169
  status: "error",
212
170
  updated: [],
@@ -252,8 +210,9 @@ async function syncTemplate(projectDir, options) {
252
210
  }
253
211
  const childPlugins = localConfig.plugins && typeof localConfig.plugins === "object" ? Object.keys(localConfig.plugins) : [];
254
212
  const pluginRoutes = {};
255
- if (parentConfig.plugins) {
256
- for (const [key, ref] of Object.entries(parentConfig.plugins)) if (ref.routes && ref.routes.length > 0) pluginRoutes[key] = ref.routes;
213
+ if (parentConfig.plugins) for (const [key, entry] of Object.entries(parentConfig.plugins)) {
214
+ const ref = entry && typeof entry !== "string" ? entry : null;
215
+ if (ref?.routes && ref.routes.length > 0) pluginRoutes[key] = ref.routes;
257
216
  }
258
217
  const excludedRoutePatterns = [];
259
218
  for (const [pluginKey, routePatterns] of Object.entries(pluginRoutes)) if (!childPlugins.includes(pluginKey)) excludedRoutePatterns.push(...routePatterns);
@@ -261,7 +220,7 @@ async function syncTemplate(projectDir, options) {
261
220
  for (const filePath of allTemplateFiles) {
262
221
  const pluginMatch = filePath.match(/^plugins\/([^/]+)/);
263
222
  if (pluginMatch && !childPlugins.includes(pluginMatch[1])) continue;
264
- if (isExcluded(filePath, excludedRoutePatterns)) continue;
223
+ if (require_path_match.isPathExcluded(filePath, excludedRoutePatterns)) continue;
265
224
  filteredFiles.add(filePath);
266
225
  }
267
226
  for (const [pluginKey, routePatterns] of Object.entries(pluginRoutes)) {
@@ -273,7 +232,7 @@ async function syncTemplate(projectDir, options) {
273
232
  dot: true,
274
233
  absolute: false
275
234
  });
276
- for (const match of matches) if (!isExcluded(match, excludedRoutePatterns)) filteredFiles.add(match);
235
+ for (const match of matches) if (!require_path_match.isPathExcluded(match, excludedRoutePatterns)) filteredFiles.add(match);
277
236
  }
278
237
  }
279
238
  const snapshot = await require_snapshot.readSnapshot(projectDir);
@@ -283,7 +242,7 @@ async function syncTemplate(projectDir, options) {
283
242
  for (const filePath of filteredFiles) {
284
243
  const destPath = toDestPath(filePath);
285
244
  const frameworkOwned = isFrameworkOwnedSyncFile(destPath);
286
- if (isExcluded(destPath, excludePatterns) && !frameworkOwned) continue;
245
+ if (require_path_match.isPathExcluded(destPath, excludePatterns) && !frameworkOwned) continue;
287
246
  const localHash = computeLocalHash(projectDir, destPath);
288
247
  const sourceContent = (0, node_fs.readFileSync)((0, node_path.join)(sourceDir, filePath));
289
248
  const sourceHash = (0, node_crypto.createHash)("sha256").update(sourceContent).digest("hex").substring(0, 16);
@@ -311,7 +270,7 @@ async function syncTemplate(projectDir, options) {
311
270
  skipped,
312
271
  added
313
272
  };
314
- const filesToWrite = [...updated, ...added].filter((f) => isFrameworkOwnedSyncFile(f) || !isExcluded(f, excludePatterns));
273
+ const filesToWrite = [...updated, ...added].filter((f) => isFrameworkOwnedSyncFile(f) || !require_path_match.isPathExcluded(f, excludePatterns));
315
274
  const destToSource = /* @__PURE__ */ new Map();
316
275
  for (const filePath of filteredFiles) destToSource.set(toDestPath(filePath), filePath);
317
276
  if (filesToWrite.length > 0) {