@protobase/cli 0.57.4 → 0.57.6
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/build/bundle-mobile.js +8 -3
- package/dist/bundle/manifest.js +1 -1
- package/dist/cli/package.js +1 -1
- package/dist/mobile/live-update-settings.js +2 -3
- package/dist/mobile/package.js +1 -1
- package/dist/mobile/run.js +0 -1
- package/package.json +7 -7
- package/skills/protobase/references/features/build-and-run.md +1 -1
- package/skills/protobase/references/guides/mobile-app.md +2 -2
- package/skills/protobase/references/reference/cli.md +7 -7
- package/skills/protobase/references/reference/config/app.md +1 -1
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { checkMobileConfig } from "../mobile/mobile-config.js";
|
|
2
2
|
//#region src/build/bundle-mobile.ts
|
|
3
3
|
/**
|
|
4
|
-
* What the manifest says of the config's `mobile` section, checked as `protobase mobile` checks it: its
|
|
5
|
-
*
|
|
4
|
+
* What the manifest says of the config's `mobile` section, checked as `protobase mobile` checks it: its app id, which a
|
|
5
|
+
* host that never runs the config binds in the release's statement, and its plugins, empty when it gives none, which it
|
|
6
|
+
* fingerprints the mobile release with. `undefined`
|
|
6
7
|
* without a section, so its presence means the app has a mobile build.
|
|
7
8
|
*/
|
|
8
9
|
const bundleMobile = (section) => {
|
|
9
10
|
if (section === void 0) return;
|
|
10
|
-
|
|
11
|
+
const { appId, plugins } = checkMobileConfig(section);
|
|
12
|
+
return {
|
|
13
|
+
appId,
|
|
14
|
+
plugins: plugins ?? {}
|
|
15
|
+
};
|
|
11
16
|
};
|
|
12
17
|
//#endregion
|
|
13
18
|
export { bundleMobile };
|
package/dist/bundle/manifest.js
CHANGED
|
@@ -32,7 +32,7 @@ const parseManifest = (value, file) => {
|
|
|
32
32
|
if (builtAt !== void 0 && !isTime(builtAt)) throw new Error(`${file} has a builtAt that is no time in ms`);
|
|
33
33
|
if (icons !== void 0 && !isIcons(icons)) throw new Error(`${file} has icons that are not a favicon flag and a list of PNG icons`);
|
|
34
34
|
if (native !== void 0 && !isVersions(native)) throw new Error(`${file} has a native that is not a map of package names to versions`);
|
|
35
|
-
if (mobile !== void 0 && !(isObject(mobile) && isVersions(mobile.plugins))) throw new Error(`${file} has a mobile that is not { plugins } with a map of package names to versions`);
|
|
35
|
+
if (mobile !== void 0 && !(isObject(mobile) && isVersions(mobile.plugins) && (mobile.appId === void 0 || typeof mobile.appId === "string"))) throw new Error(`${file} has a mobile that is not { appId, plugins } with an app id and a map of package names to versions`);
|
|
36
36
|
if (nodeModules !== void 0 && typeof nodeModules !== "string") throw new Error(`${file} has a nodeModules that is no path`);
|
|
37
37
|
if (migrations !== void 0 && typeof migrations !== "string") throw new Error(`${file} has a migrations that is no path`);
|
|
38
38
|
return {
|
package/dist/cli/package.js
CHANGED
|
@@ -12,12 +12,11 @@ const ownOrigin = (origin) => {
|
|
|
12
12
|
return url.protocol === "https:" || url.protocol === "http:" && loopback.includes(url.hostname);
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
* Whether the app gets the live updater
|
|
15
|
+
* Whether the app gets the live updater, on Android and iOS alike: with `mobile.publicKey`, the order of its own files and an
|
|
16
16
|
* API origin it may take releases from, never with `--live`. `note` says why not, when the project could change it.
|
|
17
17
|
*/
|
|
18
|
-
const liveUpdateSettings = ({
|
|
18
|
+
const liveUpdateSettings = ({ publicKey, builtInOrder, apiOrigin, live }) => {
|
|
19
19
|
if (live) return {};
|
|
20
|
-
if (platform !== "android") return publicKey === void 0 ? {} : { note: "the iOS app does not update itself yet: its live updater is Android only" };
|
|
21
20
|
if (publicKey === void 0) return { note: "the app does not update itself: set mobile.publicKey to the public key protobase mobile keys prints" };
|
|
22
21
|
if (!builtInOrder) return { note: "the app does not update itself: its files name no build time, so it could not refuse a release older than them" };
|
|
23
22
|
if (!ownOrigin(apiOrigin)) return { note: `the app does not update itself: it takes releases over https only, or http to this device, not from ${apiOrigin}` };
|
package/dist/mobile/package.js
CHANGED
package/dist/mobile/run.js
CHANGED
|
@@ -57,7 +57,6 @@ const prepare = async ({ projectDir, platform, api, extensions, live, release },
|
|
|
57
57
|
}) : await placeholderWebPart(ws);
|
|
58
58
|
const fingerprint = nativeFingerprint(pinnedNative, mobile.plugins);
|
|
59
59
|
const liveUpdate = liveUpdateSettings({
|
|
60
|
-
platform,
|
|
61
60
|
...mobile.publicKey && { publicKey: mobile.publicKey },
|
|
62
61
|
...builtInOrder && { builtInOrder },
|
|
63
62
|
apiOrigin: url.origin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.6",
|
|
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.6",
|
|
46
|
+
"@protobase/layout": "0.57.6",
|
|
47
|
+
"@protobase/query": "0.57.6",
|
|
48
|
+
"@protobase/schema": "0.57.6",
|
|
49
|
+
"@protobase/server": "0.57.6",
|
|
50
|
+
"@protobase/ui": "0.57.6",
|
|
51
51
|
"@react-email/render": "^2.1.0",
|
|
52
52
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
53
53
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -25,4 +25,4 @@ Develop, build and run an app, on servers, in containers and on phones.
|
|
|
25
25
|
- [Protobase Cloud deploys](../guides/deploy.md#protobase-cloud): A push to the app's GitHub branch builds it, migrates and checks its database in one transaction, and switches to the new version once it answers its health check.
|
|
26
26
|
- [Mobile apps](../guides/mobile-app.md) (beta): Runs an app on iOS and Android, also on your own iPhone, with sign-in, and builds signed store releases from a section in its config.
|
|
27
27
|
- [Mobile releases](../reference/cli.md#mobile-releases) (in development): The server offers the mobile app a newer copy of its files, signed, and any host that serves bundles can offer the same from the bundle's files without running its config.
|
|
28
|
-
- [Live updates](../reference/cli.md#the-live-updater) (in development): The Android app
|
|
28
|
+
- [Live updates](../reference/cli.md#the-live-updater) (in development): The Android and iOS app update themselves in the background to the server's release, downloading only the files that changed, and go back to the files they were built with when a release fails to start.
|
|
@@ -122,7 +122,7 @@ Only Gradle gets them, for the length of the build: npm, its install scripts and
|
|
|
122
122
|
|
|
123
123
|
## 7. Live updates
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
The app updates its files itself from your server, on Android and iOS alike, so it gets UI changes without a store release. Make a key pair once:
|
|
126
126
|
|
|
127
127
|
```sh
|
|
128
128
|
protobase mobile keys
|
|
@@ -139,7 +139,7 @@ mobile: {
|
|
|
139
139
|
},
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
-
Build the binary again. Each deploy of the app then reaches it: it downloads the files that changed in the background and runs them at its next start, and a release that fails to start goes back to the files the binary carries. Releases come from a server of the same Protobase minor as the binary (below 1.0); a newer minor needs a store release. See [the live updater](../reference/cli.md#the-live-updater).
|
|
142
|
+
Build the binary again. Each deploy of the app then reaches it: it downloads the files that changed in the background and runs them at its next start, and a release that fails to start goes back to the files the binary carries. Releases come from a server of the same Protobase minor as the binary (below 1.0); a newer minor needs a store release. See [the live updater](../reference/cli.md#the-live-updater).
|
|
143
143
|
|
|
144
144
|
## 8. What the stores accept
|
|
145
145
|
|
|
@@ -211,7 +211,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
211
211
|
],
|
|
212
212
|
"shell": { "protobase": "0.12.0", "pluginApi": 1, "paths": ["/index.html", "/assets", "/protobase.sw.js"] },
|
|
213
213
|
"native": { "@capacitor/core": "8.5.3", "@capacitor/ios": "8.5.3" },
|
|
214
|
-
"mobile": { "plugins": { "@capacitor/camera": "^8.0.1" } },
|
|
214
|
+
"mobile": { "appId": "com.example.shop", "plugins": { "@capacitor/camera": "^8.0.1" } },
|
|
215
215
|
"nodeModules": "node_modules",
|
|
216
216
|
"migrations": "migrations"
|
|
217
217
|
}
|
|
@@ -222,7 +222,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
222
222
|
- `plugins` are the bundle's own plugins, in the order the app merges them: the extensions', then the project's (`app`). Each names its `plugin.json`, the plugin API and Protobase versions it is built for, and the [field types](plugins.md#field-types) it registers with the storage types each shows, which the serve runtime checks the views against at startup. `/api/meta` names them to everyone, before any other plugin.
|
|
223
223
|
- `shell` is the admin app `public/` holds a copy of: its Protobase version and plugin API, and its files as URL paths. A host with a shell of its own may serve its own for those paths instead (see [The UI](#the-ui)), so the app gets that release's fixes without a rebuild.
|
|
224
224
|
- `native` is the native code, name to version, that `shell` runs on in the [mobile app](../guides/mobile-app.md): the native packages `@protobase/mobile` pins, and `@protobase/mobile` itself at its native contract, such as `native-1`, which Protobase raises when its own native code changes. The fingerprint of the bundle's [mobile release](#mobile-releases) names them. A bundle built before it serves no mobile release.
|
|
225
|
-
- `mobile` is present only when the project's config has a `mobile` section, so a host learns that the app has a mobile build without running the config: the section's `plugins`, name to the spec it gives, `{}` when it gives none, which the fingerprint of the mobile release names besides `native`. The build checks the section as `protobase mobile` does.
|
|
225
|
+
- `mobile` is present only when the project's config has a `mobile` section, so a host learns that the app has a mobile build without running the config: the section's `appId`, which the statement of a signed mobile release binds, and its `plugins`, name to the spec it gives, `{}` when it gives none, which the fingerprint of the mobile release names besides `native`. A bundle built before it names no `appId`. The build checks the section as `protobase mobile` does.
|
|
226
226
|
- `theme` is the project's [theme](theme.md), which the app links at `/protobase.theme.css`. It is always there, empty when the project has none.
|
|
227
227
|
- `nodeModules` is present only when the config module imports [native packages](#native-packages). It is always the `node_modules` folder beside `server`, where Bun and Node resolve the module's imports from, and holds plain packages: JavaScript, `package.json` files and native binaries for linux x64 and arm64 (glibc), which the runtime loads with `dlopen`. A host keeps it next to the server module and must not mount it `noexec` (an add-on there then fails with `failed to map segment from shared object`). Its binaries link nothing but glibc, `libstdc++.so.6`, `libgcc_s.so.1` and libraries in the bundle itself, so the run image must have those three. Without `nodeModules`, the server module is the only file the runtime reads.
|
|
228
228
|
- `migrations` is present only when the project has a `db/migrations` folder: its `.sql` files, which the runtime's `migrate` applies (see [Deploy](../guides/deploy.md)). A host never serves it.
|
|
@@ -424,7 +424,7 @@ The app's address and secret are `PROTOBASE_URL` and `PROTOBASE_SECRET` unless i
|
|
|
424
424
|
### Mobile releases
|
|
425
425
|
|
|
426
426
|
:::caution[In development]
|
|
427
|
-
|
|
427
|
+
Mobile releases and the live updater are in development.
|
|
428
428
|
:::
|
|
429
429
|
|
|
430
430
|
With a `mobile` section, the server serves the [mobile app](../guides/mobile-app.md) a newer copy of its files, for its live updater, so the app gets UI changes without a store release. The release is what the server serves the web, composed at startup: every file of `public/`, with the server's own shell where `protobase serve` uses it, and `index.html` naming the API origin, the app's `url` (https, or plain http to `localhost`, `127.0.0.1` or `[::1]`). There is none when the server serves the API alone, has no such `url`, or the bundle names no `native`, and with `PROTOBASE_MOBILE_SIGNING_KEY` none for a bundle that names no build time (one built before Protobase recorded it: build it again). Where `protobase serve` serves its own shell, the release's fingerprint names the `native` of that shell's `protobase.shell.json`, and there is none when it names none.
|
|
@@ -432,11 +432,11 @@ With a `mobile` section, the server serves the [mobile app](../guides/mobile-app
|
|
|
432
432
|
- `GET /api/mobile/release?fingerprint=<native fingerprint>&shell_version=<x.y.z>` answers `{ "bundleId", "url", "required" }`: the release's id, a hash of its files, and its absolute base URL, both `null` when the release does not run on the asking binary, whose native fingerprint must equal the release's. `required` is true when the shell the app runs no longer works with the server's API: below 1.0 another minor, from 1.0 another major. A missing fingerprint or a shell version that is no x.y.z version gets 400.
|
|
433
433
|
- `GET /api/mobile/releases/<bundleId>?href=<file>` serves the release's file `<file>`, such as `assets/index-abc123.js`, and with `href=capawesome-live-update-manifest.json` its manifest, a JSON array of `{ "href", "checksum", "sizeInBytes" }`. Each comes with its sha256 in hex in `X-Checksum` and, with `PROTOBASE_MOBILE_SIGNING_KEY`, its signature in `X-Signature`. Any other file, or another release's id, gets 404.
|
|
434
434
|
- Signed, a release also serves `href=protobase-release.json`, its statement: `{ "payload", "signature" }`, the payload the hex of the JSON `{ "manifest", "order", "appId", "fingerprint", "shellVersion" }` and the signature the hex of its SHA256withRSA over the line `protobase-mobile-release` and the payload. It binds the manifest's sha256 to the release's order, when the bundle was built and then when the server's own shell it serves was built (0 with the bundle's copy), to the app id and native fingerprint of the binaries it runs on, and to the server's Protobase version. Its id is then a hash of the statement and the public key, so the same files built again get another id. A file of the app may not be named like the statement or start with that line.
|
|
435
|
-
-
|
|
435
|
+
- The app, on Android and iOS alike, downloads a release itself and takes it only when its statement is signed with the key the binary pins, names the release's id, this app, this binary and a server its shell works with, and its order is not below the highest it downloaded; then every file must hash to what the manifest lists, under a path inside the release, before any file is written. It follows no redirect and reads no file past the size its manifest lists. It runs a downloaded release only above the running one's order and holding nothing but the files its manifest lists. It never takes a release at or below the order of its own files, which `protobase mobile` records in the binary as the server would order the same bundle with its copy of the shell, so a reinstalled app is not taken below them, and a release built before the binary is not taken. <gap>A phone cannot take a rollback of the bundle or of the server's shell before a later build, because ordering releases by an explicit release number is not implemented.</gap> <gap>An app with no download recorded, such as after a reinstall, cannot refuse a genuine signed release older than the latest but newer than its own files, because a signed answer naming the latest release is not implemented.</gap>
|
|
436
436
|
|
|
437
437
|
#### The live updater
|
|
438
438
|
|
|
439
|
-
An Android app built with `mobile.publicKey` updates itself from the server it calls. The shell asks `GET /api/mobile/release` when the app starts and each time it comes back to the foreground, in the background, and downloads a release it does not run, only the files that changed, then runs it at the next cold start. The session stays in the device's cookie store, so the user stays signed in across the switch.
|
|
439
|
+
An Android or iOS app built with `mobile.publicKey` updates itself from the server it calls. The shell asks `GET /api/mobile/release` when the app starts and each time it comes back to the foreground, in the background, and downloads a release it does not run, only the files that changed, then runs it at the next cold start. The session stays in the device's cookie store, so the user stays signed in across the switch.
|
|
440
440
|
|
|
441
441
|
- Once the shell has drawn, it tells the updater the release started. A release that does not within 30 seconds goes back to the app's own files at once and is never taken again.
|
|
442
442
|
- No answer, any status but 200, a body that is not the answer, or an answer naming no release changes nothing: the app keeps the files it runs, and never goes back to its own files because of the answer, which is not signed.
|
|
@@ -447,7 +447,7 @@ A host that serves bundles without running their config, such as a router in fro
|
|
|
447
447
|
|
|
448
448
|
- `nativeFingerprint(native, plugins)`: the release's fingerprint, from the manifest's `native` (or that of the shell the host serves) and `mobile.plugins`. It is a contract across versions: a binary one Protobase release built is matched by a host that runs another.
|
|
449
449
|
- `withApiOrigin(html, origin)`: the `spa` page naming the API origin, the app's `url`.
|
|
450
|
-
- `composeRelease(files, signing?)`: the release of `{ href, content }` files, every file the host serves the web with the page above in place of `spa`, with its id and, with `signing`, `{ key, binding: { order, appId, fingerprint, shellVersion } }`, the signed checksums and statement.
|
|
450
|
+
- `composeRelease(files, signing?)`: the release of `{ href, content }` files, every file the host serves the web with the page above in place of `spa`, with its id and, with `signing`, `{ key, binding: { order, appId, fingerprint, shellVersion } }`, `appId` the manifest's `mobile.appId`, the signed checksums and statement.
|
|
451
451
|
- `readSigningKey(env)`: the signing key in `PROTOBASE_MOBILE_SIGNING_KEY` of the env object given, the app's own, never the process's.
|
|
452
452
|
- `mobileReleaseApp({ release, serverVersion })`: a Hono app answering the two routes above for `{ ...release, fingerprint, origin }`.
|
|
453
453
|
|
|
@@ -602,7 +602,7 @@ Builds the project in the current directory as an iOS or Android app with Capaci
|
|
|
602
602
|
- npm and Capacitor get the CLI's environment without any variable named in the current directory's `.env*` files, nor the four `PROTOBASE_ANDROID_*` signing variables, which only Gradle gets, and with `CI=true`, which keeps Capacitor's telemetry off.
|
|
603
603
|
- It prints the workspace, the API origin and the native fingerprint, which the app also sends in its user agent as `ProtobaseNative/<fingerprint>`: a hash of the native packages `@protobase/mobile` pins, at their versions, its own native contract, and the section's `plugins`, at the versions they give. A [mobile release](#mobile-releases) runs only on a binary of its own fingerprint. A Protobase release that pins the same native packages and keeps the same native contract keeps it; raise a plugin's version when the app's files start using a newer native feature of it, which changes it.
|
|
604
604
|
- The app's files carry the live updater's manifest of them, so an update downloads only the files that changed.
|
|
605
|
-
- With `mobile.publicKey`, the Android app
|
|
605
|
+
- With `mobile.publicKey`, the Android and iOS app get the [live updater](#the-live-updater), unless `--live` is given, the app's files name no build time, or the API is neither https nor http to this machine; it prints a note why when it leaves it out.
|
|
606
606
|
- `keys` prints a fresh RSA key pair: `PROTOBASE_MOBILE_SIGNING_KEY=<key>`, on one line with its newlines written `\n`, for the server's environment, a secret never to commit, and the public key, PEM, for `mobile.publicKey`. It reads no project and writes no file.
|
|
607
607
|
|
|
608
608
|
## `token`
|
|
@@ -104,7 +104,7 @@ The app's iOS and Android build: with it, `protobase mobile` builds the app with
|
|
|
104
104
|
|
|
105
105
|
- `appId`: the app's id on both iOS and Android, such as `com.example.shop`: two or more dot-separated parts, each a letter then letters and digits.
|
|
106
106
|
- `plugins`: extra native Capacitor plugins, by npm name and version range. A range fetched over plain `http:` or `git:` is refused.
|
|
107
|
-
- `publicKey`: the public key, PEM, of the RSA key the server signs the app's [releases](../cli.md#the-live-updater) with, from [`protobase mobile keys`](../cli.md#mobile): with it the Android app
|
|
107
|
+
- `publicKey`: the public key, PEM, of the RSA key the server signs the app's [releases](../cli.md#the-live-updater) with, from [`protobase mobile keys`](../cli.md#mobile): with it the Android and iOS app update themselves. Anything but an RSA public key of at least 2048 bits stops the build.
|
|
108
108
|
|
|
109
109
|
```ts
|
|
110
110
|
export default defineConfig({
|