@protobase/cli 0.45.6 → 0.45.8

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.6";
2
+ var version = "0.45.8";
3
3
  //#endregion
4
4
  export { version };
@@ -0,0 +1,16 @@
1
+ //#region src/mobile/app-plugins-hook.ts
2
+ /** The Capacitor hooks, scripts in the workspace's package.json, run after `cap copy` and `cap update`; `add` and `sync` run both. */
3
+ const appPluginsHooks = ["capacitor:copy:after", "capacitor:update:after"];
4
+ /** Where each platform's native project keeps the app's files, as Capacitor copies them from the web part. */
5
+ const nativeWebDirs = {
6
+ ios: "ios/App/App/public",
7
+ android: "android/app/src/main/assets/public"
8
+ };
9
+ /**
10
+ * The hook's command: copies the web part's `plugins/`, the app's own UI plugins, back into the platform's files.
11
+ * Capacitor keeps `plugins/` for Cordova plugins and removes it on every copy and update, so without this the app finds
12
+ * no plugin.json at `/plugins/<name>/` and turns its plugins off. Single quotes only, for any shell npm scripts run in.
13
+ */
14
+ const appPluginsCommand = `node -e "const fs=require('fs');const to={${Object.entries(nativeWebDirs).map(([platform, dir]) => `${platform}:'${dir}'`).join(",")}}[process.env.CAPACITOR_PLATFORM_NAME];if(to&&fs.existsSync('web/plugins'))fs.cpSync('web/plugins',to+'/plugins',{recursive:true})"`;
15
+ //#endregion
16
+ export { appPluginsCommand, appPluginsHooks, nativeWebDirs };
@@ -1,11 +1,13 @@
1
1
  import { withLocalNetworking } from "./info-plist.js";
2
+ import { withProtobaseIcon } from "./native-icon.js";
2
3
  import path from "node:path";
3
4
  import { readFile, rm, writeFile } from "node:fs/promises";
4
5
  //#region src/mobile/generate.ts
5
6
  const infoPlist = (ws) => path.join(ws, "ios", "App", "App", "Info.plist");
6
7
  /**
7
8
  * Generates the platform's native project in the workspace from its capacitor.config.json and app files, replacing
8
- * the last one: it is never edited by hand. An iOS app calling the API over plain http may reach local addresses.
9
+ * the last one: it is never edited by hand. Its home-screen icon is Protobase's, and an iOS app calling the API over
10
+ * plain http may reach local addresses.
9
11
  */
10
12
  const generatePlatform = async (ws, platform, { cleartext }, cap) => {
11
13
  await rm(path.join(ws, platform), {
@@ -13,6 +15,7 @@ const generatePlatform = async (ws, platform, { cleartext }, cap) => {
13
15
  force: true
14
16
  });
15
17
  await cap(["add", platform]);
18
+ await withProtobaseIcon(ws, platform);
16
19
  if (platform !== "ios" || !cleartext) return;
17
20
  await writeFile(infoPlist(ws), withLocalNetworking(await readFile(infoPlist(ws), "utf8")));
18
21
  };
@@ -0,0 +1,39 @@
1
+ import { existsSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { copyFile } from "node:fs/promises";
4
+ /**
5
+ * The template's home-screen icon files, by path in the platform's native project, which Protobase's icon replaces:
6
+ * iOS's one 1024 pixel icon; Android's legacy, round and adaptive foreground icons at each density, and the adaptive
7
+ * icon's background colour.
8
+ */
9
+ const nativeIconFiles = {
10
+ ios: ["App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png"],
11
+ android: [...[
12
+ "mdpi",
13
+ "hdpi",
14
+ "xhdpi",
15
+ "xxhdpi",
16
+ "xxxhdpi"
17
+ ].flatMap((density) => [
18
+ "ic_launcher",
19
+ "ic_launcher_round",
20
+ "ic_launcher_foreground"
21
+ ].map((icon) => `app/src/main/res/mipmap-${density}/${icon}.png`)), "app/src/main/res/values/ic_launcher_background.xml"]
22
+ };
23
+ /** Where @protobase/mobile, installed in the workspace `ws`, has Protobase's icon for the platform, by the same paths. */
24
+ const protobaseIconDir = (ws, platform) => path.join(ws, "node_modules", "@protobase", "mobile", "icon", platform);
25
+ /**
26
+ * Gives the platform's native project in the workspace Protobase's icon in place of Capacitor's. Each file must be one
27
+ * the template has, so a template that moves its icon fails here rather than leaving Capacitor's on the phone.
28
+ */
29
+ const withProtobaseIcon = async (ws, platform) => {
30
+ for (const file of nativeIconFiles[platform]) {
31
+ const from = path.join(protobaseIconDir(ws, platform), file);
32
+ const to = path.join(ws, platform, file);
33
+ if (!existsSync(from)) throw new Error(`@protobase/mobile has no ${path.join(platform, file)} of Protobase's icon`);
34
+ if (!existsSync(to)) throw new Error(`The generated ${platform} project has no ${file}, the icon Protobase's replaces`);
35
+ await copyFile(from, to);
36
+ }
37
+ };
38
+ //#endregion
39
+ export { nativeIconFiles, protobaseIconDir, withProtobaseIcon };
@@ -1,6 +1,7 @@
1
1
  import { protobaseVersion } from "../version/version.js";
2
2
  import { protobaseFolder } from "../project/protobase-folder.js";
3
3
  import { packageNameProblem } from "./package-name.js";
4
+ import { appPluginsCommand, appPluginsHooks } from "./app-plugins-hook.js";
4
5
  import { isLocalSpec } from "./local-spec.js";
5
6
  import { checkLocalPins, isUnmet, localPins } from "./local-pins.js";
6
7
  import { existsSync } from "node:fs";
@@ -13,9 +14,10 @@ const workspaceDir = (projectDir) => path.join(projectDir, protobaseFolder, "mob
13
14
  const fromSource = path.extname(import.meta.url) === ".ts";
14
15
  /** The @protobase/mobile to install: the CLI's own version, or this repository's package when the CLI runs from source. */
15
16
  const mobileSpec = (source = fromSource) => source ? `file:${fileURLToPath(new URL("../../../mobile", import.meta.url))}` : protobaseVersion;
16
- /** The workspace's package.json: @protobase/mobile and the project's extra plugins. */
17
+ /** The workspace's package.json: @protobase/mobile, the project's extra plugins and the hooks that keep the app's UI plugins. */
17
18
  const workspacePackageJson = ({ mobileSpec, plugins = {} }) => ({
18
19
  private: true,
20
+ scripts: Object.fromEntries(appPluginsHooks.map((hook) => [hook, appPluginsCommand])),
19
21
  dependencies: {
20
22
  "@protobase/mobile": mobileSpec,
21
23
  ...plugins
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.45.6",
3
+ "version": "0.45.8",
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.6",
40
- "@protobase/query": "0.45.6",
41
- "@protobase/schema": "0.45.6",
42
- "@protobase/server": "0.45.6",
43
- "@protobase/ui": "0.45.6",
39
+ "@protobase/layout": "0.45.8",
40
+ "@protobase/query": "0.45.8",
41
+ "@protobase/schema": "0.45.8",
42
+ "@protobase/server": "0.45.8",
43
+ "@protobase/ui": "0.45.8",
44
44
  "@react-email/render": "^2.1.0",
45
45
  "@scalar/hono-api-reference": "^0.12.10",
46
46
  "@tailwindcss/vite": "^4.3.3",
@@ -163,4 +163,4 @@ Put `dist/` on a static host, and list its `plugin.json` in the deployed app's `
163
163
 
164
164
  The app updates to a new release of Protobase. Nothing happens to the plugin: within plugin API 1, every release keeps what the plugin imports, and the plugin runs on the newer `@protobase/ui` it is handed, its fixes included.
165
165
 
166
- If the app were older than the plugin needs, it would not load the plugin at all. Its admins would see a notice above the app, such as "The plugin sales-tools is off: it needs Protobase >=0.12.0, and this app runs 0.11.1.", and the card would show a warning in place of the drafts, while the rest of the app works as before. [Versions](../reference/plugins.md#versions) has the rules.
166
+ If the app were older than the plugin needs, it would not load the plugin at all. Its admins would see a notice below the top bar, such as "The plugin sales-tools is off: it needs Protobase >=0.12.0, and this app runs 0.11.1.", and the card would show a warning in place of the drafts, while the rest of the app works as before. [Versions](../reference/plugins.md#versions) has the rules.
@@ -35,6 +35,8 @@ export default defineConfig({
35
35
 
36
36
  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, `appName` or `PROTOBASE_APP_NAME` in its environment, and `build` stops.
37
37
 
38
+ On the home screen the app shows Protobase's icon, on iOS and Android alike. <gap>An app cannot show its own icon on the phone because setting the mobile app's icon is not implemented.</gap>
39
+
38
40
  With a mobile section, the API answers the app's origins, `capacitor://localhost` on iOS and `https://localhost` on Android, through [CORS](../reference/api.md#cors). Apps without one get no new dependency, and `protobase build` and `protobase dev` work as before.
39
41
 
40
42
  Signing in works in the app as on the web, with nothing more to set up:
@@ -9,7 +9,7 @@ An app looks like its own everywhere from three things in its project: its name,
9
9
  | What | Where | Used by |
10
10
  | --- | --- | --- |
11
11
  | Name | `appName` of `createAuth` ([auth configuration](auth.md#configuration)), overridden at run time by `PROTOBASE_APP_NAME` | the sidebar's logo, the end of every tab title, the installed app's name, the [mobile app](../guides/mobile-app.md)'s name on the phone, passkey and authenticator prompts, auth mail and its sender's name |
12
- | Icon | `protobase.favicon.svg` at the project's root | the browser tab, the sidebar's logo, the installed app's icon |
12
+ | Icon | `protobase.favicon.svg` at the project's root | the browser tab, the sidebar's logo, the installed app's icon; the [mobile app](../guides/mobile-app.md) shows Protobase's icon instead |
13
13
  | Raster icons | optional PNGs beside the SVG, below | the iPhone home screen and Android launchers, which take no SVG |
14
14
  | Colours | `app` in `protobase.config.ts` | the installed app's title bar and its start screen |
15
15
 
@@ -23,7 +23,7 @@ With an absolute `baseUrl`, such as another app's `https://desk.example.com/api/
23
23
 
24
24
  ## The admin app
25
25
 
26
- `<App baseUrl="/api/v1" />` renders the shell from `/api/meta` (beside the API, so `createClient` derives it from `baseUrl`) and routes `/:page` ([composed pages](layouts.md)), `/:resource` (list) and `/:resource/:key` (record); it opens on the first page, or the first resource. Its own pages sit under `/-/`, which no page or resource name takes: `/-/account` (the user's passkeys and two-factor authentication) and `/-/sign-in-policy` (admins: the policy, and the log of staff sign-ins). Before the shell, it signs in on its sign-in route, `/-/sign-in`, with the methods the server offers and asks for what the [sign-in policy](auth.md#sign-in-policy) requires. Someone signed out goes there from any page, with that page in `?next=`, and signing in comes back to it; each step (a forgotten password, an emailed code, making an account) adds `?step=`, so the browser's Back returns to the step before; `?staff-sign-in` opens the [staff sign-in](auth.md#staff-sign-in) page instead, and a staff session gets a banner above the shell. `createAuthSession` from `@protobase/client` is that session (`signIn`, `signInWithCode`, `signInWithPasskey`, `verifyTwoFactor`, `account`, `signInPolicy`, `staff`). `ui` takes the project's [custom components and action handlers](custom-components.md). The list state lives in the URL: `?list=`, a [named list](ui-config.md#more-than-one-list), `?filter=` (AIP-160), `?order_by=`, `?display=`, the [display](ui-config.md#list-displays) it shows, `?layout=panel`, the filters in a panel beside the table on a desktop instead of a bar above it, `?map=52.37,4.89,12`, where a [map](ui-config.md#maps) looks, `?calendar=month,2026-10-01`, the month or week a [calendar](ui-config.md#calendars) shows, `?timeline=quarter,2026-10-01`, the week, month or quarter a [timeline](ui-config.md#timelines) shows, and `?saved_search=`, the [saved search](ui-config.md#saved-searches) the list was opened from. Views come from `examples/*/config/*/ui.ts`. The sidebar's recent-record groups and the user menu are configured there too: see [Sidebar](sidebar.md), [User menu](user-menu.md) and [Bottom bar](bottom-bar.md).
26
+ `<App baseUrl="/api/v1" />` renders the shell from `/api/meta` (beside the API, so `createClient` derives it from `baseUrl`) and routes `/:page` ([composed pages](layouts.md)), `/:resource` (list) and `/:resource/:key` (record); it opens on the first page, or the first resource. Its own pages sit under `/-/`, which no page or resource name takes: `/-/account` (the user's passkeys and two-factor authentication) and `/-/sign-in-policy` (admins: the policy, and the log of staff sign-ins). Before the shell, it signs in on its sign-in route, `/-/sign-in`, with the methods the server offers and asks for what the [sign-in policy](auth.md#sign-in-policy) requires. Someone signed out goes there from any page, with that page in `?next=`, and signing in comes back to it; each step (a forgotten password, an emailed code, making an account) adds `?step=`, so the browser's Back returns to the step before; `?staff-sign-in` opens the [staff sign-in](auth.md#staff-sign-in) page instead, and a staff session gets a banner below the top bar. `createAuthSession` from `@protobase/client` is that session (`signIn`, `signInWithCode`, `signInWithPasskey`, `verifyTwoFactor`, `account`, `signInPolicy`, `staff`). `ui` takes the project's [custom components and action handlers](custom-components.md). The list state lives in the URL: `?list=`, a [named list](ui-config.md#more-than-one-list), `?filter=` (AIP-160), `?order_by=`, `?display=`, the [display](ui-config.md#list-displays) it shows, `?layout=panel`, the filters in a panel beside the table on a desktop instead of a bar above it, `?map=52.37,4.89,12`, where a [map](ui-config.md#maps) looks, `?calendar=month,2026-10-01`, the month or week a [calendar](ui-config.md#calendars) shows, `?timeline=quarter,2026-10-01`, the week, month or quarter a [timeline](ui-config.md#timelines) shows, and `?saved_search=`, the [saved search](ui-config.md#saved-searches) the list was opened from. Views come from `examples/*/config/*/ui.ts`. The sidebar's recent-record groups and the user menu are configured there too: see [Sidebar](sidebar.md), [User menu](user-menu.md) and [Bottom bar](bottom-bar.md).
27
27
 
28
28
  ## Global search
29
29
 
@@ -307,7 +307,7 @@ Nothing a plugin does stops the app. Each of these turns off that plugin alone:
307
307
  - its module cannot be loaded, or does not link: it imports something the app's `@protobase/ui` does not have;
308
308
  - it defines a name an earlier plugin defines.
309
309
 
310
- Every place it would fill then draws its fallback (see [Extension points](#extension-points)). The app's admins (the `admin` role) see a notice above the app naming each plugin that is off and why, such as "The plugin sales-tools is off: it needs Protobase >=0.12.3, and this app runs 0.12.1." Everyone else sees only the fallbacks. An action handler that throws shows its error in a toast, as a project's does, and a part that throws while drawing shows its fallback in its own place.
310
+ Every place it would fill then draws its fallback (see [Extension points](#extension-points)). The app's admins (the `admin` role) see a notice below the top bar naming each plugin that is off and why, such as "The plugin sales-tools is off: it needs Protobase >=0.12.3, and this app runs 0.12.1." Everyone else sees only the fallbacks. An action handler that throws shows its error in a toast, as a project's does, and a part that throws while drawing shows its fallback in its own place.
311
311
 
312
312
  ## API
313
313
 
@@ -599,7 +599,7 @@ export const repairsView = filtered
599
599
  | `l.section(title, fields, { help?, helpWhen?, presentation?, when? })` | A titled group of fields in the main column, editable where the user may write. `presentation: 'facts'` shows them on the read view as a row of [key facts](#key-facts). |
600
600
  | `l.group(title, items, { collapsed?, when? })` | A heading over sections and related tables, closed until opened with `collapsed: true`. `when` also takes a [condition](#form-and-read-view). See [Groups](#groups). |
601
601
  | `l.tab(title, items)` | A tab holding main-column items; a view's tabs show as one strip on the read view and the form. See [Tabs](#tabs). |
602
- | `l.sidebar(fields, { when? })` | A summary card beside it, read-only, each value on one line, cut off with an ellipsis when it does not fit and shown whole on hover. `when` also takes a [condition](#form-and-read-view). |
602
+ | `l.sidebar(fields, { when? })` | A summary card beside it, read-only, each value on one line, cut off with an ellipsis when it does not fit and shown whole on hover. The record's created and updated times show in a Details card below it, but for those the summary lists. `when` also takes a [condition](#form-and-read-view). |
603
603
  | `l.related(title, { ... })` | A table or cards of the records of another resource that point at this one, in the main column. See [Related records](#related-records). |
604
604
  | `l.custom(Component, { title?, props?, sidebar?, when? })` | A [custom component](custom-components.md#record-sections) where it is listed: in the main column under `title`, or with `sidebar: true` as a sidebar card. |
605
605
  | `l.map(title, { latitude, longitude, zoom?, sidebar?, when? })` | A map with a pin at the record's position, in the main column or with `sidebar: true` as a sidebar card. See [Maps](#maps). |