@rebasepro/cli 0.10.1-canary.d8d45b2 → 0.10.1-canary.ed78a2c
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/dist/bundle.d.ts +56 -0
- package/dist/commands/cloud/bundle-deploy.d.ts +25 -0
- package/dist/commands/cloud/deploy.d.ts +48 -0
- package/dist/commands/generate_sdk.d.ts +13 -0
- package/dist/fold-static.d.ts +46 -0
- package/dist/index.es.js +351 -7
- package/dist/index.es.js.map +1 -1
- package/package.json +7 -7
- package/templates/overlays/baas/backend/src/index.ts +7 -0
- package/templates/overlays/baas/backend/src/storage.ts +71 -0
- package/templates/template/.env.example +5 -0
- package/templates/template/README.md +8 -3
- package/templates/template/backend/src/index.ts +7 -0
- package/templates/template/config/admin.d.ts +9 -0
- package/templates/template/config/collections/authors.ts +12 -10
- package/templates/template/config/collections/posts.ts +17 -13
- package/templates/template/config/collections/presets/ecommerce/categories.ts +8 -6
- package/templates/template/config/collections/presets/ecommerce/orders.ts +33 -21
- package/templates/template/config/collections/presets/ecommerce/products.ts +27 -18
- package/templates/template/config/collections/tags.ts +6 -4
- package/templates/template/config/collections/users.ts +35 -30
- package/templates/template/config/frontend-assets.d.ts +17 -0
- package/templates/template/config/index.ts +6 -0
- package/templates/template/config/package.json +26 -25
- package/templates/template/config/storage.ts +88 -0
package/dist/bundle.d.ts
CHANGED
|
@@ -80,6 +80,27 @@ export declare function normalizeEsmSpecifiers(outDir: string): {
|
|
|
80
80
|
rewritten: number;
|
|
81
81
|
unresolved: string[];
|
|
82
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* A hand-written server entrypoint that a bundle does not use.
|
|
85
|
+
*
|
|
86
|
+
* `rebase dev` runs `backend/src/index.ts` whenever a project has one, so for
|
|
87
|
+
* the whole of local development that file *is* the server and every route
|
|
88
|
+
* written in it works. A bundle has no entrypoint of its own: the runtime boots
|
|
89
|
+
* the bundle and mounts what the manifest points at — the config package,
|
|
90
|
+
* functions, crons and the schema. The file is not compiled, not shipped, and
|
|
91
|
+
* never imported.
|
|
92
|
+
*
|
|
93
|
+
* Nothing said so. A project with custom routes in its entrypoint built clean,
|
|
94
|
+
* deployed green, and answered 404 on every one of them, with the file still
|
|
95
|
+
* sitting in the repository looking exactly like the server.
|
|
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.
|
|
102
|
+
*/
|
|
103
|
+
export declare function findUnusedServerEntry(projectRoot: string, functionsDir: string): string | undefined;
|
|
83
104
|
/**
|
|
84
105
|
* Compile and assemble a bundle.
|
|
85
106
|
*/
|
|
@@ -98,6 +119,41 @@ export declare function buildBundle(options: BuildBundleOptions): Promise<BuildB
|
|
|
98
119
|
* manifest — no compilation, no dependency closure (a static bundle installs
|
|
99
120
|
* nothing at boot).
|
|
100
121
|
*/
|
|
122
|
+
/**
|
|
123
|
+
* Fold a built static app into a backend bundle, so one runtime serves both.
|
|
124
|
+
*
|
|
125
|
+
* ## Why this exists
|
|
126
|
+
*
|
|
127
|
+
* A managed tenant runs one pod, and `bootFromBundle` on the backend path already
|
|
128
|
+
* knows how to serve a SPA — it looks for `entry.static` and mounts `serveSPA`
|
|
129
|
+
* last, behind `REBASE_SERVE_STATIC`. What was missing was anything putting the
|
|
130
|
+
* assets there.
|
|
131
|
+
*
|
|
132
|
+
* The consequence was not subtle. A project whose custom image served its website
|
|
133
|
+
* at `/` and its API at `/api` — the shape the scaffolded template produces — lost
|
|
134
|
+
* the website the moment it moved to the managed runtime: the API answered
|
|
135
|
+
* perfectly and every page 404'd. Managed could not be a drop-in replacement for
|
|
136
|
+
* custom while the frontend simply vanished.
|
|
137
|
+
*
|
|
138
|
+
* Folding restores parity with the container it replaces, which is the only
|
|
139
|
+
* honest baseline. It is deliberately the FIRST implementation and not the last:
|
|
140
|
+
* a static app on its own bucket behind a CDN is better for cache behaviour and
|
|
141
|
+
* lets the frontend deploy independently. But that needs infrastructure that does
|
|
142
|
+
* not exist yet, and "your site is gone" is not an acceptable state to leave a
|
|
143
|
+
* project in while it gets built.
|
|
144
|
+
*
|
|
145
|
+
* The trade it makes, stated plainly: frontend and backend now deploy together
|
|
146
|
+
* and the bundle carries the built assets. For a project that was shipping both
|
|
147
|
+
* in one image already, that is exactly what it had.
|
|
148
|
+
*/
|
|
149
|
+
export declare function foldStaticIntoBundle(options: {
|
|
150
|
+
/** The backend bundle directory, already written. */
|
|
151
|
+
bundleDir: string;
|
|
152
|
+
/** Directory of built frontend assets (the static app's `output`). */
|
|
153
|
+
assetsDir: string;
|
|
154
|
+
}): {
|
|
155
|
+
fileCount: number;
|
|
156
|
+
};
|
|
101
157
|
export declare function buildStaticBundle(options: {
|
|
102
158
|
projectRoot: string;
|
|
103
159
|
appName: string;
|
|
@@ -23,6 +23,31 @@ export declare function bundleDeployBody(input: {
|
|
|
23
23
|
manifest: RebaseBundleManifest;
|
|
24
24
|
app?: string;
|
|
25
25
|
message?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Every app this repository declares in `rebase.json`, so the platform can
|
|
28
|
+
* register the whole set rather than only the one being deployed.
|
|
29
|
+
*/
|
|
30
|
+
declaredApps?: DeclaredApp[];
|
|
26
31
|
}): Record<string, unknown>;
|
|
32
|
+
/** An app as `rebase.json` declares it, reduced to what the registry stores. */
|
|
33
|
+
export interface DeclaredApp {
|
|
34
|
+
name: string;
|
|
35
|
+
type: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The apps a project manifest declares.
|
|
39
|
+
*
|
|
40
|
+
* A deploy only ever ships ONE app's bundle, so the trigger alone could never
|
|
41
|
+
* tell the platform that the repository also contains a web frontend and an
|
|
42
|
+
* admin panel — and the Apps page, whose whole job is to show the set, listed a
|
|
43
|
+
* single entry called "backend". Sending the declared set fixes that without
|
|
44
|
+
* pretending the others are deployed: the platform registers them, and their
|
|
45
|
+
* status says what is actually true.
|
|
46
|
+
*/
|
|
47
|
+
export declare function declaredAppsFrom(manifest: {
|
|
48
|
+
apps?: Record<string, {
|
|
49
|
+
type?: string;
|
|
50
|
+
}>;
|
|
51
|
+
} | null | undefined): DeclaredApp[];
|
|
27
52
|
/** Upload a bundle archive; returns the control-plane bundle id. */
|
|
28
53
|
export declare function uploadBundle(url: string, token: string, projectId: string, tarPath: string): Promise<string>;
|
|
@@ -1,2 +1,50 @@
|
|
|
1
|
+
/** A project row, reduced to what says how it deploys (camel or snake columns). */
|
|
2
|
+
export interface DeployProjectRow {
|
|
3
|
+
runtimeMode?: string;
|
|
4
|
+
runtime_mode?: string;
|
|
5
|
+
gitRepoUrl?: string;
|
|
6
|
+
git_repo_url?: string;
|
|
7
|
+
gitBranch?: string;
|
|
8
|
+
git_branch?: string;
|
|
9
|
+
}
|
|
10
|
+
/** A deployment row, reduced to what says what it was built from. */
|
|
11
|
+
export interface DeploySourceRow {
|
|
12
|
+
id?: string | number;
|
|
13
|
+
status?: string;
|
|
14
|
+
createdAt?: string | Date;
|
|
15
|
+
created_at?: string | Date;
|
|
16
|
+
sourceRef?: string;
|
|
17
|
+
source_ref?: string;
|
|
18
|
+
bundleId?: string;
|
|
19
|
+
bundle_id?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface BareDeployPlan {
|
|
22
|
+
/**
|
|
23
|
+
* Whether the project runs the platform runtime — in which case any source
|
|
24
|
+
* build here ejects it back onto a container image.
|
|
25
|
+
*/
|
|
26
|
+
managed: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* `git` — the control plane will clone the configured repository.
|
|
29
|
+
* `snapshot` — it will rebuild the newest uploaded source archive.
|
|
30
|
+
* `none` — it holds neither, and will refuse.
|
|
31
|
+
*/
|
|
32
|
+
source: "git" | "snapshot" | "none";
|
|
33
|
+
/** Lines describing the build, printed before it is triggered. */
|
|
34
|
+
lines: string[];
|
|
35
|
+
}
|
|
36
|
+
/** Rough age of a timestamp, for "…uploaded 6d ago". Undefined if unreadable. */
|
|
37
|
+
export declare function timeAgo(value: string | Date | undefined, now: Date): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Whether this project runs on the managed runtime.
|
|
40
|
+
*
|
|
41
|
+
* `runtimeMode` on the project row is the authority — the control plane writes
|
|
42
|
+
* it. The bundle-id fallback covers a control plane that does not return the
|
|
43
|
+
* field: a successful deploy that served a bundle only happens on the managed
|
|
44
|
+
* path.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isManagedProject(project: DeployProjectRow | undefined, latest: DeploySourceRow | undefined): boolean;
|
|
47
|
+
/** What a `deploy` with nothing attached will build, in the words to print. */
|
|
48
|
+
export declare function planBareDeploy(project: DeployProjectRow | undefined, latest: DeploySourceRow | undefined, now: Date): BareDeployPlan;
|
|
1
49
|
export declare function deployCommand(rawArgs: string[], projectRef: string): Promise<void>;
|
|
2
50
|
export declare function logsCommand(rawArgs: string[], projectRef: string): Promise<void>;
|
|
@@ -23,6 +23,19 @@ interface GenerateSDKArgs {
|
|
|
23
23
|
token?: string;
|
|
24
24
|
help?: boolean;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The base URL to show in the printed usage example.
|
|
28
|
+
*
|
|
29
|
+
* `rebase dev` binds a port derived from the project path, not 3001, and writes
|
|
30
|
+
* the one it actually got to `.rebase/state.json`. Printing a hardcoded
|
|
31
|
+
* `localhost:3001` sent people to a port nothing was listening on — or, with
|
|
32
|
+
* several projects on one machine, to a different project's backend. Prefer the
|
|
33
|
+
* port this project last ran on; fall back to the literal only when the project
|
|
34
|
+
* has never been started.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveExampleBaseUrl(cwd: string): string;
|
|
37
|
+
/** Whether a slug can be written as `rebase.data.<slug>` rather than a lookup. */
|
|
38
|
+
export declare function isIdentifierLike(slug: string): boolean;
|
|
26
39
|
/**
|
|
27
40
|
* Main entry point for the generate-sdk command.
|
|
28
41
|
*/
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** The apps section of a project manifest, as much of it as folding needs. */
|
|
2
|
+
export interface FoldableManifest {
|
|
3
|
+
apps?: Record<string, {
|
|
4
|
+
type?: string;
|
|
5
|
+
build?: string;
|
|
6
|
+
output?: string;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
export interface FoldOptions {
|
|
10
|
+
projectRoot: string;
|
|
11
|
+
manifest: FoldableManifest;
|
|
12
|
+
/** The backend bundle directory, already written. */
|
|
13
|
+
bundleDir: string;
|
|
14
|
+
/** Skip running the app's own build command; fold what is already built. */
|
|
15
|
+
skipBuild?: boolean;
|
|
16
|
+
log?: (message: string) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface FoldOutcome {
|
|
19
|
+
appName: string;
|
|
20
|
+
fileCount: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Which static app, if any, should be served by the backend.
|
|
24
|
+
*
|
|
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.
|
|
29
|
+
*/
|
|
30
|
+
export declare function selectFoldableApp(manifest: FoldableManifest): {
|
|
31
|
+
app?: {
|
|
32
|
+
name: string;
|
|
33
|
+
build?: string;
|
|
34
|
+
output?: string;
|
|
35
|
+
};
|
|
36
|
+
/** Why nothing will be folded, when that is the answer. */
|
|
37
|
+
reason?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Build the project's frontend and fold it into the backend bundle.
|
|
41
|
+
*
|
|
42
|
+
* Throws rather than exiting, so the caller decides whether a missing frontend
|
|
43
|
+
* should fail its command — a `build` may reasonably want to stop, and so should
|
|
44
|
+
* a deploy, but that is not this function's call to make.
|
|
45
|
+
*/
|
|
46
|
+
export declare function foldFrontendIntoBundle(options: FoldOptions): Promise<FoldOutcome | null>;
|