@protobase/cli 0.57.1 → 0.57.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.
- package/dist/cli/package.js +1 -1
- package/dist/mobile/package.js +1 -1
- package/dist/mobile/protobase-plugin.js +40 -14
- package/dist/mobile/run.js +5 -2
- package/package.json +7 -7
package/dist/cli/package.js
CHANGED
package/dist/mobile/package.js
CHANGED
|
@@ -53,30 +53,56 @@ const readIosFile = (ws, ...parts) => readFile(path.join(ws, "ios", "App", ...pa
|
|
|
53
53
|
if (error.code === "ENOENT") return;
|
|
54
54
|
throw error;
|
|
55
55
|
});
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
let parsed;
|
|
56
|
+
const iosConfigParts = ["App", "capacitor.config.json"];
|
|
57
|
+
const parseIosConfig = (text) => {
|
|
59
58
|
try {
|
|
60
|
-
|
|
59
|
+
return JSON.parse(text);
|
|
61
60
|
} catch (error) {
|
|
62
|
-
if (error instanceof SyntaxError) return
|
|
61
|
+
if (error instanceof SyntaxError) return;
|
|
63
62
|
throw error;
|
|
64
63
|
}
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
};
|
|
65
|
+
const iosClasses = (config) => {
|
|
66
|
+
const classes = config?.packageClassList;
|
|
67
|
+
return Array.isArray(classes) ? classes.filter((name) => typeof name === "string") : void 0;
|
|
68
|
+
};
|
|
69
|
+
/** The stock live updater's iOS class, and Protobase's guard that takes its place, by `@objc` name. */
|
|
70
|
+
const stockIosLiveUpdate = "LiveUpdatePlugin";
|
|
71
|
+
const guardedIosLiveUpdate = "GuardedLiveUpdatePlugin";
|
|
72
|
+
/** The Swift package product `cap add ios` compiles the live updater into, by the name @capacitor/cli's fixName gives. */
|
|
73
|
+
const liveUpdateIosProduct = "CapawesomeCapacitorLiveUpdate";
|
|
74
|
+
/**
|
|
75
|
+
* Puts Protobase's guarded live updater in the stock one's place in the class list `cap add ios` writes, so page script
|
|
76
|
+
* reaches only what the shell needs; listing both would run two updaters. `cap add ios` lists the guard in every app, as
|
|
77
|
+
* it lists each `@objc(...)` class of @protobase/mobile's Swift files, so an app without the live updater loses it.
|
|
78
|
+
*/
|
|
79
|
+
const guardIosLiveUpdate = async (ws) => {
|
|
80
|
+
const text = await readIosFile(ws, ...iosConfigParts);
|
|
81
|
+
const config = text === void 0 ? void 0 : parseIosConfig(text);
|
|
82
|
+
const classes = iosClasses(config);
|
|
83
|
+
if (!config || !classes) return;
|
|
84
|
+
const guarded = classes.includes("LiveUpdatePlugin") ? classes.map((name) => name === "LiveUpdatePlugin" ? guardedIosLiveUpdate : name).filter((name, index, all) => all.indexOf(name) === index) : classes.filter((name) => name !== guardedIosLiveUpdate);
|
|
85
|
+
await writeFile(path.join(ws, "ios", "App", ...iosConfigParts), JSON.stringify({
|
|
86
|
+
...config,
|
|
87
|
+
packageClassList: guarded
|
|
88
|
+
}, null, " "));
|
|
67
89
|
};
|
|
68
90
|
/**
|
|
69
|
-
* Checks what `cap add ios` writes: the class list, which must name Protobase's plugin classes and not the live
|
|
70
|
-
*
|
|
71
|
-
* without its product is skipped at launch without a word. A workspace left from an
|
|
91
|
+
* Checks what `cap add ios` writes: the class list, which must name Protobase's plugin classes and not the stock live
|
|
92
|
+
* updater, and the app's Swift package, which must compile Protobase's product in, and the live updater's when the
|
|
93
|
+
* guard is listed; a class listed without its product is skipped at launch without a word. A workspace left from an
|
|
94
|
+
* earlier CLI may lack either.
|
|
72
95
|
*/
|
|
73
96
|
const checkIosPlugins = async (ws) => {
|
|
74
97
|
const stale = (what) => /* @__PURE__ */ new Error(`The iOS app lacks Protobase's native plugin (${what}): delete ${ws} and run the command again`);
|
|
75
|
-
const
|
|
76
|
-
|
|
98
|
+
const text = await readIosFile(ws, ...iosConfigParts);
|
|
99
|
+
const classes = (text === void 0 ? void 0 : iosClasses(parseIosConfig(text))) ?? [];
|
|
100
|
+
if (classes.includes("LiveUpdatePlugin")) throw new Error(`The iOS app lists ${stockIosLiveUpdate}, which hands page script the live updater unguarded: run protobase mobile again instead of cap sync`);
|
|
77
101
|
const missing = protobaseIosPluginClasses.filter((name) => !classes.includes(name));
|
|
78
102
|
if (missing.length > 0) throw stale(missing.join(", "));
|
|
79
|
-
|
|
103
|
+
const manifest = await readIosFile(ws, "CapApp-SPM", "Package.swift");
|
|
104
|
+
if (!manifest?.includes(`.product(name: "ProtobaseMobile"`)) throw stale(protobaseIosProduct);
|
|
105
|
+
if (classes.includes("GuardedLiveUpdatePlugin") && !manifest.includes(`.product(name: "CapawesomeCapacitorLiveUpdate"`)) throw new Error(`The iOS app lists ${guardedIosLiveUpdate} without the live updater's ${liveUpdateIosProduct}: run protobase mobile again`);
|
|
80
106
|
};
|
|
81
107
|
//#endregion
|
|
82
|
-
export { checkIosPlugins, checkProtobasePlugin, guardLiveUpdate, protobaseIosPluginClasses, protobaseIosProduct, protobasePluginClasses };
|
|
108
|
+
export { checkIosPlugins, checkProtobasePlugin, guardIosLiveUpdate, guardLiveUpdate, guardedIosLiveUpdate, liveUpdateIosProduct, protobaseIosPluginClasses, protobaseIosProduct, protobasePluginClasses, stockIosLiveUpdate };
|
package/dist/mobile/run.js
CHANGED
|
@@ -12,7 +12,7 @@ import { deviceAppName } from "./device-app-name.js";
|
|
|
12
12
|
import { generatePlatform } from "./generate.js";
|
|
13
13
|
import { loadMobileProject } from "./load-project.js";
|
|
14
14
|
import { signForDevelopment } from "./development-signing.js";
|
|
15
|
-
import { checkIosPlugins, checkProtobasePlugin, guardLiveUpdate } from "./protobase-plugin.js";
|
|
15
|
+
import { checkIosPlugins, checkProtobasePlugin, guardIosLiveUpdate, 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 { nativeFingerprint } from "@protobase/server/mobile-release";
|
|
@@ -69,7 +69,10 @@ const prepare = async ({ projectDir, platform, api, extensions, live, release },
|
|
|
69
69
|
if (platform === "android") {
|
|
70
70
|
await guardLiveUpdate(ws);
|
|
71
71
|
await checkProtobasePlugin(ws);
|
|
72
|
-
} else
|
|
72
|
+
} else {
|
|
73
|
+
await guardIosLiveUpdate(ws);
|
|
74
|
+
await checkIosPlugins(ws);
|
|
75
|
+
}
|
|
73
76
|
return {
|
|
74
77
|
ws,
|
|
75
78
|
url,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.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": {
|
|
@@ -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.57.
|
|
46
|
-
"@protobase/layout": "0.57.
|
|
47
|
-
"@protobase/query": "0.57.
|
|
48
|
-
"@protobase/schema": "0.57.
|
|
49
|
-
"@protobase/server": "0.57.
|
|
50
|
-
"@protobase/ui": "0.57.
|
|
45
|
+
"@protobase/config": "0.57.2",
|
|
46
|
+
"@protobase/layout": "0.57.2",
|
|
47
|
+
"@protobase/query": "0.57.2",
|
|
48
|
+
"@protobase/schema": "0.57.2",
|
|
49
|
+
"@protobase/server": "0.57.2",
|
|
50
|
+
"@protobase/ui": "0.57.2",
|
|
51
51
|
"@react-email/render": "^2.1.0",
|
|
52
52
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
53
53
|
"@tailwindcss/vite": "^4.3.3",
|