everything-dev 1.26.0 → 1.26.1

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.
@@ -1 +1 @@
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 type { OverrideSection } from \"../contract\";\nimport { fetchBosConfigFromFastKv } from \"../fastkv\";\nimport {\n loadManifestNormalizationSpec,\n normalizePackageManifestsInTree,\n} from \"../internal/manifest-normalizer\";\nimport type { BosConfig, BosConfigInput } 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\nconst FRAMEWORK_PACKAGES = [\"every-plugin\", \"everything-dev\"] as const;\n\nconst _DEFAULT_OVERRIDES: OverrideSection[] = [\"ui\", \"api\"];\n\nconst OVERRIDE_WORKSPACE_MAP: Record<OverrideSection, string[]> = {\n ui: [\"ui\"],\n api: [\"api\"],\n host: [\"host\"],\n plugins: [],\n};\n\ninterface SourceResult {\n sourceDir: string;\n parentConfig: BosConfig;\n cleanup: () => Promise<void>;\n}\n\nexport async function resolveSourceDir(opts: {\n extendsAccount: string;\n extendsGateway: string;\n source?: string;\n}): Promise<SourceResult> {\n if (opts.source) {\n const sourceDir = resolve(opts.source);\n if (!existsSync(join(sourceDir, \"bos.config.json\"))) {\n throw new Error(`No bos.config.json found in source directory: ${sourceDir}`);\n }\n const parentConfig = JSON.parse(\n readFileSync(join(sourceDir, \"bos.config.json\"), \"utf-8\"),\n ) as BosConfig;\n return { sourceDir, parentConfig, cleanup: async () => {} };\n }\n\n const parentConfig = await fetchParentConfig(opts.extendsAccount, opts.extendsGateway);\n\n if (parentConfig.repository) {\n const { dir: sourceDir, cleanup } = await downloadTarball(parentConfig.repository);\n return { sourceDir, parentConfig, cleanup };\n }\n\n const chainResult = await resolveRepositoryViaExtendsChain(\n opts.extendsAccount,\n opts.extendsGateway,\n );\n if (chainResult?.repository) {\n const { dir: sourceDir, cleanup } = await downloadTarball(chainResult.repository);\n return { sourceDir, parentConfig: chainResult.config, cleanup };\n }\n\n return {\n sourceDir: \"\",\n parentConfig,\n cleanup: async () => {},\n };\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 const patterns = content\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => line.length > 0 && !line.startsWith(\"#\"));\n\n if (!patterns.includes(\".templatekeep\")) {\n patterns.unshift(\".templatekeep\");\n }\n\n return patterns;\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 resolveRepositoryViaExtendsChain(\n extendsAccount: string,\n extendsGateway: string,\n visited = new Set<string>(),\n): Promise<{ repository: string; config: BosConfig } | null> {\n const key = `bos://${extendsAccount}/${extendsGateway}`;\n if (visited.has(key)) return null;\n visited.add(key);\n\n try {\n const config = await fetchParentConfig(extendsAccount, extendsGateway);\n if (config.repository) {\n return { repository: config.repository, config };\n }\n\n const extendsRef = config.extends;\n if (extendsRef && typeof extendsRef === \"string\") {\n const normalized = extendsRef.startsWith(\"bos://\") ? extendsRef : `bos://${extendsRef}`;\n const match = normalized.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (match) {\n const result = await resolveRepositoryViaExtendsChain(match[1], match[2], visited);\n if (result) return result;\n }\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\nexport async function detectGitRemoteUrl(directory: string): Promise<string | undefined> {\n try {\n const { stdout } = await execa(\"git\", [\"remote\", \"get-url\", \"origin\"], {\n cwd: directory,\n stdio: \"pipe\",\n });\n const url = stdout.trim();\n if (!url) return undefined;\n return normalizeGitUrl(url);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeGitUrl(url: string): string | undefined {\n const sshMatch = url.match(/^git@github\\.com:([^/]+)\\/([^/]+?)(?:\\.git)?$/);\n if (sshMatch) {\n return `https://github.com/${sshMatch[1]}/${sshMatch[2]}`;\n }\n const httpsMatch = url.match(/^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?(?:\\/.*)?$/);\n if (httpsMatch) {\n return `https://github.com/${httpsMatch[1]}/${httpsMatch[2]}`;\n }\n return url.endsWith(\".git\") ? url.slice(0, -4) : url;\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\nfunction filterPatternsByOverrides(\n patterns: string[],\n overrides: OverrideSection[],\n _plugins?: string[],\n): string[] {\n const has = (section: OverrideSection) => overrides.includes(section);\n let filtered = [...patterns];\n\n if (!has(\"host\")) {\n filtered = filtered.filter((p) => !p.startsWith(\"host/\") && p !== \"host/**\");\n }\n if (!has(\"ui\")) {\n filtered = filtered.filter((p) => !p.startsWith(\"ui/\") && p !== \"ui/**\");\n }\n if (!has(\"api\")) {\n filtered = filtered.filter((p) => !p.startsWith(\"api/\") && p !== \"api/**\");\n }\n if (!has(\"plugins\")) {\n filtered = filtered.filter((p) => !p.startsWith(\"plugins/\") && p !== \"plugins/**\");\n }\n\n return filtered;\n}\n\nexport async function copyFilteredFiles(\n sourceDir: string,\n destination: string,\n patterns: string[],\n options: {\n overrides: OverrideSection[];\n plugins?: string[];\n pluginRoutes?: Record<string, string[]>;\n },\n): Promise<number> {\n if (patterns.length === 0) {\n return 0;\n }\n\n const has = (section: OverrideSection) => options.overrides.includes(section);\n\n const effectivePatterns = filterPatternsByOverrides(patterns, options.overrides, options.plugins);\n\n if (has(\"host\") && !effectivePatterns.some((p) => p.startsWith(\"host/\") || p === \"host/**\")) {\n effectivePatterns.push(\"host/**\");\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 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) {\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\nfunction stripProductionFields(entry: Record<string, unknown>): void {\n delete entry.production;\n delete entry.integrity;\n delete entry.ssr;\n delete entry.ssrIntegrity;\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 overrides: OverrideSection[];\n pluginRoutes?: Record<string, string[]>;\n workspaceOpts?: { localOverrides?: boolean; sourceDir?: string };\n mode?: \"init\" | \"sync\";\n repository?: string;\n title?: string;\n description?: string;\n testnet?: string;\n staging?: unknown;\n },\n): Promise<void> {\n const has = (section: OverrideSection) => opts.overrides.includes(section);\n\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 if (opts.repository) {\n config.repository = opts.repository;\n } else {\n delete config.repository;\n }\n\n const inheritableFields = [\"title\", \"description\", \"testnet\", \"staging\"] as const;\n for (const field of inheritableFields) {\n if (!(field in opts)) {\n delete config[field];\n }\n }\n\n if (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 if (\n !has(entryKey as OverrideSection) &&\n (entryKey === \"host\" || entryKey === \"ui\" || entryKey === \"api\" || entryKey === \"auth\")\n ) {\n delete app[entryKey];\n continue;\n }\n const entry = app[entryKey];\n if (entry && typeof entry === \"object\") {\n stripProductionFields(entry as Record<string, unknown>);\n }\n }\n }\n\n if (has(\"plugins\")) {\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 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 plugins[pluginKey] = pluginObj;\n } else {\n continue;\n }\n\n stripProductionFields(pluginObj);\n }\n\n if (Object.keys(plugins).length === 0) {\n delete config.plugins;\n }\n }\n } else {\n delete config.plugins;\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 has(\"host\");\n if (p === \"plugins/*\") return false;\n const pluginMatch = p.match(/^plugins\\/([^/]+)/);\n if (pluginMatch)\n return has(\"plugins\") && (opts.plugins?.includes(pluginMatch[1]) ?? true);\n return true;\n });\n\n if (has(\"plugins\") && (opts.plugins?.length ?? 0) > 0) {\n for (const plugin of opts.plugins ?? []) {\n const pluginWorkspace = `plugins/${plugin}`;\n if (!ws.packages.includes(pluginWorkspace)) {\n ws.packages.push(pluginWorkspace);\n }\n }\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 (!has(\"host\")) {\n scripts.typecheck = scripts.typecheck.replace(/bun run --cwd host tsc --noEmit & ?/, \"\");\n }\n }\n\n if (!scripts.bos) {\n scripts.bos = \"node_modules/.bin/bos\";\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 const frameworkCatalog = resolveFrameworkCatalog();\n for (const [name, version] of Object.entries(frameworkCatalog)) {\n workspaces.catalog[name] = version;\n }\n if (!deps[\"everything-dev\"]) deps[\"everything-dev\"] = \"catalog:\";\n if (!deps[\"every-plugin\"]) 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 if (has(\"ui\")) {\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\n if (has(\"api\")) {\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\n const authTypesContent = generateAuthTypesTemplate();\n const authTypesPaths: string[] = [];\n if (has(\"ui\")) {\n authTypesPaths.push(join(destination, \"ui\", \"src\", \"lib\", \"auth-types.gen.ts\"));\n }\n if (has(\"api\")) {\n authTypesPaths.push(join(destination, \"api\", \"src\", \"lib\", \"auth-types.gen.ts\"));\n }\n if (has(\"host\") && 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(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n await runWithProgress(\n \"bun\",\n [\"install\", \"--ignore-scripts\"],\n destination,\n spinner,\n \"Installing dependencies\",\n );\n}\n\nexport async function runBunInstallForUpgrade(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n await runWithProgress(\"bun\", [\"install\"], destination, spinner, \"Installing dependencies\");\n}\n\nexport async function runTypesGen(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n await runWithProgress(\n \"node_modules/.bin/bos\",\n [\"types\", \"gen\"],\n destination,\n spinner,\n \"Generating types\",\n );\n}\n\nexport async function runDockerComposeUp(destination: string): Promise<void> {\n await execCommand(\"docker\", [\"compose\", \"up\", \"-d\", \"--wait\"], destination, { stdio: \"inherit\" });\n}\n\nasync function runWithProgress(\n command: string,\n args: string[],\n cwd: string,\n spinner: { message: (msg: string) => void } | undefined,\n label: string,\n): Promise<void> {\n const timeout = COMMAND_TIMEOUTS[command] ?? 2 * 60_000;\n const child = execa(command, args, { cwd, stdio: \"inherit\", timeout });\n\n if (spinner) {\n const start = Date.now();\n const interval = setInterval(() => {\n const elapsed = Math.round((Date.now() - start) / 1000);\n spinner.message(`${label}... (${elapsed}s)`);\n }, 2000);\n try {\n await child;\n } finally {\n clearInterval(interval);\n }\n } else {\n await child;\n }\n}\n\nexport function stripOrphanedWorkspacesFromLockfile(\n lockfilePath: string,\n allowedWorkspaces: string[],\n): void {\n if (!existsSync(lockfilePath)) return;\n\n const content = readFileSync(lockfilePath, \"utf-8\");\n let lockfile: Record<string, unknown>;\n try {\n lockfile = JSON.parse(content) as Record<string, unknown>;\n } catch {\n return;\n }\n\n const workspaces = lockfile.workspaces;\n if (!workspaces || typeof workspaces !== \"object\") return;\n\n const workspaceMap = workspaces as Record<string, unknown>;\n const allowed = new Set([\"\", ...allowedWorkspaces]);\n\n const keys = Object.keys(workspaceMap);\n let changed = false;\n for (const key of keys) {\n if (!allowed.has(key)) {\n delete workspaceMap[key];\n changed = true;\n }\n }\n\n if (changed) {\n writeFileSync(lockfilePath, `${JSON.stringify(lockfile, null, 2)}\\n`);\n }\n}\n\nconst WORKSPACE_LOCAL_PATHS: Record<string, string> = {\n \"everything-dev\": \"packages/everything-dev\",\n \"every-plugin\": \"packages/every-plugin\",\n};\n\nfunction resolveFrameworkCatalog(): Record<string, string> {\n const catalog: Record<string, string> = {};\n\n try {\n const selfPkgPath = require.resolve(\"everything-dev/package.json\");\n const selfPkgDir = dirname(selfPkgPath);\n const monorepoPkgPath = join(selfPkgDir, \"..\", \"..\", \"package.json\");\n if (existsSync(monorepoPkgPath)) {\n const monorepoPkg = JSON.parse(readFileSync(monorepoPkgPath, \"utf-8\")) as {\n workspaces?: { catalog?: Record<string, string> };\n };\n const sourceCatalog = monorepoPkg.workspaces?.catalog;\n if (sourceCatalog && typeof sourceCatalog === \"object\") {\n for (const [name, version] of Object.entries(sourceCatalog)) {\n if (typeof version === \"string\") {\n catalog[name] = version;\n }\n }\n }\n }\n } catch {}\n\n try {\n const selfPkgPath = require.resolve(\"everything-dev/package.json\");\n const selfPkg = JSON.parse(readFileSync(selfPkgPath, \"utf-8\")) as {\n version?: string;\n workspaces?: { catalog?: Record<string, string> };\n };\n if (selfPkg.version && !catalog[\"everything-dev\"]) {\n catalog[\"everything-dev\"] = `^${selfPkg.version}`;\n }\n const sourceCatalog = selfPkg.workspaces?.catalog;\n if (sourceCatalog && typeof sourceCatalog === \"object\") {\n for (const [name, version] of Object.entries(sourceCatalog)) {\n if (typeof version === \"string\" && !catalog[name]) {\n catalog[name] = version;\n }\n }\n }\n } catch {}\n\n if (Object.keys(catalog).length > 0) {\n return catalog;\n }\n\n for (const packageName of FRAMEWORK_PACKAGES) {\n try {\n const resolved = require.resolve(`${packageName}/package.json`);\n const pkg = JSON.parse(readFileSync(resolved, \"utf-8\")) as { version?: string };\n if (pkg.version) {\n catalog[packageName] = `^${pkg.version}`;\n }\n } catch {}\n }\n return catalog;\n}\n\nexport async function scaffoldMinimalProject(\n destination: string,\n parentConfig: BosConfigInput,\n opts: {\n extendsAccount: string;\n extendsGateway: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n overrides: OverrideSection[];\n repository?: string;\n title?: string;\n description?: string;\n },\n): Promise<number> {\n mkdirSync(destination, { recursive: true });\n\n const has = (section: OverrideSection) => opts.overrides.includes(section);\n\n const config: Record<string, unknown> = {\n extends: `bos://${opts.extendsAccount}/${opts.extendsGateway}`,\n account: opts.account || opts.extendsAccount,\n ...(opts.domain ? { domain: opts.domain } : {}),\n ...(opts.repository ? { repository: opts.repository } : {}),\n ...(opts.title ? { title: opts.title } : {}),\n ...(opts.description ? { description: opts.description } : {}),\n };\n\n if (parentConfig.app && typeof parentConfig.app === \"object\") {\n const app: Record<string, unknown> = {};\n const parentApp = parentConfig.app as Record<string, Record<string, unknown>>;\n\n if (has(\"host\") && parentApp.host) {\n app.host = { ...parentApp.host };\n stripProductionFields(app.host as Record<string, unknown>);\n }\n\n if (has(\"ui\") && parentApp.ui) {\n app.ui = { ...parentApp.ui };\n stripProductionFields(app.ui as Record<string, unknown>);\n }\n\n if (has(\"api\") && parentApp.api) {\n app.api = { ...parentApp.api };\n stripProductionFields(app.api as Record<string, unknown>);\n }\n\n if (has(\"plugins\") && parentApp.auth) {\n app.auth = { ...parentApp.auth };\n stripProductionFields(app.auth as Record<string, unknown>);\n }\n\n if (Object.keys(app).length > 0) {\n config.app = app;\n }\n }\n\n if (has(\"plugins\") && opts.plugins && opts.plugins.length > 0 && parentConfig.plugins) {\n const plugins: Record<string, unknown> = {};\n for (const key of opts.plugins) {\n const parentPlugin = (parentConfig.plugins as Record<string, unknown>)?.[key];\n if (parentPlugin) {\n if (typeof parentPlugin === \"string\") {\n plugins[key] = { extends: parentPlugin };\n } else {\n const pluginCopy = { ...(parentPlugin as Record<string, unknown>) };\n stripProductionFields(pluginCopy);\n plugins[key] = pluginCopy;\n }\n }\n }\n config.plugins = plugins;\n }\n\n await saveBosConfig(destination, config);\n\n const workspacePackages: string[] = [];\n for (const section of opts.overrides) {\n workspacePackages.push(...OVERRIDE_WORKSPACE_MAP[section]);\n }\n if (has(\"plugins\") && opts.plugins) {\n for (const plugin of opts.plugins) {\n workspacePackages.push(`plugins/${plugin}`);\n }\n }\n\n const catalog = resolveFrameworkCatalog();\n\n const pkg: Record<string, unknown> = {\n name: opts.domain || opts.extendsGateway,\n private: true,\n type: \"module\",\n scripts: {\n dev: \"node_modules/.bin/bos dev --host remote\",\n \"dev:ui\": \"node_modules/.bin/bos dev --ui local --api remote\",\n \"dev:api\": \"node_modules/.bin/bos dev --ui remote --api local\",\n build: \"node_modules/.bin/bos build\",\n deploy: \"node_modules/.bin/bos build --deploy\",\n publish: \"node_modules/.bin/bos publish\",\n start: \"node_modules/.bin/bos start\",\n typecheck: \"node_modules/.bin/bos types gen && tsc --noEmit\",\n postinstall: \"node_modules/.bin/bos types gen || true\",\n \"types:gen\": \"node_modules/.bin/bos types gen\",\n bos: \"node_modules/.bin/bos\",\n },\n dependencies: {\n \"everything-dev\": \"catalog:\",\n \"every-plugin\": \"catalog:\",\n },\n devDependencies: {},\n workspaces: {\n packages: workspacePackages,\n catalog,\n },\n };\n writeFileSync(join(destination, \"package.json\"), `${JSON.stringify(pkg, null, 2)}\\n`);\n\n const envExample = generateEnvExample(parentConfig, opts.overrides);\n if (envExample) {\n writeFileSync(join(destination, \".env.example\"), envExample);\n }\n\n writeFileSync(join(destination, \".gitignore\"), generateGitignore());\n\n return 4;\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: {\n overrides: OverrideSection[];\n plugins?: string[];\n pluginRoutes?: Record<string, string[]>;\n },\n): Promise<void> {\n const effectivePatterns = filterPatternsByOverrides(patterns, options.overrides, options.plugins);\n\n const has = (section: OverrideSection) => options.overrides.includes(section);\n if (has(\"host\") && !effectivePatterns.some((p) => p.startsWith(\"host/\") || p === \"host/**\")) {\n effectivePatterns.push(\"host/**\");\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 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\nconst COMMAND_TIMEOUTS: Record<string, number> = {\n bun: 5 * 60_000,\n docker: 5 * 60_000,\n node_modules: 2 * 60_000,\n tar: 60_000,\n};\n\nexport async function execCommand(\n command: string,\n args: string[],\n cwd?: string,\n options?: { stdio?: \"pipe\" | \"inherit\" },\n): Promise<void> {\n const timeout = COMMAND_TIMEOUTS[command] ?? 2 * 60_000;\n await execa(command, args, { cwd, stdio: options?.stdio ?? \"pipe\", timeout });\n}\n\nfunction generateEnvExample(config: BosConfigInput, overrides: OverrideSection[]): string {\n const has = (section: OverrideSection) => overrides.includes(section);\n\n const lines: string[] = [\"# Environment variables\"];\n const collectSecrets = (\n obj: Record<string, unknown>,\n includeSection: boolean,\n prefix = \"\",\n ): void => {\n for (const [key, value] of Object.entries(obj)) {\n if (!includeSection) continue;\n if (key === \"secrets\" && Array.isArray(value)) {\n for (const secret of value) {\n if (typeof secret === \"string\") {\n lines.push(`${secret}=`);\n }\n }\n } else if (key === \"variables\" && isPlainObject(value)) {\n for (const [varKey, varVal] of Object.entries(value as Record<string, unknown>)) {\n if (typeof varVal === \"string\") {\n lines.push(`${varKey}=${varVal}`);\n }\n }\n } else if (isPlainObject(value) && key !== \"extends\") {\n collectSecrets(value as Record<string, unknown>, includeSection, `${prefix}${key}.`);\n }\n }\n };\n\n if (config.app && typeof config.app === \"object\") {\n const app = config.app as Record<string, unknown>;\n collectSecrets(app, has(\"host\"), \"host.\");\n collectSecrets(app, has(\"ui\"), \"ui.\");\n collectSecrets(app, has(\"api\"), \"api.\");\n collectSecrets(app, has(\"plugins\"), \"auth.\");\n }\n if (has(\"plugins\") && config.plugins && typeof config.plugins === \"object\") {\n for (const [pluginKey, pluginVal] of Object.entries(\n config.plugins as Record<string, unknown>,\n )) {\n if (isPlainObject(pluginVal)) {\n collectSecrets(pluginVal as Record<string, unknown>, true);\n } else if (typeof pluginVal === \"string\") {\n lines.push(`# Plugin '${pluginKey}' extends ${pluginVal}`);\n }\n }\n }\n\n lines.push(\"BETTER_AUTH_SECRET=generate-a-secret-here\");\n return `${lines.join(\"\\n\")}\\n`;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction generateGitignore(): string {\n return `node_modules/\ndist/\n.env\n.bos/\n*.gen.ts\n*.gen.tsx\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,MAAM,qBAAqB,CAAC,gBAAgB,iBAAiB;AAI7D,MAAM,yBAA4D;CAChE,IAAI,CAAC,KAAK;CACV,KAAK,CAAC,MAAM;CACZ,MAAM,CAAC,OAAO;CACd,SAAS,EAAE;CACZ;AAQD,eAAsB,iBAAiB,MAIb;AACxB,KAAI,KAAK,QAAQ;EACf,MAAM,YAAY,QAAQ,KAAK,OAAO;AACtC,MAAI,CAAC,WAAW,KAAK,WAAW,kBAAkB,CAAC,CACjD,OAAM,IAAI,MAAM,iDAAiD,YAAY;AAK/E,SAAO;GAAE;GAAW,cAHC,KAAK,MACxB,aAAa,KAAK,WAAW,kBAAkB,EAAE,QAAQ,CAC1D;GACiC,SAAS,YAAY;GAAI;;CAG7D,MAAM,eAAe,MAAM,kBAAkB,KAAK,gBAAgB,KAAK,eAAe;AAEtF,KAAI,aAAa,YAAY;EAC3B,MAAM,EAAE,KAAK,WAAW,YAAY,MAAM,gBAAgB,aAAa,WAAW;AAClF,SAAO;GAAE;GAAW;GAAc;GAAS;;CAG7C,MAAM,cAAc,MAAM,iCACxB,KAAK,gBACL,KAAK,eACN;AACD,KAAI,aAAa,YAAY;EAC3B,MAAM,EAAE,KAAK,WAAW,YAAY,MAAM,gBAAgB,YAAY,WAAW;AACjF,SAAO;GAAE;GAAW,cAAc,YAAY;GAAQ;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AAc,OAAO,QAC1C,OAAO,QACR,CACC,KAAI,cAAc,UAAU,CAC1B,gBAAe,WAAsC,KAAK;WACjD,OAAO,cAAc,SAC9B,OAAM,KAAK,aAAa,UAAU,YAAY,YAAY;;AAKhE,OAAM,KAAK,4CAA4C;AACvD,QAAO,GAAG,MAAM,KAAK,KAAK,CAAC;;AAG7B,SAAS,cAAc,OAAkD;AACvE,QAAO,QAAQ,MAAM,IAAI,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM;;AAG7E,SAAS,oBAA4B;AACnC,QAAO"}
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 type { OverrideSection } from \"../contract\";\nimport { fetchBosConfigFromFastKv } from \"../fastkv\";\nimport {\n loadManifestNormalizationSpec,\n normalizePackageManifestsInTree,\n} from \"../internal/manifest-normalizer\";\nimport type { BosConfig, BosConfigInput } 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\nconst FRAMEWORK_PACKAGES = [\"every-plugin\", \"everything-dev\"] as const;\n\nconst _DEFAULT_OVERRIDES: OverrideSection[] = [\"ui\", \"api\"];\n\nconst OVERRIDE_WORKSPACE_MAP: Record<OverrideSection, string[]> = {\n ui: [\"ui\"],\n api: [\"api\"],\n host: [\"host\"],\n plugins: [],\n};\n\ninterface SourceResult {\n sourceDir: string;\n parentConfig: BosConfig;\n cleanup: () => Promise<void>;\n}\n\nexport async function resolveSourceDir(opts: {\n extendsAccount: string;\n extendsGateway: string;\n source?: string;\n}): Promise<SourceResult> {\n if (opts.source) {\n const sourceDir = resolve(opts.source);\n if (!existsSync(join(sourceDir, \"bos.config.json\"))) {\n throw new Error(`No bos.config.json found in source directory: ${sourceDir}`);\n }\n const parentConfig = JSON.parse(\n readFileSync(join(sourceDir, \"bos.config.json\"), \"utf-8\"),\n ) as BosConfig;\n return { sourceDir, parentConfig, cleanup: async () => {} };\n }\n\n const parentConfig = await fetchParentConfig(opts.extendsAccount, opts.extendsGateway);\n\n if (parentConfig.repository) {\n const { dir: sourceDir, cleanup } = await downloadTarball(parentConfig.repository);\n return { sourceDir, parentConfig, cleanup };\n }\n\n const chainResult = await resolveRepositoryViaExtendsChain(\n opts.extendsAccount,\n opts.extendsGateway,\n );\n if (chainResult?.repository) {\n const { dir: sourceDir, cleanup } = await downloadTarball(chainResult.repository);\n return { sourceDir, parentConfig: chainResult.config, cleanup };\n }\n\n return {\n sourceDir: \"\",\n parentConfig,\n cleanup: async () => {},\n };\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 const patterns = content\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => line.length > 0 && !line.startsWith(\"#\"));\n\n if (!patterns.includes(\".templatekeep\")) {\n patterns.unshift(\".templatekeep\");\n }\n\n return patterns;\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 resolveRepositoryViaExtendsChain(\n extendsAccount: string,\n extendsGateway: string,\n visited = new Set<string>(),\n): Promise<{ repository: string; config: BosConfig } | null> {\n const key = `bos://${extendsAccount}/${extendsGateway}`;\n if (visited.has(key)) return null;\n visited.add(key);\n\n try {\n const config = await fetchParentConfig(extendsAccount, extendsGateway);\n if (config.repository) {\n return { repository: config.repository, config };\n }\n\n const extendsRef = config.extends;\n if (extendsRef && typeof extendsRef === \"string\") {\n const normalized = extendsRef.startsWith(\"bos://\") ? extendsRef : `bos://${extendsRef}`;\n const match = normalized.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (match) {\n const result = await resolveRepositoryViaExtendsChain(match[1], match[2], visited);\n if (result) return result;\n }\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\nexport async function detectGitRemoteUrl(directory: string): Promise<string | undefined> {\n try {\n const { stdout } = await execa(\"git\", [\"remote\", \"get-url\", \"origin\"], {\n cwd: directory,\n stdio: \"pipe\",\n });\n const url = stdout.trim();\n if (!url) return undefined;\n return normalizeGitUrl(url);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeGitUrl(url: string): string | undefined {\n const sshMatch = url.match(/^git@github\\.com:([^/]+)\\/([^/]+?)(?:\\.git)?$/);\n if (sshMatch) {\n return `https://github.com/${sshMatch[1]}/${sshMatch[2]}`;\n }\n const httpsMatch = url.match(/^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?(?:\\/.*)?$/);\n if (httpsMatch) {\n return `https://github.com/${httpsMatch[1]}/${httpsMatch[2]}`;\n }\n return url.endsWith(\".git\") ? url.slice(0, -4) : url;\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\nfunction filterPatternsByOverrides(\n patterns: string[],\n overrides: OverrideSection[],\n _plugins?: string[],\n): string[] {\n const has = (section: OverrideSection) => overrides.includes(section);\n let filtered = [...patterns];\n\n if (!has(\"host\")) {\n filtered = filtered.filter((p) => !p.startsWith(\"host/\") && p !== \"host/**\");\n }\n if (!has(\"ui\")) {\n filtered = filtered.filter((p) => !p.startsWith(\"ui/\") && p !== \"ui/**\");\n }\n if (!has(\"api\")) {\n filtered = filtered.filter((p) => !p.startsWith(\"api/\") && p !== \"api/**\");\n }\n if (!has(\"plugins\")) {\n filtered = filtered.filter((p) => !p.startsWith(\"plugins/\") && p !== \"plugins/**\");\n }\n\n return filtered;\n}\n\nexport async function copyFilteredFiles(\n sourceDir: string,\n destination: string,\n patterns: string[],\n options: {\n overrides: OverrideSection[];\n plugins?: string[];\n pluginRoutes?: Record<string, string[]>;\n },\n): Promise<number> {\n if (patterns.length === 0) {\n return 0;\n }\n\n const has = (section: OverrideSection) => options.overrides.includes(section);\n\n const effectivePatterns = filterPatternsByOverrides(patterns, options.overrides, options.plugins);\n\n if (has(\"host\") && !effectivePatterns.some((p) => p.startsWith(\"host/\") || p === \"host/**\")) {\n effectivePatterns.push(\"host/**\");\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 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) {\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\nfunction stripProductionFields(entry: Record<string, unknown>): void {\n delete entry.production;\n delete entry.integrity;\n delete entry.ssr;\n delete entry.ssrIntegrity;\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 overrides: OverrideSection[];\n pluginRoutes?: Record<string, string[]>;\n workspaceOpts?: { localOverrides?: boolean; sourceDir?: string };\n mode?: \"init\" | \"sync\";\n repository?: string;\n title?: string;\n description?: string;\n testnet?: string;\n staging?: unknown;\n },\n): Promise<void> {\n const has = (section: OverrideSection) => opts.overrides.includes(section);\n\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 if (opts.repository) {\n config.repository = opts.repository;\n } else {\n delete config.repository;\n }\n\n const inheritableFields = [\"title\", \"description\", \"testnet\", \"staging\"] as const;\n for (const field of inheritableFields) {\n if (!(field in opts)) {\n delete config[field];\n }\n }\n\n if (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 if (\n !has(entryKey as OverrideSection) &&\n (entryKey === \"host\" || entryKey === \"ui\" || entryKey === \"api\" || entryKey === \"auth\")\n ) {\n delete app[entryKey];\n continue;\n }\n const entry = app[entryKey];\n if (entry && typeof entry === \"object\") {\n stripProductionFields(entry as Record<string, unknown>);\n }\n }\n }\n\n if (has(\"plugins\")) {\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 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 plugins[pluginKey] = pluginObj;\n } else {\n continue;\n }\n\n stripProductionFields(pluginObj);\n }\n\n if (Object.keys(plugins).length === 0) {\n delete config.plugins;\n }\n }\n } else {\n delete config.plugins;\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 has(\"host\");\n if (p === \"plugins/*\") return false;\n const pluginMatch = p.match(/^plugins\\/([^/]+)/);\n if (pluginMatch)\n return has(\"plugins\") && (opts.plugins?.includes(pluginMatch[1]) ?? true);\n return true;\n });\n\n if (has(\"plugins\") && (opts.plugins?.length ?? 0) > 0) {\n for (const plugin of opts.plugins ?? []) {\n const pluginWorkspace = `plugins/${plugin}`;\n if (!ws.packages.includes(pluginWorkspace)) {\n ws.packages.push(pluginWorkspace);\n }\n }\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 (!has(\"host\")) {\n scripts.typecheck = scripts.typecheck.replace(/bun run --cwd host tsc --noEmit & ?/, \"\");\n }\n }\n\n if (!scripts.bos) {\n scripts.bos = \"node_modules/.bin/bos\";\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 const frameworkCatalog = resolveFrameworkCatalog();\n for (const [name, version] of Object.entries(frameworkCatalog)) {\n workspaces.catalog[name] = version;\n }\n if (!deps[\"everything-dev\"]) deps[\"everything-dev\"] = \"catalog:\";\n if (!deps[\"every-plugin\"]) 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 if (has(\"ui\")) {\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\n if (has(\"api\")) {\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\n const authTypesContent = generateAuthTypesTemplate();\n const authTypesPaths: string[] = [];\n if (has(\"ui\")) {\n authTypesPaths.push(join(destination, \"ui\", \"src\", \"lib\", \"auth-types.gen.ts\"));\n }\n if (has(\"api\")) {\n authTypesPaths.push(join(destination, \"api\", \"src\", \"lib\", \"auth-types.gen.ts\"));\n }\n if (has(\"host\") && 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(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n await runWithProgress(\n \"bun\",\n [\"install\", \"--ignore-scripts\"],\n destination,\n spinner,\n \"Installing dependencies\",\n );\n}\n\nexport async function runBunInstallForUpgrade(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n await runWithProgress(\n \"bun\",\n [\"install\", \"--force\"],\n destination,\n spinner,\n \"Installing dependencies\",\n );\n}\n\nexport async function runTypesGen(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n await runWithProgress(\n \"node_modules/.bin/bos\",\n [\"types\", \"gen\"],\n destination,\n spinner,\n \"Generating types\",\n );\n}\n\nexport async function runDockerComposeUp(destination: string): Promise<void> {\n await execCommand(\"docker\", [\"compose\", \"up\", \"-d\", \"--wait\"], destination, { stdio: \"inherit\" });\n}\n\nasync function runWithProgress(\n command: string,\n args: string[],\n cwd: string,\n spinner: { message: (msg: string) => void } | undefined,\n label: string,\n): Promise<void> {\n const timeout = COMMAND_TIMEOUTS[command] ?? 2 * 60_000;\n const child = execa(command, args, { cwd, stdio: \"inherit\", timeout });\n\n if (spinner) {\n const start = Date.now();\n const interval = setInterval(() => {\n const elapsed = Math.round((Date.now() - start) / 1000);\n spinner.message(`${label}... (${elapsed}s)`);\n }, 2000);\n try {\n await child;\n } finally {\n clearInterval(interval);\n }\n } else {\n await child;\n }\n}\n\nexport function stripOrphanedWorkspacesFromLockfile(\n lockfilePath: string,\n allowedWorkspaces: string[],\n): void {\n if (!existsSync(lockfilePath)) return;\n\n const content = readFileSync(lockfilePath, \"utf-8\");\n let lockfile: Record<string, unknown>;\n try {\n lockfile = JSON.parse(content) as Record<string, unknown>;\n } catch {\n return;\n }\n\n const workspaces = lockfile.workspaces;\n if (!workspaces || typeof workspaces !== \"object\") return;\n\n const workspaceMap = workspaces as Record<string, unknown>;\n const allowed = new Set([\"\", ...allowedWorkspaces]);\n\n const keys = Object.keys(workspaceMap);\n let changed = false;\n for (const key of keys) {\n if (!allowed.has(key)) {\n delete workspaceMap[key];\n changed = true;\n }\n }\n\n if (changed) {\n writeFileSync(lockfilePath, `${JSON.stringify(lockfile, null, 2)}\\n`);\n }\n}\n\nexport function removeInitLockfile(lockfilePath: string): void {\n if (!existsSync(lockfilePath)) return;\n rmSync(lockfilePath, { force: true });\n}\n\nconst WORKSPACE_LOCAL_PATHS: Record<string, string> = {\n \"everything-dev\": \"packages/everything-dev\",\n \"every-plugin\": \"packages/every-plugin\",\n};\n\nfunction resolveFrameworkCatalog(): Record<string, string> {\n const catalog: Record<string, string> = {};\n\n try {\n const selfPkgPath = require.resolve(\"everything-dev/package.json\");\n const selfPkgDir = dirname(selfPkgPath);\n const monorepoPkgPath = join(selfPkgDir, \"..\", \"..\", \"package.json\");\n if (existsSync(monorepoPkgPath)) {\n const monorepoPkg = JSON.parse(readFileSync(monorepoPkgPath, \"utf-8\")) as {\n workspaces?: { catalog?: Record<string, string> };\n };\n const sourceCatalog = monorepoPkg.workspaces?.catalog;\n if (sourceCatalog && typeof sourceCatalog === \"object\") {\n for (const [name, version] of Object.entries(sourceCatalog)) {\n if (typeof version === \"string\") {\n catalog[name] = version;\n }\n }\n }\n }\n } catch {}\n\n try {\n const selfPkgPath = require.resolve(\"everything-dev/package.json\");\n const selfPkg = JSON.parse(readFileSync(selfPkgPath, \"utf-8\")) as {\n version?: string;\n workspaces?: { catalog?: Record<string, string> };\n };\n if (selfPkg.version && !catalog[\"everything-dev\"]) {\n catalog[\"everything-dev\"] = `^${selfPkg.version}`;\n }\n const sourceCatalog = selfPkg.workspaces?.catalog;\n if (sourceCatalog && typeof sourceCatalog === \"object\") {\n for (const [name, version] of Object.entries(sourceCatalog)) {\n if (typeof version === \"string\" && !catalog[name]) {\n catalog[name] = version;\n }\n }\n }\n } catch {}\n\n if (Object.keys(catalog).length > 0) {\n return catalog;\n }\n\n for (const packageName of FRAMEWORK_PACKAGES) {\n try {\n const resolved = require.resolve(`${packageName}/package.json`);\n const pkg = JSON.parse(readFileSync(resolved, \"utf-8\")) as { version?: string };\n if (pkg.version) {\n catalog[packageName] = `^${pkg.version}`;\n }\n } catch {}\n }\n return catalog;\n}\n\nexport async function scaffoldMinimalProject(\n destination: string,\n parentConfig: BosConfigInput,\n opts: {\n extendsAccount: string;\n extendsGateway: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n overrides: OverrideSection[];\n repository?: string;\n title?: string;\n description?: string;\n },\n): Promise<number> {\n mkdirSync(destination, { recursive: true });\n\n const has = (section: OverrideSection) => opts.overrides.includes(section);\n\n const config: Record<string, unknown> = {\n extends: `bos://${opts.extendsAccount}/${opts.extendsGateway}`,\n account: opts.account || opts.extendsAccount,\n ...(opts.domain ? { domain: opts.domain } : {}),\n ...(opts.repository ? { repository: opts.repository } : {}),\n ...(opts.title ? { title: opts.title } : {}),\n ...(opts.description ? { description: opts.description } : {}),\n };\n\n if (parentConfig.app && typeof parentConfig.app === \"object\") {\n const app: Record<string, unknown> = {};\n const parentApp = parentConfig.app as Record<string, Record<string, unknown>>;\n\n if (has(\"host\") && parentApp.host) {\n app.host = { ...parentApp.host };\n stripProductionFields(app.host as Record<string, unknown>);\n }\n\n if (has(\"ui\") && parentApp.ui) {\n app.ui = { ...parentApp.ui };\n stripProductionFields(app.ui as Record<string, unknown>);\n }\n\n if (has(\"api\") && parentApp.api) {\n app.api = { ...parentApp.api };\n stripProductionFields(app.api as Record<string, unknown>);\n }\n\n if (has(\"plugins\") && parentApp.auth) {\n app.auth = { ...parentApp.auth };\n stripProductionFields(app.auth as Record<string, unknown>);\n }\n\n if (Object.keys(app).length > 0) {\n config.app = app;\n }\n }\n\n if (has(\"plugins\") && opts.plugins && opts.plugins.length > 0 && parentConfig.plugins) {\n const plugins: Record<string, unknown> = {};\n for (const key of opts.plugins) {\n const parentPlugin = (parentConfig.plugins as Record<string, unknown>)?.[key];\n if (parentPlugin) {\n if (typeof parentPlugin === \"string\") {\n plugins[key] = { extends: parentPlugin };\n } else {\n const pluginCopy = { ...(parentPlugin as Record<string, unknown>) };\n stripProductionFields(pluginCopy);\n plugins[key] = pluginCopy;\n }\n }\n }\n config.plugins = plugins;\n }\n\n await saveBosConfig(destination, config);\n\n const workspacePackages: string[] = [];\n for (const section of opts.overrides) {\n workspacePackages.push(...OVERRIDE_WORKSPACE_MAP[section]);\n }\n if (has(\"plugins\") && opts.plugins) {\n for (const plugin of opts.plugins) {\n workspacePackages.push(`plugins/${plugin}`);\n }\n }\n\n const catalog = resolveFrameworkCatalog();\n\n const pkg: Record<string, unknown> = {\n name: opts.domain || opts.extendsGateway,\n private: true,\n type: \"module\",\n scripts: {\n dev: \"node_modules/.bin/bos dev --host remote\",\n \"dev:ui\": \"node_modules/.bin/bos dev --ui local --api remote\",\n \"dev:api\": \"node_modules/.bin/bos dev --ui remote --api local\",\n build: \"node_modules/.bin/bos build\",\n deploy: \"node_modules/.bin/bos build --deploy\",\n publish: \"node_modules/.bin/bos publish\",\n start: \"node_modules/.bin/bos start\",\n typecheck: \"node_modules/.bin/bos types gen && tsc --noEmit\",\n postinstall: \"node_modules/.bin/bos types gen || true\",\n \"types:gen\": \"node_modules/.bin/bos types gen\",\n bos: \"node_modules/.bin/bos\",\n },\n dependencies: {\n \"everything-dev\": \"catalog:\",\n \"every-plugin\": \"catalog:\",\n },\n devDependencies: {},\n workspaces: {\n packages: workspacePackages,\n catalog,\n },\n };\n writeFileSync(join(destination, \"package.json\"), `${JSON.stringify(pkg, null, 2)}\\n`);\n\n const envExample = generateEnvExample(parentConfig, opts.overrides);\n if (envExample) {\n writeFileSync(join(destination, \".env.example\"), envExample);\n }\n\n writeFileSync(join(destination, \".gitignore\"), generateGitignore());\n\n return 4;\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: {\n overrides: OverrideSection[];\n plugins?: string[];\n pluginRoutes?: Record<string, string[]>;\n },\n): Promise<void> {\n const effectivePatterns = filterPatternsByOverrides(patterns, options.overrides, options.plugins);\n\n const has = (section: OverrideSection) => options.overrides.includes(section);\n if (has(\"host\") && !effectivePatterns.some((p) => p.startsWith(\"host/\") || p === \"host/**\")) {\n effectivePatterns.push(\"host/**\");\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 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\nconst COMMAND_TIMEOUTS: Record<string, number> = {\n bun: 5 * 60_000,\n docker: 5 * 60_000,\n node_modules: 2 * 60_000,\n tar: 60_000,\n};\n\nexport async function execCommand(\n command: string,\n args: string[],\n cwd?: string,\n options?: { stdio?: \"pipe\" | \"inherit\" },\n): Promise<void> {\n const timeout = COMMAND_TIMEOUTS[command] ?? 2 * 60_000;\n await execa(command, args, { cwd, stdio: options?.stdio ?? \"pipe\", timeout });\n}\n\nfunction generateEnvExample(config: BosConfigInput, overrides: OverrideSection[]): string {\n const has = (section: OverrideSection) => overrides.includes(section);\n\n const lines: string[] = [\"# Environment variables\"];\n const collectSecrets = (\n obj: Record<string, unknown>,\n includeSection: boolean,\n prefix = \"\",\n ): void => {\n for (const [key, value] of Object.entries(obj)) {\n if (!includeSection) continue;\n if (key === \"secrets\" && Array.isArray(value)) {\n for (const secret of value) {\n if (typeof secret === \"string\") {\n lines.push(`${secret}=`);\n }\n }\n } else if (key === \"variables\" && isPlainObject(value)) {\n for (const [varKey, varVal] of Object.entries(value as Record<string, unknown>)) {\n if (typeof varVal === \"string\") {\n lines.push(`${varKey}=${varVal}`);\n }\n }\n } else if (isPlainObject(value) && key !== \"extends\") {\n collectSecrets(value as Record<string, unknown>, includeSection, `${prefix}${key}.`);\n }\n }\n };\n\n if (config.app && typeof config.app === \"object\") {\n const app = config.app as Record<string, unknown>;\n collectSecrets(app, has(\"host\"), \"host.\");\n collectSecrets(app, has(\"ui\"), \"ui.\");\n collectSecrets(app, has(\"api\"), \"api.\");\n collectSecrets(app, has(\"plugins\"), \"auth.\");\n }\n if (has(\"plugins\") && config.plugins && typeof config.plugins === \"object\") {\n for (const [pluginKey, pluginVal] of Object.entries(\n config.plugins as Record<string, unknown>,\n )) {\n if (isPlainObject(pluginVal)) {\n collectSecrets(pluginVal as Record<string, unknown>, true);\n } else if (typeof pluginVal === \"string\") {\n lines.push(`# Plugin '${pluginKey}' extends ${pluginVal}`);\n }\n }\n }\n\n lines.push(\"BETTER_AUTH_SECRET=generate-a-secret-here\");\n return `${lines.join(\"\\n\")}\\n`;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction generateGitignore(): string {\n return `node_modules/\ndist/\n.env\n.bos/\n*.gen.ts\n*.gen.tsx\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,MAAM,qBAAqB,CAAC,gBAAgB,iBAAiB;AAI7D,MAAM,yBAA4D;CAChE,IAAI,CAAC,KAAK;CACV,KAAK,CAAC,MAAM;CACZ,MAAM,CAAC,OAAO;CACd,SAAS,EAAE;CACZ;AAQD,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,K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O,GAAG,SAAS;cAG5B,cAAc,MAAM,IAAI,QAAQ,UACzC,gBAAe,OAAkC,gBAAgB,GAAG,SAAS,IAAI,GAAG;;;AAK1F,KAAI,OAAO,OAAO,OAAO,OAAO,QAAQ,UAAU;EAChD,MAAM,MAAM,OAAO;AACnB,iBAAe,KAAK,IAAI,OAAO,EAAE,QAAQ;AACzC,iBAAe,KAAK,IAAI,KAAK,EAAE,MAAM;AACrC,iBAAe,KAAK,IAAI,MAAM,EAAE,OAAO;AACvC,iBAAe,KAAK,IAAI,UAAU,EAAE,QAAQ;;AAE9C,KAAI,IAAI,UAAU,IAAI,OAAO,WAAW,OAAO,OAAO,YAAY,UAChE;OAAK,MAAM,CAAC,WAAW,cAAc,OAAO,QAC1C,OAAO,QACR,CACC,KAAI,cAAc,UAAU,CAC1B,gBAAe,WAAsC,KAAK;WACjD,OAAO,cAAc,SAC9B,OAAM,KAAK,aAAa,UAAU,YAAY,YAAY;;AAKhE,OAAM,KAAK,4CAA4C;AACvD,QAAO,GAAG,MAAM,KAAK,KAAK,CAAC;;AAG7B,SAAS,cAAc,OAAkD;AACvE,QAAO,QAAQ,MAAM,IAAI,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM;;AAG7E,SAAS,oBAA4B;AACnC,QAAO"}
@@ -1,8 +1,8 @@
1
1
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
- let _clack_prompts = require("@clack/prompts");
3
- _clack_prompts = require_runtime.__toESM(_clack_prompts, 1);
4
2
  let node_process = require("node:process");
5
3
  node_process = require_runtime.__toESM(node_process, 1);
4
+ let _clack_prompts = require("@clack/prompts");
5
+ _clack_prompts = require_runtime.__toESM(_clack_prompts, 1);
6
6
 
7
7
  //#region src/cli/prompts.ts
8
8
  function parseExtendsRef(ref) {
@@ -70,7 +70,7 @@ async function promptInitOptions(input) {
70
70
  if (_clack_prompts.isCancel(account)) node_process.default.exit(0);
71
71
  const directory = input.directory || domain || extendsGateway;
72
72
  const overrides = input.overrides ?? await _clack_prompts.multiselect({
73
- message: "Which sections to override locally?",
73
+ message: "Which sections would you like to customize",
74
74
  options: OVERRIDE_OPTIONS,
75
75
  initialValues: ["ui", "api"],
76
76
  required: false
@@ -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\";\nimport type { OverrideSection } from \"../contract\";\n\nfunction parseExtendsRef(ref: string): { account: string; gateway: string } | null {\n const normalized = ref.startsWith(\"bos://\") ? ref : `bos://${ref}`;\n const match = normalized.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!match) return null;\n return { account: match[1], gateway: match[2] };\n}\n\nfunction deriveAccountFromExtends(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 OVERRIDE_OPTIONS: { value: OverrideSection; label: string; hint: string }[] = [\n { value: \"ui\", label: \"ui\", hint: \"Override UI with local source\" },\n { value: \"api\", label: \"api\", hint: \"Override API with local source\" },\n { value: \"host\", label: \"host\", hint: \"Override host with local source\" },\n { value: \"plugins\", label: \"plugins\", hint: \"Override selected plugins with local source\" },\n];\n\nexport async function promptInitOptions(input: {\n extends?: string;\n directory?: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n overrides?: OverrideSection[];\n parentPluginKeys?: string[];\n}): Promise<{\n extendsAccount: string;\n extendsGateway: string;\n directory: string;\n account?: string;\n domain?: string;\n plugins: string[];\n overrides: OverrideSection[];\n}> {\n p.intro(\"Let's build an app...\");\n\n const extendsInput =\n input.extends ??\n ((await p.text({\n message: \"Extending an existing app?\",\n placeholder: \"bos://dev.everything.near/everything.dev\",\n })) as string);\n\n if (p.isCancel(extendsInput)) process.exit(0);\n\n let extendsAccount = \"dev.everything.near\";\n let extendsGateway = \"everything.dev\";\n\n if (extendsInput) {\n const parsed = parseExtendsRef(extendsInput);\n if (parsed) {\n extendsAccount = parsed.account;\n extendsGateway = parsed.gateway;\n }\n }\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 accountDefault = domain ? deriveAccountFromExtends(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 overrides =\n input.overrides ??\n ((await p.multiselect({\n message: \"Which sections to override locally?\",\n options: OVERRIDE_OPTIONS,\n initialValues: [\"ui\", \"api\"] as OverrideSection[],\n required: false,\n })) as OverrideSection[]);\n\n if (p.isCancel(overrides)) process.exit(0);\n\n let plugins: string[] = [];\n if (overrides.includes(\"plugins\")) {\n const parentPlugins = input.parentPluginKeys ?? [];\n const pluginOptions =\n parentPlugins.length > 0 ? parentPlugins.map((key) => ({ value: key, label: key })) : [];\n\n plugins =\n input.plugins ??\n (pluginOptions.length > 0\n ? ((await p.multiselect({\n message: \"Select plugins to include:\",\n options: pluginOptions,\n required: false,\n })) as string[])\n : []);\n\n if (p.isCancel(plugins)) process.exit(0);\n }\n\n const go = await p.confirm({\n message: \"GO!\",\n initialValue: true,\n });\n\n if (p.isCancel(go) || !go) process.exit(0);\n\n return {\n extendsAccount,\n extendsGateway,\n directory,\n account: account || undefined,\n domain: domain || undefined,\n plugins,\n overrides,\n };\n}\n"],"mappings":";;;;;;;AAIA,SAAS,gBAAgB,KAA0D;CAEjF,MAAM,SADa,IAAI,WAAW,SAAS,GAAG,MAAM,SAAS,OACpC,MAAM,0BAA0B;AACzD,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO;EAAE,SAAS,MAAM;EAAI,SAAS,MAA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,MAAMA,eAAE,YAAY;EACpB,SAAS;EACT,SAAS;EACT,eAAe,CAAC,MAAM,MAAM;EAC5B,UAAU;EACX,CAAC;AAEJ,KAAIA,eAAE,SAAS,UAAU,CAAE,sBAAQ,KAAK,EAAE;CAE1C,IAAI,UAAoB,EAAE;AAC1B,KAAI,UAAU,SAAS,UAAU,EAAE;EACjC,MAAM,gBAAgB,MAAM,oBAAoB,EAAE;EAClD,MAAM,gBACJ,cAAc,SAAS,IAAI,cAAc,KAAK,SAAS;GAAE,OAAO;GAAK,OAAO;GAAK,EAAE,GAAG,EAAE;AAE1F,YACE,MAAM,YACL,cAAc,SAAS,IAClB,MAAMA,eAAE,YAAY;GACpB,SAAS;GACT,SAAS;GACT,UAAU;GACX,CAAC,GACF,EAAE;AAER,MAAIA,eAAE,SAAS,QAAQ,CAAE,sBAAQ,KAAK,EAAE;;CAG1C,MAAM,KAAK,MAAMA,eAAE,QAAQ;EACzB,SAAS;EACT,cAAc;EACf,CAAC;AAEF,KAAIA,eAAE,SAAS,GAAG,IAAI,CAAC,GAAI,sBAAQ,KAAK,EAAE;AAE1C,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\";\nimport type { OverrideSection } from \"../contract\";\n\nfunction parseExtendsRef(ref: string): { account: string; gateway: string } | null {\n const normalized = ref.startsWith(\"bos://\") ? ref : `bos://${ref}`;\n const match = normalized.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!match) return null;\n return { account: match[1], gateway: match[2] };\n}\n\nfunction deriveAccountFromExtends(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 OVERRIDE_OPTIONS: { value: OverrideSection; label: string; hint: string }[] = [\n { value: \"ui\", label: \"ui\", hint: \"Override UI with local source\" },\n { value: \"api\", label: \"api\", hint: \"Override API with local source\" },\n { value: \"host\", label: \"host\", hint: \"Override host with local source\" },\n { value: \"plugins\", label: \"plugins\", hint: \"Override selected plugins with local source\" },\n];\n\nexport async function promptInitOptions(input: {\n extends?: string;\n directory?: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n overrides?: OverrideSection[];\n parentPluginKeys?: string[];\n}): Promise<{\n extendsAccount: string;\n extendsGateway: string;\n directory: string;\n account?: string;\n domain?: string;\n plugins: string[];\n overrides: OverrideSection[];\n}> {\n p.intro(\"Let's build an app...\");\n\n const extendsInput =\n input.extends ??\n ((await p.text({\n message: \"Extending an existing app?\",\n placeholder: \"bos://dev.everything.near/everything.dev\",\n })) as string);\n\n if (p.isCancel(extendsInput)) process.exit(0);\n\n let extendsAccount = \"dev.everything.near\";\n let extendsGateway = \"everything.dev\";\n\n if (extendsInput) {\n const parsed = parseExtendsRef(extendsInput);\n if (parsed) {\n extendsAccount = parsed.account;\n extendsGateway = parsed.gateway;\n }\n }\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 accountDefault = domain ? deriveAccountFromExtends(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 overrides =\n input.overrides ??\n ((await p.multiselect({\n message: \"Which sections would you like to customize\",\n options: OVERRIDE_OPTIONS,\n initialValues: [\"ui\", \"api\"] as OverrideSection[],\n required: false,\n })) as OverrideSection[]);\n\n if (p.isCancel(overrides)) process.exit(0);\n\n let plugins: string[] = [];\n if (overrides.includes(\"plugins\")) {\n const parentPlugins = input.parentPluginKeys ?? [];\n const pluginOptions =\n parentPlugins.length > 0 ? parentPlugins.map((key) => ({ value: key, label: key })) : [];\n\n plugins =\n input.plugins ??\n (pluginOptions.length > 0\n ? ((await p.multiselect({\n message: \"Select plugins to include:\",\n options: pluginOptions,\n required: false,\n })) as string[])\n : []);\n\n if (p.isCancel(plugins)) process.exit(0);\n }\n\n const go = await p.confirm({\n message: \"GO!\",\n initialValue: true,\n });\n\n if (p.isCancel(go) || !go) process.exit(0);\n\n return {\n extendsAccount,\n extendsGateway,\n directory,\n account: account || undefined,\n domain: domain || undefined,\n plugins,\n overrides,\n };\n}\n"],"mappings":";;;;;;;AAIA,SAAS,gBAAgB,KAA0D;CAEjF,MAAM,SADa,IAAI,WAAW,SAAS,GAAG,MAAM,SAAS,OACpC,MAAM,0BAA0B;AACzD,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO;EAAE,SAAS,MAAM;EAAI,SAAS,MAAM;EAAI;;AAGjD,SAAS,yBAAyB,QAAgB,gBAAgC;CAChF,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,mBAA8E;CAClF;EAAE,OAAO;EAAM,OAAO;EAAM,MAAM;EAAiC;CACnE;EAAE,OAAO;EAAO,OAAO;EAAO,MAAM;EAAkC;CACtE;EAAE,OAAO;EAAQ,OAAO;EAAQ,MAAM;EAAmC;CACzE;EAAE,OAAO;EAAW,OAAO;EAAW,MAAM;EAA+C;CAC5F;AAED,eAAsB,kBAAkB,OAgBrC;AACD,gBAAE,MAAM,wBAAwB;CAEhC,MAAM,eACJ,MAAM,WACJ,MAAMA,eAAE,KAAK;EACb,SAAS;EACT,aAAa;EACd,CAAC;AAEJ,KAAIA,eAAE,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AAEF,KAAIA,eAAE,SAAS,GAAG,IAAI,CAAC,GAAI,sBAAQ,KAAK,EAAE;AAE1C,QAAO;EACL;EACA;EACA;EACA,SAAS,WAAW;EACpB,QAAQ,UAAU;EAClB;EACA;EACD"}
@@ -1,5 +1,5 @@
1
- import * as p from "@clack/prompts";
2
1
  import process from "node:process";
2
+ import * as p from "@clack/prompts";
3
3
 
4
4
  //#region src/cli/prompts.ts
5
5
  function parseExtendsRef(ref) {
@@ -67,7 +67,7 @@ async function promptInitOptions(input) {
67
67
  if (p.isCancel(account)) process.exit(0);
68
68
  const directory = input.directory || domain || extendsGateway;
69
69
  const overrides = input.overrides ?? await p.multiselect({
70
- message: "Which sections to override locally?",
70
+ message: "Which sections would you like to customize",
71
71
  options: OVERRIDE_OPTIONS,
72
72
  initialValues: ["ui", "api"],
73
73
  required: false
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.mjs","names":[],"sources":["../../src/cli/prompts.ts"],"sourcesContent":["import process from \"node:process\";\nimport * as p from \"@clack/prompts\";\nimport type { OverrideSection } from \"../contract\";\n\nfunction parseExtendsRef(ref: string): { account: string; gateway: string } | null {\n const normalized = ref.startsWith(\"bos://\") ? ref : `bos://${ref}`;\n const match = normalized.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!match) return null;\n return { account: match[1], gateway: match[2] };\n}\n\nfunction deriveAccountFromExtends(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 OVERRIDE_OPTIONS: { value: OverrideSection; label: string; hint: string }[] = [\n { value: \"ui\", label: \"ui\", hint: \"Override UI with local source\" },\n { value: \"api\", label: \"api\", hint: \"Override API with local source\" },\n { value: \"host\", label: \"host\", hint: \"Override host with local source\" },\n { value: \"plugins\", label: \"plugins\", hint: \"Override selected plugins with local source\" },\n];\n\nexport async function promptInitOptions(input: {\n extends?: string;\n directory?: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n overrides?: OverrideSection[];\n parentPluginKeys?: string[];\n}): Promise<{\n extendsAccount: string;\n extendsGateway: string;\n directory: string;\n account?: string;\n domain?: string;\n plugins: string[];\n overrides: OverrideSection[];\n}> {\n p.intro(\"Let's build an app...\");\n\n const extendsInput =\n input.extends ??\n ((await p.text({\n message: \"Extending an existing app?\",\n placeholder: \"bos://dev.everything.near/everything.dev\",\n })) as string);\n\n if (p.isCancel(extendsInput)) process.exit(0);\n\n let extendsAccount = \"dev.everything.near\";\n let extendsGateway = \"everything.dev\";\n\n if (extendsInput) {\n const parsed = parseExtendsRef(extendsInput);\n if (parsed) {\n extendsAccount = parsed.account;\n extendsGateway = parsed.gateway;\n }\n }\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 accountDefault = domain ? deriveAccountFromExtends(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 overrides =\n input.overrides ??\n ((await p.multiselect({\n message: \"Which sections to override locally?\",\n options: OVERRIDE_OPTIONS,\n initialValues: [\"ui\", \"api\"] as OverrideSection[],\n required: false,\n })) as OverrideSection[]);\n\n if (p.isCancel(overrides)) process.exit(0);\n\n let plugins: string[] = [];\n if (overrides.includes(\"plugins\")) {\n const parentPlugins = input.parentPluginKeys ?? [];\n const pluginOptions =\n parentPlugins.length > 0 ? parentPlugins.map((key) => ({ value: key, label: key })) : [];\n\n plugins =\n input.plugins ??\n (pluginOptions.length > 0\n ? ((await p.multiselect({\n message: \"Select plugins to include:\",\n options: pluginOptions,\n required: false,\n })) as string[])\n : []);\n\n if (p.isCancel(plugins)) process.exit(0);\n }\n\n const go = await p.confirm({\n message: \"GO!\",\n initialValue: true,\n });\n\n if (p.isCancel(go) || !go) process.exit(0);\n\n return {\n extendsAccount,\n extendsGateway,\n directory,\n account: account || undefined,\n domain: domain || undefined,\n plugins,\n overrides,\n };\n}\n"],"mappings":";;;;AAIA,SAAS,gBAAgB,KAA0D;CAEjF,MAAM,SADa,IAAI,WAAW,SAAS,GAAG,MAAM,SAAS,OACpC,MAAM,0BAA0B;AACzD,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO;EAAE,SAAS,MAAM;EAAI,SAAS,MAAM;EAAI;;AAGjD,SAAS,yBAAyB,QAAgB,gBAAgC;CAChF,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,mBAA8E;CAClF;EAAE,OAAO;EAAM,OAAO;EAAM,MAAM;EAAiC;CACnE;EAAE,OAAO;EAAO,OAAO;EAAO,MAAM;EAAkC;CACtE;EAAE,OAAO;EAAQ,OAAO;EAAQ,MAAM;EAAmC;CACzE;EAAE,OAAO;EAAW,OAAO;EAAW,MAAM;EAA+C;CAC5F;AAED,eAAsB,kBAAkB,OAgBrC;AACD,GAAE,MAAM,wBAAwB;CAEhC,MAAM,eACJ,MAAM,WACJ,MAAM,EAAE,KAAK;EACb,SAAS;EACT,aAAa;EACd,CAAC;AAEJ,KAAI,EAAE,SAAS,aAAa,CAAE,SAAQ,KAAK,EAAE;CAE7C,IAAI,iBAAiB;CACrB,IAAI,iBAAiB;AAErB,KAAI,cAAc;EAChB,MAAM,SAAS,gBAAgB,aAAa;AAC5C,MAAI,QAAQ;AACV,oBAAiB,OAAO;AACxB,oBAAiB,OAAO;;;CAI5B,MAAM,SACJ,MAAM,UACJ,MAAM,EAAE,KAAK;EACb,SAAS;EACT,aAAa;EACd,CAAC;AAEJ,KAAI,EAAE,SAAS,OAAO,CAAE,SAAQ,KAAK,EAAE;CAEvC,MAAM,iBAAiB,SAAS,yBAAyB,QAAQ,eAAe,GAAG;CACnF,MAAM,UACJ,MAAM,WACJ,MAAM,EAAE,KAAK;EACb,SAAS;EACT,aAAa,kBAAkB;EAC/B,cAAc;EACf,CAAC;AAEJ,KAAI,EAAE,SAAS,QAAQ,CAAE,SAAQ,KAAK,EAAE;CAExC,MAAM,YAAY,MAAM,aAAa,UAAU;CAE/C,MAAM,YACJ,MAAM,aACJ,MAAM,EAAE,YAAY;EACpB,SAAS;EACT,SAAS;EACT,eAAe,CAAC,MAAM,MAAM;EAC5B,UAAU;EACX,CAAC;AAEJ,KAAI,EAAE,SAAS,UAAU,CAAE,SAAQ,KAAK,EAAE;CAE1C,IAAI,UAAoB,EAAE;AAC1B,KAAI,UAAU,SAAS,UAAU,EAAE;EACjC,MAAM,gBAAgB,MAAM,oBAAoB,EAAE;EAClD,MAAM,gBACJ,cAAc,SAAS,IAAI,cAAc,KAAK,SAAS;GAAE,OAAO;GAAK,OAAO;GAAK,EAAE,GAAG,EAAE;AAE1F,YACE,MAAM,YACL,cAAc,SAAS,IAClB,MAAM,EAAE,YAAY;GACpB,SAAS;GACT,SAAS;GACT,UAAU;GACX,CAAC,GACF,EAAE;AAER,MAAI,EAAE,SAAS,QAAQ,CAAE,SAAQ,KAAK,EAAE;;CAG1C,MAAM,KAAK,MAAM,EAAE,QAAQ;EACzB,SAAS;EACT,cAAc;EACf,CAAC;AAEF,KAAI,EAAE,SAAS,GAAG,IAAI,CAAC,GAAI,SAAQ,KAAK,EAAE;AAE1C,QAAO;EACL;EACA;EACA;EACA,SAAS,WAAW;EACpB,QAAQ,UAAU;EAClB;EACA;EACD"}
1
+ {"version":3,"file":"prompts.mjs","names":[],"sources":["../../src/cli/prompts.ts"],"sourcesContent":["import process from \"node:process\";\nimport * as p from \"@clack/prompts\";\nimport type { OverrideSection } from \"../contract\";\n\nfunction parseExtendsRef(ref: string): { account: string; gateway: string } | null {\n const normalized = ref.startsWith(\"bos://\") ? ref : `bos://${ref}`;\n const match = normalized.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!match) return null;\n return { account: match[1], gateway: match[2] };\n}\n\nfunction deriveAccountFromExtends(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 OVERRIDE_OPTIONS: { value: OverrideSection; label: string; hint: string }[] = [\n { value: \"ui\", label: \"ui\", hint: \"Override UI with local source\" },\n { value: \"api\", label: \"api\", hint: \"Override API with local source\" },\n { value: \"host\", label: \"host\", hint: \"Override host with local source\" },\n { value: \"plugins\", label: \"plugins\", hint: \"Override selected plugins with local source\" },\n];\n\nexport async function promptInitOptions(input: {\n extends?: string;\n directory?: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n overrides?: OverrideSection[];\n parentPluginKeys?: string[];\n}): Promise<{\n extendsAccount: string;\n extendsGateway: string;\n directory: string;\n account?: string;\n domain?: string;\n plugins: string[];\n overrides: OverrideSection[];\n}> {\n p.intro(\"Let's build an app...\");\n\n const extendsInput =\n input.extends ??\n ((await p.text({\n message: \"Extending an existing app?\",\n placeholder: \"bos://dev.everything.near/everything.dev\",\n })) as string);\n\n if (p.isCancel(extendsInput)) process.exit(0);\n\n let extendsAccount = \"dev.everything.near\";\n let extendsGateway = \"everything.dev\";\n\n if (extendsInput) {\n const parsed = parseExtendsRef(extendsInput);\n if (parsed) {\n extendsAccount = parsed.account;\n extendsGateway = parsed.gateway;\n }\n }\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 accountDefault = domain ? deriveAccountFromExtends(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 overrides =\n input.overrides ??\n ((await p.multiselect({\n message: \"Which sections would you like to customize\",\n options: OVERRIDE_OPTIONS,\n initialValues: [\"ui\", \"api\"] as OverrideSection[],\n required: false,\n })) as OverrideSection[]);\n\n if (p.isCancel(overrides)) process.exit(0);\n\n let plugins: string[] = [];\n if (overrides.includes(\"plugins\")) {\n const parentPlugins = input.parentPluginKeys ?? [];\n const pluginOptions =\n parentPlugins.length > 0 ? parentPlugins.map((key) => ({ value: key, label: key })) : [];\n\n plugins =\n input.plugins ??\n (pluginOptions.length > 0\n ? ((await p.multiselect({\n message: \"Select plugins to include:\",\n options: pluginOptions,\n required: false,\n })) as string[])\n : []);\n\n if (p.isCancel(plugins)) process.exit(0);\n }\n\n const go = await p.confirm({\n message: \"GO!\",\n initialValue: true,\n });\n\n if (p.isCancel(go) || !go) process.exit(0);\n\n return {\n extendsAccount,\n extendsGateway,\n directory,\n account: account || undefined,\n domain: domain || undefined,\n plugins,\n overrides,\n };\n}\n"],"mappings":";;;;AAIA,SAAS,gBAAgB,KAA0D;CAEjF,MAAM,SADa,IAAI,WAAW,SAAS,GAAG,MAAM,SAAS,OACpC,MAAM,0BAA0B;AACzD,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO;EAAE,SAAS,MAAM;EAAI,SAAS,MAAM;EAAI;;AAGjD,SAAS,yBAAyB,QAAgB,gBAAgC;CAChF,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,mBAA8E;CAClF;EA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M,gBACJ,cAAc,SAAS,IAAI,cAAc,KAAK,SAAS;GAAE,OAAO;GAAK,OAAO;GAAK,EAAE,GAAG,EAAE;AAE1F,YACE,MAAM,YACL,cAAc,SAAS,IAClB,MAAM,EAAE,YAAY;GACpB,SAAS;GACT,SAAS;GACT,UAAU;GACX,CAAC,GACF,EAAE;AAER,MAAI,EAAE,SAAS,QAAQ,CAAE,SAAQ,KAAK,EAAE;;CAG1C,MAAM,KAAK,MAAM,EAAE,QAAQ;EACzB,SAAS;EACT,cAAc;EACf,CAAC;AAEF,KAAI,EAAE,SAAS,GAAG,IAAI,CAAC,GAAI,SAAQ,KAAK,EAAE;AAE1C,QAAO;EACL;EACA;EACA;EACA,SAAS,WAAW;EACpB,QAAQ,UAAU;EAClB;EACA;EACD"}
@@ -7,11 +7,11 @@ const require_sync = require('./sync.cjs');
7
7
  const require_timing = require('./timing.cjs');
8
8
  let node_fs = require("node:fs");
9
9
  let node_path = require("node:path");
10
+ let node_process = require("node:process");
11
+ node_process = require_runtime.__toESM(node_process, 1);
10
12
  let _clack_prompts = require("@clack/prompts");
11
13
  _clack_prompts = require_runtime.__toESM(_clack_prompts, 1);
12
14
  let glob = require("glob");
13
- let node_process = require("node:process");
14
- node_process = require_runtime.__toESM(node_process, 1);
15
15
 
16
16
  //#region src/cli/upgrade.ts
17
17
  const FRAMEWORK_PACKAGES = ["everything-dev", "every-plugin"];
@@ -6,9 +6,9 @@ import { syncTemplate } from "./sync.mjs";
6
6
  import { timePhase } from "./timing.mjs";
7
7
  import { existsSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
8
8
  import { join } from "node:path";
9
+ import process from "node:process";
9
10
  import * as p from "@clack/prompts";
10
11
  import { glob } from "glob";
11
- import process from "node:process";
12
12
 
13
13
  //#region src/cli/upgrade.ts
14
14
  const FRAMEWORK_PACKAGES = ["everything-dev", "every-plugin"];
@@ -263,8 +263,8 @@ declare const PublishOptionsSchema: z.ZodObject<{
263
263
  dryRun: z.ZodDefault<z.ZodBoolean>;
264
264
  packages: z.ZodDefault<z.ZodString>;
265
265
  network: z.ZodOptional<z.ZodEnum<{
266
- testnet: "testnet";
267
266
  mainnet: "mainnet";
267
+ testnet: "testnet";
268
268
  }>>;
269
269
  privateKey: z.ZodOptional<z.ZodString>;
270
270
  }, z.core.$strip>;
@@ -290,8 +290,8 @@ declare const KeyPublishResultSchema: z.ZodObject<{
290
290
  }>;
291
291
  account: z.ZodString;
292
292
  network: z.ZodEnum<{
293
- testnet: "testnet";
294
293
  mainnet: "mainnet";
294
+ testnet: "testnet";
295
295
  }>;
296
296
  contract: z.ZodString;
297
297
  allowance: z.ZodString;
@@ -303,8 +303,8 @@ declare const KeyPublishResultSchema: z.ZodObject<{
303
303
  declare const OverrideSectionSchema: z.ZodEnum<{
304
304
  plugins: "plugins";
305
305
  ui: "ui";
306
- host: "host";
307
306
  api: "api";
307
+ host: "host";
308
308
  }>;
309
309
  declare const InitOptionsSchema: z.ZodObject<{
310
310
  extends: z.ZodOptional<z.ZodString>;
@@ -316,8 +316,8 @@ declare const InitOptionsSchema: z.ZodObject<{
316
316
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
317
317
  plugins: "plugins";
318
318
  ui: "ui";
319
- host: "host";
320
319
  api: "api";
320
+ host: "host";
321
321
  }>>>;
322
322
  noInteractive: z.ZodDefault<z.ZodBoolean>;
323
323
  noInstall: z.ZodDefault<z.ZodBoolean>;
@@ -340,8 +340,8 @@ declare const InitResultSchema: z.ZodObject<{
340
340
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
341
341
  plugins: "plugins";
342
342
  ui: "ui";
343
- host: "host";
344
343
  api: "api";
344
+ host: "host";
345
345
  }>>>;
346
346
  filesCopied: z.ZodNumber;
347
347
  timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -428,8 +428,8 @@ declare const StatusResultSchema: z.ZodObject<{
428
428
  }, z.core.$strip>;
429
429
  declare const TypesGenOptionsSchema: z.ZodObject<{
430
430
  env: z.ZodOptional<z.ZodEnum<{
431
- development: "development";
432
431
  production: "production";
432
+ development: "development";
433
433
  }>>;
434
434
  dryRun: z.ZodDefault<z.ZodBoolean>;
435
435
  }, z.core.$strip>;
@@ -704,8 +704,8 @@ declare const bosContract: {
704
704
  dryRun: z.ZodDefault<z.ZodBoolean>;
705
705
  packages: z.ZodDefault<z.ZodString>;
706
706
  network: z.ZodOptional<z.ZodEnum<{
707
- testnet: "testnet";
708
707
  mainnet: "mainnet";
708
+ testnet: "testnet";
709
709
  }>>;
710
710
  privateKey: z.ZodOptional<z.ZodString>;
711
711
  }, z.core.$strip>, z.ZodObject<{
@@ -729,8 +729,8 @@ declare const bosContract: {
729
729
  }>;
730
730
  account: z.ZodString;
731
731
  network: z.ZodEnum<{
732
- testnet: "testnet";
733
732
  mainnet: "mainnet";
733
+ testnet: "testnet";
734
734
  }>;
735
735
  contract: z.ZodString;
736
736
  allowance: z.ZodString;
@@ -749,8 +749,8 @@ declare const bosContract: {
749
749
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
750
750
  plugins: "plugins";
751
751
  ui: "ui";
752
- host: "host";
753
752
  api: "api";
753
+ host: "host";
754
754
  }>>>;
755
755
  noInteractive: z.ZodDefault<z.ZodBoolean>;
756
756
  noInstall: z.ZodDefault<z.ZodBoolean>;
@@ -768,8 +768,8 @@ declare const bosContract: {
768
768
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
769
769
  plugins: "plugins";
770
770
  ui: "ui";
771
- host: "host";
772
771
  api: "api";
772
+ host: "host";
773
773
  }>>>;
774
774
  filesCopied: z.ZodNumber;
775
775
  timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -854,8 +854,8 @@ declare const bosContract: {
854
854
  }, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
855
855
  typesGen: ContractProcedure<z.ZodObject<{
856
856
  env: z.ZodOptional<z.ZodEnum<{
857
- development: "development";
858
857
  production: "production";
858
+ development: "development";
859
859
  }>>;
860
860
  dryRun: z.ZodDefault<z.ZodBoolean>;
861
861
  }, z.core.$strip>, z.ZodObject<{