@rebasepro/cli 0.10.1-canary.18115ba → 0.10.1-canary.262a5be
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.
- package/README.md +1 -1
- package/dist/bundle.d.ts +111 -0
- package/dist/commands/apps.d.ts +1 -0
- package/dist/commands/build.d.ts +1 -1
- package/dist/commands/cloud/bundle-deploy.d.ts +28 -0
- package/dist/commands/cloud/context.d.ts +18 -0
- package/dist/commands/generate_sdk.d.ts +12 -0
- package/dist/commands/start.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +2051 -29
- package/dist/index.es.js.map +1 -1
- package/dist/manifest.d.ts +83 -0
- package/dist/utils/project.d.ts +11 -3
- package/package.json +8 -7
- package/runtime/dev-server.mjs +43 -0
- package/templates/overlays/baas/backend/src/index.ts +21 -4
- package/templates/overlays/baas/rebase.json +14 -0
- package/templates/template/.env.example +16 -3
- package/templates/template/README.md +39 -29
- package/templates/template/backend/src/index.ts +21 -4
- package/templates/template/gitignore +4 -0
- package/templates/template/rebase.json +20 -0
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ The CLI is also bundled with every Rebase project as a local dependency.
|
|
|
20
20
|
| `rebase start` | Start the backend server (production) |
|
|
21
21
|
| `rebase schema generate` | Generate Drizzle schema from collection definitions |
|
|
22
22
|
| `rebase schema introspect` | Introspect an existing database → Rebase collections |
|
|
23
|
-
| `rebase db push` | Apply schema directly to database (dev) |
|
|
23
|
+
| `rebase db push` | Apply schema directly to database (dev). Previews the plan and refuses destructive changes (e.g. dropped columns) unless confirmed interactively or run with `--allow-destructive`. |
|
|
24
24
|
| `rebase db generate` | Generate SQL migration files |
|
|
25
25
|
| `rebase db migrate` | Run pending migrations |
|
|
26
26
|
| `rebase generate-sdk` | Generate a typed TypeScript SDK from collections |
|
package/dist/bundle.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { type NativeDependency, type RebaseBundleManifest, type RebaseBackendAppConfig } from "@rebasepro/types";
|
|
2
|
+
export declare const DEFAULT_BUNDLE_DIR = "dist-bundle";
|
|
3
|
+
export interface BuildBundleOptions {
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
appName: string;
|
|
6
|
+
app: RebaseBackendAppConfig;
|
|
7
|
+
/** Output directory, absolute or relative to the project root. */
|
|
8
|
+
outDir?: string;
|
|
9
|
+
/** Runtime range from the manifest, recorded for compatibility checks. */
|
|
10
|
+
runtimeRange: string;
|
|
11
|
+
/** Skip type checking. Faster, and strictly worse — for iteration only. */
|
|
12
|
+
skipTypeCheck?: boolean;
|
|
13
|
+
/** Skip regenerating the Drizzle schema from the collections. */
|
|
14
|
+
skipSchema?: boolean;
|
|
15
|
+
/** Emit progress. */
|
|
16
|
+
log?: (message: string) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface BuildBundleResult {
|
|
19
|
+
outDir: string;
|
|
20
|
+
manifest: RebaseBundleManifest;
|
|
21
|
+
collectionCount: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether the compiled config package exports a `storageAuthorize` hook.
|
|
25
|
+
*
|
|
26
|
+
* Recorded in the manifest so a host can refuse a deploy that would enable file
|
|
27
|
+
* storage with no access model, rather than let the runtime's boot guard turn it
|
|
28
|
+
* into a crash loop the developer cannot read.
|
|
29
|
+
*
|
|
30
|
+
* Read from the *compiled* index, deliberately: that is the exact module the
|
|
31
|
+
* runtime imports and reads the export off, so this cannot disagree with what
|
|
32
|
+
* actually happens at boot. It is a textual check rather than an import because
|
|
33
|
+
* a freshly built bundle cannot resolve its own dependencies until it is
|
|
34
|
+
* deployed — the same reason schema hashing reads source.
|
|
35
|
+
*
|
|
36
|
+
* Errs toward `false`: a missed detection costs a deploy rejection whose message
|
|
37
|
+
* says exactly how to proceed, while a false positive would hand back the crash
|
|
38
|
+
* loop this exists to prevent.
|
|
39
|
+
*/
|
|
40
|
+
export declare function detectStorageAuthorize(compiledConfigDir: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Detect native code in the dependency closure.
|
|
43
|
+
*
|
|
44
|
+
* Walks declared runtime dependencies breadth-first through `node_modules`,
|
|
45
|
+
* flagging anything with a `binding.gyp`, a prebuilt `.node` binary, or an
|
|
46
|
+
* install script that builds one. The managed runtime cannot run these: a
|
|
47
|
+
* binary compiled for one image will not load in another, and finding that out
|
|
48
|
+
* at deploy time is far better than in a crash loop.
|
|
49
|
+
*
|
|
50
|
+
* The walk is bounded. A dependency graph can be enormous, and this is a
|
|
51
|
+
* heuristic gate whose false negatives are caught at deploy time anyway.
|
|
52
|
+
*/
|
|
53
|
+
export declare function detectNativeDependencies(projectRoot: string, declared: Record<string, string>, limit?: number): NativeDependency[];
|
|
54
|
+
/**
|
|
55
|
+
* Collect the runtime dependencies a bundle needs installed beside it.
|
|
56
|
+
*
|
|
57
|
+
* Packages the runtime image already provides are excluded — reinstalling a
|
|
58
|
+
* second copy of the server next to the one running the process is at best
|
|
59
|
+
* wasted space and at worst a version conflict. Workspace packages are excluded
|
|
60
|
+
* too: they are not on the registry the runtime installs from, and the project's
|
|
61
|
+
* own config package already travels inside the bundle.
|
|
62
|
+
*/
|
|
63
|
+
export declare function collectDeclaredDependencies(projectRoot: string): Record<string, string>;
|
|
64
|
+
/**
|
|
65
|
+
* Rewrite relative import specifiers in emitted JavaScript so Node can resolve them.
|
|
66
|
+
*
|
|
67
|
+
* TypeScript deliberately does not touch specifiers: `moduleResolution: "bundler"`
|
|
68
|
+
* lets a project write `from "./posts"` or `from "./collections"`, and TypeScript
|
|
69
|
+
* emits them unchanged on the assumption that a bundler will finish the job.
|
|
70
|
+
* Nothing bundles a Rebase bundle — the runtime imports these files directly with
|
|
71
|
+
* Node's ESM loader, which requires a full path with an extension and refuses
|
|
72
|
+
* directory imports outright.
|
|
73
|
+
*
|
|
74
|
+
* Without this, adopting the bundle would mean asking every project written in
|
|
75
|
+
* the (extremely common) extensionless style to rewrite all of its imports. The
|
|
76
|
+
* rewrite is mechanical and verifiable: only relative specifiers are touched, and
|
|
77
|
+
* only when the target file actually exists on disk.
|
|
78
|
+
*/
|
|
79
|
+
export declare function normalizeEsmSpecifiers(outDir: string): {
|
|
80
|
+
rewritten: number;
|
|
81
|
+
unresolved: string[];
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Compile and assemble a bundle.
|
|
85
|
+
*/
|
|
86
|
+
export declare function buildBundle(options: BuildBundleOptions): Promise<BuildBundleResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Package a built static app (a `static` or bundled-`admin` app) into a bundle.
|
|
89
|
+
*
|
|
90
|
+
* A static bundle is the counterpart to a backend bundle: the same shape, the
|
|
91
|
+
* same runtime image runs it, but its manifest says `mode: "static"` and it
|
|
92
|
+
* carries only the built assets under `static/`. That is what lets a frontend or
|
|
93
|
+
* admin app be its own deployable, scalable unit rather than something baked into
|
|
94
|
+
* the backend container.
|
|
95
|
+
*
|
|
96
|
+
* `assetsDir` is the app's built output (e.g. `frontend/dist`), already produced
|
|
97
|
+
* by its own build command. This copies it into the bundle and writes the
|
|
98
|
+
* manifest — no compilation, no dependency closure (a static bundle installs
|
|
99
|
+
* nothing at boot).
|
|
100
|
+
*/
|
|
101
|
+
export declare function buildStaticBundle(options: {
|
|
102
|
+
projectRoot: string;
|
|
103
|
+
appName: string;
|
|
104
|
+
assetsDir: string;
|
|
105
|
+
outDir: string;
|
|
106
|
+
runtimeRange: string;
|
|
107
|
+
}): {
|
|
108
|
+
outDir: string;
|
|
109
|
+
manifest: RebaseBundleManifest;
|
|
110
|
+
fileCount: number;
|
|
111
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function appsCommand(subcommand: string | undefined, rawArgs?: string[]): Promise<void>;
|
package/dist/commands/build.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function buildCommand(): Promise<void>;
|
|
1
|
+
export declare function buildCommand(rawArgs?: string[]): Promise<void>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RebaseBundleManifest } from "@rebasepro/types";
|
|
2
|
+
/** Read and shallow-validate a built bundle's manifest. */
|
|
3
|
+
export declare function readBundleManifest(bundleDir: string): RebaseBundleManifest;
|
|
4
|
+
/**
|
|
5
|
+
* Tar a built bundle into a gzipped archive.
|
|
6
|
+
*
|
|
7
|
+
* `node_modules` is excluded on purpose: the bundle ships a `package.json`, and
|
|
8
|
+
* the managed runtime installs the declared dependencies at boot. Uploading an
|
|
9
|
+
* installed `node_modules` would bloat the archive and could carry a
|
|
10
|
+
* platform-specific build that will not run on the runtime image.
|
|
11
|
+
*/
|
|
12
|
+
export declare function packBundle(bundleDir: string, outPath: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Assemble the deploy-trigger body for a bundle deploy.
|
|
15
|
+
*
|
|
16
|
+
* The manifest travels with the trigger so the control plane can validate intake
|
|
17
|
+
* without unpacking the uploaded archive first — a rejection (native deps, no
|
|
18
|
+
* matching runtime) is then a fast, cheap answer.
|
|
19
|
+
*/
|
|
20
|
+
export declare function bundleDeployBody(input: {
|
|
21
|
+
projectId: string;
|
|
22
|
+
bundleId: string;
|
|
23
|
+
manifest: RebaseBundleManifest;
|
|
24
|
+
app?: string;
|
|
25
|
+
message?: string;
|
|
26
|
+
}): Record<string, unknown>;
|
|
27
|
+
/** Upload a bundle archive; returns the control-plane bundle id. */
|
|
28
|
+
export declare function uploadBundle(url: string, token: string, projectId: string, tarPath: string): Promise<string>;
|
|
@@ -62,6 +62,24 @@ export interface ProjectLink {
|
|
|
62
62
|
slug?: string;
|
|
63
63
|
projectName?: string;
|
|
64
64
|
orgId?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Base URL of the project's own API.
|
|
67
|
+
*
|
|
68
|
+
* For a cloud project this is a convenience derived from the subdomain. For
|
|
69
|
+
* a **self-hosted** project it is the entire link: there is no control plane
|
|
70
|
+
* to look anything up in, so `projectId` is empty and this is what commands
|
|
71
|
+
* resolve against.
|
|
72
|
+
*
|
|
73
|
+
* Keeping both kinds of link in one file is deliberate. A second link file
|
|
74
|
+
* for self-hosting would fork every command that reads one, and the tooling
|
|
75
|
+
* would drift into being cloud-only by accident.
|
|
76
|
+
*/
|
|
77
|
+
apiUrl?: string;
|
|
78
|
+
/**
|
|
79
|
+
* How this checkout is linked. Absent means `cloud` — which is every link
|
|
80
|
+
* written before this field existed.
|
|
81
|
+
*/
|
|
82
|
+
mode?: "cloud" | "direct";
|
|
65
83
|
}
|
|
66
84
|
export declare function readLink(cwd?: string): ProjectLink | null;
|
|
67
85
|
export declare function writeLink(link: ProjectLink, cwd?: string): void;
|
|
@@ -10,6 +10,18 @@ interface GenerateSDKArgs {
|
|
|
10
10
|
collectionsDir: string;
|
|
11
11
|
output: string;
|
|
12
12
|
cwd: string;
|
|
13
|
+
/**
|
|
14
|
+
* Where to read the schema from instead of local source.
|
|
15
|
+
*
|
|
16
|
+
* `link` uses this checkout's linked project; anything else is treated as
|
|
17
|
+
* the base URL of a Rebase backend. This is what lets a repository that
|
|
18
|
+
* contains no collections — a separate frontend, a second web app — generate
|
|
19
|
+
* a typed client from the project it talks to.
|
|
20
|
+
*/
|
|
21
|
+
from?: string;
|
|
22
|
+
/** Bearer token for the contract endpoint. Falls back to REBASE_SERVICE_KEY. */
|
|
23
|
+
token?: string;
|
|
24
|
+
help?: boolean;
|
|
13
25
|
}
|
|
14
26
|
/**
|
|
15
27
|
* Main entry point for the generate-sdk command.
|
package/dist/commands/start.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function startCommand(): Promise<void>;
|
|
1
|
+
export declare function startCommand(rawArgs?: string[]): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,8 @@ export * from "./commands/auth";
|
|
|
9
9
|
export * from "./commands/doctor";
|
|
10
10
|
export * from "./commands/generate_sdk";
|
|
11
11
|
export * from "./commands/cloud";
|
|
12
|
+
export * from "./commands/apps";
|
|
12
13
|
export * from "./utils/project";
|
|
13
14
|
export * from "./utils/package-manager";
|
|
15
|
+
export * from "./manifest";
|
|
16
|
+
export * from "./bundle";
|