@rebasepro/cli 0.11.1-canary.gfd39654 → 0.12.1-canary.g5f403cf

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 (39) hide show
  1. package/bin/rebase.js +21 -0
  2. package/dist/bundle.d.ts +24 -7
  3. package/dist/commands/eject.d.ts +1 -0
  4. package/dist/commands/init.d.ts +19 -15
  5. package/dist/fold-static.d.ts +41 -15
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.es.js +899 -250
  8. package/dist/index.es.js.map +1 -1
  9. package/dist/manifest.d.ts +27 -8
  10. package/package.json +11 -11
  11. package/runtime/dev-server.mjs +0 -1
  12. package/templates/{template/backend → eject}/Dockerfile +16 -4
  13. package/templates/{template → eject}/backend/src/env.ts +0 -1
  14. package/templates/{template → eject}/backend/src/index.ts +41 -27
  15. package/templates/eject/docker-compose.custom.yml +71 -0
  16. package/templates/overlays/baas/backend/package.json +1 -4
  17. package/templates/overlays/baas/backend/tsconfig.json +8 -2
  18. package/templates/overlays/baas/config/index.ts +15 -0
  19. package/templates/overlays/baas/config/package.json +28 -0
  20. package/templates/overlays/baas/package.json +2 -1
  21. package/templates/overlays/baas/pnpm-workspace.yaml +1 -0
  22. package/templates/overlays/baas/rebase.json +2 -6
  23. package/templates/template/.env.example +15 -0
  24. package/templates/template/README.md +56 -22
  25. package/templates/template/ai-instructions.md +1 -0
  26. package/templates/template/backend/functions/hello.ts +45 -14
  27. package/templates/template/backend/package.json +1 -4
  28. package/templates/template/backend/tsconfig.json +23 -2
  29. package/templates/template/config/tsconfig.json +16 -1
  30. package/templates/template/docker-compose.yml +62 -38
  31. package/templates/template/frontend/package.json +2 -1
  32. package/templates/template/frontend/src/App.tsx +2 -1
  33. package/templates/template/frontend/src/main.tsx +8 -1
  34. package/templates/template/frontend/vite.config.ts +5 -0
  35. package/templates/template/rebase.json +5 -8
  36. package/templates/overlays/baas/backend/src/index.ts +0 -216
  37. package/templates/template/frontend/Dockerfile +0 -52
  38. package/templates/template/frontend/nginx.conf +0 -40
  39. /package/templates/overlays/baas/{backend/src → config}/storage.ts +0 -0
package/dist/index.es.js CHANGED
@@ -12,7 +12,7 @@ import crypto from "crypto";
12
12
  import { execSync, spawn, spawnSync } from "child_process";
13
13
  import os from "os";
14
14
  import { createRebaseClient } from "@rebasepro/client";
15
- import { BUNDLE_FORMAT_VERSION, RUNTIME_CONTRACT_VERSION, computeSchemaVersion, deserializeCollections } from "@rebasepro/types";
15
+ import { BUNDLE_FORMAT_VERSION, RUNTIME_CONTRACT_VERSION, computeSchemaVersion, deserializeCollections, findStorageSuffixCollision, normalizeStorageSources, storageEnvSuffix } from "@rebasepro/types";
16
16
  import { generateSDK } from "@rebasepro/codegen";
17
17
  import { createRequire } from "module";
18
18
  //#region src/utils/package-manager.ts
@@ -829,7 +829,7 @@ function openUrl(target, label = "Opening") {
829
829
  //#region src/commands/init.ts
830
830
  var access = promisify(fs.access);
831
831
  var __filename$1 = fileURLToPath(import.meta.url);
832
- var __dirname$1 = path.dirname(__filename$1);
832
+ var __dirname$2 = path.dirname(__filename$1);
833
833
  function findParentDir(currentDir, targetName) {
834
834
  const root = path.parse(currentDir).root;
835
835
  while (currentDir && currentDir !== root) {
@@ -838,22 +838,56 @@ function findParentDir(currentDir, targetName) {
838
838
  }
839
839
  return null;
840
840
  }
841
- var cliRoot = findParentDir(__dirname$1, "cli");
841
+ var cliRoot = findParentDir(__dirname$2, "cli");
842
842
  var PROJECT_NAME_RE = /^[a-z0-9][a-z0-9._-]*$/;
843
+ /**
844
+ * Every scaffolded file that carries a `{{PLACEHOLDER}}`.
845
+ *
846
+ * Exported because it is the single source of truth: `init.test.ts` reads it and
847
+ * asserts that every template file containing `{{` appears here. It used to be a
848
+ * local, with the test harness keeping a *second* copy — so the two drifted, and
849
+ * a test built on the copy could not observe the production list at all.
850
+ *
851
+ * The drift shipped: `docker-compose.yml` arrived with the self-host work
852
+ * (26fd5259c) and was added to neither, so every scaffolded project got a literal
853
+ * `name: {{PROJECT_NAME}}`. In YAML `{{...}}` is a map, not a string, so the
854
+ * documented `docker compose up` path failed on the file before doing anything:
855
+ *
856
+ * yaml: unmarshal errors: line 28: cannot unmarshal !!map into string
857
+ */
858
+ var TEMPLATE_PLACEHOLDER_FILES = [
859
+ "package.json",
860
+ "frontend/package.json",
861
+ "backend/package.json",
862
+ "config/package.json",
863
+ "frontend/index.html",
864
+ "pnpm-workspace.yaml",
865
+ "docker-compose.yml",
866
+ "README.md"
867
+ ];
843
868
  /** Returns an error message, or null when the name is a valid package name. */
844
869
  function validateProjectName(name) {
845
870
  if (!name.trim()) return "Project name is required";
846
871
  if (!PROJECT_NAME_RE.test(name)) return "Project name must start with a lowercase letter or number and contain only lowercase letters, numbers, hyphens, dots, or underscores";
847
872
  return null;
848
873
  }
849
- var FLAVOR_CHOICES = [{
850
- name: "BaaS + admin — API plus an admin UI, driven by collections you define (like Payload/Directus)",
851
- value: "cms",
852
- short: "BaaS + admin"
874
+ /**
875
+ * Whether to scaffold the admin panel alongside the backend.
876
+ *
877
+ * A boolean, not a named pair. It was `--flavor cms|baas`, and neither word
878
+ * survived what they described: "cms" is a product category rather than a thing
879
+ * this tool builds, and "baas" was the same value that used to appear as
880
+ * `backend.mode` — which is now derived from whether collections are declared.
881
+ * What is left is one question: does this project get an admin UI?
882
+ */
883
+ var HEADLESS_CHOICES = [{
884
+ name: "Backend + admin — API plus an admin UI, driven by collections you define (like Payload/Directus)",
885
+ value: false,
886
+ short: "Backend + admin"
853
887
  }, {
854
- name: "BaaS only — headless API over your database. No collections, no UI (like Supabase)",
855
- value: "baas",
856
- short: "BaaS only"
888
+ name: "Backend only — headless API over your database. No collections, no UI (like Supabase)",
889
+ value: true,
890
+ short: "Backend only"
857
891
  }];
858
892
  var PRESET_CHOICES = [
859
893
  {
@@ -878,7 +912,7 @@ var PRESET_CHOICES = [
878
912
  * types registered by the installed version of inquirer.
879
913
  */
880
914
  function buildInitQuestions(params) {
881
- const { nameArg, templateArg, flavorArg, hasGitFlag, hasInstallFlag, pm } = params;
915
+ const { nameArg, templateArg, headlessArg, hasGitFlag, hasInstallFlag, pm } = params;
882
916
  const questions = [];
883
917
  if (!nameArg) questions.push({
884
918
  type: "input",
@@ -887,12 +921,12 @@ function buildInitQuestions(params) {
887
921
  default: "my-rebase-app",
888
922
  validate: (input) => validateProjectName(input) ?? true
889
923
  });
890
- if (!flavorArg) questions.push({
924
+ if (headlessArg === void 0) questions.push({
891
925
  type: "select",
892
- name: "flavor",
926
+ name: "headless",
893
927
  message: "What do you want to build?",
894
- choices: FLAVOR_CHOICES,
895
- default: "cms"
928
+ choices: HEADLESS_CHOICES,
929
+ default: false
896
930
  });
897
931
  if (!templateArg) questions.push({
898
932
  type: "select",
@@ -900,7 +934,7 @@ function buildInitQuestions(params) {
900
934
  message: "Choose a starter template:",
901
935
  choices: PRESET_CHOICES,
902
936
  default: "blog",
903
- when: (answers) => (flavorArg ?? answers.flavor) !== "baas"
937
+ when: (answers) => !(headlessArg ?? answers.headless)
904
938
  });
905
939
  if (!hasGitFlag) questions.push({
906
940
  type: "confirm",
@@ -956,7 +990,7 @@ ${chalk.bold("Usage")}
956
990
 
957
991
  ${chalk.bold("Options")}
958
992
  ${chalk.blue("-t, --template")} ${chalk.gray("<preset>")} blog | ecommerce | blank ${chalk.gray("(default: blog)")}
959
- ${chalk.blue("-f, --flavor")} ${chalk.gray("<flavor>")} cms | baas ${chalk.gray("(default: cms)")}
993
+ ${chalk.blue("--headless")} Backend only — no admin panel, no collections
960
994
  ${chalk.blue("-y, --yes")} Accept defaults, never prompt ${chalk.gray("(required for CI / non-TTY)")}
961
995
  ${chalk.blue("-i, --install")} Install dependencies after scaffolding
962
996
  ${chalk.blue("-g, --git")} Initialize a git repository and make an initial commit
@@ -965,14 +999,14 @@ ${chalk.bold("Options")}
965
999
  ${chalk.blue("--project")} ${chalk.gray("<slug>")} Link the scaffold to a Rebase Cloud project
966
1000
  ${chalk.blue("--setup-key")} ${chalk.gray("<key>")} One-time key authenticating the cloud link ${chalk.gray("(use with --project)")}
967
1001
 
968
- ${chalk.bold("Flavors")}
969
- ${chalk.blue("cms")} BaaS + admin UI, driven by collections you define ${chalk.gray("(like Payload/Directus)")}
970
- ${chalk.blue("baas")} Headless API over your database — no collections, no UI ${chalk.gray("(like Supabase)")}
971
- ${chalk.gray("--template has no effect on this flavor.")}
1002
+ ${chalk.bold("What gets scaffolded")}
1003
+ ${chalk.gray("default")} Backend + an admin UI, driven by collections you define ${chalk.gray("(like Payload/Directus)")}
1004
+ ${chalk.blue("--headless")} Backend only, over your existing database ${chalk.gray("(like Supabase)")}
1005
+ ${chalk.gray("--template has no effect: there are no collections to seed.")}
972
1006
 
973
1007
  ${chalk.bold("Examples")}
974
1008
  ${chalk.gray("$")} rebase init my-shop --template ecommerce --install
975
- ${chalk.gray("$")} rebase init my-api --flavor baas --yes
1009
+ ${chalk.gray("$")} rebase init my-api --headless --yes
976
1010
  ${chalk.gray("$")} rebase init . --yes --git
977
1011
  `);
978
1012
  }
@@ -993,14 +1027,13 @@ async function promptForOptions(rawArgs, pm) {
993
1027
  "--database-url": String,
994
1028
  "--introspect": Boolean,
995
1029
  "--template": String,
996
- "--flavor": String,
1030
+ "--headless": Boolean,
997
1031
  "--project": String,
998
1032
  "--setup-key": String,
999
1033
  "--yes": Boolean,
1000
1034
  "-g": "--git",
1001
1035
  "-i": "--install",
1002
1036
  "-t": "--template",
1003
- "-f": "--flavor",
1004
1037
  "-y": "--yes"
1005
1038
  }, {
1006
1039
  argv: rawArgs.slice(3),
@@ -1021,11 +1054,7 @@ async function promptForOptions(rawArgs, pm) {
1021
1054
  console.error(chalk.red(`Unknown template "${templateArg}". Available: ${PRESET_CHOICES.map((p) => p.value).join(", ")}`));
1022
1055
  process.exit(1);
1023
1056
  }
1024
- const flavorArg = args["--flavor"];
1025
- if (flavorArg && !FLAVOR_CHOICES.some((f) => f.value === flavorArg)) {
1026
- console.error(chalk.red(`Unknown flavor "${flavorArg}". Available: ${FLAVOR_CHOICES.map((f) => f.value).join(", ")}`));
1027
- process.exit(1);
1028
- }
1057
+ const headlessArg = args["--headless"] === true ? true : void 0;
1029
1058
  if (isNonInteractive) {
1030
1059
  const projectName = nameArg || "my-rebase-app";
1031
1060
  const targetDirectory = path.resolve(process.cwd(), projectName);
@@ -1041,7 +1070,7 @@ async function promptForOptions(rawArgs, pm) {
1041
1070
  introspect: args["--introspect"] || false,
1042
1071
  preset: templateArg || "blog",
1043
1072
  explicitPreset: !!templateArg,
1044
- flavor: flavorArg || "cms",
1073
+ headless: headlessArg ?? false,
1045
1074
  pm,
1046
1075
  pmCommands,
1047
1076
  cloudProject: args["--project"] || void 0,
@@ -1052,14 +1081,14 @@ async function promptForOptions(rawArgs, pm) {
1052
1081
  if (!process.stdin.isTTY) {
1053
1082
  console.error(chalk.red("Cannot prompt: this is a non-interactive terminal (no TTY)."));
1054
1083
  console.error(chalk.yellow(" Re-run with --yes to accept defaults, passing any choices as flags, e.g.:"));
1055
- console.error(chalk.yellow(` rebase init ${nameArg || "my-app"} --yes --template blog --flavor cms`));
1056
- console.error(chalk.gray(" Options: --template <blog|ecommerce|blank> --flavor <cms|baas> --database-url <url> --install --git"));
1084
+ console.error(chalk.yellow(` rebase init ${nameArg || "my-app"} --yes --template blog`));
1085
+ console.error(chalk.gray(" Options: --template <blog|ecommerce|blank> --headless --database-url <url> --install --git"));
1057
1086
  process.exit(1);
1058
1087
  }
1059
1088
  const questions = buildInitQuestions({
1060
1089
  nameArg,
1061
1090
  templateArg,
1062
- flavorArg,
1091
+ headlessArg,
1063
1092
  hasGitFlag: !!args["--git"],
1064
1093
  hasInstallFlag: !!args["--install"],
1065
1094
  pm
@@ -1079,7 +1108,7 @@ async function promptForOptions(rawArgs, pm) {
1079
1108
  introspect: answers.introspect || false,
1080
1109
  preset: templateArg || answers.preset || "blog",
1081
1110
  explicitPreset: !!templateArg,
1082
- flavor: flavorArg || answers.flavor || "cms",
1111
+ headless: headlessArg ?? Boolean(answers.headless),
1083
1112
  pm,
1084
1113
  pmCommands,
1085
1114
  cloudProject: args["--project"] || void 0,
@@ -1163,12 +1192,12 @@ async function createProject$1(options) {
1163
1192
  const shipped = path.join(options.targetDirectory, from);
1164
1193
  if (fs.existsSync(shipped)) fs.renameSync(shipped, path.join(options.targetDirectory, to));
1165
1194
  }
1166
- if (options.flavor === "baas" && options.explicitPreset) console.log(chalk.yellow(` Ignoring --template ${options.preset}: the baas flavor has no collections.`));
1167
- if (options.flavor !== "baas") {
1195
+ if (options.headless && options.explicitPreset) console.log(chalk.yellow(` Ignoring --template ${options.preset}: a headless project declares no collections.`));
1196
+ if (!options.headless) {
1168
1197
  if (options.introspect && options.preset !== "blank") console.log(chalk.gray(" Using the blank template: collections will come from your database."));
1169
1198
  await applyPreset(options.targetDirectory, options.introspect ? "blank" : options.preset);
1170
1199
  }
1171
- await applyFlavor(options.targetDirectory, options.flavor);
1200
+ await applyHeadless(options.targetDirectory, options.headless);
1172
1201
  await replacePlaceholders(options);
1173
1202
  await configureEnvFile(options.targetDirectory, options.databaseUrl);
1174
1203
  if (options.git) {
@@ -1266,7 +1295,7 @@ async function createProject$1(options) {
1266
1295
  console.log("");
1267
1296
  const runDev = pmCommands.run("dev");
1268
1297
  const runDbPush = pmCommands.run("db:push");
1269
- const isBaas = options.flavor === "baas";
1298
+ const isBaas = options.headless;
1270
1299
  const cdTarget = formatCdTarget(process.cwd(), options.targetDirectory);
1271
1300
  if (cdTarget) console.log(` ${chalk.cyan("cd")} ${cdTarget}`);
1272
1301
  if (!options.installDeps) console.log(` ${chalk.cyan(installCmd.join(" "))}`);
@@ -1336,18 +1365,31 @@ async function createProject$1(options) {
1336
1365
  * presets directory so the final project is clean.
1337
1366
  */
1338
1367
  /**
1339
- * Reduce the scaffolded project to the chosen flavor.
1368
+ * Reduce the scaffolded project to the chosen shape.
1369
+ *
1370
+ * The base template is the full triad. `--headless` drops the frontend and the
1371
+ * declared collections — there is nothing to define, since the server derives
1372
+ * its API from the database — and overlays the files that differ.
1340
1373
  *
1341
- * The base template is the full CMS triad. `baas` drops the frontend and the
1342
- * collections config entirely — there is nothing to define, since the server
1343
- * derives its API from the database — and overlays the files that differ.
1374
+ * The config *package* stays, holding only `storageAuthorize`. Storage is not
1375
+ * under row-level security, so a deployment with file storage enabled and no
1376
+ * access model serves every user's files to every signed-in user; the server
1377
+ * refuses to boot in that state. Deleting the package outright would leave a
1378
+ * headless project with nowhere to put the hook, and the scaffold's own
1379
+ * docker-compose.yml enables storage — so the first `docker compose up` would
1380
+ * crash-loop.
1344
1381
  */
1345
- async function applyFlavor(targetDirectory, flavor) {
1346
- if (flavor !== "baas") return;
1347
- for (const dir of ["frontend", "config"]) fs.rmSync(path.join(targetDirectory, dir), {
1382
+ async function applyHeadless(targetDirectory, headless) {
1383
+ if (!headless) return;
1384
+ fs.rmSync(path.join(targetDirectory, "frontend"), {
1348
1385
  recursive: true,
1349
1386
  force: true
1350
1387
  });
1388
+ fs.rmSync(path.join(targetDirectory, "config", "collections"), {
1389
+ recursive: true,
1390
+ force: true
1391
+ });
1392
+ for (const stray of ["admin.d.ts", "frontend-assets.d.ts"]) fs.rmSync(path.join(targetDirectory, "config", stray), { force: true });
1351
1393
  fs.rmSync(path.join(targetDirectory, "backend", "src", "schema.generated.ts"), { force: true });
1352
1394
  const overlayDir = path.resolve(cliRoot, "templates", "overlays", "baas");
1353
1395
  if (!fs.existsSync(overlayDir)) {
@@ -1394,15 +1436,7 @@ function cleanupPresets(presetsDir) {
1394
1436
  });
1395
1437
  }
1396
1438
  async function replacePlaceholders(options) {
1397
- const filesToProcess = [
1398
- "package.json",
1399
- "frontend/package.json",
1400
- "backend/package.json",
1401
- "config/package.json",
1402
- "frontend/index.html",
1403
- "pnpm-workspace.yaml",
1404
- "README.md"
1405
- ];
1439
+ const filesToProcess = TEMPLATE_PLACEHOLDER_FILES;
1406
1440
  const packageJsonPath = path.resolve(cliRoot, "package.json");
1407
1441
  let cliVersion = "latest";
1408
1442
  if (fs.existsSync(packageJsonPath)) cliVersion = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")).version || "latest";
@@ -1427,9 +1461,10 @@ async function replacePlaceholders(options) {
1427
1461
  versionToUse = stdout.trim();
1428
1462
  } catch {
1429
1463
  try {
1464
+ const tag = cliVersion.includes("canary") ? "canary" : "latest";
1430
1465
  const { stdout } = await execa(viewBin, [
1431
1466
  "view",
1432
- `${pkgName}@${cliVersion.includes("canary") ? "canary" : "latest"}`,
1467
+ `${pkgName}@${tag}`,
1433
1468
  "version"
1434
1469
  ]);
1435
1470
  if (!stdout.trim()) throw new Error("Not found");
@@ -1497,6 +1532,26 @@ async function findAvailablePort(startPort) {
1497
1532
  while (!await isPortAvailable(port)) port++;
1498
1533
  return port;
1499
1534
  }
1535
+ /**
1536
+ * The CLI's own version, which is the runtime image tag a scaffolded project
1537
+ * pins. They move together: the CLI, the packages and the runtime image are cut
1538
+ * from one release, so the version that installed the project is the version
1539
+ * whose runtime can boot its bundle.
1540
+ *
1541
+ * Falls back to `latest` only when the CLI cannot read its own manifest — a
1542
+ * floating tag is worse than a pinned one, but better than a compose file that
1543
+ * names a version that was never published.
1544
+ */
1545
+ function readCliVersion() {
1546
+ try {
1547
+ const manifest = path.resolve(cliRoot, "package.json");
1548
+ if (fs.existsSync(manifest)) {
1549
+ const pkg = JSON.parse(fs.readFileSync(manifest, "utf-8"));
1550
+ if (typeof pkg.version === "string" && pkg.version) return pkg.version;
1551
+ }
1552
+ } catch {}
1553
+ return "latest";
1554
+ }
1500
1555
  async function configureEnvFile(targetDirectory, databaseUrl) {
1501
1556
  const envExamplePath = path.join(targetDirectory, ".env.example");
1502
1557
  const envPath = path.join(targetDirectory, ".env");
@@ -1508,6 +1563,8 @@ async function configureEnvFile(targetDirectory, databaseUrl) {
1508
1563
  let envContent = fs.readFileSync(envPath, "utf-8");
1509
1564
  envContent = envContent.replace(/^JWT_SECRET=.*$/m, `JWT_SECRET=${jwtSecret}`);
1510
1565
  envContent = envContent.replace(/^#\s*REBASE_SERVICE_KEY=.*$/m, `REBASE_SERVICE_KEY=${serviceKey}`);
1566
+ const runtimeVersion = readCliVersion();
1567
+ envContent = /^#?\s*REBASE_VERSION=.*$/m.test(envContent) ? envContent.replace(/^#?\s*REBASE_VERSION=.*$/m, `REBASE_VERSION=${runtimeVersion}`) : `${envContent.trimEnd()}\n\n# The Rebase runtime image tag docker-compose.yml pulls.\n# Change this and restart to upgrade; your project bundle is untouched.\nREBASE_VERSION=${runtimeVersion}\n`;
1511
1568
  if (databaseUrl) {
1512
1569
  if (/[\r\n]/.test(databaseUrl)) throw new Error("Invalid DATABASE_URL: multiline values are not allowed.");
1513
1570
  envContent = envContent.replace(/^DATABASE_URL=.*$/m, `DATABASE_URL=${databaseUrl}\nDATABASE_PASSWORD=${dbPassword}`);
@@ -2014,21 +2071,51 @@ var ManifestError = class extends Error {
2014
2071
  this.name = "ManifestError";
2015
2072
  }
2016
2073
  };
2017
- var APP_TYPES = [
2018
- "backend",
2019
- "static",
2020
- "admin",
2021
- "mobile",
2022
- "custom"
2023
- ];
2074
+ var APP_TYPES = ["backend", "static"];
2075
+ /**
2076
+ * App types that used to exist, and what replaced each one.
2077
+ *
2078
+ * Kept so a manifest written against the old vocabulary fails with the fix in
2079
+ * hand rather than with `must be one of: backend, static`, which tells a reader
2080
+ * what is wrong but not what to write instead.
2081
+ */
2082
+ var REMOVED_APP_TYPES = {
2083
+ admin: "the admin panel is an ordinary static app now — declare it as { \"type\": \"static\", \"root\": \"frontend\", \"output\": \"frontend/dist\", \"path\": \"/admin\" }",
2084
+ custom: "who owns the server is a property of the backend now — declare { \"type\": \"backend\", \"runtime\": \"custom\" } instead of a separate app",
2085
+ mobile: "mobile apps are no longer declared in the manifest — nothing consumed this type. Remove the entry"
2086
+ };
2024
2087
  /** Reserved because they name things in URLs and CLI output. */
2025
- var RESERVED_APP_NAMES = new Set([
2088
+ var RESERVED_APP_NAMES = /* @__PURE__ */ new Set([
2026
2089
  "api",
2027
2090
  "health",
2028
2091
  "metrics",
2029
2092
  "livez",
2030
2093
  "_rebase"
2031
2094
  ]);
2095
+ /**
2096
+ * Validate a static app's public base path.
2097
+ *
2098
+ * Normalizes to "no trailing slash, except for the root" so that mounting and
2099
+ * the `REBASE_APP_BASE` build variable have one shape to reason about.
2100
+ */
2101
+ function checkAppPath(value, fieldPath, issues) {
2102
+ if (value === void 0) return void 0;
2103
+ if (typeof value !== "string" || !value.startsWith("/") || value.includes("..")) {
2104
+ issues.push({
2105
+ path: fieldPath,
2106
+ message: "must be an absolute path like \"/admin\""
2107
+ });
2108
+ return;
2109
+ }
2110
+ if (value !== "/" && value.endsWith("/")) {
2111
+ issues.push({
2112
+ path: fieldPath,
2113
+ message: "must not end with a slash — write \"/admin\", not \"/admin/\""
2114
+ });
2115
+ return;
2116
+ }
2117
+ return value;
2118
+ }
2032
2119
  function isRecord(value) {
2033
2120
  return typeof value === "object" && value !== null && !Array.isArray(value);
2034
2121
  }
@@ -2071,6 +2158,73 @@ function checkRelativePath(value, fieldPath, issues, { required }) {
2071
2158
  }
2072
2159
  return value;
2073
2160
  }
2161
+ /** Fields each app type understands. Anything else is a typo or a newer CLI. */
2162
+ var KNOWN_APP_FIELDS = {
2163
+ backend: [
2164
+ "type",
2165
+ "runtime",
2166
+ "config",
2167
+ "functions",
2168
+ "crons",
2169
+ "schema",
2170
+ "usersCollection",
2171
+ "dockerfile",
2172
+ "context",
2173
+ "port"
2174
+ ],
2175
+ static: [
2176
+ "type",
2177
+ "root",
2178
+ "build",
2179
+ "output",
2180
+ "path",
2181
+ "spa"
2182
+ ]
2183
+ };
2184
+ /**
2185
+ * Report a field this CLI does not recognise.
2186
+ *
2187
+ * A warning rather than an error, and the distinction matters in both
2188
+ * directions. `"pathh": "/admin"` is a typo that would otherwise be silently
2189
+ * dropped — the app builds for `/`, mounts at `/`, and the only symptom is that
2190
+ * it is not where you put it. But an unknown field is also what an *older* CLI
2191
+ * sees when it opens a manifest written for a newer one, and refusing to build
2192
+ * over a field that is simply from the future would make every manifest addition
2193
+ * a breaking change.
2194
+ *
2195
+ * So: name it, suggest the near-miss, and carry on.
2196
+ */
2197
+ function warnUnknownFields(name, raw, type) {
2198
+ const known = KNOWN_APP_FIELDS[type];
2199
+ if (!known) return;
2200
+ for (const field of Object.keys(raw)) {
2201
+ if (known.includes(field)) continue;
2202
+ const suggestion = known.find((candidate) => isNearMiss(candidate, field));
2203
+ console.warn(`⚠ rebase.json: apps.${name}.${field} is not a field this CLI knows.` + (suggestion ? ` Did you mean "${suggestion}"?` : " It is ignored — your CLI may be older than this manifest."));
2204
+ }
2205
+ }
2206
+ /** One edit apart, ignoring case: enough for a typo, tight enough to stay quiet. */
2207
+ function isNearMiss(a, b) {
2208
+ const x = a.toLowerCase();
2209
+ const y = b.toLowerCase();
2210
+ if (x === y) return true;
2211
+ if (Math.abs(x.length - y.length) > 1) return false;
2212
+ const [shorter, longer] = x.length <= y.length ? [x, y] : [y, x];
2213
+ let i = 0;
2214
+ let j = 0;
2215
+ let edits = 0;
2216
+ while (i < shorter.length && j < longer.length) {
2217
+ if (shorter[i] === longer[j]) {
2218
+ i++;
2219
+ j++;
2220
+ continue;
2221
+ }
2222
+ if (++edits > 1) return false;
2223
+ if (shorter.length === longer.length) i++;
2224
+ j++;
2225
+ }
2226
+ return edits + (longer.length - j) + (shorter.length - i) <= 1;
2227
+ }
2074
2228
  function validateApp(name, raw, issues) {
2075
2229
  const base = `apps.${name}`;
2076
2230
  if (!isRecord(raw)) {
@@ -2081,6 +2235,13 @@ function validateApp(name, raw, issues) {
2081
2235
  return;
2082
2236
  }
2083
2237
  const type = raw.type;
2238
+ if (typeof type === "string" && REMOVED_APP_TYPES[type]) {
2239
+ issues.push({
2240
+ path: `${base}.type`,
2241
+ message: `"${type}" is no longer an app type — ${REMOVED_APP_TYPES[type]}`
2242
+ });
2243
+ return;
2244
+ }
2084
2245
  if (typeof type !== "string" || !APP_TYPES.includes(type)) {
2085
2246
  issues.push({
2086
2247
  path: `${base}.type`,
@@ -2088,18 +2249,39 @@ function validateApp(name, raw, issues) {
2088
2249
  });
2089
2250
  return;
2090
2251
  }
2252
+ warnUnknownFields(name, raw, type);
2091
2253
  switch (type) {
2092
- case "backend":
2254
+ case "backend": {
2093
2255
  checkRelativePath(raw.config, `${base}.config`, issues, { required: false });
2094
2256
  checkRelativePath(raw.functions, `${base}.functions`, issues, { required: false });
2095
2257
  checkRelativePath(raw.crons, `${base}.crons`, issues, { required: false });
2096
2258
  checkRelativePath(raw.schema, `${base}.schema`, issues, { required: false });
2097
2259
  checkRelativePath(raw.usersCollection, `${base}.usersCollection`, issues, { required: false });
2098
- if (raw.mode !== void 0 && raw.mode !== "cms" && raw.mode !== "baas") issues.push({
2260
+ if (raw.mode !== void 0) issues.push({
2099
2261
  path: `${base}.mode`,
2100
- message: "must be \"cms\" or \"baas\""
2262
+ message: "is no longer a field — collections come from the config directory when it exists, and are introspected from the database when it does not"
2263
+ });
2264
+ const custom = raw.runtime === "custom";
2265
+ if (raw.runtime !== "managed" && !custom) issues.push({
2266
+ path: `${base}.runtime`,
2267
+ message: "is required, and must be \"managed\" or \"custom\""
2268
+ });
2269
+ for (const field of [
2270
+ "dockerfile",
2271
+ "context",
2272
+ "port"
2273
+ ]) if (raw[field] !== void 0 && !custom) issues.push({
2274
+ path: `${base}.${field}`,
2275
+ message: "only applies to a custom runtime — set \"runtime\": \"custom\" to build your own image"
2276
+ });
2277
+ checkRelativePath(raw.dockerfile, `${base}.dockerfile`, issues, { required: false });
2278
+ checkRelativePath(raw.context, `${base}.context`, issues, { required: false });
2279
+ if (raw.port !== void 0 && (typeof raw.port !== "number" || !Number.isInteger(raw.port))) issues.push({
2280
+ path: `${base}.port`,
2281
+ message: "must be an integer"
2101
2282
  });
2102
2283
  return raw;
2284
+ }
2103
2285
  case "static":
2104
2286
  checkRelativePath(raw.root, `${base}.root`, issues, { required: true });
2105
2287
  checkRelativePath(raw.output, `${base}.output`, issues, { required: true });
@@ -2111,37 +2293,7 @@ function validateApp(name, raw, issues) {
2111
2293
  path: `${base}.spa`,
2112
2294
  message: "must be a boolean"
2113
2295
  });
2114
- return raw;
2115
- case "admin": {
2116
- const mode = raw.mode ?? "hosted";
2117
- if (mode !== "hosted" && mode !== "bundled") {
2118
- issues.push({
2119
- path: `${base}.mode`,
2120
- message: "must be \"hosted\" or \"bundled\""
2121
- });
2122
- return;
2123
- }
2124
- if (mode === "bundled") {
2125
- checkRelativePath(raw.root, `${base}.root`, issues, { required: true });
2126
- checkRelativePath(raw.output, `${base}.output`, issues, { required: true });
2127
- }
2128
- return raw;
2129
- }
2130
- case "mobile": {
2131
- const platform = raw.platform;
2132
- if (platform !== "ios" && platform !== "android" && platform !== "other") issues.push({
2133
- path: `${base}.platform`,
2134
- message: "must be \"ios\", \"android\" or \"other\""
2135
- });
2136
- return raw;
2137
- }
2138
- case "custom":
2139
- checkRelativePath(raw.dockerfile, `${base}.dockerfile`, issues, { required: false });
2140
- checkRelativePath(raw.context, `${base}.context`, issues, { required: false });
2141
- if (raw.port !== void 0 && (typeof raw.port !== "number" || !Number.isInteger(raw.port))) issues.push({
2142
- path: `${base}.port`,
2143
- message: "must be an integer"
2144
- });
2296
+ checkAppPath(raw.path, `${base}.path`, issues);
2145
2297
  return raw;
2146
2298
  default: return;
2147
2299
  }
@@ -2155,10 +2307,13 @@ function validateManifest(raw) {
2155
2307
  path: "",
2156
2308
  message: `${MANIFEST_FILENAME} must contain a JSON object`
2157
2309
  }] };
2158
- if (typeof raw.runtime !== "string" || raw.runtime.trim() === "") issues.push({
2159
- path: "runtime",
2160
- message: `is required, e.g. "^1"`
2161
- });
2310
+ if (typeof raw.rebase !== "string" || raw.rebase.trim() === "") {
2311
+ const message = typeof raw.runtime === "string" ? `is required, e.g. "^1" — this is the top-level "runtime" key renamed, because "runtime" now means "managed" or "custom" on the backend app` : `is required, e.g. "^1"`;
2312
+ issues.push({
2313
+ path: "rebase",
2314
+ message
2315
+ });
2316
+ }
2162
2317
  if (!isRecord(raw.apps)) {
2163
2318
  issues.push({
2164
2319
  path: "apps",
@@ -2192,55 +2347,148 @@ function validateManifest(raw) {
2192
2347
  path: "apps",
2193
2348
  message: "a project may declare at most one backend app"
2194
2349
  });
2350
+ const byPath = /* @__PURE__ */ new Map();
2351
+ for (const [name, app] of Object.entries(apps)) {
2352
+ if (app.type !== "static") continue;
2353
+ const at = app.path ?? "/";
2354
+ const owner = byPath.get(at);
2355
+ if (owner) {
2356
+ issues.push({
2357
+ path: `apps.${name}.path`,
2358
+ message: `two apps cannot serve the same path — "${owner}" is already at "${at}"`
2359
+ });
2360
+ continue;
2361
+ }
2362
+ byPath.set(at, name);
2363
+ }
2364
+ const storage = validateStorageSources(raw.storage, issues);
2195
2365
  if (issues.length > 0) return { issues };
2196
2366
  return {
2197
2367
  manifest: {
2198
2368
  $schema: typeof raw.$schema === "string" ? raw.$schema : void 0,
2199
- runtime: raw.runtime,
2200
- apps
2369
+ rebase: raw.rebase,
2370
+ apps,
2371
+ ...storage ? { storage } : {}
2201
2372
  },
2202
2373
  issues
2203
2374
  };
2204
2375
  }
2205
2376
  /**
2377
+ * Validate the `storage` block — which buckets this project uses.
2378
+ *
2379
+ * Absent means one default source, so `undefined` is a valid answer and not an
2380
+ * issue. Everything else is checked strictly, because each key here becomes the
2381
+ * suffix of a set of environment variables: a key that cannot become a variable
2382
+ * name, or two keys that become the *same* one, are failures worth catching
2383
+ * while someone is looking at the file rather than at a tenant serving one
2384
+ * bucket's files with another's credentials.
2385
+ */
2386
+ function validateStorageSources(raw, issues) {
2387
+ if (raw === void 0) return void 0;
2388
+ if (!isRecord(raw)) {
2389
+ issues.push({
2390
+ path: "storage",
2391
+ message: "must be an object keyed by storage source name"
2392
+ });
2393
+ return;
2394
+ }
2395
+ const sources = {};
2396
+ for (const [key, value] of Object.entries(raw)) {
2397
+ if (!isRecord(value)) {
2398
+ issues.push({
2399
+ path: `storage.${key}`,
2400
+ message: "must be an object"
2401
+ });
2402
+ continue;
2403
+ }
2404
+ if (typeof value.engine !== "string" || value.engine.trim() === "") {
2405
+ issues.push({
2406
+ path: `storage.${key}.engine`,
2407
+ message: "is required, e.g. \"s3\", \"gcs\" or \"local\""
2408
+ });
2409
+ continue;
2410
+ }
2411
+ if (value.transport !== void 0 && value.transport !== "server" && value.transport !== "direct") {
2412
+ issues.push({
2413
+ path: `storage.${key}.transport`,
2414
+ message: "must be \"server\" or \"direct\""
2415
+ });
2416
+ continue;
2417
+ }
2418
+ if (value.label !== void 0 && typeof value.label !== "string") {
2419
+ issues.push({
2420
+ path: `storage.${key}.label`,
2421
+ message: "must be a string"
2422
+ });
2423
+ continue;
2424
+ }
2425
+ try {
2426
+ storageEnvSuffix(key);
2427
+ } catch {
2428
+ issues.push({
2429
+ path: `storage.${key}`,
2430
+ message: "name cannot become an environment variable suffix — use a name containing at least one letter or digit"
2431
+ });
2432
+ continue;
2433
+ }
2434
+ sources[key] = {
2435
+ engine: value.engine,
2436
+ ...value.transport !== void 0 ? { transport: value.transport } : {},
2437
+ ...value.label !== void 0 ? { label: value.label } : {}
2438
+ };
2439
+ }
2440
+ const collision = findStorageSuffixCollision(Object.keys(sources));
2441
+ if (collision) issues.push({
2442
+ path: `storage.${collision.b}`,
2443
+ message: `maps to the same environment variable suffix ("${collision.suffix || "(none)"}") as "${collision.a}", so the two would read each other's configuration — rename one of them`
2444
+ });
2445
+ return Object.keys(sources).length > 0 ? sources : void 0;
2446
+ }
2447
+ /**
2206
2448
  * Infer a manifest from a directory that does not have one.
2207
2449
  *
2208
2450
  * This mirrors exactly what the template scaffolds, which is what makes adopting
2209
2451
  * the manifest a no-op for existing projects: the synthesized result is what
2210
2452
  * they would have written by hand.
2211
2453
  *
2212
- * An ejected backend — one with its own `src/index.ts` entrypoint — is reported
2213
- * as a `custom` app rather than a `backend` app. That is not a downgrade; it is
2214
- * an accurate description, and it is what keeps such a project deploying exactly
2215
- * as it does today.
2454
+ * The backend's `runtime` is inferred from whether the repository declares a
2455
+ * **Dockerfile** — the thing that actually builds an image — and from nothing
2456
+ * else. It used to be inferred from the presence of `backend/src/index.ts`,
2457
+ * which every scaffolded project had whether or not it wanted its own server, so
2458
+ * projects predating the manifest silently landed on the custom runtime and paid
2459
+ * for it (see `docs/cloud-deploy-workspace-vendoring.md`).
2216
2460
  */
2217
2461
  function synthesizeManifest(projectRoot) {
2218
2462
  const exists = (relative) => fs.existsSync(path.join(projectRoot, relative));
2219
2463
  const apps = {};
2220
2464
  const hasConfig = exists(DEFAULT_CONFIG_DIR);
2221
2465
  const hasBackend = exists("backend");
2222
- const backendEntry = exists("backend/src/index.ts");
2223
- if (hasBackend && backendEntry) apps.backend = {
2224
- type: "custom",
2225
- dockerfile: exists("backend/Dockerfile") ? "backend/Dockerfile" : void 0,
2226
- context: "."
2227
- };
2228
- else if (hasBackend || hasConfig) {
2229
- const backend = { type: "backend" };
2230
- if (!hasConfig) backend.mode = "baas";
2466
+ const dockerfile = ["Dockerfile", "backend/Dockerfile"].find(exists);
2467
+ if (hasBackend || hasConfig) {
2468
+ const backend = dockerfile ? {
2469
+ type: "backend",
2470
+ runtime: "custom",
2471
+ dockerfile,
2472
+ context: "."
2473
+ } : {
2474
+ type: "backend",
2475
+ runtime: "managed"
2476
+ };
2231
2477
  if (exists("backend/functions")) backend.functions = DEFAULT_FUNCTIONS_DIR;
2232
2478
  if (exists("backend/crons")) backend.crons = DEFAULT_CRONS_DIR;
2233
2479
  apps.backend = backend;
2480
+ if (!dockerfile && exists("backend/src/index.ts")) console.warn("⚠ backend/src/index.ts exists but this project's backend is managed — it is\n never loaded. Delete it, or run `rebase eject` to make it the entrypoint.");
2234
2481
  }
2235
2482
  if (exists("frontend")) apps.web = {
2236
2483
  type: "static",
2237
2484
  root: "frontend",
2238
2485
  build: "npm run build --workspace frontend",
2239
2486
  output: "frontend/dist",
2487
+ path: "/",
2240
2488
  spa: true
2241
2489
  };
2242
2490
  return {
2243
- runtime: "^1",
2491
+ rebase: "^1",
2244
2492
  apps
2245
2493
  };
2246
2494
  }
@@ -2282,7 +2530,7 @@ function writeManifest(projectRoot, manifest) {
2282
2530
  const filePath = manifestPath(projectRoot);
2283
2531
  const ordered = {
2284
2532
  $schema: manifest.$schema ?? "https://rebase.pro/schemas/rebase.json",
2285
- runtime: manifest.runtime,
2533
+ rebase: manifest.rebase,
2286
2534
  apps: manifest.apps
2287
2535
  };
2288
2536
  fs.writeFileSync(filePath, `${JSON.stringify(ordered, null, 4)}\n`, "utf8");
@@ -2301,13 +2549,8 @@ function buildableApps(manifest) {
2301
2549
  name,
2302
2550
  app
2303
2551
  }));
2304
- const rank = (app) => {
2305
- if (app.type === "backend") return 0;
2306
- if (app.type === "admin") return 1;
2307
- if (app.type === "static") return 2;
2308
- return 3;
2309
- };
2310
- return entries.filter(({ app }) => app.type !== "mobile").sort((a, b) => rank(a.app) - rank(b.app));
2552
+ const rank = (app) => app.type === "backend" ? 0 : 1;
2553
+ return entries.sort((a, b) => rank(a.app) - rank(b.app));
2311
2554
  }
2312
2555
  /**
2313
2556
  * Decide whether a project can run on the managed runtime, and say why not.
@@ -2317,28 +2560,45 @@ function buildableApps(manifest) {
2317
2560
  * verdict.
2318
2561
  */
2319
2562
  function assessManagedCompatibility(manifest) {
2320
- const reasons = [];
2321
2563
  const backend = findBackendApp(manifest);
2322
- if (!backend) {
2323
- const custom = Object.entries(manifest.apps).find(([, app]) => app.type === "custom");
2324
- if (custom) reasons.push(`App "${custom[0]}" is a custom container. The managed runtime runs the platform image with your bundle, so a project that builds its own image uses the custom runtime instead.`);
2325
- else reasons.push("No backend app is declared in this repository. Only the repository that declares the backend selects the runtime.");
2326
- }
2327
- for (const [name, app] of Object.entries(manifest.apps)) if (app.type === "custom") reasons.push(`App "${name}" is a custom container image.`);
2564
+ if (!backend) return {
2565
+ eligible: false,
2566
+ reasons: ["No backend app is declared in this repository. Only the repository that declares the backend selects the runtime."]
2567
+ };
2568
+ if (backend.app.runtime === "custom") return {
2569
+ eligible: false,
2570
+ reasons: [`App "${backend.name}" declares runtime: "custom", so it builds and runs its own image. The managed runtime boots the platform image with your bundle; the custom runtime deploys exactly the same way, from your Dockerfile.`]
2571
+ };
2328
2572
  return {
2329
- eligible: reasons.length === 0 && Boolean(backend),
2330
- reasons
2573
+ eligible: true,
2574
+ reasons: []
2331
2575
  };
2332
2576
  }
2333
- /** Resolve a backend app's directories against the conventions it omits. */
2334
- function resolveBackendPaths(app) {
2577
+ /**
2578
+ * Resolve a backend app's directories against the conventions it omits.
2579
+ *
2580
+ * `hasCollections` replaces the old `mode: "cms" | "baas"` field. Where the
2581
+ * collections come from was never an independent choice: either they are
2582
+ * declared in code and the bundle ships them, or they are not and the runtime
2583
+ * introspects the live database at boot. Declaring it separately only created
2584
+ * the contradictory state — code-first declared, no collections anywhere.
2585
+ *
2586
+ * `hasConfig` is deliberately a **separate** question. A headless project has no
2587
+ * `config/collections`, but it may still ship a config package — that is where
2588
+ * the `storageAuthorize` hook lives, and storage is not under row-level
2589
+ * security, so without one the server refuses to boot with storage enabled.
2590
+ * Collapsing the two would leave a headless project nowhere to put it.
2591
+ */
2592
+ function resolveBackendPaths(app, projectRoot) {
2593
+ const config = app.config ?? "config";
2335
2594
  return {
2336
- config: app.config ?? "config",
2595
+ config,
2337
2596
  functions: app.functions ?? "backend/functions",
2338
2597
  crons: app.crons ?? "backend/crons",
2339
2598
  schema: app.schema ?? "backend/src/schema.generated.ts",
2340
2599
  usersCollection: app.usersCollection ?? "collections/users",
2341
- mode: app.mode ?? "cms"
2600
+ hasConfig: fs.existsSync(path.join(projectRoot, config)),
2601
+ hasCollections: fs.existsSync(path.join(projectRoot, config, "collections"))
2342
2602
  };
2343
2603
  }
2344
2604
  //#endregion
@@ -2401,22 +2661,19 @@ function devRuntimeEnv(projectRoot) {
2401
2661
  REBASE_DEV_CONFIG: "config",
2402
2662
  REBASE_DEV_FUNCTIONS: "backend/functions",
2403
2663
  REBASE_DEV_CRONS: "backend/crons",
2404
- REBASE_DEV_SCHEMA: "backend/src/schema.generated.ts",
2405
- REBASE_DEV_MODE: "cms"
2664
+ REBASE_DEV_SCHEMA: "backend/src/schema.generated.ts"
2406
2665
  };
2407
2666
  try {
2408
2667
  const backend = findBackendApp(loadManifest(projectRoot).manifest);
2409
2668
  if (backend) {
2410
- const paths = resolveBackendPaths(backend.app);
2669
+ const paths = resolveBackendPaths(backend.app, projectRoot);
2411
2670
  result.REBASE_DEV_CONFIG = paths.config;
2412
2671
  result.REBASE_DEV_FUNCTIONS = paths.functions;
2413
2672
  result.REBASE_DEV_CRONS = paths.crons;
2414
2673
  result.REBASE_DEV_SCHEMA = paths.schema;
2415
- result.REBASE_DEV_MODE = paths.mode;
2416
2674
  result.REBASE_DEV_APP = backend.name;
2417
2675
  }
2418
2676
  } catch {}
2419
- if (!fs.existsSync(path.join(projectRoot, result.REBASE_DEV_CONFIG))) result.REBASE_DEV_MODE = "baas";
2420
2677
  return result;
2421
2678
  }
2422
2679
  /** Well-known filename the backend writes its actual port to. */
@@ -2825,7 +3082,7 @@ ${chalk.green.bold("Description")}
2825
3082
  */
2826
3083
  var DEFAULT_BUNDLE_DIR = "dist-bundle";
2827
3084
  /** Packages whose presence means the bundle cannot run on a stock runtime image. */
2828
- var KNOWN_NATIVE_PACKAGES = new Set([
3085
+ var KNOWN_NATIVE_PACKAGES = /* @__PURE__ */ new Set([
2829
3086
  "sharp",
2830
3087
  "canvas",
2831
3088
  "bcrypt",
@@ -2841,7 +3098,7 @@ var KNOWN_NATIVE_PACKAGES = new Set([
2841
3098
  "pg-native"
2842
3099
  ]);
2843
3100
  /** Dependencies supplied by the runtime image itself, not by the bundle. */
2844
- var RUNTIME_PROVIDED = new Set([
3101
+ var RUNTIME_PROVIDED = /* @__PURE__ */ new Set([
2845
3102
  "@rebasepro/server",
2846
3103
  "@rebasepro/types",
2847
3104
  "@rebasepro/client",
@@ -3024,16 +3281,27 @@ async function writeBundleTsconfig(projectRoot, outDir, includes, skipTypeCheck)
3024
3281
  * says exactly how to proceed, while a false positive would hand back the crash
3025
3282
  * loop this exists to prevent.
3026
3283
  */
3027
- function detectStorageAuthorize(compiledConfigDir) {
3284
+ function detectStorageAuthorize(compiledConfigDir, depth = 0) {
3028
3285
  const indexPath = [
3029
3286
  ".js",
3030
3287
  ".mjs",
3031
3288
  ".ts"
3032
3289
  ].map((ext) => path.join(compiledConfigDir, `index${ext}`)).find((candidate) => fs.existsSync(candidate));
3033
3290
  if (!indexPath) return false;
3291
+ return moduleExportsStorageAuthorize(indexPath, depth);
3292
+ }
3293
+ /**
3294
+ * Whether one compiled module re-exports or defines `storageAuthorize`.
3295
+ *
3296
+ * Split out from {@link detectStorageAuthorize} so a wildcard re-export can be
3297
+ * followed. `export * from "./storage.js"` is an ordinary way to write a config
3298
+ * barrel, and treating it as "no hook" rejected deploys that were correct — with
3299
+ * a message telling the developer to add a hook they had already written.
3300
+ */
3301
+ function moduleExportsStorageAuthorize(modulePath, depth) {
3034
3302
  let source;
3035
3303
  try {
3036
- source = fs.readFileSync(indexPath, "utf8");
3304
+ source = fs.readFileSync(modulePath, "utf8");
3037
3305
  } catch {
3038
3306
  return false;
3039
3307
  }
@@ -3042,9 +3310,48 @@ function detectStorageAuthorize(compiledConfigDir) {
3042
3310
  const parts = entry.split(/\bas\b/);
3043
3311
  return parts[parts.length - 1].trim();
3044
3312
  }).includes("storageAuthorize")) return true;
3313
+ if (depth < 3) for (const clause of source.matchAll(/\bexport\s*\*\s*from\s*["']([^"']+)["']/g)) {
3314
+ const specifier = clause[1];
3315
+ if (!specifier.startsWith(".")) continue;
3316
+ const resolved = resolveRelativeModule(path.dirname(modulePath), specifier);
3317
+ if (resolved && moduleExportsStorageAuthorize(resolved, depth + 1)) return true;
3318
+ }
3045
3319
  return false;
3046
3320
  }
3047
3321
  /**
3322
+ * Resolve a relative ESM specifier to a file on disk.
3323
+ *
3324
+ * Compiled output carries explicit `.js` extensions, but the same function reads
3325
+ * TypeScript sources during a source boot, where the specifier may be
3326
+ * extensionless or point at a directory index.
3327
+ */
3328
+ function resolveRelativeModule(fromDir, specifier) {
3329
+ const base = path.resolve(fromDir, specifier);
3330
+ const candidates = [
3331
+ base,
3332
+ `${base}.js`,
3333
+ `${base}.mjs`,
3334
+ `${base}.ts`,
3335
+ path.join(base, "index.js"),
3336
+ path.join(base, "index.mjs"),
3337
+ path.join(base, "index.ts")
3338
+ ];
3339
+ for (const candidate of candidates) try {
3340
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) return candidate;
3341
+ } catch {
3342
+ continue;
3343
+ }
3344
+ if (/\.js$/.test(base)) {
3345
+ const asTs = base.replace(/\.js$/, ".ts");
3346
+ try {
3347
+ if (fs.existsSync(asTs) && fs.statSync(asTs).isFile()) return asTs;
3348
+ } catch {
3349
+ return null;
3350
+ }
3351
+ }
3352
+ return null;
3353
+ }
3354
+ /**
3048
3355
  * Detect native code in the dependency closure.
3049
3356
  *
3050
3357
  * Walks declared runtime dependencies breadth-first through `node_modules`,
@@ -3328,11 +3635,10 @@ async function regenerateSchema(projectRoot, configDir, options) {
3328
3635
  * deployed green, and answered 404 on every one of them, with the file still
3329
3636
  * sitting in the repository looking exactly like the server.
3330
3637
  *
3331
- * A project that means to keep its own entrypoint declares the app as
3332
- * `"type": "custom"`, which builds the repository's Dockerfile instead — which
3333
- * is what {@link synthesizeManifest} already infers for a manifest-less repo
3334
- * carrying one. The warning names that route rather than implying the file is
3335
- * a mistake.
3638
+ * A project that means to keep its own entrypoint runs `rebase eject`, which
3639
+ * writes the entrypoint, a Dockerfile and a compose file together and flips the
3640
+ * backend to `runtime: "custom"`. The warning names that route rather than
3641
+ * implying the file is a mistake.
3336
3642
  */
3337
3643
  function findUnusedServerEntry(projectRoot, functionsDir) {
3338
3644
  const found = [path.join("backend", "src", "index.ts"), path.join(path.dirname(functionsDir), "src", "index.ts")].find((candidate) => fs.existsSync(path.join(projectRoot, candidate)));
@@ -3343,22 +3649,22 @@ function findUnusedServerEntry(projectRoot, functionsDir) {
3343
3649
  */
3344
3650
  async function buildBundle(options) {
3345
3651
  const { projectRoot, app, appName } = options;
3346
- const paths = resolveBackendPaths(app);
3652
+ const paths = resolveBackendPaths(app, projectRoot);
3347
3653
  const outDir = path.resolve(projectRoot, options.outDir ?? "dist-bundle");
3348
3654
  const includes = [];
3349
3655
  const addIfExists = (relative, pattern) => {
3350
3656
  if (fs.existsSync(path.join(projectRoot, relative))) includes.push(pattern);
3351
3657
  };
3352
- if (paths.mode === "cms") addIfExists(paths.config, `${paths.config}/**/*.ts`);
3658
+ if (paths.hasConfig) addIfExists(paths.config, `${paths.config}/**/*.ts`);
3353
3659
  addIfExists(paths.functions, `${paths.functions}/**/*.ts`);
3354
3660
  addIfExists(paths.crons, `${paths.crons}/**/*.ts`);
3355
3661
  if (fs.existsSync(path.join(projectRoot, paths.schema))) includes.push(paths.schema);
3356
3662
  if (includes.length === 0) throw new Error(`Nothing to build for app "${appName}". Expected a config directory at "${paths.config}" or functions at "${paths.functions}".`);
3357
- if (paths.mode === "cms" && options.skipSchema !== true) await regenerateSchema(projectRoot, paths.config, options);
3663
+ if (paths.hasCollections && options.skipSchema !== true) await regenerateSchema(projectRoot, paths.config, options);
3358
3664
  const unusedEntry = findUnusedServerEntry(projectRoot, paths.functions);
3359
3665
  if (unusedEntry) {
3360
3666
  const parts = [
3361
- ...paths.mode === "cms" ? [`${paths.config}/`] : [],
3667
+ ...paths.hasCollections ? [`${paths.config}/`] : [],
3362
3668
  `${paths.functions}/`,
3363
3669
  "the schema"
3364
3670
  ];
@@ -3366,7 +3672,7 @@ async function buildBundle(options) {
3366
3672
  console.log(chalk.yellow(` ⚠ ${unusedEntry} is not the bundle's entry point — it is not compiled or shipped.`));
3367
3673
  console.log(chalk.dim(` The runtime boots the bundle itself and mounts ${compiled}.`));
3368
3674
  console.log(chalk.dim(` Routes defined there will not exist once deployed: move them to ${paths.functions}/,`));
3369
- console.log(chalk.dim(` or declare this app as "type": "custom" in rebase.json to keep your own entrypoint.`));
3675
+ console.log(chalk.dim(` or run \`rebase eject\` to make this file the entrypoint and own the image.`));
3370
3676
  }
3371
3677
  log(options, chalk.dim(` compiling ${includes.length} source group(s) → ${path.relative(projectRoot, outDir)}/`));
3372
3678
  cleanOutDir(projectRoot, outDir);
@@ -3391,14 +3697,17 @@ async function buildBundle(options) {
3391
3697
  const compiledConfigDir = path.join(outDir, paths.config);
3392
3698
  const compiledCollectionsDir = path.join(compiledConfigDir, "collections");
3393
3699
  let collections = [];
3394
- if (paths.mode === "cms") {
3700
+ if (paths.hasCollections) {
3395
3701
  collections = await loadSourceCollections(path.join(projectRoot, paths.config, "collections"));
3396
- if (collections.length === 0) throw new Error(`No collections were found in ${path.join(paths.config, "collections")}. A cms-mode project must define at least one collection.`);
3702
+ if (collections.length === 0) throw new Error(`No collections were found in ${path.join(paths.config, "collections")}. Define at least one collection there, or remove the directory to have the runtime introspect collections from the live database instead.`);
3397
3703
  if (!fs.existsSync(compiledCollectionsDir)) throw new Error(`Compilation produced no collections directory at ${path.relative(projectRoot, compiledCollectionsDir)}.`);
3398
3704
  }
3399
3705
  const declared = collectDeclaredDependencies(projectRoot);
3400
3706
  const nativeModules = detectNativeDependencies(projectRoot, declared);
3401
3707
  const declaresStorageAuthorize = detectStorageAuthorize(path.join(outDir, paths.config));
3708
+ const storageSources = normalizeStorageSources(options.storage, void 0);
3709
+ const collision = findStorageSuffixCollision(storageSources.map((s) => s.key));
3710
+ if (collision) throw new Error(`Storage sources "${collision.a}" and "${collision.b}" in rebase.json both map to the environment variable suffix "${collision.suffix || "(none)"}", so they would read each other's configuration. Rename one of them.`);
3402
3711
  const schemaOut = paths.schema.replace(/\.ts$/, ".js");
3403
3712
  const relative = (target) => fs.existsSync(path.join(outDir, target)) ? target : void 0;
3404
3713
  const manifest = {
@@ -3408,23 +3717,26 @@ async function buildBundle(options) {
3408
3717
  builtAgainst: resolveServerVersion(projectRoot),
3409
3718
  contract: RUNTIME_CONTRACT_VERSION
3410
3719
  },
3411
- schemaVersion: paths.mode === "baas" ? "" : computeSchemaVersion(collections),
3720
+ schemaVersion: paths.hasCollections ? computeSchemaVersion(collections) : "",
3412
3721
  app: appName,
3413
- mode: paths.mode,
3722
+ kind: "backend",
3414
3723
  entry: {
3415
- config: paths.mode === "cms" ? relative(paths.config) : void 0,
3416
- collections: paths.mode === "cms" ? relative(path.join(paths.config, "collections")) : void 0,
3724
+ config: paths.hasConfig ? relative(paths.config) : void 0,
3725
+ collections: paths.hasCollections ? relative(path.join(paths.config, "collections")) : void 0,
3417
3726
  functions: relative(paths.functions),
3418
3727
  crons: relative(paths.crons),
3419
3728
  schema: relative(schemaOut),
3420
- usersCollection: paths.mode === "cms" ? relative(path.join(paths.config, `${paths.usersCollection}.js`)) : void 0
3729
+ usersCollection: paths.hasCollections ? relative(path.join(paths.config, `${paths.usersCollection}.js`)) : void 0
3421
3730
  },
3422
3731
  collections: collections.map((collection) => collection.slug).filter((slug) => Boolean(slug)).sort(),
3423
3732
  hooks: {
3424
3733
  native: nativeModules.length > 0,
3425
3734
  nativeModules: nativeModules.length > 0 ? nativeModules : void 0
3426
3735
  },
3427
- storage: { authorize: declaresStorageAuthorize },
3736
+ storage: {
3737
+ authorize: declaresStorageAuthorize,
3738
+ ...storageSources.length > 0 ? { sources: storageSources } : {}
3739
+ },
3428
3740
  deps: { declared },
3429
3741
  build: {
3430
3742
  cli: resolveCliVersion(),
@@ -3487,11 +3799,12 @@ async function buildBundle(options) {
3487
3799
  * in one image already, that is exactly what it had.
3488
3800
  */
3489
3801
  function foldStaticIntoBundle(options) {
3490
- const { bundleDir, assetsDir } = options;
3802
+ const { bundleDir, assetsDir, appName, path: basePath, spa } = options;
3491
3803
  const manifestPath = path.join(bundleDir, "manifest.json");
3492
3804
  if (!fs.existsSync(manifestPath)) throw new Error(`No manifest at ${manifestPath} — build the backend bundle first.`);
3493
3805
  if (!fs.existsSync(assetsDir)) throw new Error(`No built assets at ${assetsDir}.`);
3494
- const staticOut = path.join(bundleDir, "static");
3806
+ const dir = path.posix.join("static", appName);
3807
+ const staticOut = path.join(bundleDir, "static", appName);
3495
3808
  fs.rmSync(staticOut, {
3496
3809
  recursive: true,
3497
3810
  force: true
@@ -3499,21 +3812,30 @@ function foldStaticIntoBundle(options) {
3499
3812
  fs.mkdirSync(staticOut, { recursive: true });
3500
3813
  fs.cpSync(assetsDir, staticOut, { recursive: true });
3501
3814
  let fileCount = 0;
3502
- const count = (dir) => {
3503
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) if (entry.isDirectory()) count(path.join(dir, entry.name));
3815
+ const count = (target) => {
3816
+ for (const entry of fs.readdirSync(target, { withFileTypes: true })) if (entry.isDirectory()) count(path.join(target, entry.name));
3504
3817
  else fileCount++;
3505
3818
  };
3506
3819
  count(staticOut);
3507
3820
  const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
3821
+ const existing = (manifest.entry?.static ?? []).filter((entry) => entry.dir !== dir);
3508
3822
  manifest.entry = {
3509
3823
  ...manifest.entry,
3510
- static: "static"
3824
+ static: [...existing, {
3825
+ path: basePath,
3826
+ dir,
3827
+ spa
3828
+ }]
3511
3829
  };
3512
3830
  fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
3513
- return { fileCount };
3831
+ return {
3832
+ fileCount,
3833
+ dir
3834
+ };
3514
3835
  }
3515
3836
  function buildStaticBundle(options) {
3516
3837
  const { projectRoot, appName, assetsDir, outDir, runtimeRange } = options;
3838
+ const basePath = options.path ?? "/";
3517
3839
  cleanOutDir(projectRoot, outDir);
3518
3840
  const staticOut = path.join(outDir, "static");
3519
3841
  fs.mkdirSync(staticOut, { recursive: true });
@@ -3533,8 +3855,12 @@ function buildStaticBundle(options) {
3533
3855
  },
3534
3856
  schemaVersion: "",
3535
3857
  app: appName,
3536
- mode: "static",
3537
- entry: { static: "static" },
3858
+ kind: "static",
3859
+ entry: { static: [{
3860
+ path: basePath,
3861
+ dir: "static",
3862
+ spa: options.spa ?? true
3863
+ }] },
3538
3864
  hooks: { native: false },
3539
3865
  deps: { declared: {} },
3540
3866
  build: {
@@ -3636,7 +3962,7 @@ function resolveCliVersion() {
3636
3962
  //#endregion
3637
3963
  //#region src/fold-static.ts
3638
3964
  /**
3639
- * Folding a project's frontend into its backend bundle.
3965
+ * Folding a project's static apps into its backend bundle.
3640
3966
  *
3641
3967
  * Shared by `rebase build` and `rebase cloud deploy` deliberately. It lived in
3642
3968
  * the build *command* first, and `deploy` rebuilds the bundle itself — so a
@@ -3645,34 +3971,77 @@ function resolveCliVersion() {
3645
3971
  * folding had never been written. Two callers building the same artefact must
3646
3972
  * share the step that completes it.
3647
3973
  *
3648
- * Why fold at all: `bootFromBundle` already serves a SPA from `entry.static`
3974
+ * Why fold at all: `bootFromBundle` serves static apps from `entry.static`
3649
3975
  * behind `REBASE_SERVE_STATIC` (default on). A managed tenant runs one pod, so
3650
- * putting the built site in the bundle gives it the shape a custom container
3651
- * already had — site at `/`, API at `/api` — which is the only honest baseline
3652
- * for calling the managed runtime a drop-in replacement.
3976
+ * putting the built assets in the bundle gives it the shape a custom container
3977
+ * already had — site at `/`, admin at `/admin`, API at `/api` — which is the
3978
+ * only honest baseline for calling the managed runtime a drop-in replacement.
3979
+ *
3980
+ * **Every** static app is folded, each at its declared path. Folding used to
3981
+ * pick exactly one and refuse when it found two, which meant a project with a
3982
+ * site and an admin panel deployed with neither.
3653
3983
  */
3654
3984
  /**
3655
- * Which static app, if any, should be served by the backend.
3985
+ * Every static app in the manifest, in mount order.
3656
3986
  *
3657
- * Exactly one `static` app is folded. With several, folding would have to choose,
3658
- * and silently picking one of two websites is worse than doing nothing — so it
3659
- * declines and names what it saw. Pure, so the decision is testable without a
3660
- * filesystem.
3987
+ * Longest path first, so the `/`-rooted app is registered last — its catch-all
3988
+ * would otherwise claim its siblings' URLs. Pure, so the ordering is testable
3989
+ * without a filesystem.
3661
3990
  */
3662
- function selectFoldableApp(manifest) {
3663
- const statics = Object.entries(manifest.apps ?? {}).filter(([, app]) => app?.type === "static").map(([name, app]) => ({
3664
- name,
3665
- build: app?.build,
3666
- output: app?.output
3667
- }));
3668
- if (statics.length === 0) return {};
3669
- if (statics.length > 1) return { reason: `${statics.length} static apps (${statics.map((s) => s.name).join(", ")}) — none folded in. Pick one to serve from the backend, or host them separately.` };
3670
- const only = statics[0];
3671
- if (!only.output) return { reason: `"${only.name}" declares no output directory — not folded in.` };
3672
- return { app: only };
3991
+ function foldableApps(manifest) {
3992
+ const apps = [];
3993
+ const skipped = [];
3994
+ for (const [name, app] of Object.entries(manifest.apps ?? {})) {
3995
+ if (app?.type !== "static") continue;
3996
+ if (!app.output) {
3997
+ skipped.push({
3998
+ name,
3999
+ reason: `"${name}" declares no output directory — not folded in.`
4000
+ });
4001
+ continue;
4002
+ }
4003
+ apps.push({
4004
+ name,
4005
+ build: app.build,
4006
+ output: app.output,
4007
+ path: app.path ?? "/",
4008
+ spa: app.spa ?? true
4009
+ });
4010
+ }
4011
+ apps.sort((a, b) => b.path.length - a.path.length);
4012
+ return {
4013
+ apps,
4014
+ skipped
4015
+ };
4016
+ }
4017
+ /**
4018
+ * Assert a built app's assets are actually rooted at the path it is served from.
4019
+ *
4020
+ * An app mounted at `/admin` but built with Vite's default `base: "/"` emits
4021
+ * `<script src="/assets/index-a1b2.js">`. The server serves `index.html` fine
4022
+ * and 404s every asset: a blank page, no server error, nothing in the logs. It
4023
+ * is the single most expensive silent failure in this design, so it is a build
4024
+ * error rather than a runtime surprise.
4025
+ *
4026
+ * Only `<script src>` and `<link href>` are inspected — those are what a bundler
4027
+ * rewrites through `base`. Author-written anchors and canonical URLs are not
4028
+ * evidence of a misbuild.
4029
+ */
4030
+ function assertBuiltForPath(indexHtml, basePath, appName) {
4031
+ if (basePath === "/") return;
4032
+ const offenders = [];
4033
+ for (const match of indexHtml.matchAll(/<(?:script|link)\b[^>]*?\b(?:src|href)\s*=\s*["']([^"']+)["']/gi)) {
4034
+ const ref = match[1];
4035
+ if (!ref.startsWith("/")) continue;
4036
+ if (ref === `${basePath}` || ref.startsWith(`${basePath}/`)) continue;
4037
+ offenders.push(ref);
4038
+ }
4039
+ if (offenders.length === 0) return;
4040
+ throw new Error(`"${appName}" is declared at ${basePath} but its build emitted assets rooted at /.\n index.html references: ${offenders.slice(0, 3).join(", ")}\n The app would load a blank page. Set \`base\` from REBASE_APP_BASE in its
4041
+ build config — see docs/apps-and-runtimes.md §4.2.`);
3673
4042
  }
3674
4043
  /**
3675
- * Build the project's frontend and fold it into the backend bundle.
4044
+ * Build the project's static apps and fold them into the backend bundle.
3676
4045
  *
3677
4046
  * Throws rather than exiting, so the caller decides whether a missing frontend
3678
4047
  * should fail its command — a `build` may reasonably want to stop, and so should
@@ -3681,27 +4050,39 @@ function selectFoldableApp(manifest) {
3681
4050
  async function foldFrontendIntoBundle(options) {
3682
4051
  const { projectRoot, manifest, bundleDir, skipBuild } = options;
3683
4052
  const log = options.log ?? ((m) => console.log(m));
3684
- const { app, reason } = selectFoldableApp(manifest);
3685
- if (reason) {
3686
- log(chalk.yellow(` ⚠ ${reason}`));
3687
- return null;
4053
+ const { apps, skipped } = foldableApps(manifest);
4054
+ for (const { reason } of skipped) log(chalk.yellow(` ⚠ ${reason}`));
4055
+ if (apps.length === 0) return [];
4056
+ const outcomes = [];
4057
+ for (const app of apps) {
4058
+ if (app.build && !skipBuild) await execa(app.build, {
4059
+ cwd: projectRoot,
4060
+ stdio: "inherit",
4061
+ shell: true,
4062
+ env: {
4063
+ REBASE_APP_PATH: app.path,
4064
+ REBASE_APP_BASE: app.path === "/" ? "/" : `${app.path}/`,
4065
+ REBASE_APP_NAME: app.name
4066
+ }
4067
+ });
4068
+ const assetsDir = path.join(projectRoot, app.output);
4069
+ if (!fs.existsSync(assetsDir)) throw new Error(`"${app.name}" declared output "${app.output}" does not exist after building — the bundle would ship without a frontend.`);
4070
+ const indexHtml = path.join(assetsDir, "index.html");
4071
+ if (fs.existsSync(indexHtml)) assertBuiltForPath(fs.readFileSync(indexHtml, "utf8"), app.path, app.name);
4072
+ const { fileCount } = foldStaticIntoBundle({
4073
+ bundleDir,
4074
+ assetsDir,
4075
+ appName: app.name,
4076
+ path: app.path,
4077
+ spa: app.spa
4078
+ });
4079
+ outcomes.push({
4080
+ appName: app.name,
4081
+ fileCount,
4082
+ path: app.path
4083
+ });
3688
4084
  }
3689
- if (!app) return null;
3690
- if (app.build && !skipBuild) await execa(app.build, {
3691
- cwd: projectRoot,
3692
- stdio: "inherit",
3693
- shell: true
3694
- });
3695
- const assetsDir = path.join(projectRoot, app.output);
3696
- if (!fs.existsSync(assetsDir)) throw new Error(`"${app.name}" declared output "${app.output}" does not exist after building — the bundle would ship without a frontend.`);
3697
- const { fileCount } = foldStaticIntoBundle({
3698
- bundleDir,
3699
- assetsDir
3700
- });
3701
- return {
3702
- appName: app.name,
3703
- fileCount
3704
- };
4085
+ return outcomes;
3705
4086
  }
3706
4087
  //#endregion
3707
4088
  //#region src/commands/build.ts
@@ -3719,7 +4100,7 @@ async function foldFrontendIntoBundle(options) {
3719
4100
  * entrypoint, falls back to the previous behaviour: run every workspace's own
3720
4101
  * `build` script. Nothing that built before stops building.
3721
4102
  */
3722
- function printHelp$3() {
4103
+ function printHelp$4() {
3723
4104
  console.log(`
3724
4105
  ${chalk.bold("rebase build")} — build the apps declared in rebase.json
3725
4106
 
@@ -3754,7 +4135,7 @@ async function buildCommand(rawArgs = []) {
3754
4135
  permissive: true
3755
4136
  });
3756
4137
  if (args["--help"]) {
3757
- printHelp$3();
4138
+ printHelp$4();
3758
4139
  return;
3759
4140
  }
3760
4141
  const projectRoot = requireProjectRoot();
@@ -3798,13 +4179,20 @@ async function buildCommand(rawArgs = []) {
3798
4179
  console.log(`${chalk.bold("Rebase")} — building ${targets.length} app(s)\n`);
3799
4180
  for (const { name, app } of targets) {
3800
4181
  console.log(chalk.cyan(`▸ ${name}`) + chalk.dim(` (${app.type})`));
4182
+ if (app.type === "backend" && app.runtime === "custom") {
4183
+ console.log(chalk.dim(" custom runtime — this project builds its own image, not a bundle"));
4184
+ console.log(chalk.dim(` ${chalk.cyan(`npm run build --workspace ${name}`)} then ${chalk.cyan(`docker build -f ${app.dockerfile ?? "Dockerfile"} .`)}`));
4185
+ console.log("");
4186
+ continue;
4187
+ }
3801
4188
  if (app.type === "backend") {
3802
4189
  const result = await buildBundle({
3803
4190
  projectRoot,
3804
4191
  appName: name,
3805
4192
  app,
3806
4193
  outDir: args["--out"],
3807
- runtimeRange: manifest.runtime,
4194
+ runtimeRange: manifest.rebase,
4195
+ storage: manifest.storage,
3808
4196
  skipTypeCheck: args["--skip-type-check"],
3809
4197
  skipSchema: args["--skip-schema"]
3810
4198
  });
@@ -3827,28 +4215,24 @@ async function buildCommand(rawArgs = []) {
3827
4215
  console.error(chalk.red(` ✗ ${err instanceof Error ? err.message : String(err)}`));
3828
4216
  process.exit(1);
3829
4217
  });
3830
- if (folded) console.log(chalk.green(` ✓ ${folded.appName} folded in`) + chalk.dim(` (${folded.fileCount} file(s) → served at /)`));
4218
+ for (const outcome of folded ?? []) console.log(chalk.green(` ✓ ${outcome.appName} folded in`) + chalk.dim(` (${outcome.fileCount} file(s) → served at ${outcome.path})`));
3831
4219
  }
3832
- } else if (app.type === "static" || app.type === "admin") await buildAssetApp(projectRoot, name, app, manifest.runtime, args["--out"]);
3833
- else if (app.type === "custom") console.log(chalk.dim(" custom container — built at deploy time from its Dockerfile"));
4220
+ } else if (app.type === "static") await buildAssetApp(projectRoot, name, app, manifest.rebase, args["--out"]);
3834
4221
  console.log("");
3835
4222
  }
3836
4223
  console.log(chalk.green("✓ Build complete."));
3837
4224
  }
3838
4225
  /**
3839
- * Build a static or bundled-admin app and package it into a static bundle.
4226
+ * Build a static app and package it into a static bundle.
3840
4227
  *
3841
4228
  * Runs the app's own build command, checks it produced the declared output, then
3842
- * packages that output into a `static`-mode bundle — the same deployable shape as
4229
+ * packages that output into a `static`-kind bundle — the same deployable shape as
3843
4230
  * a backend bundle, so a frontend or admin app deploys through the identical
3844
4231
  * path and runs on the identical image, just serving files instead of an API.
3845
4232
  */
3846
4233
  async function buildAssetApp(projectRoot, name, app, runtimeRange, outOverride) {
3847
4234
  const asset = app;
3848
- if (app.type === "admin" && app.mode !== "bundled") {
3849
- console.log(chalk.dim(" hosted admin panel — nothing to build"));
3850
- return;
3851
- }
4235
+ const basePath = asset.path ?? "/";
3852
4236
  if (!asset.build) {
3853
4237
  console.log(chalk.dim(" no build command declared — skipping"));
3854
4238
  return;
@@ -3857,7 +4241,12 @@ async function buildAssetApp(projectRoot, name, app, runtimeRange, outOverride)
3857
4241
  await execa(asset.build, {
3858
4242
  cwd: projectRoot,
3859
4243
  stdio: "inherit",
3860
- shell: true
4244
+ shell: true,
4245
+ env: {
4246
+ REBASE_APP_PATH: basePath,
4247
+ REBASE_APP_BASE: basePath === "/" ? "/" : `${basePath}/`,
4248
+ REBASE_APP_NAME: name
4249
+ }
3861
4250
  });
3862
4251
  } catch {
3863
4252
  console.error(chalk.red(` ✗ build command failed for "${name}"`));
@@ -3872,15 +4261,24 @@ async function buildAssetApp(projectRoot, name, app, runtimeRange, outOverride)
3872
4261
  console.error(chalk.red(` ✗ declared output "${asset.output}" does not exist after building`));
3873
4262
  process.exit(1);
3874
4263
  }
4264
+ const indexHtml = path.join(outputPath, "index.html");
4265
+ if (fs.existsSync(indexHtml)) try {
4266
+ assertBuiltForPath(fs.readFileSync(indexHtml, "utf8"), basePath, name);
4267
+ } catch (err) {
4268
+ console.error(chalk.red(` ✗ ${err instanceof Error ? err.message : String(err)}`));
4269
+ process.exit(1);
4270
+ }
3875
4271
  const result = buildStaticBundle({
3876
4272
  projectRoot,
3877
4273
  appName: name,
3878
4274
  assetsDir: outputPath,
3879
4275
  outDir: outOverride ? path.resolve(process.cwd(), outOverride) : path.join(projectRoot, `dist-bundle-${name}`),
3880
- runtimeRange
4276
+ runtimeRange,
4277
+ path: basePath,
4278
+ spa: asset.spa ?? true
3881
4279
  });
3882
4280
  const rel = path.relative(projectRoot, result.outDir);
3883
- console.log(chalk.green(` ✓ static bundle → ${rel}/`) + chalk.dim(` (${result.fileCount} file(s))`));
4281
+ console.log(chalk.green(` ✓ static bundle → ${rel}/`) + chalk.dim(` (${result.fileCount} file(s) → served at ${basePath})`));
3884
4282
  }
3885
4283
  /** The pre-manifest behaviour: build every workspace package. */
3886
4284
  async function runWorkspaceBuilds(projectRoot) {
@@ -3898,6 +4296,234 @@ async function runWorkspaceBuilds(projectRoot) {
3898
4296
  }
3899
4297
  }
3900
4298
  //#endregion
4299
+ //#region src/commands/eject.ts
4300
+ /**
4301
+ * CLI command: rebase eject
4302
+ *
4303
+ * The supported route from the managed runtime to a custom one.
4304
+ *
4305
+ * Without it, `runtime: "custom"` is a mode a user can only reach by
4306
+ * hand-writing an entrypoint they have never seen. The template used to solve
4307
+ * that by scaffolding `backend/src/index.ts` into every project — ~190 lines
4308
+ * configuring CORS, auth, cookies, storage and history, which the managed
4309
+ * runtime never loads. It was the most important-looking file in a new project
4310
+ * and editing it did nothing.
4311
+ *
4312
+ * So the file moved here. A managed project does not carry it; a project that
4313
+ * asks for it gets it together with the Dockerfile and the manifest change that
4314
+ * make it actually run.
4315
+ *
4316
+ * There is deliberately no `rebase uneject`. Going back is deleting two files
4317
+ * and editing one line, and a command that silently discarded a user's server
4318
+ * code would be worse than its absence.
4319
+ */
4320
+ var __dirname$1 = path.dirname(fileURLToPath(import.meta.url));
4321
+ /** Walk up to the package root, which holds `templates/`. */
4322
+ function findCliRoot(from) {
4323
+ const root = path.parse(from).root;
4324
+ let dir = from;
4325
+ while (dir && dir !== root) {
4326
+ if (fs.existsSync(path.join(dir, "templates", "eject"))) return dir;
4327
+ dir = path.dirname(dir);
4328
+ }
4329
+ return null;
4330
+ }
4331
+ /** Files the eject payload contributes, as `<source> → <destination>`. */
4332
+ var PAYLOAD = [
4333
+ {
4334
+ from: "backend/src/index.ts",
4335
+ to: "backend/src/index.ts",
4336
+ overwrite: true
4337
+ },
4338
+ {
4339
+ from: "backend/src/env.ts",
4340
+ to: "backend/src/env.ts",
4341
+ overwrite: true
4342
+ },
4343
+ {
4344
+ from: "Dockerfile",
4345
+ to: "Dockerfile",
4346
+ overwrite: false
4347
+ },
4348
+ {
4349
+ from: "docker-compose.custom.yml",
4350
+ to: "docker-compose.custom.yml",
4351
+ overwrite: false
4352
+ }
4353
+ ];
4354
+ /**
4355
+ * The project's name, for the `{{PROJECT_NAME}}` the payload carries.
4356
+ *
4357
+ * Falls back to the directory name — a compose project name is cosmetic, and a
4358
+ * missing or unreadable package.json is not a reason to refuse to eject.
4359
+ */
4360
+ function projectNameOf(projectRoot) {
4361
+ try {
4362
+ const pkg = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8"));
4363
+ if (typeof pkg.name === "string" && pkg.name.trim()) return pkg.name.trim();
4364
+ } catch {}
4365
+ return path.basename(projectRoot);
4366
+ }
4367
+ function printHelp$3() {
4368
+ console.log(`
4369
+ ${chalk.bold("rebase eject")} — take ownership of the server process
4370
+
4371
+ Writes the backend entrypoint and a Dockerfile into this project, and flips its
4372
+ backend to ${chalk.cyan("runtime: \"custom\"")}. From then on this repository builds its own
4373
+ image: platform runtime upgrades no longer reach it, and CORS, auth wiring,
4374
+ storage and shutdown become yours to configure.
4375
+
4376
+ ${chalk.bold("Usage")}
4377
+ rebase eject [app]
4378
+
4379
+ ${chalk.bold("Options")}
4380
+ --dry-run List what would change, and change nothing
4381
+ -h, --help Show this help
4382
+ `.trim());
4383
+ }
4384
+ async function ejectCommand(rawArgs = []) {
4385
+ const args = arg({
4386
+ "--dry-run": Boolean,
4387
+ "--help": Boolean,
4388
+ "-h": "--help"
4389
+ }, {
4390
+ argv: rawArgs.slice(2),
4391
+ permissive: true
4392
+ });
4393
+ if (args["--help"]) {
4394
+ printHelp$3();
4395
+ return;
4396
+ }
4397
+ const projectRoot = requireProjectRoot();
4398
+ const dryRun = Boolean(args["--dry-run"]);
4399
+ const requested = args._.slice(1).find((value) => !value.startsWith("-"));
4400
+ let loaded;
4401
+ try {
4402
+ loaded = loadManifest(projectRoot);
4403
+ } catch (err) {
4404
+ if (err instanceof ManifestError) {
4405
+ console.error(chalk.red(`✗ ${err.message}`));
4406
+ for (const issue of err.issues) console.error(chalk.dim(` ${issue.path}: ${issue.message}`));
4407
+ process.exit(1);
4408
+ }
4409
+ throw err;
4410
+ }
4411
+ const { manifest } = loaded;
4412
+ let appName;
4413
+ let app;
4414
+ if (requested) {
4415
+ const declared = manifest.apps[requested];
4416
+ if (!declared) {
4417
+ console.error(chalk.red(`✗ No app named "${requested}" in rebase.json.`));
4418
+ console.error(chalk.dim(` Declared: ${Object.keys(manifest.apps).join(", ") || "(none)"}`));
4419
+ process.exit(1);
4420
+ }
4421
+ if (declared.type !== "backend") {
4422
+ console.error(chalk.red(`✗ "${requested}" is a ${declared.type} app — only a backend can be ejected.`));
4423
+ process.exit(1);
4424
+ }
4425
+ appName = requested;
4426
+ app = declared;
4427
+ } else {
4428
+ const backend = findBackendApp(manifest);
4429
+ if (!backend) {
4430
+ console.error(chalk.red("✗ This repository declares no backend app."));
4431
+ console.error(chalk.dim(" Only the repository that declares the backend chooses its runtime."));
4432
+ process.exit(1);
4433
+ }
4434
+ appName = backend.name;
4435
+ app = backend.app;
4436
+ }
4437
+ if (app.runtime === "custom") {
4438
+ console.error(chalk.red(`✗ "${appName}" is already ejected — it declares runtime: "custom".`));
4439
+ console.error(chalk.dim(` Its entrypoint is ${app.dockerfile ?? "Dockerfile"} and backend/src/index.ts.`));
4440
+ process.exit(1);
4441
+ }
4442
+ const cliRoot = findCliRoot(__dirname$1);
4443
+ if (!cliRoot) {
4444
+ console.error(chalk.red("✗ Could not locate the eject templates. Reinstall @rebasepro/cli."));
4445
+ process.exit(1);
4446
+ }
4447
+ const payloadDir = path.join(cliRoot, "templates", "eject");
4448
+ const planned = [];
4449
+ for (const file of PAYLOAD) {
4450
+ const source = path.join(payloadDir, file.from);
4451
+ if (!fs.existsSync(source)) {
4452
+ console.error(chalk.red(`✗ The eject template is missing ${file.from}. Reinstall @rebasepro/cli.`));
4453
+ process.exit(1);
4454
+ }
4455
+ const exists = fs.existsSync(path.join(projectRoot, file.to));
4456
+ planned.push({
4457
+ to: file.to,
4458
+ action: exists && !file.overwrite ? "keep" : "write"
4459
+ });
4460
+ }
4461
+ if (dryRun) {
4462
+ console.log(chalk.bold(`Would eject "${appName}" to a custom runtime:`));
4463
+ console.log("");
4464
+ for (const item of planned) console.log(item.action === "write" ? ` ${chalk.green("write")} ${item.to}` : ` ${chalk.dim("keep")} ${item.to} ${chalk.dim("(already exists)")}`);
4465
+ console.log(` ${chalk.green("write")} rebase.json ${chalk.dim("(runtime: \"custom\")")}`);
4466
+ console.log("");
4467
+ console.log(chalk.dim("Nothing was changed."));
4468
+ return;
4469
+ }
4470
+ const projectName = projectNameOf(projectRoot);
4471
+ for (const [index, file] of PAYLOAD.entries()) {
4472
+ if (planned[index].action === "keep") continue;
4473
+ const destination = path.join(projectRoot, file.to);
4474
+ fs.mkdirSync(path.dirname(destination), { recursive: true });
4475
+ const contents = fs.readFileSync(path.join(payloadDir, file.from), "utf8").replace(/\{\{PROJECT_NAME\}\}/g, projectName);
4476
+ fs.writeFileSync(destination, contents, "utf8");
4477
+ }
4478
+ const dockerfile = app.dockerfile ?? "Dockerfile";
4479
+ manifest.apps[appName] = {
4480
+ ...app,
4481
+ runtime: "custom",
4482
+ dockerfile,
4483
+ port: app.port ?? 8080
4484
+ };
4485
+ writeManifest(projectRoot, manifest);
4486
+ restoreBackendScripts(projectRoot);
4487
+ console.log("");
4488
+ console.log(chalk.green(`✓ Ejected "${appName}" to a custom runtime.`));
4489
+ console.log("");
4490
+ console.log(` ${chalk.cyan("backend/src/index.ts".padEnd(26))} your entrypoint — the runtime no longer boots the bundle`);
4491
+ console.log(` ${chalk.cyan("backend/src/env.ts".padEnd(26))} the environment it reads`);
4492
+ console.log(` ${chalk.cyan(dockerfile.padEnd(26))} your image`);
4493
+ console.log(` ${chalk.cyan("docker-compose.custom.yml".padEnd(26))} runs it`);
4494
+ console.log(` ${chalk.cyan("rebase.json".padEnd(26))} runtime: custom`);
4495
+ console.log("");
4496
+ console.log(chalk.yellow(" You now own CORS, auth wiring, storage and shutdown. Platform runtime"));
4497
+ console.log(chalk.yellow(" upgrades no longer reach this project."));
4498
+ console.log("");
4499
+ console.log(chalk.dim(` ${chalk.cyan("docker compose -f docker-compose.custom.yml up --build")}`));
4500
+ console.log(chalk.dim(" docker-compose.yml is untouched — it still runs the managed shape if you go back."));
4501
+ console.log("");
4502
+ }
4503
+ /**
4504
+ * Point the backend workspace's scripts at the entrypoint that now exists.
4505
+ *
4506
+ * A managed project's backend package deliberately declares no `main` and no
4507
+ * `start`: there is no entrypoint to name. Ejecting creates one.
4508
+ */
4509
+ function restoreBackendScripts(projectRoot) {
4510
+ const packagePath = path.join(projectRoot, "backend", "package.json");
4511
+ if (!fs.existsSync(packagePath)) return;
4512
+ let parsed;
4513
+ try {
4514
+ parsed = JSON.parse(fs.readFileSync(packagePath, "utf8"));
4515
+ } catch {
4516
+ console.log(chalk.yellow(" ⚠ backend/package.json is not valid JSON — its scripts were left alone."));
4517
+ return;
4518
+ }
4519
+ const scripts = parsed.scripts ?? {};
4520
+ parsed.main ??= "src/index.ts";
4521
+ scripts.dev ??= "tsx watch --include=\"../config/**/*\" --include=\"./functions/**/*\" src/index.ts";
4522
+ scripts.start ??= "node dist/backend/src/index.js";
4523
+ parsed.scripts = scripts;
4524
+ fs.writeFileSync(packagePath, `${JSON.stringify(parsed, null, 4)}\n`, "utf8");
4525
+ }
4526
+ //#endregion
3901
4527
  //#region src/commands/start.ts
3902
4528
  /**
3903
4529
  * CLI command: rebase start
@@ -5345,7 +5971,7 @@ function declaredAppsFrom(manifest) {
5345
5971
  if (!apps || typeof apps !== "object") return [];
5346
5972
  return Object.entries(apps).filter(([name]) => name.trim().length > 0).map(([name, value]) => ({
5347
5973
  name,
5348
- type: String(value?.type ?? "custom")
5974
+ type: value?.type === "backend" ? "backend" : "static"
5349
5975
  }));
5350
5976
  }
5351
5977
  /** Upload a bundle archive; returns the control-plane bundle id. */
@@ -5502,7 +6128,8 @@ async function deployBundle(opts) {
5502
6128
  projectRoot,
5503
6129
  appName: backend.name,
5504
6130
  app: backend.app,
5505
- runtimeRange: loaded.manifest.runtime,
6131
+ runtimeRange: loaded.manifest.rebase,
6132
+ storage: loaded.manifest.storage,
5506
6133
  skipTypeCheck: opts.skipTypeCheck,
5507
6134
  log: (m) => console.log(chalk.gray(m))
5508
6135
  })).outDir;
@@ -5513,7 +6140,7 @@ async function deployBundle(opts) {
5513
6140
  bundleDir,
5514
6141
  log: (m) => console.log(m)
5515
6142
  });
5516
- if (folded) console.log(chalk.gray(` folded ${folded.appName} in (${folded.fileCount} file(s), served at /)`));
6143
+ for (const outcome of folded) console.log(chalk.gray(` folded ${outcome.appName} in (${outcome.fileCount} file(s), served at ${outcome.path})`));
5517
6144
  } catch (err) {
5518
6145
  fail(err instanceof Error ? err.message : String(err), "Fix the frontend build, or pass --no-static to deploy the API alone.");
5519
6146
  }
@@ -5650,6 +6277,23 @@ async function readDeployContext(client, projectId) {
5650
6277
  return {};
5651
6278
  }
5652
6279
  }
6280
+ /**
6281
+ * Whether this repository's backend declares the managed runtime.
6282
+ *
6283
+ * Deliberately quiet: a directory that is not a Rebase project, or whose
6284
+ * manifest does not parse, simply does not route this way — `rebase build` is
6285
+ * where a broken manifest gets reported, and a deploy refusing on one before it
6286
+ * has even said what it is doing would be the wrong place to find out.
6287
+ */
6288
+ function declaresManagedRuntime() {
6289
+ try {
6290
+ const projectRoot = findProjectRoot();
6291
+ if (!projectRoot) return false;
6292
+ return findBackendApp(loadManifest(projectRoot).manifest)?.app.runtime === "managed";
6293
+ } catch {
6294
+ return false;
6295
+ }
6296
+ }
5653
6297
  async function deployCommand(rawArgs, projectRef) {
5654
6298
  const args = arg({
5655
6299
  "--no-follow": Boolean,
@@ -5666,8 +6310,10 @@ async function deployCommand(rawArgs, projectRef) {
5666
6310
  });
5667
6311
  const { client, url } = await requireClient(rawArgs);
5668
6312
  const projectId = await resolveProjectRef(projectRef, client);
5669
- if (args["--bundle"]) {
5670
- if (args["--source"]) fail("--bundle and --source cannot be combined: one is a managed bundle, the other a source build.");
6313
+ const declaredManaged = !args["--source"] && !args["--bundle"] && declaresManagedRuntime();
6314
+ if (args["--bundle"] || declaredManaged) {
6315
+ if (args["--bundle"] && args["--source"]) fail("--bundle and --source cannot be combined: one is a managed bundle, the other a source build.");
6316
+ if (declaredManaged && !isJsonMode()) console.log(chalk.gray(" rebase.json declares runtime: managed — deploying a bundle."));
5671
6317
  await deployBundle({
5672
6318
  client,
5673
6319
  url,
@@ -9039,11 +9685,8 @@ async function appsCommand(subcommand, rawArgs = []) {
9039
9685
  }
9040
9686
  function describeApp(app) {
9041
9687
  switch (app.type) {
9042
- case "backend": return `config: ${app.config ?? "config"}, mode: ${app.mode ?? "cms"}`;
9043
- case "static": return `${app.root} → ${app.output}`;
9044
- case "admin": return app.mode === "bundled" ? `bundled → ${app.output ?? "?"}` : "hosted by the platform";
9045
- case "mobile": return app.platform;
9046
- case "custom": return app.dockerfile ?? "Dockerfile";
9688
+ case "backend": return app.runtime === "custom" ? `custom runtime — ${app.dockerfile ?? "Dockerfile"}` : `managed runtime, config: ${app.config ?? "config"}`;
9689
+ case "static": return `${app.root} → ${app.output} @ ${app.path ?? "/"}`;
9047
9690
  default: return "";
9048
9691
  }
9049
9692
  }
@@ -9053,7 +9696,7 @@ async function listApps(asJson) {
9053
9696
  if (asJson) {
9054
9697
  console.log(JSON.stringify({
9055
9698
  source: loaded.source,
9056
- runtime: loaded.manifest.runtime,
9699
+ rebase: loaded.manifest.rebase,
9057
9700
  apps: loaded.manifest.apps,
9058
9701
  managed: compatibility
9059
9702
  }, null, 2));
@@ -9063,7 +9706,7 @@ async function listApps(asJson) {
9063
9706
  console.log(chalk.dim("No rebase.json — showing the layout inferred from this project."));
9064
9707
  console.log(chalk.dim(`Run ${chalk.cyan("rebase apps init")} to write it down.\n`));
9065
9708
  }
9066
- console.log(chalk.bold(`Runtime ${loaded.manifest.runtime}`));
9709
+ console.log(chalk.bold(`Rebase ${loaded.manifest.rebase}`));
9067
9710
  console.log("");
9068
9711
  const entries = Object.entries(loaded.manifest.apps);
9069
9712
  if (entries.length === 0) {
@@ -9209,6 +9852,7 @@ async function entry(args) {
9209
9852
  "api-keys",
9210
9853
  "cloud",
9211
9854
  "apps",
9855
+ "eject",
9212
9856
  "generate-sdk"
9213
9857
  ].includes(command)) {
9214
9858
  printHelp();
@@ -9261,6 +9905,9 @@ async function entry(args) {
9261
9905
  case "apps":
9262
9906
  await appsCommand(effectiveSubcommand, args);
9263
9907
  break;
9908
+ case "eject":
9909
+ await ejectCommand(args);
9910
+ break;
9264
9911
  case "auth":
9265
9912
  await authCommand(effectiveSubcommand, args);
9266
9913
  break;
@@ -9295,6 +9942,8 @@ ${chalk.green.bold("Commands")}
9295
9942
  ${chalk.blue.bold("dev")} Start the development server
9296
9943
  ${chalk.blue.bold("build")} Build all workspace packages
9297
9944
  ${chalk.blue.bold("start")} Start the backend server ${chalk.gray("(production)")}
9945
+ ${chalk.blue.bold("apps list")} Show the apps this repository declares
9946
+ ${chalk.blue.bold("eject")} Take ownership of the server process and image
9298
9947
 
9299
9948
  ${chalk.green.bold("Schema")}
9300
9949
  ${chalk.blue.bold("schema generate")} Generate Drizzle schema from collections
@@ -9312,25 +9961,25 @@ ${chalk.green.bold("SDK")}
9312
9961
 
9313
9962
  ${chalk.green.bold("Auth")}
9314
9963
  ${chalk.blue.bold("auth reset-password")} Reset a user's password
9315
- ${chalk.blue.bold("auth")} ${chalk.gray("--help")} Show auth command help
9964
+ ${chalk.blue.bold("auth")} ${chalk.gray("--help")} Show auth command help
9316
9965
 
9317
9966
  ${chalk.green.bold("Diagnostics")}
9318
9967
  ${chalk.blue.bold("doctor")} Detect schema drift between collections, schema, and DB
9319
9968
 
9320
9969
  ${chalk.green.bold("AI Agent Skills")}
9321
- ${chalk.blue.bold("skills install")} Install Rebase agent skills for your AI coding assistant
9970
+ ${chalk.blue.bold("skills install")} Install Rebase agent skills for your AI coding assistant
9322
9971
 
9323
9972
  ${chalk.green.bold("API Keys")}
9324
- ${chalk.blue.bold("api-keys list")} List all service API keys
9325
- ${chalk.blue.bold("api-keys create")} Create a new scoped API key
9326
- ${chalk.blue.bold("api-keys revoke")} Revoke an existing API key
9327
- ${chalk.blue.bold("api-keys")} ${chalk.gray("--help")} Show API key command help
9973
+ ${chalk.blue.bold("api-keys list")} List all service API keys
9974
+ ${chalk.blue.bold("api-keys create")} Create a new scoped API key
9975
+ ${chalk.blue.bold("api-keys revoke")} Revoke an existing API key
9976
+ ${chalk.blue.bold("api-keys")} ${chalk.gray("--help")} Show API key command help
9328
9977
 
9329
9978
  ${chalk.green.bold("Rebase Cloud")}
9330
9979
  ${chalk.blue.bold("cloud login")} Sign in to the hosted control plane
9331
9980
  ${chalk.blue.bold("cloud link")} Link this directory to a cloud project
9332
9981
  ${chalk.blue.bold("cloud deploy")} Deploy the linked project + stream logs
9333
- ${chalk.blue.bold("cloud")} ${chalk.gray("--help")} Show all cloud commands
9982
+ ${chalk.blue.bold("cloud")} ${chalk.gray("--help")} Show all cloud commands
9334
9983
 
9335
9984
  ${chalk.green.bold("Options")}
9336
9985
  ${chalk.blue("--version, -v")} Show version number
@@ -9340,6 +9989,6 @@ ${chalk.gray("Documentation: https://rebase.pro/docs")}
9340
9989
  `);
9341
9990
  }
9342
9991
  //#endregion
9343
- export { CURRENT_RUNTIME_RANGE, DEFAULT_BUNDLE_DIR, DEFAULT_CONFIG_DIR, DEFAULT_CRONS_DIR, DEFAULT_FUNCTIONS_DIR, DEFAULT_SCHEMA_FILE, MANIFEST_FILENAME, ManifestError, appsCommand, assessManagedCompatibility, authCommand, buildBundle, buildCommand, buildInitQuestions, buildStaticBundle, buildableApps, cloudCommand, collectDeclaredDependencies, configureEnvFile, createRebaseApp, dbCommand, detectNativeDependencies, detectPackageManager, detectStorageAuthorize, devCommand, doctorCommand, entry, findBackendApp, findBackendDir, findEnvFile, findFrontendDir, findProjectRoot, findUnusedServerEntry, foldStaticIntoBundle, formatCdTarget, generateSdkCommand, getActiveBackendPlugin, getPMCommands, isIdentifierLike, isPnpmAvailable, loadManifest, manifestExists, manifestPath, normalizeEsmSpecifiers, pnpmAvailabilityFromProbe, printInitHelp, requireBackendDir, requireProjectRoot, resetPnpmAvailabilityCache, resolveBackendPaths, resolveExampleBaseUrl, resolveLocalBin, resolvePluginCliScript, resolveTsx, schemaCommand, startCommand, synthesizeManifest, validateManifest, validateProjectName, validateTsxInstallation, writeManifest };
9992
+ export { CURRENT_RUNTIME_RANGE, DEFAULT_BUNDLE_DIR, DEFAULT_CONFIG_DIR, DEFAULT_CRONS_DIR, DEFAULT_FUNCTIONS_DIR, DEFAULT_SCHEMA_FILE, MANIFEST_FILENAME, ManifestError, TEMPLATE_PLACEHOLDER_FILES, appsCommand, assessManagedCompatibility, authCommand, buildBundle, buildCommand, buildInitQuestions, buildStaticBundle, buildableApps, cloudCommand, collectDeclaredDependencies, configureEnvFile, createRebaseApp, dbCommand, detectNativeDependencies, detectPackageManager, detectStorageAuthorize, devCommand, doctorCommand, ejectCommand, entry, findBackendApp, findBackendDir, findEnvFile, findFrontendDir, findProjectRoot, findUnusedServerEntry, foldStaticIntoBundle, formatCdTarget, generateSdkCommand, getActiveBackendPlugin, getPMCommands, isIdentifierLike, isPnpmAvailable, loadManifest, manifestExists, manifestPath, normalizeEsmSpecifiers, pnpmAvailabilityFromProbe, printInitHelp, requireBackendDir, requireProjectRoot, resetPnpmAvailabilityCache, resolveBackendPaths, resolveExampleBaseUrl, resolveLocalBin, resolvePluginCliScript, resolveTsx, schemaCommand, startCommand, synthesizeManifest, validateManifest, validateProjectName, validateTsxInstallation, writeManifest };
9344
9993
 
9345
9994
  //# sourceMappingURL=index.es.js.map