@protobase/cli 0.23.1 → 0.23.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/package.js
CHANGED
package/dist/skill/install.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { access, cp, readFile, rm } from "node:fs/promises";
|
|
1
|
+
import { basename, join } from "node:path";
|
|
2
|
+
import { access, cp, readFile, readdir, rm } from "node:fs/promises";
|
|
3
3
|
//#region src/skill/install.ts
|
|
4
|
-
const
|
|
4
|
+
const skillFolders = [".agents/skills", ".claude/skills"];
|
|
5
5
|
const exists = (path) => access(path).then(() => true, () => false);
|
|
6
|
-
const
|
|
6
|
+
const isSkill = async (target, name) => {
|
|
7
7
|
const text = await readFile(join(target, "SKILL.md"), "utf8").catch((error) => {
|
|
8
8
|
if (error.code === "ENOENT") return "";
|
|
9
9
|
throw error;
|
|
10
10
|
});
|
|
11
|
-
return
|
|
11
|
+
return new RegExp(`^---\\n(?:[^\\n]*\\n)*?name: ${name}\\n`).test(text);
|
|
12
12
|
};
|
|
13
|
+
/** The skills in `skillsDir`, one folder each, by name. */
|
|
14
|
+
const bundledSkills = async (skillsDir) => (await readdir(skillsDir, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
13
15
|
async function installSkill(source, projectDir) {
|
|
14
|
-
const
|
|
16
|
+
const name = basename(source);
|
|
17
|
+
const targets = skillFolders.map((folder) => join(projectDir, folder, name));
|
|
15
18
|
for (const target of targets) {
|
|
16
19
|
if (!await exists(target)) continue;
|
|
17
|
-
if (!await
|
|
20
|
+
if (!await isSkill(target, name)) throw new Error(`${target} holds a skill other than ${name}; move it away to install the ${name} skill`);
|
|
18
21
|
}
|
|
19
22
|
for (const target of targets) {
|
|
20
23
|
await rm(target, {
|
|
@@ -26,4 +29,4 @@ async function installSkill(source, projectDir) {
|
|
|
26
29
|
return targets;
|
|
27
30
|
}
|
|
28
31
|
//#endregion
|
|
29
|
-
export { installSkill };
|
|
32
|
+
export { bundledSkills, installSkill };
|
package/dist/skill/register.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { protobaseVersion } from "../version/version.js";
|
|
2
|
-
import { installSkill } from "./install.js";
|
|
2
|
+
import { bundledSkills, installSkill } from "./install.js";
|
|
3
|
+
import { join } from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
//#region src/skill/register.ts
|
|
5
|
-
const
|
|
6
|
+
const skillsDir = fileURLToPath(new URL("../../skills", import.meta.url));
|
|
6
7
|
function registerSkill(program) {
|
|
7
|
-
program.command("skill").description("the protobase agent
|
|
8
|
+
program.command("skill").description("the protobase agent skills").command("install [name]").description("copy the agent skills of this CLI's version, or only the one named, into the project's .agents/skills and .claude/skills").action(async (name) => {
|
|
9
|
+
const skills = await bundledSkills(skillsDir);
|
|
10
|
+
if (name && !skills.includes(name)) throw new Error(`no skill named ${name}; this CLI ships ${skills.join(", ")}`);
|
|
8
11
|
const projectDir = process.cwd();
|
|
9
|
-
const
|
|
10
|
-
|
|
12
|
+
for (const skillName of name ? [name] : skills) {
|
|
13
|
+
const folders = (await installSkill(join(skillsDir, skillName), projectDir)).map((target) => target.slice(projectDir.length + 1));
|
|
14
|
+
process.stdout.write(`${skillName} skill ${protobaseVersion} → ${folders.join(", ")}\n`);
|
|
15
|
+
}
|
|
11
16
|
});
|
|
12
17
|
}
|
|
13
18
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.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": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hono/node-server": "^2.1.3",
|
|
37
37
|
"@hono/vite-dev-server": "^0.26.1",
|
|
38
|
-
"@protobase/layout": "0.23.
|
|
39
|
-
"@protobase/query": "0.23.
|
|
40
|
-
"@protobase/schema": "0.23.
|
|
41
|
-
"@protobase/server": "0.23.
|
|
42
|
-
"@protobase/ui": "0.23.
|
|
38
|
+
"@protobase/layout": "0.23.2",
|
|
39
|
+
"@protobase/query": "0.23.2",
|
|
40
|
+
"@protobase/schema": "0.23.2",
|
|
41
|
+
"@protobase/server": "0.23.2",
|
|
42
|
+
"@protobase/ui": "0.23.2",
|
|
43
43
|
"@react-email/render": "^2.1.0",
|
|
44
44
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
45
45
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -25,6 +25,8 @@ Run the CLI as the project does: `npx protobase <command>`, or `bun run protobas
|
|
|
25
25
|
|
|
26
26
|
`protobase build` writes the bundle (`dist/`); the host runs the serve runtime around it, after the project's migrations and with no other writes while they run. Check a bundle locally with `protobase serve dist`. Details: [references/guides/deploy.md](references/guides/deploy.md).
|
|
27
27
|
|
|
28
|
+
An app hosted on protobase-cloud deploys from a push to its GitHub branch instead: the `protobase-cloud` skill, which `protobase skill install` writes next to this one, covers it.
|
|
29
|
+
|
|
28
30
|
## Rules of thumb
|
|
29
31
|
|
|
30
32
|
- Records live at the framework's standard addresses and API; give a resource another look through its views, layouts or a plugin, not a page with routes of its own.
|
|
@@ -474,10 +474,10 @@ curl -H "Authorization: Bearer $(protobase token me@x)" http://localhost:5173/ap
|
|
|
474
474
|
## `skill`
|
|
475
475
|
|
|
476
476
|
```sh
|
|
477
|
-
protobase skill install
|
|
477
|
+
protobase skill install [name]
|
|
478
478
|
```
|
|
479
479
|
|
|
480
|
-
Copies the
|
|
480
|
+
Copies the agent skills of this CLI's version into the current project, or only the one `name` names. `protobase`, the protobase agent skill, goes to `.agents/skills/protobase/` (read by Codex, Cursor, OpenCode and Amp) and `.claude/skills/protobase/` (read by Claude Code): a short `SKILL.md` with the everyday workflow and the checks before calling a change done, and the guides and reference of this version as files it points to. `protobase-cloud` goes to `.agents/skills/protobase-cloud/` and `.claude/skills/protobase-cloud/`: how an app hosted on protobase-cloud deploys from GitHub, how to check that a change went live, and why a deploy failed. Each replaces an earlier copy, and refuses to touch a folder of its name that holds another skill. Commit the folders, and run the command again after upgrading the `@protobase` packages. The skills also ship in `node_modules/@protobase/cli/skills`, where the `skills` CLI's `experimental_sync` finds it.
|
|
481
481
|
|
|
482
482
|
## ERP example
|
|
483
483
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: protobase-cloud
|
|
3
|
+
description: Deploy a Protobase app hosted on protobase-cloud from its GitHub repository, check that a change went live, and find why a push did not deploy or a deploy failed. Use it when working on an app hosted on protobase-cloud; a self-hosted app does not need it.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Protobase cloud
|
|
7
|
+
|
|
8
|
+
An app hosted on protobase-cloud whose code is on GitHub follows one branch of its repository, the repository's default branch unless the app was linked to another. A push to that branch is what deploys it: nothing else does, and a change on any other branch, a tag or a pull request deploys nothing.
|
|
9
|
+
|
|
10
|
+
protobase-cloud pushes to that branch too: a runtime update commits a new `bun.lock` within the `@protobase` ranges of `package.json`, as `Protobase <jobs@protobase.invalid>`, and deploys like any push. Pull before pushing. An update that cannot land on the branch goes to a `protobase/update-<version>` branch instead, to merge by hand.
|
|
11
|
+
|
|
12
|
+
## How a push goes live
|
|
13
|
+
|
|
14
|
+
1. GitHub sends the push to protobase-cloud through the Protobase GitHub App's webhook.
|
|
15
|
+
2. protobase-cloud fetches the branch and starts one build of its newest commit. While a build runs, later pushes wait for it; the next build takes the newest commit then, so quick pushes give one build, and the commits in between get no build of their own.
|
|
16
|
+
3. The build installs the packages (`bun install --frozen-lockfile`) and runs `protobase build`. It runs neither the typecheck nor the tests.
|
|
17
|
+
4. The deploy stops the app's writes (pages keep reading; writes, sign-in included, answer that the app is read-only while it is being updated), then runs `db:migrate`, the auth schema's migration and `protobase doctor --env DATABASE_URL` in one database transaction that commits only when all of them pass.
|
|
18
|
+
5. Writes come back, the new version is started on its own and must answer `/health` with its startup checks, and only then does the app switch to it.
|
|
19
|
+
|
|
20
|
+
When any step fails, the previous version keeps serving, on a database that is as it was, except that a failed start comes after the migrations committed: they stay applied.
|
|
21
|
+
|
|
22
|
+
## Is my change live?
|
|
23
|
+
|
|
24
|
+
Each build reports on GitHub as the check run `Protobase deploy` on the commit it built: in progress while it runs, then success ("Deployed") or failure with the step that failed and the end of its output.
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
gh api repos/<owner>/<repo>/commits/<sha>/check-runs --jq '.check_runs[] | select(.name == "Protobase deploy") | {status, conclusion, title: .output.title, text: .output.text}'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
A change is live once the newest `Protobase deploy` on the followed branch succeeded on its commit or on a later commit that contains it (`git merge-base --is-ancestor <sha> <deployed sha>`). A deploy takes minutes; look again rather than in a tight loop.
|
|
31
|
+
|
|
32
|
+
## Why it is not live
|
|
33
|
+
|
|
34
|
+
Work down the list; the first that matches is the cause.
|
|
35
|
+
|
|
36
|
+
1. **Wrong branch.** The commit is not on the branch the app follows (`git branch -r --contains <sha>`).
|
|
37
|
+
2. **Still deploying.** The check run is in progress, or another build was running when you pushed: your commit gets built after it, or a later commit that contains it does.
|
|
38
|
+
3. **The build failed.** The check run's conclusion is failure. Its title names the step:
|
|
39
|
+
|
|
40
|
+
| Title | Cause and fix |
|
|
41
|
+
|---|---|
|
|
42
|
+
| The app's packages could not be installed | `bun.lock` does not match `package.json`, or a package cannot be fetched. Run `bun install --frozen-lockfile` locally and commit the lockfile |
|
|
43
|
+
| The app did not build | `protobase build` fails: run it locally |
|
|
44
|
+
| The app's migrations failed | A migration failed and everything rolled back. They run in one transaction: `CREATE INDEX CONCURRENTLY` and other statements Postgres refuses in a transaction fail, use the plain form; any failed statement fails them all |
|
|
45
|
+
| The app's config does not pass protobase doctor | Run `protobase doctor --env DATABASE_URL` on a database with the migrations applied. Usually a `.filterable()` or `.sortable()` field without an index: add the index it prints as a migration |
|
|
46
|
+
| The app's first-time setup failed | `db:seed:base` or creating the first admin failed on the first deploy |
|
|
47
|
+
| The new version was not deployed | Its text says why; `start_failed` means the new version did not start or answer `/health`, followed by the end of its output, such as a startup check that failed |
|
|
48
|
+
| The deploy ran out of time | The build or the migrations took too long |
|
|
49
|
+
| The data plane stopped during the deploy, The platform failed during the deploy | The platform's side: push again later, or report it |
|
|
50
|
+
|
|
51
|
+
A commit whose build failed is not built again: the fix is a new push, which builds the newest commit.
|
|
52
|
+
4. **No check run at all**, nothing in progress, and the push is a few minutes old:
|
|
53
|
+
- The app's page in the Protobase console shows the repository link. A broken link (the GitHub App was uninstalled or suspended, or the repository was removed from it, archived or deleted) means pushes no longer reach the app: relink it there.
|
|
54
|
+
- The webhook did not arrive. protobase-cloud syncs every linked app nightly, which deploys it then; a Protobase admin can redeliver the push from the GitHub App's recent deliveries sooner.
|
|
55
|
+
5. **It went live and was replaced.** A rollback from the console serves an earlier version until the next deploy.
|
|
56
|
+
|
|
57
|
+
## Before calling a change done
|
|
58
|
+
|
|
59
|
+
The deploy does not run the project's typecheck or tests, and refuses what doctor refuses, so run them before pushing:
|
|
60
|
+
|
|
61
|
+
1. The project's typecheck and tests.
|
|
62
|
+
2. `protobase doctor --env DATABASE_URL` against a database with the project's migrations applied; exit code 1 means the deploy will be refused.
|
|
63
|
+
3. `protobase build`.
|
|
64
|
+
4. Migrations that work inside one transaction (no `CONCURRENTLY`), since the deploy runs them all in one.
|
|
65
|
+
|
|
66
|
+
After pushing, the change is done when `Protobase deploy` succeeded on its commit or a later one that contains it. A failure leaves the previous version live: fix it with a new push.
|