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.cjs","names":["require","fetchBosConfigFromFastKv","loadManifestNormalizationSpec","normalizePackageManifestsInTree","writeSnapshot"],"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} 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a,cAAc,eAAe;AAC/D,MAAI,yBAAY,QAAQ,CAAE;AAI1B,MAAI,CAFQ,KAAK,gCAAmB,SAAS,QAAQ,CAAC,CAClC,UACL,eAAgB;AAG/B,QAAM,YAAY,OAAO,CAAC,OAAO,cAAc,sBAD9B,aAAa,aAAa,CACU;;;AAIzD,SAAgB,YAAY,SAAiB,MAAgB,KAA6B;AACxF,QAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,sCAAc,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.cjs","names":["require","fetchBosConfigFromFastKv","isPathExcluded","saveBosConfig","loadManifestNormalizationSpec","normalizePackageManifestsInTree","writeSnapshot"],"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,MAAMA,yFAAwC;AAQ9C,eAAsB,iBAAiB,MAIb;AACxB,KAAI,KAAK,QAAQ;EACf,MAAM,mCAAoB,KAAK,OAAO;AACtC,MAAI,6CAAiB,WAAW,kBAAkB,CAAC,CACjD,OAAM,IAAI,MAAM,iDAAiD,YAAY;AAK/E,SAAO;GAAE;GAAW,cAHC,KAAK,oDACN,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,MAAM,gBAAgB,aAAa,WAAW;AAClF,QAAO;EAAE;EAAW;EAAc;EAAS;;AAG7C,eAAsB,iBAAiB,WAAsC;CAC3E,MAAM,+BAAgB,WAAW,gBAAgB;AACjD,KAAI,yBAAY,SAAS,CACvB,QAAO,EAAE;AAIX,kCAD6B,UAAU,QAAQ,CAE5C,MAAM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M,CAAC,UAAU,GAAG,GAAG;;AAGzE,SAAS,SAAS,QAAwB;AACxC,0EAAgC,EAAE,GAAG,OAAO,GAAG,CAAC;;AAGlD,eAAsB,2BAA2B,aAAoC;CACnF,MAAM,iBAAiB,qBAAW,wBAAwB;EACxD,KAAK;EACL,OAAO;EACP,KAAK;EACL,UAAU;EACV,QAAQ,CAAC,qBAAqB;EAC/B,CAAC;AAEF,MAAK,MAAM,cAAc,gBAAgB;EACvC,MAAM,sCAAuB,WAAW;EACxC,MAAM,8BAAe,aAAa,cAAc,eAAe;AAC/D,MAAI,yBAAY,QAAQ,CAAE;AAI1B,MAAI,CAFQ,KAAK,gCAAmB,SAAS,QAAQ,CAAC,CAClC,UACL,eAAgB;AAG/B,QAAM,YAAY,OAAO,CAAC,OAAO,cAAc,sBAD9B,aAAa,aAAa,CACU;;;AAIzD,SAAgB,YAAY,SAAiB,MAAgB,KAA6B;AACxF,QAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,sCAAc,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"}
@@ -11,12 +11,12 @@ declare function resolveSourceDir(opts: {
11
11
  extendsGateway: string;
12
12
  source?: string;
13
13
  }): Promise<SourceResult>;
14
+ declare function readTemplatekeep(sourceDir: string): Promise<string[]>;
14
15
  declare function fetchParentConfig(extendsAccount: string, extendsGateway: string): Promise<BosConfig>;
15
16
  declare function downloadTarball(repoUrl: string): Promise<{
16
17
  dir: string;
17
18
  cleanup: () => Promise<void>;
18
19
  }>;
19
- declare function readTemplatekeep(sourceDir: string): Promise<string[]>;
20
20
  declare function copyFilteredFiles(sourceDir: string, destination: string, patterns: string[], options: {
21
21
  withHost: boolean;
22
22
  plugins?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.cts","names":[],"sources":["../../src/cli/init.ts"],"mappings":";;;UAwDU,YAAA;EACR,SAAA;EACA,YAAA,EAAc,SAAA;EACd,OAAA,QAAe,OAAA;AAAA;AAAA,iBAGK,gBAAA,CAAiB,IAAA;EACrC,cAAA;EACA,cAAA;EACA,MAAA;AAAA,IACE,OAAA,CAAQ,YAAA;AAAA,iBAsBU,iBAAA,CACpB,cAAA,UACA,cAAA,WACC,OAAA,CAAQ,SAAA;AAAA,iBAKW,eAAA,CACpB,OAAA,WACC,OAAA;EAAU,GAAA;EAAa,OAAA,QAAe,OAAA;AAAA;AAAA,iBAiEnB,gBAAA,CAAiB,SAAA,WAAoB,OAAA;AAAA,iBAarC,iBAAA,CACpB,SAAA,UACA,WAAA,UACA,QAAA,YACA,OAAA;EAAW,QAAA;EAAmB,OAAA;EAAoB,YAAA,GAAe,MAAA;AAAA,IAChE,OAAA;AAAA,iBAoGmB,iBAAA,CACpB,WAAA,UACA,IAAA;EACE,cAAA;EACA,cAAA;EACA,OAAA;EACA,MAAA;EACA,OAAA;EACA,YAAA,GAAe,MAAA;EACf,aAAA;IAAkB,cAAA;IAA0B,SAAA;EAAA;EAC5C,IAAA;EACA,QAAA;AAAA,IAED,OAAA;AAAA,iBAuMmB,aAAA,CAAc,WAAA,WAAsB,OAAA;AAAA,iBAIpC,WAAA,CAAY,WAAA,WAAsB,OAAA;AAAA,iBAoDlC,iBAAA,CACpB,WAAA,UACA,cAAA,UACA,cAAA,UACA,SAAA,UACA,QAAA,YACA,OAAA;EAAW,QAAA;EAAmB,OAAA;EAAoB,YAAA,GAAe,MAAA;AAAA,IAChE,OAAA;AAAA,iBAsFmB,0BAAA,CAA2B,WAAA,WAAsB,OAAA;AAAA,iBAuBvD,WA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olveSourceDir(opts: {
11
11
  extendsGateway: string;
12
12
  source?: string;
13
13
  }): Promise<SourceResult>;
14
+ declare function readTemplatekeep(sourceDir: string): Promise<string[]>;
14
15
  declare function fetchParentConfig(extendsAccount: string, extendsGateway: string): Promise<BosConfig>;
15
16
  declare function downloadTarball(repoUrl: string): Promise<{
16
17
  dir: string;
17
18
  cleanup: () => Promise<void>;
18
19
  }>;
19
- declare function readTemplatekeep(sourceDir: string): Promise<string[]>;
20
20
  declare function copyFilteredFiles(sourceDir: string, destination: string, patterns: string[], options: {
21
21
  withHost: boolean;
22
22
  plugins?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.mts","names":[],"sources":["../../src/cli/init.ts"],"mappings":";;;UAwDU,YAAA;EACR,SAAA;EACA,YAAA,EAAc,SAAA;EACd,OAAA,QAAe,OAAA;AAAA;AAAA,iBAGK,gBAAA,CAAiB,IAAA;EACrC,cAAA;EACA,cAAA;EACA,MAAA;AAAA,IACE,OAAA,CAAQ,YAAA;AAAA,iBAsBU,iBAAA,CACpB,cAAA,UACA,cAAA,WACC,OAAA,CAAQ,SAAA;AAAA,iBAKW,eAAA,CACpB,OAAA,WACC,OAAA;EAAU,GAAA;EAAa,OAAA,QAAe,OAAA;AAAA;AAAA,iBAiEnB,gBAAA,CAAiB,SAAA,WAAoB,OAAA;AAAA,iBAarC,iBAAA,CACpB,SAAA,UACA,WAAA,UACA,QAAA,YACA,OAAA;EAAW,QAAA;EAAmB,OAAA;EAAoB,YAAA,GAAe,MAAA;AAAA,IAChE,OAAA;AAAA,iBAoGmB,iBAAA,CACpB,WAAA,UACA,IAAA;EACE,cAAA;EACA,cAAA;EACA,OAAA;EACA,MAAA;EACA,OAAA;EACA,YAAA,GAAe,MAAA;EACf,aAAA;IAAkB,cAAA;IAA0B,SAAA;EAAA;EAC5C,IAAA;EACA,QAAA;AAAA,IAED,OAAA;AAAA,iBAuMmB,aAAA,CAAc,WAAA,WAAsB,OAAA;AAAA,iBAIpC,WAAA,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,UACA,SAAA,UACA,QAAA,YACA,OAAA;EAAW,QAAA;EAAmB,OAAA;EAAoB,YAAA,GAAe,MAAA;AAAA,IAChE,OAAA;AAAA,iBA2EmB,0BAAA,CAA2B,WAAA,WAAsB,OAAA;AAAA,iBAuBvD,WAAA,CAAY,OAAA,UAAiB,IAAA,YAAgB,GAAA,YAAe,OAAA"}
package/dist/cli/init.mjs CHANGED
@@ -1,8 +1,10 @@
1
1
  import { fetchBosConfigFromFastKv } from "../fastkv.mjs";
2
2
  import { loadManifestNormalizationSpec, normalizePackageManifestsInTree } from "../internal/manifest-normalizer.mjs";
3
+ import { isPathExcluded } from "../utils/path-match.mjs";
4
+ import { saveBosConfig } from "../utils/save-config.mjs";
3
5
  import { writeSnapshot } from "./snapshot.mjs";
4
6
  import { createRequire } from "node:module";
5
- import { createWriteStream, existsSync, lstatSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
7
+ import { createWriteStream, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
8
  import { dirname, join, resolve } from "node:path";
7
9
  import { createHash } from "node:crypto";
8
10
  import { spawn } from "node:child_process";
@@ -12,23 +14,6 @@ import { glob } from "glob";
12
14
 
13
15
  //#region src/cli/init.ts
14
16
  const require = createRequire(import.meta.url);
15
- const BOS_CONFIG_ORDER = [
16
- "extends",
17
- "account",
18
- "domain",
19
- "testnet",
20
- "staging",
21
- "repository",
22
- "app",
23
- "plugins",
24
- "shared"
25
- ];
26
- function rebuildOrderedConfig(config) {
27
- const ordered = {};
28
- for (const key of BOS_CONFIG_ORDER) if (key in config) ordered[key] = config[key];
29
- for (const key of Object.keys(config)) if (!BOS_CONFIG_ORDER.includes(key)) ordered[key] = config[key];
30
- return ordered;
31
- }
32
17
  async function resolveSourceDir(opts) {
33
18
  if (opts.source) {
34
19
  const sourceDir = resolve(opts.source);
@@ -48,6 +33,11 @@ async function resolveSourceDir(opts) {
48
33
  cleanup
49
34
  };
50
35
  }
36
+ async function readTemplatekeep(sourceDir) {
37
+ const keepFile = join(sourceDir, ".templatekeep");
38
+ if (!existsSync(keepFile)) return [];
39
+ return readFileSync(keepFile, "utf-8").split("\n").map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
40
+ }
51
41
  async function fetchParentConfig(extendsAccount, extendsGateway) {
52
42
  return fetchBosConfigFromFastKv(`bos://${extendsAccount}/${extendsGateway}`);
53
43
  }
@@ -124,11 +114,6 @@ function parseGitHubUrl(url) {
124
114
  };
125
115
  return null;
126
116
  }
127
- async function readTemplatekeep(sourceDir) {
128
- const keepFile = join(sourceDir, ".templatekeep");
129
- if (!existsSync(keepFile)) return [];
130
- return readFileSync(keepFile, "utf-8").split("\n").map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
131
- }
132
117
  async function copyFilteredFiles(sourceDir, destination, patterns, options) {
133
118
  if (patterns.length === 0) return 0;
134
119
  const filteredPatterns = (options.withHost ? [...patterns, "host/**"] : patterns.filter((p) => !p.startsWith("host/") && p !== "host/**")).filter((p) => {
@@ -155,7 +140,7 @@ async function copyFilteredFiles(sourceDir, destination, patterns, options) {
155
140
  const pluginName = pluginMatch[1];
156
141
  if (!(options.plugins?.includes(pluginName) ?? true)) continue;
157
142
  }
158
- if (isRouteExcluded(match, excludedRoutePatterns)) continue;
143
+ if (isPathExcluded(match, excludedRoutePatterns)) continue;
159
144
  allFiles.add(match);
160
145
  }
161
146
  }
@@ -169,7 +154,7 @@ async function copyFilteredFiles(sourceDir, destination, patterns, options) {
169
154
  dot: true,
170
155
  absolute: false
171
156
  });
172
- for (const match of matches) if (!isRouteExcluded(match, excludedRoutePatterns)) routeFiles.add(match);
157
+ for (const match of matches) if (!isPathExcluded(match, excludedRoutePatterns)) routeFiles.add(match);
173
158
  }
174
159
  }
175
160
  for (const f of routeFiles) allFiles.add(f);
@@ -185,14 +170,6 @@ async function copyFilteredFiles(sourceDir, destination, patterns, options) {
185
170
  }
186
171
  return count;
187
172
  }
188
- function isRouteExcluded(filePath, excludedPatterns) {
189
- if (excludedPatterns.length === 0) return false;
190
- for (const pattern of excludedPatterns) if (pattern.endsWith("/**")) {
191
- const prefix = pattern.slice(0, -3);
192
- if (filePath.startsWith(`${prefix}/`) || filePath === prefix) return true;
193
- } else if (filePath === pattern || filePath.startsWith(`${pattern}/`)) return true;
194
- return false;
195
- }
196
173
  async function personalizeConfig(destination, opts) {
197
174
  const isInit = opts.mode !== "sync";
198
175
  const configPath = join(destination, "bos.config.json");
@@ -219,17 +196,86 @@ async function personalizeConfig(destination, opts) {
219
196
  if (opts.plugins && opts.plugins.length > 0) {
220
197
  for (const pluginKey of Object.keys(plugins)) if (!opts.plugins.includes(pluginKey)) delete plugins[pluginKey];
221
198
  }
222
- if (isInit) for (const pluginKey of Object.keys(plugins)) {
223
- const plugin = plugins[pluginKey];
224
- if (plugin && typeof plugin === "object") {
225
- const p = plugin;
226
- delete p.production;
227
- delete p.integrity;
199
+ if (isInit) {
200
+ const parentDomain = opts.extendsGateway;
201
+ for (const pluginKey of Object.keys(plugins)) {
202
+ const plugin = plugins[pluginKey];
203
+ let pluginObj;
204
+ if (typeof plugin === "string") {
205
+ pluginObj = { extends: plugin };
206
+ plugins[pluginKey] = pluginObj;
207
+ } else if (plugin && typeof plugin === "object") pluginObj = { ...plugin };
208
+ else continue;
209
+ if (pluginObj.development && typeof pluginObj.development === "string" && pluginObj.development.startsWith("local:")) {
210
+ const pluginDir = join(destination, pluginObj.development.slice(6));
211
+ const pluginConfigPath = join(pluginDir, "bos.config.json");
212
+ if (existsSync(pluginConfigPath)) try {
213
+ const pluginConfig = JSON.parse(readFileSync(pluginConfigPath, "utf-8"));
214
+ delete pluginConfig.extends;
215
+ if (pluginConfig.app && typeof pluginConfig.app === "object") {
216
+ const app = pluginConfig.app;
217
+ for (const entryKey of Object.keys(app)) {
218
+ const entry = app[entryKey];
219
+ if (entry && typeof entry === "object") {
220
+ const e = entry;
221
+ delete e.production;
222
+ delete e.integrity;
223
+ }
224
+ }
225
+ }
226
+ writeFileSync(pluginConfigPath, `${JSON.stringify(pluginConfig, null, 2)}\n`);
227
+ } catch {}
228
+ else if (existsSync(pluginDir)) {
229
+ const pluginConfig = {};
230
+ pluginConfig.domain = `${pluginKey}.${opts.domain ?? parentDomain}`;
231
+ pluginConfig.app = { api: { development: "local:." } };
232
+ if (opts.pluginRoutes?.[pluginKey]) pluginConfig.routes = opts.pluginRoutes[pluginKey];
233
+ if (pluginObj.sidebar) pluginConfig.sidebar = pluginObj.sidebar;
234
+ mkdirSync(pluginDir, { recursive: true });
235
+ writeFileSync(pluginConfigPath, `${JSON.stringify(pluginConfig, null, 2)}\n`);
236
+ }
237
+ const cleanEntry = { development: pluginObj.development };
238
+ if (pluginObj.extends) cleanEntry.extends = pluginObj.extends;
239
+ if (pluginObj.secrets) cleanEntry.secrets = pluginObj.secrets;
240
+ if (pluginObj.variables) cleanEntry.variables = pluginObj.variables;
241
+ plugins[pluginKey] = cleanEntry;
242
+ } else {
243
+ delete pluginObj.production;
244
+ delete pluginObj.integrity;
245
+ delete pluginObj.sidebar;
246
+ delete pluginObj.routes;
247
+ }
228
248
  }
249
+ } else for (const pluginKey of Object.keys(plugins)) {
250
+ const pluginConfigPath = join(resolve(destination, plugins[pluginKey]?.development?.toString()?.slice(6) ?? ""), "bos.config.json");
251
+ if (!existsSync(pluginConfigPath)) continue;
252
+ try {
253
+ const pluginConfig = JSON.parse(readFileSync(pluginConfigPath, "utf-8"));
254
+ let changed = false;
255
+ if ("extends" in pluginConfig) {
256
+ delete pluginConfig.extends;
257
+ changed = true;
258
+ }
259
+ if (pluginConfig.app && typeof pluginConfig.app === "object") {
260
+ const app = pluginConfig.app;
261
+ for (const entryKey of Object.keys(app)) {
262
+ const entry = app[entryKey];
263
+ if (entry && typeof entry === "object") {
264
+ const e = entry;
265
+ if ("production" in e || "integrity" in e) {
266
+ delete e.production;
267
+ delete e.integrity;
268
+ changed = true;
269
+ }
270
+ }
271
+ }
272
+ }
273
+ if (changed) writeFileSync(pluginConfigPath, `${JSON.stringify(pluginConfig, null, 2)}\n`);
274
+ } catch {}
229
275
  }
230
276
  if (Object.keys(plugins).length === 0) config.plugins = {};
231
277
  }
232
- writeFileSync(configPath, `${JSON.stringify(rebuildOrderedConfig(config), null, 2)}\n`);
278
+ await saveBosConfig(destination, config);
233
279
  }
234
280
  const pkgPath = join(destination, "package.json");
235
281
  if (existsSync(pkgPath)) {
@@ -250,14 +296,14 @@ async function personalizeConfig(destination, opts) {
250
296
  const rewrite = (key, from, to) => {
251
297
  if (scripts[key]?.includes(from)) scripts[key] = scripts[key].replaceAll(from, to);
252
298
  };
253
- rewrite("dev", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
254
- rewrite("dev:ui", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
255
- rewrite("dev:api", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
256
- rewrite("dev:proxy", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
257
- rewrite("build", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
258
- rewrite("deploy", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
259
- rewrite("publish", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
260
- rewrite("start", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
299
+ rewrite("dev", "packages/everything-dev/src/cli.ts", "node_modules/.bin/bos");
300
+ rewrite("dev:ui", "packages/everything-dev/src/cli.ts", "node_modules/.bin/bos");
301
+ rewrite("dev:api", "packages/everything-dev/src/cli.ts", "node_modules/.bin/bos");
302
+ rewrite("dev:proxy", "packages/everything-dev/src/cli.ts", "node_modules/.bin/bos");
303
+ rewrite("build", "packages/everything-dev/src/cli.ts", "node_modules/.bin/bos");
304
+ rewrite("deploy", "packages/everything-dev/src/cli.ts", "node_modules/.bin/bos");
305
+ rewrite("publish", "packages/everything-dev/src/cli.ts", "node_modules/.bin/bos");
306
+ rewrite("start", "packages/everything-dev/src/cli.ts", "node_modules/.bin/bos");
261
307
  scripts.postinstall = "node_modules/.bin/bos types gen || true";
262
308
  scripts["types:gen"] = "node_modules/.bin/bos types gen";
263
309
  if (scripts.typecheck) {
@@ -310,22 +356,64 @@ async function personalizeConfig(destination, opts) {
310
356
  mkdirSync(dirname(pluginsClientGenPath), { recursive: true });
311
357
  writeFileSync(pluginsClientGenPath, `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`);
312
358
  }
313
- const authTypesGenPath = join(destination, "ui", "src", "lib", "auth-types.gen.ts");
314
- if (!existsSync(authTypesGenPath)) {
359
+ const authTypesContent = generateAuthTypesTemplate();
360
+ const authTypesPaths = [join(destination, "ui", "src", "lib", "auth-types.gen.ts"), join(destination, "api", "src", "lib", "auth-types.gen.ts")];
361
+ if (existsSync(join(destination, "host", "src"))) authTypesPaths.push(join(destination, "host", "src", "lib", "auth-types.gen.ts"));
362
+ for (const authTypesGenPath of authTypesPaths) if (!existsSync(authTypesGenPath)) {
315
363
  mkdirSync(dirname(authTypesGenPath), { recursive: true });
316
- writeFileSync(authTypesGenPath, `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`);
317
- }
318
- const apiAuthTypesGenPath = join(destination, "api", "src", "lib", "auth-types.gen.ts");
319
- if (!existsSync(apiAuthTypesGenPath)) {
320
- mkdirSync(dirname(apiAuthTypesGenPath), { recursive: true });
321
- writeFileSync(apiAuthTypesGenPath, `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`);
322
- }
323
- const hostAuthTypesGenPath = join(destination, "host", "src", "lib", "auth-types.gen.ts");
324
- if (existsSync(join(destination, "host", "src")) && !existsSync(hostAuthTypesGenPath)) {
325
- mkdirSync(dirname(hostAuthTypesGenPath), { recursive: true });
326
- writeFileSync(hostAuthTypesGenPath, `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`);
364
+ writeFileSync(authTypesGenPath, authTypesContent);
327
365
  }
328
366
  }
367
+ function generateAuthTypesTemplate() {
368
+ return `import type { Auth } from "better-auth";
369
+ export type { Auth } from "better-auth";
370
+ export type AuthSessionUser = NonNullable<Auth["$Infer"]["Session"]["user"]> & {
371
+ role?: string | null;
372
+ isAnonymous?: boolean | null;
373
+ walletAddress?: string | null;
374
+ banned?: boolean | null;
375
+ };
376
+ export type AuthSessionData = NonNullable<Auth["$Infer"]["Session"]["session"]> & {
377
+ activeOrganizationId?: string | null;
378
+ };
379
+ export type AuthSession = {
380
+ user: AuthSessionUser | null;
381
+ session: AuthSessionData | null;
382
+ };
383
+ export interface AuthOrganizationContext {
384
+ activeOrganizationId: string | null;
385
+ organization: { id: string; name: string; slug: string; logo?: string | null; metadata?: Record<string, unknown> } | null;
386
+ member: { id: string; role: string } | null;
387
+ isPersonal: boolean;
388
+ hasOrganization: boolean;
389
+ }
390
+ export interface AuthRequestContext {
391
+ user: AuthSessionUser | null;
392
+ userId: string | null;
393
+ isAuthenticated: boolean;
394
+ authMethod: "session" | "apiKey" | "anonymous" | "none";
395
+ near: {
396
+ primaryAccountId: string | null;
397
+ linkedAccounts: Array<{ accountId: string; network: string; publicKey: string; isPrimary: boolean }>;
398
+ hasNearAccount: boolean;
399
+ };
400
+ organization: AuthOrganizationContext;
401
+ organizations?: Array<{ id: string; role: string; name?: string; slug?: string }>;
402
+ }
403
+ export type AuthActiveMember = { id: string | null; role: string | null; organizationId: string | null };
404
+ export type AuthOrganization = NonNullable<AuthOrganizationContext["organization"]>;
405
+ export type AuthOrganizationMember = NonNullable<AuthOrganizationContext["member"]>;
406
+ export type AuthOrganizationSummary = NonNullable<AuthRequestContext["organizations"]>[number];
407
+ export type AuthBaseSession = Auth["$Infer"]["Session"];
408
+ export type createAuthInstance = never;
409
+ export interface AuthServices {
410
+ auth: Auth;
411
+ db: unknown;
412
+ driver: { close(): Promise<void> };
413
+ handler: (req: Request) => Promise<Response>;
414
+ }
415
+ `;
416
+ }
329
417
  async function runBunInstall(destination) {
330
418
  await execCommand("bun", ["install", "--ignore-scripts"], destination);
331
419
  }
@@ -382,7 +470,7 @@ async function writeInitSnapshot(destination, extendsAccount, extendsGateway, so
382
470
  for (const match of matches) {
383
471
  const pluginMatch = match.match(/^plugins\/([^/]+)/);
384
472
  if (pluginMatch && !(options.plugins?.includes(pluginMatch[1]) ?? true)) continue;
385
- if (isRouteExcluded(match, excludedRoutePatterns)) continue;
473
+ if (isPathExcluded(match, excludedRoutePatterns)) continue;
386
474
  allFiles.add(match);
387
475
  }
388
476
  }
@@ -395,7 +483,7 @@ async function writeInitSnapshot(destination, extendsAccount, extendsGateway, so
395
483
  dot: true,
396
484
  absolute: false
397
485
  });
398
- for (const match of matches) if (!isRouteExcluded(match, excludedRoutePatterns)) allFiles.add(match);
486
+ for (const match of matches) if (!isPathExcluded(match, excludedRoutePatterns)) allFiles.add(match);
399
487
  }
400
488
  }
401
489
  const fileHashes = {};
@@ -415,18 +503,7 @@ function computeHash(data) {
415
503
  return createHash("sha256").update(data).digest("hex").substring(0, 16);
416
504
  }
417
505
  function mkTmpDir(prefix) {
418
- const base = join(tmpdir(), prefix);
419
- let attempt = 0;
420
- while (true) {
421
- const dir = `${base}-${Date.now()}-${attempt}`;
422
- try {
423
- mkdirSync(dir, { recursive: true });
424
- return dir;
425
- } catch {
426
- attempt++;
427
- if (attempt > 10) throw new Error("Failed to create temp directory");
428
- }
429
- }
506
+ return mkdtempSync(join(tmpdir(), `${prefix}-`));
430
507
  }
431
508
  async function generateDatabaseMigrations(destination) {
432
509
  const drizzleConfigs = await glob("**/drizzle.config.ts", {