@protobase/cli 0.46.13 → 0.46.14
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/build/bundle-plugins.js +1 -1
- package/dist/build/config-bundle.js +1 -3
- package/dist/build/deploy-bundle.js +4 -2
- package/dist/build/packages/host-packages.js +2 -13
- package/dist/build/plugin-build.js +1 -3
- package/dist/build/shell.js +1 -1
- package/dist/cli/package.js +1 -1
- package/dist/main.js +2 -0
- package/dist/serve/bundle-manifest.js +10 -0
- package/dist/serve/create-admin.js +2 -2
- package/dist/serve/migrate-bundle.js +2 -2
- package/dist/serve/serve-bundle.js +2 -2
- package/dist/serve/serve-dir.js +1 -1
- package/dist/serve/served-shell.js +3 -12
- package/dist/version/project-version.js +32 -0
- package/dist/worker/start-worker.js +3 -3
- package/package.json +6 -6
- package/skills/protobase/references/features/releases.md +1 -1
- package/skills/protobase/references/guides/deploy.md +1 -1
- package/skills/protobase/references/guides/plugin-build.md +2 -2
- package/skills/protobase/references/reference/cli.md +6 -6
- package/skills/protobase/references/reference/plugins.md +3 -3
- package/skills/protobase/references/reference/versioning.md +5 -11
- package/dist/serve/bundle-version.js +0 -16
- package/dist/version/compatibility.js +0 -31
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { projectUiFile } from "../project/project-ui.js";
|
|
2
1
|
import { readPackageJson } from "./packages/package-dir.js";
|
|
2
|
+
import { projectUiFile } from "../project/project-ui.js";
|
|
3
3
|
import { buildPlugin, pluginManifestFile } from "./plugin-build.js";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
@@ -5,7 +5,7 @@ import { hostModuleIds } from "../serve/host-module-ids.js";
|
|
|
5
5
|
import { collectComponents } from "./component-names.js";
|
|
6
6
|
import { bundleEntryCode } from "./entry-code.js";
|
|
7
7
|
import { layoutCheck } from "./layout-check.js";
|
|
8
|
-
import { hostPackages
|
|
8
|
+
import { hostPackages } from "./packages/host-packages.js";
|
|
9
9
|
import { isNativePackage } from "./packages/native-package.js";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
//#region src/build/config-bundle.ts
|
|
@@ -38,8 +38,6 @@ const servedImports = (native) => {
|
|
|
38
38
|
external: true
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
const problem = await hostVersionProblem(name, from);
|
|
42
|
-
if (problem) this.error(problem);
|
|
43
41
|
return {
|
|
44
42
|
id,
|
|
45
43
|
external: true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { projectProtobaseVersion } from "../version/project-version.js";
|
|
2
2
|
import { buildIcons } from "./app-icons.js";
|
|
3
3
|
import { bundleLayout, bundleMigrations, bundleNodeModules, manifestFile } from "../bundle/manifest.js";
|
|
4
4
|
import { buildBundlePlugins } from "./bundle-plugins.js";
|
|
@@ -46,6 +46,8 @@ const copyShell = async (publicDir, sourceMaps) => {
|
|
|
46
46
|
return shell;
|
|
47
47
|
};
|
|
48
48
|
const buildDeployBundle = async ({ projectDir, outDir, bun, extensions = [], sourceMaps = false, onWarning }) => {
|
|
49
|
+
const protobase = projectProtobaseVersion(projectDir);
|
|
50
|
+
if (protobase === void 0) throw new Error(`${projectDir} has no @protobase packages installed; install the project's dependencies first`);
|
|
49
51
|
await removeOwnFolder(outDir, bundleNodeModules, "nodeModules");
|
|
50
52
|
await removeOwnFolder(outDir, bundleMigrations, "migrations");
|
|
51
53
|
const components = /* @__PURE__ */ new Set();
|
|
@@ -82,7 +84,7 @@ const buildDeployBundle = async ({ projectDir, outDir, bun, extensions = [], sou
|
|
|
82
84
|
});
|
|
83
85
|
const manifest = {
|
|
84
86
|
version: 3,
|
|
85
|
-
protobase
|
|
87
|
+
protobase,
|
|
86
88
|
...bundleLayout,
|
|
87
89
|
api: [...bundleLayout.api],
|
|
88
90
|
plugins,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findPackageDirSync } from "./package-dir.js";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -23,16 +23,5 @@ const collectHostPackages = () => {
|
|
|
23
23
|
};
|
|
24
24
|
const declaredIn = collectHostPackages();
|
|
25
25
|
const hostPackages = new Set(declaredIn.keys());
|
|
26
|
-
const releaseLine = (version = "") => {
|
|
27
|
-
const [major, minor] = version.split(".");
|
|
28
|
-
return major === "0" ? `0.${minor}` : major;
|
|
29
|
-
};
|
|
30
|
-
const hostVersionProblem = async (name, importerDir) => {
|
|
31
|
-
const [projectDir, ownDir] = await Promise.all([findPackageDir(name, importerDir), findPackageDir(name, declaredIn.get(name) ?? cliRoot)]);
|
|
32
|
-
if (!projectDir || !ownDir || projectDir === ownDir) return void 0;
|
|
33
|
-
const [project, own] = await Promise.all([readPackageJson(projectDir), readPackageJson(ownDir)]);
|
|
34
|
-
if (releaseLine(project.version) === releaseLine(own.version)) return void 0;
|
|
35
|
-
return `${name} ${project.version} is installed here, but the serve runtime supplies ${name} ${own.version}; use a version compatible with it`;
|
|
36
|
-
};
|
|
37
26
|
//#endregion
|
|
38
|
-
export { hostPackages
|
|
27
|
+
export { hostPackages };
|
|
@@ -31,9 +31,7 @@ const pluginTarget = async (pluginDir, own, projectDir) => {
|
|
|
31
31
|
const theme = ui.exports?.["./theme.css"];
|
|
32
32
|
if (api === void 0 || typeof theme !== "string") throw new Error(`@protobase/ui ${ui.version} loads no plugins; install a version that does`);
|
|
33
33
|
const protobase = own.engines?.protobase ?? `>=${ui.version}`;
|
|
34
|
-
|
|
35
|
-
if (fits === void 0) throw new Error(`engines.protobase "${protobase}" is not a range the app reads; write comparators such as >=0.12.0 <1.0.0`);
|
|
36
|
-
if (!fits) throw new Error(`engines.protobase "${protobase}" leaves out @protobase/ui ${ui.version}, which the plugin is built with`);
|
|
34
|
+
if (inRange(ui.version ?? "", protobase) === void 0) throw new Error(`engines.protobase "${protobase}" is not a range the app reads; write comparators such as >=0.12.0 <1.0.0`);
|
|
37
35
|
return {
|
|
38
36
|
api,
|
|
39
37
|
protobase,
|
package/dist/build/shell.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { adminAppDir, uiEntry, uiPackageDir } from "../project/admin-app.js";
|
|
2
|
-
import { projectUiPlugin } from "../project/project-ui.js";
|
|
3
2
|
import { readPackageJson } from "./packages/package-dir.js";
|
|
3
|
+
import { projectUiPlugin } from "../project/project-ui.js";
|
|
4
4
|
import { sharedModulesPlugin } from "../project/shared-modules.js";
|
|
5
5
|
import { faviconLink } from "../project/favicon-link.js";
|
|
6
6
|
import { themeLink } from "../project/theme-link.js";
|
package/dist/cli/package.js
CHANGED
package/dist/main.js
CHANGED
|
@@ -16,6 +16,7 @@ import { registerImport } from "./supabase/register.js";
|
|
|
16
16
|
import { registerToken, registerUsers } from "./users/register.js";
|
|
17
17
|
import { ExitSignal } from "./exit-signal.js";
|
|
18
18
|
import { errorMessage } from "./error-message.js";
|
|
19
|
+
import { checkProjectMajor } from "./version/project-version.js";
|
|
19
20
|
import { statSync } from "node:fs";
|
|
20
21
|
import path from "node:path";
|
|
21
22
|
import { Command, InvalidArgumentError } from "commander";
|
|
@@ -29,6 +30,7 @@ const uiSection = (value) => {
|
|
|
29
30
|
};
|
|
30
31
|
const collectSection = (value, previous) => [...previous, uiSection(value)];
|
|
31
32
|
const program = new Command("protobase").description("Protobase command line").version(protobaseVersion, "-v, --version", "print the Protobase version");
|
|
33
|
+
program.hook("preAction", () => checkProjectMajor(process.cwd()));
|
|
32
34
|
program.command("scaffold").description("Generate or update config/<resource>/data.ts from a Postgres database").argument("[args...]", "connection string (default: DATABASE_URL from the environment or .env) followed by an optional target: all, schema, schema.table, schema.table.column").option("--env <variable>", "read the connection string from this environment variable").option("--config <dir>", "config folder", "config").option("--yes", "accept all proposals without asking", false).option("--dry-run", "print a diff instead of writing files", false).option("--ui", "also write config/<resource>/ui.ts (names and list)", false).option("--ui-list", "write only the list section of ui.ts", false).option("--ui-section <name>", "write only this ui.ts section (names or list), repeatable", collectSection, []).option("--exclude <table>", "skip a schema or schema.table, repeatable", collect, []).action(async (args, opts) => {
|
|
33
35
|
loadNearestEnvFile(process.cwd());
|
|
34
36
|
const [first, ...rest] = args;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { manifestFile } from "../bundle/manifest.js";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
//#region src/serve/bundle-manifest.ts
|
|
5
|
+
const checkBundleManifest = (configFile) => {
|
|
6
|
+
const file = path.join(path.dirname(configFile), manifestFile);
|
|
7
|
+
if (!existsSync(file)) throw new Error(`${file} is missing; serve the config module of a bundle folder from \`protobase build\``);
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { checkBundleManifest };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { readHidden } from "../users/password.js";
|
|
2
2
|
import { createUserCommand } from "../users/commands.js";
|
|
3
3
|
import { usersApi } from "../users/users-api.js";
|
|
4
|
-
import {
|
|
4
|
+
import { checkBundleManifest } from "./bundle-manifest.js";
|
|
5
5
|
import { loadBundle } from "./load-bundle.js";
|
|
6
6
|
import { bundleConfigFile } from "../worker/start-worker.js";
|
|
7
7
|
import { checkAuthSchema } from "@protobase/server";
|
|
8
8
|
//#region src/serve/create-admin.ts
|
|
9
9
|
const createAdminInBundle = async (bundle, email, options, out) => {
|
|
10
10
|
const file = await bundleConfigFile(bundle);
|
|
11
|
-
|
|
11
|
+
checkBundleManifest(file);
|
|
12
12
|
const project = await loadBundle(file);
|
|
13
13
|
if (!project.auth) throw new Error("The bundle exports no `auth`: users are managed by Better Auth");
|
|
14
14
|
await checkAuthSchema(project.auth);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readManifest } from "../bundle/manifest.js";
|
|
2
|
-
import {
|
|
2
|
+
import { checkBundleManifest } from "./bundle-manifest.js";
|
|
3
3
|
import { bundleConfigFile } from "../worker/start-worker.js";
|
|
4
4
|
import { applyMigrations } from "../migration/apply-migrations.js";
|
|
5
5
|
import path from "node:path";
|
|
@@ -12,7 +12,7 @@ import postgres from "postgres";
|
|
|
12
12
|
*/
|
|
13
13
|
const migrateBundle = async (bundle, env, out) => {
|
|
14
14
|
const file = await bundleConfigFile(bundle);
|
|
15
|
-
|
|
15
|
+
checkBundleManifest(file);
|
|
16
16
|
const dir = path.dirname(file);
|
|
17
17
|
const manifest = await readManifest(dir);
|
|
18
18
|
if (!manifest.migrations) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { projectErrorReporter } from "../project/error-reporter.js";
|
|
2
2
|
import { readManifest } from "../bundle/manifest.js";
|
|
3
|
-
import {
|
|
3
|
+
import { checkBundleManifest } from "./bundle-manifest.js";
|
|
4
4
|
import { loadBundle } from "./load-bundle.js";
|
|
5
5
|
import { bundleUi } from "./bundle-ui.js";
|
|
6
6
|
import { reportCrashes } from "./crash-reports.js";
|
|
@@ -11,7 +11,7 @@ import path from "node:path";
|
|
|
11
11
|
//#region src/serve/serve-bundle.ts
|
|
12
12
|
const serveBundle = async (file, env, out, site) => {
|
|
13
13
|
const serveEnv = readServeEnv(env);
|
|
14
|
-
|
|
14
|
+
checkBundleManifest(file);
|
|
15
15
|
const manifest = await readManifest(path.dirname(file));
|
|
16
16
|
const project = await loadBundle(file);
|
|
17
17
|
const reporter = await projectErrorReporter(project, env);
|
package/dist/serve/serve-dir.js
CHANGED
|
@@ -9,7 +9,7 @@ import path from "node:path";
|
|
|
9
9
|
const serveBundleDir = async (dir, env, out) => {
|
|
10
10
|
const manifest = await readManifest(dir);
|
|
11
11
|
const own = env["PROTOBASE_SHELL"] ? path.resolve(env[shellVariable]) : installedShellDir;
|
|
12
|
-
const { shell, note } = await servedShell(
|
|
12
|
+
const { shell, note } = await servedShell(own);
|
|
13
13
|
const site = {
|
|
14
14
|
...bundleSite(dir, manifest),
|
|
15
15
|
...shell && {
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
import { readShell } from "../build/shell.js";
|
|
2
|
-
import { pluginProblem } from "@protobase/schema/internal";
|
|
3
2
|
//#region src/serve/served-shell.ts
|
|
4
3
|
/** The environment variable naming a shell folder for `protobase serve`, instead of the installed @protobase/ui's. */
|
|
5
4
|
const shellVariable = "PROTOBASE_SHELL";
|
|
6
5
|
/**
|
|
7
|
-
* The shell a server of its own shell `ownDir` serves a bundle with: its own,
|
|
8
|
-
*
|
|
9
|
-
* the reason in `note`.
|
|
6
|
+
* The shell a server of its own shell `ownDir` serves a bundle with: its own, so the app follows the server's version
|
|
7
|
+
* without a rebuild; without one, the bundle's copy.
|
|
10
8
|
*/
|
|
11
|
-
const servedShell = async (
|
|
9
|
+
const servedShell = async (ownDir) => {
|
|
12
10
|
if (ownDir === void 0) return { note: "the bundle's copy of the app" };
|
|
13
11
|
const own = await readShell(ownDir);
|
|
14
|
-
for (const plugin of manifest.plugins) {
|
|
15
|
-
const problem = pluginProblem(plugin, {
|
|
16
|
-
api: own.pluginApi,
|
|
17
|
-
version: own.protobase
|
|
18
|
-
});
|
|
19
|
-
if (problem) return { note: `the bundle's copy of the app: its plugin ${plugin.name} would be off in the app of Protobase ${own.protobase}, since ${problem}` };
|
|
20
|
-
}
|
|
21
12
|
return {
|
|
22
13
|
shell: {
|
|
23
14
|
dir: ownDir,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { protobaseVersion } from "./version.js";
|
|
2
|
+
import { findPackageDirSync } from "../build/packages/package-dir.js";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
//#region src/version/project-version.ts
|
|
6
|
+
const projectPackages = [
|
|
7
|
+
"@protobase/cli",
|
|
8
|
+
"@protobase/server",
|
|
9
|
+
"@protobase/ui"
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* The Protobase version the project in `projectDir` is pinned to: the version its lockfile installed, read from the
|
|
13
|
+
* @protobase package Node's resolution finds from there. Undefined outside a project, or before its install.
|
|
14
|
+
*/
|
|
15
|
+
const projectProtobaseVersion = (projectDir) => {
|
|
16
|
+
for (const name of projectPackages) {
|
|
17
|
+
const dir = findPackageDirSync(name, projectDir);
|
|
18
|
+
if (dir) return JSON.parse(readFileSync(path.join(dir, "package.json"), "utf8")).version;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const major = (version) => version.split(".")[0];
|
|
22
|
+
/**
|
|
23
|
+
* Refuses a project of another Protobase major than this CLI's, the one version check the CLI makes: within a major a
|
|
24
|
+
* CLI runs every project, whatever its minor. Outside a project, or before its install, there is nothing to check.
|
|
25
|
+
*/
|
|
26
|
+
const checkProjectMajor = (projectDir, cliVersion = protobaseVersion) => {
|
|
27
|
+
const project = projectProtobaseVersion(projectDir);
|
|
28
|
+
if (project === void 0 || major(project) === major(cliVersion)) return;
|
|
29
|
+
throw new Error(`This project is on Protobase ${project}, and this CLI is Protobase ${cliVersion}: run it with a Protobase ${major(project)}.x CLI`);
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { checkProjectMajor, projectProtobaseVersion };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { projectAdmin } from "../project/project-admin.js";
|
|
2
2
|
import { createPgDb } from "../project/pg-db.js";
|
|
3
3
|
import { readManifest } from "../bundle/manifest.js";
|
|
4
|
-
import {
|
|
4
|
+
import { checkBundleManifest } from "../serve/bundle-manifest.js";
|
|
5
5
|
import { loadBundle } from "../serve/load-bundle.js";
|
|
6
6
|
import { statSync } from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
@@ -49,10 +49,10 @@ const startWorker = async ({ project, databaseUrl, createDb = (url) => createPgD
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
|
-
/** `protobase worker <bundle>`: the bundle's jobs until SIGTERM or SIGINT
|
|
52
|
+
/** `protobase worker <bundle>`: the bundle's jobs until SIGTERM or SIGINT. */
|
|
53
53
|
const loadWorkerBundle = async (bundle) => {
|
|
54
54
|
const file = await bundleConfigFile(bundle);
|
|
55
|
-
|
|
55
|
+
checkBundleManifest(file);
|
|
56
56
|
return loadBundle(file);
|
|
57
57
|
};
|
|
58
58
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.14",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"@better-auth/core": "^1.7.12",
|
|
40
40
|
"@hono/node-server": "^2.1.3",
|
|
41
41
|
"@hono/vite-dev-server": "^0.26.1",
|
|
42
|
-
"@protobase/layout": "0.46.
|
|
43
|
-
"@protobase/query": "0.46.
|
|
44
|
-
"@protobase/schema": "0.46.
|
|
45
|
-
"@protobase/server": "0.46.
|
|
46
|
-
"@protobase/ui": "0.46.
|
|
42
|
+
"@protobase/layout": "0.46.14",
|
|
43
|
+
"@protobase/query": "0.46.14",
|
|
44
|
+
"@protobase/schema": "0.46.14",
|
|
45
|
+
"@protobase/server": "0.46.14",
|
|
46
|
+
"@protobase/ui": "0.46.14",
|
|
47
47
|
"@react-email/render": "^2.1.0",
|
|
48
48
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
49
49
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -6,7 +6,7 @@ How Protobase is released and versioned, and what a release keeps working.
|
|
|
6
6
|
|
|
7
7
|
- [Releases](../reference/versioning.md#releases): Every fix and feature is released when it lands, as npm packages, published with provenance, and images of one version.
|
|
8
8
|
- [Version rules](../reference/versioning.md#versions-below-10): Semantic versioning. Below 1.0 a minor version may break.
|
|
9
|
-
- [Bundles and runtimes](../reference/versioning.md#bundles-and-runtimes):
|
|
9
|
+
- [Bundles and runtimes](../reference/versioning.md#bundles-and-runtimes): The CLI runs every project of its major, and a bundle names the version its project is pinned to, for the host to serve it on.
|
|
10
10
|
- [Plugins keep working](../reference/versioning.md#plugins): Plugins target a plugin API that releases keep.
|
|
11
11
|
- [Runtime updates](../reference/versioning.md#runtime-updates): Admins see whether the runtime has an update and start it from the app, when the host offers one.
|
|
12
12
|
- [New version notice](../reference/versioning.md#a-new-version-under-an-open-page): An open page keeps working when the server moves to a new Protobase version, and offers a reload.
|
|
@@ -28,7 +28,7 @@ dist/
|
|
|
28
28
|
plugins and the app's version
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
The host serves `public/` itself and sends only the manifest's `api` paths to the runtime (`/api` and the two OAuth discovery documents of [MCP clients](../reference/auth.md#oauth-for-mcp-clients), and `/.well-known/webauthn`, for an app on [several origins](../reference/auth.md#several-origins)), so loading the UI never needs a running container. With the UI it sends `X-Frame-Options: DENY` and `Content-Security-Policy: frame-ancestors 'none'`, as `protobase serve` does, so no other site frames the app's pages. The runtime serves the API alone; `protobase serve dist` serves the whole folder the same way, to check a bundle locally. The host passes `DATABASE_URL`, `PORT` (default 8787) and optionally `PROTOBASE_DB_CONNECTIONS` (the connections the app may open, so its functions and jobs leave one to requests, see [`serve`](../reference/cli.md#serve)), `REQUEST_LOG`, `PROTOBASE_SMTP_URL` and `PROTOBASE_MAIL_FROM` (the mail server and sender for [password reset](../reference/auth.md#password-reset) and emailed sign-in codes) `PROTOBASE_APP_NAME` (the app's name in that mail, see [`appName`](../reference/auth.md#configuration)) `PROTOBASE_SIGN_IN_*` (a provider people with an account sign in with, the [platform sign-in provider](../reference/auth.md#platform-sign-in-provider)) `PROTOBASE_OPERATOR_*` (the provider its staff sign in with for [staff sign-in](../reference/auth.md#staff-sign-in)), `PROTOBASE_ORIGINS` and `PROTOBASE_PASSKEY_DOMAIN` (the app's [other origins](../reference/auth.md#several-origins) and its passkey domain) `PROTOBASE_CORS_ORIGINS` (the websites that may call its API, see [CORS](../reference/api.md#cors)), `PROTOBASE_TRUSTED_PROXIES` (the proxies in front of the runtime, whose `X-Forwarded-For` names the client the sign-in limits count, see [Client addresses](../reference/auth.md#client-addresses)) and `PROTOBASE_SENTRY_DSN` (the app's [error tracker](../reference/api.md#error-reporting)), plus the project's own settings (`BETTER_AUTH_SECRET`, ...). The runtime and the config module are plain JavaScript for Bun: no install, no TypeScript, no writes. The runtime supplies protobase and the dependencies it runs on the server (`pg`, `postgres`, `kysely`, `better-auth`, ...), so the config module carries only the project's code and the other packages it uses. The
|
|
31
|
+
The host serves `public/` itself and sends only the manifest's `api` paths to the runtime (`/api` and the two OAuth discovery documents of [MCP clients](../reference/auth.md#oauth-for-mcp-clients), and `/.well-known/webauthn`, for an app on [several origins](../reference/auth.md#several-origins)), so loading the UI never needs a running container. With the UI it sends `X-Frame-Options: DENY` and `Content-Security-Policy: frame-ancestors 'none'`, as `protobase serve` does, so no other site frames the app's pages. The runtime serves the API alone; `protobase serve dist` serves the whole folder the same way, to check a bundle locally. The host passes `DATABASE_URL`, `PORT` (default 8787) and optionally `PROTOBASE_DB_CONNECTIONS` (the connections the app may open, so its functions and jobs leave one to requests, see [`serve`](../reference/cli.md#serve)), `REQUEST_LOG`, `PROTOBASE_SMTP_URL` and `PROTOBASE_MAIL_FROM` (the mail server and sender for [password reset](../reference/auth.md#password-reset) and emailed sign-in codes) `PROTOBASE_APP_NAME` (the app's name in that mail, see [`appName`](../reference/auth.md#configuration)) `PROTOBASE_SIGN_IN_*` (a provider people with an account sign in with, the [platform sign-in provider](../reference/auth.md#platform-sign-in-provider)) `PROTOBASE_OPERATOR_*` (the provider its staff sign in with for [staff sign-in](../reference/auth.md#staff-sign-in)), `PROTOBASE_ORIGINS` and `PROTOBASE_PASSKEY_DOMAIN` (the app's [other origins](../reference/auth.md#several-origins) and its passkey domain) `PROTOBASE_CORS_ORIGINS` (the websites that may call its API, see [CORS](../reference/api.md#cors)), `PROTOBASE_TRUSTED_PROXIES` (the proxies in front of the runtime, whose `X-Forwarded-For` names the client the sign-in limits count, see [Client addresses](../reference/auth.md#client-addresses)) and `PROTOBASE_SENTRY_DSN` (the app's [error tracker](../reference/api.md#error-reporting)), plus the project's own settings (`BETTER_AUTH_SECRET`, ...). The runtime and the config module are plain JavaScript for Bun: no install, no TypeScript, no writes. The runtime supplies protobase and the dependencies it runs on the server (`pg`, `postgres`, `kysely`, `better-auth`, ...), so the config module carries only the project's code and the other packages it uses. The manifest's `protobase` is the version the project is pinned to, and the host serves the bundle on the runtime of that version (see [Versioning](../reference/versioning.md#bundles-and-runtimes)). The manifest format and the routing rules are in the CLI reference: [`build`](../reference/cli.md#build), [`build-serve`](../reference/cli.md#build-serve) and [`serve`](../reference/cli.md#serve).
|
|
32
32
|
|
|
33
33
|
## Migrations
|
|
34
34
|
|
|
@@ -54,7 +54,7 @@ Each `--extend` folder's `protobase.ui.tsx` becomes a plugin of its own, `plugin
|
|
|
54
54
|
A host that serves `public/` as before keeps working: `index.html` for navigations, files for the rest. Two things are new:
|
|
55
55
|
|
|
56
56
|
- The plugins' `assets/` folders, `public/plugins/<name>/assets/`, are named by their content like `public/assets/`: serve them as immutable too. `plugin.json`, `protobase.theme.css`, `protobase.favicon.svg` and the PNG icons are served with `no-cache`.
|
|
57
|
-
- A host that keeps the prebuilt app of newer releases may serve it for the manifest's `shell.paths`, so the app gets that release's fixes without a rebuild (see [the shell](../reference/plugins.md#the-shell)). `protobase serve` does so with its own
|
|
57
|
+
- A host that keeps the prebuilt app of newer releases may serve it for the manifest's `shell.paths`, so the app gets that release's fixes without a rebuild (see [the shell](../reference/plugins.md#the-shell)). `protobase serve` does so with its own whenever it has one.
|
|
58
58
|
|
|
59
59
|
## 6. protobase dev
|
|
60
60
|
|
|
@@ -62,4 +62,4 @@ Nothing changes: `protobase dev` builds `protobase.ui.tsx` into its page with ho
|
|
|
62
62
|
|
|
63
63
|
## After the move
|
|
64
64
|
|
|
65
|
-
From now on, a release of Protobase within the same minor needs no rebuild of the project's UI: the app it runs in is the release's, and the plugin keeps working within its [plugin API](../reference/plugins.md#versions). The server config
|
|
65
|
+
From now on, a release of Protobase within the same minor needs no rebuild of the project's UI: the app it runs in is the release's, and the plugin keeps working within its [plugin API](../reference/plugins.md#versions). The server config runs on the runtime the project is pinned to (see [Bundles and runtimes](../reference/versioning.md#bundles-and-runtimes)), so moving the pin to a new minor below 1.0 is still a rebuild.
|
|
@@ -12,7 +12,7 @@ bun run protobase <command> # from the project, config folde
|
|
|
12
12
|
bun run --cwd examples/erp protobase <command> # in this repository, for an example
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Any package manager installs the packages, and the command runs on Node or on Bun: `npm install` and `npx protobase <command>` work the same. The bin starts with `#!/usr/bin/env node`, so where Node is installed `bun run protobase` starts it on Node, unless the project's `bunfig.toml` sets `[run] bun = true`, as the presets' does. `protobase --version` (or `-v`) prints the Protobase version.
|
|
15
|
+
Any package manager installs the packages, and the command runs on Node or on Bun: `npm install` and `npx protobase <command>` work the same. The bin starts with `#!/usr/bin/env node`, so where Node is installed `bun run protobase` starts it on Node, unless the project's `bunfig.toml` sets `[run] bun = true`, as the presets' does. `protobase --version` (or `-v`) prints the Protobase version. Before any command runs, the CLI checks that the project in the current directory, by the `@protobase` packages installed there, is of its own major version, and stops with an error naming both versions when it is not: within a major a CLI runs every project, whatever its minor. That is the CLI's one version check. Outside a project, or before its install, there is nothing to check.
|
|
16
16
|
|
|
17
17
|
## How it runs
|
|
18
18
|
|
|
@@ -254,10 +254,10 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
254
254
|
}
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
-
- `protobase` is the Protobase version
|
|
257
|
+
- `protobase` is the Protobase version the project is pinned to: the `@protobase/cli` its lockfile installed, whichever CLI of its major built the bundle. A host serves the bundle on the runtime of that version (see [Versioning](versioning.md#bundles-and-runtimes)). The build fails in a project without its `@protobase` packages installed.
|
|
258
258
|
- `server`, `public`, `nodeModules` and `migrations` are relative to the bundle folder; `spa`, `theme` and each plugin's `path` to `public`.
|
|
259
259
|
- `plugins` are the bundle's own plugins, in the order the app merges them: the extensions', then the project's (`app`). Each names its `plugin.json`, the plugin API and Protobase versions it is built for, and the [field types](plugins.md#field-types) it registers with the storage types each shows, which the serve runtime checks the views against at startup. `/api/meta` names them to everyone, before any other plugin.
|
|
260
|
-
- `shell` is the admin app `public/` holds a copy of: its Protobase version and plugin API, and its files as URL paths. A host with a shell of its own
|
|
260
|
+
- `shell` is the admin app `public/` holds a copy of: its Protobase version and plugin API, and its files as URL paths. A host with a shell of its own may serve its own for those paths instead (see [The UI](#the-ui)), so the app gets that release's fixes without a rebuild.
|
|
261
261
|
- `native` is the native code, name to version, that `shell` runs on in the [mobile app](../guides/mobile-app.md): the native packages `@protobase/mobile` pins, and `@protobase/mobile` itself at its native contract, such as `native-1`, which Protobase raises when its own native code changes. The fingerprint of the bundle's [mobile release](#mobile-releases) names them. A bundle built before it serves no mobile release.
|
|
262
262
|
- `theme` is the project's [theme](theme.md), which the app links at `/protobase.theme.css`. It is always there, empty when the project has none.
|
|
263
263
|
- `nodeModules` is present only when the config module imports [native packages](#native-packages). It is always the `node_modules` folder beside `server`, where Bun and Node resolve the module's imports from, and holds plain packages: JavaScript, `package.json` files and native binaries for linux x64 and arm64 (glibc), which the runtime loads with `dlopen`. A host keeps it next to the server module and must not mount it `noexec` (an add-on there then fails with `failed to map segment from shared object`). Its binaries link nothing but glibc, `libstdc++.so.6`, `libgcc_s.so.1` and libraries in the bundle itself, so the run image must have those three. Without `nodeModules`, the server module is the only file the runtime reads.
|
|
@@ -295,7 +295,7 @@ The modules the app shares with plugins, `react`, `react/jsx-runtime`, `react-do
|
|
|
295
295
|
|
|
296
296
|
`react-email` is a dependency of `@protobase/server` that the runtime does not supply: the server loads it only to send its own mail, or for `@protobase/server/email`, so a config that imports it inlines its own copy, like any other package.
|
|
297
297
|
|
|
298
|
-
Importing any other `@protobase` package or dependency of one (`@protobase/ui`, `react-dom`, `better-auth/plugins`, `zod/v4`, ...) fails the build with this list, also from inside an inlined package, when the finished bundle still imports it: an inlined package may re-export a module that imports one, as `react-email` does with `tailwindcss`, as long as the project leaves that export unused.
|
|
298
|
+
Importing any other `@protobase` package or dependency of one (`@protobase/ui`, `react-dom`, `better-auth/plugins`, `zod/v4`, ...) fails the build with this list, also from inside an inlined package, when the finished bundle still imports it: an inlined package may re-export a module that imports one, as `react-email` does with `tailwindcss`, as long as the project leaves that export unused. The runtime supplies them at its own versions, whichever the project installed. The list is `packages/cli/src/serve/host-module-ids.ts`; the set of packages comes from the `package.json` of `@protobase/cli` and of every `@protobase` package it depends on.
|
|
299
299
|
- Packages with a native add-on stay imports too, and the bundle carries them in `node_modules/` (see [Native packages](#native-packages)). Node's built-in modules stay imports.
|
|
300
300
|
- Everything else (the project's files and its other packages) is inlined. Nothing is minified.
|
|
301
301
|
- Layout files (`@jsxImportSource @protobase/layout`) compile to calls of `@protobase/layout/jsx-runtime`, for production whatever `NODE_ENV` says. The build refuses one with a function, class, `new` value or hook in its JSX, naming the file, line and column ([what a layout may hold](layouts.md#what-a-layout-may-hold)).
|
|
@@ -395,7 +395,7 @@ protobase serve <bundle> # the whole b
|
|
|
395
395
|
|
|
396
396
|
Serves the API of a bundle from `protobase build` and owns the process around it. Given the bundle folder, `protobase serve` also serves its UI by [the manifest's rules](#the-manifest), so a bundle can be checked locally exactly as the host will serve it.
|
|
397
397
|
|
|
398
|
-
**Its own shell.** Given the bundle folder, `protobase serve` serves the manifest's `shell.paths`, the root and navigations from a shell of its own when it has one: the folder `PROTOBASE_SHELL` names, else the prebuilt shell of the installed `@protobase/ui` (none when the CLI runs from this repository's sources).
|
|
398
|
+
**Its own shell.** Given the bundle folder, `protobase serve` serves the manifest's `shell.paths`, the root and navigations from a shell of its own when it has one: the folder `PROTOBASE_SHELL` names, else the prebuilt shell of the installed `@protobase/ui` (none when the CLI runs from this repository's sources). Without one it serves the bundle's copy. Its startup output says which (`app the app of Protobase 0.12.3 from ...`). The plugins, the theme and the API always come from the bundle.
|
|
399
399
|
|
|
400
400
|
| Variable | |
|
|
401
401
|
| --- | --- |
|
|
@@ -429,7 +429,7 @@ Better Auth and other settings are the project's own variables (`BETTER_AUTH_SEC
|
|
|
429
429
|
|
|
430
430
|
- **Routes:** `createAdmin` (`/api/v1`, `/api/meta`, `/api/functions/*`, `/api/auth/*`, ...) and `GET /health`, which answers `{"status":"ok"}` without a token and without touching the database. The runtime never serves the UI; `protobase serve <bundle>` serves `public/` for every path outside the manifest's `api` and `/.well-known/webauthn`, after `/health`, with `X-Frame-Options: DENY` and `Content-Security-Policy: frame-ancestors 'none'`, so no other site frames its pages.
|
|
431
431
|
- **Plugins:** the runtime reads the manifest's `plugins`: `/api/meta` names them, and a view that shows a field with one of their [field types](plugins.md#field-types) that does not show the field's storage type stops startup, naming the view, the field and what the field type shows.
|
|
432
|
-
- **
|
|
432
|
+
- **Manifest:** a config module needs its `protobase.bundle.json` beside it. The runtime checks no version: the host picks the runtime from the manifest's `protobase` (see [Versioning](versioning.md#bundles-and-runtimes)).
|
|
433
433
|
- **Startup:** a bundle without a default export, `config` or `authenticate`, or with an `options.basePath` other than `/api/v1`, stops startup with a one-line error and exit code 1, as does a missing `DATABASE_URL`, an auth schema that lacks a table or column, or still has the OAuth tables of [MCP](auth.md#oauth-for-mcp-clients) with `mcp` off (see [`auth migration`](#auth-migration)), a resource whose [events](events.md) or [history](history.md) lack their triggers or have out-of-date ones, or a missing history or [comments](comments.md#the-table) table, a [rollup or formula field](data-config.md#rollups-and-formulas) whose column or trigger is missing or out of date, a jobs schema that is missing or behind for a config with [jobs](jobs.md#the-jobs-schema) (see [`migration`](#migration)), an [AI field or action](ai.md#the-model) without a model key, [encrypted fields](data-config.md#encrypted-fields) without a key, or another resource over their column, or a taken port; `PROTOBASE_STARTUP_CHECKS=false` skips the checks of those schemas and the key. `protobase serve listening on port <port>` means it is ready.
|
|
434
434
|
- **Jobs:** with [jobs](jobs.md) in the config it runs them beside the API, unless `PROTOBASE_JOBS=false`, and with `PROTOBASE_JOBS_DRAIN_TOKEN` it answers `POST /api/jobs/drain` for the operator.
|
|
435
435
|
- **Shutdown:** the first SIGTERM or SIGINT stops accepting connections, closes open WebSockets with 1001 (dropping any still open after 5 seconds), waits for open requests, gives running jobs 30 seconds to finish, drains the pool `serve` created (a `db` the config exports is the project's to close) and exits with 0.
|
|
@@ -16,7 +16,7 @@ Plugins are written by an app's developers and by Protobase itself, and they run
|
|
|
16
16
|
|
|
17
17
|
Plugins split the work of keeping an app current. Protobase maintains the admin app, the API and the server; an app's developers maintain their plugins, and those seldom need work. A plugin is built against the plugin API, which releases add to but never break, so the same build keeps loading as the app moves to newer releases, and gets their fixes and new features on the way. Nobody ports it, rebuilds it or tests it again for each release; it needs a new build only when Protobase starts a new plugin API (see [Versions](#versions)).
|
|
18
18
|
|
|
19
|
-
What still follows Protobase's releases is the rest of the bundle. Below 1.0 a new minor version may change how `data.ts`, `ui.ts` and the server config are written, and a runtime
|
|
19
|
+
What still follows Protobase's releases is the rest of the bundle. Below 1.0 a new minor version may change how `data.ts`, `ui.ts` and the server config are written, and a bundle is served on the runtime of the version the project is pinned to, so moving to a new minor means installing that version and running `protobase build` again, after any change the release notes ask of the config (see [Bundles and runtimes](versioning.md#bundles-and-runtimes)). The plugins' code stays as it is. Within a minor, where features ship as patches below 1.0, a host that serves the newer release's [shell](#the-shell) gives the app its fixes with nothing rebuilt.
|
|
20
20
|
|
|
21
21
|
## How a plugin stays working
|
|
22
22
|
|
|
@@ -274,7 +274,7 @@ The plugin starts the session itself, with a request that sets the app's session
|
|
|
274
274
|
|
|
275
275
|
The shell is the admin app: `index.html` and its `assets/`, the same for every project on a release. Each release ships it prebuilt in `@protobase/ui`'s `dist/shell/` and in the [protobase image](../guides/deploy.md#images) at `/opt/protobase/shell/`, with a `protobase.shell.json` naming its Protobase version and plugin API. A bundle carries a copy, so any static host can serve it, and its manifest names that copy's version and paths (`shell` in [the manifest](cli.md#the-manifest)).
|
|
276
276
|
|
|
277
|
-
A host that keeps the shells of its releases can serve the shell of a newer one for those paths
|
|
277
|
+
A host that keeps the shells of its releases can serve the shell of a newer one for those paths; the app still turns off a plugin that does not load in it. The plugins, the theme and the API stay the bundle's. `protobase serve` does this with its own shell (see [serve](cli.md#serve)). The app then has the newer release's fixes with nothing rebuilt; only a change of the server config's format, a new minor below 1.0, still needs a [rebuild](versioning.md#bundles-and-runtimes).
|
|
278
278
|
|
|
279
279
|
## Versions
|
|
280
280
|
|
|
@@ -287,7 +287,7 @@ A plugin is built for one plugin API and a range of Protobase versions, both wri
|
|
|
287
287
|
{ "engines": { "protobase": ">=0.12.0" } }
|
|
288
288
|
```
|
|
289
289
|
|
|
290
|
-
A range is comparators separated by spaces, all of which must hold: `>=`, `>`, `<=`, `<` or `=` and an `x.y.z` version, such as `>=0.12.0 <2.0.0`. The build
|
|
290
|
+
A range is comparators separated by spaces, all of which must hold: `>=`, `>`, `<=`, `<` or `=` and an `x.y.z` version, such as `>=0.12.0 <2.0.0`. The build checks only the range's form; which versions it holds is the app's to compare when it loads the plugin. If the plugin uses something an older release in its range does not have, it fails to load there and is turned off, as described below.
|
|
291
291
|
|
|
292
292
|
The app loads a plugin when the plugin's `api` is its own and its version is in the plugin's `protobase` range. Protobase keeps the plugin API through its releases and starts a new one only when a plugin built for the old one could break:
|
|
293
293
|
|
|
@@ -56,25 +56,19 @@ Running the workflow by hand with a tag (`gh workflow run release.yml -f tag=v0.
|
|
|
56
56
|
|
|
57
57
|
## Bundles and runtimes
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- **From 1.0:** the major versions are the same and the runtime's minor is the bundle's or newer. A 1.4.x runtime serves bundles built by 1.0.0 up to 1.4.x.
|
|
62
|
-
- **Below 1.0:** the minor versions are the same. A 0.2.x runtime serves only bundles built by 0.2.x, not those of 0.1.x or 0.3.x.
|
|
63
|
-
- **Patches** never matter: a 0.1.2 runtime serves a bundle built by 0.1.7.
|
|
64
|
-
|
|
65
|
-
Otherwise, and for a bundle whose manifest has no `protobase` version or one that is not `x.y.z`, startup stops with exit code 1 and an error naming both versions:
|
|
59
|
+
The CLI makes one version check, when it starts: the project in the current directory, by the `@protobase` packages installed there, must be of the CLI's own major version. A 0.x CLI runs every 0.x project, whatever its minor, and refuses a 1.x one before any command runs:
|
|
66
60
|
|
|
67
61
|
```
|
|
68
|
-
error:
|
|
62
|
+
error: This project is on Protobase 1.2.0, and this CLI is Protobase 0.14.2: run it with a Protobase 1.x CLI
|
|
69
63
|
```
|
|
70
64
|
|
|
71
|
-
|
|
65
|
+
Within a major the CLI stays backwards compatible, so a platform builds every app with the newest CLI of the app's major. Nothing else compares versions: not the build, not the serve runtime. `protobase build` writes the version the project is pinned to, the `@protobase/cli` its lockfile installed, into [the manifest](cli.md#the-manifest) as `protobase`, whichever CLI built the bundle, and a host serves the bundle on the runtime of that version. The check is `checkProjectMajor` in `packages/cli/src/version/project-version.ts`.
|
|
72
66
|
|
|
73
67
|
## Plugins
|
|
74
68
|
|
|
75
|
-
[Plugins](plugins.md) are versioned by a plugin API of their own
|
|
69
|
+
[Plugins](plugins.md) are versioned by a plugin API of their own: `@protobase/ui`'s `pluginApi`, 1 so far. A plugin's `plugin.json` names the plugin API it is built for and a range of Protobase versions, from the `@protobase/ui` it is built with on. An app loads a plugin of its own plugin API whose range holds its version, and turns off any other, telling its admins why.
|
|
76
70
|
|
|
77
|
-
A project's own `protobase.ui.tsx` is a plugin of its bundle, so the same rule holds for it. The admin app it runs in, the shell, is prebuilt once per release; a host that serves a newer release's shell for a bundle whose plugins all load in it gives the app that release's fixes without a rebuild (see [the shell](plugins.md#the-shell)).
|
|
71
|
+
A project's own `protobase.ui.tsx` is a plugin of its bundle, so the same rule holds for it. The admin app it runs in, the shell, is prebuilt once per release; a host that serves a newer release's shell for a bundle whose plugins all load in it gives the app that release's fixes without a rebuild (see [the shell](plugins.md#the-shell)).
|
|
78
72
|
|
|
79
73
|
Releases keep the plugin API, below 1.0 too, where a minor version may change the config: they add exports to `@protobase/ui`, but remove or change one, add or remove a module the app shares with plugins, or move to a new major version of React only with a new plugin API. A test pins every export of `@protobase/ui` (`packages/ui/src/plugins/plugin-api.exports.json`) and fails when one goes away while `pluginApi` stays the same.
|
|
80
74
|
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { protobaseVersion } from "../version/version.js";
|
|
2
|
-
import { manifestFile } from "../bundle/manifest.js";
|
|
3
|
-
import { bundleVersionProblem } from "../version/compatibility.js";
|
|
4
|
-
import { existsSync } from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { readFile } from "node:fs/promises";
|
|
7
|
-
//#region src/serve/bundle-version.ts
|
|
8
|
-
const checkBundleVersion = async (configFile, runtimeVersion = protobaseVersion) => {
|
|
9
|
-
const file = path.join(path.dirname(configFile), manifestFile);
|
|
10
|
-
if (!existsSync(file)) throw new Error(`${file} is missing; serve the config module of a bundle folder from \`protobase build\``);
|
|
11
|
-
const manifest = JSON.parse(await readFile(file, "utf8"));
|
|
12
|
-
const problem = bundleVersionProblem(runtimeVersion, manifest?.protobase);
|
|
13
|
-
if (problem) throw new Error(`${file}: ${problem}`);
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
16
|
-
export { checkBundleVersion };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
//#region src/version/compatibility.ts
|
|
2
|
-
const versionPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
3
|
-
const parseVersion = (value) => {
|
|
4
|
-
const match = typeof value === "string" ? versionPattern.exec(value) : null;
|
|
5
|
-
if (!match) return void 0;
|
|
6
|
-
return {
|
|
7
|
-
major: Number(match[1]),
|
|
8
|
-
minor: Number(match[2]),
|
|
9
|
-
patch: Number(match[3])
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
const line = (version) => `${version.major}.${version.minor}.x`;
|
|
13
|
-
const servedRange = (version) => version.major === 0 ? line(version) : `${version.major}.0.x to ${line(version)}`;
|
|
14
|
-
const neededRuntime = (version) => version.major === 0 ? line(version) : `${version.major}.${version.minor} or a newer ${version.major}.x`;
|
|
15
|
-
/**
|
|
16
|
-
* Why a runtime of Protobase `runtime` cannot serve a bundle built by Protobase `bundle`, or undefined when it can.
|
|
17
|
-
* It can when both have the same major and the runtime's minor is the bundle's or newer; below 1.0, where a minor
|
|
18
|
-
* may break, the minors must be the same. Patches never matter.
|
|
19
|
-
*/
|
|
20
|
-
const bundleVersionProblem = (runtime, bundle) => {
|
|
21
|
-
const own = parseVersion(runtime);
|
|
22
|
-
if (!own) throw new Error(`The runtime's own Protobase version ${JSON.stringify(runtime)} is no x.y.z version`);
|
|
23
|
-
const rebuild = `rebuild the bundle with Protobase ${line(own)}`;
|
|
24
|
-
if (bundle === void 0) return `the bundle names no Protobase version, so it was built before 0.1.0; ${rebuild} to serve it on this runtime (${runtime})`;
|
|
25
|
-
const built = parseVersion(bundle);
|
|
26
|
-
if (!built) return `the bundle's Protobase version ${JSON.stringify(bundle)} is no x.y.z version; ${rebuild} to serve it on this runtime (${runtime})`;
|
|
27
|
-
if (built.major === own.major && (own.major === 0 ? built.minor === own.minor : built.minor <= own.minor)) return void 0;
|
|
28
|
-
return `the bundle was built by Protobase ${bundle} and this runtime is Protobase ${runtime}, which serves bundles built by ${servedRange(own)}; ${rebuild} or serve it with a runtime of ${neededRuntime(built)}`;
|
|
29
|
-
};
|
|
30
|
-
//#endregion
|
|
31
|
-
export { bundleVersionProblem };
|