@protobase/cli 0.56.0 → 0.57.1

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.56.0";
2
+ var version = "0.57.1";
3
3
  //#endregion
4
4
  export { version };
@@ -1,6 +1,6 @@
1
1
  //#region ../mobile/package.json
2
2
  var name = "@protobase/mobile";
3
- var nativeContract = 3;
3
+ var nativeContract = 4;
4
4
  var dependencies = {
5
5
  "@capacitor/android": "8.5.3",
6
6
  "@capacitor/app": "8.1.2",
@@ -42,17 +42,41 @@ const checkProtobasePlugin = async (ws) => {
42
42
  if (missing.length === 0) return;
43
43
  throw new Error(`The Android app lacks Protobase's native plugin (${missing.join(", ")}): delete ${ws} and run the command again`);
44
44
  };
45
- /** The class of Protobase's iOS plugin, which gives the page back the bounce Capacitor turns off. */
46
- const protobaseIosPlugin = "ProtobaseBounce";
47
45
  /**
48
- * Checks the class list `cap add ios` writes: it refuses the live updater, which has no guard on iOS yet, and an app
49
- * without Protobase's iOS plugin, as a workspace left from an earlier CLI may build.
46
+ * The classes of Protobase's iOS plugin, by `@objc` name: the bounce Capacitor turns off, and ProtobaseAuth, which keeps
47
+ * page script away from the session.
48
+ */
49
+ const protobaseIosPluginClasses = ["ProtobaseBounce", "ProtobaseAuthPlugin"];
50
+ /** The Swift package product `cap add ios` compiles @protobase/mobile into, by the name @capacitor/cli's fixName gives. */
51
+ const protobaseIosProduct = "ProtobaseMobile";
52
+ const readIosFile = (ws, ...parts) => readFile(path.join(ws, "ios", "App", ...parts), "utf8").catch((error) => {
53
+ if (error.code === "ENOENT") return;
54
+ throw error;
55
+ });
56
+ const iosClassList = (text) => {
57
+ if (text === void 0) return [];
58
+ let parsed;
59
+ try {
60
+ parsed = JSON.parse(text);
61
+ } catch (error) {
62
+ if (error instanceof SyntaxError) return [];
63
+ throw error;
64
+ }
65
+ const classes = parsed?.packageClassList;
66
+ return Array.isArray(classes) ? classes.filter((name) => typeof name === "string") : [];
67
+ };
68
+ /**
69
+ * Checks what `cap add ios` writes: the class list, which must name Protobase's plugin classes and not the live updater,
70
+ * which has no guard on iOS yet, and the app's Swift package, which must compile Protobase's product in; a class listed
71
+ * without its product is skipped at launch without a word. A workspace left from an earlier CLI may lack either.
50
72
  */
51
73
  const checkIosPlugins = async (ws) => {
52
- const classes = JSON.parse(await readFile(path.join(ws, "ios", "App", "App", "capacitor.config.json"), "utf8")).packageClassList ?? [];
74
+ const stale = (what) => /* @__PURE__ */ new Error(`The iOS app lacks Protobase's native plugin (${what}): delete ${ws} and run the command again`);
75
+ const classes = iosClassList(await readIosFile(ws, "App", "capacitor.config.json"));
53
76
  if (classes.includes("LiveUpdatePlugin")) throw new Error("The iOS app lists LiveUpdatePlugin, which has no guard against page script on iOS yet");
54
- if (classes.includes("ProtobaseBounce")) return;
55
- throw new Error(`The iOS app lacks Protobase's native plugin (${protobaseIosPlugin}): delete ${ws} and run the command again`);
77
+ const missing = protobaseIosPluginClasses.filter((name) => !classes.includes(name));
78
+ if (missing.length > 0) throw stale(missing.join(", "));
79
+ if (!(await readIosFile(ws, "CapApp-SPM", "Package.swift"))?.includes(`.product(name: "ProtobaseMobile"`)) throw stale(protobaseIosProduct);
56
80
  };
57
81
  //#endregion
58
- export { checkIosPlugins, checkProtobasePlugin, guardLiveUpdate, protobaseIosPlugin, protobasePluginClasses };
82
+ export { checkIosPlugins, checkProtobasePlugin, guardLiveUpdate, protobaseIosPluginClasses, protobaseIosProduct, protobasePluginClasses };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.56.0",
3
+ "version": "0.57.1",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -42,12 +42,12 @@
42
42
  "dependencies": {
43
43
  "@better-auth/core": "^1.7.12",
44
44
  "@hono/node-server": "^2.1.3",
45
- "@protobase/config": "0.56.0",
46
- "@protobase/layout": "0.56.0",
47
- "@protobase/query": "0.56.0",
48
- "@protobase/schema": "0.56.0",
49
- "@protobase/server": "0.56.0",
50
- "@protobase/ui": "0.56.0",
45
+ "@protobase/config": "0.57.1",
46
+ "@protobase/layout": "0.57.1",
47
+ "@protobase/query": "0.57.1",
48
+ "@protobase/schema": "0.57.1",
49
+ "@protobase/server": "0.57.1",
50
+ "@protobase/ui": "0.57.1",
51
51
  "@react-email/render": "^2.1.0",
52
52
  "@scalar/hono-api-reference": "^0.12.10",
53
53
  "@tailwindcss/vite": "^4.3.3",
@@ -33,7 +33,7 @@ export default defineConfig({
33
33
  ```
34
34
 
35
35
  - `appId` is the app's id in reverse-DNS form, the same on iOS and Android: at least two parts separated by dots, each starting with a letter and holding only letters and digits. Underscores and hyphens are refused, as iOS rejects underscores and Android rejects hyphens; `protobase mobile` stops early on such an id and suggests one without them.
36
- - `plugins`, optional, are extra native [Capacitor plugins](https://capacitorjs.com/docs/plugins), npm name to version. Capacitor itself, `@capacitor/app`, `@capacitor/keyboard`, `@capacitor/splash-screen` and `@capawesome/capacitor-live-update` come with Protobase at fixed versions and cannot be listed. A plugin runs native code with the app's rights, and one that writes files, such as `@capacitor/filesystem`, lets a script that got into the page point the iOS app at files it wrote (with Capacitor's own `WebView.setServerBasePath`), so list only plugins the app needs. On Android a plugin's JavaScript cannot call `CapacitorHttp`, `CapacitorCookies` or `WebView`, and `Capacitor.convertFileSrc` URLs do not load: call those from the plugin's native code.
36
+ - `plugins`, optional, are extra native [Capacitor plugins](https://capacitorjs.com/docs/plugins), npm name to version. Capacitor itself, `@capacitor/app`, `@capacitor/keyboard`, `@capacitor/splash-screen` and `@capawesome/capacitor-live-update` come with Protobase at fixed versions and cannot be listed. A plugin runs native code with the app's rights, so list only plugins the app needs. A plugin's JavaScript cannot call `CapacitorHttp`, `CapacitorCookies` or `WebView`, and `Capacitor.convertFileSrc` URLs do not load: call those from the plugin's native code.
37
37
 
38
38
  The app is installed under the name it shows in its upper left, on iOS and Android alike: `protobase mobile` reads it from the server the app calls (its web manifest), so a `PROTOBASE_APP_NAME` the server runs with names the app on the phone too. When that server cannot be reached, `run` and `open` warn and take the project's own name, the config's `name` or `PROTOBASE_APP_NAME` in its environment, and `build` stops.
39
39
 
@@ -47,7 +47,7 @@ Signing in works in the app as on the web, with nothing more to set up:
47
47
  - The app calls `/api/auth` through the device's native HTTP, naming its Capacitor origin. With a mobile section, sign-in trusts the Capacitor origin a request names, for that request only, without CORS.
48
48
  - The session lives in the device's cookie store, so it survives reloads, updates and relaunches. On iOS, signing in or out within about a second of killing the app may be lost.
49
49
  - <gap>"Forgot password?" is not offered in the app, as the emailed link cannot lead back into it.</gap>
50
- - On Android, page script cannot reach the session cookie: Capacitor's `CapacitorHttp`, `CapacitorCookies` and `WebView` plugins are refused to it, and so are the app's local file routes. A plugin that reads files for its JavaScript, such as `@capacitor/filesystem`, could still hand the cookie over. <gap>On iOS, page script can still reach the session cookie through Capacitor's native plugins, as Protobase's native plugin is not implemented for iOS yet.</gap> There, keep untrusted script out of UI plugins.
50
+ - Page script cannot reach the session cookie, on iOS and Android alike: Capacitor's `CapacitorHttp`, `CapacitorCookies` and `WebView` plugins are refused to it, and so are the app's local file routes. A plugin that reads files for its JavaScript, such as `@capacitor/filesystem`, could still hand the cookie over.
51
51
  - While you develop over plain `http://localhost` with a mobile section, a page served on `https://localhost` in the same browser can send sign-in requests that carry your dev session, as some browsers treat the two as the same site. Do not open untrusted pages on `https://localhost` while you develop.
52
52
 
53
53
  ## 3. Run it
@@ -44,7 +44,7 @@ Every commit message follows [Conventional Commits](https://www.conventionalcomm
44
44
 
45
45
  `.github/workflows/release.yml` runs on every push to `main`:
46
46
 
47
- 1. The checks of `ci.yml` (`bun run check`, the smoke test on Node, the docs build, the Storybook play tests and the docs check), of the tests and steps the changes since the last `v<version>` tag affect (see What a push checks in `CONTRIBUTING.md`), and commitlint over the pushed commits. When the push cuts a release, the Postgres suite (`bun run test:postgres`, on Postgres and PgBouncer) runs in full as well, whatever changed.
47
+ 1. The checks of `ci.yml` (`bun run check`, the smoke test on Node, the docs build, the Storybook play tests and the docs check), of the tests and steps the changes since the last `v<version>` tag affect (see What a push checks in `CONTRIBUTING.md`), and commitlint over the pushed commits. The Postgres suite (`bun run test:postgres`, on Postgres and PgBouncer) runs in full as well, whatever changed, beside the other checks. They start at once, and the release waits for them all.
48
48
  2. `bun run release` (`scripts/release.mjs`, with [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version)) computes the next version and its notes from the commits since the last `v<version>` tag, as above, and tags the pushed commit `v<version>`. It commits nothing and changes no file. Without a fix, feature or breaking change it tags nothing.
49
49
  3. The tag is pushed, and the GitHub release of the tag gets the notes.
50
50
  4. `scripts/stamp-version.mjs` writes the tag's version into every `package.json` and `bun.lock` in the runner, never committed. `scripts/publish.mjs` then builds every package at the tag to `dist` and packs it with Bun (the private `@protobase/presets` is not published), and npm, under Node, publishes it with [trusted publishing](https://docs.npmjs.com/trusted-publishers) and provenance; there is no npm token. A run that cut no release publishes nothing.