everything-dev 1.46.0 → 1.46.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.
package/dist/build.cjs CHANGED
@@ -97,27 +97,34 @@ async function runBuildAttempt(cmd, args, cwd, env, verbose, wsKey) {
97
97
  const exitCode = result?.exitCode ?? 0;
98
98
  const output = `${stdout}\n${stderr}`;
99
99
  const deployEntries = require_integrity.parseDeployLines(output);
100
+ if (deployEntries.length > 0) {
101
+ if (exitCode !== 0) {
102
+ const errorLines = output.split("\n").filter((line) => /\bERROR\b/.test(line) || line.startsWith("Rspack compiled with")).slice(0, 5);
103
+ if (errorLines.length > 0 && !verbose) {
104
+ console.log(` ${require_theme.colors.yellow("⚠")} Build completed with errors (exit code ${exitCode}) — Zephyr deployed successfully`);
105
+ for (const line of errorLines) console.log(` ${require_theme.colors.dim(line.trim())}`);
106
+ }
107
+ }
108
+ return {
109
+ success: true,
110
+ url: deployEntries[0]?.url,
111
+ exitCode: 0,
112
+ output,
113
+ deployEntries
114
+ };
115
+ }
100
116
  if (exitCode !== 0) return {
101
117
  success: false,
102
118
  error: `Build failed (exit code ${exitCode})\n${output.trim().split("\n").slice(-5).join("\n")}`,
103
119
  exitCode,
104
- output,
105
- deployEntries
120
+ output
106
121
  };
107
122
  const zeMatch = output.match(/ZE\d+/);
108
123
  if (zeMatch) return {
109
124
  success: false,
110
125
  error: `Zephyr upload failed (${zeMatch[0]})`,
111
126
  exitCode: 0,
112
- output,
113
- deployEntries
114
- };
115
- if (deployEntries.length > 0) return {
116
- success: true,
117
- url: deployEntries[0]?.url,
118
- exitCode: 0,
119
- output,
120
- deployEntries
127
+ output
121
128
  };
122
129
  const deployMatch = output.match(/🚀.*Deployed:\s*(https?:\S+)/);
123
130
  if (deployMatch) return {
@@ -1 +1 @@
1
- {"version":3,"file":"build.cjs","names":["resolveLocalDevelopmentPath","run","colors","parseDeployLines","padRight","formatDuration","icons","syncResolvedSharedDeps","process","applyDeployResults"],"sources":["../src/build.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { access, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport process from \"node:process\";\nimport { formatDuration } from \"./cli/timing\";\nimport { resolveLocalDevelopmentPath } from \"./config\";\nimport type { WorkspaceDeployResult } from \"./contract\";\nimport { applyDeployResults, type DeployResultEntry, parseDeployLines } from \"./integrity\";\nimport { syncResolvedSharedDeps } from \"./shared-deps\";\nimport type { BosConfig, BosPluginRef, RuntimeConfig } from \"./types\";\nimport { run } from \"./utils/run\";\nimport { padRight } from \"./utils/string\";\nimport { colors, icons } from \"./utils/theme\";\n\nconst buildCommands: Record<string, { cmd: string; args: string[] }> = {\n host: { cmd: \"bun\", args: [\"run\", \"build\"] },\n ui: { cmd: \"bun\", args: [\"run\", \"build\"] },\n api: { cmd: \"bun\", args: [\"run\", \"build\"] },\n};\n\ntype WorkspaceTarget = {\n key: string;\n kind: \"app\" | \"plugin\";\n path: string;\n};\n\nexport function getPluginRef(entry: string | BosPluginRef | undefined | null): BosPluginRef | null {\n if (!entry || typeof entry === \"string\") return null;\n return entry;\n}\n\nexport async function fileExists(path: string): Promise<boolean> {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function readJsonFile<T>(path: string): Promise<T> {\n return JSON.parse(await readFile(path, \"utf8\")) as T;\n}\n\nfunction resolveWorkspaceTarget(\n key: string,\n bosConfig: BosConfig | null,\n runtimeConfig: RuntimeConfig | null,\n configDir: string,\n): WorkspaceTarget | null {\n if (bosConfig?.app && key in bosConfig.app) {\n const appEntry = (bosConfig.app as Record<string, { development?: string }>)[key];\n const devPath = resolveLocalDevelopmentPath(appEntry?.development, configDir);\n if (devPath) {\n return {\n key,\n kind: \"app\",\n path: devPath,\n };\n }\n return {\n key,\n kind: \"app\",\n path: `${configDir}/${key}`,\n };\n }\n\n const runtimePlugin = runtimeConfig?.plugins?.[key];\n const pluginPath =\n runtimePlugin?.localPath ??\n resolveLocalDevelopmentPath(getPluginRef(bosConfig?.plugins?.[key])?.development, configDir);\n if (pluginPath) {\n return {\n key,\n kind: \"plugin\",\n path: pluginPath,\n };\n }\n\n return null;\n}\n\nexport function selectWorkspaceTargets(packages: string, bosConfig: BosConfig | null): string[] {\n const allPackages = [\n ...Object.keys(bosConfig?.app ?? {}),\n ...Object.keys(bosConfig?.plugins ?? {}),\n ];\n if (packages === \"all\") {\n return allPackages;\n }\n\n return packages\n .split(\",\")\n .map((pkg) => pkg.trim())\n .filter((pkg) => allPackages.includes(pkg));\n}\n\ninterface BuildAttemptResult {\n success: boolean;\n url?: string;\n error?: string;\n exitCode: number;\n output: string;\n deployEntries?: DeployResultEntry[];\n}\n\nasync function runBuildAttempt(\n cmd: string,\n args: string[],\n cwd: string,\n env: Record<string, string>,\n verbose: boolean,\n wsKey: string,\n): Promise<BuildAttemptResult> {\n let zephyrAuthShown = false;\n const result = await run(cmd, args, {\n cwd,\n env,\n capture: true,\n onChunk: (stream, chunk) => {\n if (verbose) {\n if (stream === \"stdout\") process.stdout.write(chunk);\n else process.stderr.write(chunk);\n }\n if (zephyrAuthShown) return;\n const text = chunk.toString(\"utf-8\");\n if (\n /Authentication required.*log in to Zephyr/i.test(text) ||\n /auth\\.zephyr-cloud\\.io\\/authorize/.test(text)\n ) {\n zephyrAuthShown = true;\n const urlMatch = text.match(/https:\\/\\/auth\\.zephyr-cloud\\.io\\/authorize\\S+/);\n console.log();\n console.log(colors.yellow(` ⚠ Zephyr authentication required for ${wsKey}`));\n if (urlMatch) {\n console.log(` ${colors.cyan(urlMatch[0])}`);\n }\n console.log(colors.dim(\" Waiting for authentication...\"));\n console.log();\n }\n },\n });\n const stdout = result?.stdout ?? \"\";\n const stderr = result?.stderr ?? \"\";\n const exitCode = result?.exitCode ?? 0;\n const output = `${stdout}\\n${stderr}`;\n\n const deployEntries = parseDeployLines(output);\n\n if (exitCode !== 0) {\n const lastLines = output.trim().split(\"\\n\").slice(-5).join(\"\\n\");\n return {\n success: false,\n error: `Build failed (exit code ${exitCode})\\n${lastLines}`,\n exitCode,\n output,\n deployEntries,\n };\n }\n\n const zeMatch = output.match(/ZE\\d+/);\n if (zeMatch) {\n return {\n success: false,\n error: `Zephyr upload failed (${zeMatch[0]})`,\n exitCode: 0,\n output,\n deployEntries,\n };\n }\n\n if (deployEntries.length > 0) {\n return { success: true, url: deployEntries[0]?.url, exitCode: 0, output, deployEntries };\n }\n\n const deployMatch = output.match(/🚀.*Deployed:\\s*(https?:\\S+)/);\n if (deployMatch) {\n return { success: true, url: deployMatch[1], exitCode: 0, output };\n }\n\n if (env.DEPLOY === \"true\") {\n return {\n success: false,\n error: \"No deploy URL found (Zephyr may have failed)\",\n exitCode: 0,\n output,\n };\n }\n return { success: true, exitCode: 0, output };\n}\n\ninterface InternalWorkspaceResult extends WorkspaceDeployResult {\n deployEntries?: DeployResultEntry[];\n}\n\nasync function buildOneWorkspace(\n ws: WorkspaceTarget,\n env: Record<string, string>,\n opts: { deploy: boolean; verbose?: boolean },\n): Promise<InternalWorkspaceResult> {\n const pkgJson = await readJsonFile<{\n scripts?: Record<string, string>;\n }>(`${ws.path}/package.json`);\n const shouldDeployScript = opts.deploy && pkgJson.scripts?.deploy;\n const buildConfig = shouldDeployScript\n ? { cmd: \"bun\", args: [\"run\", \"deploy\"] }\n : (buildCommands[ws.key] ?? { cmd: \"bun\", args: [\"run\", \"build\"] });\n\n const wsEnv = { ...env };\n\n const startTime = Date.now();\n let attempt = await runBuildAttempt(\n buildConfig.cmd,\n buildConfig.args,\n ws.path,\n wsEnv,\n opts.verbose ?? false,\n ws.key,\n );\n\n let retried = false;\n\n if (!attempt.success && attempt.exitCode === 0 && opts.deploy) {\n if (!opts.verbose) {\n console.log(` ${colors.yellow(\"↻\")} ${padRight(ws.key, 28)} retrying...`);\n }\n retried = true;\n attempt = await runBuildAttempt(\n buildConfig.cmd,\n buildConfig.args,\n ws.path,\n wsEnv,\n opts.verbose ?? false,\n ws.key,\n );\n }\n\n const durationMs = Date.now() - startTime;\n const result: InternalWorkspaceResult = {\n key: ws.key,\n kind: ws.kind,\n success: attempt.success,\n url: attempt.url,\n error: attempt.error,\n deployEntries: attempt.deployEntries,\n durationMs,\n retried: retried ? true : undefined,\n };\n\n if (!opts.verbose) {\n const name = padRight(ws.key, 28);\n if (result.success) {\n const duration = formatDuration(durationMs);\n const retryTag = retried ? \" (retried)\" : \"\";\n console.log(` ${colors.green(icons.ok)} ${name} ${colors.dim(duration + retryTag)}`);\n } else {\n const errorLine = (result.error ?? \"Failed\").split(\"\\n\")[0];\n console.log(` ${colors.error(icons.err)} ${name} ${errorLine}`);\n }\n }\n\n return result;\n}\n\nexport async function buildWorkspaceTargets(opts: {\n configDir: string;\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n targets: string[];\n deploy: boolean;\n verbose?: boolean;\n}): Promise<{\n built: string[];\n skipped: string[];\n deployResults?: WorkspaceDeployResult[];\n}> {\n const existing: WorkspaceTarget[] = [];\n const skipped: string[] = [];\n\n for (const target of opts.targets) {\n const resolved = resolveWorkspaceTarget(\n target,\n opts.bosConfig,\n opts.runtimeConfig,\n opts.configDir,\n );\n if (!resolved) {\n skipped.push(target);\n continue;\n }\n\n const exists = await fileExists(`${resolved.path}/package.json`);\n if (exists) existing.push(resolved);\n else skipped.push(target);\n }\n\n if (existing.length === 0) {\n return { built: [], skipped };\n }\n\n const sharedSync = await syncResolvedSharedDeps({\n configDir: opts.configDir,\n hostMode: \"local\",\n bosConfig: opts.bosConfig ?? undefined,\n extendsChain: [],\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: opts.configDir });\n }\n\n const shouldBuildPlugin = existing.some((entry) => entry.key === \"api\");\n\n const forceRebuild = opts.deploy;\n const buildTasks: Promise<void>[] = [buildEverythingDevQuietly(opts.configDir, forceRebuild)];\n if (shouldBuildPlugin) {\n buildTasks.push(buildEveryPluginQuietly(opts.configDir, forceRebuild));\n }\n await Promise.all(buildTasks);\n\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: opts.deploy ? \"production\" : \"development\",\n };\n if (opts.deploy) {\n env.DEPLOY = \"true\";\n } else {\n delete env.DEPLOY;\n }\n\n const bosConfigPath = join(opts.configDir, \"bos.config.json\");\n let configSnapshot: string | undefined;\n if (opts.deploy && existsSync(bosConfigPath)) {\n configSnapshot = readFileSync(bosConfigPath, \"utf-8\");\n }\n\n const orderedExisting = opts.deploy\n ? [\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key !== \"host\"),\n ...existing.filter((entry) => entry.kind === \"plugin\"),\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key === \"host\"),\n ]\n : existing;\n\n const parallelGroup = opts.deploy\n ? orderedExisting.filter((e) => e.key !== \"host\")\n : orderedExisting;\n const sequentialGroup = opts.deploy ? orderedExisting.filter((e) => e.key === \"host\") : [];\n\n const built: string[] = [];\n const deployResults: WorkspaceDeployResult[] = [];\n\n if (opts.deploy && parallelGroup.length > 0) {\n const total = parallelGroup.length + sequentialGroup.length;\n console.log();\n console.log(` Building ${total} workspace${total > 1 ? \"s\" : \"\"}...`);\n console.log();\n\n const results = await Promise.allSettled(\n parallelGroup.map((ws) => buildOneWorkspace(ws, env, opts)),\n );\n\n const allDeployEntries: DeployResultEntry[] = [];\n for (let i = 0; i < parallelGroup.length; i++) {\n const ws = parallelGroup[i];\n const result = results[i];\n if (result.status === \"fulfilled\") {\n if (result.value.success) {\n built.push(ws.key);\n }\n if (result.value.deployEntries) {\n allDeployEntries.push(...result.value.deployEntries);\n }\n const { deployEntries: _deployEntries, ...deployResult } = result.value;\n deployResults.push(deployResult);\n } else {\n deployResults.push({\n key: ws.key,\n kind: ws.kind,\n success: false,\n error: result.reason?.message ?? \"Unknown error\",\n });\n }\n }\n\n if (configSnapshot && allDeployEntries.length > 0) {\n const config = JSON.parse(configSnapshot) as Record<string, unknown>;\n const merged = applyDeployResults(config, allDeployEntries);\n writeFileSync(bosConfigPath, `${JSON.stringify(merged, null, 2)}\\n`);\n }\n\n for (const ws of sequentialGroup) {\n const result = await buildOneWorkspace(ws, env, opts);\n if (result.success) {\n built.push(ws.key);\n }\n if (result.deployEntries) {\n const hostEntries = result.deployEntries.filter((r) => r.urlField.startsWith(\"app.host\"));\n if (hostEntries.length > 0 && existsSync(bosConfigPath)) {\n const currentConfig = JSON.parse(readFileSync(bosConfigPath, \"utf-8\")) as Record<\n string,\n unknown\n >;\n const merged = applyDeployResults(currentConfig, hostEntries);\n writeFileSync(bosConfigPath, `${JSON.stringify(merged, null, 2)}\\n`);\n }\n }\n const { deployEntries: _deployEntries, ...sequentialResult } = result;\n deployResults.push(sequentialResult);\n }\n\n console.log();\n } else {\n for (const resolved of orderedExisting) {\n const buildConfig = buildCommands[resolved.key] ?? {\n cmd: \"bun\",\n args: [\"run\", \"build\"],\n };\n\n await run(buildConfig.cmd, buildConfig.args, {\n cwd: resolved.path,\n env,\n });\n built.push(resolved.key);\n }\n }\n\n return { built, skipped, deployResults: opts.deploy ? deployResults : undefined };\n}\n\nexport async function buildEveryPluginQuietly(cwd: string, force = false) {\n const packageDir = `${cwd}/packages/every-plugin`;\n const packageExists = await fileExists(`${packageDir}/package.json`);\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;\n const distExists = await fileExists(distPath);\n\n if (distExists && !force) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/every-plugin\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`,\n );\n}\n\nexport async function buildEverythingDevQuietly(cwd: string, force = false) {\n const packageDir = `${cwd}/packages/everything-dev`;\n const packageExists = await fileExists(`${packageDir}/package.json`);\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;\n const distExists = await fileExists(distPath);\n\n if (distExists && !force) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/everything-dev\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAM,gBAAiE;CACrE,MAAM;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C,IAAI;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC1C,KAAK;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C;AAQD,SAAgB,aAAa,OAAsE;AACjG,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAO;;AAGT,eAAsB,WAAW,MAAgC;AAC/D,KAAI;AACF,qCAAa,KAAK;AAClB,SAAO;SACD;AACN,SAAO;;;AAIX,eAAsB,aAAgB,MAA0B;AAC9D,QAAO,KAAK,MAAM,qCAAe,MAAM,OAAO,CAAC;;AAGjD,SAAS,uBACP,KACA,WACA,eACA,WACwB;AACxB,KAAI,WAAW,OAAO,OAAO,UAAU,KAAK;EAC1C,MAAM,WAAY,UAAU,IAAiD;EAC7E,MAAM,UAAUA,2CAA4B,UAAU,aAAa,UAAU;AAC7E,MAAI,QACF,QAAO;GACL;GACA,MAAM;GACN,MAAM;GACP;AAEH,SAAO;GACL;GACA,MAAM;GACN,MAAM,GAAG,UAAU,GAAG;GACvB;;CAIH,MAAM,cADgB,eAAe,UAAU,OAE9B,aACfA,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O,OAAO;AAGrC,KAAI,OAAO,OAAO,MAAM,CACtB,sBAAQ,OAAO,MAAM,OAAO,OAAO;AAGrC,OAAM,IAAI,MACR,qEAAqE,OAAO,WAC7E"}
1
+ {"version":3,"file":"build.cjs","names":["resolveLocalDevelopmentPath","run","colors","parseDeployLines","padRight","formatDuration","icons","syncResolvedSharedDeps","process","applyDeployResults"],"sources":["../src/build.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { access, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport process from \"node:process\";\nimport { formatDuration } from \"./cli/timing\";\nimport { resolveLocalDevelopmentPath } from \"./config\";\nimport type { WorkspaceDeployResult } from \"./contract\";\nimport { applyDeployResults, type DeployResultEntry, parseDeployLines } from \"./integrity\";\nimport { syncResolvedSharedDeps } from \"./shared-deps\";\nimport type { BosConfig, BosPluginRef, RuntimeConfig } from \"./types\";\nimport { run } from \"./utils/run\";\nimport { padRight } from \"./utils/string\";\nimport { colors, icons } from \"./utils/theme\";\n\nconst buildCommands: Record<string, { cmd: string; args: string[] }> = {\n host: { cmd: \"bun\", args: [\"run\", \"build\"] },\n ui: { cmd: \"bun\", args: [\"run\", \"build\"] },\n api: { cmd: \"bun\", args: [\"run\", \"build\"] },\n};\n\ntype WorkspaceTarget = {\n key: string;\n kind: \"app\" | \"plugin\";\n path: string;\n};\n\nexport function getPluginRef(entry: string | BosPluginRef | undefined | null): BosPluginRef | null {\n if (!entry || typeof entry === \"string\") return null;\n return entry;\n}\n\nexport async function fileExists(path: string): Promise<boolean> {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function readJsonFile<T>(path: string): Promise<T> {\n return JSON.parse(await readFile(path, \"utf8\")) as T;\n}\n\nfunction resolveWorkspaceTarget(\n key: string,\n bosConfig: BosConfig | null,\n runtimeConfig: RuntimeConfig | null,\n configDir: string,\n): WorkspaceTarget | null {\n if (bosConfig?.app && key in bosConfig.app) {\n const appEntry = (bosConfig.app as Record<string, { development?: string }>)[key];\n const devPath = resolveLocalDevelopmentPath(appEntry?.development, configDir);\n if (devPath) {\n return {\n key,\n kind: \"app\",\n path: devPath,\n };\n }\n return {\n key,\n kind: \"app\",\n path: `${configDir}/${key}`,\n };\n }\n\n const runtimePlugin = runtimeConfig?.plugins?.[key];\n const pluginPath =\n runtimePlugin?.localPath ??\n resolveLocalDevelopmentPath(getPluginRef(bosConfig?.plugins?.[key])?.development, configDir);\n if (pluginPath) {\n return {\n key,\n kind: \"plugin\",\n path: pluginPath,\n };\n }\n\n return null;\n}\n\nexport function selectWorkspaceTargets(packages: string, bosConfig: BosConfig | null): string[] {\n const allPackages = [\n ...Object.keys(bosConfig?.app ?? {}),\n ...Object.keys(bosConfig?.plugins ?? {}),\n ];\n if (packages === \"all\") {\n return allPackages;\n }\n\n return packages\n .split(\",\")\n .map((pkg) => pkg.trim())\n .filter((pkg) => allPackages.includes(pkg));\n}\n\ninterface BuildAttemptResult {\n success: boolean;\n url?: string;\n error?: string;\n exitCode: number;\n output: string;\n deployEntries?: DeployResultEntry[];\n}\n\nasync function runBuildAttempt(\n cmd: string,\n args: string[],\n cwd: string,\n env: Record<string, string>,\n verbose: boolean,\n wsKey: string,\n): Promise<BuildAttemptResult> {\n let zephyrAuthShown = false;\n const result = await run(cmd, args, {\n cwd,\n env,\n capture: true,\n onChunk: (stream, chunk) => {\n if (verbose) {\n if (stream === \"stdout\") process.stdout.write(chunk);\n else process.stderr.write(chunk);\n }\n if (zephyrAuthShown) return;\n const text = chunk.toString(\"utf-8\");\n if (\n /Authentication required.*log in to Zephyr/i.test(text) ||\n /auth\\.zephyr-cloud\\.io\\/authorize/.test(text)\n ) {\n zephyrAuthShown = true;\n const urlMatch = text.match(/https:\\/\\/auth\\.zephyr-cloud\\.io\\/authorize\\S+/);\n console.log();\n console.log(colors.yellow(` ⚠ Zephyr authentication required for ${wsKey}`));\n if (urlMatch) {\n console.log(` ${colors.cyan(urlMatch[0])}`);\n }\n console.log(colors.dim(\" Waiting for authentication...\"));\n console.log();\n }\n },\n });\n const stdout = result?.stdout ?? \"\";\n const stderr = result?.stderr ?? \"\";\n const exitCode = result?.exitCode ?? 0;\n const output = `${stdout}\\n${stderr}`;\n\n const deployEntries = parseDeployLines(output);\n\n if (deployEntries.length > 0) {\n if (exitCode !== 0) {\n const errorLines = output\n .split(\"\\n\")\n .filter((line) => /\\bERROR\\b/.test(line) || line.startsWith(\"Rspack compiled with\"))\n .slice(0, 5);\n if (errorLines.length > 0 && !verbose) {\n console.log(\n ` ${colors.yellow(\"⚠\")} Build completed with errors (exit code ${exitCode}) — Zephyr deployed successfully`,\n );\n for (const line of errorLines) {\n console.log(` ${colors.dim(line.trim())}`);\n }\n }\n }\n return { success: true, url: deployEntries[0]?.url, exitCode: 0, output, deployEntries };\n }\n\n if (exitCode !== 0) {\n const lastLines = output.trim().split(\"\\n\").slice(-5).join(\"\\n\");\n return {\n success: false,\n error: `Build failed (exit code ${exitCode})\\n${lastLines}`,\n exitCode,\n output,\n };\n }\n\n const zeMatch = output.match(/ZE\\d+/);\n if (zeMatch) {\n return {\n success: false,\n error: `Zephyr upload failed (${zeMatch[0]})`,\n exitCode: 0,\n output,\n };\n }\n\n const deployMatch = output.match(/🚀.*Deployed:\\s*(https?:\\S+)/);\n if (deployMatch) {\n return { success: true, url: deployMatch[1], exitCode: 0, output };\n }\n\n if (env.DEPLOY === \"true\") {\n return {\n success: false,\n error: \"No deploy URL found (Zephyr may have failed)\",\n exitCode: 0,\n output,\n };\n }\n return { success: true, exitCode: 0, output };\n}\n\ninterface InternalWorkspaceResult extends WorkspaceDeployResult {\n deployEntries?: DeployResultEntry[];\n}\n\nasync function buildOneWorkspace(\n ws: WorkspaceTarget,\n env: Record<string, string>,\n opts: { deploy: boolean; verbose?: boolean },\n): Promise<InternalWorkspaceResult> {\n const pkgJson = await readJsonFile<{\n scripts?: Record<string, string>;\n }>(`${ws.path}/package.json`);\n const shouldDeployScript = opts.deploy && pkgJson.scripts?.deploy;\n const buildConfig = shouldDeployScript\n ? { cmd: \"bun\", args: [\"run\", \"deploy\"] }\n : (buildCommands[ws.key] ?? { cmd: \"bun\", args: [\"run\", \"build\"] });\n\n const wsEnv = { ...env };\n\n const startTime = Date.now();\n let attempt = await runBuildAttempt(\n buildConfig.cmd,\n buildConfig.args,\n ws.path,\n wsEnv,\n opts.verbose ?? false,\n ws.key,\n );\n\n let retried = false;\n\n if (!attempt.success && attempt.exitCode === 0 && opts.deploy) {\n if (!opts.verbose) {\n console.log(` ${colors.yellow(\"↻\")} ${padRight(ws.key, 28)} retrying...`);\n }\n retried = true;\n attempt = await runBuildAttempt(\n buildConfig.cmd,\n buildConfig.args,\n ws.path,\n wsEnv,\n opts.verbose ?? false,\n ws.key,\n );\n }\n\n const durationMs = Date.now() - startTime;\n const result: InternalWorkspaceResult = {\n key: ws.key,\n kind: ws.kind,\n success: attempt.success,\n url: attempt.url,\n error: attempt.error,\n deployEntries: attempt.deployEntries,\n durationMs,\n retried: retried ? true : undefined,\n };\n\n if (!opts.verbose) {\n const name = padRight(ws.key, 28);\n if (result.success) {\n const duration = formatDuration(durationMs);\n const retryTag = retried ? \" (retried)\" : \"\";\n console.log(` ${colors.green(icons.ok)} ${name} ${colors.dim(duration + retryTag)}`);\n } else {\n const errorLine = (result.error ?? \"Failed\").split(\"\\n\")[0];\n console.log(` ${colors.error(icons.err)} ${name} ${errorLine}`);\n }\n }\n\n return result;\n}\n\nexport async function buildWorkspaceTargets(opts: {\n configDir: string;\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n targets: string[];\n deploy: boolean;\n verbose?: boolean;\n}): Promise<{\n built: string[];\n skipped: string[];\n deployResults?: WorkspaceDeployResult[];\n}> {\n const existing: WorkspaceTarget[] = [];\n const skipped: string[] = [];\n\n for (const target of opts.targets) {\n const resolved = resolveWorkspaceTarget(\n target,\n opts.bosConfig,\n opts.runtimeConfig,\n opts.configDir,\n );\n if (!resolved) {\n skipped.push(target);\n continue;\n }\n\n const exists = await fileExists(`${resolved.path}/package.json`);\n if (exists) existing.push(resolved);\n else skipped.push(target);\n }\n\n if (existing.length === 0) {\n return { built: [], skipped };\n }\n\n const sharedSync = await syncResolvedSharedDeps({\n configDir: opts.configDir,\n hostMode: \"local\",\n bosConfig: opts.bosConfig ?? undefined,\n extendsChain: [],\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: opts.configDir });\n }\n\n const shouldBuildPlugin = existing.some((entry) => entry.key === \"api\");\n\n const forceRebuild = opts.deploy;\n const buildTasks: Promise<void>[] = [buildEverythingDevQuietly(opts.configDir, forceRebuild)];\n if (shouldBuildPlugin) {\n buildTasks.push(buildEveryPluginQuietly(opts.configDir, forceRebuild));\n }\n await Promise.all(buildTasks);\n\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: opts.deploy ? \"production\" : \"development\",\n };\n if (opts.deploy) {\n env.DEPLOY = \"true\";\n } else {\n delete env.DEPLOY;\n }\n\n const bosConfigPath = join(opts.configDir, \"bos.config.json\");\n let configSnapshot: string | undefined;\n if (opts.deploy && existsSync(bosConfigPath)) {\n configSnapshot = readFileSync(bosConfigPath, \"utf-8\");\n }\n\n const orderedExisting = opts.deploy\n ? [\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key !== \"host\"),\n ...existing.filter((entry) => entry.kind === \"plugin\"),\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key === \"host\"),\n ]\n : existing;\n\n const parallelGroup = opts.deploy\n ? orderedExisting.filter((e) => e.key !== \"host\")\n : orderedExisting;\n const sequentialGroup = opts.deploy ? orderedExisting.filter((e) => e.key === \"host\") : [];\n\n const built: string[] = [];\n const deployResults: WorkspaceDeployResult[] = [];\n\n if (opts.deploy && parallelGroup.length > 0) {\n const total = parallelGroup.length + sequentialGroup.length;\n console.log();\n console.log(` Building ${total} workspace${total > 1 ? \"s\" : \"\"}...`);\n console.log();\n\n const results = await Promise.allSettled(\n parallelGroup.map((ws) => buildOneWorkspace(ws, env, opts)),\n );\n\n const allDeployEntries: DeployResultEntry[] = [];\n for (let i = 0; i < parallelGroup.length; i++) {\n const ws = parallelGroup[i];\n const result = results[i];\n if (result.status === \"fulfilled\") {\n if (result.value.success) {\n built.push(ws.key);\n }\n if (result.value.deployEntries) {\n allDeployEntries.push(...result.value.deployEntries);\n }\n const { deployEntries: _deployEntries, ...deployResult } = result.value;\n deployResults.push(deployResult);\n } else {\n deployResults.push({\n key: ws.key,\n kind: ws.kind,\n success: false,\n error: result.reason?.message ?? \"Unknown error\",\n });\n }\n }\n\n if (configSnapshot && allDeployEntries.length > 0) {\n const config = JSON.parse(configSnapshot) as Record<string, unknown>;\n const merged = applyDeployResults(config, allDeployEntries);\n writeFileSync(bosConfigPath, `${JSON.stringify(merged, null, 2)}\\n`);\n }\n\n for (const ws of sequentialGroup) {\n const result = await buildOneWorkspace(ws, env, opts);\n if (result.success) {\n built.push(ws.key);\n }\n if (result.deployEntries) {\n const hostEntries = result.deployEntries.filter((r) => r.urlField.startsWith(\"app.host\"));\n if (hostEntries.length > 0 && existsSync(bosConfigPath)) {\n const currentConfig = JSON.parse(readFileSync(bosConfigPath, \"utf-8\")) as Record<\n string,\n unknown\n >;\n const merged = applyDeployResults(currentConfig, hostEntries);\n writeFileSync(bosConfigPath, `${JSON.stringify(merged, null, 2)}\\n`);\n }\n }\n const { deployEntries: _deployEntries, ...sequentialResult } = result;\n deployResults.push(sequentialResult);\n }\n\n console.log();\n } else {\n for (const resolved of orderedExisting) {\n const buildConfig = buildCommands[resolved.key] ?? {\n cmd: \"bun\",\n args: [\"run\", \"build\"],\n };\n\n await run(buildConfig.cmd, buildConfig.args, {\n cwd: resolved.path,\n env,\n });\n built.push(resolved.key);\n }\n }\n\n return { built, skipped, deployResults: opts.deploy ? deployResults : undefined };\n}\n\nexport async function buildEveryPluginQuietly(cwd: string, force = false) {\n const packageDir = `${cwd}/packages/every-plugin`;\n const packageExists = await fileExists(`${packageDir}/package.json`);\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;\n const distExists = await fileExists(distPath);\n\n if (distExists && !force) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/every-plugin\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`,\n );\n}\n\nexport async function buildEverythingDevQuietly(cwd: string, force = false) {\n const packageDir = `${cwd}/packages/everything-dev`;\n const packageExists = await fileExists(`${packageDir}/package.json`);\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;\n const distExists = await fileExists(distPath);\n\n if (distExists && !force) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/everything-dev\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAM,gBAAiE;CACrE,MAAM;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C,IAAI;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC1C,KAAK;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C;AAQD,SAAgB,aAAa,OAAsE;AACjG,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAO;;AAGT,eAAsB,W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Q,OAAO;AAGxE,KAAI,CAAC,MADuB,WAAW,GAAG,GADpB,IAAI,wBAC2B,eAAe,CAElE;AAMF,KAAI,MAFqB,WAAW,GADhB,IAAI,qDACqB,IAE3B,CAAC,MACjB;CAGF,MAAM,SAAU,MAAMA,gBAAI,OAAO;EAAC;EAAO;EAAS;EAAyB;EAAQ,EAAE;EACnF;EACA,SAAS;EACV,CAAC;AAEF,KAAI,OAAO,aAAa,EACtB;AAGF,KAAI,OAAO,OAAO,MAAM,CACtB,sBAAQ,OAAO,MAAM,OAAO,OAAO;AAGrC,KAAI,OAAO,OAAO,MAAM,CACtB,sBAAQ,OAAO,MAAM,OAAO,OAAO;AAGrC,OAAM,IAAI,MACR,mEAAmE,OAAO,WAC3E;;AAGH,eAAsB,0BAA0B,KAAa,QAAQ,OAAO;AAG1E,KAAI,CAAC,MADuB,WAAW,GAAG,GADpB,IAAI,0BAC2B,eAAe,CAElE;AAMF,KAAI,MAFqB,WAAW,GADhB,IAAI,yCACqB,IAE3B,CAAC,MACjB;CAGF,MAAM,SAAU,MAAMA,gBAAI,OAAO;EAAC;EAAO;EAAS;EAA2B;EAAQ,EAAE;EACrF;EACA,SAAS;EACV,CAAC;AAEF,KAAI,OAAO,aAAa,EACtB;AAGF,KAAI,OAAO,OAAO,MAAM,CACtB,sBAAQ,OAAO,MAAM,OAAO,OAAO;AAGrC,KAAI,OAAO,OAAO,MAAM,CACtB,sBAAQ,OAAO,MAAM,OAAO,OAAO;AAGrC,OAAM,IAAI,MACR,qEAAqE,OAAO,WAC7E"}
package/dist/build.mjs CHANGED
@@ -95,27 +95,34 @@ async function runBuildAttempt(cmd, args, cwd, env, verbose, wsKey) {
95
95
  const exitCode = result?.exitCode ?? 0;
96
96
  const output = `${stdout}\n${stderr}`;
97
97
  const deployEntries = parseDeployLines(output);
98
+ if (deployEntries.length > 0) {
99
+ if (exitCode !== 0) {
100
+ const errorLines = output.split("\n").filter((line) => /\bERROR\b/.test(line) || line.startsWith("Rspack compiled with")).slice(0, 5);
101
+ if (errorLines.length > 0 && !verbose) {
102
+ console.log(` ${colors.yellow("⚠")} Build completed with errors (exit code ${exitCode}) — Zephyr deployed successfully`);
103
+ for (const line of errorLines) console.log(` ${colors.dim(line.trim())}`);
104
+ }
105
+ }
106
+ return {
107
+ success: true,
108
+ url: deployEntries[0]?.url,
109
+ exitCode: 0,
110
+ output,
111
+ deployEntries
112
+ };
113
+ }
98
114
  if (exitCode !== 0) return {
99
115
  success: false,
100
116
  error: `Build failed (exit code ${exitCode})\n${output.trim().split("\n").slice(-5).join("\n")}`,
101
117
  exitCode,
102
- output,
103
- deployEntries
118
+ output
104
119
  };
105
120
  const zeMatch = output.match(/ZE\d+/);
106
121
  if (zeMatch) return {
107
122
  success: false,
108
123
  error: `Zephyr upload failed (${zeMatch[0]})`,
109
124
  exitCode: 0,
110
- output,
111
- deployEntries
112
- };
113
- if (deployEntries.length > 0) return {
114
- success: true,
115
- url: deployEntries[0]?.url,
116
- exitCode: 0,
117
- output,
118
- deployEntries
125
+ output
119
126
  };
120
127
  const deployMatch = output.match(/🚀.*Deployed:\s*(https?:\S+)/);
121
128
  if (deployMatch) return {
@@ -1 +1 @@
1
- {"version":3,"file":"build.mjs","names":[],"sources":["../src/build.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { access, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport process from \"node:process\";\nimport { formatDuration } from \"./cli/timing\";\nimport { resolveLocalDevelopmentPath } from \"./config\";\nimport type { WorkspaceDeployResult } from \"./contract\";\nimport { applyDeployResults, type DeployResultEntry, parseDeployLines } from \"./integrity\";\nimport { syncResolvedSharedDeps } from \"./shared-deps\";\nimport type { BosConfig, BosPluginRef, RuntimeConfig } from \"./types\";\nimport { run } from \"./utils/run\";\nimport { padRight } from \"./utils/string\";\nimport { colors, icons } from \"./utils/theme\";\n\nconst buildCommands: Record<string, { cmd: string; args: string[] }> = {\n host: { cmd: \"bun\", args: [\"run\", \"build\"] },\n ui: { cmd: \"bun\", args: [\"run\", \"build\"] },\n api: { cmd: \"bun\", args: [\"run\", \"build\"] },\n};\n\ntype WorkspaceTarget = {\n key: string;\n kind: \"app\" | \"plugin\";\n path: string;\n};\n\nexport function getPluginRef(entry: string | BosPluginRef | undefined | null): BosPluginRef | null {\n if (!entry || typeof entry === \"string\") return null;\n return entry;\n}\n\nexport async function fileExists(path: string): Promise<boolean> {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function readJsonFile<T>(path: string): Promise<T> {\n return JSON.parse(await readFile(path, \"utf8\")) as T;\n}\n\nfunction resolveWorkspaceTarget(\n key: string,\n bosConfig: BosConfig | null,\n runtimeConfig: RuntimeConfig | null,\n configDir: string,\n): WorkspaceTarget | null {\n if (bosConfig?.app && key in bosConfig.app) {\n const appEntry = (bosConfig.app as Record<string, { development?: string }>)[key];\n const devPath = resolveLocalDevelopmentPath(appEntry?.development, configDir);\n if (devPath) {\n return {\n key,\n kind: \"app\",\n path: devPath,\n };\n }\n return {\n key,\n kind: \"app\",\n path: `${configDir}/${key}`,\n };\n }\n\n const runtimePlugin = runtimeConfig?.plugins?.[key];\n const pluginPath =\n runtimePlugin?.localPath ??\n resolveLocalDevelopmentPath(getPluginRef(bosConfig?.plugins?.[key])?.development, configDir);\n if (pluginPath) {\n return {\n key,\n kind: \"plugin\",\n path: pluginPath,\n };\n }\n\n return null;\n}\n\nexport function selectWorkspaceTargets(packages: string, bosConfig: BosConfig | null): string[] {\n const allPackages = [\n ...Object.keys(bosConfig?.app ?? {}),\n ...Object.keys(bosConfig?.plugins ?? {}),\n ];\n if (packages === \"all\") {\n return allPackages;\n }\n\n return packages\n .split(\",\")\n .map((pkg) => pkg.trim())\n .filter((pkg) => allPackages.includes(pkg));\n}\n\ninterface BuildAttemptResult {\n success: boolean;\n url?: string;\n error?: string;\n exitCode: number;\n output: string;\n deployEntries?: DeployResultEntry[];\n}\n\nasync function runBuildAttempt(\n cmd: string,\n args: string[],\n cwd: string,\n env: Record<string, string>,\n verbose: boolean,\n wsKey: string,\n): Promise<BuildAttemptResult> {\n let zephyrAuthShown = false;\n const result = await run(cmd, args, {\n cwd,\n env,\n capture: true,\n onChunk: (stream, chunk) => {\n if (verbose) {\n if (stream === \"stdout\") process.stdout.write(chunk);\n else process.stderr.write(chunk);\n }\n if (zephyrAuthShown) return;\n const text = chunk.toString(\"utf-8\");\n if (\n /Authentication required.*log in to Zephyr/i.test(text) ||\n /auth\\.zephyr-cloud\\.io\\/authorize/.test(text)\n ) {\n zephyrAuthShown = true;\n const urlMatch = text.match(/https:\\/\\/auth\\.zephyr-cloud\\.io\\/authorize\\S+/);\n console.log();\n console.log(colors.yellow(` ⚠ Zephyr authentication required for ${wsKey}`));\n if (urlMatch) {\n console.log(` ${colors.cyan(urlMatch[0])}`);\n }\n console.log(colors.dim(\" Waiting for authentication...\"));\n console.log();\n }\n },\n });\n const stdout = result?.stdout ?? \"\";\n const stderr = result?.stderr ?? \"\";\n const exitCode = result?.exitCode ?? 0;\n const output = `${stdout}\\n${stderr}`;\n\n const deployEntries = parseDeployLines(output);\n\n if (exitCode !== 0) {\n const lastLines = output.trim().split(\"\\n\").slice(-5).join(\"\\n\");\n return {\n success: false,\n error: `Build failed (exit code ${exitCode})\\n${lastLines}`,\n exitCode,\n output,\n deployEntries,\n };\n }\n\n const zeMatch = output.match(/ZE\\d+/);\n if (zeMatch) {\n return {\n success: false,\n error: `Zephyr upload failed (${zeMatch[0]})`,\n exitCode: 0,\n output,\n deployEntries,\n };\n }\n\n if (deployEntries.length > 0) {\n return { success: true, url: deployEntries[0]?.url, exitCode: 0, output, deployEntries };\n }\n\n const deployMatch = output.match(/🚀.*Deployed:\\s*(https?:\\S+)/);\n if (deployMatch) {\n return { success: true, url: deployMatch[1], exitCode: 0, output };\n }\n\n if (env.DEPLOY === \"true\") {\n return {\n success: false,\n error: \"No deploy URL found (Zephyr may have failed)\",\n exitCode: 0,\n output,\n };\n }\n return { success: true, exitCode: 0, output };\n}\n\ninterface InternalWorkspaceResult extends WorkspaceDeployResult {\n deployEntries?: DeployResultEntry[];\n}\n\nasync function buildOneWorkspace(\n ws: WorkspaceTarget,\n env: Record<string, string>,\n opts: { deploy: boolean; verbose?: boolean },\n): Promise<InternalWorkspaceResult> {\n const pkgJson = await readJsonFile<{\n scripts?: Record<string, string>;\n }>(`${ws.path}/package.json`);\n const shouldDeployScript = opts.deploy && pkgJson.scripts?.deploy;\n const buildConfig = shouldDeployScript\n ? { cmd: \"bun\", args: [\"run\", \"deploy\"] }\n : (buildCommands[ws.key] ?? { cmd: \"bun\", args: [\"run\", \"build\"] });\n\n const wsEnv = { ...env };\n\n const startTime = Date.now();\n let attempt = await runBuildAttempt(\n buildConfig.cmd,\n buildConfig.args,\n ws.path,\n wsEnv,\n opts.verbose ?? false,\n ws.key,\n );\n\n let retried = false;\n\n if (!attempt.success && attempt.exitCode === 0 && opts.deploy) {\n if (!opts.verbose) {\n console.log(` ${colors.yellow(\"↻\")} ${padRight(ws.key, 28)} retrying...`);\n }\n retried = true;\n attempt = await runBuildAttempt(\n buildConfig.cmd,\n buildConfig.args,\n ws.path,\n wsEnv,\n opts.verbose ?? false,\n ws.key,\n );\n }\n\n const durationMs = Date.now() - startTime;\n const result: InternalWorkspaceResult = {\n key: ws.key,\n kind: ws.kind,\n success: attempt.success,\n url: attempt.url,\n error: attempt.error,\n deployEntries: attempt.deployEntries,\n durationMs,\n retried: retried ? true : undefined,\n };\n\n if (!opts.verbose) {\n const name = padRight(ws.key, 28);\n if (result.success) {\n const duration = formatDuration(durationMs);\n const retryTag = retried ? \" (retried)\" : \"\";\n console.log(` ${colors.green(icons.ok)} ${name} ${colors.dim(duration + retryTag)}`);\n } else {\n const errorLine = (result.error ?? \"Failed\").split(\"\\n\")[0];\n console.log(` ${colors.error(icons.err)} ${name} ${errorLine}`);\n }\n }\n\n return result;\n}\n\nexport async function buildWorkspaceTargets(opts: {\n configDir: string;\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n targets: string[];\n deploy: boolean;\n verbose?: boolean;\n}): Promise<{\n built: string[];\n skipped: string[];\n deployResults?: WorkspaceDeployResult[];\n}> {\n const existing: WorkspaceTarget[] = [];\n const skipped: string[] = [];\n\n for (const target of opts.targets) {\n const resolved = resolveWorkspaceTarget(\n target,\n opts.bosConfig,\n opts.runtimeConfig,\n opts.configDir,\n );\n if (!resolved) {\n skipped.push(target);\n continue;\n }\n\n const exists = await fileExists(`${resolved.path}/package.json`);\n if (exists) existing.push(resolved);\n else skipped.push(target);\n }\n\n if (existing.length === 0) {\n return { built: [], skipped };\n }\n\n const sharedSync = await syncResolvedSharedDeps({\n configDir: opts.configDir,\n hostMode: \"local\",\n bosConfig: opts.bosConfig ?? undefined,\n extendsChain: [],\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: opts.configDir });\n }\n\n const shouldBuildPlugin = existing.some((entry) => entry.key === \"api\");\n\n const forceRebuild = opts.deploy;\n const buildTasks: Promise<void>[] = [buildEverythingDevQuietly(opts.configDir, forceRebuild)];\n if (shouldBuildPlugin) {\n buildTasks.push(buildEveryPluginQuietly(opts.configDir, forceRebuild));\n }\n await Promise.all(buildTasks);\n\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: opts.deploy ? \"production\" : \"development\",\n };\n if (opts.deploy) {\n env.DEPLOY = \"true\";\n } else {\n delete env.DEPLOY;\n }\n\n const bosConfigPath = join(opts.configDir, \"bos.config.json\");\n let configSnapshot: string | undefined;\n if (opts.deploy && existsSync(bosConfigPath)) {\n configSnapshot = readFileSync(bosConfigPath, \"utf-8\");\n }\n\n const orderedExisting = opts.deploy\n ? [\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key !== \"host\"),\n ...existing.filter((entry) => entry.kind === \"plugin\"),\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key === \"host\"),\n ]\n : existing;\n\n const parallelGroup = opts.deploy\n ? orderedExisting.filter((e) => e.key !== \"host\")\n : orderedExisting;\n const sequentialGroup = opts.deploy ? orderedExisting.filter((e) => e.key === \"host\") : [];\n\n const built: string[] = [];\n const deployResults: WorkspaceDeployResult[] = [];\n\n if (opts.deploy && parallelGroup.length > 0) {\n const total = parallelGroup.length + sequentialGroup.length;\n console.log();\n console.log(` Building ${total} workspace${total > 1 ? \"s\" : \"\"}...`);\n console.log();\n\n const results = await Promise.allSettled(\n parallelGroup.map((ws) => buildOneWorkspace(ws, env, opts)),\n );\n\n const allDeployEntries: DeployResultEntry[] = [];\n for (let i = 0; i < parallelGroup.length; i++) {\n const ws = parallelGroup[i];\n const result = results[i];\n if (result.status === \"fulfilled\") {\n if (result.value.success) {\n built.push(ws.key);\n }\n if (result.value.deployEntries) {\n allDeployEntries.push(...result.value.deployEntries);\n }\n const { deployEntries: _deployEntries, ...deployResult } = result.value;\n deployResults.push(deployResult);\n } else {\n deployResults.push({\n key: ws.key,\n kind: ws.kind,\n success: false,\n error: result.reason?.message ?? \"Unknown error\",\n });\n }\n }\n\n if (configSnapshot && allDeployEntries.length > 0) {\n const config = JSON.parse(configSnapshot) as Record<string, unknown>;\n const merged = applyDeployResults(config, allDeployEntries);\n writeFileSync(bosConfigPath, `${JSON.stringify(merged, null, 2)}\\n`);\n }\n\n for (const ws of sequentialGroup) {\n const result = await buildOneWorkspace(ws, env, opts);\n if (result.success) {\n built.push(ws.key);\n }\n if (result.deployEntries) {\n const hostEntries = result.deployEntries.filter((r) => r.urlField.startsWith(\"app.host\"));\n if (hostEntries.length > 0 && existsSync(bosConfigPath)) {\n const currentConfig = JSON.parse(readFileSync(bosConfigPath, \"utf-8\")) as Record<\n string,\n unknown\n >;\n const merged = applyDeployResults(currentConfig, hostEntries);\n writeFileSync(bosConfigPath, `${JSON.stringify(merged, null, 2)}\\n`);\n }\n }\n const { deployEntries: _deployEntries, ...sequentialResult } = result;\n deployResults.push(sequentialResult);\n }\n\n console.log();\n } else {\n for (const resolved of orderedExisting) {\n const buildConfig = buildCommands[resolved.key] ?? {\n cmd: \"bun\",\n args: [\"run\", \"build\"],\n };\n\n await run(buildConfig.cmd, buildConfig.args, {\n cwd: resolved.path,\n env,\n });\n built.push(resolved.key);\n }\n }\n\n return { built, skipped, deployResults: opts.deploy ? deployResults : undefined };\n}\n\nexport async function buildEveryPluginQuietly(cwd: string, force = false) {\n const packageDir = `${cwd}/packages/every-plugin`;\n const packageExists = await fileExists(`${packageDir}/package.json`);\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;\n const distExists = await fileExists(distPath);\n\n if (distExists && !force) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/every-plugin\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`,\n );\n}\n\nexport async function buildEverythingDevQuietly(cwd: string, force = false) {\n const packageDir = `${cwd}/packages/everything-dev`;\n const packageExists = await fileExists(`${packageDir}/package.json`);\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;\n const distExists = await fileExists(distPath);\n\n if (distExists && !force) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/everything-dev\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,gBAAiE;CACrE,MAAM;EAAE,K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FqB,WAAW,GADhB,IAAI,qDACqB,IAE3B,CAAC,MACjB;CAGF,MAAM,SAAU,MAAM,IAAI,OAAO;EAAC;EAAO;EAAS;EAAyB;EAAQ,EAAE;EACnF;EACA,SAAS;EACV,CAAC;AAEF,KAAI,OAAO,aAAa,EACtB;AAGF,KAAI,OAAO,OAAO,MAAM,CACtB,SAAQ,OAAO,MAAM,OAAO,OAAO;AAGrC,KAAI,OAAO,OAAO,MAAM,CACtB,SAAQ,OAAO,MAAM,OAAO,OAAO;AAGrC,OAAM,IAAI,MACR,mEAAmE,OAAO,WAC3E;;AAGH,eAAsB,0BAA0B,KAAa,QAAQ,OAAO;AAG1E,KAAI,CAAC,MADuB,WAAW,GAAG,GADpB,IAAI,0BAC2B,eAAe,CAElE;AAMF,KAAI,MAFqB,WAAW,GADhB,IAAI,yCACqB,IAE3B,CAAC,MACjB;CAGF,MAAM,SAAU,MAAM,IAAI,OAAO;EAAC;EAAO;EAAS;EAA2B;EAAQ,EAAE;EACrF;EACA,SAAS;EACV,CAAC;AAEF,KAAI,OAAO,aAAa,EACtB;AAGF,KAAI,OAAO,OAAO,MAAM,CACtB,SAAQ,OAAO,MAAM,OAAO,OAAO;AAGrC,KAAI,OAAO,OAAO,MAAM,CACtB,SAAQ,OAAO,MAAM,OAAO,OAAO;AAGrC,OAAM,IAAI,MACR,qEAAqE,OAAO,WAC7E"}
1
+ {"version":3,"file":"build.mjs","names":[],"sources":["../src/build.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { access, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport process from \"node:process\";\nimport { formatDuration } from \"./cli/timing\";\nimport { resolveLocalDevelopmentPath } from \"./config\";\nimport type { WorkspaceDeployResult } from \"./contract\";\nimport { applyDeployResults, type DeployResultEntry, parseDeployLines } from \"./integrity\";\nimport { syncResolvedSharedDeps } from \"./shared-deps\";\nimport type { BosConfig, BosPluginRef, RuntimeConfig } from \"./types\";\nimport { run } from \"./utils/run\";\nimport { padRight } from \"./utils/string\";\nimport { colors, icons } from \"./utils/theme\";\n\nconst buildCommands: Record<string, { cmd: string; args: string[] }> = {\n host: { cmd: \"bun\", args: [\"run\", \"build\"] },\n ui: { cmd: \"bun\", args: [\"run\", \"build\"] },\n api: { cmd: \"bun\", args: [\"run\", \"build\"] },\n};\n\ntype WorkspaceTarget = {\n key: string;\n kind: \"app\" | \"plugin\";\n path: string;\n};\n\nexport function getPluginRef(entry: string | BosPluginRef | undefined | null): BosPluginRef | null {\n if (!entry || typeof entry === \"string\") return null;\n return entry;\n}\n\nexport async function fileExists(path: string): Promise<boolean> {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function readJsonFile<T>(path: string): Promise<T> {\n return JSON.parse(await readFile(path, \"utf8\")) as T;\n}\n\nfunction resolveWorkspaceTarget(\n key: string,\n bosConfig: BosConfig | null,\n runtimeConfig: RuntimeConfig | null,\n configDir: string,\n): WorkspaceTarget | null {\n if (bosConfig?.app && key in bosConfig.app) {\n const appEntry = (bosConfig.app as Record<string, { development?: string }>)[key];\n const devPath = resolveLocalDevelopmentPath(appEntry?.development, configDir);\n if (devPath) {\n return {\n key,\n kind: \"app\",\n path: devPath,\n };\n }\n return {\n key,\n kind: \"app\",\n path: `${configDir}/${key}`,\n };\n }\n\n const runtimePlugin = runtimeConfig?.plugins?.[key];\n const pluginPath =\n runtimePlugin?.localPath ??\n resolveLocalDevelopmentPath(getPluginRef(bosConfig?.plugins?.[key])?.development, configDir);\n if (pluginPath) {\n return {\n key,\n kind: \"plugin\",\n path: pluginPath,\n };\n }\n\n return null;\n}\n\nexport function selectWorkspaceTargets(packages: string, bosConfig: BosConfig | null): string[] {\n const allPackages = [\n ...Object.keys(bosConfig?.app ?? {}),\n ...Object.keys(bosConfig?.plugins ?? {}),\n ];\n if (packages === \"all\") {\n return allPackages;\n }\n\n return packages\n .split(\",\")\n .map((pkg) => pkg.trim())\n .filter((pkg) => allPackages.includes(pkg));\n}\n\ninterface BuildAttemptResult {\n success: boolean;\n url?: string;\n error?: string;\n exitCode: number;\n output: string;\n deployEntries?: DeployResultEntry[];\n}\n\nasync function runBuildAttempt(\n cmd: string,\n args: string[],\n cwd: string,\n env: Record<string, string>,\n verbose: boolean,\n wsKey: string,\n): Promise<BuildAttemptResult> {\n let zephyrAuthShown = false;\n const result = await run(cmd, args, {\n cwd,\n env,\n capture: true,\n onChunk: (stream, chunk) => {\n if (verbose) {\n if (stream === \"stdout\") process.stdout.write(chunk);\n else process.stderr.write(chunk);\n }\n if (zephyrAuthShown) return;\n const text = chunk.toString(\"utf-8\");\n if (\n /Authentication required.*log in to Zephyr/i.test(text) ||\n /auth\\.zephyr-cloud\\.io\\/authorize/.test(text)\n ) {\n zephyrAuthShown = true;\n const urlMatch = text.match(/https:\\/\\/auth\\.zephyr-cloud\\.io\\/authorize\\S+/);\n console.log();\n console.log(colors.yellow(` ⚠ Zephyr authentication required for ${wsKey}`));\n if (urlMatch) {\n console.log(` ${colors.cyan(urlMatch[0])}`);\n }\n console.log(colors.dim(\" Waiting for authentication...\"));\n console.log();\n }\n },\n });\n const stdout = result?.stdout ?? \"\";\n const stderr = result?.stderr ?? \"\";\n const exitCode = result?.exitCode ?? 0;\n const output = `${stdout}\\n${stderr}`;\n\n const deployEntries = parseDeployLines(output);\n\n if (deployEntries.length > 0) {\n if (exitCode !== 0) {\n const errorLines = output\n .split(\"\\n\")\n .filter((line) => /\\bERROR\\b/.test(line) || line.startsWith(\"Rspack compiled with\"))\n .slice(0, 5);\n if (errorLines.length > 0 && !verbose) {\n console.log(\n ` ${colors.yellow(\"⚠\")} Build completed with errors (exit code ${exitCode}) — Zephyr deployed successfully`,\n );\n for (const line of errorLines) {\n console.log(` ${colors.dim(line.trim())}`);\n }\n }\n }\n return { success: true, url: deployEntries[0]?.url, exitCode: 0, output, deployEntries };\n }\n\n if (exitCode !== 0) {\n const lastLines = output.trim().split(\"\\n\").slice(-5).join(\"\\n\");\n return {\n success: false,\n error: `Build failed (exit code ${exitCode})\\n${lastLines}`,\n exitCode,\n output,\n };\n }\n\n const zeMatch = output.match(/ZE\\d+/);\n if (zeMatch) {\n return {\n success: false,\n error: `Zephyr upload failed (${zeMatch[0]})`,\n exitCode: 0,\n output,\n };\n }\n\n const deployMatch = output.match(/🚀.*Deployed:\\s*(https?:\\S+)/);\n if (deployMatch) {\n return { success: true, url: deployMatch[1], exitCode: 0, output };\n }\n\n if (env.DEPLOY === \"true\") {\n return {\n success: false,\n error: \"No deploy URL found (Zephyr may have failed)\",\n exitCode: 0,\n output,\n };\n }\n return { success: true, exitCode: 0, output };\n}\n\ninterface InternalWorkspaceResult extends WorkspaceDeployResult {\n deployEntries?: DeployResultEntry[];\n}\n\nasync function buildOneWorkspace(\n ws: WorkspaceTarget,\n env: Record<string, string>,\n opts: { deploy: boolean; verbose?: boolean },\n): Promise<InternalWorkspaceResult> {\n const pkgJson = await readJsonFile<{\n scripts?: Record<string, string>;\n }>(`${ws.path}/package.json`);\n const shouldDeployScript = opts.deploy && pkgJson.scripts?.deploy;\n const buildConfig = shouldDeployScript\n ? { cmd: \"bun\", args: [\"run\", \"deploy\"] }\n : (buildCommands[ws.key] ?? { cmd: \"bun\", args: [\"run\", \"build\"] });\n\n const wsEnv = { ...env };\n\n const startTime = Date.now();\n let attempt = await runBuildAttempt(\n buildConfig.cmd,\n buildConfig.args,\n ws.path,\n wsEnv,\n opts.verbose ?? false,\n ws.key,\n );\n\n let retried = false;\n\n if (!attempt.success && attempt.exitCode === 0 && opts.deploy) {\n if (!opts.verbose) {\n console.log(` ${colors.yellow(\"↻\")} ${padRight(ws.key, 28)} retrying...`);\n }\n retried = true;\n attempt = await runBuildAttempt(\n buildConfig.cmd,\n buildConfig.args,\n ws.path,\n wsEnv,\n opts.verbose ?? false,\n ws.key,\n );\n }\n\n const durationMs = Date.now() - startTime;\n const result: InternalWorkspaceResult = {\n key: ws.key,\n kind: ws.kind,\n success: attempt.success,\n url: attempt.url,\n error: attempt.error,\n deployEntries: attempt.deployEntries,\n durationMs,\n retried: retried ? true : undefined,\n };\n\n if (!opts.verbose) {\n const name = padRight(ws.key, 28);\n if (result.success) {\n const duration = formatDuration(durationMs);\n const retryTag = retried ? \" (retried)\" : \"\";\n console.log(` ${colors.green(icons.ok)} ${name} ${colors.dim(duration + retryTag)}`);\n } else {\n const errorLine = (result.error ?? \"Failed\").split(\"\\n\")[0];\n console.log(` ${colors.error(icons.err)} ${name} ${errorLine}`);\n }\n }\n\n return result;\n}\n\nexport async function buildWorkspaceTargets(opts: {\n configDir: string;\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n targets: string[];\n deploy: boolean;\n verbose?: boolean;\n}): Promise<{\n built: string[];\n skipped: string[];\n deployResults?: WorkspaceDeployResult[];\n}> {\n const existing: WorkspaceTarget[] = [];\n const skipped: string[] = [];\n\n for (const target of opts.targets) {\n const resolved = resolveWorkspaceTarget(\n target,\n opts.bosConfig,\n opts.runtimeConfig,\n opts.configDir,\n );\n if (!resolved) {\n skipped.push(target);\n continue;\n }\n\n const exists = await fileExists(`${resolved.path}/package.json`);\n if (exists) existing.push(resolved);\n else skipped.push(target);\n }\n\n if (existing.length === 0) {\n return { built: [], skipped };\n }\n\n const sharedSync = await syncResolvedSharedDeps({\n configDir: opts.configDir,\n hostMode: \"local\",\n bosConfig: opts.bosConfig ?? undefined,\n extendsChain: [],\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: opts.configDir });\n }\n\n const shouldBuildPlugin = existing.some((entry) => entry.key === \"api\");\n\n const forceRebuild = opts.deploy;\n const buildTasks: Promise<void>[] = [buildEverythingDevQuietly(opts.configDir, forceRebuild)];\n if (shouldBuildPlugin) {\n buildTasks.push(buildEveryPluginQuietly(opts.configDir, forceRebuild));\n }\n await Promise.all(buildTasks);\n\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: opts.deploy ? \"production\" : \"development\",\n };\n if (opts.deploy) {\n env.DEPLOY = \"true\";\n } else {\n delete env.DEPLOY;\n }\n\n const bosConfigPath = join(opts.configDir, \"bos.config.json\");\n let configSnapshot: string | undefined;\n if (opts.deploy && existsSync(bosConfigPath)) {\n configSnapshot = readFileSync(bosConfigPath, \"utf-8\");\n }\n\n const orderedExisting = opts.deploy\n ? [\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key !== \"host\"),\n ...existing.filter((entry) => entry.kind === \"plugin\"),\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key === \"host\"),\n ]\n : existing;\n\n const parallelGroup = opts.deploy\n ? orderedExisting.filter((e) => e.key !== \"host\")\n : orderedExisting;\n const sequentialGroup = opts.deploy ? orderedExisting.filter((e) => e.key === \"host\") : [];\n\n const built: string[] = [];\n const deployResults: WorkspaceDeployResult[] = [];\n\n if (opts.deploy && parallelGroup.length > 0) {\n const total = parallelGroup.length + sequentialGroup.length;\n console.log();\n console.log(` Building ${total} workspace${total > 1 ? \"s\" : \"\"}...`);\n console.log();\n\n const results = await Promise.allSettled(\n parallelGroup.map((ws) => buildOneWorkspace(ws, env, opts)),\n );\n\n const allDeployEntries: DeployResultEntry[] = [];\n for (let i = 0; i < parallelGroup.length; i++) {\n const ws = parallelGroup[i];\n const result = results[i];\n if (result.status === \"fulfilled\") {\n if (result.value.success) {\n built.push(ws.key);\n }\n if (result.value.deployEntries) {\n allDeployEntries.push(...result.value.deployEntries);\n }\n const { deployEntries: _deployEntries, ...deployResult } = result.value;\n deployResults.push(deployResult);\n } else {\n deployResults.push({\n key: ws.key,\n kind: ws.kind,\n success: false,\n error: result.reason?.message ?? \"Unknown error\",\n });\n }\n }\n\n if (configSnapshot && allDeployEntries.length > 0) {\n const config = JSON.parse(configSnapshot) as Record<string, unknown>;\n const merged = applyDeployResults(config, allDeployEntries);\n writeFileSync(bosConfigPath, `${JSON.stringify(merged, null, 2)}\\n`);\n }\n\n for (const ws of sequentialGroup) {\n const result = await buildOneWorkspace(ws, env, opts);\n if (result.success) {\n built.push(ws.key);\n }\n if (result.deployEntries) {\n const hostEntries = result.deployEntries.filter((r) => r.urlField.startsWith(\"app.host\"));\n if (hostEntries.length > 0 && existsSync(bosConfigPath)) {\n const currentConfig = JSON.parse(readFileSync(bosConfigPath, \"utf-8\")) as Record<\n string,\n unknown\n >;\n const merged = applyDeployResults(currentConfig, hostEntries);\n writeFileSync(bosConfigPath, `${JSON.stringify(merged, null, 2)}\\n`);\n }\n }\n const { deployEntries: _deployEntries, ...sequentialResult } = result;\n deployResults.push(sequentialResult);\n }\n\n console.log();\n } else {\n for (const resolved of orderedExisting) {\n const buildConfig = buildCommands[resolved.key] ?? {\n cmd: \"bun\",\n args: [\"run\", \"build\"],\n };\n\n await run(buildConfig.cmd, buildConfig.args, {\n cwd: resolved.path,\n env,\n });\n built.push(resolved.key);\n }\n }\n\n return { built, skipped, deployResults: opts.deploy ? deployResults : undefined };\n}\n\nexport async function buildEveryPluginQuietly(cwd: string, force = false) {\n const packageDir = `${cwd}/packages/every-plugin`;\n const packageExists = await fileExists(`${packageDir}/package.json`);\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;\n const distExists = await fileExists(distPath);\n\n if (distExists && !force) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/every-plugin\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`,\n );\n}\n\nexport async function buildEverythingDevQuietly(cwd: string, force = false) {\n const packageDir = `${cwd}/packages/everything-dev`;\n const packageExists = await fileExists(`${packageDir}/package.json`);\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;\n const distExists = await fileExists(distPath);\n\n if (distExists && !force) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/everything-dev\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,gBAAiE;CACrE,MAAM;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C,IAAI;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC1C,KAAK;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C;AAQD,SAAgB,aAAa,OAAsE;AACjG,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAO;;AAGT,eAAsB,WAAW,MAAgC;AAC/D,KAAI;AACF,QAAM,OAAO,KAAK;AAClB,SAAO;SACD;AACN,SAAO;;;AAIX,eAAsB,aAAgB,MAA0B;AAC9D,QAAO,KAAK,MAAM,MAAM,SAAS,MAAM,OAAO,CAAC;;AAGjD,SAAS,uBACP,KACA,WACA,eACA,WACwB;AACxB,KAAI,WAAW,OAAO,OAAO,UAAU,KAAK;EAC1C,MAAM,WAAY,UAAU,IAAiD;EAC7E,MAAM,UAAU,4BAA4B,UAAU,aAAa,UAAU;AAC7E,MAAI,QACF,QAAO;GACL;GACA,MAAM;GACN,MAAM;GACP;AAEH,SAAO;GACL;GACA,MAAM;GACN,MAAM,GAAG,UAAU,GAAG;GACvB;;CAIH,MAAM,cADgB,eAAe,UAAU,OAE9B,aACf,4BAA4B,aAAa,WAAW,UAAU,KAAK,EAAE,aAAa,UAAU;AAC9F,KAAI,WACF,QAAO;EACL;EACA,MAAM;EACN,MAA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AAI,yCACqB,IAE3B,CAAC,MACjB;CAGF,MAAM,SAAU,MAAM,IAAI,OAAO;EAAC;EAAO;EAAS;EAA2B;EAAQ,EAAE;EACrF;EACA,SAAS;EACV,CAAC;AAEF,KAAI,OAAO,aAAa,EACtB;AAGF,KAAI,OAAO,OAAO,MAAM,CACtB,SAAQ,OAAO,MAAM,OAAO,OAAO;AAGrC,KAAI,OAAO,OAAO,MAAM,CACtB,SAAQ,OAAO,MAAM,OAAO,OAAO;AAGrC,OAAM,IAAI,MACR,qEAAqE,OAAO,WAC7E"}
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.cjs","names":["colors","frames","icons","gradients","formatDuration","sumPhaseDurations","findConfigPath","findCommandDescriptor","bosPlugin","parseCommandInput","p","consumeDevSession","promptInitBasic","fetchParentConfig","promptInitOverrides","runDockerComposeUp"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { dirname } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { findCommandDescriptor } from \"./cli/catalog\";\nimport { printHelp } from \"./cli/help\";\nimport { loadProjectEnv } from \"./cli/infra\";\nimport { fetchParentConfig, runDockerComposeUp } from \"./cli/init\";\nimport { parseCommandInput } from \"./cli/parse\";\nimport { promptInitBasic, promptInitOverrides } from \"./cli/prompts\";\nimport { formatDuration, sumPhaseDurations } from \"./cli/timing\";\nimport { findConfigPath } from \"./config\";\nimport type {\n DevOptions,\n DevResult,\n InitOptions,\n InitResult,\n OverrideSection,\n StartOptions,\n StartResult,\n} from \"./contract\";\nimport type { ProgressEvent, StartSummary } from \"./plugin\";\nimport bosPlugin, { consumeDevSession, pluginEvents } from \"./plugin\";\nimport { createPluginRuntime } from \"./sdk\";\nimport { printBanner } from \"./utils/banner\";\nimport { colors, frames, gradients, icons } from \"./utils/theme\";\n\nfunction printConfigView(result: {\n account: string;\n domain?: string;\n staging?: { domain: string };\n app?: {\n host: { name?: string; development: string; production?: string };\n ui: { name?: string; development?: string; production?: string; ssr?: string };\n api: { name?: string; development?: string; production?: string; proxy?: string };\n };\n}) {\n console.log();\n console.log(colors.cyan(frames.top(52)));\n console.log(` ${icons.app} ${gradients.cyber(\"CONFIG\")}`);\n console.log(colors.cyan(frames.bottom(52)));\n console.log();\n\n console.log(` ${colors.dim(\"Account\")} ${colors.cyan(result.account)}`);\n console.log(` ${colors.dim(\"Domain\")} ${colors.white(result.domain ?? \"not configured\")}`);\n if (result.staging) {\n console.log(` ${colors.dim(\"Staging\")} ${colors.magenta(result.staging.domain)}`);\n }\n console.log();\n}\n\nfunction formatTimeAgo(isoTimestamp: string): string {\n const now = Date.now();\n const then = new Date(isoTimestamp).getTime();\n const diffMs = now - then;\n const diffMins = Math.floor(diffMs / 60_000);\n if (diffMins < 1) return \"just now\";\n if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? \"s\" : \"\"} ago`;\n const diffHours = Math.floor(diffMins / 60);\n if (diffHours < 24) return `${diffHours} hour${diffHours > 1 ? \"s\" : \"\"} ago`;\n const diffDays = Math.floor(diffHours / 24);\n if (diffDays < 30) return `${diffDays} day${diffDays > 1 ? \"s\" : \"\"} ago`;\n return isoTimestamp.split(\"T\")[0] ?? isoTimestamp;\n}\n\nfunction normalizeVersion(v: string): string {\n return v.replace(/^[\\^~>=v]+/, \"\").trim();\n}\n\nfunction printTimingSummary(timings: Array<{ name: string; durationMs: number }> | undefined) {\n if (!timings || timings.length === 0) return;\n\n console.log(` ${colors.dim(\"Timings:\")}`);\n for (const timing of timings) {\n console.log(` ${colors.dim(timing.name.padEnd(22))} ${formatDuration(timing.durationMs)}`);\n }\n console.log(\n ` ${colors.dim(\"total\".padEnd(22))} ${formatDuration(sumPhaseDurations(timings))}`,\n );\n}\n\nfunction printStartSummary(summary: StartSummary) {\n console.log();\n console.log(` ${colors.dim(\"Config Source:\")} ${summary.configSource}`);\n if (summary.configSourceHttp) {\n console.log(` ${colors.dim(summary.configSourceHttp)}`);\n }\n console.log(` ${colors.dim(\"Account:\")} ${summary.account}`);\n console.log(` ${colors.dim(\"Domain:\")} ${summary.domain ?? \"not configured\"}`);\n console.log();\n console.log(` ${colors.dim(\"Modules:\")}`);\n console.log(` ${colors.dim(\"HOST\")} → ${summary.modules.host ?? \"local\"}`);\n console.log(` ${colors.dim(\"UI\")} → ${summary.modules.ui ?? \"local\"}`);\n console.log(` ${colors.dim(\"API\")} → ${summary.modules.api ?? \"local\"}`);\n if (summary.modules.auth) {\n console.log(` ${colors.dim(\"AUTH\")} → ${summary.modules.auth}`);\n }\n if (summary.warnings.length > 0) {\n console.log();\n for (const w of summary.warnings) {\n console.log(` ${colors.yellow(w)}`);\n }\n }\n console.log();\n}\n\nfunction clearSpinnerStopLine() {\n if (!process.stdout.isTTY) return;\n process.stdout.write(\"\\u001B[1A\\u001B[2K\\u001B[1G\");\n}\n\nasync function warnIfOutdated(client: any, command: string): Promise<void> {\n if (![\"dev\", \"build\", \"start\"].includes(command)) return;\n\n try {\n const status = await client.status();\n if (status.status === \"error\" || !status.packages) return;\n\n const frameworkPackages = [\"everything-dev\", \"every-plugin\"];\n\n const outdated = status.packages.filter(\n (p: { name: string; installed?: string; latest?: string }) =>\n p.installed &&\n p.latest &&\n normalizeVersion(p.installed) !== normalizeVersion(p.latest) &&\n frameworkPackages.includes(p.name),\n );\n\n if (outdated.length === 0) return;\n\n console.log();\n console.log(colors.yellow(` ! Outdated packages detected:`));\n for (const pkg of outdated) {\n console.log(colors.dim(` ${pkg.name} ${pkg.installed} → ${pkg.latest}`));\n }\n console.log(\n colors.dim(\n ` Run ${colors.cyan(\"bos upgrade\")} to update packages and sync template files.`,\n ),\n );\n console.log();\n } catch {\n // silently ignore if status check fails\n }\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n\n if (args.includes(\"--help\") || args.includes(\"-h\")) {\n printHelp();\n return;\n }\n\n const invocationArgs = args.length > 0 ? args : [\"dev\"];\n const command = invocationArgs[0] ?? \"dev\";\n const configPath = findConfigPath();\n\n const commandMatch = findCommandDescriptor(invocationArgs);\n if (!commandMatch) {\n console.error(`Unknown command: ${command}`);\n process.exit(1);\n }\n\n const { descriptor, consumed } = commandMatch;\n const commandArgs = invocationArgs.slice(consumed);\n\n printBanner();\n\n const runtime = createPluginRuntime({\n registry: {\n bos: { module: bosPlugin },\n },\n secrets: {},\n });\n\n const pluginRuntime: any = runtime;\n const loadPlugin = pluginRuntime.usePlugin.bind(pluginRuntime);\n const plugin = await loadPlugin(\"bos\", {\n variables: {\n configPath: configPath ?? undefined,\n },\n secrets: {},\n });\n\n const client = plugin.createClient();\n\n const outdatedWarning = warnIfOutdated(client, command);\n\n try {\n const input = parseCommandInput(descriptor, commandArgs);\n\n if (descriptor.key === \"dev\") {\n const devSpinner = p.spinner();\n devSpinner.start(\"Starting dev environment\");\n\n const devPhaseLabels: Record<string, string> = {\n \"shared deps\": \"Preparing config...\",\n install: \"Installing dependencies...\",\n build: \"Building...\",\n \"resolve config\": \"Resolving config...\",\n ports: \"Finding available ports...\",\n \"generate artifacts\": \"Generating code artifacts...\",\n };\n\n const onDevProgress = (event: ProgressEvent) => {\n const label = devPhaseLabels[event.phase] ?? event.phase;\n if (event.status === \"running\") {\n devSpinner.message(label);\n }\n };\n pluginEvents.on(\"progress\", onDevProgress);\n\n let result: DevResult;\n try {\n result = await client.dev(input as DevOptions);\n } finally {\n pluginEvents.off(\"progress\", onDevProgress);\n }\n\n if (result.status === \"error\") {\n devSpinner.stop(\"Failed\");\n console.error(`[CLI] ${result.description}`);\n process.exit(1);\n }\n\n devSpinner.stop();\n clearSpinnerStopLine();\n\n const session = consumeDevSession();\n await outdatedWarning;\n if (session) {\n const { devApp } = await import(\"./dev-session\");\n devApp(session.orchestrator, session.services, session.runtimeConfig);\n }\n return;\n }\n\n if (descriptor.key === \"start\") {\n const startSpinner = p.spinner();\n startSpinner.start(\"Starting production environment\");\n\n const startPhaseLabels: Record<string, string> = {\n config: \"Preparing config...\",\n \"generate artifacts\": \"Generating code artifacts...\",\n };\n\n const onStartProgress = (event: ProgressEvent) => {\n const label = startPhaseLabels[event.phase] ?? event.phase;\n if (event.status === \"running\") {\n startSpinner.message(label);\n }\n };\n pluginEvents.on(\"progress\", onStartProgress);\n\n let result: StartResult;\n try {\n result = await client.start(input as StartOptions);\n } finally {\n pluginEvents.off(\"progress\", onStartProgress);\n }\n\n if (result.status === \"error\") {\n startSpinner.stop(\"Failed\");\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n\n startSpinner.stop(\"Ready\");\n\n const session = consumeDevSession();\n await outdatedWarning;\n if (session) {\n const summary = session.summary;\n if (summary) {\n printStartSummary(summary);\n }\n const { startApp } = await import(\"./dev-session\");\n startApp(session.orchestrator, session.services, session.runtimeConfig);\n }\n return;\n }\n\n if (descriptor.key === \"init\") {\n let initInput: InitOptions = { ...(input as InitOptions) };\n\n if (!initInput.noInteractive) {\n const basic = await promptInitBasic({\n extends: initInput.extends,\n account: initInput.account,\n domain: initInput.domain,\n });\n\n let parentPluginKeys: string[] = [];\n let parentConfig: {\n title?: string;\n description?: string;\n plugins?: Record<string, unknown>;\n } | null = null;\n\n const fetchSpinner = p.spinner();\n fetchSpinner.start(\"Fetching parent config\");\n try {\n parentConfig = await fetchParentConfig(basic.extendsAccount, basic.extendsGateway);\n if (parentConfig?.plugins && typeof parentConfig.plugins === \"object\") {\n parentPluginKeys = Object.keys(parentConfig.plugins);\n }\n } catch {\n fetchSpinner.stop(\"Config not found\");\n console.error(\n `[CLI] No config found at bos://${basic.extendsAccount}/${basic.extendsGateway}`,\n );\n process.exit(1);\n }\n fetchSpinner.stop(\"Config fetched\");\n\n if (\n typeof parentConfig?.title === \"string\" &&\n parentConfig.title.trim() &&\n typeof parentConfig?.description === \"string\" &&\n parentConfig.description.trim()\n ) {\n const shouldContinue = await p.confirm({\n message: `You will be extending ${parentConfig.title} - ${parentConfig.description}. Continue?`,\n initialValue: true,\n });\n\n if (p.isCancel(shouldContinue) || !shouldContinue) {\n process.exit(0);\n }\n }\n\n const overrides = await promptInitOverrides({\n parentPluginKeys,\n plugins: initInput.plugins,\n overrides: initInput.overrides as OverrideSection[] | undefined,\n });\n\n const directory = initInput.directory || basic.domain || basic.extendsGateway;\n\n initInput = {\n ...initInput,\n extends: `bos://${basic.extendsAccount}/${basic.extendsGateway}`,\n directory,\n account: basic.account,\n domain: basic.domain || undefined,\n plugins: overrides.plugins,\n overrides: overrides.overrides,\n noInteractive: true,\n };\n }\n\n const initSpinner = p.spinner();\n initSpinner.start(\"Initializing project\");\n\n const phaseLabels: Record<string, string> = {\n \"parent config\": \"Fetching parent config...\",\n \"template source\": \"Resolving template source...\",\n \"scaffold project\": \"Creating project scaffold...\",\n \"copy files\": \"Copying template files...\",\n \"personalize config\": \"Personalizing config...\",\n \"write snapshot\": \"Writing snapshot...\",\n \"resolve config\": \"Resolving config...\",\n \"generate env/docker\": \"Generating environment config...\",\n \"create env file\": \"Creating .env file...\",\n \"install dependencies\": \"Installing dependencies...\",\n \"generate types\": \"Generating types...\",\n \"generate migrations\": \"Generating database migrations...\",\n \"generate code artifacts\": \"Generating code artifacts...\",\n };\n\n const onProgress = (event: ProgressEvent) => {\n const label = phaseLabels[event.phase] ?? event.phase;\n if (event.status === \"running\") {\n initSpinner.message(label);\n }\n };\n pluginEvents.on(\"progress\", onProgress);\n\n let result: InitResult;\n try {\n result = await client.init(initInput);\n } finally {\n pluginEvents.off(\"progress\", onProgress);\n }\n\n if (result.status === \"error\") {\n initSpinner.stop(\"Failed\");\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n\n initSpinner.stop(\"Project initialized\");\n\n console.log(` ${colors.dim(\"Extends:\")} ${result.extends}`);\n console.log(` ${colors.dim(\"Directory:\")} ${result.directory}`);\n if (result.account) console.log(` ${colors.dim(\"Account:\")} ${result.account}`);\n if (result.domain) console.log(` ${colors.dim(\"Domain:\")} ${result.domain}`);\n if (result.overrides && result.overrides.length > 0)\n console.log(` ${colors.dim(\"Overrides:\")} ${result.overrides.join(\", \")}`);\n if (result.plugins && result.plugins.length > 0)\n console.log(` ${colors.dim(\"Plugins:\")} ${result.plugins.join(\", \")}`);\n console.log(` ${colors.dim(\"Files copied:\")} ${result.filesCopied}`);\n printTimingSummary(result.timings);\n console.log();\n console.log(colors.dim(\" Next steps:\"));\n console.log(colors.dim(` cd ${result.directory}`));\n if (!initInput.noInstall) {\n console.log(colors.dim(\" docker compose up -d --wait\"));\n console.log(colors.dim(\" bun run dev\"));\n } else {\n console.log(colors.dim(\" bun install\"));\n console.log(colors.dim(\" docker compose up -d --wait\"));\n console.log(colors.dim(\" bun run dev\"));\n }\n console.log();\n\n if (initInput.noInteractive !== true && !initInput.noInstall && result.targetDir) {\n const shouldStartDocker = await p.confirm({\n message: \"Run docker compose up -d --wait?\",\n initialValue: true,\n });\n\n if (shouldStartDocker === true) {\n const dockerSpinner = p.spinner();\n dockerSpinner.start(\"Starting Docker services\");\n try {\n await runDockerComposeUp(result.targetDir);\n dockerSpinner.stop(\"Docker services ready\");\n } catch (error) {\n dockerSpinner.stop(\"Docker services not started\");\n p.log.warn(\n `docker compose up -d --wait failed: ${error instanceof Error ? error.message : error}`,\n );\n }\n }\n }\n\n return;\n }\n\n await outdatedWarning;\n\n const result = await (client as any)[descriptor.key](input);\n\n if (descriptor.key === \"dbStudio\") {\n if (result.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n\n const configPath = findConfigPath();\n if (configPath) loadProjectEnv(dirname(configPath));\n\n const { runStudioLocal, runStudioRemote } = await import(\"./cli/db-studio\");\n const info = {\n key: result.plugin as string,\n source: result.source as \"local\" | \"remote\",\n section: result.section as \"app.api\" | \"app.auth\" | \"plugins\",\n databaseSecret: result.databaseSecret as string,\n databaseUrl: result.databaseUrl as string,\n workspaceDir: result.workspaceDir as string | undefined,\n projectDir: dirname(configPath ?? process.cwd()),\n };\n\n try {\n if (info.source === \"local\" && info.workspaceDir) {\n await runStudioLocal(info);\n } else {\n await runStudioRemote(info);\n }\n } catch (error) {\n console.error(`[CLI] ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n return;\n }\n\n if (descriptor.key === \"config\") {\n if (!result.config) {\n console.error(\"No bos.config.json found\");\n process.exit(1);\n }\n\n printConfigView(result.config);\n process.stdout.write(`${JSON.stringify(result.config, null, 2)}\\n`);\n return;\n }\n\n if (descriptor.key === \"sync\") {\n console.log();\n if (result.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n if (result.status === \"dry-run\") {\n console.log(colors.cyan(`${icons.ok} Dry run — no files written`));\n } else {\n console.log(colors.green(`${icons.ok} Template synced`));\n }\n if (result.updated.length > 0) {\n console.log(` ${colors.dim(\"Updated:\")} ${result.updated.length} file(s)`);\n for (const f of result.updated) console.log(` ${colors.dim(f)}`);\n }\n if (result.added.length > 0) {\n console.log(` ${colors.dim(\"Added:\")} ${result.added.length} file(s)`);\n for (const f of result.added) console.log(` ${colors.dim(f)}`);\n }\n if (result.skipped.length > 0) {\n console.log(\n ` ${colors.yellow(\"Skipped:\")} ${result.skipped.length} file(s) (locally modified, use --force to overwrite)`,\n );\n for (const f of result.skipped) console.log(` ${colors.dim(f)}`);\n }\n if (result.updated.length === 0 && result.added.length === 0 && result.skipped.length === 0) {\n console.log(` ${colors.dim(\"Already up to date\")}`);\n }\n if (result.status !== \"dry-run\" && result.updated.length > 0) {\n console.log();\n console.log(colors.dim(\" Review changes — your customizations take priority:\"));\n console.log(\n colors.dim(\n \" • api/src/contract.ts, api/src/index.ts, api/src/db/schema.ts — never overwritten\",\n ),\n );\n console.log(\n colors.dim(\" • ui/src/components/**, ui/src/styles.css — never overwritten\"),\n );\n console.log(\n colors.dim(\n \" • Other updated files — accept framework improvements, then restore your changes\",\n ),\n );\n console.log(colors.dim(\" • Skipped files — yours already, only update with --force\"));\n }\n console.log();\n return;\n }\n\n if (descriptor.key === \"upgrade\") {\n console.log();\n if (result.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n if (result.status === \"dry-run\") {\n console.log(colors.cyan(`${icons.ok} Dry run — no changes applied`));\n } else {\n console.log(colors.green(`${icons.ok} Upgrade successful`));\n }\n for (const pkg of result.packages) {\n if (pkg.from && pkg.from !== pkg.to) {\n console.log(` ${colors.dim(`${pkg.name}:`)} ${pkg.from} → ${pkg.to}`);\n } else if (!pkg.from) {\n console.log(` ${colors.dim(`${pkg.name}:`)} ${pkg.to} (new)`);\n } else {\n console.log(` ${colors.dim(`${pkg.name}:`)} ${pkg.to} (up to date)`);\n }\n }\n if (result.changelogUrl) {\n console.log(` ${colors.dim(\"Changelog:\")} ${result.changelogUrl}`);\n }\n if (result.availablePlugins && result.availablePlugins.length > 0) {\n console.log(` ${colors.dim(\"New parent plugins:\")} ${result.availablePlugins.join(\", \")}`);\n }\n if (result.selectedPlugins && result.selectedPlugins.length > 0) {\n console.log(` ${colors.dim(\"Added plugins:\")} ${result.selectedPlugins.join(\", \")}`);\n }\n printTimingSummary(result.timings);\n if (result.sync) {\n const sync = result.sync;\n if (sync.updated.length > 0) {\n console.log(` ${colors.dim(\"Updated:\")} ${sync.updated.length} file(s)`);\n for (const f of sync.updated) console.log(` ${colors.dim(f)}`);\n }\n if (sync.added.length > 0) {\n console.log(` ${colors.dim(\"Added:\")} ${sync.added.length} file(s)`);\n for (const f of sync.added) console.log(` ${colors.dim(f)}`);\n }\n if (sync.skipped.length > 0) {\n console.log(\n ` ${colors.yellow(\"Skipped:\")} ${sync.skipped.length} file(s) (locally modified, use --force to overwrite)`,\n );\n for (const f of sync.skipped) console.log(` ${colors.dim(f)}`);\n }\n if (\n result.status !== \"dry-run\" &&\n (sync.updated.length > 0 || sync.added.length > 0 || sync.skipped.length > 0)\n ) {\n console.log();\n console.log(colors.dim(\" Resolve differences — your code takes priority:\"));\n console.log();\n console.log(colors.dim(\" Never overwritten (safe):\"));\n console.log(\n colors.dim(\" • api/src/contract.ts, api/src/index.ts, api/src/db/schema.ts\"),\n );\n console.log(colors.dim(\" • ui/src/components/**, ui/src/styles.css\"));\n console.log();\n console.log(colors.dim(\" Replaced — review and keep your changes:\"));\n console.log(\n colors.dim(\n \" • api/drizzle.config.ts, api/tsconfig.json, api/tsconfig.contract.json\",\n ),\n );\n console.log(colors.dim(\" • api/plugin.dev.ts, api/rspack.config.js\"));\n console.log(colors.dim(\" • ui/src/routes/* (core routes only)\"));\n console.log();\n console.log(colors.dim(\" Merged — your deps preserved:\"));\n console.log(colors.dim(\" • package.json, api/package.json, ui/package.json\"));\n console.log();\n console.log(colors.dim(\" Skipped — already yours:\"));\n console.log(colors.dim(\" • Use --force only if you want framework updates\"));\n }\n }\n if (result.migrated && result.migrated.length > 0) {\n console.log(` ${colors.yellow(\"Removed:\")} ${result.migrated.length} obsolete file(s)`);\n for (const f of result.migrated) console.log(` ${colors.dim(f)}`);\n }\n console.log();\n return;\n }\n\n if (descriptor.key === \"status\") {\n console.log();\n if (result.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n console.log(colors.cyan(frames.top(52)));\n console.log(` ${icons.app} ${gradients.cyber(\"STATUS\")}`);\n console.log(colors.cyan(frames.bottom(52)));\n console.log();\n if (result.extends) console.log(` ${colors.dim(\"Extends:\")} ${result.extends}`);\n if (result.account) console.log(` ${colors.dim(\"Account:\")} ${result.account}`);\n if (result.domain) console.log(` ${colors.dim(\"Domain:\")} ${result.domain}`);\n console.log();\n console.log(` ${colors.dim(\"Packages:\")}`);\n for (const pkg of result.packages) {\n const hasUpdate =\n pkg.installed &&\n pkg.latest &&\n normalizeVersion(pkg.installed) !== normalizeVersion(pkg.latest);\n const versionStr = hasUpdate\n ? `${pkg.installed} → ${pkg.latest}`\n : pkg.installed || \"not installed\";\n const label = hasUpdate ? colors.yellow(versionStr) : colors.dim(versionStr);\n console.log(` ${colors.dim(`${pkg.name}`)} ${label}`);\n }\n console.log();\n if (result.lastSync) {\n const ago = formatTimeAgo(result.lastSync);\n console.log(` ${colors.dim(\"Last sync:\")} ${ago}`);\n } else {\n console.log(` ${colors.dim(\"Last sync:\")} never`);\n }\n const envLabel =\n result.envFile === \"found\"\n ? colors.green(\"found\")\n : result.envFile === \"example-only\"\n ? colors.yellow(\"missing (only .env.example found)\")\n : colors.error(\"missing\");\n console.log(` ${colors.dim(\".env:\")} ${envLabel}`);\n if (result.parentReachable !== undefined) {\n const parentLabel = result.parentReachable\n ? colors.green(\"reachable\")\n : colors.error(\"unreachable\");\n console.log(` ${colors.dim(\"Parent:\")} ${parentLabel}`);\n }\n const hasUpdates = result.packages.some(\n (p: { installed?: string; latest?: string }) =>\n p.installed && p.latest && normalizeVersion(p.installed) !== normalizeVersion(p.latest),\n );\n if (hasUpdates) {\n console.log();\n console.log(\n colors.dim(\n ` Run ${colors.cyan(\"bos upgrade\")} to update packages and sync template files.`,\n ),\n );\n }\n console.log();\n return;\n }\n\n if (descriptor.key === \"typesGen\") {\n console.log();\n if (result.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n console.log(colors.green(`${icons.ok} Types generated`));\n if (result.source) {\n console.log(\n ` ${colors.dim(\"Mode:\")} ${result.source === \"remote\" ? colors.cyan(\"remote\") : colors.dim(\"local\")}`,\n );\n }\n if (result.generated.length > 0) {\n console.log(` ${colors.dim(\"Generated:\")}`);\n for (const f of result.generated) console.log(` ${colors.dim(f)}`);\n }\n if (result.fetched.length > 0) {\n console.log(` ${colors.dim(\"Fetched (remote):\")}`);\n for (const url of result.fetched) console.log(` ${colors.dim(url)}`);\n }\n if (result.skipped.length > 0) {\n console.log(` ${colors.dim(\"Skipped:\")}`);\n for (const s of result.skipped) console.log(` ${colors.dim(s)}`);\n }\n if (result.failed.length > 0) {\n console.log(` ${colors.yellow(\"Failed:\")}`);\n for (const f of result.failed) console.log(` ${colors.error(f)}`);\n }\n console.log();\n return;\n }\n\n if (result?.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n\n if (descriptor.key === \"keyPublish\") {\n process.stdout.write(`Generated publish key for ${result.account}\\n`);\n process.stdout.write(` Network: ${result.network}\\n`);\n process.stdout.write(` Contract: ${result.contract}\\n`);\n process.stdout.write(` Allowance: ${result.allowance}\\n`);\n process.stdout.write(` Functions: ${result.functionNames.join(\", \")}\\n`);\n process.stdout.write(` Public key: ${result.publicKey}\\n`);\n process.stdout.write(` Private key: ${result.privateKey}\\n`);\n process.stdout.write(` Copy: NEAR_PRIVATE_KEY=${result.privateKey}\\n`);\n }\n\n if (descriptor.key === \"pluginAdd\") {\n console.log();\n console.log(colors.green(`${icons.ok} Added plugin ${result.key}`));\n if (result.development) console.log(` ${colors.dim(\"Development:\")} ${result.development}`);\n if (result.production) console.log(` ${colors.dim(\"Production:\")} ${result.production}`);\n console.log();\n return;\n }\n\n if (descriptor.key === \"pluginRemove\") {\n console.log();\n console.log(colors.green(`${icons.ok} Removed plugin ${result.key}`));\n console.log();\n return;\n }\n\n if (descriptor.key === \"pluginList\") {\n console.log();\n console.log(colors.cyan(frames.top(52)));\n console.log(` ${icons.config} ${gradients.cyber(\"PLUGINS\")}`);\n console.log(colors.cyan(frames.bottom(52)));\n console.log();\n if (result.plugins.length === 0) {\n console.log(colors.dim(\" No plugins configured\"));\n } else {\n for (const pluginItem of result.plugins) {\n console.log(` ${colors.cyan(pluginItem.key)}`);\n if (pluginItem.development)\n console.log(` ${colors.dim(\"Development:\")} ${pluginItem.development}`);\n if (pluginItem.production)\n console.log(` ${colors.dim(\"Production:\")} ${pluginItem.production}`);\n }\n }\n console.log();\n return;\n }\n\n if (descriptor.key === \"pluginPublish\") {\n console.log();\n console.log(colors.green(`${icons.ok} Published plugin ${result.key}`));\n if (result.path) console.log(` ${colors.dim(\"Path:\")} ${result.path}`);\n if (result.script) console.log(` ${colors.dim(\"Script:\")} bun run ${result.script}`);\n if (result.production) console.log(` ${colors.dim(\"Production:\")} ${result.production}`);\n console.log();\n return;\n }\n\n if (descriptor.key === \"publish\") {\n if (result.status === \"dry-run\") {\n console.log();\n console.log(colors.cyan(`${icons.ok} Dry run complete`));\n console.log(` ${colors.dim(\"Registry URL:\")} ${result.registryUrl}`);\n console.log();\n return;\n }\n\n if (result.status === \"error\") {\n console.log();\n console.log(colors.error(`${icons.err} Publish failed`));\n if (result.error) {\n console.log(` ${colors.dim(\"Error:\")} ${result.error}`);\n }\n if (result.deployResults && result.deployResults.length > 0) {\n const failures = result.deployResults.filter((r: any) => !r.success);\n if (failures.length > 0) {\n console.log();\n for (const f of failures) {\n const errorLine = (f.error ?? \"Failed\").split(\"\\n\")[0];\n console.log(` ${colors.error(icons.err)} ${f.key}: ${errorLine}`);\n }\n }\n }\n console.log();\n process.exit(1);\n }\n\n if (result.status === \"published\") {\n console.log();\n console.log(colors.green(`${icons.ok} Published successfully`));\n console.log(` ${colors.dim(\"Registry URL:\")} ${result.registryUrl}`);\n if (result.txHash) {\n console.log(` ${colors.dim(\"Transaction:\")} ${result.txHash}`);\n }\n if (result.built && result.built.length > 0) {\n console.log(` ${colors.dim(\"Built:\")} ${result.built.join(\", \")}`);\n }\n if (result.skipped && result.skipped.length > 0) {\n console.log(` ${colors.dim(\"Skipped:\")} ${result.skipped.join(\", \")}`);\n }\n console.log();\n return;\n }\n }\n\n if (descriptor.key === \"deploy\") {\n const deployResult = result as any;\n if (deployResult.status === \"dry-run\") {\n console.log();\n console.log(colors.cyan(`${icons.ok} Dry run complete`));\n console.log(` ${colors.dim(\"Registry URL:\")} ${deployResult.registryUrl}`);\n console.log();\n return;\n }\n\n if (deployResult.status === \"error\") {\n console.log();\n console.log(colors.error(`${icons.err} Deploy failed`));\n if (deployResult.error) {\n console.log(` ${colors.dim(\"Error:\")} ${deployResult.error}`);\n }\n if (deployResult.deployResults && deployResult.deployResults.length > 0) {\n const failures = deployResult.deployResults.filter((r: any) => !r.success);\n if (failures.length > 0) {\n console.log();\n for (const f of failures) {\n const errorLine = (f.error ?? \"Failed\").split(\"\\n\")[0];\n console.log(` ${colors.error(icons.err)} ${f.key}: ${errorLine}`);\n }\n }\n }\n console.log();\n process.exit(1);\n }\n\n if (deployResult.status === \"deployed\") {\n console.log();\n console.log(colors.green(`${icons.ok} Deployed successfully`));\n console.log(` ${colors.dim(\"Registry URL:\")} ${deployResult.registryUrl}`);\n if (deployResult.txHash) {\n console.log(` ${colors.dim(\"Transaction:\")} ${deployResult.txHash}`);\n }\n if (deployResult.built && deployResult.built.length > 0) {\n console.log(` ${colors.dim(\"Built:\")} ${deployResult.built.join(\", \")}`);\n }\n if (deployResult.skipped && deployResult.skipped.length > 0) {\n console.log(` ${colors.dim(\"Skipped:\")} ${deployResult.skipped.join(\", \")}`);\n }\n if (deployResult.redeployed) {\n console.log(\n ` ${colors.dim(\"Railway:\")} redeployed ${deployResult.service ?? \"service\"}`,\n );\n } else if (!process.env.RAILWAY_TOKEN) {\n console.log(` ${colors.yellow(\"Railway:\")} skipped (RAILWAY_TOKEN not set)`);\n }\n console.log();\n return;\n }\n\n if (deployResult.status === \"published\") {\n console.log();\n console.log(colors.yellow(`${icons.err} Config published, but Railway redeploy failed`));\n console.log(` ${colors.dim(\"Registry URL:\")} ${deployResult.registryUrl}`);\n if (deployResult.txHash) {\n console.log(` ${colors.dim(\"Transaction:\")} ${deployResult.txHash}`);\n }\n if (deployResult.error) {\n console.log(` ${colors.dim(\"Railway:\")} ${deployResult.error}`);\n }\n console.log();\n process.exit(1);\n }\n }\n } catch (error) {\n console.error(`[CLI] ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n}\n\nvoid main().catch((error) => {\n console.error(\"[CLI] Fatal error:\", error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,SAAS,gBAAgB,QAStB;AACD,SAAQ,KAAK;AACb,SAAQ,IAAIA,qBAAO,KAAKC,qBAAO,IAAI,GAAG,CAAC,CAAC;AACxC,SAAQ,IAAI,KAAKC,oBAAM,IAAI,GAAGC,wB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GE,oBAAM,IAAI,gDAAgD,CAAC;AACxF,YAAQ,IAAI,KAAKF,qBAAO,IAAI,gBAAgB,CAAC,GAAG,aAAa,cAAc;AAC3E,QAAI,aAAa,OACf,SAAQ,IAAI,KAAKA,qBAAO,IAAI,eAAe,CAAC,GAAG,aAAa,SAAS;AAEvE,QAAI,aAAa,MACf,SAAQ,IAAI,KAAKA,qBAAO,IAAI,WAAW,CAAC,GAAG,aAAa,QAAQ;AAElE,YAAQ,KAAK;AACb,YAAQ,KAAK,EAAE;;;UAGZ,OAAO;AACd,UAAQ,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GAAG;AAChF,UAAQ,KAAK,EAAE;;;AAId,MAAM,CAAC,OAAO,UAAU;AAC3B,SAAQ,MAAM,sBAAsB,MAAM;AAC1C,SAAQ,KAAK,EAAE;EACf"}
1
+ {"version":3,"file":"cli.cjs","names":["colors","frames","icons","gradients","formatDuration","sumPhaseDurations","findConfigPath","findCommandDescriptor","bosPlugin","parseCommandInput","p","consumeDevSession","promptInitBasic","fetchParentConfig","promptInitOverrides","runDockerComposeUp"],"sources":["../src/cli.ts"],"sourcesContent":["import { dirname } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { findCommandDescriptor } from \"./cli/catalog\";\nimport { printHelp } from \"./cli/help\";\nimport { loadProjectEnv } from \"./cli/infra\";\nimport { fetchParentConfig, runDockerComposeUp } from \"./cli/init\";\nimport { parseCommandInput } from \"./cli/parse\";\nimport { promptInitBasic, promptInitOverrides } from \"./cli/prompts\";\nimport { formatDuration, sumPhaseDurations } from \"./cli/timing\";\nimport { findConfigPath } from \"./config\";\nimport type {\n DevOptions,\n DevResult,\n InitOptions,\n InitResult,\n OverrideSection,\n StartOptions,\n StartResult,\n} from \"./contract\";\nimport type { ProgressEvent, StartSummary } from \"./plugin\";\nimport bosPlugin, { consumeDevSession, pluginEvents } from \"./plugin\";\nimport { createPluginRuntime } from \"./sdk\";\nimport { printBanner } from \"./utils/banner\";\nimport { colors, frames, gradients, icons } from \"./utils/theme\";\n\nfunction printConfigView(result: {\n account: string;\n domain?: string;\n staging?: { domain: string };\n app?: {\n host: { name?: string; development: string; production?: string };\n ui: { name?: string; development?: string; production?: string; ssr?: string };\n api: { name?: string; development?: string; production?: string; proxy?: string };\n };\n}) {\n console.log();\n console.log(colors.cyan(frames.top(52)));\n console.log(` ${icons.app} ${gradients.cyber(\"CONFIG\")}`);\n console.log(colors.cyan(frames.bottom(52)));\n console.log();\n\n console.log(` ${colors.dim(\"Account\")} ${colors.cyan(result.account)}`);\n console.log(` ${colors.dim(\"Domain\")} ${colors.white(result.domain ?? \"not configured\")}`);\n if (result.staging) {\n console.log(` ${colors.dim(\"Staging\")} ${colors.magenta(result.staging.domain)}`);\n }\n console.log();\n}\n\nfunction formatTimeAgo(isoTimestamp: string): string {\n const now = Date.now();\n const then = new Date(isoTimestamp).getTime();\n const diffMs = now - then;\n const diffMins = Math.floor(diffMs / 60_000);\n if (diffMins < 1) return \"just now\";\n if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? \"s\" : \"\"} ago`;\n const diffHours = Math.floor(diffMins / 60);\n if (diffHours < 24) return `${diffHours} hour${diffHours > 1 ? \"s\" : \"\"} ago`;\n const diffDays = Math.floor(diffHours / 24);\n if (diffDays < 30) return `${diffDays} day${diffDays > 1 ? \"s\" : \"\"} ago`;\n return isoTimestamp.split(\"T\")[0] ?? isoTimestamp;\n}\n\nfunction normalizeVersion(v: string): string {\n return v.replace(/^[\\^~>=v]+/, \"\").trim();\n}\n\nfunction printTimingSummary(timings: Array<{ name: string; durationMs: number }> | undefined) {\n if (!timings || timings.length === 0) return;\n\n console.log(` ${colors.dim(\"Timings:\")}`);\n for (const timing of timings) {\n console.log(` ${colors.dim(timing.name.padEnd(22))} ${formatDuration(timing.durationMs)}`);\n }\n console.log(\n ` ${colors.dim(\"total\".padEnd(22))} ${formatDuration(sumPhaseDurations(timings))}`,\n );\n}\n\nfunction printStartSummary(summary: StartSummary) {\n console.log();\n console.log(` ${colors.dim(\"Config Source:\")} ${summary.configSource}`);\n if (summary.configSourceHttp) {\n console.log(` ${colors.dim(summary.configSourceHttp)}`);\n }\n console.log(` ${colors.dim(\"Account:\")} ${summary.account}`);\n console.log(` ${colors.dim(\"Domain:\")} ${summary.domain ?? \"not configured\"}`);\n console.log();\n console.log(` ${colors.dim(\"Modules:\")}`);\n console.log(` ${colors.dim(\"HOST\")} → ${summary.modules.host ?? \"local\"}`);\n console.log(` ${colors.dim(\"UI\")} → ${summary.modules.ui ?? \"local\"}`);\n console.log(` ${colors.dim(\"API\")} → ${summary.modules.api ?? \"local\"}`);\n if (summary.modules.auth) {\n console.log(` ${colors.dim(\"AUTH\")} → ${summary.modules.auth}`);\n }\n if (summary.warnings.length > 0) {\n console.log();\n for (const w of summary.warnings) {\n console.log(` ${colors.yellow(w)}`);\n }\n }\n console.log();\n}\n\nfunction clearSpinnerStopLine() {\n if (!process.stdout.isTTY) return;\n process.stdout.write(\"\\u001B[1A\\u001B[2K\\u001B[1G\");\n}\n\nasync function warnIfOutdated(client: any, command: string): Promise<void> {\n if (![\"dev\", \"build\", \"start\"].includes(command)) return;\n\n try {\n const status = await client.status();\n if (status.status === \"error\" || !status.packages) return;\n\n const frameworkPackages = [\"everything-dev\", \"every-plugin\"];\n\n const outdated = status.packages.filter(\n (p: { name: string; installed?: string; latest?: string }) =>\n p.installed &&\n p.latest &&\n normalizeVersion(p.installed) !== normalizeVersion(p.latest) &&\n frameworkPackages.includes(p.name),\n );\n\n if (outdated.length === 0) return;\n\n console.log();\n console.log(colors.yellow(` ! Outdated packages detected:`));\n for (const pkg of outdated) {\n console.log(colors.dim(` ${pkg.name} ${pkg.installed} → ${pkg.latest}`));\n }\n console.log(\n colors.dim(\n ` Run ${colors.cyan(\"bos upgrade\")} to update packages and sync template files.`,\n ),\n );\n console.log();\n } catch {\n // silently ignore if status check fails\n }\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n\n if (args.includes(\"--help\") || args.includes(\"-h\")) {\n printHelp();\n return;\n }\n\n const invocationArgs = args.length > 0 ? args : [\"dev\"];\n const command = invocationArgs[0] ?? \"dev\";\n const configPath = findConfigPath();\n\n const commandMatch = findCommandDescriptor(invocationArgs);\n if (!commandMatch) {\n console.error(`Unknown command: ${command}`);\n process.exit(1);\n }\n\n const { descriptor, consumed } = commandMatch;\n const commandArgs = invocationArgs.slice(consumed);\n\n printBanner();\n\n const runtime = createPluginRuntime({\n registry: {\n bos: { module: bosPlugin },\n },\n secrets: {},\n });\n\n const pluginRuntime: any = runtime;\n const loadPlugin = pluginRuntime.usePlugin.bind(pluginRuntime);\n const plugin = await loadPlugin(\"bos\", {\n variables: {\n configPath: configPath ?? undefined,\n },\n secrets: {},\n });\n\n const client = plugin.createClient();\n\n const outdatedWarning = warnIfOutdated(client, command);\n\n try {\n const input = parseCommandInput(descriptor, commandArgs);\n\n if (descriptor.key === \"dev\") {\n const devSpinner = p.spinner();\n devSpinner.start(\"Starting dev environment\");\n\n const devPhaseLabels: Record<string, string> = {\n \"shared deps\": \"Preparing config...\",\n install: \"Installing dependencies...\",\n build: \"Building...\",\n \"resolve config\": \"Resolving config...\",\n ports: \"Finding available ports...\",\n \"generate artifacts\": \"Generating code artifacts...\",\n };\n\n const onDevProgress = (event: ProgressEvent) => {\n const label = devPhaseLabels[event.phase] ?? event.phase;\n if (event.status === \"running\") {\n devSpinner.message(label);\n }\n };\n pluginEvents.on(\"progress\", onDevProgress);\n\n let result: DevResult;\n try {\n result = await client.dev(input as DevOptions);\n } finally {\n pluginEvents.off(\"progress\", onDevProgress);\n }\n\n if (result.status === \"error\") {\n devSpinner.stop(\"Failed\");\n console.error(`[CLI] ${result.description}`);\n process.exit(1);\n }\n\n devSpinner.stop();\n clearSpinnerStopLine();\n\n const session = consumeDevSession();\n await outdatedWarning;\n if (session) {\n const { devApp } = await import(\"./dev-session\");\n devApp(session.orchestrator, session.services, session.runtimeConfig);\n }\n return;\n }\n\n if (descriptor.key === \"start\") {\n const startSpinner = p.spinner();\n startSpinner.start(\"Starting production environment\");\n\n const startPhaseLabels: Record<string, string> = {\n config: \"Preparing config...\",\n \"generate artifacts\": \"Generating code artifacts...\",\n };\n\n const onStartProgress = (event: ProgressEvent) => {\n const label = startPhaseLabels[event.phase] ?? event.phase;\n if (event.status === \"running\") {\n startSpinner.message(label);\n }\n };\n pluginEvents.on(\"progress\", onStartProgress);\n\n let result: StartResult;\n try {\n result = await client.start(input as StartOptions);\n } finally {\n pluginEvents.off(\"progress\", onStartProgress);\n }\n\n if (result.status === \"error\") {\n startSpinner.stop(\"Failed\");\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n\n startSpinner.stop(\"Ready\");\n\n const session = consumeDevSession();\n await outdatedWarning;\n if (session) {\n const summary = session.summary;\n if (summary) {\n printStartSummary(summary);\n }\n const { startApp } = await import(\"./dev-session\");\n startApp(session.orchestrator, session.services, session.runtimeConfig);\n }\n return;\n }\n\n if (descriptor.key === \"init\") {\n let initInput: InitOptions = { ...(input as InitOptions) };\n\n if (!initInput.noInteractive) {\n const basic = await promptInitBasic({\n extends: initInput.extends,\n account: initInput.account,\n domain: initInput.domain,\n });\n\n let parentPluginKeys: string[] = [];\n let parentConfig: {\n title?: string;\n description?: string;\n plugins?: Record<string, unknown>;\n } | null = null;\n\n const fetchSpinner = p.spinner();\n fetchSpinner.start(\"Fetching parent config\");\n try {\n parentConfig = await fetchParentConfig(basic.extendsAccount, basic.extendsGateway);\n if (parentConfig?.plugins && typeof parentConfig.plugins === \"object\") {\n parentPluginKeys = Object.keys(parentConfig.plugins);\n }\n } catch {\n fetchSpinner.stop(\"Config not found\");\n console.error(\n `[CLI] No config found at bos://${basic.extendsAccount}/${basic.extendsGateway}`,\n );\n process.exit(1);\n }\n fetchSpinner.stop(\"Config fetched\");\n\n if (\n typeof parentConfig?.title === \"string\" &&\n parentConfig.title.trim() &&\n typeof parentConfig?.description === \"string\" &&\n parentConfig.description.trim()\n ) {\n const shouldContinue = await p.confirm({\n message: `You will be extending ${parentConfig.title} - ${parentConfig.description}. Continue?`,\n initialValue: true,\n });\n\n if (p.isCancel(shouldContinue) || !shouldContinue) {\n process.exit(0);\n }\n }\n\n const overrides = await promptInitOverrides({\n parentPluginKeys,\n plugins: initInput.plugins,\n overrides: initInput.overrides as OverrideSection[] | undefined,\n });\n\n const directory = initInput.directory || basic.domain || basic.extendsGateway;\n\n initInput = {\n ...initInput,\n extends: `bos://${basic.extendsAccount}/${basic.extendsGateway}`,\n directory,\n account: basic.account,\n domain: basic.domain || undefined,\n plugins: overrides.plugins,\n overrides: overrides.overrides,\n noInteractive: true,\n };\n }\n\n const initSpinner = p.spinner();\n initSpinner.start(\"Initializing project\");\n\n const phaseLabels: Record<string, string> = {\n \"parent config\": \"Fetching parent config...\",\n \"template source\": \"Resolving template source...\",\n \"scaffold project\": \"Creating project scaffold...\",\n \"copy files\": \"Copying template files...\",\n \"personalize config\": \"Personalizing config...\",\n \"write snapshot\": \"Writing snapshot...\",\n \"resolve config\": \"Resolving config...\",\n \"generate env/docker\": \"Generating environment config...\",\n \"create env file\": \"Creating .env file...\",\n \"install dependencies\": \"Installing dependencies...\",\n \"generate types\": \"Generating types...\",\n \"generate migrations\": \"Generating database migrations...\",\n \"generate code artifacts\": \"Generating code artifacts...\",\n };\n\n const onProgress = (event: ProgressEvent) => {\n const label = phaseLabels[event.phase] ?? event.phase;\n if (event.status === \"running\") {\n initSpinner.message(label);\n }\n };\n pluginEvents.on(\"progress\", onProgress);\n\n let result: InitResult;\n try {\n result = await client.init(initInput);\n } finally {\n pluginEvents.off(\"progress\", onProgress);\n }\n\n if (result.status === \"error\") {\n initSpinner.stop(\"Failed\");\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n\n initSpinner.stop(\"Project initialized\");\n\n console.log(` ${colors.dim(\"Extends:\")} ${result.extends}`);\n console.log(` ${colors.dim(\"Directory:\")} ${result.directory}`);\n if (result.account) console.log(` ${colors.dim(\"Account:\")} ${result.account}`);\n if (result.domain) console.log(` ${colors.dim(\"Domain:\")} ${result.domain}`);\n if (result.overrides && result.overrides.length > 0)\n console.log(` ${colors.dim(\"Overrides:\")} ${result.overrides.join(\", \")}`);\n if (result.plugins && result.plugins.length > 0)\n console.log(` ${colors.dim(\"Plugins:\")} ${result.plugins.join(\", \")}`);\n console.log(` ${colors.dim(\"Files copied:\")} ${result.filesCopied}`);\n printTimingSummary(result.timings);\n console.log();\n console.log(colors.dim(\" Next steps:\"));\n console.log(colors.dim(` cd ${result.directory}`));\n if (!initInput.noInstall) {\n console.log(colors.dim(\" docker compose up -d --wait\"));\n console.log(colors.dim(\" bun run dev\"));\n } else {\n console.log(colors.dim(\" bun install\"));\n console.log(colors.dim(\" docker compose up -d --wait\"));\n console.log(colors.dim(\" bun run dev\"));\n }\n console.log();\n\n if (initInput.noInteractive !== true && !initInput.noInstall && result.targetDir) {\n const shouldStartDocker = await p.confirm({\n message: \"Run docker compose up -d --wait?\",\n initialValue: true,\n });\n\n if (shouldStartDocker === true) {\n const dockerSpinner = p.spinner();\n dockerSpinner.start(\"Starting Docker services\");\n try {\n await runDockerComposeUp(result.targetDir);\n dockerSpinner.stop(\"Docker services ready\");\n } catch (error) {\n dockerSpinner.stop(\"Docker services not started\");\n p.log.warn(\n `docker compose up -d --wait failed: ${error instanceof Error ? error.message : error}`,\n );\n }\n }\n }\n\n return;\n }\n\n await outdatedWarning;\n\n const result = await (client as any)[descriptor.key](input);\n\n if (descriptor.key === \"dbStudio\") {\n if (result.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n\n const configPath = findConfigPath();\n if (configPath) loadProjectEnv(dirname(configPath));\n\n const { runStudioLocal, runStudioRemote } = await import(\"./cli/db-studio\");\n const info = {\n key: result.plugin as string,\n source: result.source as \"local\" | \"remote\",\n section: result.section as \"app.api\" | \"app.auth\" | \"plugins\",\n databaseSecret: result.databaseSecret as string,\n databaseUrl: result.databaseUrl as string,\n workspaceDir: result.workspaceDir as string | undefined,\n projectDir: dirname(configPath ?? process.cwd()),\n };\n\n try {\n if (info.source === \"local\" && info.workspaceDir) {\n await runStudioLocal(info);\n } else {\n await runStudioRemote(info);\n }\n } catch (error) {\n console.error(`[CLI] ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n return;\n }\n\n if (descriptor.key === \"config\") {\n if (!result.config) {\n console.error(\"No bos.config.json found\");\n process.exit(1);\n }\n\n printConfigView(result.config);\n process.stdout.write(`${JSON.stringify(result.config, null, 2)}\\n`);\n return;\n }\n\n if (descriptor.key === \"sync\") {\n console.log();\n if (result.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n if (result.status === \"dry-run\") {\n console.log(colors.cyan(`${icons.ok} Dry run — no files written`));\n } else {\n console.log(colors.green(`${icons.ok} Template synced`));\n }\n if (result.updated.length > 0) {\n console.log(` ${colors.dim(\"Updated:\")} ${result.updated.length} file(s)`);\n for (const f of result.updated) console.log(` ${colors.dim(f)}`);\n }\n if (result.added.length > 0) {\n console.log(` ${colors.dim(\"Added:\")} ${result.added.length} file(s)`);\n for (const f of result.added) console.log(` ${colors.dim(f)}`);\n }\n if (result.skipped.length > 0) {\n console.log(\n ` ${colors.yellow(\"Skipped:\")} ${result.skipped.length} file(s) (locally modified, use --force to overwrite)`,\n );\n for (const f of result.skipped) console.log(` ${colors.dim(f)}`);\n }\n if (result.updated.length === 0 && result.added.length === 0 && result.skipped.length === 0) {\n console.log(` ${colors.dim(\"Already up to date\")}`);\n }\n if (result.status !== \"dry-run\" && result.updated.length > 0) {\n console.log();\n console.log(colors.dim(\" Review changes — your customizations take priority:\"));\n console.log(\n colors.dim(\n \" • api/src/contract.ts, api/src/index.ts, api/src/db/schema.ts — never overwritten\",\n ),\n );\n console.log(\n colors.dim(\" • ui/src/components/**, ui/src/styles.css — never overwritten\"),\n );\n console.log(\n colors.dim(\n \" • Other updated files — accept framework improvements, then restore your changes\",\n ),\n );\n console.log(colors.dim(\" • Skipped files — yours already, only update with --force\"));\n }\n console.log();\n return;\n }\n\n if (descriptor.key === \"upgrade\") {\n console.log();\n if (result.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n if (result.status === \"dry-run\") {\n console.log(colors.cyan(`${icons.ok} Dry run — no changes applied`));\n } else {\n console.log(colors.green(`${icons.ok} Upgrade successful`));\n }\n for (const pkg of result.packages) {\n if (pkg.from && pkg.from !== pkg.to) {\n console.log(` ${colors.dim(`${pkg.name}:`)} ${pkg.from} → ${pkg.to}`);\n } else if (!pkg.from) {\n console.log(` ${colors.dim(`${pkg.name}:`)} ${pkg.to} (new)`);\n } else {\n console.log(` ${colors.dim(`${pkg.name}:`)} ${pkg.to} (up to date)`);\n }\n }\n if (result.changelogUrl) {\n console.log(` ${colors.dim(\"Changelog:\")} ${result.changelogUrl}`);\n }\n if (result.availablePlugins && result.availablePlugins.length > 0) {\n console.log(` ${colors.dim(\"New parent plugins:\")} ${result.availablePlugins.join(\", \")}`);\n }\n if (result.selectedPlugins && result.selectedPlugins.length > 0) {\n console.log(` ${colors.dim(\"Added plugins:\")} ${result.selectedPlugins.join(\", \")}`);\n }\n printTimingSummary(result.timings);\n if (result.sync) {\n const sync = result.sync;\n if (sync.updated.length > 0) {\n console.log(` ${colors.dim(\"Updated:\")} ${sync.updated.length} file(s)`);\n for (const f of sync.updated) console.log(` ${colors.dim(f)}`);\n }\n if (sync.added.length > 0) {\n console.log(` ${colors.dim(\"Added:\")} ${sync.added.length} file(s)`);\n for (const f of sync.added) console.log(` ${colors.dim(f)}`);\n }\n if (sync.skipped.length > 0) {\n console.log(\n ` ${colors.yellow(\"Skipped:\")} ${sync.skipped.length} file(s) (locally modified, use --force to overwrite)`,\n );\n for (const f of sync.skipped) console.log(` ${colors.dim(f)}`);\n }\n if (\n result.status !== \"dry-run\" &&\n (sync.updated.length > 0 || sync.added.length > 0 || sync.skipped.length > 0)\n ) {\n console.log();\n console.log(colors.dim(\" Resolve differences — your code takes priority:\"));\n console.log();\n console.log(colors.dim(\" Never overwritten (safe):\"));\n console.log(\n colors.dim(\" • api/src/contract.ts, api/src/index.ts, api/src/db/schema.ts\"),\n );\n console.log(colors.dim(\" • ui/src/components/**, ui/src/styles.css\"));\n console.log();\n console.log(colors.dim(\" Replaced — review and keep your changes:\"));\n console.log(\n colors.dim(\n \" • api/drizzle.config.ts, api/tsconfig.json, api/tsconfig.contract.json\",\n ),\n );\n console.log(colors.dim(\" • api/plugin.dev.ts, api/rspack.config.js\"));\n console.log(colors.dim(\" • ui/src/routes/* (core routes only)\"));\n console.log();\n console.log(colors.dim(\" Merged — your deps preserved:\"));\n console.log(colors.dim(\" • package.json, api/package.json, ui/package.json\"));\n console.log();\n console.log(colors.dim(\" Skipped — already yours:\"));\n console.log(colors.dim(\" • Use --force only if you want framework updates\"));\n }\n }\n if (result.migrated && result.migrated.length > 0) {\n console.log(` ${colors.yellow(\"Removed:\")} ${result.migrated.length} obsolete file(s)`);\n for (const f of result.migrated) console.log(` ${colors.dim(f)}`);\n }\n console.log();\n return;\n }\n\n if (descriptor.key === \"status\") {\n console.log();\n if (result.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n console.log(colors.cyan(frames.top(52)));\n console.log(` ${icons.app} ${gradients.cyber(\"STATUS\")}`);\n console.log(colors.cyan(frames.bottom(52)));\n console.log();\n if (result.extends) console.log(` ${colors.dim(\"Extends:\")} ${result.extends}`);\n if (result.account) console.log(` ${colors.dim(\"Account:\")} ${result.account}`);\n if (result.domain) console.log(` ${colors.dim(\"Domain:\")} ${result.domain}`);\n console.log();\n console.log(` ${colors.dim(\"Packages:\")}`);\n for (const pkg of result.packages) {\n const hasUpdate =\n pkg.installed &&\n pkg.latest &&\n normalizeVersion(pkg.installed) !== normalizeVersion(pkg.latest);\n const versionStr = hasUpdate\n ? `${pkg.installed} → ${pkg.latest}`\n : pkg.installed || \"not installed\";\n const label = hasUpdate ? colors.yellow(versionStr) : colors.dim(versionStr);\n console.log(` ${colors.dim(`${pkg.name}`)} ${label}`);\n }\n console.log();\n if (result.lastSync) {\n const ago = formatTimeAgo(result.lastSync);\n console.log(` ${colors.dim(\"Last sync:\")} ${ago}`);\n } else {\n console.log(` ${colors.dim(\"Last sync:\")} never`);\n }\n const envLabel =\n result.envFile === \"found\"\n ? colors.green(\"found\")\n : result.envFile === \"example-only\"\n ? colors.yellow(\"missing (only .env.example found)\")\n : colors.error(\"missing\");\n console.log(` ${colors.dim(\".env:\")} ${envLabel}`);\n if (result.parentReachable !== undefined) {\n const parentLabel = result.parentReachable\n ? colors.green(\"reachable\")\n : colors.error(\"unreachable\");\n console.log(` ${colors.dim(\"Parent:\")} ${parentLabel}`);\n }\n const hasUpdates = result.packages.some(\n (p: { installed?: string; latest?: string }) =>\n p.installed && p.latest && normalizeVersion(p.installed) !== normalizeVersion(p.latest),\n );\n if (hasUpdates) {\n console.log();\n console.log(\n colors.dim(\n ` Run ${colors.cyan(\"bos upgrade\")} to update packages and sync template files.`,\n ),\n );\n }\n console.log();\n return;\n }\n\n if (descriptor.key === \"typesGen\") {\n console.log();\n if (result.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n console.log(colors.green(`${icons.ok} Types generated`));\n if (result.source) {\n console.log(\n ` ${colors.dim(\"Mode:\")} ${result.source === \"remote\" ? colors.cyan(\"remote\") : colors.dim(\"local\")}`,\n );\n }\n if (result.generated.length > 0) {\n console.log(` ${colors.dim(\"Generated:\")}`);\n for (const f of result.generated) console.log(` ${colors.dim(f)}`);\n }\n if (result.fetched.length > 0) {\n console.log(` ${colors.dim(\"Fetched (remote):\")}`);\n for (const url of result.fetched) console.log(` ${colors.dim(url)}`);\n }\n if (result.skipped.length > 0) {\n console.log(` ${colors.dim(\"Skipped:\")}`);\n for (const s of result.skipped) console.log(` ${colors.dim(s)}`);\n }\n if (result.failed.length > 0) {\n console.log(` ${colors.yellow(\"Failed:\")}`);\n for (const f of result.failed) console.log(` ${colors.error(f)}`);\n }\n console.log();\n return;\n }\n\n if (result?.status === \"error\") {\n console.error(`[CLI] ${result.error || \"Unknown error\"}`);\n process.exit(1);\n }\n\n if (descriptor.key === \"keyPublish\") {\n process.stdout.write(`Generated publish key for ${result.account}\\n`);\n process.stdout.write(` Network: ${result.network}\\n`);\n process.stdout.write(` Contract: ${result.contract}\\n`);\n process.stdout.write(` Allowance: ${result.allowance}\\n`);\n process.stdout.write(` Functions: ${result.functionNames.join(\", \")}\\n`);\n process.stdout.write(` Public key: ${result.publicKey}\\n`);\n process.stdout.write(` Private key: ${result.privateKey}\\n`);\n process.stdout.write(` Copy: NEAR_PRIVATE_KEY=${result.privateKey}\\n`);\n }\n\n if (descriptor.key === \"pluginAdd\") {\n console.log();\n console.log(colors.green(`${icons.ok} Added plugin ${result.key}`));\n if (result.development) console.log(` ${colors.dim(\"Development:\")} ${result.development}`);\n if (result.production) console.log(` ${colors.dim(\"Production:\")} ${result.production}`);\n console.log();\n return;\n }\n\n if (descriptor.key === \"pluginRemove\") {\n console.log();\n console.log(colors.green(`${icons.ok} Removed plugin ${result.key}`));\n console.log();\n return;\n }\n\n if (descriptor.key === \"pluginList\") {\n console.log();\n console.log(colors.cyan(frames.top(52)));\n console.log(` ${icons.config} ${gradients.cyber(\"PLUGINS\")}`);\n console.log(colors.cyan(frames.bottom(52)));\n console.log();\n if (result.plugins.length === 0) {\n console.log(colors.dim(\" No plugins configured\"));\n } else {\n for (const pluginItem of result.plugins) {\n console.log(` ${colors.cyan(pluginItem.key)}`);\n if (pluginItem.development)\n console.log(` ${colors.dim(\"Development:\")} ${pluginItem.development}`);\n if (pluginItem.production)\n console.log(` ${colors.dim(\"Production:\")} ${pluginItem.production}`);\n }\n }\n console.log();\n return;\n }\n\n if (descriptor.key === \"pluginPublish\") {\n console.log();\n console.log(colors.green(`${icons.ok} Published plugin ${result.key}`));\n if (result.path) console.log(` ${colors.dim(\"Path:\")} ${result.path}`);\n if (result.script) console.log(` ${colors.dim(\"Script:\")} bun run ${result.script}`);\n if (result.production) console.log(` ${colors.dim(\"Production:\")} ${result.production}`);\n console.log();\n return;\n }\n\n if (descriptor.key === \"publish\") {\n if (result.status === \"dry-run\") {\n console.log();\n console.log(colors.cyan(`${icons.ok} Dry run complete`));\n console.log(` ${colors.dim(\"Registry URL:\")} ${result.registryUrl}`);\n console.log();\n return;\n }\n\n if (result.status === \"error\") {\n console.log();\n console.log(colors.error(`${icons.err} Publish failed`));\n if (result.error) {\n console.log(` ${colors.dim(\"Error:\")} ${result.error}`);\n }\n if (result.deployResults && result.deployResults.length > 0) {\n const failures = result.deployResults.filter((r: any) => !r.success);\n if (failures.length > 0) {\n console.log();\n for (const f of failures) {\n const errorLine = (f.error ?? \"Failed\").split(\"\\n\")[0];\n console.log(` ${colors.error(icons.err)} ${f.key}: ${errorLine}`);\n }\n }\n }\n console.log();\n process.exit(1);\n }\n\n if (result.status === \"published\") {\n console.log();\n console.log(colors.green(`${icons.ok} Published successfully`));\n console.log(` ${colors.dim(\"Registry URL:\")} ${result.registryUrl}`);\n if (result.txHash) {\n console.log(` ${colors.dim(\"Transaction:\")} ${result.txHash}`);\n }\n if (result.built && result.built.length > 0) {\n console.log(` ${colors.dim(\"Built:\")} ${result.built.join(\", \")}`);\n }\n if (result.skipped && result.skipped.length > 0) {\n console.log(` ${colors.dim(\"Skipped:\")} ${result.skipped.join(\", \")}`);\n }\n console.log();\n return;\n }\n }\n\n if (descriptor.key === \"deploy\") {\n const deployResult = result as any;\n if (deployResult.status === \"dry-run\") {\n console.log();\n console.log(colors.cyan(`${icons.ok} Dry run complete`));\n console.log(` ${colors.dim(\"Registry URL:\")} ${deployResult.registryUrl}`);\n console.log();\n return;\n }\n\n if (deployResult.status === \"error\") {\n console.log();\n console.log(colors.error(`${icons.err} Deploy failed`));\n if (deployResult.error) {\n console.log(` ${colors.dim(\"Error:\")} ${deployResult.error}`);\n }\n if (deployResult.deployResults && deployResult.deployResults.length > 0) {\n const failures = deployResult.deployResults.filter((r: any) => !r.success);\n if (failures.length > 0) {\n console.log();\n for (const f of failures) {\n const errorLine = (f.error ?? \"Failed\").split(\"\\n\")[0];\n console.log(` ${colors.error(icons.err)} ${f.key}: ${errorLine}`);\n }\n }\n }\n console.log();\n process.exit(1);\n }\n\n if (deployResult.status === \"deployed\") {\n console.log();\n console.log(colors.green(`${icons.ok} Deployed successfully`));\n console.log(` ${colors.dim(\"Registry URL:\")} ${deployResult.registryUrl}`);\n if (deployResult.txHash) {\n console.log(` ${colors.dim(\"Transaction:\")} ${deployResult.txHash}`);\n }\n if (deployResult.built && deployResult.built.length > 0) {\n console.log(` ${colors.dim(\"Built:\")} ${deployResult.built.join(\", \")}`);\n }\n if (deployResult.skipped && deployResult.skipped.length > 0) {\n console.log(` ${colors.dim(\"Skipped:\")} ${deployResult.skipped.join(\", \")}`);\n }\n if (deployResult.redeployed) {\n console.log(\n ` ${colors.dim(\"Railway:\")} redeployed ${deployResult.service ?? \"service\"}`,\n );\n } else if (!process.env.RAILWAY_TOKEN) {\n console.log(` ${colors.yellow(\"Railway:\")} skipped (RAILWAY_TOKEN not set)`);\n }\n console.log();\n return;\n }\n\n if (deployResult.status === \"published\") {\n console.log();\n console.log(colors.yellow(`${icons.err} Config published, but Railway redeploy failed`));\n console.log(` ${colors.dim(\"Registry URL:\")} ${deployResult.registryUrl}`);\n if (deployResult.txHash) {\n console.log(` ${colors.dim(\"Transaction:\")} ${deployResult.txHash}`);\n }\n if (deployResult.error) {\n console.log(` ${colors.dim(\"Railway:\")} ${deployResult.error}`);\n }\n console.log();\n process.exit(1);\n }\n }\n } catch (error) {\n console.error(`[CLI] ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n}\n\nvoid main().catch((error) => {\n console.error(\"[CLI] Fatal error:\", error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,SAAS,gBAAgB,QAStB;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