@rebasepro/cli 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/LICENSE +17 -196
  2. package/dist/index.cjs +158 -44
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.es.js +142 -28
  5. package/dist/index.es.js.map +1 -1
  6. package/package.json +13 -11
  7. package/templates/template/.cursorrules +2 -0
  8. package/templates/template/.env.example +7 -0
  9. package/templates/template/.github/copilot-instructions.md +2 -0
  10. package/templates/template/.windsurfrules +2 -0
  11. package/templates/template/README.md +2 -2
  12. package/templates/template/ai-instructions.md +14 -0
  13. package/templates/template/backend/Dockerfile +1 -1
  14. package/templates/template/backend/drizzle.config.ts +11 -5
  15. package/templates/template/backend/package.json +4 -3
  16. package/templates/template/backend/src/env.ts +2 -43
  17. package/templates/template/backend/src/index.ts +10 -12
  18. package/templates/template/config/collections/index.ts +6 -4
  19. package/templates/template/config/collections/posts.ts +3 -17
  20. package/templates/template/config/collections/roles.ts +72 -0
  21. package/templates/template/config/collections/users.ts +141 -0
  22. package/templates/template/config/index.ts +1 -1
  23. package/templates/template/config/package.json +2 -1
  24. package/templates/template/docker-compose.yml +1 -1
  25. package/templates/template/frontend/package.json +3 -1
  26. package/templates/template/frontend/src/App.tsx +3 -3
  27. package/templates/template/frontend/src/virtual.d.ts +6 -0
  28. package/templates/template/frontend/tsconfig.json +3 -2
  29. package/templates/template/frontend/vite.config.ts +1 -1
  30. package/templates/template/pnpm-workspace.yaml +6 -0
package/LICENSE CHANGED
@@ -1,201 +1,22 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
1
+ MIT License
4
2
 
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
3
+ Copyright (c) 2026 Rebase
6
4
 
7
- 1. Definitions.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
8
11
 
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
11
14
 
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
14
22
 
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("chalk"), require("arg"), require("inquirer"), require("path"), require("fs"), require("util"), require("execa"), require("ncp"), require("url"), require("crypto"), require("@rebasepro/sdk-generator"), require("child_process"), require("os")) : typeof define === "function" && define.amd ? define(["exports", "chalk", "arg", "inquirer", "path", "fs", "util", "execa", "ncp", "url", "crypto", "@rebasepro/sdk-generator", "child_process", "os"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["Rebase CLI"] = {}, global.chalk, global.arg, global.inquirer, global.path, global.fs, global.util, global.execa, global.ncp, global.url, global.crypto, global.sdkGenerator, global.child_process, global.os));
3
- })(this, (function(exports2, chalk, arg, inquirer, path, fs, util, execa, ncp, url, crypto, sdkGenerator, child_process, os) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("chalk"), require("arg"), require("inquirer"), require("path"), require("fs"), require("util"), require("execa"), require("fs/promises"), require("url"), require("crypto"), require("@rebasepro/sdk-generator"), require("child_process"), require("os")) : typeof define === "function" && define.amd ? define(["exports", "chalk", "arg", "inquirer", "path", "fs", "util", "execa", "fs/promises", "url", "crypto", "@rebasepro/sdk-generator", "child_process", "os"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["Rebase CLI"] = {}, global.chalk, global.arg, global.inquirer, global.path, global.fs, global.util, global.execa, global.promises, global.url, global.crypto, global.sdkGenerator, global.child_process, global.os));
3
+ })(this, (function(exports2, chalk, arg, inquirer, path, fs, util, execa, promises, url, crypto, sdkGenerator, child_process, os) {
4
4
  "use strict";
5
5
  var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
6
6
  function _interopNamespaceDefault(e) {
@@ -60,7 +60,6 @@
60
60
  };
61
61
  }
62
62
  const access = util.promisify(fs.access);
63
- const copy = util.promisify(ncp);
64
63
  const __filename$2 = url.fileURLToPath(typeof document === "undefined" && typeof location === "undefined" ? require("url").pathToFileURL(__filename).href : typeof document === "undefined" ? location.href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href);
65
64
  const __dirname$2 = path.dirname(__filename$2);
66
65
  function findParentDir(currentDir, targetName) {
@@ -87,8 +86,12 @@ ${chalk.bold("Rebase")} — Create a new project 🚀
87
86
  {
88
87
  "--git": Boolean,
89
88
  "--install": Boolean,
89
+ "--database-url": String,
90
+ "--introspect": Boolean,
91
+ "--yes": Boolean,
90
92
  "-g": "--git",
91
- "-i": "--install"
93
+ "-i": "--install",
94
+ "-y": "--yes"
92
95
  },
93
96
  {
94
97
  argv: rawArgs.slice(3),
@@ -97,6 +100,24 @@ ${chalk.bold("Rebase")} — Create a new project 🚀
97
100
  }
98
101
  );
99
102
  const nameArg = args._[0];
103
+ const isNonInteractive = args["--yes"] || false;
104
+ if (isNonInteractive) {
105
+ const projectName2 = nameArg || "my-rebase-app";
106
+ const targetDirectory2 = path.resolve(process.cwd(), projectName2);
107
+ const templateDirectory2 = path.resolve(cliRoot, "templates", "template");
108
+ const pmCommands2 = getPMCommands(pm);
109
+ return {
110
+ projectName: path.basename(targetDirectory2),
111
+ git: args["--git"] ?? false,
112
+ installDeps: args["--install"] ?? false,
113
+ targetDirectory: targetDirectory2,
114
+ templateDirectory: templateDirectory2,
115
+ databaseUrl: args["--database-url"] || void 0,
116
+ introspect: args["--introspect"] || false,
117
+ pm,
118
+ pmCommands: pmCommands2
119
+ };
120
+ }
100
121
  const questions = [];
101
122
  if (!nameArg) {
102
123
  questions.push({
@@ -176,9 +197,8 @@ ${chalk.bold("Rebase")} — Create a new project 🚀
176
197
  }
177
198
  console.log(chalk.gray(" Copying project files..."));
178
199
  try {
179
- await copy(options.templateDirectory, options.targetDirectory, {
180
- clobber: false,
181
- dot: true,
200
+ await promises.cp(options.templateDirectory, options.targetDirectory, {
201
+ recursive: true,
182
202
  filter: (source) => {
183
203
  const basename = path.basename(source);
184
204
  return basename !== "node_modules" && basename !== ".DS_Store";
@@ -193,7 +213,7 @@ ${chalk.bold("Rebase")} — Create a new project 🚀
193
213
  if (options.git) {
194
214
  console.log(chalk.gray(" Initializing git repository..."));
195
215
  try {
196
- await execa("git", ["init"], { cwd: options.targetDirectory });
216
+ await execa.execa("git", ["init"], { cwd: options.targetDirectory });
197
217
  } catch {
198
218
  console.warn(chalk.yellow(" Warning: Failed to initialize git repository"));
199
219
  }
@@ -206,7 +226,7 @@ ${chalk.bold("Rebase")} — Create a new project 🚀
206
226
  console.log(chalk.gray(` Installing dependencies with ${pm}...`));
207
227
  console.log("");
208
228
  try {
209
- await execa(installCmd[0], installCmd.slice(1), {
229
+ await execa.execa(installCmd[0], installCmd.slice(1), {
210
230
  cwd: options.targetDirectory,
211
231
  stdio: "inherit"
212
232
  });
@@ -220,7 +240,7 @@ ${chalk.bold("Rebase")} — Create a new project 🚀
220
240
  console.log(chalk.gray(" Introspecting database and generating collections..."));
221
241
  console.log("");
222
242
  try {
223
- await execa(execCmd[0], execCmd.slice(1), {
243
+ await execa.execa(execCmd[0], execCmd.slice(1), {
224
244
  cwd: options.targetDirectory,
225
245
  stdio: "inherit"
226
246
  });
@@ -282,20 +302,24 @@ ${chalk.bold("Rebase")} — Create a new project 🚀
282
302
  const viewBin = "npm";
283
303
  const getPackageVersion = async (pkgName) => {
284
304
  if (versionCache.has(pkgName)) return versionCache.get(pkgName);
305
+ if (process.env.REBASE_E2E === "true") {
306
+ versionCache.set(pkgName, cliVersion);
307
+ return cliVersion;
308
+ }
285
309
  let versionToUse = cliVersion;
286
310
  try {
287
- const { stdout } = await execa(viewBin, ["view", `${pkgName}@${cliVersion}`, "version"]);
311
+ const { stdout } = await execa.execa(viewBin, ["view", `${pkgName}@${cliVersion}`, "version"]);
288
312
  if (!stdout.trim()) throw new Error("Not found");
289
313
  versionToUse = stdout.trim();
290
314
  } catch {
291
315
  try {
292
316
  const tag = cliVersion.includes("canary") ? "canary" : "latest";
293
- const { stdout } = await execa(viewBin, ["view", `${pkgName}@${tag}`, "version"]);
317
+ const { stdout } = await execa.execa(viewBin, ["view", `${pkgName}@${tag}`, "version"]);
294
318
  if (!stdout.trim()) throw new Error("Not found");
295
319
  versionToUse = stdout.trim();
296
320
  } catch {
297
321
  try {
298
- const { stdout } = await execa(viewBin, ["view", pkgName, "version"]);
322
+ const { stdout } = await execa.execa(viewBin, ["view", pkgName, "version"]);
299
323
  versionToUse = stdout.trim() || "latest";
300
324
  } catch {
301
325
  versionToUse = "latest";
@@ -449,6 +473,7 @@ Expected a default export of EntityCollection[] or an object with named collecti
449
473
  console.log("");
450
474
  console.log(chalk.cyan(" → Loading collection definitions..."));
451
475
  const collections = await loadCollections(resolvedCollectionsDir);
476
+ collections.sort((a, b) => a.slug.localeCompare(b.slug));
452
477
  if (collections.length === 0) {
453
478
  console.log(chalk.red(" ✗ No collections found. Nothing to generate."));
454
479
  process.exit(1);
@@ -508,15 +533,20 @@ Expected a default export of EntityCollection[] or an object with named collecti
508
533
  if (!fs.existsSync(pkgPath)) return null;
509
534
  try {
510
535
  const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
511
- const deps = {
512
- ...pkg.dependencies,
513
- ...pkg.devDependencies
514
- };
515
- for (const dep of Object.keys(deps)) {
516
- if (dep.startsWith("@rebasepro/server-") && dep !== "@rebasepro/server-core") {
517
- return dep;
536
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
537
+ const candidates = Object.keys(deps).filter(
538
+ (dep) => dep.startsWith("@rebasepro/server-") && dep !== "@rebasepro/server-core"
539
+ );
540
+ if (candidates.length === 0) return null;
541
+ if (candidates.includes("@rebasepro/server-postgresql")) {
542
+ return "@rebasepro/server-postgresql";
543
+ }
544
+ for (const candidate of candidates) {
545
+ if (resolvePluginCliScript(backendDir, candidate)) {
546
+ return candidate;
518
547
  }
519
548
  }
549
+ return candidates[0];
520
550
  } catch {
521
551
  }
522
552
  return null;
@@ -578,7 +608,7 @@ Expected a default export of EntityCollection[] or an object with named collecti
578
608
  if (!root) {
579
609
  console.error(chalk.red("✗ Could not find a Rebase project root."));
580
610
  console.error(chalk.gray(" Make sure you are inside a Rebase project directory"));
581
- console.error(chalk.gray(" (one with backend/, frontend/, and shared/ directories)."));
611
+ console.error(chalk.gray(" (one with backend/, frontend/, and config/ directories)."));
582
612
  process.exit(1);
583
613
  }
584
614
  return root;
@@ -623,13 +653,13 @@ Expected a default export of EntityCollection[] or an object with named collecti
623
653
  console.error(chalk.red("✗ Could not find tsx binary."));
624
654
  process.exit(1);
625
655
  }
626
- await execa(tsxBin, [pluginCli, ...rawArgs.slice(2)], {
656
+ await execa.execa(tsxBin, [pluginCli, ...rawArgs.slice(2)], {
627
657
  cwd: backendDir,
628
658
  stdio: "inherit",
629
659
  env
630
660
  });
631
661
  } else {
632
- await execa("node", [pluginCli, ...rawArgs.slice(2)], {
662
+ await execa.execa("node", [pluginCli, ...rawArgs.slice(2)], {
633
663
  cwd: backendDir,
634
664
  stdio: "inherit",
635
665
  env
@@ -691,13 +721,13 @@ ${chalk.green.bold("introspect Options")}
691
721
  console.error(chalk.red("✗ Could not find tsx binary."));
692
722
  process.exit(1);
693
723
  }
694
- await execa(tsxBin, [pluginCli, ...rawArgs.slice(2)], {
724
+ await execa.execa(tsxBin, [pluginCli, ...rawArgs.slice(2)], {
695
725
  cwd: backendDir,
696
726
  stdio: "inherit",
697
727
  env
698
728
  });
699
729
  } else {
700
- await execa("node", [pluginCli, ...rawArgs.slice(2)], {
730
+ await execa.execa("node", [pluginCli, ...rawArgs.slice(2)], {
701
731
  cwd: backendDir,
702
732
  stdio: "inherit",
703
733
  env
@@ -761,10 +791,12 @@ ${chalk.green.bold("Examples")}
761
791
  "--backend-only": Boolean,
762
792
  "--frontend-only": Boolean,
763
793
  "--port": Number,
794
+ "--generate": Boolean,
764
795
  "--help": Boolean,
765
796
  "-b": "--backend-only",
766
797
  "-f": "--frontend-only",
767
798
  "-p": "--port",
799
+ "-g": "--generate",
768
800
  "-h": "--help"
769
801
  },
770
802
  {
@@ -782,6 +814,7 @@ ${chalk.green.bold("Examples")}
782
814
  const frontendDir = findFrontendDir(projectRoot);
783
815
  const backendOnly = args["--backend-only"] || false;
784
816
  const frontendOnly = args["--frontend-only"] || false;
817
+ const shouldGenerate = args["--generate"] || process.env.REBASE_AUTO_GENERATE === "true" || process.env.REBASE_GENERATE === "true";
785
818
  const startPort = resolveStartPort(projectRoot, args["--port"]);
786
819
  console.log("");
787
820
  console.log(chalk.bold(" 🚀 Rebase Dev Server"));
@@ -801,10 +834,10 @@ ${chalk.green.bold("Examples")}
801
834
  console.log("");
802
835
  console.log(chalk.cyan("┌────────────────────────────────────────────────────────────┐"));
803
836
  console.log(chalk.cyan("│ │"));
804
- console.log(chalk.cyan("│ Rebase Admin App is ready! │"));
837
+ console.log(chalk.cyan("│ Rebase Admin App is ready! │"));
805
838
  const cleanUrl = stripAnsi(frontendUrl);
806
- const paddedUrl = cleanUrl.padEnd(40);
807
- console.log(chalk.cyan("│ 👉 Frontend URL: ") + chalk.white(paddedUrl) + chalk.cyan("│"));
839
+ const paddedUrl = cleanUrl.padEnd(41);
840
+ console.log(chalk.cyan("│ Frontend URL: ") + chalk.white(paddedUrl) + chalk.cyan("│"));
808
841
  console.log(chalk.cyan("│ │"));
809
842
  console.log(chalk.cyan("└────────────────────────────────────────────────────────────┘"));
810
843
  console.log("");
@@ -823,7 +856,7 @@ ${chalk.green.bold("Examples")}
823
856
  if (child.pid && !child.killed) {
824
857
  try {
825
858
  if (process.platform === "win32") {
826
- execa.commandSync(`taskkill /pid ${child.pid} /T /F`);
859
+ execa.execaCommandSync(`taskkill /pid ${child.pid} /T /F`);
827
860
  } else {
828
861
  process.kill(-child.pid, "SIGKILL");
829
862
  }
@@ -850,7 +883,7 @@ ${chalk.green.bold("Examples")}
850
883
  const pm = detectPackageManager(projectRoot);
851
884
  const pmCmds = getPMCommands(pm);
852
885
  const runDevCmd = pmCmds.run("dev");
853
- const frontendChild = execa(
886
+ const frontendChild = execa.execa(
854
887
  runDevCmd[0],
855
888
  runDevCmd.slice(1),
856
889
  {
@@ -901,9 +934,67 @@ ${chalk.green.bold("Examples")}
901
934
  console.log(` ${chalk.cyan("▶")} Backend: ${chalk.gray(backendDir)}`);
902
935
  console.log(` ${chalk.gray("↳ PORT")} = ${chalk.white(String(startPort))}`);
903
936
  let frontendLaunched = false;
904
- const backendChild = execa(
937
+ if (shouldGenerate) {
938
+ console.log(chalk.gray(" → Ensuring schema and SDK are generated on start..."));
939
+ try {
940
+ const activePlugin = getActiveBackendPlugin(backendDir);
941
+ const pluginCli = activePlugin ? resolvePluginCliScript(backendDir, activePlugin) : null;
942
+ if (pluginCli) {
943
+ await execa.execa(tsxBin, [pluginCli, "schema", "generate"], {
944
+ cwd: backendDir,
945
+ stdio: "inherit",
946
+ env
947
+ });
948
+ }
949
+ await execa.execa("npx", ["rebase", "generate-sdk"], {
950
+ cwd: projectRoot,
951
+ stdio: "inherit",
952
+ env
953
+ });
954
+ console.log(chalk.green(" ✓ Initial schema and SDK generated successfully.\n"));
955
+ } catch (err) {
956
+ console.error(chalk.red(` ✗ Initial schema/SDK generation failed: ${err.message || err}
957
+ `));
958
+ }
959
+ const collectionsDir = path.join(projectRoot, "config", "collections");
960
+ if (fs.existsSync(collectionsDir)) {
961
+ let watchDebounce = null;
962
+ fs.watch(collectionsDir, { recursive: true }, (eventType, filename) => {
963
+ if (!filename || filename.startsWith(".") || filename.endsWith(".tmp")) return;
964
+ if (watchDebounce) clearTimeout(watchDebounce);
965
+ watchDebounce = setTimeout(async () => {
966
+ console.log(chalk.yellow(`
967
+ 🔄 Collection change detected (${filename}). Regenerating schema & SDK...`));
968
+ try {
969
+ const activePlugin = getActiveBackendPlugin(backendDir);
970
+ const pluginCli = activePlugin ? resolvePluginCliScript(backendDir, activePlugin) : null;
971
+ if (pluginCli) {
972
+ await execa.execa(tsxBin, [pluginCli, "schema", "generate"], {
973
+ cwd: backendDir,
974
+ stdio: "inherit",
975
+ env
976
+ });
977
+ }
978
+ await execa.execa("npx", ["rebase", "generate-sdk"], {
979
+ cwd: projectRoot,
980
+ stdio: "inherit",
981
+ env
982
+ });
983
+ console.log(chalk.green(" ✓ Schema & SDK regenerated successfully. Hono will reload."));
984
+ } catch (err) {
985
+ console.error(chalk.red(` ✗ Failed to regenerate schema/SDK: ${err.message || err}`));
986
+ }
987
+ }, 300);
988
+ });
989
+ }
990
+ }
991
+ const watchArgs = ["watch", "--conditions", "development", "src/index.ts"];
992
+ if (!shouldGenerate) {
993
+ watchArgs.splice(1, 0, `--watch="${path.join("..", "config", "**", "*")}"`);
994
+ }
995
+ const backendChild = execa.execa(
905
996
  tsxBin,
906
- ["watch", `--watch="${path.join("..", "config", "**", "*")}"`, "--conditions", "development", "src/index.ts"],
997
+ watchArgs,
907
998
  {
908
999
  cwd: backendDir,
909
1000
  stdio: ["inherit", "pipe", "pipe"],
@@ -976,6 +1067,7 @@ ${chalk.green.bold("Options")}
976
1067
  ${chalk.blue("--backend-only, -b")} Only start the backend server
977
1068
  ${chalk.blue("--frontend-only, -f")} Only start the frontend server
978
1069
  ${chalk.blue("--port, -p")} Backend port (default: auto-detected per project)
1070
+ ${chalk.blue("--generate, -g")} Enable automatic schema and SDK generation on startup and file changes
979
1071
 
980
1072
  ${chalk.green.bold("Description")}
981
1073
  Starts both the backend (tsx watch + Hono) and frontend (Vite)
@@ -988,6 +1080,10 @@ ${chalk.green.bold("Description")}
988
1080
  If the assigned port is already in use, the server will automatically
989
1081
  try the next available port. The frontend is started only after the
990
1082
  backend is ready, and VITE_API_URL is injected automatically.
1083
+
1084
+ By default, automatic schema and SDK generation is disabled on startup
1085
+ and file changes. Pass --generate (-g) or set REBASE_AUTO_GENERATE=true
1086
+ in your environment to enable it.
991
1087
  `);
992
1088
  }
993
1089
  async function buildCommand() {
@@ -998,7 +1094,7 @@ ${chalk.green.bold("Description")}
998
1094
  console.log(`${chalk.bold("Rebase")} — Building all workspaces with ${chalk.cyan(pm)}...
999
1095
  `);
1000
1096
  try {
1001
- await execa(buildCmd[0], buildCmd.slice(1), {
1097
+ await execa.execa(buildCmd[0], buildCmd.slice(1), {
1002
1098
  cwd: projectRoot,
1003
1099
  stdio: "inherit"
1004
1100
  });
@@ -1020,7 +1116,7 @@ ${chalk.green.bold("Description")}
1020
1116
  console.log(`${chalk.bold("Rebase")} — Starting backend server...
1021
1117
  `);
1022
1118
  try {
1023
- await execa(startCmd[0], startCmd.slice(1), {
1119
+ await execa.execa(startCmd[0], startCmd.slice(1), {
1024
1120
  cwd: projectRoot,
1025
1121
  stdio: "inherit",
1026
1122
  env
@@ -1082,12 +1178,12 @@ ${chalk.green.bold("Description")}
1082
1178
  env.DOTENV_CONFIG_PATH = envFile;
1083
1179
  }
1084
1180
  const scriptContent = `
1085
- import { createPostgresDatabaseConnection } from "@rebasepro/server-core";
1086
- import { hashPassword } from "@rebasepro/server-core/src/auth/password";
1181
+ import { createPostgresDatabaseConnection } from "@rebasepro/server-postgresql";
1182
+ import { hashPassword } from "@rebasepro/server-core";
1087
1183
  import { eq } from "drizzle-orm";
1088
- import { users } from "@rebasepro/server-core/src/db/auth-schema";
1089
1184
  import * as dotenv from "dotenv";
1090
1185
  import path from "path";
1186
+ import fs from "fs";
1091
1187
 
1092
1188
  dotenv.config({ path: "${envFile || path.join(projectRoot, ".env")}" });
1093
1189
 
@@ -1098,12 +1194,30 @@ async function resetPassword() {
1098
1194
  const { db } = createPostgresDatabaseConnection(process.env.DATABASE_URL!);
1099
1195
  const hash = await hashPassword(newPassword);
1100
1196
 
1101
- const result = await db.update(users)
1102
- .set({ passwordHash: hash })
1103
- .where(eq(users.email, email))
1197
+ let usersTable;
1198
+ try {
1199
+ const schemaPath = path.resolve("./src/schema.generated.ts");
1200
+ if (fs.existsSync(schemaPath)) {
1201
+ const schema = await import("file://" + schemaPath);
1202
+ usersTable = schema.users || schema.tables?.users;
1203
+ }
1204
+ } catch (e) {
1205
+ // ignore and fallback
1206
+ }
1207
+
1208
+ if (!usersTable) {
1209
+ const pgServer = await import("@rebasepro/server-postgresql");
1210
+ usersTable = pgServer.users;
1211
+ }
1212
+
1213
+ const passwordHashKey = (usersTable.passwordHash || "passwordHash" in usersTable) ? "passwordHash" : "password_hash";
1214
+
1215
+ const result = await db.update(usersTable)
1216
+ .set({ [passwordHashKey]: hash })
1217
+ .where(eq(usersTable.email, email))
1104
1218
  .returning({
1105
- id: users.id,
1106
- email: users.email
1219
+ id: usersTable.id,
1220
+ email: usersTable.email
1107
1221
  });
1108
1222
 
1109
1223
  if (result.length > 0) {
@@ -1191,13 +1305,13 @@ ${chalk.green.bold("Examples")}
1191
1305
  console.error(chalk.red("✗ Could not find tsx binary."));
1192
1306
  process.exit(1);
1193
1307
  }
1194
- await execa(tsxBin, [pluginCli, ...rawArgs.slice(2)], {
1308
+ await execa.execa(tsxBin, [pluginCli, ...rawArgs.slice(2)], {
1195
1309
  cwd: backendDir,
1196
1310
  stdio: "inherit",
1197
1311
  env
1198
1312
  });
1199
1313
  } else {
1200
- await execa("node", [pluginCli, ...rawArgs.slice(2)], {
1314
+ await execa.execa("node", [pluginCli, ...rawArgs.slice(2)], {
1201
1315
  cwd: backendDir,
1202
1316
  stdio: "inherit",
1203
1317
  env