@protobase/cli 0.96.8 → 0.96.10
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/dev/dev-module-url.js +9 -0
- package/dist/dev/project.js +3 -6
- package/dist/serve/env.js +4 -0
- package/dist/serve/lifecycle.js +3 -3
- package/package.json +8 -8
- package/skills/protobase/references/features/build-and-run.md +1 -1
- package/skills/protobase/references/features/start-a-project.md +1 -1
- package/skills/protobase/references/getting-started.md +1 -1
- package/skills/protobase/references/reference/cli.md +1 -0
package/dist/cli/package.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
//#region src/dev/dev-module-url.ts
|
|
3
|
+
const devModuleUrl = (file) => {
|
|
4
|
+
const posix = file.replaceAll("\\", "/");
|
|
5
|
+
if (posix.split("/").includes("node_modules")) return pathToFileURL(file).href;
|
|
6
|
+
return posix.startsWith("/") ? `/@fs${posix}` : `/@fs/${posix}`;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { devModuleUrl };
|
package/dist/dev/project.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { serverPackage } from "./server-package.js";
|
|
2
2
|
import { loadSourceConfig } from "../config/source-config.js";
|
|
3
3
|
import { sharedDb } from "./create-db.js";
|
|
4
|
-
import {
|
|
4
|
+
import { devModuleUrl } from "./dev-module-url.js";
|
|
5
5
|
//#region src/dev/project.ts
|
|
6
|
-
const load = (file) =>
|
|
6
|
+
const load = (file) => import(
|
|
7
7
|
/* @vite-ignore */
|
|
8
|
-
|
|
9
|
-
) : import(
|
|
10
|
-
/* @vite-ignore */
|
|
11
|
-
`/@fs${file}`
|
|
8
|
+
devModuleUrl(file)
|
|
12
9
|
);
|
|
13
10
|
const importModules = async (files) => {
|
|
14
11
|
const modules = [];
|
package/dist/serve/env.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readTrustedProxies } from "./client-address.js";
|
|
2
2
|
import { readDbConnections } from "@protobase/server";
|
|
3
|
+
import { isIP } from "node:net";
|
|
3
4
|
import { readSigningKey } from "@protobase/server/mobile-release";
|
|
4
5
|
//#region src/serve/env.ts
|
|
5
6
|
const defaultPort = 8787;
|
|
@@ -12,12 +13,15 @@ const readBoolean = (env, name, fallback) => {
|
|
|
12
13
|
const readServeEnv = (env) => {
|
|
13
14
|
const port = env.PORT ? Number(env.PORT) : defaultPort;
|
|
14
15
|
if (!Number.isInteger(port) || port < 0 || port > 65535) throw new Error(`PORT must be a port number, not "${env.PORT}"`);
|
|
16
|
+
const host = env.PROTOBASE_HOST || void 0;
|
|
17
|
+
if (host && isIP(host) === 0) throw new Error(`PROTOBASE_HOST must be an IP address, such as 127.0.0.1, not "${host}"`);
|
|
15
18
|
const minutes = env.PROTOBASE_FILES_CLEANUP_MINUTES ? Number(env.PROTOBASE_FILES_CLEANUP_MINUTES) : 60;
|
|
16
19
|
if (!Number.isInteger(minutes) || minutes < 0) throw new Error(`PROTOBASE_FILES_CLEANUP_MINUTES must be a whole number of minutes, not "${env.PROTOBASE_FILES_CLEANUP_MINUTES}"`);
|
|
17
20
|
const mobileSigningKey = readSigningKey(env);
|
|
18
21
|
const connections = env.PROTOBASE_DB_CONNECTIONS ? readDbConnections(env) : void 0;
|
|
19
22
|
return {
|
|
20
23
|
port,
|
|
24
|
+
...host && { host },
|
|
21
25
|
databaseUrl: env.DATABASE_URL || void 0,
|
|
22
26
|
...connections && { dbConnections: connections },
|
|
23
27
|
requestLog: readBoolean(env, "REQUEST_LOG", false),
|
package/dist/serve/lifecycle.js
CHANGED
|
@@ -12,9 +12,9 @@ import pg from "pg";
|
|
|
12
12
|
import { assistantSettings, authStoreTables, backgroundSettled, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkResourcesOutsideAuthStore, checkStatusSchema, checkUserTablesSchema, checkWebhooksSchema, checkWorkflowsSchema, configExports, createFileCleanup, relayed, sqlSends, startJobs } from "@protobase/server";
|
|
13
13
|
import { createAdaptorServer, upgradeWebSocket } from "@hono/node-server";
|
|
14
14
|
//#region src/serve/lifecycle.ts
|
|
15
|
-
const listen = (server, port) => new Promise((resolve, reject) => {
|
|
15
|
+
const listen = (server, port, host) => new Promise((resolve, reject) => {
|
|
16
16
|
server.once("error", reject);
|
|
17
|
-
server.listen(port, () => {
|
|
17
|
+
server.listen(port, host, () => {
|
|
18
18
|
server.off("error", reject);
|
|
19
19
|
resolve();
|
|
20
20
|
});
|
|
@@ -87,7 +87,7 @@ const startServe = async ({ config, env, openDb = (url) => openAppDatabase(pg, u
|
|
|
87
87
|
overrideGlobalObjects: false,
|
|
88
88
|
websocket: { server: sockets }
|
|
89
89
|
});
|
|
90
|
-
await listen(server, env.port).catch(async (error) => {
|
|
90
|
+
await listen(server, env.port, env.host).catch(async (error) => {
|
|
91
91
|
await jobs?.stop();
|
|
92
92
|
throw error;
|
|
93
93
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.96.
|
|
3
|
+
"version": "0.96.10",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@better-auth/core": "^1.7.12",
|
|
45
45
|
"@hono/node-server": "^2.1.3",
|
|
46
|
-
"@protobase/config": "0.96.
|
|
47
|
-
"@protobase/layout": "0.96.
|
|
48
|
-
"@protobase/query": "0.96.
|
|
49
|
-
"@protobase/schema": "0.96.
|
|
50
|
-
"@protobase/server": "0.96.
|
|
51
|
-
"@protobase/ui": "0.96.
|
|
52
|
-
"@protobase/workflows": "0.96.
|
|
46
|
+
"@protobase/config": "0.96.10",
|
|
47
|
+
"@protobase/layout": "0.96.10",
|
|
48
|
+
"@protobase/query": "0.96.10",
|
|
49
|
+
"@protobase/schema": "0.96.10",
|
|
50
|
+
"@protobase/server": "0.96.10",
|
|
51
|
+
"@protobase/ui": "0.96.10",
|
|
52
|
+
"@protobase/workflows": "0.96.10",
|
|
53
53
|
"@react-email/render": "^2.1.0",
|
|
54
54
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
55
55
|
"@sentry/vite-plugin": "^11.10.0",
|
|
@@ -18,7 +18,7 @@ Develop, build and run an app, on servers, in containers and on phones.
|
|
|
18
18
|
- [Source maps](../reference/cli.md#source-maps): The bundle and plugins can carry source maps with debug ids, for an error tracker to read browser stack frames.
|
|
19
19
|
- [Extensions](../reference/cli.md#extensions): A host adds its own widgets, dock assistant tools (`assistant/tools.ts`) and MCP tools (`mcp/tools.ts`) to every app it builds.
|
|
20
20
|
- [Native packages](../reference/cli.md#native-packages): npm packages with native add-ons are bundled for Linux.
|
|
21
|
-
- [Serve runtime](../reference/cli.md#serve): Runs a bundle, set by environment variables, with a health check, startup checks, jobs and a clean shutdown.
|
|
21
|
+
- [Serve runtime](../reference/cli.md#serve): Runs a bundle, set by environment variables, with a health check, startup checks, jobs and a clean shutdown. `PROTOBASE_HOST=127.0.0.1` keeps it to this computer.
|
|
22
22
|
- [Host module list](../reference/cli.md#the-config-module): Each release of `@protobase/cli` carries the modules its runtime supplies to a bundle as `@protobase/cli/host-modules.json`, for a host to check a bundle's imports against the version that serves it.
|
|
23
23
|
- [Migrations at update time](../guides/deploy.md#migrations): The bundle carries the project's migrations, and the runtime applies them in one transaction before the new version serves.
|
|
24
24
|
- [Single-file runtime](../reference/cli.md#build-serve): The runtime as one file, so a host needs only Bun and that file.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Start a new app, or an admin over an existing Postgres database, and keep the config in step with it.
|
|
6
6
|
|
|
7
|
-
- [Project starter](../getting-started.md#start-an-app): `npm create protobase` (also `bun create` and `pnpm create`) starts a new app from the scratch, ERP, property portal or real estate preset, with its own Postgres in Docker for development, and prints the next steps. Each preset has an `AGENTS.md` with rules for coding agents.
|
|
7
|
+
- [Project starter](../getting-started.md#start-an-app): `npm create protobase` (also `bun create` and `pnpm create`) starts a new app from the scratch, automations (workflows on), ERP, property portal or real estate preset, with its own Postgres in Docker for development, and prints the next steps. Each preset has an `AGENTS.md` with rules for coding agents.
|
|
8
8
|
- [Start on an existing database](../getting-started.md#on-an-existing-database): `npm create protobase <database-url>` makes a project on a Postgres database you already have and asks which of its tables become resources, only reading the database.
|
|
9
9
|
- [Example apps](../getting-started.md#run-the-erp-example): Seeded example apps on Postgres: an ERP, real estate property management and a public property portal.
|
|
10
10
|
- [One config](../reference/config.md): The whole app is one object of data in `protobase.config.ts`, typed with `defineConfig`, with a sensible default for every key.
|
|
@@ -10,7 +10,7 @@ An app's own React code, its components, field types and actions, is a [plugin](
|
|
|
10
10
|
|
|
11
11
|
## Start an app
|
|
12
12
|
|
|
13
|
-
`npm create protobase my-app` asks which preset to start from, scratch (the default), the ERP, the property portal or real estate, writes the project into `my-app`, with the `@protobase` packages in `devDependencies` at the caret range of the latest release, so it is [bundled](reference/versioning.md#bundled-and-locked-projects): dev, the build and its scripts run the CLI's own copies, and a newer CLI in that range updates it with no change to its files. It prints the next steps. Without a folder it asks for one too. `--preset <name>` picks the preset without asking; without a terminal it takes scratch. `bun create protobase` and `pnpm create protobase` do the same, and take `--preset` without the `--` that npm needs. It needs Node 22.12 or later. Each preset has an `AGENTS.md` with the rules for a coding agent that changes the app, such as a new migration file for every schema change.
|
|
13
|
+
`npm create protobase my-app` asks which preset to start from, scratch (the default), automations (scratch with [workflows](reference/workflows.md) on), the ERP, the property portal or real estate, writes the project into `my-app`, with the `@protobase` packages in `devDependencies` at the caret range of the latest release, so it is [bundled](reference/versioning.md#bundled-and-locked-projects): dev, the build and its scripts run the CLI's own copies, and a newer CLI in that range updates it with no change to its files. It prints the next steps. Without a folder it asks for one too. `--preset <name>` picks the preset without asking; without a terminal it takes scratch. `bun create protobase` and `pnpm create protobase` do the same, and take `--preset` without the `--` that npm needs. It needs Node 22.12 or later. Each preset has an `AGENTS.md` with the rules for a coding agent that changes the app, such as a new migration file for every schema change.
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
16
|
npm create protobase my-app
|
|
@@ -426,6 +426,7 @@ Serves the API of a bundle from `protobase build` and owns the process around it
|
|
|
426
426
|
| `DATABASE_URL` | the API's pool (Kysely over `pg`, 10 connections) |
|
|
427
427
|
| `PROTOBASE_DB_CONNECTIONS` | the connections that pool opens, such as the database's limit for the app; default 10. Sign-in's store shares them. [API functions](../guides/api-functions.md) and [jobs](jobs.md) hold at most one less, so a long import leaves a connection to page and API requests; those with [`longQueries`](../guides/api-functions.md#long-queries) take theirs from one more connection, kept for them. A query waits at most 2 seconds for a free connection, then fails with `503 connections-busy` ([Safety](api.md#safety)); a new connection may take up to 30 seconds to open, such as while a database that scaled to zero wakes |
|
|
428
428
|
| `PORT` | default 8787 |
|
|
429
|
+
| `PROTOBASE_HOST` | the IP address the server listens on, such as `127.0.0.1` so only this computer reaches it; default every interface |
|
|
429
430
|
| `REQUEST_LOG` | `true` logs every request; default `false` |
|
|
430
431
|
| `PROTOBASE_SMTP_URL` | the SMTP server for password-reset mail, emailed sign-in and two-factor codes and the app's own [email](email.md), credential included: `smtp://user:password@host:587` (STARTTLS required, `?requireTLS=false` sends in plaintext, see [Email](email.md#configuration)) or `smtps://...:465`; without it they are off ([Password reset](auth.md#password-reset), [Emailed sign-in codes](auth.md#emailed-sign-in-codes)) |
|
|
431
432
|
| `PROTOBASE_MAIL_FROM` | the sender of that mail, a plain address such as `noreply@admin.example.com`; set with `PROTOBASE_SMTP_URL` or not at all |
|