@rebasepro/cli 0.30.1 → 0.31.0-canary.g59cd6fd

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 (284) hide show
  1. package/README.md +8 -7
  2. package/dist/{agent-setup-0uyfC7VX.js → agent-setup-DqAcoDcn.js} +10 -5
  3. package/dist/{agent-setup-0uyfC7VX.js.map → agent-setup-DqAcoDcn.js.map} +1 -1
  4. package/dist/{api-keys-Dfw5-9s1.js → api-keys-eIUjMqWn.js} +8 -7
  5. package/dist/api-keys-eIUjMqWn.js.map +1 -0
  6. package/dist/{apps-MKQbgDtN.js → apps-DExO4PEl.js} +8 -7
  7. package/dist/apps-DExO4PEl.js.map +1 -0
  8. package/dist/{project-CasK56vN.js → args-CaCcrYE1.js} +2 -351
  9. package/dist/args-CaCcrYE1.js.map +1 -0
  10. package/dist/{atlas-dev-database-BODqdCWt.js → atlas-dev-database-DOCKk6ht.js} +2 -2
  11. package/dist/{atlas-dev-database-BODqdCWt.js.map → atlas-dev-database-DOCKk6ht.js.map} +1 -1
  12. package/dist/{auth-Bv0rTbQX.js → auth-D96QYgFR.js} +7 -6
  13. package/dist/{auth-Bv0rTbQX.js.map → auth-D96QYgFR.js.map} +1 -1
  14. package/dist/backend-guard-C0mVkXBw.js +162 -0
  15. package/dist/backend-guard-C0mVkXBw.js.map +1 -0
  16. package/dist/{branch-pointer-BQUF6lYa.js → branch-pointer-DMPyvZoK.js} +1 -1
  17. package/dist/{build-BuKTnec8.js → build-CA5R07tw.js} +29 -9
  18. package/dist/build-CA5R07tw.js.map +1 -0
  19. package/dist/{bundle-BAH4FCju.js → bundle-DgILeA5b.js} +112 -138
  20. package/dist/bundle-DgILeA5b.js.map +1 -0
  21. package/dist/bundle.d.ts +35 -12
  22. package/dist/cli.d.ts +2 -2
  23. package/dist/{cloud-DtADfWwn.js → cloud-CYMk92iG.js} +72 -71
  24. package/dist/cloud-CYMk92iG.js.map +1 -0
  25. package/dist/cms-directories-BK3vcswg.js +33 -0
  26. package/dist/cms-directories-BK3vcswg.js.map +1 -0
  27. package/dist/codemod/collections-to-tables/ast.d.ts +135 -0
  28. package/dist/codemod/collections-to-tables/backend.d.ts +38 -0
  29. package/dist/codemod/collections-to-tables/command.d.ts +35 -0
  30. package/dist/codemod/collections-to-tables/comments.d.ts +45 -0
  31. package/dist/codemod/collections-to-tables/customization.d.ts +47 -0
  32. package/dist/codemod/collections-to-tables/dynamic-props.d.ts +34 -0
  33. package/dist/codemod/collections-to-tables/export-changes.d.ts +83 -0
  34. package/dist/codemod/collections-to-tables/firestore.d.ts +11 -0
  35. package/dist/codemod/collections-to-tables/helper-hooks.d.ts +41 -0
  36. package/dist/codemod/collections-to-tables/hooks.d.ts +44 -0
  37. package/dist/codemod/collections-to-tables/journal.d.ts +10 -0
  38. package/dist/codemod/collections-to-tables/legacy-shims.d.ts +52 -0
  39. package/dist/codemod/collections-to-tables/load-legacy.d.ts +81 -0
  40. package/dist/codemod/collections-to-tables/migrate.d.ts +20 -0
  41. package/dist/codemod/collections-to-tables/modules.d.ts +127 -0
  42. package/dist/codemod/collections-to-tables/moved-imports.d.ts +70 -0
  43. package/dist/codemod/collections-to-tables/moved-symbols.generated.d.ts +12 -0
  44. package/dist/codemod/collections-to-tables/own.d.ts +10 -0
  45. package/dist/codemod/collections-to-tables/path-aliases.d.ts +26 -0
  46. package/dist/codemod/collections-to-tables/plan-context.d.ts +49 -0
  47. package/dist/codemod/collections-to-tables/print-js.d.ts +44 -0
  48. package/dist/codemod/collections-to-tables/project-files.d.ts +144 -0
  49. package/dist/codemod/collections-to-tables/repoint.d.ts +50 -0
  50. package/dist/codemod/collections-to-tables/row-hands.d.ts +7 -0
  51. package/dist/codemod/collections-to-tables/sdk-calls.d.ts +88 -0
  52. package/dist/codemod/collections-to-tables/skills-step.d.ts +13 -0
  53. package/dist/codemod/collections-to-tables/split-constants.d.ts +42 -0
  54. package/dist/codemod/collections-to-tables/storage-paths.d.ts +28 -0
  55. package/dist/codemod/collections-to-tables/types.d.ts +164 -0
  56. package/dist/codemod/collections-to-tables/verify.d.ts +27 -0
  57. package/dist/codemod/collections-to-tables/vocabulary.d.ts +40 -0
  58. package/dist/command-D5lhW_-B.js +9984 -0
  59. package/dist/command-D5lhW_-B.js.map +1 -0
  60. package/dist/commands/agent-setup.d.ts +6 -2
  61. package/dist/commands/cloud/context.d.ts +1 -1
  62. package/dist/commands/cloud/init.d.ts +2 -2
  63. package/dist/commands/console.d.ts +1 -2
  64. package/dist/commands/db.d.ts +5 -6
  65. package/dist/commands/dev.d.ts +18 -17
  66. package/dist/commands/doctor.d.ts +4 -5
  67. package/dist/commands/eject.d.ts +17 -13
  68. package/dist/commands/generate-view.d.ts +20 -9
  69. package/dist/commands/generate_sdk.d.ts +27 -27
  70. package/dist/commands/init.d.ts +21 -8
  71. package/dist/commands/migrate.d.ts +24 -0
  72. package/dist/commands/schema-reconcile.d.ts +1 -1
  73. package/dist/commands/skills.d.ts +8 -0
  74. package/dist/commands/verify-cms.d.ts +28 -0
  75. package/dist/commands/verify.d.ts +14 -9
  76. package/dist/{consent-BD7F29T3.js → consent-BXLIrMl8.js} +2 -2
  77. package/dist/{consent-BD7F29T3.js.map → consent-BXLIrMl8.js.map} +1 -1
  78. package/dist/{console-CdwIYOMV.js → console-C1d3LwB7.js} +14 -14
  79. package/dist/console-C1d3LwB7.js.map +1 -0
  80. package/dist/{context-AXdAh-q8.js → context--JwaHaZp.js} +6 -5
  81. package/dist/context--JwaHaZp.js.map +1 -0
  82. package/dist/{daemon-Cp7oNXth.js → daemon-w30PsdwV.js} +2 -2
  83. package/dist/{daemon-Cp7oNXth.js.map → daemon-w30PsdwV.js.map} +1 -1
  84. package/dist/{db-DBbKpjYX.js → db-DQZK9n9c.js} +52 -51
  85. package/dist/db-DQZK9n9c.js.map +1 -0
  86. package/dist/{derive-ae9UOoOB.js → derive-C3ezmY-p.js} +105 -133
  87. package/dist/derive-C3ezmY-p.js.map +1 -0
  88. package/dist/{dev-C93d4QIv.js → dev-PY5h4O6u.js} +142 -84
  89. package/dist/dev-PY5h4O6u.js.map +1 -0
  90. package/dist/dev-db/attver.d.ts +32 -0
  91. package/dist/dev-db/pull.d.ts +15 -1
  92. package/dist/{dev-preflight-Cxv3TiD1.js → dev-preflight-DjvcV6SK.js} +5 -5
  93. package/dist/dev-preflight-DjvcV6SK.js.map +1 -0
  94. package/dist/{dev-server-OJsUGZEB.js → dev-server-BLxCbQEP.js} +2 -2
  95. package/dist/{dev-server-OJsUGZEB.js.map → dev-server-BLxCbQEP.js.map} +1 -1
  96. package/dist/{doctor-BBPQUO2g.js → doctor-CnUu8kpM.js} +39 -62
  97. package/dist/doctor-CnUu8kpM.js.map +1 -0
  98. package/dist/doctor-environment.d.ts +6 -6
  99. package/dist/{eject-DABcDnPN.js → eject-Bhzd6hgb.js} +25 -16
  100. package/dist/eject-Bhzd6hgb.js.map +1 -0
  101. package/dist/{fold-static-BWzxNn06.js → fold-static-CKewnAPX.js} +5 -3
  102. package/dist/fold-static-CKewnAPX.js.map +1 -0
  103. package/dist/{generate-view-IFwCADvb.js → generate-view-CTOluXvH.js} +160 -89
  104. package/dist/generate-view-CTOluXvH.js.map +1 -0
  105. package/dist/{generate_sdk-DNmNuFuW.js → generate_sdk-De-aLC1L.js} +120 -137
  106. package/dist/generate_sdk-De-aLC1L.js.map +1 -0
  107. package/dist/import-schema-module-Df67TIWj.js +51 -0
  108. package/dist/import-schema-module-Df67TIWj.js.map +1 -0
  109. package/dist/index.es.js +64 -51
  110. package/dist/index.es.js.map +1 -1
  111. package/dist/{init-vL1DWOeC.js → init-Dtl-IcXf.js} +83 -80
  112. package/dist/init-Dtl-IcXf.js.map +1 -0
  113. package/dist/last-dev-database-Dc8cP01o.js +2 -0
  114. package/dist/{manifest-BtzDy7KQ.js → manifest-C3uLDrrJ.js} +115 -40
  115. package/dist/manifest-C3uLDrrJ.js.map +1 -0
  116. package/dist/manifest.d.ts +79 -24
  117. package/dist/migrate-VrKoi3nB.js +138 -0
  118. package/dist/migrate-VrKoi3nB.js.map +1 -0
  119. package/dist/{normalize-imports-Bd5Y4yLp.js → normalize-imports-DwxqEMYq.js} +3 -3
  120. package/dist/{normalize-imports-Bd5Y4yLp.js.map → normalize-imports-DwxqEMYq.js.map} +1 -1
  121. package/dist/path-flags-7O5uPBcQ.js +139 -0
  122. package/dist/path-flags-7O5uPBcQ.js.map +1 -0
  123. package/dist/{prepare-CTw9NEkh.js → prepare-Ccxspoj-.js} +4 -4
  124. package/dist/{prepare-CTw9NEkh.js.map → prepare-Ccxspoj-.js.map} +1 -1
  125. package/dist/project-CLcF5i8c.js +360 -0
  126. package/dist/project-CLcF5i8c.js.map +1 -0
  127. package/dist/project-schema-CsSOG2gE.js +30 -0
  128. package/dist/project-schema-CsSOG2gE.js.map +1 -0
  129. package/dist/{pull-DDMpsZ5r.js → pull-DRWqBZp5.js} +327 -4
  130. package/dist/pull-DRWqBZp5.js.map +1 -0
  131. package/dist/resolve-BY7bSFRT.js +2 -0
  132. package/dist/resources/derive.d.ts +19 -13
  133. package/dist/{resources-CPSC5Kcu.js → resources-Dpfs2y8P.js} +5 -4
  134. package/dist/{resources-CPSC5Kcu.js.map → resources-Dpfs2y8P.js.map} +1 -1
  135. package/dist/{schema-DtLPsXbT.js → schema-CdDjv5zI.js} +41 -39
  136. package/dist/schema-CdDjv5zI.js.map +1 -0
  137. package/dist/schema-dir-Cd1kvYbf.js +98 -0
  138. package/dist/schema-dir-Cd1kvYbf.js.map +1 -0
  139. package/dist/schema-reconcile-BAupXfkd.js +2 -0
  140. package/dist/schema-text-CpNrsuMe.js +73 -0
  141. package/dist/schema-text-CpNrsuMe.js.map +1 -0
  142. package/dist/{skills-CbwV6vw_.js → skills-CXjA9TWw.js} +54 -10
  143. package/dist/skills-CXjA9TWw.js.map +1 -0
  144. package/dist/{start-YOr3X5Zm.js → start-Bwbtt2W5.js} +7 -10
  145. package/dist/{start-YOr3X5Zm.js.map → start-Bwbtt2W5.js.map} +1 -1
  146. package/dist/{status-BREvtzJm.js → status-D7XCGHu2.js} +12 -12
  147. package/dist/status-D7XCGHu2.js.map +1 -0
  148. package/dist/{storage-CO9ouK76.js → storage-iTqj5-Av.js} +12 -11
  149. package/dist/storage-iTqj5-Av.js.map +1 -0
  150. package/dist/{telemetry-DwK5RQJl.js → telemetry-BP_1Cl9r.js} +4 -4
  151. package/dist/{telemetry-DwK5RQJl.js.map → telemetry-BP_1Cl9r.js.map} +1 -1
  152. package/dist/{telemetry-CgwJPVMO.js → telemetry-M3HjlyhZ.js} +2 -2
  153. package/dist/{telemetry-CgwJPVMO.js.map → telemetry-M3HjlyhZ.js.map} +1 -1
  154. package/dist/{upgrade-B7sVwL8S.js → upgrade-oZzJ13jM.js} +5 -4
  155. package/dist/{upgrade-B7sVwL8S.js.map → upgrade-oZzJ13jM.js.map} +1 -1
  156. package/dist/utils/backend-guard.d.ts +47 -0
  157. package/dist/utils/cms-directories.d.ts +6 -0
  158. package/dist/utils/dev-preflight.d.ts +2 -2
  159. package/dist/utils/import-schema-module.d.ts +16 -0
  160. package/dist/utils/path-flags.d.ts +35 -16
  161. package/dist/utils/project-schema.d.ts +40 -0
  162. package/dist/utils/project.d.ts +8 -2
  163. package/dist/utils/schema-dir.d.ts +32 -0
  164. package/dist/utils/schema-drift.d.ts +6 -0
  165. package/dist/utils/schema-text.d.ts +24 -0
  166. package/dist/verify-5p_vaUG2.js +1160 -0
  167. package/dist/verify-5p_vaUG2.js.map +1 -0
  168. package/package.json +11 -8
  169. package/runtime/dev-server.mjs +5 -1
  170. package/templates/eject/Dockerfile +1 -4
  171. package/templates/eject/backend/src/env.ts +1 -1
  172. package/templates/eject/backend/src/index.ts +53 -40
  173. package/templates/eject/docker-compose.custom.yml +1 -1
  174. package/templates/overlays/baas/README.md +39 -12
  175. package/templates/overlays/baas/ai-instructions.md +8 -8
  176. package/templates/overlays/baas/{config → backend}/storage.ts +3 -4
  177. package/templates/overlays/baas/backend/tsconfig.json +10 -12
  178. package/templates/overlays/baas/package.json +1 -2
  179. package/templates/overlays/baas/pnpm-workspace.yaml +0 -1
  180. package/templates/presets/blank/backend/schema/index.ts +19 -0
  181. package/templates/presets/blank/frontend/src/App.tsx +56 -0
  182. package/templates/presets/ecommerce/backend/schema/categories.ts +12 -0
  183. package/templates/presets/ecommerce/backend/schema/index.ts +23 -0
  184. package/templates/presets/ecommerce/backend/schema/orders.ts +13 -0
  185. package/templates/presets/ecommerce/backend/schema/products.ts +18 -0
  186. package/templates/presets/ecommerce/frontend/src/App.tsx +59 -0
  187. package/templates/presets/ecommerce/frontend/src/cms/categories.tsx +12 -0
  188. package/templates/presets/ecommerce/frontend/src/cms/orders.tsx +38 -0
  189. package/templates/presets/ecommerce/frontend/src/cms/products.tsx +27 -0
  190. package/templates/resource-graphs/blank.json +2 -2
  191. package/templates/resource-graphs/blog.json +5 -5
  192. package/templates/resource-graphs/ecommerce.json +5 -5
  193. package/templates/resource-graphs/headless.json +1 -1
  194. package/templates/template/.claude/hooks/post-edit-collection.sh +27 -23
  195. package/templates/template/.cursorrules +2 -2
  196. package/templates/template/.env.example +6 -17
  197. package/templates/template/.github/copilot-instructions.md +2 -2
  198. package/templates/template/.windsurfrules +2 -2
  199. package/templates/template/AGENTS.md +2 -2
  200. package/templates/template/CLAUDE.md +2 -2
  201. package/templates/template/README.md +47 -13
  202. package/templates/template/ai-instructions.md +15 -14
  203. package/templates/template/backend/functions/hello.ts +1 -1
  204. package/templates/template/backend/package.json +0 -2
  205. package/templates/template/{config → backend}/resources.ts +3 -3
  206. package/templates/template/backend/schema/authors.ts +11 -0
  207. package/templates/template/backend/schema/index.ts +29 -0
  208. package/templates/template/backend/schema/posts.ts +29 -0
  209. package/templates/template/backend/schema/tags.ts +9 -0
  210. package/templates/template/backend/schema/users.ts +32 -0
  211. package/templates/template/{config → backend}/storage.ts +4 -4
  212. package/templates/template/backend/tsconfig.json +15 -20
  213. package/templates/template/docker-compose.yml +3 -3
  214. package/templates/template/frontend/package.json +0 -2
  215. package/templates/template/frontend/src/App.tsx +10 -4
  216. package/templates/template/frontend/src/cms/authors.tsx +7 -0
  217. package/templates/template/frontend/src/cms/posts.tsx +27 -0
  218. package/templates/template/frontend/src/cms/tags.tsx +11 -0
  219. package/templates/template/frontend/src/cms/ui-config.json +3 -0
  220. package/templates/template/frontend/src/cms/users.tsx +54 -0
  221. package/templates/template/frontend/src/{virtual.d.ts → vite-env.d.ts} +0 -4
  222. package/templates/template/frontend/vite.config.ts +6 -2
  223. package/templates/template/gitignore +1 -1
  224. package/templates/template/package.json +1 -2
  225. package/templates/template/pnpm-workspace.yaml +0 -1
  226. package/templates/template/scripts/example.ts +3 -3
  227. package/templates/template/tsconfig.json +1 -1
  228. package/templates/views/AppView.tsx.tmpl +4 -4
  229. package/templates/views/EntityView.tsx.tmpl +3 -4
  230. package/dist/api-keys-Dfw5-9s1.js.map +0 -1
  231. package/dist/apps-MKQbgDtN.js.map +0 -1
  232. package/dist/build-BuKTnec8.js.map +0 -1
  233. package/dist/bundle-BAH4FCju.js.map +0 -1
  234. package/dist/cloud-DtADfWwn.js.map +0 -1
  235. package/dist/collection-drift-BKj_BoMq.js +0 -106
  236. package/dist/collection-drift-BKj_BoMq.js.map +0 -1
  237. package/dist/collections-dir-DlvDhime.js +0 -69
  238. package/dist/collections-dir-DlvDhime.js.map +0 -1
  239. package/dist/console-CdwIYOMV.js.map +0 -1
  240. package/dist/context-AXdAh-q8.js.map +0 -1
  241. package/dist/db-DBbKpjYX.js.map +0 -1
  242. package/dist/derive-ae9UOoOB.js.map +0 -1
  243. package/dist/dev-C93d4QIv.js.map +0 -1
  244. package/dist/dev-preflight-Cxv3TiD1.js.map +0 -1
  245. package/dist/doctor-BBPQUO2g.js.map +0 -1
  246. package/dist/eject-DABcDnPN.js.map +0 -1
  247. package/dist/fold-static-BWzxNn06.js.map +0 -1
  248. package/dist/generate-view-IFwCADvb.js.map +0 -1
  249. package/dist/generate_sdk-DNmNuFuW.js.map +0 -1
  250. package/dist/init-vL1DWOeC.js.map +0 -1
  251. package/dist/last-dev-database-DpW5dfoX.js +0 -2
  252. package/dist/manifest-BtzDy7KQ.js.map +0 -1
  253. package/dist/path-flags-DNvtEi2-.js +0 -92
  254. package/dist/path-flags-DNvtEi2-.js.map +0 -1
  255. package/dist/project-CasK56vN.js.map +0 -1
  256. package/dist/pull-DDMpsZ5r.js.map +0 -1
  257. package/dist/resolve-D647F1LA.js +0 -2
  258. package/dist/schema-DtLPsXbT.js.map +0 -1
  259. package/dist/schema-reconcile-DkArN9jF.js +0 -2
  260. package/dist/skills-CbwV6vw_.js.map +0 -1
  261. package/dist/status-BREvtzJm.js.map +0 -1
  262. package/dist/storage-CO9ouK76.js.map +0 -1
  263. package/dist/utils/collection-drift.d.ts +0 -27
  264. package/dist/utils/collections-dir.d.ts +0 -14
  265. package/dist/verify-Y3rWSgfA.js +0 -730
  266. package/dist/verify-Y3rWSgfA.js.map +0 -1
  267. package/templates/overlays/baas/config/index.ts +0 -24
  268. package/templates/overlays/baas/config/package.json +0 -30
  269. package/templates/template/config/cms.d.ts +0 -15
  270. package/templates/template/config/collections/authors.ts +0 -47
  271. package/templates/template/config/collections/index.ts +0 -44
  272. package/templates/template/config/collections/posts.ts +0 -94
  273. package/templates/template/config/collections/presets/blank/index.ts +0 -5
  274. package/templates/template/config/collections/presets/ecommerce/categories.ts +0 -42
  275. package/templates/template/config/collections/presets/ecommerce/index.ts +0 -31
  276. package/templates/template/config/collections/presets/ecommerce/orders.ts +0 -78
  277. package/templates/template/config/collections/presets/ecommerce/products.ts +0 -73
  278. package/templates/template/config/collections/tags.ts +0 -27
  279. package/templates/template/config/collections/users.ts +0 -149
  280. package/templates/template/config/frontend-assets.d.ts +0 -17
  281. package/templates/template/config/index.ts +0 -12
  282. package/templates/template/config/package.json +0 -30
  283. package/templates/template/config/tsconfig.json +0 -35
  284. /package/templates/eject/{config → backend}/resources.ts +0 -0
@@ -1,5 +1,6 @@
1
- import { p as requireProjectRoot, w as wantsHelp, x as parseCommandArgs } from "./project-CasK56vN.js";
2
- import { d as findBackendApp, g as resolveBackendPaths, o as ManifestError, p as loadManifest, x as writeManifest } from "./manifest-BtzDy7KQ.js";
1
+ import { a as wantsHelp, n as parseCommandArgs } from "./args-CaCcrYE1.js";
2
+ import { p as requireProjectRoot } from "./project-CLcF5i8c.js";
3
+ import { C as resolveBackendPaths, O as writeManifest, _ as findBackendApp, b as loadManifest, l as ManifestError } from "./manifest-C3uLDrrJ.js";
3
4
  import chalk from "chalk";
4
5
  import fs from "fs";
5
6
  import path from "path";
@@ -44,7 +45,12 @@ function findCliRoot(from) {
44
45
  * flag renamed on the interface left this list naming a block that no longer
45
46
  * exists, and the template kept switching on it.
46
47
  */
47
- var SHAPE_FLAGS = ["collections", "frontend"];
48
+ var SHAPE_FLAGS = [
49
+ "tables",
50
+ "frontend",
51
+ "storage",
52
+ "hooks"
53
+ ];
48
54
  /** Narrow a marker name to a flag, having checked it is one. */
49
55
  function isShapeFlag(name) {
50
56
  return SHAPE_FLAGS.includes(name);
@@ -59,12 +65,12 @@ function isShapeFlag(name) {
59
65
  * job in an ejected project. So both branches live in the file, marked with
60
66
  * lines that are comments in TypeScript, YAML and Dockerfiles alike:
61
67
  *
62
- * // {{#collections}}
68
+ * // {{#tables}}
63
69
  * import { tables } from "./schema.generated.js";
64
- * // {{/collections}}
65
- * // {{^collections}}
70
+ * // {{/tables}}
71
+ * // {{^tables}}
66
72
  * // No schema module: this project introspects the database.
67
- * // {{/collections}}
73
+ * // {{/tables}}
68
74
  *
69
75
  * `{{#name}}` keeps its block when the flag is on, `{{^name}}` when it is off,
70
76
  * and the marker lines themselves never reach the user. The template stays
@@ -109,8 +115,8 @@ var PAYLOAD = [
109
115
  overwrite: true
110
116
  },
111
117
  {
112
- from: "config/resources.ts",
113
- to: "config/resources.ts",
118
+ from: "backend/resources.ts",
119
+ to: "backend/resources.ts",
114
120
  overwrite: false
115
121
  },
116
122
  {
@@ -223,9 +229,12 @@ async function ejectCommand(rawArgs = []) {
223
229
  process.exit(1);
224
230
  }
225
231
  const payloadDir = path.join(cliRoot, "templates", "eject");
232
+ const paths = resolveBackendPaths(app, projectRoot);
226
233
  const shape = {
227
- collections: resolveBackendPaths(app, projectRoot).hasCollections,
228
- frontend: fs.existsSync(path.join(projectRoot, "frontend"))
234
+ tables: paths.hasTables,
235
+ frontend: fs.existsSync(path.join(projectRoot, "frontend")),
236
+ storage: fs.existsSync(path.join(projectRoot, paths.storage)),
237
+ hooks: fs.existsSync(path.join(projectRoot, paths.hooks))
229
238
  };
230
239
  const planned = [];
231
240
  const blocked = [];
@@ -296,8 +305,8 @@ async function ejectCommand(rawArgs = []) {
296
305
  console.log("");
297
306
  console.log(chalk.yellow(" You now own CORS, auth wiring, storage and shutdown. Platform runtime"));
298
307
  console.log(chalk.yellow(" upgrades no longer reach this project."));
299
- if (!shape.collections) {
300
- console.log(chalk.yellow(" This project declares no collections, so the entrypoint derives them"));
308
+ if (!shape.tables) {
309
+ console.log(chalk.yellow(" This project declares no tables, so the entrypoint derives them"));
301
310
  console.log(chalk.yellow(" from the live database, as the managed runtime did."));
302
311
  }
303
312
  console.log("");
@@ -323,12 +332,12 @@ function restoreBackendScripts(projectRoot) {
323
332
  }
324
333
  const scripts = parsed.scripts ?? {};
325
334
  parsed.main ??= "src/index.ts";
326
- scripts.dev ??= "tsx watch --include=\"../config/**/*\" --include=\"./functions/**/*\" src/index.ts";
327
- scripts.start ??= "node dist/backend/src/index.js";
335
+ scripts.dev ??= "tsx watch --include=\"./schema/**/*\" --include=\"./functions/**/*\" src/index.ts";
336
+ scripts.start ??= "node dist/src/index.js";
328
337
  parsed.scripts = scripts;
329
338
  fs.writeFileSync(packagePath, `${JSON.stringify(parsed, null, 4)}\n`, "utf8");
330
339
  }
331
340
  //#endregion
332
341
  export { ejectCommand };
333
342
 
334
- //# sourceMappingURL=eject-DABcDnPN.js.map
343
+ //# sourceMappingURL=eject-Bhzd6hgb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eject-Bhzd6hgb.js","names":[],"sources":["../src/commands/eject.ts"],"sourcesContent":["/**\n * CLI command: rebase eject\n *\n * The supported route from the managed runtime to a custom one.\n *\n * Without it, `runtime: \"custom\"` is a mode a user can only reach by\n * hand-writing an entrypoint they have never seen. The template used to solve\n * that by scaffolding `backend/src/index.ts` into every project — ~190 lines\n * configuring CORS, auth, cookies, storage and history, which the managed\n * runtime never loads. It was the most important-looking file in a new project\n * and editing it did nothing.\n *\n * So the file moved here. A managed project does not carry it; a project that\n * asks for it gets it together with the Dockerfile and the manifest change that\n * make it actually run.\n *\n * There is deliberately no `rebase uneject`. Going back is deleting two files\n * and editing one line, and a command that silently discarded a user's server\n * code would be worse than its absence.\n */\nimport chalk from \"chalk\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { RebaseBackendAppConfig } from \"@rebasepro/types\";\nimport { requireProjectRoot } from \"../utils/project\";\nimport { findBackendApp, loadManifest, ManifestError, resolveBackendPaths, writeManifest } from \"../manifest\";\nimport { parseCommandArgs, wantsHelp } from \"../utils/args\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\n/** Walk up to the package root, which holds `templates/`. */\nfunction findCliRoot(from: string): string | null {\n const root = path.parse(from).root;\n let dir = from;\n while (dir && dir !== root) {\n if (fs.existsSync(path.join(dir, \"templates\", \"eject\"))) return dir;\n dir = path.dirname(dir);\n }\n return null;\n}\n\n/**\n * The ways one project's payload differs from another's.\n *\n * None is a flag: each is read from the project. `--headless` has no\n * `backend/schema`, no `backend/src/schema.generated.ts` and no `frontend/`,\n * so a payload that assumes them emits an entrypoint importing files that are\n * not there and a Dockerfile whose first `COPY` fails.\n */\ninterface ProjectShape {\n /**\n * Tables declared in code: the schema directory has an index. Without\n * them the server derives its API from the live database instead — the\n * same signal `rebase build` reads.\n */\n tables: boolean;\n /** A `frontend` workspace for the image to build and the entrypoint to serve. */\n frontend: boolean;\n /** `backend/storage.ts`, exporting `storageAuthorize`. */\n storage: boolean;\n /** `backend/hooks.ts`, exporting the global table `hooks`. */\n hooks: boolean;\n}\n\n/**\n * The block names the payload may switch on. A typo has to be an error.\n *\n * Typed as keys of {@link ProjectShape}, which is what makes that true: `as\n * const` alone gave these two string literals and tied them to nothing, so a\n * flag renamed on the interface left this list naming a block that no longer\n * exists, and the template kept switching on it.\n */\nconst SHAPE_FLAGS: readonly (keyof ProjectShape)[] = [\"tables\", \"frontend\", \"storage\", \"hooks\"];\n\n/** Narrow a marker name to a flag, having checked it is one. */\nfunction isShapeFlag(name: string): name is keyof ProjectShape {\n return (SHAPE_FLAGS as readonly string[]).includes(name);\n}\n\n/**\n * Render one payload file for this project.\n *\n * The payload is one set of files rather than one per flavour, because the\n * flavours differ by about a dozen lines and two copies of a 230-line\n * entrypoint are how copies drift — the payload had already drifted from\n * `app/backend/src/index.ts` over `cronsDir`, which silently stopped every cron\n * job in an ejected project. So both branches live in the file, marked with\n * lines that are comments in TypeScript, YAML and Dockerfiles alike:\n *\n * // {{#tables}}\n * import { tables } from \"./schema.generated.js\";\n * // {{/tables}}\n * // {{^tables}}\n * // No schema module: this project introspects the database.\n * // {{/tables}}\n *\n * `{{#name}}` keeps its block when the flag is on, `{{^name}}` when it is off,\n * and the marker lines themselves never reach the user. The template stays\n * valid TypeScript with every marker line removed, which is the flavour a\n * typechecker would see.\n */\nexport function renderPayload(contents: string, shape: ProjectShape, projectName: string): string {\n const out: string[] = [];\n let open: { name: string; keep: boolean } | null = null;\n\n for (const line of contents.split(\"\\n\")) {\n const marker = /^\\s*(?:\\/\\/|#)\\s*\\{\\{([#^/])([A-Za-z]+)\\}\\}\\s*$/.exec(line);\n if (!marker) {\n if (!open || open.keep) out.push(line);\n continue;\n }\n const [, kind, name] = marker;\n if (kind === \"/\") {\n if (!open || open.name !== name) {\n throw new Error(`Eject template: {{/${name}}} does not close an open block.`);\n }\n open = null;\n continue;\n }\n if (open) throw new Error(`Eject template: {{${kind}${name}}} inside an open ${open.name} block.`);\n if (!isShapeFlag(name)) {\n throw new Error(`Eject template: unknown block {{${kind}${name}}}.`);\n }\n // `shape[name]` directly: the check above narrows `name` to a key of\n // `ProjectShape`, which is what the double cast to `Record<string,\n // boolean>` on the shape was standing in for — and that cast also meant\n // nothing checked that the block names and the interface agree.\n open = { name,\nkeep: kind === \"#\" ? shape[name] === true : shape[name] !== true };\n }\n\n if (open) throw new Error(`Eject template: {{#${open.name}}} was never closed.`);\n // A replacer function: the name is read from package.json unchecked, and a\n // replacement string would expand any `$&`, `$'` or `$$` in it.\n return out.join(\"\\n\").replace(/\\{\\{PROJECT_NAME\\}\\}/g, () => projectName);\n}\n\n/** Files the eject payload contributes, as `<source> → <destination>`. */\nconst PAYLOAD: { from: string; to: string; overwrite: boolean }[] = [\n // The entrypoint IS the point of ejecting, so it replaces whatever is\n // there — but only with `--force`, and only after keeping the old file as\n // `.bak`. `runtime: \"custom\"` (the guard below) means \"already ejected\",\n // not \"nobody wrote a server here\": a managed project can have a\n // hand-written `backend/src/index.ts` that `rebase dev` has been running.\n { from: \"backend/src/index.ts\",\nto: \"backend/src/index.ts\",\noverwrite: true },\n { from: \"backend/src/env.ts\",\nto: \"backend/src/env.ts\",\noverwrite: true },\n // The declarations the emitted server imports. Never overwritten — a\n // project that already declares its resources owns that file, and replacing\n // it would silently drop every bucket and database it named. Written when\n // absent because the entrypoint imports it unconditionally: an ejected\n // server that cannot resolve its own resources does not start.\n { from: \"backend/resources.ts\",\nto: \"backend/resources.ts\",\noverwrite: false },\n // Never overwritten: a Dockerfile someone already wrote is theirs, and so is\n // a compose file they have edited. The scaffolded `docker-compose.yml` is\n // deliberately left alone — it runs the managed shape, and going back should\n // stay a one-line change rather than a restore from git.\n { from: \"Dockerfile\",\nto: \"Dockerfile\",\noverwrite: false },\n { from: \"docker-compose.custom.yml\",\nto: \"docker-compose.custom.yml\",\noverwrite: false }\n];\n\n/**\n * The project's name, for the `{{PROJECT_NAME}}` the payload carries.\n *\n * Falls back to the directory name — a compose project name is cosmetic, and a\n * missing or unreadable package.json is not a reason to refuse to eject.\n */\nfunction projectNameOf(projectRoot: string): string {\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(projectRoot, \"package.json\"), \"utf8\"));\n if (typeof pkg.name === \"string\" && pkg.name.trim()) return pkg.name.trim();\n } catch {\n // fall through\n }\n return path.basename(projectRoot);\n}\n\nfunction printHelp(): void {\n console.log(`\n${chalk.bold(\"rebase eject\")} — take ownership of the server process\n\nWrites the backend entrypoint and a Dockerfile into this project, and flips its\nbackend to ${chalk.cyan('runtime: \"custom\"')}. From then on this repository builds its own\nimage: platform runtime upgrades no longer reach it, and CORS, auth wiring,\nstorage and shutdown become yours to configure.\n\n${chalk.bold(\"Usage\")}\n rebase eject [app] Take ownership of the server process\n\n${chalk.bold(\"Options\")}\n --dry-run List what would change, and change nothing\n --force Replace an existing backend/src/index.ts or\n env.ts, keeping the current file as <name>.bak\n -h, --help Show this help\n`.trim());\n}\n\nexport async function ejectCommand(rawArgs: string[] = []): Promise<void> {\n if (wantsHelp(rawArgs)) {\n printHelp();\n return;\n }\n\n const { flags: args, positionals } = parseCommandArgs({\n spec: {\n \"--dry-run\": Boolean,\n \"--force\": Boolean\n },\n rawArgs,\n commandWords: 1,\n command: \"eject\",\n maxPositionals: 1\n });\n\n const projectRoot = requireProjectRoot();\n const dryRun = Boolean(args[\"--dry-run\"]);\n const force = Boolean(args[\"--force\"]);\n // Strict parsing rejects an undeclared flag rather than filing it under the\n // positionals, so the first one is the app — there is nothing to filter out.\n const requested = positionals[0];\n\n let loaded;\n try {\n loaded = loadManifest(projectRoot);\n } catch (err) {\n if (err instanceof ManifestError) {\n console.error(chalk.red(`✗ ${err.message}`));\n for (const issue of err.issues) {\n console.error(chalk.dim(` ${issue.path}: ${issue.message}`));\n }\n process.exit(1);\n }\n throw err;\n }\n\n const { manifest } = loaded;\n\n let appName: string;\n let app: RebaseBackendAppConfig;\n\n if (requested) {\n const declared = manifest.apps[requested];\n if (!declared) {\n console.error(chalk.red(`✗ No app named \"${requested}\" in rebase.json.`));\n console.error(chalk.dim(` Declared: ${Object.keys(manifest.apps).join(\", \") || \"(none)\"}`));\n process.exit(1);\n }\n if (declared.type !== \"backend\") {\n // Ejecting is about who runs the server. A static app has no server.\n console.error(chalk.red(`✗ \"${requested}\" is a ${declared.type} app — only a backend can be ejected.`));\n process.exit(1);\n }\n appName = requested;\n app = declared;\n } else {\n const backend = findBackendApp(manifest);\n if (!backend) {\n console.error(chalk.red(\"✗ This repository declares no backend app.\"));\n console.error(chalk.dim(\" Only the repository that declares the backend chooses its runtime.\"));\n process.exit(1);\n }\n appName = backend.name;\n app = backend.app;\n }\n\n if (app.runtime === \"custom\") {\n console.error(chalk.red(`✗ \"${appName}\" is already ejected — it declares runtime: \"custom\".`));\n console.error(chalk.dim(` Its entrypoint is ${app.dockerfile ?? \"Dockerfile\"} and backend/src/index.ts.`));\n process.exit(1);\n }\n\n const cliRoot = findCliRoot(__dirname);\n if (!cliRoot) {\n console.error(chalk.red(\"✗ Could not locate the eject templates. Reinstall @rebasepro/cli.\"));\n process.exit(1);\n }\n const payloadDir = path.join(cliRoot!, \"templates\", \"eject\");\n\n // What the payload has to look like here. Read from the project rather than\n // asked for: `--headless` left no tables and no frontend, and an\n // entrypoint importing either would not compile.\n const paths = resolveBackendPaths(app, projectRoot);\n const shape: ProjectShape = {\n tables: paths.hasTables,\n frontend: fs.existsSync(path.join(projectRoot, \"frontend\")),\n storage: fs.existsSync(path.join(projectRoot, paths.storage)),\n hooks: fs.existsSync(path.join(projectRoot, paths.hooks))\n };\n\n // Decide everything before writing anything, so --dry-run and the real run\n // report the same list and a mid-way failure cannot leave a half-ejected\n // project.\n const planned: { to: string; action: \"write\" | \"keep\" | \"overwrite\" }[] = [];\n const blocked: string[] = [];\n for (const file of PAYLOAD) {\n const source = path.join(payloadDir, file.from);\n if (!fs.existsSync(source)) {\n console.error(chalk.red(`✗ The eject template is missing ${file.from}. Reinstall @rebasepro/cli.`));\n process.exit(1);\n }\n const exists = fs.existsSync(path.join(projectRoot, file.to));\n if (exists && file.overwrite && !force) blocked.push(file.to);\n planned.push({\n to: file.to,\n action: !exists ? \"write\" : file.overwrite ? \"overwrite\" : \"keep\"\n });\n }\n\n if (blocked.length > 0) {\n // A managed backend never loads `backend/src/index.ts`, but `rebase dev`\n // does — it picks the entrypoint by file existence — so this file is very\n // often a server someone is running and editing. Replacing it without\n // being asked is the one unrecoverable thing this command could do.\n console.error(chalk.red(\"✗ Ejecting would replace a file this project already has:\"));\n for (const item of blocked) console.error(chalk.red(` ${item}`));\n console.error(chalk.dim(\" Eject writes its own entrypoint — it does not adopt yours.\"));\n console.error(chalk.dim(\" Move the file aside, or re-run with --force, which keeps the current\"));\n console.error(chalk.dim(\" contents as <name>.bak.\"));\n process.exit(1);\n }\n\n if (dryRun) {\n console.log(chalk.bold(`Would eject \"${appName}\" to a custom runtime:`));\n console.log(\"\");\n for (const item of planned) {\n if (item.action === \"write\") console.log(` ${chalk.green(\"write\")} ${item.to}`);\n else if (item.action === \"overwrite\") {\n console.log(` ${chalk.yellow(\"overwrite\")} ${item.to} ${chalk.dim(`(kept as ${item.to}.bak)`)}`);\n } else console.log(` ${chalk.dim(\"keep\")} ${item.to} ${chalk.dim(\"(already exists)\")}`);\n }\n console.log(` ${chalk.green(\"write\")} rebase.json ${chalk.dim('(runtime: \"custom\")')}`);\n // Not part of the payload table, but it is changed on the real run, and\n // a dry run's whole purpose is to enumerate what changes.\n if (fs.existsSync(path.join(projectRoot, \"backend\", \"package.json\"))) {\n console.log(` ${chalk.green(\"write\")} backend/package.json ${chalk.dim(\"(main, dev and start scripts)\")}`);\n }\n console.log(\"\");\n console.log(chalk.dim(\"Nothing was changed.\"));\n return;\n }\n\n const projectName = projectNameOf(projectRoot);\n const backups: string[] = [];\n for (const [index, file] of PAYLOAD.entries()) {\n if (planned[index].action === \"keep\") continue;\n const destination = path.join(projectRoot, file.to);\n if (planned[index].action === \"overwrite\") {\n fs.copyFileSync(destination, `${destination}.bak`);\n backups.push(`${file.to}.bak`);\n }\n fs.mkdirSync(path.dirname(destination), { recursive: true });\n const contents = renderPayload(\n fs.readFileSync(path.join(payloadDir, file.from), \"utf8\"),\n shape,\n projectName\n );\n fs.writeFileSync(destination, contents, \"utf8\");\n }\n\n const dockerfile = app.dockerfile ?? \"Dockerfile\";\n manifest.apps[appName] = {\n ...app,\n runtime: \"custom\",\n dockerfile,\n port: app.port ?? 8080\n };\n writeManifest(projectRoot, manifest);\n\n // The backend workspace stops being a package the runtime reads and becomes\n // one that is run. Its scripts have to say so, or `npm start` in the image\n // has nothing to call.\n restoreBackendScripts(projectRoot);\n\n console.log(\"\");\n console.log(chalk.green(`✓ Ejected \"${appName}\" to a custom runtime.`));\n console.log(\"\");\n console.log(` ${chalk.cyan(\"backend/src/index.ts\".padEnd(26))} your entrypoint — the runtime no longer boots the bundle`);\n console.log(` ${chalk.cyan(\"backend/src/env.ts\".padEnd(26))} the environment it reads`);\n console.log(` ${chalk.cyan(dockerfile.padEnd(26))} your image`);\n console.log(` ${chalk.cyan(\"docker-compose.custom.yml\".padEnd(26))} runs it`);\n console.log(` ${chalk.cyan(\"rebase.json\".padEnd(26))} runtime: custom`);\n for (const backup of backups) {\n console.log(` ${chalk.cyan(backup.padEnd(26))} what was there before`);\n }\n console.log(\"\");\n console.log(chalk.yellow(\" You now own CORS, auth wiring, storage and shutdown. Platform runtime\"));\n console.log(chalk.yellow(\" upgrades no longer reach this project.\"));\n if (!shape.tables) {\n console.log(chalk.yellow(\" This project declares no tables, so the entrypoint derives them\"));\n console.log(chalk.yellow(\" from the live database, as the managed runtime did.\"));\n }\n console.log(\"\");\n console.log(chalk.dim(` ${chalk.cyan(\"docker compose -f docker-compose.custom.yml up --build\")}`));\n console.log(chalk.dim(\" docker-compose.yml is untouched — it still runs the managed shape if you go back.\"));\n console.log(\"\");\n}\n\n/**\n * Point the backend workspace's scripts at the entrypoint that now exists.\n *\n * A managed project's backend package deliberately declares no `main` and no\n * `start`: there is no entrypoint to name. Ejecting creates one.\n */\nfunction restoreBackendScripts(projectRoot: string): void {\n const packagePath = path.join(projectRoot, \"backend\", \"package.json\");\n if (!fs.existsSync(packagePath)) return;\n\n let parsed: Record<string, unknown>;\n try {\n parsed = JSON.parse(fs.readFileSync(packagePath, \"utf8\"));\n } catch {\n // A malformed package.json is the user's to fix, and refusing to finish\n // the eject over it would leave the project half-changed.\n console.log(chalk.yellow(\" ⚠ backend/package.json is not valid JSON — its scripts were left alone.\"));\n return;\n }\n\n const scripts = (parsed.scripts ?? {}) as Record<string, string>;\n parsed.main ??= \"src/index.ts\";\n scripts.dev ??= 'tsx watch --include=\"./schema/**/*\" --include=\"./functions/**/*\" src/index.ts';\n scripts.start ??= \"node dist/src/index.js\";\n parsed.scripts = scripts;\n\n fs.writeFileSync(packagePath, `${JSON.stringify(parsed, null, 4)}\\n`, \"utf8\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC;;AAG7D,SAAS,YAAY,MAA6B;CAC9C,MAAM,OAAO,KAAK,MAAM,IAAI,CAAC,CAAC;CAC9B,IAAI,MAAM;CACV,OAAO,OAAO,QAAQ,MAAM;EACxB,IAAI,GAAG,WAAW,KAAK,KAAK,KAAK,aAAa,OAAO,CAAC,GAAG,OAAO;EAChE,MAAM,KAAK,QAAQ,GAAG;CAC1B;CACA,OAAO;AACX;;;;;;;;;AAiCA,IAAM,cAA+C;CAAC;CAAU;CAAY;CAAW;AAAO;;AAG9F,SAAS,YAAY,MAA0C;CAC3D,OAAQ,YAAkC,SAAS,IAAI;AAC3D;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,cAAc,UAAkB,OAAqB,aAA6B;CAC9F,MAAM,MAAgB,CAAC;CACvB,IAAI,OAA+C;CAEnD,KAAK,MAAM,QAAQ,SAAS,MAAM,IAAI,GAAG;EACrC,MAAM,SAAS,kDAAkD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AO,EAAE,CAAC,EAAE,iBAAiB;CACvE,KAAK,MAAM,UAAU,SACjB,QAAQ,IAAI,KAAK,MAAM,KAAK,OAAO,OAAO,EAAE,CAAC,EAAE,uBAAuB;CAE1E,QAAQ,IAAI,EAAE;CACd,QAAQ,IAAI,MAAM,OAAO,yEAAyE,CAAC;CACnG,QAAQ,IAAI,MAAM,OAAO,0CAA0C,CAAC;CACpE,IAAI,CAAC,MAAM,QAAQ;EACf,QAAQ,IAAI,MAAM,OAAO,mEAAmE,CAAC;EAC7F,QAAQ,IAAI,MAAM,OAAO,uDAAuD,CAAC;CACrF;CACA,QAAQ,IAAI,EAAE;CACd,QAAQ,IAAI,MAAM,IAAI,KAAK,MAAM,KAAK,wDAAwD,GAAG,CAAC;CAClG,QAAQ,IAAI,MAAM,IAAI,qFAAqF,CAAC;CAC5G,QAAQ,IAAI,EAAE;AAClB;;;;;;;AAQA,SAAS,sBAAsB,aAA2B;CACtD,MAAM,cAAc,KAAK,KAAK,aAAa,WAAW,cAAc;CACpE,IAAI,CAAC,GAAG,WAAW,WAAW,GAAG;CAEjC,IAAI;CACJ,IAAI;EACA,SAAS,KAAK,MAAM,GAAG,aAAa,aAAa,MAAM,CAAC;CAC5D,QAAQ;EAGJ,QAAQ,IAAI,MAAM,OAAO,2EAA2E,CAAC;EACrG;CACJ;CAEA,MAAM,UAAW,OAAO,WAAW,CAAC;CACpC,OAAO,SAAS;CAChB,QAAQ,QAAQ;CAChB,QAAQ,UAAU;CAClB,OAAO,UAAU;CAEjB,GAAG,cAAc,aAAa,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,EAAE,KAAK,MAAM;AAChF"}
@@ -1,5 +1,6 @@
1
- import { u as compareMountOrder, v as staticAppAddress } from "./manifest-BtzDy7KQ.js";
2
- import { C as toolStdio, y as foldStaticIntoBundle } from "./bundle-BAH4FCju.js";
1
+ import { T as staticAppAddress, g as compareMountOrder } from "./manifest-C3uLDrrJ.js";
2
+ import { T as toolStdio, x as foldStaticIntoBundle } from "./bundle-DgILeA5b.js";
3
+ import { i as assertBackendGuarded } from "./backend-guard-C0mVkXBw.js";
3
4
  import chalk from "chalk";
4
5
  import fs from "fs";
5
6
  import path from "path";
@@ -162,6 +163,7 @@ async function foldFrontendIntoBundle(options) {
162
163
  const { apps, skipped } = foldableApps(manifest);
163
164
  for (const { reason } of skipped) log(chalk.yellow(` ⚠ ${reason}`));
164
165
  if (apps.length === 0) return [];
166
+ await assertBackendGuarded(projectRoot);
165
167
  const outcomes = [];
166
168
  for (const app of apps) {
167
169
  if (app.build && !skipBuild && !options.builtApps?.has(app.name)) {
@@ -198,4 +200,4 @@ async function foldFrontendIntoBundle(options) {
198
200
  //#endregion
199
201
  export { staticBuildEnv as i, foldFrontendIntoBundle as n, foldableApps as r, assertBuiltForPath as t };
200
202
 
201
- //# sourceMappingURL=fold-static-BWzxNn06.js.map
203
+ //# sourceMappingURL=fold-static-CKewnAPX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fold-static-CKewnAPX.js","names":[],"sources":["../src/fold-static.ts"],"sourcesContent":["/**\n * Folding a project's static apps into its backend bundle.\n *\n * Shared by `rebase build` and `rebase cloud deploy` deliberately. It lived in\n * the build *command* first, and `deploy` rebuilds the bundle itself — so a\n * deploy silently produced a bundle without the frontend, packed 164 KB where\n * 39 MB was expected, and the site 404'd on the managed runtime exactly as if\n * folding had never been written. Two callers building the same artefact must\n * share the step that completes it.\n *\n * Why fold at all: `bootFromBundle` serves static apps from `entry.static`\n * behind `REBASE_SERVE_STATIC` (default on). A managed tenant runs one pod, so\n * putting the built assets in the bundle gives it the shape a custom container\n * already had — site at `/`, admin at `/admin`, API at `/api` — which is the\n * only honest baseline for calling the managed runtime a drop-in replacement.\n *\n * **Every** static app is folded, each at its declared path. Folding used to\n * pick exactly one and refuse when it found two, which meant a project with a\n * site and an admin panel deployed with neither.\n */\nimport fs from \"fs\";\nimport path from \"path\";\nimport { execa } from \"execa\";\nimport { assertBackendGuarded } from \"./utils/backend-guard\";\nimport chalk from \"chalk\";\nimport { foldStaticIntoBundle } from \"./bundle\";\nimport { compareMountOrder, staticAppAddress } from \"./manifest\";\nimport { toolStdio } from \"./utils/tool-stdio\";\n\n/** The apps section of a project manifest, as much of it as folding needs. */\nexport interface FoldableManifest {\n apps?: Record<string, {\n type?: string;\n build?: string;\n output?: string;\n path?: string;\n spa?: boolean;\n cms?: string;\n }>;\n}\n\nexport interface FoldOptions {\n projectRoot: string;\n manifest: FoldableManifest;\n /** The backend bundle directory, already written. */\n bundleDir: string;\n /** Skip running each app's own build command; fold what is already built. */\n skipBuild?: boolean;\n /**\n * The static apps already built in this run, shared with `buildAssetApp`.\n * An app named here is not built again; an app built here is added. One\n * `rebase build` used to run the admin's `vite build && tsc` twice — once\n * to fold it, once for its own static bundle — with the same command, the\n * same environment and the same output directory.\n */\n builtApps?: Set<string>;\n log?: (message: string) => void;\n /** Send each app's build output to stderr: the caller's stdout carries a result. See `toolStdio`. */\n quietStdout?: boolean;\n}\n\nexport interface FoldOutcome {\n appName: string;\n fileCount: number;\n /** Public base path this app was folded in at. */\n path: string;\n /** The one hostname it answers on, when its `path` names one. */\n host?: string;\n}\n\n/** A static app as folding sees it, with the manifest's defaults applied. */\nexport interface FoldableApp {\n name: string;\n build?: string;\n output?: string;\n /**\n * Public base path, defaulted to `/`. Always a path: when the manifest's\n * `path` is a URL, this is the part after the hostname, which is what the\n * app is built for and mounted at.\n */\n path: string;\n /** The one hostname this app answers on, when its `path` is a URL. */\n host?: string;\n /** SPA fallback, defaulted to `true`. */\n spa: boolean;\n /** Where this app mounts the Rebase CMS, if it does. */\n cms?: string;\n}\n\n/**\n * Every static app in the manifest, in mount order.\n *\n * Longest path first, so the `/`-rooted app is registered last — its catch-all\n * would otherwise claim its siblings' URLs — and, at an equal path, the app with\n * a hostname before the one without (see `compareMountOrder`). Pure, so the\n * ordering is testable without a filesystem.\n */\nexport function foldableApps(manifest: FoldableManifest): {\n apps: FoldableApp[];\n /** Apps that cannot be folded, and why. */\n skipped: { name: string; reason: string }[];\n} {\n const apps: FoldableApp[] = [];\n const skipped: { name: string; reason: string }[] = [];\n\n for (const [name, app] of Object.entries(manifest.apps ?? {})) {\n if (app?.type !== \"static\") continue;\n if (!app.output) {\n skipped.push({ name,\nreason: `\"${name}\" declares no output directory — not folded in.` });\n continue;\n }\n const { host, path: appPath } = staticAppAddress(name, app);\n apps.push({\n name,\n build: app.build,\n output: app.output,\n path: appPath,\n ...(host ? { host } : {}),\n spa: app.spa ?? true,\n cms: app.cms\n });\n }\n\n apps.sort(compareMountOrder);\n return { apps,\nskipped };\n}\n\n/**\n * Assert a built app's assets are actually rooted at the path it is served from.\n *\n * An app mounted at `/admin` but built with Vite's default `base: \"/\"` emits\n * `<script src=\"/assets/index-a1b2.js\">`. The server serves `index.html` fine\n * and 404s every asset: a blank page, no server error, nothing in the logs. It\n * is the single most expensive silent failure in this design, so it is a build\n * error rather than a runtime surprise.\n *\n * Only `<script src>` and `<link href>` are inspected — those are what a bundler\n * rewrites through `base`. Author-written anchors and canonical URLs are not\n * evidence of a misbuild.\n */\nexport function assertBuiltForPath(\n indexHtml: string,\n basePath: string,\n appName: string\n): void {\n if (basePath === \"/\") return;\n\n const offenders: string[] = [];\n const pattern = /<(?:script|link)\\b[^>]*?\\b(?:src|href)\\s*=\\s*[\"']([^\"']+)[\"']/gi;\n for (const match of indexHtml.matchAll(pattern)) {\n const ref = match[1];\n // Relative, or on another host: `//cdn.example.com/x.js` starts with a\n // slash and is no more rooted at this app's path than `https://` is.\n if (!ref.startsWith(\"/\") || ref.startsWith(\"//\")) continue;\n if (ref === `${basePath}` || ref.startsWith(`${basePath}/`)) continue;\n offenders.push(ref);\n }\n\n if (offenders.length === 0) return;\n\n throw new Error(\n `\"${appName}\" is declared at ${basePath} but its build emitted assets rooted at /.\\n` +\n ` index.html references: ${offenders.slice(0, 3).join(\", \")}\\n` +\n \" The app would load a blank page. Set `base` from REBASE_APP_BASE in its\\n\" +\n \" build config — see docs/apps-and-runtimes.md §4.2.\"\n );\n}\n\n/**\n * The environment every static app is built with, wherever that build is driven from.\n *\n * Shared because there are two drivers — `foldFrontendIntoBundle` here, and\n * `buildAssetApp` in `build.ts` for a standalone `type: \"static\"` app — and they\n * had already drifted: the path variables were duplicated into both, so a fix\n * applied to one shipped a bundle built the old way from the other. One function\n * makes that impossible rather than merely unlikely.\n *\n * ## REBASE_APP_*\n *\n * The declared path is a build-time input, not only a serving concern: Vite\n * reads `base` from REBASE_APP_BASE, and the trailing slash is that field's\n * convention. See `assertBuiltForPath`.\n *\n * For an app declared at a URL these carry the path part only — `/` for\n * `https://admin.example.com`. The hostname is where the platform routes the\n * app, not something its assets should name: an absolute `base` would pin\n * every script to production, so `vite preview` and any other hostname the app\n * is opened on would load it from somewhere else.\n *\n * ## NODE_ENV\n *\n * A built app is a production artifact by construction, so build it as one. Not\n * a formality: the scaffold's `.env` carries `NODE_ENV=development` for the dev\n * backend, and Vite's `loadEnv` promotes a `NODE_ENV` found in an env file into\n * the build unless the environment already sets one. So `rebase build` and\n * `rebase cloud deploy` shipped a *development* bundle — `import.meta.env.DEV\n * === true`, development React, dev-only branches live — from commands whose\n * whole purpose is to produce something deployable. Setting it here is what\n * closes it: Vite consults the env file's NODE_ENV only when `process.env`\n * has none.\n *\n * ## VITE_API_URL\n *\n * An app served by the backend it talks to has its API on its own origin by\n * construction, so a baked-in absolute URL can only be wrong. It was: that same\n * `.env` carries `VITE_API_URL=http://localhost:3001` and\n * `frontend/vite.config.ts` reads the project root via `envDir: \"..\"`, so a\n * stock deploy shipped a site whose every request went to whoever ran the build\n * — passing every server-side health check on the way out. Blanking it here\n * fixes the bundle even for a project whose `.env` predates the `init` fix, or\n * was written by hand. Empty is the right value rather than a missing one: the\n * client falls back to `window.location.origin`, which keeps working when a\n * custom domain is added.\n *\n * Vite prioritises `process.env.VITE_*` over `.env` files, so an explicit\n * `VITE_API_URL=https://api.example.com rebase cloud deploy` still wins — the\n * cross-origin escape hatch stays open, it just has to be deliberate. Nothing on\n * this path loads the project `.env` into `process.env`, so a value inherited\n * here really was set by the caller.\n */\nexport function staticBuildEnv(appPath: string, appName: string): Record<string, string> {\n return {\n REBASE_APP_PATH: appPath,\n REBASE_APP_BASE: appPath === \"/\" ? \"/\" : `${appPath}/`,\n REBASE_APP_NAME: appName,\n NODE_ENV: \"production\",\n VITE_API_URL: process.env.VITE_API_URL ?? \"\"\n };\n}\n\n/**\n * Build the project's static apps and fold them into the backend bundle.\n *\n * Throws rather than exiting, so the caller decides whether a missing frontend\n * should fail its command — a `build` may reasonably want to stop, and so should\n * a deploy, but that is not this function's call to make.\n */\nexport async function foldFrontendIntoBundle(options: FoldOptions): Promise<FoldOutcome[]> {\n const { projectRoot, manifest, bundleDir, skipBuild } = options;\n const log = options.log ?? ((m: string) => console.log(m));\n\n const { apps, skipped } = foldableApps(manifest);\n for (const { reason } of skipped) log(chalk.yellow(` ⚠ ${reason}`));\n if (apps.length === 0) return [];\n\n // A frontend that builds without the backend guard can ship backend code.\n // `rebase build` refused it already; a cloud deploy rebuilds through here.\n await assertBackendGuarded(projectRoot);\n\n const outcomes: FoldOutcome[] = [];\n\n for (const app of apps) {\n if (app.build && !skipBuild && !options.builtApps?.has(app.name)) {\n await execa(app.build, {\n cwd: projectRoot,\n stdio: toolStdio(options.quietStdout),\n shell: true,\n env: staticBuildEnv(app.path, app.name)\n });\n options.builtApps?.add(app.name);\n }\n\n const assetsDir = path.join(projectRoot, app.output as string);\n if (!fs.existsSync(assetsDir)) {\n // Exited 0 and produced nothing where the manifest says it should.\n // Folding that ships an empty site, which from the outside is\n // indistinguishable from a broken deploy.\n throw new Error(\n `\"${app.name}\" declared output \"${app.output}\" does not exist after building — ` +\n \"the bundle would ship without a frontend.\"\n );\n }\n\n const indexHtml = path.join(assetsDir, \"index.html\");\n if (fs.existsSync(indexHtml)) {\n assertBuiltForPath(fs.readFileSync(indexHtml, \"utf8\"), app.path, app.name);\n }\n\n const { fileCount } = foldStaticIntoBundle({\n bundleDir,\n assetsDir,\n appName: app.name,\n path: app.path,\n host: app.host,\n spa: app.spa,\n cms: app.cms\n });\n outcomes.push({ appName: app.name,\nfileCount,\npath: app.path,\n...(app.host ? { host: app.host } : {}) });\n }\n\n return outcomes;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,SAAgB,aAAa,UAI3B;CACE,MAAM,OAAsB,CAAC;CAC7B,MAAM,UAA8C,CAAC;CAErD,KAAK,MAAM,CAAC,MAAM,QAAQ,OAAO,QAAQ,SAAS,QAAQ,CAAC,CAAC,GAAG;EAC3D,IAAI,KAAK,SAAS,UAAU;EAC5B,IAAI,CAAC,IAAI,QAAQ;GACb,QAAQ,KAAK;IAAE;IAC3B,QAAQ,IAAI,KAAK;GAAiD,CAAC;GACvD;EACJ;EACA,MAAM,EAAE,MAAM,MAAM,YAAY,iBAAiB,MAAM,GAAG;EAC1D,KAAK,KAAK;GACN;GACA,OAAO,IAAI;GACX,QAAQ,IAAI;GACZ,MAAM;GACN,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;GACvB,KAAK,IAAI,OAAO;GAChB,KAAK,IAAI;EACb,CAAC;CACL;CAEA,KAAK,KAAK,iBAAiB;CAC3B,OAAO;EAAE;EACb;CAAQ;AACR;;;;;;;;;;;;;;AAeA,SAAgB,mBACZ,WACA,UACA,SACI;CACJ,IAAI,aAAa,KAAK;CAEtB,MAAM,YAAsB,CAAC;CAE7B,KAAK,MAAM,SAAS,UAAU,SAAS,iEAAO,GAAG;EAC7C,MAAM,MAAM,MAAM;EAGlB,IAAI,CAAC,IAAI,WAAW,GAAG,KAAK,IAAI,WAAW,IAAI,GAAG;EAClD,IAAI,QAAQ,GAAG,cAAc,IAAI,WAAW,GAAG,SAAS,EAAE,GAAG;EAC7D,UAAU,KAAK,GAAG;CACtB;CAEA,IAAI,UAAU,WAAW,GAAG;CAE5B,MAAM,IAAI,MACN,IAAI,QAAQ,mBAAmB,SAAS,yEACV,UAAU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,IAAI,IAAI;EAG7E,MAAM,EAAE,cAAc,qBAAqB;GACvC;GACA;GACA,SAAS,IAAI;GACb,MAAM,IAAI;GACV,MAAM,IAAI;GACV,KAAK,IAAI;GACT,KAAK,IAAI;EACb,CAAC;EACD,SAAS,KAAK;GAAE,SAAS,IAAI;GACrC;GACA,MAAM,IAAI;GACV,GAAI,IAAI,OAAO,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;EAAG,CAAC;CACrC;CAEA,OAAO;AACX"}
@@ -1,16 +1,19 @@
1
- import { b as UsageError, p as requireProjectRoot, w as wantsHelp, x as parseCommandArgs } from "./project-CasK56vN.js";
2
- import { l as cmsMountOf, p as loadManifest } from "./manifest-BtzDy7KQ.js";
3
- import { resolveCollectionsDir } from "./collections-dir-DlvDhime.js";
1
+ import { a as wantsHelp, n as parseCommandArgs, t as UsageError } from "./args-CaCcrYE1.js";
2
+ import { p as requireProjectRoot } from "./project-CLcF5i8c.js";
3
+ import { b as loadManifest, h as cmsMountOf } from "./manifest-C3uLDrrJ.js";
4
+ import { n as resolveSchemaDir } from "./schema-dir-Cd1kvYbf.js";
5
+ import { t as declaredTables } from "./schema-text-CpNrsuMe.js";
4
6
  import chalk from "chalk";
5
7
  import fs from "fs";
6
8
  import path from "path";
7
9
  import { fileURLToPath } from "url";
10
+ import { tableIdentifier } from "@rebasepro/common";
8
11
  //#region src/commands/generate-view.ts
9
12
  /**
10
13
  * `rebase generate view <slug>` — scaffold a custom admin screen and register it.
11
14
  *
12
15
  * Most back-office screens are a table, a form or a board, and the admin draws
13
- * those from the collection. The rest — a dispatch board, a reconciliation
16
+ * those from the table. The rest — a dispatch board, a reconciliation
14
17
  * screen, a record's audit trail — are a hundred lines of React. Written inside
15
18
  * the admin they inherit the sign-in, the security rules, the sidebar, the UI
16
19
  * kit and the data layer; written as a separate app they have to rebuild every
@@ -23,11 +26,13 @@ import { fileURLToPath } from "url";
23
26
  * `<frontend>/src/views/index.ts` as an `AppView`, which `App.tsx` hands to
24
27
  * `<RebaseCMS views>`. The first run wires `App.tsx`; later runs only append
25
28
  * to the list.
26
- * - **A record tab** (`--collection <slug>`): the same file location, with a
27
- * component that takes `EntityCustomViewParams`, added to that collection's
28
- * `admin.entityViews` *by path*. The collection file is shared with the
29
- * backend, and a path is the one form of component reference the backend
30
- * never evaluates — the admin's Vite plugin turns it into a lazy import.
29
+ * - **A record tab** (`--collection <slug>`, the slug of a table in
30
+ * `backend/schema`): the same file location, with a component that takes
31
+ * `EntityCustomViewParams`, added to the `entityViews` of that table's
32
+ * `customizeTable(…)` in `<frontend>/src/cms/` — imported directly, because
33
+ * that directory is the admin's own code and the backend never reads it. A
34
+ * table with no customization yet gets one, `<frontend>/src/cms/<slug>.tsx`,
35
+ * listed in `cms/index.ts`'s `tableCustomizations` when there is one.
31
36
  *
32
37
  * The frontend is where `rebase.json` says the CMS is (the static app with a
33
38
  * `cms` mount), which is `frontend/` in everything `rebase init` writes. A
@@ -35,7 +40,7 @@ import { fileURLToPath } from "url";
35
40
  * nowhere for a view to render.
36
41
  *
37
42
  * Edits to existing files are textual and conservative. When `App.tsx` already
38
- * passes its own `views`, or a collection's shape is not one this can read, the
43
+ * passes its own `views`, or a customization's shape is not one this can read, the
39
44
  * view file is still written and the command prints the one line to add by
40
45
  * hand instead of guessing.
41
46
  */
@@ -234,32 +239,36 @@ function resolveFrontendDir(projectRoot) {
234
239
  const fallback = path.join(projectRoot, "frontend");
235
240
  return fs.existsSync(path.join(fallback, "src")) ? fallback : void 0;
236
241
  }
237
- function collectionFiles(dir) {
242
+ /** Every source file under the admin's `src/cms`, sorted: where table customizations live. */
243
+ function customizationFiles(dir) {
238
244
  if (!fs.existsSync(dir)) return [];
239
245
  const out = [];
240
246
  const entries = fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
241
247
  for (const entry of entries) {
242
248
  const full = path.join(dir, entry.name);
243
249
  if (entry.isDirectory()) {
244
- if (entry.name !== "node_modules" && entry.name !== "presets") out.push(...collectionFiles(full));
250
+ if (entry.name !== "node_modules") out.push(...customizationFiles(full));
245
251
  } else if (/\.tsx?$/.test(entry.name) && !/\.(test|spec|d)\.tsx?$/.test(entry.name)) out.push(full);
246
252
  }
247
253
  return out;
248
254
  }
249
- var SLUG_PROPERTY = /(^|[\s,{])slug\s*:\s*(["'])([^"'\n]+)\2/g;
250
- /** Every `slug: "…"` a collection file declares, with where. */
251
- function declaredSlugs(dir) {
255
+ /**
256
+ * Every `customizeTable("<slug>", {` of a table, in code (not in a comment or
257
+ * a string): the file, and where the options object opens. Empty when no file
258
+ * under `cmsDir` customizes the table.
259
+ */
260
+ function findCustomization(cmsDir, slug) {
252
261
  const found = [];
253
- for (const file of collectionFiles(dir)) {
262
+ const call = /\bcustomizeTable\s*(?:<[^>]*>)?\(\s*(["'`])([^"'`\n]+)\1\s*,\s*\{/g;
263
+ for (const file of customizationFiles(cmsDir)) {
254
264
  const source = fs.readFileSync(file, "utf8");
255
265
  const masked = maskCode(source);
256
- for (const match of source.matchAll(SLUG_PROPERTY)) {
257
- const at = (match.index ?? 0) + match[1].length;
258
- if (masked[at] !== "s") continue;
266
+ for (const match of source.matchAll(call)) {
267
+ const at = match.index ?? 0;
268
+ if (match[2] !== slug || masked[at] !== "c") continue;
259
269
  found.push({
260
- slug: match[3],
261
270
  file,
262
- at
271
+ optionsOpen: at + match[0].length - 1
263
272
  });
264
273
  }
265
274
  }
@@ -285,6 +294,16 @@ function findCliRoot(from) {
285
294
  }
286
295
  return null;
287
296
  }
297
+ /** The `{ key, name, Builder }` an entity view is registered as, with `unit` indentation inside. */
298
+ function entityViewEntry(view, unit) {
299
+ return [
300
+ "{",
301
+ `${unit}key: ${JSON.stringify(view.key)},`,
302
+ `${unit}name: ${JSON.stringify(view.name)},`,
303
+ `${unit}Builder: ${view.componentName}`,
304
+ "}"
305
+ ].join("\n");
306
+ }
288
307
  /**
289
308
  * A label as JSX text: written as is when it is plain, as a string expression
290
309
  * when it holds a character JSX reads — `{`, `}`, `<`, `>`, `&`. Pasted raw,
@@ -366,7 +385,7 @@ function planCmsTypesDependency(frontendDir, files, manualSteps) {
366
385
  manualSteps.push(`Run your package manager's install: ${path.basename(frontendDir)}/package.json now depends on @rebasepro/cms-types, which the view imports its types from.`);
367
386
  }
368
387
  function defaultCollectionFor(projectRoot) {
369
- const slugs = declaredSlugs(resolveCollectionsDir(projectRoot)).map((entry) => entry.slug);
388
+ const slugs = declaredTables(resolveSchemaDir(projectRoot)).map((entry) => entry.slug);
370
389
  return slugs.find((slug) => slug !== "users") ?? slugs[0] ?? "users";
371
390
  }
372
391
  /**
@@ -392,38 +411,82 @@ function planGenerateView(options) {
392
411
  const viewAction = viewExists ? "replace" : "create";
393
412
  if (options.collection) {
394
413
  const kind = "entity";
395
- const collectionsDir = resolveCollectionsDir(projectRoot);
396
- const declared = declaredSlugs(collectionsDir);
397
- const matches = declared.filter((entry) => entry.slug === options.collection);
398
- if (matches.length === 0) {
414
+ const table = options.collection;
415
+ const schemaDir = resolveSchemaDir(projectRoot);
416
+ const declared = declaredTables(schemaDir);
417
+ if (!declared.some((entry) => entry.slug === table)) {
399
418
  const known = [...new Set(declared.map((entry) => entry.slug))].sort();
400
- throw new UsageError(`No collection with slug "${options.collection}" under ${path.relative(projectRoot, collectionsDir) || "."}.` + (known.length ? ` Declared: ${known.join(", ")}.` : ""));
419
+ throw new UsageError(`No table with slug "${table}" under ${path.relative(projectRoot, schemaDir) || "."}.` + (known.length ? ` Declared: ${known.join(", ")}.` : ""));
401
420
  }
402
- if (matches.length > 1) throw new UsageError(`More than one collection declares slug "${options.collection}": ${matches.map((entry) => path.relative(projectRoot, entry.file)).join(", ")}.`);
403
- const [{ file: collectionFile, at: slugAt }] = matches;
421
+ const cmsDir = path.join(frontendDir, "src", "cms");
422
+ const customizations = findCustomization(cmsDir, table);
423
+ if (customizations.length > 1) throw new UsageError(`More than one customizeTable("${table}", …) under ${path.relative(projectRoot, cmsDir)}: ${[...new Set(customizations.map((entry) => path.relative(projectRoot, entry.file)))].join(", ")}.`);
404
424
  files.push({
405
425
  path: viewFile,
406
426
  contents: entityViewSource({
407
427
  slug,
408
428
  componentName,
409
429
  label,
410
- collection: options.collection
430
+ collection: table
411
431
  }),
412
432
  action: viewAction
413
433
  });
414
- const builder = relativeImport(path.dirname(collectionFile), viewFile);
415
- const updated = registerEntityView(fs.readFileSync(collectionFile, "utf8"), slugAt, {
434
+ const view = {
416
435
  key: slug,
417
436
  name: label,
418
- builder
419
- });
420
- const where = `${path.relative(projectRoot, collectionFile)}`;
421
- if (updated === "already") {} else if (updated === void 0) manualSteps.push(`Add this to admin.entityViews in ${where}: { key: ${JSON.stringify(slug)}, name: ${JSON.stringify(label)}, Builder: ${JSON.stringify(builder)} }`);
422
- else files.push({
423
- path: collectionFile,
424
- contents: updated,
425
- action: "update"
426
- });
437
+ componentName
438
+ };
439
+ if (customizations.length === 1) {
440
+ const [{ file, optionsOpen }] = customizations;
441
+ const importLine = `import { ${componentName} } from "${relativeImport(path.dirname(file), viewFile)}";`;
442
+ const updated = registerEntityView(fs.readFileSync(file, "utf8"), optionsOpen, view);
443
+ const where = path.relative(projectRoot, file);
444
+ if (updated === "already") {} else if (updated === void 0) manualSteps.push(`Add this to the entityViews of customizeTable("${table}", …) in ${where}: { key: ${JSON.stringify(slug)}, name: ${JSON.stringify(label)}, Builder: ${componentName} }, and ${importLine}`);
445
+ else files.push({
446
+ path: file,
447
+ contents: addImport(updated, importLine),
448
+ action: "update"
449
+ });
450
+ } else {
451
+ const identifier = `${tableIdentifier(table)}Cms`;
452
+ const file = path.join(cmsDir, `${table}.tsx`);
453
+ if (fs.existsSync(file)) throw new UsageError(`${path.relative(projectRoot, file)} exists but holds no customizeTable("${table}", …): add the record tab to the table's customization by hand, or move that file aside.`);
454
+ const unit = " ";
455
+ files.push({
456
+ path: file,
457
+ contents: [
458
+ "import { customizeTable } from \"@rebasepro/cms\";",
459
+ `import { ${componentName} } from "${relativeImport(cmsDir, viewFile)}";`,
460
+ "",
461
+ `export const ${identifier} = customizeTable("${table}", {`,
462
+ `${unit}entityViews: [`,
463
+ reindent(entityViewEntry(view, unit), " "),
464
+ `${unit}]`,
465
+ "});",
466
+ ""
467
+ ].join("\n"),
468
+ action: "create"
469
+ });
470
+ const indexFile = path.join(cmsDir, "index.ts");
471
+ const appFile = path.join(frontendDir, "src", "App.tsx");
472
+ const index = readIfExists(indexFile);
473
+ const app = readIfExists(appFile);
474
+ const listedInIndex = index === void 0 ? void 0 : listCustomization(index, identifier, `./${table}`);
475
+ const listedInApp = listedInIndex === void 0 && app !== void 0 ? listCustomization(app, identifier, `./cms/${table}`) : void 0;
476
+ if (listedInIndex !== void 0) {
477
+ if (listedInIndex !== "already") files.push({
478
+ path: indexFile,
479
+ contents: listedInIndex,
480
+ action: "update"
481
+ });
482
+ } else if (listedInApp !== void 0) {
483
+ if (listedInApp !== "already") files.push({
484
+ path: appFile,
485
+ contents: listedInApp,
486
+ action: "update"
487
+ });
488
+ } else manualSteps.push(`Hand the customization to the admin: import { ${identifier} } from "./cms/${table}" and add it to <RebaseCMS tableCustomizations={[…]}> in ${path.relative(projectRoot, appFile)}.`);
489
+ }
427
490
  planCmsTypesDependency(frontendDir, files, manualSteps);
428
491
  return {
429
492
  kind,
@@ -533,55 +596,63 @@ function wireViewsIntoApp(source) {
533
596
  return addImport(source.slice(0, insertAt) + attribute + source.slice(insertAt), "import { views } from \"./views\";");
534
597
  }
535
598
  /**
536
- * The collection file with a `{ key, name, Builder }` entry in the
537
- * `admin.entityViews` of the collection whose `slug:` is at `slugAt`;
538
- * `"already"` when that key is there; `undefined` when the shape cannot be read.
599
+ * The customization file with a `{ key, name, Builder }` entry in the
600
+ * `entityViews` of the `customizeTable(…)` options object whose `{` is at
601
+ * `optionsOpen`; `"already"` when that key is there; `undefined` when the
602
+ * shape cannot be read. The component's import is the caller's to add.
539
603
  *
540
604
  * Exported for its tests.
541
605
  */
542
- function registerEntityView(source, slugAt, view) {
606
+ function registerEntityView(source, optionsOpen, view) {
543
607
  const masked = maskCode(source);
544
- const collectionOpen = enclosingBrace(masked, slugAt);
545
- if (collectionOpen === -1) return void 0;
608
+ const close = matchClose(masked, optionsOpen);
609
+ if (close === -1) return void 0;
546
610
  const unit = indentUnit(source);
547
- const entry = [
548
- "{",
549
- `${unit}key: ${JSON.stringify(view.key)},`,
550
- `${unit}name: ${JSON.stringify(view.name)},`,
551
- `${unit}Builder: ${JSON.stringify(view.builder)}`,
552
- "}"
553
- ].join("\n");
554
- const admin = directProperty(masked, collectionOpen, "admin", "{");
555
- if (admin) {
556
- const entityViews = directProperty(masked, admin.valueOpen, "entityViews", "[");
557
- if (entityViews) {
558
- const close = matchClose(masked, entityViews.valueOpen);
559
- if (close === -1) return void 0;
560
- const listed = source.slice(entityViews.valueOpen, close);
561
- if (new RegExp(`key\\s*:\\s*["']${view.key}["']|["']${view.key}["']`).test(listed)) return "already";
562
- const indent = indentAt(source, entityViews.keyAt) + unit;
563
- return appendToArray(source, masked, entityViews.valueOpen, reindent(entry, indent));
564
- }
565
- const indent = indentAt(source, admin.keyAt) + unit;
566
- const block = `${indent}entityViews: [\n${reindent(entry, indent + unit)}\n${indent}],`;
567
- const adminClose = matchClose(masked, admin.valueOpen);
568
- const empty = masked.slice(admin.valueOpen + 1, adminClose).trim() === "";
569
- const insertAt = admin.valueOpen + 1;
570
- return empty ? `${source.slice(0, insertAt)}\n${block.replace(/,$/, "")}\n${indentAt(source, admin.keyAt)}${source.slice(adminClose)}` : `${source.slice(0, insertAt)}\n${block}${source.slice(insertAt)}`;
611
+ const entry = entityViewEntry(view, unit);
612
+ const entityViews = directProperty(masked, optionsOpen, "entityViews", "[");
613
+ if (entityViews) {
614
+ const listClose = matchClose(masked, entityViews.valueOpen);
615
+ if (listClose === -1) return void 0;
616
+ const listed = source.slice(entityViews.valueOpen, listClose);
617
+ if (new RegExp(`key\\s*:\\s*["']${view.key}["']|["']${view.key}["']`).test(listed)) return "already";
618
+ const indent = indentAt(source, entityViews.keyAt) + unit;
619
+ return appendToArray(source, masked, entityViews.valueOpen, reindent(entry, indent));
571
620
  }
572
- const slugLineEnd = source.indexOf("\n", slugAt);
573
- if (slugLineEnd === -1) return void 0;
574
- const slugLine = masked.slice(slugAt, slugLineEnd);
575
- if (!/,\s*$/.test(slugLine)) return void 0;
576
- const indent = indentAt(source, slugAt);
577
- const block = [
578
- `${indent}admin: {`,
579
- `${indent}${unit}entityViews: [`,
580
- reindent(entry, indent + unit + unit),
581
- `${indent}${unit}]`,
582
- `${indent}},`
583
- ].join("\n");
584
- return `${source.slice(0, slugLineEnd + 1)}${block}\n${source.slice(slugLineEnd + 1)}`;
621
+ const indent = indentAt(source, optionsOpen) + unit;
622
+ const block = `${indent}entityViews: [\n${reindent(entry, indent + unit)}\n${indent}]`;
623
+ const empty = masked.slice(optionsOpen + 1, close).trim() === "";
624
+ const insertAt = optionsOpen + 1;
625
+ return empty ? `${source.slice(0, insertAt)}\n${block}\n${indentAt(source, optionsOpen)}${source.slice(close)}` : `${source.slice(0, insertAt)}\n${block},${source.slice(insertAt)}`;
626
+ }
627
+ /**
628
+ * A source with `identifier` imported from `importPath` and appended to its
629
+ * list of table customizations — `export const tableCustomizations = [ … ]`
630
+ * (`cms/index.ts`) or `tableCustomizations={[ … ]}` on `<RebaseCMS>`
631
+ * (`App.tsx`); `"already"` when it is listed; `undefined` when the source has
632
+ * no such list.
633
+ *
634
+ * Exported for its tests.
635
+ */
636
+ function listCustomization(source, identifier, importPath) {
637
+ const masked = maskCode(source);
638
+ const declaration = /export\s+const\s+tableCustomizations\b[^=]*=\s*\[/.exec(masked) ?? /\btableCustomizations\s*=\s*\{\s*\[/.exec(masked);
639
+ if (!declaration) return void 0;
640
+ const open = declaration.index + declaration[0].length - 1;
641
+ const close = matchClose(masked, open);
642
+ if (close === -1) return void 0;
643
+ if (new RegExp(`\\b${identifier}\\b`).test(masked.slice(open, close))) return "already";
644
+ const inner = masked.slice(open + 1, close);
645
+ let appended;
646
+ if (inner.trim() !== "" && !inner.includes("\n")) {
647
+ let last = close - 1;
648
+ while (last > open && /\s/.test(masked[last])) last--;
649
+ const comma = masked[last] === "," ? " " : ", ";
650
+ appended = `${source.slice(0, last + 1)}${comma}${identifier}${source.slice(last + 1)}`;
651
+ } else {
652
+ const unit = indentUnit(source);
653
+ appended = appendToArray(source, masked, open, `${indentAt(source, open)}${unit}${identifier}`);
654
+ }
655
+ return addImport(appended, `import { ${identifier} } from "${importPath}";`);
585
656
  }
586
657
  function printHelp() {
587
658
  console.log(`
@@ -589,17 +660,17 @@ ${chalk.bold("rebase generate")} — scaffold code into this project
589
660
 
590
661
  ${chalk.bold("Usage")}
591
662
  rebase generate view <slug> A screen of the admin, in the sidebar
592
- rebase generate view <slug> --collection <slug> A tab on every record of a collection
663
+ rebase generate view <slug> --collection <slug> A tab on every record of a table
593
664
 
594
665
  ${chalk.bold("What it writes")}
595
666
  <frontend>/src/views/<Name>View.tsx The component, drawn with @rebasepro/ui
596
667
  <frontend>/src/views/index.ts The screens list (AppView[]), wired into
597
668
  <RebaseCMS views> in App.tsx on first run
598
- With --collection, the collection file instead gains an admin.entityViews
599
- entry that points at the component by path.
669
+ With --collection, the table's customizeTable(…) in <frontend>/src/cms gains
670
+ an entityViews entry with the component (a new <slug>.tsx when it has none).
600
671
 
601
672
  ${chalk.bold("Options")}
602
- --collection <slug> Register as a record tab of this collection
673
+ --collection <slug> Register as a record tab of the table with this slug
603
674
  --name <label> Sidebar or tab label ${chalk.gray("(default: the slug in sentence case)")}
604
675
  --icon <Lucide name> Sidebar icon for a screen ${chalk.gray("(default: LayoutDashboard)")}
605
676
  --dry-run List what would change, and change nothing
@@ -659,4 +730,4 @@ async function generateViewCommand(rawArgs) {
659
730
  //#endregion
660
731
  export { GENERATE_SUBCOMMANDS, generateCommand };
661
732
 
662
- //# sourceMappingURL=generate-view-IFwCADvb.js.map
733
+ //# sourceMappingURL=generate-view-CTOluXvH.js.map