everything-dev 1.14.4 → 1.16.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 (54) hide show
  1. package/dist/cli/init.cjs +6 -18
  2. package/dist/cli/init.cjs.map +1 -1
  3. package/dist/cli/init.d.cts.map +1 -1
  4. package/dist/cli/init.d.mts.map +1 -1
  5. package/dist/cli/init.mjs +6 -18
  6. package/dist/cli/init.mjs.map +1 -1
  7. package/dist/cli/prompts.cjs +8 -8
  8. package/dist/cli/prompts.cjs.map +1 -1
  9. package/dist/cli/prompts.mjs +8 -8
  10. package/dist/cli/prompts.mjs.map +1 -1
  11. package/dist/config.cjs +2 -0
  12. package/dist/config.cjs.map +1 -1
  13. package/dist/config.d.cts.map +1 -1
  14. package/dist/config.d.mts.map +1 -1
  15. package/dist/config.mjs +2 -0
  16. package/dist/config.mjs.map +1 -1
  17. package/dist/contract.d.cts +4 -0
  18. package/dist/contract.d.cts.map +1 -1
  19. package/dist/contract.d.mts +4 -0
  20. package/dist/contract.d.mts.map +1 -1
  21. package/dist/merge.cjs +2 -0
  22. package/dist/merge.cjs.map +1 -1
  23. package/dist/merge.d.cts +1 -1
  24. package/dist/merge.d.cts.map +1 -1
  25. package/dist/merge.d.mts +1 -1
  26. package/dist/merge.d.mts.map +1 -1
  27. package/dist/merge.mjs +2 -0
  28. package/dist/merge.mjs.map +1 -1
  29. package/dist/near-cli.cjs +29 -52
  30. package/dist/near-cli.cjs.map +1 -1
  31. package/dist/near-cli.mjs +29 -52
  32. package/dist/near-cli.mjs.map +1 -1
  33. package/dist/plugin.cjs +15 -7
  34. package/dist/plugin.cjs.map +1 -1
  35. package/dist/plugin.d.cts +5 -0
  36. package/dist/plugin.d.mts +5 -0
  37. package/dist/plugin.mjs +15 -7
  38. package/dist/plugin.mjs.map +1 -1
  39. package/dist/types.cjs +4 -0
  40. package/dist/types.cjs.map +1 -1
  41. package/dist/types.d.cts +7 -0
  42. package/dist/types.d.cts.map +1 -1
  43. package/dist/types.d.mts +7 -0
  44. package/dist/types.d.mts.map +1 -1
  45. package/dist/types.mjs +4 -0
  46. package/dist/types.mjs.map +1 -1
  47. package/package.json +2 -1
  48. package/src/cli/init.ts +4 -24
  49. package/src/cli/prompts.ts +12 -8
  50. package/src/config.ts +2 -0
  51. package/src/merge.ts +2 -0
  52. package/src/near-cli.ts +42 -69
  53. package/src/plugin.ts +38 -19
  54. package/src/types.ts +6 -0
package/dist/cli/init.cjs CHANGED
@@ -8,10 +8,10 @@ const require_snapshot = require('./snapshot.cjs');
8
8
  let node_fs = require("node:fs");
9
9
  let node_path = require("node:path");
10
10
  let node_crypto = require("node:crypto");
11
- let node_child_process = require("node:child_process");
12
11
  let node_module = require("node:module");
13
12
  let node_os = require("node:os");
14
13
  let node_stream_promises = require("node:stream/promises");
14
+ let execa = require("execa");
15
15
  let glob = require("glob");
16
16
 
17
17
  //#region src/cli/init.ts
@@ -195,7 +195,7 @@ async function personalizeConfig(destination, opts) {
195
195
  }
196
196
  if (config.plugins && typeof config.plugins === "object") {
197
197
  const plugins = config.plugins;
198
- if (opts.plugins && opts.plugins.length > 0) {
198
+ if (opts.plugins !== void 0) {
199
199
  for (const pluginKey of Object.keys(plugins)) if (!opts.plugins.includes(pluginKey)) delete plugins[pluginKey];
200
200
  }
201
201
  if (isInit) {
@@ -523,22 +523,10 @@ async function generateDatabaseMigrations(destination) {
523
523
  await execCommand("bun", ["run", "db:generate"], (0, node_path.join)(destination, workspaceDir));
524
524
  }
525
525
  }
526
- function execCommand(command, args, cwd) {
527
- return new Promise((resolve, reject) => {
528
- const child = (0, node_child_process.spawn)(command, args, {
529
- cwd,
530
- stdio: "pipe",
531
- shell: true
532
- });
533
- let stderr = "";
534
- child.stderr?.on("data", (data) => {
535
- stderr += data.toString();
536
- });
537
- child.on("close", (code) => {
538
- if (code === 0) resolve();
539
- else reject(/* @__PURE__ */ new Error(`Command '${command} ${args.join(" ")}' failed with exit code ${code}: ${stderr}`));
540
- });
541
- child.on("error", reject);
526
+ async function execCommand(command, args, cwd) {
527
+ await (0, execa.execa)(command, args, {
528
+ cwd,
529
+ stdio: "pipe"
542
530
  });
543
531
  }
544
532
 
@@ -1 +1 @@
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 ${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AAc,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 { 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 { execa } from \"execa\";\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 !== undefined) {\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 async function execCommand(command: string, args: string[], cwd?: string): Promise<void> {\n await execa(command, args, { cwd, stdio: \"pipe\" });\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,KAAK,CACX,KAAK,SAAS,KAAK,MAAM,CAAC,CAC1B,QAAQ,SAAS,KAAK,SAAS,KAAK,CAAC,KAAK,WAAW,IAAI,CAAC;;AAG/D,eAAsB,kBACpB,gBACA,gBACoB;AAEpB,QAAOC,wCADQ,SAAS,eAAe,GAAG,iBACQ;;AAGpD,eAAsB,gBACpB,SACwD;CACxD,MAAM,SAAS,eAAe,QAAQ;AACtC,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,gCAAgC,UAAU;CAG5D,MAAM,EAAE,OAAO,MAAM,WAAW;CAChC,MAAM,aAAa,gCAAgC,MAAM,GAAG,KAAK,WAAW;CAE5E,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file":"init.d.mts","names":[],"sources":["../../src/cli/init.ts"],"mappings":";;;UA6BU,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,gBAAA,CAAiB,SAAA,WAAoB,OAAA;AAAA,iBAarC,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,iBAAA,CACpB,SAAA,UACA,WAAA,UACA,QAAA,YACA,OAAA;EAAW,QAAA;EAAmB,OAAA;EAAoB,YAAA,GAAe,MAAA;AAAA,IAChE,OAAA;AAAA,iBAuFmB,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,iBA6VmB,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,iBA2EmB,0BAAA,CAA2B,WAAA,WAAsB,OAAA;AAAA,iBAuBjD,WAAA,CAAY,OAAA,UAAiB,IAAA,YAAgB,GAAA,YAAe,OAAA"}
package/dist/cli/init.mjs CHANGED
@@ -7,9 +7,9 @@ import { createRequire } from "node:module";
7
7
  import { createWriteStream, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
8
8
  import { dirname, join, resolve } from "node:path";
9
9
  import { createHash } from "node:crypto";
10
- import { spawn } from "node:child_process";
11
10
  import { tmpdir } from "node:os";
12
11
  import { pipeline } from "node:stream/promises";
12
+ import { execa } from "execa";
13
13
  import { glob } from "glob";
14
14
 
15
15
  //#region src/cli/init.ts
@@ -193,7 +193,7 @@ async function personalizeConfig(destination, opts) {
193
193
  }
194
194
  if (config.plugins && typeof config.plugins === "object") {
195
195
  const plugins = config.plugins;
196
- if (opts.plugins && opts.plugins.length > 0) {
196
+ if (opts.plugins !== void 0) {
197
197
  for (const pluginKey of Object.keys(plugins)) if (!opts.plugins.includes(pluginKey)) delete plugins[pluginKey];
198
198
  }
199
199
  if (isInit) {
@@ -521,22 +521,10 @@ async function generateDatabaseMigrations(destination) {
521
521
  await execCommand("bun", ["run", "db:generate"], join(destination, workspaceDir));
522
522
  }
523
523
  }
524
- function execCommand(command, args, cwd) {
525
- return new Promise((resolve, reject) => {
526
- const child = spawn(command, args, {
527
- cwd,
528
- stdio: "pipe",
529
- shell: true
530
- });
531
- let stderr = "";
532
- child.stderr?.on("data", (data) => {
533
- stderr += data.toString();
534
- });
535
- child.on("close", (code) => {
536
- if (code === 0) resolve();
537
- else reject(/* @__PURE__ */ new Error(`Command '${command} ${args.join(" ")}' failed with exit code ${code}: ${stderr}`));
538
- });
539
- child.on("error", reject);
524
+ async function execCommand(command, args, cwd) {
525
+ await execa(command, args, {
526
+ cwd,
527
+ stdio: "pipe"
540
528
  });
541
529
  }
542
530
 
@@ -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 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,KAA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Q,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 { 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 { execa } from \"execa\";\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 !== undefined) {\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 async function execCommand(command: string, args: string[], cwd?: string): Promise<void> {\n await execa(command, args, { cwd, stdio: \"pipe\" });\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAM,UAAU,cAAc,OAAO,KAAK,I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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,eAAsB,YAAY,SAAiB,MAAgB,KAA6B;AAC9F,OAAM,MAAM,SAAS,MAAM;EAAE;EAAK,OAAO;EAAQ,CAAC"}
@@ -18,10 +18,6 @@ function deriveAccountFromDomain(domain, extendsAccount) {
18
18
  if (!firstSegment) return "";
19
19
  return `${firstSegment}.${extendsAccount.includes(".") ? extendsAccount.substring(extendsAccount.indexOf(".") + 1) : extendsAccount}`;
20
20
  }
21
- const AVAILABLE_PLUGINS = [{
22
- value: "settings",
23
- label: "settings"
24
- }];
25
21
  async function promptInitOptions(input) {
26
22
  _clack_prompts.intro("Let's build an app...");
27
23
  const domain = input.domain ?? await _clack_prompts.text({
@@ -53,12 +49,16 @@ async function promptInitOptions(input) {
53
49
  });
54
50
  if (_clack_prompts.isCancel(account)) node_process.default.exit(0);
55
51
  const directory = input.directory || domain || extendsGateway;
56
- const plugins = input.plugins ?? await _clack_prompts.multiselect({
52
+ const parentPlugins = input.parentPluginKeys ?? [];
53
+ const pluginOptions = parentPlugins.length > 0 ? parentPlugins.map((key) => ({
54
+ value: key,
55
+ label: key
56
+ })) : [];
57
+ const plugins = input.plugins ?? (pluginOptions.length > 0 ? await _clack_prompts.multiselect({
57
58
  message: "Select plugins:",
58
- options: AVAILABLE_PLUGINS,
59
- initialValues: ["settings"],
59
+ options: pluginOptions,
60
60
  required: false
61
- });
61
+ }) : []);
62
62
  if (_clack_prompts.isCancel(plugins)) node_process.default.exit(0);
63
63
  const go = input.withHost !== void 0 ? true : await _clack_prompts.confirm({
64
64
  message: "GO!",
@@ -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: \"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,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;CAAY,OAAO;CAAY,CAAC;AAEpE,eAAsB,kBAAkB,OAiBrC;AACD,gBAAE,MAAM,wBAAwB;CAEhC,MAAM,SACJ,MAAM,UACJ,MAAMA,eAAE,KAAK;EACb,SAAS;EACT,aAAa;EACd,CAAC;AAEJ,KAAIA,eAAE,SAAS,OAAO,CAAE,sBAAQ,KAAK,EAAE;CAGvC,MAAM,eACJ,MAAM,WACJ,MAAMA,eAAE,KAAK;EACb,SAAS;EACT,aALuB;EAMxB,CAAC;AAEJ,KAAIA,eAAE,SAAS,aAAa,CAAE,sBAAQ,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,MAAMA,eAAE,KAAK;EACb,SAAS;EACT,aAAa,kBAAkB;EAC/B,cAAc;EACf,CAAC;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,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"}
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\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 parentPluginKeys?: string[];\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 parentPlugins = input.parentPluginKeys ?? [];\n const pluginOptions =\n parentPlugins.length > 0 ? parentPlugins.map((key) => ({ value: key, label: key })) : [];\n\n const plugins =\n input.plugins ??\n (pluginOptions.length > 0\n ? ((await p.multiselect({\n message: \"Select plugins:\",\n options: pluginOptions,\n required: false,\n })) as string[])\n : []);\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,eAAsB,kBAAkB,OAkBrC;AACD,gBAAE,MAAM,wBAAwB;CAEhC,MAAM,SACJ,MAAM,UACJ,MAAMA,eAAE,KAAK;EACb,SAAS;EACT,aAAa;EACd,CAAC;AAEJ,KAAIA,eAAE,SAAS,OAAO,CAAE,sBAAQ,KAAK,EAAE;CAGvC,MAAM,eACJ,MAAM,WACJ,MAAMA,eAAE,KAAK;EACb,SAAS;EACT,aALuB;EAMxB,CAAC;AAEJ,KAAIA,eAAE,SAAS,aAAa,CAAE,sBAAQ,KAAK,EAAE;CAE7C,IAAI,iBAAiB,MAAM,kBAAkB;CAC7C,IAAI,iBAAiB,MAAM,kBAAkB;AAE7C,KAAI,cAAc;EAChB,MAAM,SAAS,gBAAgB,aAAa;AAC5C,MAAI,QAAQ;AACV,oBAA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