@rebasepro/cli 0.10.0 → 0.10.1-canary.14e53ae
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 +28 -0
- package/dist/commands/cloud/deployments.d.ts +16 -0
- package/dist/commands/cloud/env.d.ts +2 -0
- package/dist/commands/cloud/resources.d.ts +38 -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 +2380 -87
- package/dist/index.es.js.map +1 -1
- package/dist/manifest.d.ts +83 -0
- package/dist/utils/package-manager.d.ts +26 -2
- 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;
|
|
@@ -100,6 +118,16 @@ export declare function initOutputMode(rawArgs: string[]): boolean;
|
|
|
100
118
|
export declare function isJsonMode(): boolean;
|
|
101
119
|
/** Force the mode (tests only — production latches it via `initOutputMode`). */
|
|
102
120
|
export declare function setJsonModeForTest(value: boolean): void;
|
|
121
|
+
/**
|
|
122
|
+
* Write one JSON value to stdout, followed by a newline.
|
|
123
|
+
*
|
|
124
|
+
* Indented, because the overwhelmingly common reader is a person or an agent
|
|
125
|
+
* looking at a terminal — JSON mode is entered automatically whenever stdout is
|
|
126
|
+
* not a TTY, so `rebase cloud deployments list` piped anywhere at all produced
|
|
127
|
+
* a project's entire deployment history as one unwrapped line. `JSON.parse`
|
|
128
|
+
* does not care about the whitespace; everything else does.
|
|
129
|
+
*/
|
|
130
|
+
export declare function printJson(value: unknown): void;
|
|
103
131
|
/**
|
|
104
132
|
* The one output primitive every new command uses: in JSON mode emit `json`
|
|
105
133
|
* (and nothing else); otherwise run `human`. Keeping the two behind a single
|
|
@@ -18,6 +18,10 @@ export interface DeploymentRow {
|
|
|
18
18
|
triggered_by_user_id?: string;
|
|
19
19
|
gitCommitHash?: string;
|
|
20
20
|
gitCommitMessage?: string;
|
|
21
|
+
deployMessage?: string;
|
|
22
|
+
deploy_message?: string;
|
|
23
|
+
frameworkVersion?: string;
|
|
24
|
+
framework_version?: string;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
27
|
* The backend's rule EXACTLY: a rollback is honoured only for a successful
|
|
@@ -33,6 +37,18 @@ export declare function triggerInfo(dep: DeploymentRow): {
|
|
|
33
37
|
};
|
|
34
38
|
/** Shape one deployment row into the stable JSON view the CLI publishes. */
|
|
35
39
|
export declare function deploymentView(dep: DeploymentRow): Record<string, unknown>;
|
|
40
|
+
/**
|
|
41
|
+
* Rows shown when `--limit` is not given.
|
|
42
|
+
*
|
|
43
|
+
* History is unbounded and grows one row per deploy, so "all of it" is the
|
|
44
|
+
* wrong default in both directions: a wall of near-identical lines in a
|
|
45
|
+
* terminal, and — since JSON mode is entered automatically for any non-TTY
|
|
46
|
+
* stdout — a project's entire history dumped at anything that pipes the
|
|
47
|
+
* command. Recent deploys are what the question is almost always about.
|
|
48
|
+
*/
|
|
49
|
+
export declare const DEFAULT_DEPLOYMENTS_LIMIT = 20;
|
|
50
|
+
/** `--limit N`, bounded. A garbage value is a refusal, never a silent default. */
|
|
51
|
+
export declare function parseDeploymentsLimit(raw: number | undefined): number;
|
|
36
52
|
export declare function deploymentsListCommand(rawArgs: string[]): Promise<void>;
|
|
37
53
|
export declare function rollbackCommand(rawArgs: string[]): Promise<void>;
|
|
38
54
|
export declare function cancelCommand(rawArgs: string[]): Promise<void>;
|
|
@@ -1,6 +1,44 @@
|
|
|
1
|
+
/** The control plane's verdict on what a tenant's uploads actually do. */
|
|
2
|
+
interface StorageState {
|
|
3
|
+
effective?: {
|
|
4
|
+
kind?: string;
|
|
5
|
+
summary?: string;
|
|
6
|
+
storageType?: string;
|
|
7
|
+
missing?: string[];
|
|
8
|
+
};
|
|
9
|
+
source?: string;
|
|
10
|
+
configured?: string;
|
|
11
|
+
overridden?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* One line describing this project's storage — or `undefined` when the control
|
|
15
|
+
* plane could not be asked, which prints as a blank rather than a guess.
|
|
16
|
+
*
|
|
17
|
+
* `status` used to render the `storages` row and nothing else, so a project
|
|
18
|
+
* whose bucket is configured through its own `STORAGE_TYPE`/`S3_*` variables —
|
|
19
|
+
* the supported path, and the one `mergeStorageEnv` deliberately lets WIN over
|
|
20
|
+
* the row — was reported as `Storage: none` while its pod logged `Initialized
|
|
21
|
+
* storage backends count: 1` against a live bucket. Storage is the thing an app
|
|
22
|
+
* refuses to boot without, so that false negative sends someone off to
|
|
23
|
+
* provision a bucket they already have. The row is not the answer; the tenant's
|
|
24
|
+
* resolved environment is, and the control plane computes it with the same two
|
|
25
|
+
* functions the build log uses.
|
|
26
|
+
*/
|
|
27
|
+
export declare function describeStorageState(state: StorageState | undefined): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* One line describing the database.
|
|
30
|
+
*
|
|
31
|
+
* `connectionStatus` is written `"untested"` at creation and only ever changed
|
|
32
|
+
* by `rebase cloud db test`, so `managed (untested)` was reporting the absence
|
|
33
|
+
* of a manual test as though it were the database's condition — on a project
|
|
34
|
+
* that had just deployed against it. A never-tested database says only its
|
|
35
|
+
* type; the verdict appears once there is one.
|
|
36
|
+
*/
|
|
37
|
+
export declare function describeDatabaseState(db: Record<string, unknown> | undefined): string | undefined;
|
|
1
38
|
export declare function statusCommand(rawArgs: string[]): Promise<void>;
|
|
2
39
|
export declare function metricsCommand(rawArgs: string[]): Promise<void>;
|
|
3
40
|
export declare function webhooksCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void>;
|
|
4
41
|
export declare function storageCommand(action: string | undefined, rawArgs: string[]): Promise<void>;
|
|
5
42
|
export declare function clustersCommand(rawArgs: string[]): Promise<void>;
|
|
6
43
|
export declare function billingCommand(rawArgs: string[]): Promise<void>;
|
|
44
|
+
export {};
|
|
@@ -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";
|