@protobase/cli 0.46.15 → 0.47.0

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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.46.15";
2
+ var version = "0.47.0";
3
3
  //#endregion
4
4
  export { version };
package/dist/main.js CHANGED
@@ -16,7 +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
+ import { checkProjectVersion } from "./version/project-version.js";
20
20
  import { statSync } from "node:fs";
21
21
  import path from "node:path";
22
22
  import { Command, InvalidArgumentError } from "commander";
@@ -30,7 +30,7 @@ const uiSection = (value) => {
30
30
  };
31
31
  const collectSection = (value, previous) => [...previous, uiSection(value)];
32
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()));
33
+ program.hook("preAction", () => checkProjectVersion(process.cwd()));
34
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) => {
35
35
  loadNearestEnvFile(process.cwd());
36
36
  const [first, ...rest] = args;
@@ -2,6 +2,7 @@ import { protobaseVersion } from "./version.js";
2
2
  import { findPackageDirSync } from "../build/packages/package-dir.js";
3
3
  import { readFileSync } from "node:fs";
4
4
  import path from "node:path";
5
+ import semver from "semver";
5
6
  //#region src/version/project-version.ts
6
7
  const projectPackages = [
7
8
  "@protobase/cli",
@@ -18,15 +19,17 @@ const projectProtobaseVersion = (projectDir) => {
18
19
  if (dir) return JSON.parse(readFileSync(path.join(dir, "package.json"), "utf8")).version;
19
20
  }
20
21
  };
21
- const major = (version) => version.split(".")[0];
22
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.
23
+ * Refuses a project whose Protobase version this CLI is not compatible with, the one version check the CLI makes: the
24
+ * CLI's version must be in the caret range of the project's, so from 1.0 on the same major and below 1.0, where a minor
25
+ * may break, the same minor, and never older. Outside a project, or before its install, there is nothing to check.
25
26
  */
26
- const checkProjectMajor = (projectDir, cliVersion = protobaseVersion) => {
27
+ const checkProjectVersion = (projectDir, cliVersion = protobaseVersion) => {
27
28
  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`);
29
+ if (project === void 0) return;
30
+ const range = `^${project}`;
31
+ if (semver.satisfies(cliVersion, range)) return;
32
+ throw new Error(`This project is on Protobase ${project}, and this CLI is Protobase ${cliVersion}: run it with a Protobase ${range} CLI`);
30
33
  };
31
34
  //#endregion
32
- export { checkProjectMajor, projectProtobaseVersion };
35
+ export { checkProjectVersion, projectProtobaseVersion };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.46.15",
3
+ "version": "0.47.0",
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.15",
43
- "@protobase/query": "0.46.15",
44
- "@protobase/schema": "0.46.15",
45
- "@protobase/server": "0.46.15",
46
- "@protobase/ui": "0.46.15",
42
+ "@protobase/layout": "0.47.0",
43
+ "@protobase/query": "0.47.0",
44
+ "@protobase/schema": "0.47.0",
45
+ "@protobase/server": "0.47.0",
46
+ "@protobase/ui": "0.47.0",
47
47
  "@react-email/render": "^2.1.0",
48
48
  "@scalar/hono-api-reference": "^0.12.10",
49
49
  "@tailwindcss/vite": "^4.3.3",
@@ -88,7 +88,7 @@ bun run --cwd examples/property-portal dev # http://localhost:5173
88
88
  | `bun run test:watch` | `bun run test` in watch mode |
89
89
  | `bun run test:integration` | the database, subprocess and build tests (projects `integration*`), against the Postgres container, among them the real-Postgres tests (`*.postgres.test.ts`) |
90
90
  | `bun run test:smoke` / `node --run test:smoke` | the CLI on Bun or on Node builds the ERP and serves its bundle, whose `€` must come back intact; part of `test:integration` on Bun |
91
- | `bun run presets:write <version> <dir>` | writes each preset to `<dir>/<name>`: a standalone copy of its example with the `@protobase` packages in the range of `<version>`'s major (`>=0.y.z <1` below 1.0, `^x.y.z` from 1.0) and its own `bun.lock` at exactly `<version>`, which must be on npm |
91
+ | `bun run presets:write <version> <dir>` | writes each preset to `<dir>/<name>`: a standalone copy of its example with the `@protobase` packages in the caret range of `<version>` (`^x.y.z`, which below 1.0 covers only that minor) and its own `bun.lock` at exactly `<version>`, which must be on npm |
92
92
  | `bun run images:context` | the build contexts of the `protobase` and `protobase-dev` images in `dist/images`, at the version in `package.json` (see [Deploy](guides/deploy.md#images)) |
93
93
  | `bun run test:presets` | writes each preset as `bun run presets:write` does it and installs it with Bun from npm (so at a published version), then migrates, seeds, checks, tests and builds it on a database of its own, as a role without superuser rights; needs the Postgres container |
94
94
  | `bun run test:postgres` | the Postgres suite in `tests/postgres/` (Vitest project `postgres`): the ERP's medium seed and the planner's statistics on it, and the jobs and event delivery through PgBouncer; needs the Postgres and PgBouncer containers and `bun run test:db postgres` |
@@ -20,7 +20,7 @@ A Bun workspace of npm packages under the `@protobase` scope, in `packages/<name
20
20
  | `@protobase/presets` | `packages/presets` | none: private, `bun run presets:write` writes a project per preset | Bun | none; each preset depends on the `@protobase` packages of the major it is written at, locked at that version |
21
21
  | `examples/*` | | none | any | `@protobase/*` entry points only |
22
22
 
23
- The presets are written from `examples/erp`, `examples/real-estate` and `examples/scratch` (from scratch) by `bun run presets:write <version> <dir>`, run from a clone of this repository; `npm create protobase` (`packages/create-protobase`) writes them too, without a lockfile. Each is a standalone copy with the `@protobase` packages in the range of `<version>`'s major, `>=0.y.z <1` below 1.0 (where `^0.y.z` would cover only that minor) and `^x.y.z` from 1.0, so an app takes updates within that major, and its own `bun.lock` at exactly `<version>`. The three declare the same dependencies, so one `node_modules` fits them all, and their `db:migrate` (the auth schema's migrations included), `typecheck` and `test` scripts take their settings from the environment, or a `.env` beside them, and reach nothing outside the project.
23
+ The presets are written from `examples/erp`, `examples/real-estate` and `examples/scratch` (from scratch) by `bun run presets:write <version> <dir>`, run from a clone of this repository; `npm create protobase` (`packages/create-protobase`) writes them too, without a lockfile. Each is a standalone copy with the `@protobase` packages in the caret range of `<version>`, `^x.y.z`, so an app takes the updates semver calls compatible: within that major from 1.0 on, and within that minor below 1.0, where a minor may break, and its own `bun.lock` at exactly `<version>`. The three declare the same dependencies, so one `node_modules` fits them all, and their `db:migrate` (the auth schema's migrations included), `typecheck` and `test` scripts take their settings from the environment, or a `.env` beside them, and reach nothing outside the project.
24
24
 
25
25
  The JSX runtime belongs to `@protobase/layout` because a layout file names one package in `@jsxImportSource @protobase/layout`, and TypeScript and Vite look up `jsx-runtime` and `jsx-dev-runtime` under it. Each field type is split along the same lines: its Zod builder is `packages/schema/src/fields/<type>.ts` and its SQL parameter conversion `packages/query/src/fields/<type>.ts`.
26
26
 
@@ -56,13 +56,13 @@ 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
- 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:
59
+ The CLI makes one version check, when it starts: its own version must be in the caret range of the project's, the version of the `@protobase` packages installed in the current directory, which semver calls compatible with it. From 1.0 on that is the same major, and below 1.0, where a minor may break, the same minor, never older than the project's. A 0.14.2 CLI runs a 0.14.0 project and refuses a 0.15.0 or a 1.2.0 one before any command runs:
60
60
 
61
61
  ```
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
62
+ error: This project is on Protobase 1.2.0, and this CLI is Protobase 0.14.2: run it with a Protobase ^1.2.0 CLI
63
63
  ```
64
64
 
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`.
65
+ Within its caret range the CLI stays backwards compatible, so a platform builds every app with the newest CLI in the caret range of the app's version. 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 `checkProjectVersion` in `packages/cli/src/version/project-version.ts`.
66
66
 
67
67
  ## Plugins
68
68