@protobase/cli 0.56.0 → 0.57.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.56.0";
2
+ var version = "0.57.0";
3
3
  //#endregion
4
4
  export { version };
@@ -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.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": {
@@ -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.0",
46
+ "@protobase/layout": "0.57.0",
47
+ "@protobase/query": "0.57.0",
48
+ "@protobase/schema": "0.57.0",
49
+ "@protobase/server": "0.57.0",
50
+ "@protobase/ui": "0.57.0",
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