@rebasepro/cli 0.11.1-canary.gf2b0ff7 → 0.11.1-canary.gf410d03

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 (32) hide show
  1. package/bin/rebase.js +21 -0
  2. package/dist/bundle.d.ts +15 -5
  3. package/dist/commands/eject.d.ts +1 -0
  4. package/dist/commands/init.d.ts +3 -15
  5. package/dist/fold-static.d.ts +41 -15
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.es.js +703 -225
  8. package/dist/index.es.js.map +1 -1
  9. package/dist/manifest.d.ts +26 -7
  10. package/package.json +7 -7
  11. package/runtime/dev-server.mjs +0 -1
  12. package/templates/{template/backend → eject}/Dockerfile +16 -4
  13. package/templates/eject/docker-compose.custom.yml +71 -0
  14. package/templates/overlays/baas/backend/package.json +1 -4
  15. package/templates/overlays/baas/backend/tsconfig.json +8 -2
  16. package/templates/overlays/baas/config/index.ts +15 -0
  17. package/templates/overlays/baas/config/package.json +28 -0
  18. package/templates/overlays/baas/package.json +2 -1
  19. package/templates/overlays/baas/pnpm-workspace.yaml +1 -0
  20. package/templates/overlays/baas/rebase.json +2 -6
  21. package/templates/template/README.md +34 -16
  22. package/templates/template/backend/package.json +1 -4
  23. package/templates/template/docker-compose.yml +62 -38
  24. package/templates/template/frontend/src/main.tsx +8 -1
  25. package/templates/template/frontend/vite.config.ts +5 -0
  26. package/templates/template/rebase.json +5 -8
  27. package/templates/overlays/baas/backend/src/index.ts +0 -216
  28. package/templates/template/frontend/Dockerfile +0 -52
  29. package/templates/template/frontend/nginx.conf +0 -40
  30. /package/templates/{template → eject}/backend/src/env.ts +0 -0
  31. /package/templates/{template → eject}/backend/src/index.ts +0 -0
  32. /package/templates/overlays/baas/{backend/src → config}/storage.ts +0 -0
package/bin/rebase.js CHANGED
@@ -65,6 +65,27 @@ try {
65
65
  /* ignore */
66
66
  }
67
67
 
68
+ /**
69
+ * `dist/` is gitignored, so in a fresh clone it does not exist until someone
70
+ * runs a build — and `rebase` is reached long before that: CONTRIBUTING's
71
+ * getting-started steps call `db push` and `dev` through it. Importing a
72
+ * missing module raises a bare ERR_MODULE_NOT_FOUND stack trace naming an
73
+ * internal path, which reads as a broken repository rather than a missing step.
74
+ *
75
+ * stderr, like the staleness warning above, so `--json` output stays parseable.
76
+ */
77
+ if (!existsSync(distEntry)) {
78
+ const dev = existsSync(srcDir);
79
+ process.stderr.write(
80
+ `\x1b[31m✗ rebase CLI: not built yet — ${distEntry} is missing.\x1b[0m\n` +
81
+ (dev
82
+ ? " Build it with: pnpm --filter @rebasepro/cli build\n" +
83
+ " (or `pnpm build` from the repo root to build every package)\n"
84
+ : " This install looks incomplete; try reinstalling @rebasepro/cli.\n")
85
+ );
86
+ process.exit(1);
87
+ }
88
+
68
89
  const { entry } = await import("../dist/index.es.js");
69
90
 
70
91
  entry(process.argv);
package/dist/bundle.d.ts CHANGED
@@ -94,11 +94,10 @@ export declare function normalizeEsmSpecifiers(outDir: string): {
94
94
  * deployed green, and answered 404 on every one of them, with the file still
95
95
  * sitting in the repository looking exactly like the server.
96
96
  *
97
- * A project that means to keep its own entrypoint declares the app as
98
- * `"type": "custom"`, which builds the repository's Dockerfile instead — which
99
- * is what {@link synthesizeManifest} already infers for a manifest-less repo
100
- * carrying one. The warning names that route rather than implying the file is
101
- * a mistake.
97
+ * A project that means to keep its own entrypoint runs `rebase eject`, which
98
+ * writes the entrypoint, a Dockerfile and a compose file together and flips the
99
+ * backend to `runtime: "custom"`. The warning names that route rather than
100
+ * implying the file is a mistake.
102
101
  */
103
102
  export declare function findUnusedServerEntry(projectRoot: string, functionsDir: string): string | undefined;
104
103
  /**
@@ -151,8 +150,15 @@ export declare function foldStaticIntoBundle(options: {
151
150
  bundleDir: string;
152
151
  /** Directory of built frontend assets (the static app's `output`). */
153
152
  assetsDir: string;
153
+ /** The app's name in `rebase.json`. Names its directory inside the bundle. */
154
+ appName: string;
155
+ /** Public base path this app is served under. */
156
+ path: string;
157
+ /** Serve `index.html` for unmatched paths under `path`. */
158
+ spa: boolean;
154
159
  }): {
155
160
  fileCount: number;
161
+ dir: string;
156
162
  };
157
163
  export declare function buildStaticBundle(options: {
158
164
  projectRoot: string;
@@ -160,6 +166,10 @@ export declare function buildStaticBundle(options: {
160
166
  assetsDir: string;
161
167
  outDir: string;
162
168
  runtimeRange: string;
169
+ /** Public base path. Default `/` — a standalone bundle owns its origin. */
170
+ path?: string;
171
+ /** Serve `index.html` for unmatched paths. Default `true`. */
172
+ spa?: boolean;
163
173
  }): {
164
174
  outDir: string;
165
175
  manifest: RebaseBundleManifest;
@@ -0,0 +1 @@
1
+ export declare function ejectCommand(rawArgs?: string[]): Promise<void>;
@@ -2,18 +2,6 @@ import type { PackageManager, PMCommands } from "../utils/package-manager";
2
2
  /** Returns an error message, or null when the name is a valid package name. */
3
3
  export declare function validateProjectName(name: string): string | null;
4
4
  export type TemplatePreset = "blog" | "ecommerce" | "blank";
5
- /**
6
- * How much of Rebase to scaffold.
7
- *
8
- * `cms` is the full triad (config + backend + frontend). `baas` is the backend
9
- * alone, serving the database over REST with no collection files and no UI.
10
- */
11
- /**
12
- * `cms` scaffolds BaaS + the admin UI; `baas` scaffolds the API alone. The
13
- * values match `RebaseBackendConfig.mode`, which is what the generated backend
14
- * sets — the labels below are what users actually read.
15
- */
16
- export type TemplateFlavor = "cms" | "baas";
17
5
  export interface InitOptions {
18
6
  projectName: string;
19
7
  git: boolean;
@@ -26,8 +14,8 @@ export interface InitOptions {
26
14
  preset: TemplatePreset;
27
15
  /** Whether `preset` came from an explicit --template rather than the default. */
28
16
  explicitPreset?: boolean;
29
- /** Which parts of Rebase to scaffold. */
30
- flavor: TemplateFlavor;
17
+ /** Scaffold the backend alone, with no admin panel and no collections. */
18
+ headless: boolean;
31
19
  /** Detected package manager (pnpm or npm). */
32
20
  pm: PackageManager;
33
21
  /** Command helpers for the detected PM. */
@@ -42,7 +30,7 @@ export interface InitOptions {
42
30
  export interface BuildQuestionsParams {
43
31
  nameArg?: string;
44
32
  templateArg?: TemplatePreset;
45
- flavorArg?: TemplateFlavor;
33
+ headlessArg?: boolean;
46
34
  hasGitFlag: boolean;
47
35
  hasInstallFlag: boolean;
48
36
  pm: PackageManager;
@@ -4,6 +4,8 @@ export interface FoldableManifest {
4
4
  type?: string;
5
5
  build?: string;
6
6
  output?: string;
7
+ path?: string;
8
+ spa?: boolean;
7
9
  }>;
8
10
  }
9
11
  export interface FoldOptions {
@@ -11,36 +13,60 @@ export interface FoldOptions {
11
13
  manifest: FoldableManifest;
12
14
  /** The backend bundle directory, already written. */
13
15
  bundleDir: string;
14
- /** Skip running the app's own build command; fold what is already built. */
16
+ /** Skip running each app's own build command; fold what is already built. */
15
17
  skipBuild?: boolean;
16
18
  log?: (message: string) => void;
17
19
  }
18
20
  export interface FoldOutcome {
19
21
  appName: string;
20
22
  fileCount: number;
23
+ /** Public base path this app was folded in at. */
24
+ path: string;
25
+ }
26
+ /** A static app as folding sees it, with the manifest's defaults applied. */
27
+ export interface FoldableApp {
28
+ name: string;
29
+ build?: string;
30
+ output?: string;
31
+ /** Public base path, defaulted to `/`. */
32
+ path: string;
33
+ /** SPA fallback, defaulted to `true`. */
34
+ spa: boolean;
21
35
  }
22
36
  /**
23
- * Which static app, if any, should be served by the backend.
37
+ * Every static app in the manifest, in mount order.
24
38
  *
25
- * Exactly one `static` app is folded. With several, folding would have to choose,
26
- * and silently picking one of two websites is worse than doing nothing — so it
27
- * declines and names what it saw. Pure, so the decision is testable without a
28
- * filesystem.
39
+ * Longest path first, so the `/`-rooted app is registered last — its catch-all
40
+ * would otherwise claim its siblings' URLs. Pure, so the ordering is testable
41
+ * without a filesystem.
29
42
  */
30
- export declare function selectFoldableApp(manifest: FoldableManifest): {
31
- app?: {
43
+ export declare function foldableApps(manifest: FoldableManifest): {
44
+ apps: FoldableApp[];
45
+ /** Apps that cannot be folded, and why. */
46
+ skipped: {
32
47
  name: string;
33
- build?: string;
34
- output?: string;
35
- };
36
- /** Why nothing will be folded, when that is the answer. */
37
- reason?: string;
48
+ reason: string;
49
+ }[];
38
50
  };
39
51
  /**
40
- * Build the project's frontend and fold it into the backend bundle.
52
+ * Assert a built app's assets are actually rooted at the path it is served from.
53
+ *
54
+ * An app mounted at `/admin` but built with Vite's default `base: "/"` emits
55
+ * `<script src="/assets/index-a1b2.js">`. The server serves `index.html` fine
56
+ * and 404s every asset: a blank page, no server error, nothing in the logs. It
57
+ * is the single most expensive silent failure in this design, so it is a build
58
+ * error rather than a runtime surprise.
59
+ *
60
+ * Only `<script src>` and `<link href>` are inspected — those are what a bundler
61
+ * rewrites through `base`. Author-written anchors and canonical URLs are not
62
+ * evidence of a misbuild.
63
+ */
64
+ export declare function assertBuiltForPath(indexHtml: string, basePath: string, appName: string): void;
65
+ /**
66
+ * Build the project's static apps and fold them into the backend bundle.
41
67
  *
42
68
  * Throws rather than exiting, so the caller decides whether a missing frontend
43
69
  * should fail its command — a `build` may reasonably want to stop, and so should
44
70
  * a deploy, but that is not this function's call to make.
45
71
  */
46
- export declare function foldFrontendIntoBundle(options: FoldOptions): Promise<FoldOutcome | null>;
72
+ export declare function foldFrontendIntoBundle(options: FoldOptions): Promise<FoldOutcome[]>;
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from "./commands/schema";
4
4
  export * from "./commands/db";
5
5
  export * from "./commands/dev";
6
6
  export * from "./commands/build";
7
+ export * from "./commands/eject";
7
8
  export * from "./commands/start";
8
9
  export * from "./commands/auth";
9
10
  export * from "./commands/doctor";