@rebasepro/cli 0.23.0 → 0.24.1-canary.g56af4a4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +19 -3
  2. package/bin/rebase.js +4 -1
  3. package/dist/agent-setup-B31F00DC.js +324 -0
  4. package/dist/agent-setup-B31F00DC.js.map +1 -0
  5. package/dist/api-keys-BPBi5nOF.js +524 -0
  6. package/dist/api-keys-BPBi5nOF.js.map +1 -0
  7. package/dist/apps-CPXNElX4.js +256 -0
  8. package/dist/apps-CPXNElX4.js.map +1 -0
  9. package/dist/args-BnmsEXvu.js +109 -0
  10. package/dist/args-BnmsEXvu.js.map +1 -0
  11. package/dist/atlas-dev-database-DTMuEScS.js +62 -0
  12. package/dist/atlas-dev-database-DTMuEScS.js.map +1 -0
  13. package/dist/auth-DvY94ZuL.js +395 -0
  14. package/dist/auth-DvY94ZuL.js.map +1 -0
  15. package/dist/branch-pointer-DIhKbQLp.js +2 -0
  16. package/dist/build-CFwUx-Ff.js +336 -0
  17. package/dist/build-CFwUx-Ff.js.map +1 -0
  18. package/dist/bundle-BQhP_xiA.js +1617 -0
  19. package/dist/bundle-BQhP_xiA.js.map +1 -0
  20. package/dist/bundle.d.ts +6 -2
  21. package/dist/cli.d.ts +23 -2
  22. package/dist/cloud-CkTr-yt0.js +9640 -0
  23. package/dist/cloud-CkTr-yt0.js.map +1 -0
  24. package/dist/collection-drift-BKj_BoMq.js +106 -0
  25. package/dist/collection-drift-BKj_BoMq.js.map +1 -0
  26. package/dist/commands/__test_support__/parser-specs.d.ts +13 -0
  27. package/dist/commands/agent-setup.d.ts +116 -0
  28. package/dist/commands/api-keys.d.ts +86 -23
  29. package/dist/commands/apps.d.ts +17 -0
  30. package/dist/commands/auth.d.ts +7 -0
  31. package/dist/commands/build.d.ts +5 -1
  32. package/dist/commands/cloud/auth.d.ts +4 -3
  33. package/dist/commands/cloud/bundle-deploy.d.ts +45 -0
  34. package/dist/commands/cloud/context.d.ts +44 -5
  35. package/dist/commands/cloud/cron.d.ts +53 -0
  36. package/dist/commands/cloud/debug.d.ts +134 -0
  37. package/dist/commands/cloud/index.d.ts +89 -12
  38. package/dist/commands/cloud/token-capabilities.d.ts +76 -0
  39. package/dist/commands/cloud/tokens.d.ts +23 -0
  40. package/dist/commands/db.d.ts +52 -25
  41. package/dist/commands/dev.d.ts +181 -7
  42. package/dist/commands/doctor.d.ts +5 -0
  43. package/dist/commands/generate_sdk.d.ts +29 -2
  44. package/dist/commands/init.d.ts +57 -14
  45. package/dist/commands/schema.d.ts +6 -0
  46. package/dist/commands/skills.d.ts +126 -7
  47. package/dist/commands/start.d.ts +29 -0
  48. package/dist/commands/storage.d.ts +46 -0
  49. package/dist/consent-BWHaYx5p.js +76 -0
  50. package/dist/consent-BWHaYx5p.js.map +1 -0
  51. package/dist/context-BqhRydBg.js +1234 -0
  52. package/dist/context-BqhRydBg.js.map +1 -0
  53. package/dist/daemon-DBn-shxX.js +2 -0
  54. package/dist/{daemon-entry-LTFKtpHy.js → daemon-entry-Da-D3rmH.js} +3 -4
  55. package/dist/daemon-entry-Da-D3rmH.js.map +1 -0
  56. package/dist/db-CMpBK3sv.js +1252 -0
  57. package/dist/db-CMpBK3sv.js.map +1 -0
  58. package/dist/derive-RPIsAVO4.js +474 -0
  59. package/dist/derive-RPIsAVO4.js.map +1 -0
  60. package/dist/dev-C9P5Yp9k.js +1593 -0
  61. package/dist/dev-C9P5Yp9k.js.map +1 -0
  62. package/dist/dev-db/atlas-dev-database.d.ts +32 -0
  63. package/dist/dev-db/daemon-entry.d.ts +13 -0
  64. package/dist/dev-db/daemon.d.ts +10 -0
  65. package/dist/dev-db/prepare.d.ts +10 -0
  66. package/dist/dev-preflight-N1evJL3S.js +2 -0
  67. package/dist/doctor-DYs-NqFI.js +771 -0
  68. package/dist/doctor-DYs-NqFI.js.map +1 -0
  69. package/dist/eject-BT6t37D0.js +335 -0
  70. package/dist/eject-BT6t37D0.js.map +1 -0
  71. package/dist/fold-static-C1EtHlfV.js +201 -0
  72. package/dist/fold-static-C1EtHlfV.js.map +1 -0
  73. package/dist/fold-static.d.ts +26 -3
  74. package/dist/function-portability-BIvlvR9q.js +265 -0
  75. package/dist/function-portability-BIvlvR9q.js.map +1 -0
  76. package/dist/generate_sdk-UV635zSe.js +477 -0
  77. package/dist/generate_sdk-UV635zSe.js.map +1 -0
  78. package/dist/index.es.js +189 -22095
  79. package/dist/index.es.js.map +1 -1
  80. package/dist/init-fXeBcxuN.js +1042 -0
  81. package/dist/init-fXeBcxuN.js.map +1 -0
  82. package/dist/manifest-DzlC60WX.js +871 -0
  83. package/dist/manifest-DzlC60WX.js.map +1 -0
  84. package/dist/manifest.d.ts +41 -1
  85. package/dist/normalize-imports-CmVdE9iZ.js +100 -0
  86. package/dist/normalize-imports-CmVdE9iZ.js.map +1 -0
  87. package/dist/package-manager-DSEOwTqM.js +193 -0
  88. package/dist/package-manager-DSEOwTqM.js.map +1 -0
  89. package/dist/path-flags-DUBuI2i1.js +77 -0
  90. package/dist/path-flags-DUBuI2i1.js.map +1 -0
  91. package/dist/precompress.d.ts +17 -0
  92. package/dist/prepare-Btn9Ewbn.js +1052 -0
  93. package/dist/prepare-Btn9Ewbn.js.map +1 -0
  94. package/dist/{project-3WCbrrfW.js → project-Wp2zoyeN.js} +34 -184
  95. package/dist/project-Wp2zoyeN.js.map +1 -0
  96. package/dist/resolve-CJLkfFV0.js +2 -0
  97. package/dist/resources-DT1COn_6.js +161 -0
  98. package/dist/resources-DT1COn_6.js.map +1 -0
  99. package/dist/schema-BDBWvCHu.js +125 -0
  100. package/dist/schema-BDBWvCHu.js.map +1 -0
  101. package/dist/skills-DTFibT1m.js +642 -0
  102. package/dist/skills-DTFibT1m.js.map +1 -0
  103. package/dist/start-rU2e3Kp5.js +228 -0
  104. package/dist/start-rU2e3Kp5.js.map +1 -0
  105. package/dist/{state-C59Elrnt.js → state-Do7ZJYkF.js} +49 -4
  106. package/dist/state-Do7ZJYkF.js.map +1 -0
  107. package/dist/status-BR9oyi-y.js +351 -0
  108. package/dist/status-BR9oyi-y.js.map +1 -0
  109. package/dist/storage-DyvrSTH3.js +303 -0
  110. package/dist/storage-DyvrSTH3.js.map +1 -0
  111. package/dist/telemetry-CAWNCugs.js +338 -0
  112. package/dist/telemetry-CAWNCugs.js.map +1 -0
  113. package/dist/telemetry-DbLqGIBW.js +129 -0
  114. package/dist/telemetry-DbLqGIBW.js.map +1 -0
  115. package/dist/unknown-command-DNwDcX3w.js +98 -0
  116. package/dist/unknown-command-DNwDcX3w.js.map +1 -0
  117. package/dist/upgrade-D-5-Od96.js +1265 -0
  118. package/dist/upgrade-D-5-Od96.js.map +1 -0
  119. package/dist/upgrade.d.ts +14 -2
  120. package/dist/utils/path-flags.d.ts +18 -0
  121. package/dist/utils/project.d.ts +16 -0
  122. package/dist/version-Buyyo1ut.js +58 -0
  123. package/dist/version-Buyyo1ut.js.map +1 -0
  124. package/package.json +7 -7
  125. package/templates/eject/backend/src/env.ts +1 -1
  126. package/templates/eject/backend/src/index.ts +23 -2
  127. package/templates/overlays/baas/ai-instructions.md +1 -1
  128. package/templates/overlays/baas/config/storage.ts +5 -3
  129. package/templates/template/.cursorrules +1 -1
  130. package/templates/template/.env.example +10 -6
  131. package/templates/template/.github/copilot-instructions.md +1 -1
  132. package/templates/template/.mcp.json +2 -2
  133. package/templates/template/.windsurfrules +1 -1
  134. package/templates/template/AGENTS.md +1 -1
  135. package/templates/template/CLAUDE.md +1 -1
  136. package/templates/template/README.md +11 -12
  137. package/templates/template/ai-instructions.md +5 -4
  138. package/templates/template/backend/functions/hello.ts +8 -0
  139. package/templates/template/backend/package.json +1 -1
  140. package/templates/template/config/storage.ts +5 -3
  141. package/templates/template/docker-compose.yml +6 -6
  142. package/templates/template/frontend/vite.config.ts +11 -3
  143. package/templates/template/gitignore +6 -1
  144. package/templates/template/package.json +4 -3
  145. package/templates/template/scripts/example.ts +6 -4
  146. package/dist/branch-pointer-dBiClJ0p.js +0 -111
  147. package/dist/branch-pointer-dBiClJ0p.js.map +0 -1
  148. package/dist/constraints-DKGbNfUW.js +0 -48
  149. package/dist/constraints-DKGbNfUW.js.map +0 -1
  150. package/dist/daemon-DR9Tk0La.js +0 -355
  151. package/dist/daemon-DR9Tk0La.js.map +0 -1
  152. package/dist/daemon-entry-LTFKtpHy.js.map +0 -1
  153. package/dist/dev-preflight-CNLl4rdo.js +0 -367
  154. package/dist/dev-preflight-CNLl4rdo.js.map +0 -1
  155. package/dist/project-3WCbrrfW.js.map +0 -1
  156. package/dist/resolve-BAeRUBhg.js +0 -74
  157. package/dist/resolve-BAeRUBhg.js.map +0 -1
  158. package/dist/state-C59Elrnt.js.map +0 -1
@@ -0,0 +1,336 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { n as getPMCommands, t as detectPackageManager } from "./package-manager-DSEOwTqM.js";
3
+ import { p as requireProjectRoot } from "./project-Wp2zoyeN.js";
4
+ import { n as parseCommandArgs, r as wantsHelp, t as UsageError } from "./args-BnmsEXvu.js";
5
+ import { n as cliVersion } from "./version-Buyyo1ut.js";
6
+ import { c as buildableApps, d as findBackendApp, f as formatAppAddress, o as ManifestError, p as loadManifest, v as staticAppAddress } from "./manifest-DzlC60WX.js";
7
+ import { b as toolStdio, o as buildBundle, p as detectFrameworkDepDrift, s as buildStaticBundle, t as DEFAULT_BUNDLE_DIR } from "./bundle-BQhP_xiA.js";
8
+ import { i as staticBuildEnv, n as foldFrontendIntoBundle, t as assertBuiltForPath } from "./fold-static-C1EtHlfV.js";
9
+ import { l as writeResourceGraphFile, n as deriveOptionsFor, r as deriveResourceGraph } from "./derive-RPIsAVO4.js";
10
+ import chalk from "chalk";
11
+ import fs from "fs";
12
+ import path from "path";
13
+ import { execa } from "execa";
14
+ //#region src/commands/build.ts
15
+ /**
16
+ * CLI command: rebase build [app...]
17
+ *
18
+ * Builds the apps a repository declares in `rebase.json`.
19
+ *
20
+ * For a `backend` app this produces a **bundle** — compiled collections,
21
+ * functions and schema plus a manifest — which is the artifact the runtime
22
+ * loads. For `static` and bundled `admin` apps it runs the declared build
23
+ * command and reports where the output landed.
24
+ *
25
+ * A project with no manifest, or one whose backend has been ejected to its own
26
+ * entrypoint, falls back to the previous behaviour: run every workspace's own
27
+ * `build` script. Nothing that built before stops building.
28
+ */
29
+ var build_exports = /* @__PURE__ */ __exportAll({
30
+ buildAssetApp: () => buildAssetApp,
31
+ buildCommand: () => buildCommand,
32
+ dockerBuildHint: () => dockerBuildHint
33
+ });
34
+ function printHelp() {
35
+ console.log(`
36
+ ${chalk.bold("rebase build")} — build the apps declared in rebase.json
37
+
38
+ ${chalk.bold("Usage")}
39
+ rebase build [app...] Build the named apps (default: all)
40
+
41
+ ${chalk.bold("Options")}
42
+ --output, --out <dir> Bundle output directory (default: ${DEFAULT_BUNDLE_DIR});
43
+ one app at a time
44
+ --skip-type-check Compile without type checking (faster; use for iteration only)
45
+ --skip-schema Do not regenerate the database schema from collections
46
+ --no-static Do not fold the frontend into the backend bundle (each
47
+ static app still gets its own bundle)
48
+ --skip-static-build Fold the frontend as already built, without running its
49
+ build command — for CI that built it in an earlier step
50
+ --no-vendor Do not install dependencies into the bundle (they
51
+ install on every pod start instead, ~40-60s slower)
52
+ --vendor Install them whatever the tree's size — for a
53
+ deploy that builds from source and never uploads it
54
+ --workspace Run every workspace's own build script instead
55
+ -h, --help Show this help
56
+
57
+ ${chalk.bold("Examples")}
58
+ rebase build Build every app in this repository
59
+ rebase build backend Build only the backend bundle
60
+ rebase build web Build only the "web" static app
61
+ `.trim());
62
+ }
63
+ /**
64
+ * The two commands that turn a custom-runtime app into an image.
65
+ *
66
+ * Exported for the test, because the failure this replaced was in the printed
67
+ * text and nowhere else. It said:
68
+ *
69
+ * docker build -f backend/Dockerfile .
70
+ *
71
+ * for every custom backend, and the `.` was a guess — `context` was validated,
72
+ * stored on the config, and read by nothing. For the reference project that
73
+ * guess is wrong: `app/backend/Dockerfile` opens by copying `pnpm-lock.yaml`
74
+ * and `pnpm-workspace.yaml`, which live at the monorepo root, so the command
75
+ * `rebase build` handed you died on its first instruction. The deploy that
76
+ * actually works, `infra/cloudbuild.yaml`, has always said
77
+ * `-f app/backend/Dockerfile .` from the root.
78
+ *
79
+ * `dockerfile` is relative to `rebase.json`; `context` is too, and may point
80
+ * above it. Docker resolves `-f` against the working directory, not the
81
+ * context, so the path has to be re-expressed against wherever the command
82
+ * runs — which is what the old line never did and is the whole reason it
83
+ * could not be right for both.
84
+ */
85
+ function dockerBuildHint(projectRoot, name, app) {
86
+ const dockerfile = app.dockerfile ?? "Dockerfile";
87
+ const context = app.context ?? ".";
88
+ const contextDir = path.resolve(projectRoot, context);
89
+ const fromContext = path.relative(contextDir, path.resolve(projectRoot, dockerfile));
90
+ const build = `${chalk.cyan(`npm run build --workspace ${name}`)}`;
91
+ if (fromContext.startsWith("..")) return [
92
+ chalk.dim(` ${build}`),
93
+ chalk.yellow(` ⚠ ${dockerfile} is outside the build context (${context}) — nothing it COPYs is reachable.`),
94
+ chalk.dim(` Widen "context" in rebase.json, or move the Dockerfile inside it.`)
95
+ ];
96
+ const docker = chalk.cyan(`docker build -f ${fromContext} .`);
97
+ return context === "." ? [chalk.dim(` ${build} then ${docker}`)] : [chalk.dim(` ${build}`), chalk.dim(` ${chalk.cyan(`cd ${context}`)} && ${docker}`)];
98
+ }
99
+ async function buildCommand(rawArgs = []) {
100
+ if (wantsHelp(rawArgs)) {
101
+ printHelp();
102
+ return;
103
+ }
104
+ const { flags: args, positionals: requested } = parseCommandArgs({
105
+ spec: {
106
+ "--output": String,
107
+ "--out": "--output",
108
+ "--skip-type-check": Boolean,
109
+ "--no-vendor": Boolean,
110
+ "--vendor": Boolean,
111
+ "--skip-schema": Boolean,
112
+ "--no-static": Boolean,
113
+ "--skip-static-build": Boolean,
114
+ "--workspace": Boolean
115
+ },
116
+ rawArgs,
117
+ commandWords: 1,
118
+ command: "build"
119
+ });
120
+ const projectRoot = requireProjectRoot();
121
+ if (args["--workspace"]) {
122
+ await runWorkspaceBuilds(projectRoot);
123
+ return;
124
+ }
125
+ let loaded;
126
+ try {
127
+ loaded = loadManifest(projectRoot);
128
+ } catch (err) {
129
+ if (err instanceof ManifestError) {
130
+ console.error(chalk.red(`✗ ${err.message}`));
131
+ for (const issue of err.issues) console.error(chalk.red(` ${issue.path ? `${issue.path}: ` : ""}${issue.message}`));
132
+ process.exit(1);
133
+ }
134
+ throw err;
135
+ }
136
+ const { manifest, source } = loaded;
137
+ let targets = buildableApps(manifest);
138
+ if (requested.length > 0) {
139
+ const known = new Set(targets.map((t) => t.name));
140
+ const unknown = requested.filter((name) => !known.has(name));
141
+ if (unknown.length > 0) {
142
+ console.error(chalk.red(`✗ Unknown app(s): ${unknown.join(", ")}`));
143
+ console.error(chalk.dim(` This repository declares: ${targets.map((t) => t.name).join(", ") || "(none)"}`));
144
+ process.exit(1);
145
+ }
146
+ targets = targets.filter((t) => requested.includes(t.name));
147
+ }
148
+ if (targets.length === 0) {
149
+ console.log(chalk.yellow("No buildable apps declared. Nothing to do."));
150
+ return;
151
+ }
152
+ if (!findBackendApp(manifest) && source === "synthesized") {
153
+ console.log(chalk.dim("No rebase.json found — building workspace packages.\n"));
154
+ await runWorkspaceBuilds(projectRoot);
155
+ return;
156
+ }
157
+ const output = args["--output"] ? path.resolve(process.cwd(), args["--output"]) : void 0;
158
+ const bundled = targets.filter(({ app }) => app.type === "backend" && app.runtime !== "custom" || app.type === "static" && Boolean(app.build) && Boolean(app.output));
159
+ if (output && bundled.length > 1) throw new UsageError(`--output names one bundle directory, and this build produces ${bundled.length}: ${bundled.map((t) => t.name).join(", ")}. Build one app into it: rebase build ${bundled[0].name} --output ${args["--output"]}`);
160
+ console.log(`${chalk.bold("Rebase")} — building ${targets.length} app(s)\n`);
161
+ const builtApps = /* @__PURE__ */ new Set();
162
+ for (const { name, app } of targets) {
163
+ console.log(chalk.cyan(`▸ ${name}`) + chalk.dim(` (${app.type})`));
164
+ if (app.type === "backend" && app.runtime === "custom") {
165
+ console.log(chalk.dim(" custom runtime — this project builds its own image, not a bundle"));
166
+ for (const line of dockerBuildHint(projectRoot, name, app)) console.log(line);
167
+ console.log("");
168
+ continue;
169
+ }
170
+ if (app.type === "backend") {
171
+ const { graph: resourceGraph, issues } = await deriveResourceGraph(deriveOptionsFor(projectRoot, app));
172
+ if (issues.length > 0) {
173
+ console.error(chalk.red(`\n ✗ ${issues.length} problem(s) in the declared resources:\n`));
174
+ for (const issue of issues) console.error(` ${chalk.bold(issue.path)} ${issue.message}`);
175
+ console.error("");
176
+ process.exitCode = 1;
177
+ return;
178
+ }
179
+ writeResourceGraphFile(projectRoot, resourceGraph);
180
+ const drift = detectFrameworkDepDrift(projectRoot, cliVersion());
181
+ const result = await buildBundle({
182
+ projectRoot,
183
+ appName: name,
184
+ app,
185
+ outDir: output,
186
+ runtimeRange: manifest.rebase,
187
+ resources: resourceGraph,
188
+ skipTypeCheck: args["--skip-type-check"],
189
+ skipSchema: args["--skip-schema"],
190
+ vendor: args["--no-vendor"] ? false : args["--vendor"] ? true : void 0
191
+ });
192
+ const rel = path.relative(projectRoot, result.outDir);
193
+ console.log(chalk.green(` ✓ bundle → ${rel}/`));
194
+ const schemaVersion = result.manifest.schemaVersion;
195
+ console.log(chalk.dim(` ${result.collectionCount} collection(s)${schemaVersion ? `, schema ${schemaVersion}` : ""}`));
196
+ if (result.vendor.vendored) {
197
+ console.log(chalk.dim(` dependencies installed into the bundle (${result.vendor.target?.os}/${result.vendor.target?.cpu})`));
198
+ if ((result.vendor.bytes ?? 0) > 157286400) {
199
+ const mb = Math.round((result.vendor.bytes ?? 0) / (1024 * 1024));
200
+ console.log(chalk.yellow(` ⚠ the installed tree is ${mb} MB on disk — enough to risk the control plane's 100 MB limit on the compressed upload`));
201
+ console.log(chalk.dim(" Shrink the declared dependencies, or rebuild with --no-vendor."));
202
+ }
203
+ } else if (Object.keys(result.manifest.deps.declared).length === 0) console.log(chalk.dim(" no dependencies to install — nothing to bundle"));
204
+ else {
205
+ console.log(chalk.yellow(` ⚠ dependencies not bundled: ${result.vendor.skipped}`));
206
+ console.log(chalk.dim(" They install on every pod start instead, which is ~40-60s of cold start."));
207
+ }
208
+ if (result.manifest.hooks.native) {
209
+ const names = (result.manifest.hooks.nativeModules ?? []).map((m) => m.name).join(", ");
210
+ console.log(chalk.yellow(` ⚠ native dependencies detected: ${names}`));
211
+ console.log(chalk.dim(" These cannot run on the managed runtime. See `rebase doctor`."));
212
+ }
213
+ if (drift.behind.length > 0) {
214
+ console.log(chalk.yellow(` ⚠ framework dependencies older than this CLI (${cliVersion()}):`));
215
+ for (const dep of drift.behind) console.log(chalk.dim(` ${dep.name}@${dep.range} (${dep.file})`));
216
+ console.log(chalk.dim(" The image supplies the server, but your bundle supplies the database"));
217
+ console.log(chalk.dim(" driver — a newer runtime does not update it."));
218
+ console.log(chalk.dim(` Run \`${upgradeToThisCli()}\`, then rebuild.`));
219
+ } else if (drift.disagreeing.length > 0) {
220
+ console.log(chalk.yellow(` ⚠ mixed @rebasepro versions declared: ${drift.disagreeing.join(", ")}`));
221
+ console.log(chalk.dim(" These are published together and expect to run together."));
222
+ console.log(chalk.dim(` Run \`${upgradeToThisCli()}\` to pin them alike, then rebuild.`));
223
+ }
224
+ if (!args["--no-static"]) {
225
+ const folded = await foldFrontendIntoBundle({
226
+ projectRoot,
227
+ manifest,
228
+ bundleDir: result.outDir,
229
+ skipBuild: args["--skip-static-build"] === true,
230
+ builtApps,
231
+ log: (m) => console.log(m)
232
+ }).catch((err) => {
233
+ console.error(chalk.red(` ✗ ${err instanceof Error ? err.message : String(err)}`));
234
+ process.exit(1);
235
+ });
236
+ for (const outcome of folded ?? []) console.log(chalk.green(` ✓ ${outcome.appName} folded in`) + chalk.dim(` (${outcome.fileCount} file(s) → served at ${formatAppAddress(outcome)})`));
237
+ }
238
+ } else if (app.type === "static") await buildAssetApp(projectRoot, name, app, manifest.rebase, output, { builtApps }).catch((err) => {
239
+ console.error(chalk.red(` ✗ ${err instanceof Error ? err.message : String(err)}`));
240
+ process.exit(1);
241
+ });
242
+ console.log("");
243
+ }
244
+ console.log(chalk.green("✓ Build complete."));
245
+ }
246
+ /**
247
+ * Build a static app and package it into a static bundle.
248
+ *
249
+ * Runs the app's own build command, checks it produced the declared output, then
250
+ * packages that output into a `static`-kind bundle — the same deployable shape as
251
+ * a backend bundle, so a frontend or admin app deploys through the identical
252
+ * path and runs on the identical image, just serving files instead of an API.
253
+ *
254
+ * Throws when the build fails or produces nothing usable, so the caller answers
255
+ * in its own way: `rebase build` with a red line, `rebase cloud deploy --json`
256
+ * with its JSON error.
257
+ */
258
+ async function buildAssetApp(projectRoot, name, app, runtimeRange, outOverride, options = {}) {
259
+ const asset = app;
260
+ const address = staticAppAddress(name, asset);
261
+ const basePath = address.path;
262
+ const say = (line) => {
263
+ if (options.quietStdout) console.error(line);
264
+ else console.log(line);
265
+ };
266
+ if (!asset.build) {
267
+ say(chalk.dim(" no build command declared — skipping"));
268
+ return;
269
+ }
270
+ if (options.builtApps?.has(name)) say(chalk.dim(" built once already in this run — packaging that output"));
271
+ else {
272
+ try {
273
+ await execa(asset.build, {
274
+ cwd: projectRoot,
275
+ stdio: toolStdio(options.quietStdout),
276
+ shell: true,
277
+ env: staticBuildEnv(basePath, name)
278
+ });
279
+ } catch {
280
+ throw new Error(`build command failed for "${name}"`);
281
+ }
282
+ options.builtApps?.add(name);
283
+ }
284
+ if (!asset.output) {
285
+ say(chalk.yellow(" no output directory declared — built, but nothing to bundle"));
286
+ return;
287
+ }
288
+ const outputPath = path.join(projectRoot, asset.output);
289
+ if (!fs.existsSync(outputPath)) throw new Error(`declared output "${asset.output}" does not exist after building`);
290
+ const indexHtml = path.join(outputPath, "index.html");
291
+ if (fs.existsSync(indexHtml)) assertBuiltForPath(fs.readFileSync(indexHtml, "utf8"), basePath, name);
292
+ const result = buildStaticBundle({
293
+ projectRoot,
294
+ appName: name,
295
+ assetsDir: outputPath,
296
+ outDir: outOverride ? path.resolve(process.cwd(), outOverride) : path.join(projectRoot, `dist-bundle-${name}`),
297
+ runtimeRange,
298
+ path: basePath,
299
+ host: address.host,
300
+ spa: asset.spa ?? true,
301
+ cms: asset.cms
302
+ });
303
+ const rel = path.relative(projectRoot, result.outDir);
304
+ say(chalk.green(` ✓ static bundle → ${rel}/`) + chalk.dim(` (${result.fileCount} file(s) → served at ${formatAppAddress(address)})`));
305
+ return result.outDir;
306
+ }
307
+ /**
308
+ * The `rebase upgrade` line the drift warnings print.
309
+ *
310
+ * Aimed at this CLI's own version, because that is what the warning measured
311
+ * against: "older than this CLI" is answered by moving to exactly this CLI, not
312
+ * to whatever `latest` happens to be — which, on a canary, is older still.
313
+ */
314
+ function upgradeToThisCli() {
315
+ const version = cliVersion();
316
+ return version === "unknown" ? "rebase upgrade" : `rebase upgrade --to ${version}`;
317
+ }
318
+ /** The pre-manifest behaviour: build every workspace package. */
319
+ async function runWorkspaceBuilds(projectRoot) {
320
+ const pm = detectPackageManager(projectRoot);
321
+ const buildCmd = getPMCommands(pm).runAll("build");
322
+ console.log(`${chalk.bold("Rebase")} — Building all workspaces with ${chalk.cyan(pm)}...\n`);
323
+ try {
324
+ await execa(buildCmd[0], buildCmd.slice(1), {
325
+ cwd: projectRoot,
326
+ stdio: "inherit"
327
+ });
328
+ } catch {
329
+ console.error(chalk.red("\n✗ Build failed."));
330
+ process.exit(1);
331
+ }
332
+ }
333
+ //#endregion
334
+ export { build_exports as n, buildAssetApp as t };
335
+
336
+ //# sourceMappingURL=build-CFwUx-Ff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-CFwUx-Ff.js","names":[],"sources":["../src/commands/build.ts"],"sourcesContent":["/**\n * CLI command: rebase build [app...]\n *\n * Builds the apps a repository declares in `rebase.json`.\n *\n * For a `backend` app this produces a **bundle** — compiled collections,\n * functions and schema plus a manifest — which is the artifact the runtime\n * loads. For `static` and bundled `admin` apps it runs the declared build\n * command and reports where the output landed.\n *\n * A project with no manifest, or one whose backend has been ejected to its own\n * entrypoint, falls back to the previous behaviour: run every workspace's own\n * `build` script. Nothing that built before stops building.\n */\nimport fs from \"fs\";\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { execa } from \"execa\";\nimport type { RebaseAppConfig, RebaseStaticAppConfig } from \"@rebasepro/types\";\nimport { requireProjectRoot } from \"../utils/project\";\nimport { parseCommandArgs, UsageError, wantsHelp } from \"../utils/args\";\nimport { detectPackageManager, getPMCommands } from \"../utils/package-manager\";\nimport { cliVersion } from \"../utils/version\";\nimport { toolStdio } from \"../utils/tool-stdio\";\nimport {\n buildableApps,\n findBackendApp,\n formatAppAddress,\n loadManifest,\n ManifestError,\n resolveBackendPaths,\n staticAppAddress\n} from \"../manifest\";\nimport {\n buildBundle,\n buildStaticBundle,\n detectFrameworkDepDrift,\n DEFAULT_BUNDLE_DIR,\n VENDOR_SIZE_WARN_BYTES\n} from \"../bundle\";\nimport { assertBuiltForPath, foldFrontendIntoBundle, staticBuildEnv } from \"../fold-static\";\nimport { deriveOptionsFor, deriveResourceGraph, writeResourceGraphFile } from \"../resources/derive\";\n\nfunction printHelp(): void {\n console.log(`\n${chalk.bold(\"rebase build\")} — build the apps declared in rebase.json\n\n${chalk.bold(\"Usage\")}\n rebase build [app...] Build the named apps (default: all)\n\n${chalk.bold(\"Options\")}\n --output, --out <dir> Bundle output directory (default: ${DEFAULT_BUNDLE_DIR});\n one app at a time\n --skip-type-check Compile without type checking (faster; use for iteration only)\n --skip-schema Do not regenerate the database schema from collections\n --no-static Do not fold the frontend into the backend bundle (each\n static app still gets its own bundle)\n --skip-static-build Fold the frontend as already built, without running its\n build command — for CI that built it in an earlier step\n --no-vendor Do not install dependencies into the bundle (they\n install on every pod start instead, ~40-60s slower)\n --vendor Install them whatever the tree's size — for a\n deploy that builds from source and never uploads it\n --workspace Run every workspace's own build script instead\n -h, --help Show this help\n\n${chalk.bold(\"Examples\")}\n rebase build Build every app in this repository\n rebase build backend Build only the backend bundle\n rebase build web Build only the \"web\" static app\n`.trim());\n}\n\n/**\n * The two commands that turn a custom-runtime app into an image.\n *\n * Exported for the test, because the failure this replaced was in the printed\n * text and nowhere else. It said:\n *\n * docker build -f backend/Dockerfile .\n *\n * for every custom backend, and the `.` was a guess — `context` was validated,\n * stored on the config, and read by nothing. For the reference project that\n * guess is wrong: `app/backend/Dockerfile` opens by copying `pnpm-lock.yaml`\n * and `pnpm-workspace.yaml`, which live at the monorepo root, so the command\n * `rebase build` handed you died on its first instruction. The deploy that\n * actually works, `infra/cloudbuild.yaml`, has always said\n * `-f app/backend/Dockerfile .` from the root.\n *\n * `dockerfile` is relative to `rebase.json`; `context` is too, and may point\n * above it. Docker resolves `-f` against the working directory, not the\n * context, so the path has to be re-expressed against wherever the command\n * runs — which is what the old line never did and is the whole reason it\n * could not be right for both.\n */\nexport function dockerBuildHint(\n projectRoot: string,\n name: string,\n app: { dockerfile?: string; context?: string }\n): string[] {\n const dockerfile = app.dockerfile ?? \"Dockerfile\";\n const context = app.context ?? \".\";\n const contextDir = path.resolve(projectRoot, context);\n const fromContext = path.relative(contextDir, path.resolve(projectRoot, dockerfile));\n\n const build = `${chalk.cyan(`npm run build --workspace ${name}`)}`;\n\n // A Dockerfile outside its own context is legal to `docker build` but means\n // nothing it copies is reachable, so there is no command to offer. Say what\n // is wrong instead of printing one that cannot work.\n if (fromContext.startsWith(\"..\")) {\n return [\n chalk.dim(` ${build}`),\n chalk.yellow(` ⚠ ${dockerfile} is outside the build context (${context}) — nothing it COPYs is reachable.`),\n chalk.dim(` Widen \"context\" in rebase.json, or move the Dockerfile inside it.`)\n ];\n }\n\n const docker = chalk.cyan(`docker build -f ${fromContext} .`);\n return context === \".\"\n ? [chalk.dim(` ${build} then ${docker}`)]\n : [chalk.dim(` ${build}`), chalk.dim(` ${chalk.cyan(`cd ${context}`)} && ${docker}`)];\n}\n\nexport async function buildCommand(rawArgs: string[] = []): Promise<void> {\n if (wantsHelp(rawArgs)) {\n printHelp();\n return;\n }\n\n const { flags: args, positionals: requested } = parseCommandArgs({\n spec: {\n \"--output\": String,\n // `--out` kept as an accepted alias. `generate-sdk` has always\n // spelled this `--output`, and two names for one concept across one\n // CLI is a thing you have to remember rather than know. `--output`\n // is canonical now; `--out` still works so no script breaks.\n \"--out\": \"--output\",\n \"--skip-type-check\": Boolean,\n /* Do not install the declared dependencies into the bundle. The\n bundle still works — it installs them at boot, as every bundle did\n before vendoring existed — so this is for a build that must not\n shell out to npm, not for a smaller artifact. */\n \"--no-vendor\": Boolean,\n /* Keep the installed tree whatever its size. The size ceiling\n protects an upload that a source-built deploy never performs, so\n that path needs a way to say so. */\n \"--vendor\": Boolean,\n \"--skip-schema\": Boolean,\n /* Do not fold the frontend into the backend bundle. For a project\n that publishes its frontend elsewhere and does not want the assets\n travelling with its API. */\n \"--no-static\": Boolean,\n /* Fold assets that are already built, without re-running the app's\n build command — for a CI job that built the frontend in an earlier\n step. */\n \"--skip-static-build\": Boolean,\n \"--workspace\": Boolean\n },\n rawArgs,\n commandWords: 1,\n command: \"build\"\n });\n\n const projectRoot = requireProjectRoot();\n\n if (args[\"--workspace\"]) {\n await runWorkspaceBuilds(projectRoot);\n return;\n }\n\n let loaded;\n try {\n loaded = loadManifest(projectRoot);\n } catch (err) {\n if (err instanceof ManifestError) {\n console.error(chalk.red(`✗ ${err.message}`));\n for (const issue of err.issues) {\n console.error(chalk.red(` ${issue.path ? `${issue.path}: ` : \"\"}${issue.message}`));\n }\n process.exit(1);\n }\n throw err;\n }\n\n const { manifest, source } = loaded;\n\n let targets = buildableApps(manifest);\n if (requested.length > 0) {\n const known = new Set(targets.map(t => t.name));\n const unknown = requested.filter(name => !known.has(name));\n if (unknown.length > 0) {\n console.error(chalk.red(`✗ Unknown app(s): ${unknown.join(\", \")}`));\n console.error(chalk.dim(` This repository declares: ${targets.map(t => t.name).join(\", \") || \"(none)\"}`));\n process.exit(1);\n }\n targets = targets.filter(t => requested.includes(t.name));\n }\n\n if (targets.length === 0) {\n console.log(chalk.yellow(\"No buildable apps declared. Nothing to do.\"));\n return;\n }\n\n // An ejected backend owns its own build; the workspace scripts are the only\n // thing that knows how to run it.\n const backend = findBackendApp(manifest);\n if (!backend && source === \"synthesized\") {\n console.log(chalk.dim(\"No rebase.json found — building workspace packages.\\n\"));\n await runWorkspaceBuilds(projectRoot);\n return;\n }\n\n // `--output` names one bundle directory, resolved from where it was typed.\n // It is refused for a build that produces several bundles rather than\n // handed to each: every bundle build empties its directory first, so the\n // last app built deleted the others' and the build still reported success.\n const output = args[\"--output\"] ? path.resolve(process.cwd(), args[\"--output\"]) : undefined;\n const bundled = targets.filter(({ app }) =>\n (app.type === \"backend\" && app.runtime !== \"custom\") ||\n (app.type === \"static\" && Boolean(app.build) && Boolean(app.output)));\n if (output && bundled.length > 1) {\n throw new UsageError(\n `--output names one bundle directory, and this build produces ${bundled.length}: ` +\n `${bundled.map(t => t.name).join(\", \")}. Build one app into it: ` +\n `rebase build ${bundled[0].name} --output ${args[\"--output\"]}`\n );\n }\n\n console.log(`${chalk.bold(\"Rebase\")} — building ${targets.length} app(s)\\n`);\n\n // Each static app is built once per run, whichever consumer gets to it\n // first: folding into the backend bundle, or its own static bundle.\n const builtApps = new Set<string>();\n\n for (const { name, app } of targets) {\n console.log(chalk.cyan(`▸ ${name}`) + chalk.dim(` (${app.type})`));\n\n if (app.type === \"backend\" && app.runtime === \"custom\") {\n // An ejected backend's artifact is an IMAGE, not a bundle. Building\n // one anyway produced a `dist-bundle/` the project never deploys,\n // which is worse than doing nothing: it looks like the thing that\n // ships. The workspace's own `build` script compiles this app, and\n // the Dockerfile turns it into the image.\n console.log(chalk.dim(\" custom runtime — this project builds its own image, not a bundle\"));\n for (const line of dockerBuildHint(projectRoot, name, app)) console.log(line);\n console.log(\"\");\n continue;\n }\n\n if (app.type === \"backend\") {\n // Derived per backend app, because each has its own config\n // directory. Issues are fatal here rather than reported: a bundle\n // whose manifest is missing a bucket the code declares would deploy\n // into a tenant with nothing provisioned for it, and the first sign\n // would be uploads failing in production.\n const { graph: resourceGraph, issues } = await deriveResourceGraph(deriveOptionsFor(projectRoot, app));\n if (issues.length > 0) {\n console.error(chalk.red(`\\n ✗ ${issues.length} problem(s) in the declared resources:\\n`));\n for (const issue of issues) console.error(` ${chalk.bold(issue.path)} ${issue.message}`);\n console.error(\"\");\n process.exitCode = 1;\n return;\n }\n // Written alongside the bundle so the repository records what this\n // project needs. `rebase resources --check` is what keeps it honest.\n writeResourceGraphFile(projectRoot, resourceGraph);\n\n /* The framework pins, read before the build and reported after it.\n Ranges no single version satisfies are refused by `buildBundle`\n itself, before it builds anything, for every command that builds\n a bundle. */\n const drift = detectFrameworkDepDrift(projectRoot, cliVersion());\n\n const result = await buildBundle({\n projectRoot,\n appName: name,\n app,\n outDir: output,\n runtimeRange: manifest.rebase,\n resources: resourceGraph,\n skipTypeCheck: args[\"--skip-type-check\"],\n skipSchema: args[\"--skip-schema\"],\n vendor: args[\"--no-vendor\"] ? false : (args[\"--vendor\"] ? true : undefined)\n });\n const rel = path.relative(projectRoot, result.outDir);\n console.log(chalk.green(` ✓ bundle → ${rel}/`));\n // A headless build has no schema version — the API is introspected\n // from the live database at boot — and interpolating it anyway left\n // the summary ending in a dangling `schema `, which reads as a value\n // that failed to render rather than one that does not exist.\n const schemaVersion = result.manifest.schemaVersion;\n console.log(chalk.dim(\n ` ${result.collectionCount} collection(s)${schemaVersion ? `, schema ${schemaVersion}` : \"\"}`\n ));\n /* Say what the bundle's cold start will be, at the one moment\n anyone is listening.\n\n A vendored bundle starts in about five seconds; one that installs\n at boot takes forty to sixty, on EVERY pod start — an eviction, a\n node failure, an OOM, a runtime rollout. That is not a build\n detail, it is what each of those events costs in downtime, and it\n is invisible until an incident unless it is said here. */\n if (result.vendor.vendored) {\n console.log(chalk.dim(` dependencies installed into the bundle (${result.vendor.target?.os}/${result.vendor.target?.cpu})`));\n if ((result.vendor.bytes ?? 0) > VENDOR_SIZE_WARN_BYTES) {\n const mb = Math.round((result.vendor.bytes ?? 0) / (1024 * 1024));\n /* The limit is on the *compressed* upload and this is the\n tree on disk, so a number above 100 does not mean the\n upload fails — but \"201 MB, close to the 100 MB limit\"\n reads as nonsense and got ignored for exactly that\n reason. Say which quantity is which. */\n console.log(chalk.yellow(\n ` ⚠ the installed tree is ${mb} MB on disk — enough to risk the control plane's 100 MB ` +\n \"limit on the compressed upload\"));\n console.log(chalk.dim(\" Shrink the declared dependencies, or rebuild with --no-vendor.\"));\n }\n } else if (Object.keys(result.manifest.deps.declared).length === 0) {\n // Nothing to install is not a degraded state — this bundle\n // already starts as fast as a vendored one. Warning here would\n // train people to ignore the warning that matters.\n console.log(chalk.dim(\" no dependencies to install — nothing to bundle\"));\n } else {\n console.log(chalk.yellow(` ⚠ dependencies not bundled: ${result.vendor.skipped}`));\n console.log(chalk.dim(\" They install on every pod start instead, which is ~40-60s of cold start.\"));\n }\n\n if (result.manifest.hooks.native) {\n const names = (result.manifest.hooks.nativeModules ?? []).map(m => m.name).join(\", \");\n console.log(chalk.yellow(` ⚠ native dependencies detected: ${names}`));\n console.log(chalk.dim(\" These cannot run on the managed runtime. See `rebase doctor`.\"));\n }\n\n /* Framework pins older than this CLI.\n\n Warned here because this is the only moment anyone can be told.\n Locally every `@rebasepro/*` resolves through pnpm's workspace and\n `link:` overrides to the checkout, so the version strings in\n package.json are never exercised — the project runs fine on a\n developer's machine while declaring something years old. Those\n strings are first honoured when the runtime npm-installs them in\n the cloud, and by then the symptom is a tenant that boots and then\n misbehaves against its database.\n\n A warning rather than a hard failure: the CLI cannot know that a\n newer package has actually been published, and refusing to build\n over a guess would be worse than saying it out loud. (`drift` was\n read before the build, above.) */\n if (drift.behind.length > 0) {\n console.log(chalk.yellow(` ⚠ framework dependencies older than this CLI (${cliVersion()}):`));\n for (const dep of drift.behind) {\n console.log(chalk.dim(` ${dep.name}@${dep.range} (${dep.file})`));\n }\n console.log(chalk.dim(\" The image supplies the server, but your bundle supplies the database\"));\n console.log(chalk.dim(\" driver — a newer runtime does not update it.\"));\n console.log(chalk.dim(` Run \\`${upgradeToThisCli()}\\`, then rebuild.`));\n } else if (drift.disagreeing.length > 0) {\n console.log(chalk.yellow(` ⚠ mixed @rebasepro versions declared: ${drift.disagreeing.join(\", \")}`));\n console.log(chalk.dim(\" These are published together and expect to run together.\"));\n console.log(chalk.dim(` Run \\`${upgradeToThisCli()}\\` to pin them alike, then rebuild.`));\n }\n\n /* Fold the project's static apps into the backend bundle, so ONE\n runtime serves the site at `/`, the admin at `/admin` and the API\n at `/api` — the shape the scaffolded template produces and the\n shape a custom container already had.\n\n Without this, moving a project to the managed runtime silently\n removed its website: the API answered perfectly and every page\n 404'd, because the managed pod runs the backend bundle and nothing\n else. Parity with the container being replaced is the only honest\n baseline for calling managed a drop-in.\n\n `--no-static` opts out, for a project that publishes its frontend\n somewhere else and does not want the assets in its bundle. */\n if (!args[\"--no-static\"]) {\n const folded = await foldFrontendIntoBundle({\n projectRoot,\n manifest,\n bundleDir: result.outDir,\n skipBuild: args[\"--skip-static-build\"] === true,\n builtApps,\n log: (m) => console.log(m)\n }).catch((err: unknown) => {\n console.error(chalk.red(` ✗ ${err instanceof Error ? err.message : String(err)}`));\n process.exit(1);\n });\n for (const outcome of folded ?? []) {\n console.log(\n chalk.green(` ✓ ${outcome.appName} folded in`) +\n chalk.dim(` (${outcome.fileCount} file(s) → served at ${formatAppAddress(outcome)})`)\n );\n }\n }\n } else if (app.type === \"static\") {\n await buildAssetApp(projectRoot, name, app, manifest.rebase, output, { builtApps }).catch((err: unknown) => {\n console.error(chalk.red(` ✗ ${err instanceof Error ? err.message : String(err)}`));\n process.exit(1);\n });\n }\n\n console.log(\"\");\n }\n\n console.log(chalk.green(\"✓ Build complete.\"));\n}\n\n/**\n * Build a static app and package it into a static bundle.\n *\n * Runs the app's own build command, checks it produced the declared output, then\n * packages that output into a `static`-kind bundle — the same deployable shape as\n * a backend bundle, so a frontend or admin app deploys through the identical\n * path and runs on the identical image, just serving files instead of an API.\n *\n * Throws when the build fails or produces nothing usable, so the caller answers\n * in its own way: `rebase build` with a red line, `rebase cloud deploy --json`\n * with its JSON error.\n */\nexport async function buildAssetApp(\n projectRoot: string,\n name: string,\n app: RebaseAppConfig,\n runtimeRange: string,\n outOverride?: string,\n /**\n * `quietStdout`: every line, the build command's included, goes to stderr. See `toolStdio`.\n * `builtApps`: the static apps already built in this run (see `FoldOptions.builtApps`).\n */\n options: { quietStdout?: boolean; builtApps?: Set<string> } = {}\n): Promise<string | undefined> {\n const asset = app as RebaseStaticAppConfig;\n // The path part is what the app is built for and mounted at; the hostname,\n // when `path` names one, only travels in the bundle.\n const address = staticAppAddress(name, asset);\n const basePath = address.path;\n const say = (line: string): void => {\n if (options.quietStdout) console.error(line);\n else console.log(line);\n };\n\n if (!asset.build) {\n say(chalk.dim(\" no build command declared — skipping\"));\n return undefined;\n }\n\n if (options.builtApps?.has(name)) {\n say(chalk.dim(\" built once already in this run — packaging that output\"));\n } else {\n try {\n await execa(asset.build, {\n cwd: projectRoot,\n stdio: toolStdio(options.quietStdout),\n shell: true,\n env: staticBuildEnv(basePath, name)\n });\n } catch {\n throw new Error(`build command failed for \"${name}\"`);\n }\n options.builtApps?.add(name);\n }\n\n if (!asset.output) {\n say(chalk.yellow(\" no output directory declared — built, but nothing to bundle\"));\n return undefined;\n }\n\n const outputPath = path.join(projectRoot, asset.output);\n if (!fs.existsSync(outputPath)) {\n // The command exited 0 but produced nothing where the manifest says it\n // should. Bundling that would ship an empty site.\n throw new Error(`declared output \"${asset.output}\" does not exist after building`);\n }\n\n // The assets were built for `basePath`; refusing here is the difference\n // between a build error and a blank page nobody can diagnose.\n const indexHtml = path.join(outputPath, \"index.html\");\n if (fs.existsSync(indexHtml)) {\n assertBuiltForPath(fs.readFileSync(indexHtml, \"utf8\"), basePath, name);\n }\n\n // Per-app bundle directory, so a project's several static apps do not clobber\n // one another or the backend's `dist-bundle`.\n const outDir = outOverride\n ? path.resolve(process.cwd(), outOverride)\n : path.join(projectRoot, `dist-bundle-${name}`);\n const result = buildStaticBundle({\n projectRoot,\n appName: name,\n assetsDir: outputPath,\n outDir,\n runtimeRange,\n path: basePath,\n host: address.host,\n spa: asset.spa ?? true,\n cms: asset.cms\n });\n const rel = path.relative(projectRoot, result.outDir);\n say(\n chalk.green(` ✓ static bundle → ${rel}/`) +\n chalk.dim(` (${result.fileCount} file(s) → served at ${formatAppAddress(address)})`)\n );\n return result.outDir;\n}\n\n/**\n * The `rebase upgrade` line the drift warnings print.\n *\n * Aimed at this CLI's own version, because that is what the warning measured\n * against: \"older than this CLI\" is answered by moving to exactly this CLI, not\n * to whatever `latest` happens to be — which, on a canary, is older still.\n */\nfunction upgradeToThisCli(): string {\n const version = cliVersion();\n return version === \"unknown\" ? \"rebase upgrade\" : `rebase upgrade --to ${version}`;\n}\n\n/** The pre-manifest behaviour: build every workspace package. */\nasync function runWorkspaceBuilds(projectRoot: string): Promise<void> {\n const pm = detectPackageManager(projectRoot);\n const cmds = getPMCommands(pm);\n const buildCmd = cmds.runAll(\"build\");\n\n console.log(`${chalk.bold(\"Rebase\")} — Building all workspaces with ${chalk.cyan(pm)}...\\n`);\n\n try {\n await execa(buildCmd[0], buildCmd.slice(1), {\n cwd: projectRoot,\n stdio: \"inherit\"\n });\n } catch {\n console.error(chalk.red(\"\\n✗ Build failed.\"));\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAS,YAAkB;CACvB,QAAQ,IAAI;EACd,MAAM,KAAK,cAAc,EAAE;;EAE3B,MAAM,KAAK,OAAO,EAAE;;;EAGpB,MAAM,KAAK,SAAS,EAAE;mEAC2C,mBAAmB;;;;;;;;;;;;;;;EAepF,MAAM,KAAK,UAAU,EAAE;;;;EAIvB,KAAK,CAAC;AACR;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,gBACZ,aACA,MACA,KACQ;CACR,MAAM,aAAa,IAAI,cAAc;CACrC,MAAM,UAAU,IAAI,WAAW;CAC/B,M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