@protobase/cli 0.45.1 → 0.45.2

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.45.1";
2
+ var version = "0.45.2";
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 = 1;
3
+ var nativeContract = 2;
4
4
  var dependencies = {
5
5
  "@capacitor/android": "8.5.3",
6
6
  "@capacitor/app": "8.1.2",
@@ -1,5 +1,5 @@
1
1
  import path from "node:path";
2
- import { readFile } from "node:fs/promises";
2
+ import { readFile, writeFile } from "node:fs/promises";
3
3
  //#region src/mobile/protobase-plugin.ts
4
4
  /** The classes of Protobase's native plugin that keep page script away from the session, by Java class name. */
5
5
  const protobasePluginClasses = [
@@ -9,16 +9,43 @@ const protobasePluginClasses = [
9
9
  "RefusedWebView",
10
10
  "LocalServerGuard"
11
11
  ].map((name) => `net.protobase.mobile.${name}`);
12
+ const liveUpdatePackage = "@capawesome/capacitor-live-update";
13
+ const stockLiveUpdate = "io.capawesome.capacitorjs.plugins.liveupdate.LiveUpdatePlugin";
14
+ const guardedLiveUpdate = {
15
+ pkg: "@protobase/mobile",
16
+ classpath: "net.protobase.mobile.GuardedLiveUpdate"
17
+ };
18
+ const pluginsFile = (ws) => path.join(ws, "android", "app", "src", "main", "assets", "capacitor.plugins.json");
19
+ const readPlugins = async (ws) => JSON.parse(await readFile(pluginsFile(ws), "utf8"));
20
+ /**
21
+ * Puts Protobase's guarded live updater in the stock one's place in the plugin list `cap add android` writes, so page
22
+ * script reaches only what the shell needs; listing both would run two updaters. The guard compiles from the same
23
+ * plugin list, and the build checks it again (@protobase/mobile's build.gradle). An app without the plugin is left as is.
24
+ */
25
+ const guardLiveUpdate = async (ws) => {
26
+ const entries = await readPlugins(ws);
27
+ if (!entries.some(({ classpath }) => classpath === stockLiveUpdate)) return;
28
+ const guarded = entries.map((entry) => entry.classpath === stockLiveUpdate ? guardedLiveUpdate : entry);
29
+ await writeFile(pluginsFile(ws), JSON.stringify(guarded, null, " "));
30
+ };
12
31
  /**
13
32
  * Checks that `cap add android` compiled Protobase's native plugin into the app, from the plugin list it writes: an
14
- * installed @protobase/mobile older than the CLI's, as a workspace left from an earlier CLI may hold, has none.
33
+ * installed @protobase/mobile older than the CLI's, as a workspace left from an earlier CLI may hold, has none. Refuses
34
+ * any class of the live updater's own package still listed, which no guard stands in front of.
15
35
  */
16
36
  const checkProtobasePlugin = async (ws) => {
17
- const file = path.join(ws, "android", "app", "src", "main", "assets", "capacitor.plugins.json");
18
- const listed = new Set(JSON.parse(await readFile(file, "utf8")).map(({ classpath }) => classpath));
37
+ const entries = await readPlugins(ws);
38
+ const unguarded = entries.find(({ pkg, classpath }) => pkg === liveUpdatePackage || classpath === stockLiveUpdate);
39
+ if (unguarded) throw new Error(`The Android app lists ${unguarded.classpath}, which hands page script the live updater unguarded`);
40
+ const listed = new Set(entries.map(({ classpath }) => classpath));
19
41
  const missing = protobasePluginClasses.filter((name) => !listed.has(name));
20
42
  if (missing.length === 0) return;
21
43
  throw new Error(`The Android app lacks Protobase's native plugin (${missing.join(", ")}): delete ${ws} and run the command again`);
22
44
  };
45
+ /** Refuses the live updater on iOS, which has no guard yet, from the class list `cap add ios` writes. */
46
+ const checkIosPlugins = async (ws) => {
47
+ if (!JSON.parse(await readFile(path.join(ws, "ios", "App", "App", "capacitor.config.json"), "utf8")).packageClassList?.includes("LiveUpdatePlugin")) return;
48
+ throw new Error("The iOS app lists LiveUpdatePlugin, which has no guard against page script on iOS yet");
49
+ };
23
50
  //#endregion
24
- export { checkProtobasePlugin, protobasePluginClasses };
51
+ export { checkIosPlugins, checkProtobasePlugin, guardLiveUpdate, protobasePluginClasses };
@@ -12,7 +12,7 @@ import { generatePlatform } from "./generate.js";
12
12
  import { checkMobileConfig } from "./mobile-config.js";
13
13
  import { loadMobileProject } from "./load-project.js";
14
14
  import { signForDevelopment } from "./development-signing.js";
15
- import { checkProtobasePlugin } from "./protobase-plugin.js";
15
+ import { checkIosPlugins, checkProtobasePlugin, guardLiveUpdate } from "./protobase-plugin.js";
16
16
  import { mobileSpec, prepareWorkspace, workspaceDir, workspacePackageJson } from "./workspace.js";
17
17
  import path from "node:path";
18
18
  import { defaultAppName } from "@protobase/server";
@@ -57,7 +57,10 @@ const prepare = async ({ projectDir, platform, api, extensions, live, release },
57
57
  }));
58
58
  const cap = capacitorRunner(ws, env, run);
59
59
  await generatePlatform(ws, platform, allowances, cap);
60
- if (platform === "android") await checkProtobasePlugin(ws);
60
+ if (platform === "android") {
61
+ await guardLiveUpdate(ws);
62
+ await checkProtobasePlugin(ws);
63
+ } else await checkIosPlugins(ws);
61
64
  return {
62
65
  ws,
63
66
  url,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.45.1",
3
+ "version": "0.45.2",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -36,11 +36,11 @@
36
36
  "@better-auth/core": "^1.7.12",
37
37
  "@hono/node-server": "^2.1.3",
38
38
  "@hono/vite-dev-server": "^0.26.1",
39
- "@protobase/layout": "0.45.1",
40
- "@protobase/query": "0.45.1",
41
- "@protobase/schema": "0.45.1",
42
- "@protobase/server": "0.45.1",
43
- "@protobase/ui": "0.45.1",
39
+ "@protobase/layout": "0.45.2",
40
+ "@protobase/query": "0.45.2",
41
+ "@protobase/schema": "0.45.2",
42
+ "@protobase/server": "0.45.2",
43
+ "@protobase/ui": "0.45.2",
44
44
  "@react-email/render": "^2.1.0",
45
45
  "@scalar/hono-api-reference": "^0.12.10",
46
46
  "@tailwindcss/vite": "^4.3.3",