@sbuilder/cli 0.11.0 → 0.13.0
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/README.md +114 -4
- package/README.vi.md +116 -5
- package/dist/bin/sb.js +88 -6
- package/dist/bin/sb.js.map +1 -1
- package/dist/src/agentdocs.js +163 -2
- package/dist/src/agentdocs.js.map +1 -1
- package/dist/src/appblocks.js +5 -1
- package/dist/src/appblocks.js.map +1 -1
- package/dist/src/components.js +792 -0
- package/dist/src/components.js.map +1 -0
- package/dist/src/doctor.js +32 -3
- package/dist/src/doctor.js.map +1 -1
- package/dist/src/envtypes.gen.js +17 -0
- package/dist/src/envtypes.gen.js.map +1 -1
- package/dist/src/host.js +31 -0
- package/dist/src/host.js.map +1 -1
- package/dist/src/login.js +1 -1
- package/dist/src/route.js +2 -0
- package/dist/src/route.js.map +1 -1
- package/dist/src/site.js +70 -10
- package/dist/src/site.js.map +1 -1
- package/dist/src/siteinit.js +168 -17
- package/dist/src/siteinit.js.map +1 -1
- package/dist/src/sitekinds.js +26 -7
- package/dist/src/sitekinds.js.map +1 -1
- package/dist/src/source/derived.js +96 -0
- package/dist/src/source/derived.js.map +1 -0
- package/dist/src/source/meta.js +3 -3
- package/dist/src/source/meta.js.map +1 -1
- package/dist/src/source/parse.js +3 -1
- package/dist/src/source/parse.js.map +1 -1
- package/dist/src/source/print.js +8 -1
- package/dist/src/source/print.js.map +1 -1
- package/dist/src/starter.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,8 +16,9 @@ Account
|
|
|
16
16
|
that renews itself
|
|
17
17
|
sb logout sign this machine out and forget that credential
|
|
18
18
|
sb whoami which account (and platform) the CLI acts as
|
|
19
|
-
sb doctor [--json]
|
|
20
|
-
problem names its fix; exit 1 on any failure
|
|
19
|
+
sb doctor [--json] [--build] check this machine, repo and Next.js app; every
|
|
20
|
+
problem names its fix; exit 1 on any failure (--build
|
|
21
|
+
also bundles components/, running the repo's esbuild)
|
|
21
22
|
|
|
22
23
|
Sites
|
|
23
24
|
sb site new "<description>" [--dir <path>] [--github] [--editor]
|
|
@@ -44,7 +45,16 @@ Sites
|
|
|
44
45
|
sb site code push [--site <id>] [--dir <path>] [--force] [--dry-run] [--delete]
|
|
45
46
|
send local edits back; refuses a file changed
|
|
46
47
|
in the Code Dock since your pull unless --force
|
|
47
|
-
sb site
|
|
48
|
+
sb site components init | list [--json] | upgrade <Name> [--to <n>] [--dry-run]
|
|
49
|
+
code components: set the repo up (components/Hero.tsx);
|
|
50
|
+
list them on the platform; move a component's pins
|
|
51
|
+
sb site components preview <Name> [--props <json|@file>] [--json]
|
|
52
|
+
build one here and render it once on the platform
|
|
53
|
+
sb site components delete <Name> <version> [--yes] [--dry-run]
|
|
54
|
+
delete one version (refused while a page uses it;
|
|
55
|
+
a number is never reused)
|
|
56
|
+
sb site agents [--refresh] write the AI-agent files into this repo (never overwrites;
|
|
57
|
+
--refresh updates the ones the CLI wrote, unedited)
|
|
48
58
|
sb site types [--dir <path>] [--quiet]
|
|
49
59
|
write design/sbuilder-env.d.ts: types for the .page.tsx files
|
|
50
60
|
sb site mcp the Store Builder MCP server, with this repo's key
|
|
@@ -709,6 +719,7 @@ sb site next # serve the pages from a Next.js app (npm run
|
|
|
709
719
|
sb site next --link # mint the host secret into .env: a deployed host signs its requests
|
|
710
720
|
sb site deploy --vercel # one command to production on Vercel, with your own vercel CLI (--dry-run: the plan; --rotate replaces a link made elsewhere)
|
|
711
721
|
sb site agents # the AI-agent files, for a repo made by an older CLI
|
|
722
|
+
sb site agents --refresh # bring them to this CLI's text; an edited one gets <file>.new
|
|
712
723
|
sb site types # design/sbuilder-env.d.ts: completion + checks for .page.tsx
|
|
713
724
|
sb site types --quiet # the same, silent: what a Next app's predev / prebuild run
|
|
714
725
|
sb site mcp # the Store Builder MCP server, with this repo's key
|
|
@@ -762,12 +773,22 @@ takes `--site <id>`), and writes:
|
|
|
762
773
|
| `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, `.gemini/settings.json`, `.codex/config.toml` | The MCP server, started as `sb site mcp`, for Claude Code, Cursor, VS Code, Gemini CLI and Codex |
|
|
763
774
|
| `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` | How an AI agent works in this repo; the other two import `AGENTS.md` |
|
|
764
775
|
| `.claude/skills/sbuilder-page/SKILL.md` | The page syntax, the section-building loop with the tools, app-block rules and what pull / push / publish do — `AGENTS.md` points at it, so every agent reads the same text |
|
|
776
|
+
| `.claude/skills/sbuilder-components/SKILL.md` | Code components for an agent: when one is right (native elements first), the file and props rules, the sandbox it renders in, the `<CodeComponent …/>` line and the push / pin / upgrade / delete loop. `sb site components init` writes it too |
|
|
765
777
|
| `.github/workflows/sbuilder.yml` | The GitHub half of the sync |
|
|
766
778
|
| `design/sbuilder-env.d.ts`, `design/tsconfig.json` | Types for the page files (see *Page types* below) — commit them; `sb site types` regenerates the first |
|
|
767
779
|
|
|
768
780
|
None of the agent files above is overwritten. One that is already there is kept — silently when it
|
|
769
781
|
is what init would write, otherwise with a note saying what it lacks and the exact text to add.
|
|
770
782
|
`sb site agents` writes just these files into a repo made by an older version of the CLI, with the same rule.
|
|
783
|
+
`sb site agents --refresh` brings them — and `.github/workflows/sbuilder.yml`, which pins the CLI too —
|
|
784
|
+
to this CLI's text without clobbering an edit: `.sb-site.json` records the sha of each file as the CLI
|
|
785
|
+
wrote it, and a file still holding that sha is rewritten (re-checked at the moment of the write). One
|
|
786
|
+
edited since, or one the CLI never recorded (a repo made before 0.13, your own `AGENTS.md`), is kept and
|
|
787
|
+
today's text is written beside it as `<file>.new` (or `<file>.new.2`, … when a `.new` of your own is
|
|
788
|
+
there), named, for you to merge; the exit is then 1. **To keep your version as it is, delete the
|
|
789
|
+
`.new`**: the next refresh records your file as kept, says so, and stops asking — `sb doctor` too —
|
|
790
|
+
until the CLI's own text for that file changes. A deleted agent file is re-created; a deleted workflow
|
|
791
|
+
is not (CI may be off on purpose). `sb doctor` warns when an agent file is not this sb's.
|
|
771
792
|
A symbolic link in the way of any file init writes (`.env`, `.github`, …) is refused before the
|
|
772
793
|
key is minted (an agent file behind a link is skipped with a note instead), and an existing
|
|
773
794
|
`.env` is never replaced. A folder's own `.gitignore` is kept — init only adds `node_modules` and
|
|
@@ -1003,17 +1024,103 @@ quiet. It is `sb site push` per file: a parse error is printed as `file:line:col
|
|
|
1003
1024
|
nothing, a file that got a 409 (the editor changed it) is stopped and named, and it never
|
|
1004
1025
|
publishes or prunes, and it does not take `--force` (that would overwrite the editor on every save). A page whose repo has no record of the last sync (a manifest from an older CLI) names any fact the file states differently from the platform instead of sending it: `sb site pull` records them.
|
|
1005
1026
|
|
|
1027
|
+
### Code components — your own React in a page
|
|
1028
|
+
|
|
1029
|
+
```
|
|
1030
|
+
sb site components init # esbuild + preact into devDependencies, components/Hero.tsx
|
|
1031
|
+
sb site push # bundles each components/<Name>.tsx and uploads it, then the pages
|
|
1032
|
+
sb site components upgrade Hero # move every page's pin of Hero to its latest version
|
|
1033
|
+
sb site components upgrade Hero --to 3 --dry-run
|
|
1034
|
+
sb site components preview Hero --props '{"title":"Hi"}' # build it here, render it once on the platform
|
|
1035
|
+
sb site components list # each component: latest version, how many, sizes, created
|
|
1036
|
+
sb site components list --json # the same, as JSON
|
|
1037
|
+
sb site components delete Hero 2 # delete one version (asks first; --yes off a terminal)
|
|
1038
|
+
sb site components delete Hero 2 --dry-run # say what would be deleted, delete nothing
|
|
1039
|
+
```
|
|
1040
|
+
|
|
1041
|
+
A code component is a React (Preact) component in `components/<Name>.tsx` that exports its props
|
|
1042
|
+
as `export const schema = defineProps({ … })` (from `@sbuilder/sdk/component`) and a default
|
|
1043
|
+
function component. The editor lists it as the **Code component** element; the platform renders
|
|
1044
|
+
it to HTML on the server, inside a sandbox with no network, a frozen clock and a seeded
|
|
1045
|
+
`Math.random`, and the page keeps that HTML. The CLI also builds a client bundle for every
|
|
1046
|
+
component, so the published page hydrates it in the browser — every code component ships its JavaScript.
|
|
1047
|
+
|
|
1048
|
+
- **Props.** `text`, `richtext`, `link`, `image`, `enum` (with `options`), `boolean` and `number`
|
|
1049
|
+
are content: they change the markup and are the same on every breakpoint. **A length or a colour is a `css` prop**:
|
|
1050
|
+
the page sets it per breakpoint as the custom property `--<name>` and the component reads
|
|
1051
|
+
`var(--<name>, <default>)`. A `css` name is lowercase kebab-case (`gap-size`); camelCase is a type
|
|
1052
|
+
error in `defineProps` and refused by the platform. The schema must be a literal object —
|
|
1053
|
+
`sb site push` reads it from the source without running anything.
|
|
1054
|
+
- **Versions are immutable.** `sb site push` uploads a new version only when the bundle changed
|
|
1055
|
+
(the platform answers with the existing one otherwise) and prints the version it assigned. Every
|
|
1056
|
+
component is uploaded **before** any page, so a page's pin (`version={3}` on its
|
|
1057
|
+
`<CodeComponent …/>`) always names a version that exists. Nothing on any page moves by itself.
|
|
1058
|
+
- **Upgrading is a local edit.** `sb site components upgrade <Name> [--to <n>]` rewrites the pins
|
|
1059
|
+
in `design/` (pages, shared sections, overlays), names a prop the new version no longer takes,
|
|
1060
|
+
and sends nothing. Review the diff, then `sb site push` saves a draft.
|
|
1061
|
+
- **`html`, `clientUrl` and `hydrateProps` are the platform's.** The component's rendered markup, its
|
|
1062
|
+
browser bundle's address and the sanitised props it hydrates with are derived: on every save the platform keeps them while the pin and props are
|
|
1063
|
+
unchanged and re-renders otherwise, whatever a file says. So a page file never holds them — `sb
|
|
1064
|
+
site pull` does not write them, and a file that still has one (pulled by an older `sb`, or typed
|
|
1065
|
+
by hand) is read without it: `sb site push` and `sb doctor` name the file, the node and the key
|
|
1066
|
+
(`` `html` on code-component cc_1 is rendered by the platform; your edit is ignored. ``). A file
|
|
1067
|
+
you have not edited since an older `sb` pulled it is rewritten without them on the next `sb site
|
|
1068
|
+
pull`. The Next host (`sb site next`) previews each component with the markup the platform
|
|
1069
|
+
stored for it. One whose pin or props you changed locally, whose last render on the platform
|
|
1070
|
+
failed, or whose stored draft could not be read shows without it — said once on the console and
|
|
1071
|
+
named on every response in `x-sbuilder-unrendered` — until `sb site push` renders it.
|
|
1072
|
+
- **Previewing.** `sb site components preview <Name> [--props <json|@file>] [--json]` builds
|
|
1073
|
+
`components/<Name>.tsx` here, exactly as push does, and has the platform render it once in the same
|
|
1074
|
+
sandbox (`POST /api/v1/code-components/preview`): it prints the HTML a page save would store
|
|
1075
|
+
(`--json`: `{"html": …}`). Props the schema names but `--props` omits take their default; unknown
|
|
1076
|
+
and `css` props are dropped, as on a page save. Nothing is uploaded and no page changes. A refusal
|
|
1077
|
+
— `bundle_rejected` with the sandbox's own error, `invalid_props` naming the prop, `css_prop_name`,
|
|
1078
|
+
a size cap — prints its code and message and exits 1, which is what an agent reads to fix the
|
|
1079
|
+
component. A busy platform (429 / 503) prints its `Retry-After` and exits 1; nothing retries.
|
|
1080
|
+
`--dry-run` only builds. It needs an API key (`wbk_…`, `pages.write`).
|
|
1081
|
+
- **For an AI agent.** `sb site init` and `sb site components init` write
|
|
1082
|
+
`.claude/skills/sbuilder-components/SKILL.md` and `AGENTS.md` points at it: when a code component
|
|
1083
|
+
is right (native elements first), the props and sandbox rules above, the `<CodeComponent …/>` line
|
|
1084
|
+
and this loop. Its example component is built and its page snippet parsed by the CLI's own tests.
|
|
1085
|
+
- **Listing and deleting.** `sb site components list [--json]` shows every component on the
|
|
1086
|
+
platform with its latest version, how many versions it has, each version's SSR and client size
|
|
1087
|
+
and when it was made, and which versions the files in this repo pin (the platform's own drafts
|
|
1088
|
+
and live pages are not listed). `sb site components delete <Name> <version> [--yes]` deletes one
|
|
1089
|
+
version: it asks first, and off a terminal it needs `--yes`; `--dry-run` deletes nothing: it reads
|
|
1090
|
+
the version, so a missing one is named, and only the real delete can tell whether a page pins it. While any draft or live page, shared
|
|
1091
|
+
section or overlay still uses that version the platform refuses: the pages it names are printed
|
|
1092
|
+
and the exit is 1. **A deleted number is never reused** — the next upload gets a new one, so a
|
|
1093
|
+
pin can never come to mean different code. Deleting needs an API key (`wbk_…`, `pages.write`).
|
|
1094
|
+
- **Limits.** SSR bundle 512 KiB, client bundle 256 KiB (named locally before any upload), one
|
|
1095
|
+
second to render, a clock frozen at 2000-01-01 and a seeded `Math.random` (`fetch`, timers and
|
|
1096
|
+
`crypto` throw), no
|
|
1097
|
+
Server Components, no Suspense data, no `use`. A bundle that throws when the platform renders it
|
|
1098
|
+
once with its defaults is refused with its own error (`bundle_rejected`).
|
|
1099
|
+
- **The bundles are the CLI's.** Both bundle contracts (SSR assigns `globalThis.__sbComponent = { render }`; the client is an IIFE `__sbClient` exporting `hydrate(el, props)`, which the platform attaches to `Name@Version`) are generated by the CLI; the author never writes them, only the component.
|
|
1100
|
+
- **What runs where.** `sb site push` runs **your repo's esbuild** (from `node_modules`, put there
|
|
1101
|
+
by `npm install`) on your machine, as `npm run build` would. The CLI has no dependency of its own;
|
|
1102
|
+
`init` pins `esbuild`, `preact` and `preact-render-to-string` to exact versions, so the same
|
|
1103
|
+
source builds the same bytes. Uploading needs an API key (`wbk_…`, `pages.write`) in `SB_TOKEN` or
|
|
1104
|
+
`.env`; a browser sign-in cannot upload (pages are still pushed). A file in `components/` without
|
|
1105
|
+
`export const schema` is not a component and is skipped by name — `components/` is also the folder
|
|
1106
|
+
a Next.js app keeps its own components in.
|
|
1107
|
+
|
|
1006
1108
|
## `sb doctor` — check the setup
|
|
1007
1109
|
|
|
1008
1110
|
```
|
|
1009
1111
|
sb doctor # check this machine, this repo and its Next.js app
|
|
1010
1112
|
sb doctor --json # the same, as JSON for CI (exit 1 when a check fails)
|
|
1113
|
+
sb doctor --build # also bundle components/ (runs the repo's esbuild)
|
|
1011
1114
|
```
|
|
1012
1115
|
|
|
1013
1116
|
Read-only: it reads files and sends GET requests, nothing else. Every check that does not pass
|
|
1014
1117
|
names the exact command or Manage path that fixes it (`fix:`). `ok` and `skip` pass; a `warn`
|
|
1015
1118
|
works but something you probably want is off; only a `fail` makes the exit code `1`.
|
|
1016
1119
|
|
|
1120
|
+
`sb doctor` never runs code from the repo it checks. `sb doctor --build` is the exception, and says
|
|
1121
|
+
so: it also bundles `components/`, which loads and **runs the repo's own esbuild** from
|
|
1122
|
+
`node_modules`. Use it in a repo you trust, as you would `npm run build`.
|
|
1123
|
+
|
|
1017
1124
|
| Check | What it looks at | Fails when |
|
|
1018
1125
|
| --- | --- | --- |
|
|
1019
1126
|
| `node` | Node.js version | older than 20 |
|
|
@@ -1022,7 +1129,10 @@ works but something you probably want is off; only a `fail` makes the exit code
|
|
|
1022
1129
|
| `scope:write` | the write scopes — **not probed** (a GET cannot test a write); it says what each one gates | never |
|
|
1023
1130
|
| `site` | `sb.json` names a site this key or login reaches, and `.sb-site.json` is from the same one | no `siteId`, bad JSON, another site's manifest, a site you cannot read |
|
|
1024
1131
|
| `manifest` | `.sb-site.json`: every path inside its kind's folder under `design/`, no symbolic links | a path outside `design/`, a symbolic link (a missing file is a `warn`) |
|
|
1025
|
-
| `files` | every file under `design/` parses | any does not: it prints `file:line:col` |
|
|
1132
|
+
| `files` | every file under `design/` parses | any does not: it prints `file:line:col`. A warning names a file that still holds a code component's `html` or `clientUrl` (the platform's; ignored) |
|
|
1133
|
+
| `agents` | in a site repo, every agent file (`AGENTS.md`, the skills, the MCP configs, the CI workflow) is the text this CLI writes, or one you kept | one differs or is missing (warning): `sb site agents --refresh` |
|
|
1134
|
+
| `components:build` | `components/<Name>.tsx` files with a literal `schema`, and `esbuild` installed in the repo (its `package.json` is looked for — never loaded). Static: **no repo code runs** | a file's `schema` is not a literal, a symbolic link, esbuild missing. With `--build` also: a component that does not build or is over a size cap |
|
|
1135
|
+
| `components:pins` | every `<CodeComponent version={n}>` in `design/` names a version the platform has (GET) | one does not (`sb site components upgrade`, or `sb site push` to upload it) |
|
|
1026
1136
|
| `domain` | the store's primary domain against `SB_PUBLIC_URL`, and the built-in address's redirect | they differ; the built-in address redirects to your deployment (the loop — fix: Manage → Domains → Default address → *Serve this site directly*) |
|
|
1027
1137
|
| `host-secret` | the site's host link (asked with a GET), whether `SB_HOST_SECRET` / `SB_SITE_ID` are in this environment or `.env`, and — with `SB_STOREFRONT` — whether the store still accepts that secret (a signed and an unsigned GET of `robots.txt` are compared; a rotation elsewhere is a `fail`) | a secret is set but the site has no link (revoked) or no site id; a Next app with no link, or a link with no secret here, is a `warn` |
|
|
1028
1138
|
| `next:version` | the installed `next` is in `>=15.0.0 <17` | it is outside the range |
|
package/README.vi.md
CHANGED
|
@@ -16,8 +16,9 @@ Tài khoản
|
|
|
16
16
|
gia hạn
|
|
17
17
|
sb logout đăng xuất máy này và xoá credential đó
|
|
18
18
|
sb whoami CLI đang dùng tài khoản (và platform) nào
|
|
19
|
-
sb doctor [--json]
|
|
20
|
-
nêu cách sửa; exit 1 khi có kiểm tra hỏng
|
|
19
|
+
sb doctor [--json] [--build] kiểm tra máy, repo và app Next.js; mỗi vấn đề đều
|
|
20
|
+
nêu cách sửa; exit 1 khi có kiểm tra hỏng (--build
|
|
21
|
+
còn đóng gói components/, chạy esbuild của repo)
|
|
21
22
|
|
|
22
23
|
Site
|
|
23
24
|
sb site new "<mô tả>" [--dir <path>] [--github] [--editor]
|
|
@@ -45,7 +46,16 @@ Site
|
|
|
45
46
|
sb site code push [--site <id>] [--dir <path>] [--force] [--dry-run] [--delete]
|
|
46
47
|
gửi các chỗ sửa ở máy ngược lại; từ chối file đã
|
|
47
48
|
đổi trong Code Dock kể từ lần pull, trừ khi --force
|
|
48
|
-
sb site
|
|
49
|
+
sb site components init | list [--json] | upgrade <Name> [--to <n>] [--dry-run]
|
|
50
|
+
code component: chuẩn bị repo (components/Hero.tsx);
|
|
51
|
+
liệt kê trên nền tảng; chuyển pin sang phiên bản khác
|
|
52
|
+
sb site components preview <Name> [--props <json|@file>] [--json]
|
|
53
|
+
build ở máy và render thử một lần trên nền tảng
|
|
54
|
+
sb site components delete <Name> <version> [--yes] [--dry-run]
|
|
55
|
+
xoá một phiên bản (bị từ chối khi còn trang dùng;
|
|
56
|
+
số phiên bản không bao giờ dùng lại)
|
|
57
|
+
sb site agents [--refresh] ghi các file cho AI agent vào repo này (không bao giờ ghi đè;
|
|
58
|
+
--refresh cập nhật các file sb đã ghi mà chưa ai sửa)
|
|
49
59
|
sb site types [--dir <path>] [--quiet]
|
|
50
60
|
ghi design/sbuilder-env.d.ts: kiểu cho các file .page.tsx
|
|
51
61
|
sb site mcp MCP server của Store Builder, với key của repo này
|
|
@@ -711,6 +721,7 @@ sb site next # phục vụ các trang từ một app Next.j
|
|
|
711
721
|
sb site next --link # tạo host secret vào .env: host đã deploy ký các request của nó
|
|
712
722
|
sb site deploy --vercel # một lệnh lên production trên Vercel, bằng vercel CLI của bạn (--dry-run: chỉ in kế hoạch; --rotate thay link do nơi khác tạo)
|
|
713
723
|
sb site agents # các file cho AI agent, cho repo tạo bởi bản CLI cũ
|
|
724
|
+
sb site agents --refresh # đưa chúng về văn bản của bản CLI này; file đã sửa nhận <file>.new
|
|
714
725
|
sb site types # design/sbuilder-env.d.ts: gợi ý + kiểm tra cho .page.tsx
|
|
715
726
|
sb site types --quiet # như trên, im lặng: thứ predev / prebuild của app Next chạy
|
|
716
727
|
sb site mcp # MCP server của Store Builder, với key của repo này
|
|
@@ -759,12 +770,23 @@ bao giờ tự xuất bản**. Agent sửa bản nháp của site; bạn duyệt
|
|
|
759
770
|
| `.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, `.gemini/settings.json`, `.codex/config.toml` | MCP server, chạy qua `sb site mcp`, cho Claude Code, Cursor, VS Code, Gemini CLI và Codex |
|
|
760
771
|
| `AGENTS.md`, `CLAUDE.md`, `GEMINI.md` | Cách một AI agent làm việc trong repo; hai file kia nạp `AGENTS.md` |
|
|
761
772
|
| `.claude/skills/sbuilder-page/SKILL.md` | Cú pháp file trang, vòng dựng từng section bằng công cụ, luật app block và pull / push / publish làm gì — `AGENTS.md` chỉ tới nó nên agent nào cũng đọc cùng một văn bản |
|
|
773
|
+
| `.claude/skills/sbuilder-components/SKILL.md` | Code component cho agent: khi nào nên dùng (ưu tiên element có sẵn), luật về file và props, sandbox nơi nó được render, dòng `<CodeComponent …/>` và vòng push / pin / upgrade / delete. `sb site components init` cũng ghi file này |
|
|
762
774
|
| `.github/workflows/sbuilder.yml` | Nửa GitHub của việc đồng bộ |
|
|
763
775
|
| `design/sbuilder-env.d.ts`, `design/tsconfig.json` | Kiểu cho các file trang (xem *Kiểu cho file trang* bên dưới) — hãy commit; `sb site types` tạo lại file đầu |
|
|
764
776
|
|
|
765
777
|
Không file agent nào ở trên bị ghi đè. File đã có sẵn được giữ nguyên — im lặng nếu nó đúng là
|
|
766
778
|
thứ init sẽ ghi, còn không thì kèm ghi chú nó thiếu gì và đoạn chữ chính xác cần thêm.
|
|
767
|
-
`sb site agents` chỉ ghi các file này vào repo tạo bởi một bản CLI cũ, cùng quy tắc đó.
|
|
779
|
+
`sb site agents` chỉ ghi các file này vào repo tạo bởi một bản CLI cũ, cùng quy tắc đó.
|
|
780
|
+
`sb site agents --refresh` đưa chúng — và `.github/workflows/sbuilder.yml`, file cũng pin bản CLI —
|
|
781
|
+
về đúng văn bản của bản CLI này mà không đè lên chỗ bạn đã sửa: `.sb-site.json` ghi sha của từng file
|
|
782
|
+
lúc sb ghi nó, và file nào vẫn giữ đúng sha đó thì được ghi lại (kiểm tra lại ngay lúc ghi). File đã bị
|
|
783
|
+
sửa từ đó, hoặc file sb chưa từng ghi nhận (repo tạo trước 0.13, `AGENTS.md` của riêng bạn), được giữ
|
|
784
|
+
nguyên và văn bản hôm nay được ghi bên cạnh thành `<file>.new` (hoặc `<file>.new.2`, … khi đã có một
|
|
785
|
+
`.new` của riêng bạn), có nêu tên, để bạn tự gộp; khi đó mã thoát là 1. **Muốn giữ nguyên bản của bạn
|
|
786
|
+
thì xoá file `.new`**: lần refresh sau ghi nhận file của bạn là được giữ, báo ra, và thôi hỏi — cả
|
|
787
|
+
`sb doctor` cũng vậy — cho tới khi văn bản của CLI cho file đó đổi. File agent bị xoá sẽ được tạo lại;
|
|
788
|
+
workflow bị xoá thì không (có thể bạn cố ý tắt CI). `sb doctor` cảnh báo khi một file agent không phải
|
|
789
|
+
của bản sb này. Một liên kết
|
|
768
790
|
mềm chặn đường của bất kỳ file nào init ghi (`.env`, `.github`, …) bị từ chối trước khi key được
|
|
769
791
|
tạo (file agent nằm sau một liên kết thì được bỏ qua kèm ghi chú), và `.env` đã có không bao giờ
|
|
770
792
|
bị thay. `.gitignore` sẵn có của thư mục được giữ — init chỉ thêm `node_modules` và `.env` vào —
|
|
@@ -991,17 +1013,103 @@ yên lặng. Nó là `sb site push` cho từng file: lỗi cú pháp được in
|
|
|
991
1013
|
gửi gì, file bị 409 (editor đã đổi nó) bị dừng và nêu tên, và nó không bao giờ xuất bản hay
|
|
992
1014
|
`--prune`, và không nhận `--force` (nó sẽ ghi đè editor ở mỗi lần lưu). Trang mà repo không có bản ghi của lần đồng bộ gần nhất (manifest từ CLI cũ) sẽ nêu tên thông tin file ghi khác nền tảng thay vì gửi nó: `sb site pull` sẽ ghi lại chúng.
|
|
993
1015
|
|
|
1016
|
+
### Code component — React của riêng bạn trong trang
|
|
1017
|
+
|
|
1018
|
+
```
|
|
1019
|
+
sb site components init # esbuild + preact vào devDependencies, components/Hero.tsx
|
|
1020
|
+
sb site push # đóng gói và tải lên từng components/<Name>.tsx, rồi mới đến các trang
|
|
1021
|
+
sb site components upgrade Hero # chuyển pin của Hero ở mọi trang lên phiên bản mới nhất
|
|
1022
|
+
sb site components upgrade Hero --to 3 --dry-run
|
|
1023
|
+
sb site components preview Hero --props '{"title":"Hi"}' # build ở máy, render thử một lần trên nền tảng
|
|
1024
|
+
sb site components list # từng component: phiên bản mới nhất, số phiên bản, kích thước, ngày tạo
|
|
1025
|
+
sb site components list --json # như trên, dạng JSON
|
|
1026
|
+
sb site components delete Hero 2 # xoá một phiên bản (hỏi trước; ngoài terminal cần --yes)
|
|
1027
|
+
sb site components delete Hero 2 --dry-run # cho biết sẽ xoá gì, không xoá gì
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
Code component là một component React (Preact) trong `components/<Name>.tsx`, xuất props dưới dạng
|
|
1031
|
+
`export const schema = defineProps({ … })` (từ `@sbuilder/sdk/component`) cùng một function
|
|
1032
|
+
component mặc định. Editor liệt kê nó như phần tử **Code component**; nền tảng render nó ra HTML
|
|
1033
|
+
trên máy chủ, trong sandbox không có mạng, đồng hồ cố định và `Math.random` có seed, và trang giữ
|
|
1034
|
+
HTML đó. CLI luôn build thêm client bundle cho mọi component, nên trang đã xuất bản sẽ hydrate nó
|
|
1035
|
+
trong trình duyệt — component nào cũng kèm JavaScript của nó.
|
|
1036
|
+
|
|
1037
|
+
- **Props.** `text`, `richtext`, `link`, `image`, `enum` (kèm `options`), `boolean` và `number`
|
|
1038
|
+
là nội dung: chúng đổi markup và giống nhau ở mọi breakpoint. **Độ dài hay màu là prop `css`**:
|
|
1039
|
+
trang đặt nó theo từng breakpoint dưới dạng custom property `--<name>` và component đọc
|
|
1040
|
+
`var(--<name>, <default>)`. Tên `css` là chữ thường kebab-case (`gap-size`); camelCase là lỗi kiểu
|
|
1041
|
+
trong `defineProps` và bị nền tảng từ chối. Schema phải là object literal — `sb site push` đọc nó
|
|
1042
|
+
từ mã nguồn mà không chạy gì cả.
|
|
1043
|
+
- **Phiên bản bất biến.** `sb site push` chỉ tải lên phiên bản mới khi bundle đổi (nếu không, nền
|
|
1044
|
+
tảng trả về phiên bản đã có) và in ra phiên bản được gán. Mọi component được tải lên **trước**
|
|
1045
|
+
bất kỳ trang nào, nên pin của trang (`version={3}` trên `<CodeComponent …/>`) luôn trỏ tới một
|
|
1046
|
+
phiên bản có thật. Không có gì trên trang tự dịch chuyển.
|
|
1047
|
+
- **Nâng cấp là sửa cục bộ.** `sb site components upgrade <Name> [--to <n>]` ghi lại các pin trong
|
|
1048
|
+
`design/` (trang, section dùng chung, overlay), nêu tên prop mà phiên bản mới không còn nhận,
|
|
1049
|
+
và không gửi gì. Xem diff, rồi `sb site push` lưu bản nháp.
|
|
1050
|
+
- **`html`, `clientUrl` và `hydrateProps` thuộc về nền tảng.** Markup đã render của component, địa chỉ
|
|
1051
|
+
bundle chạy trên trình duyệt và bộ props đã làm sạch dùng để hydrate là dữ liệu suy ra: mỗi lần lưu, nền tảng giữ nguyên chúng nếu pin và props
|
|
1052
|
+
không đổi, còn không thì render lại, bất kể file ghi gì. Vì vậy file trang không bao giờ chứa
|
|
1053
|
+
chúng — `sb site pull` không ghi ra, và file nào vẫn còn (do `sb` bản cũ kéo về, hoặc tự gõ tay)
|
|
1054
|
+
sẽ được đọc như thể không có: `sb site push` và `sb doctor` nêu tên file, node và khoá
|
|
1055
|
+
(`` `html` on code-component cc_1 is rendered by the platform; your edit is ignored. ``). File
|
|
1056
|
+
bạn chưa sửa kể từ khi `sb` bản cũ kéo về sẽ được ghi lại không có chúng ở lần `sb site pull`
|
|
1057
|
+
kế tiếp. Host Next (`sb site next`) xem trước từng component bằng markup nền tảng đã lưu; component
|
|
1058
|
+
nào bạn đổi pin hoặc props ở máy, có lần render gần nhất trên nền tảng bị lỗi, hoặc không đọc được
|
|
1059
|
+
bản nháp đã lưu, sẽ hiện không có markup đó — báo một lần trên console và nêu tên ở mọi response
|
|
1060
|
+
trong `x-sbuilder-unrendered` — cho tới khi `sb site push` render nó.
|
|
1061
|
+
- **Xem trước.** `sb site components preview <Name> [--props <json|@file>] [--json]` build
|
|
1062
|
+
`components/<Name>.tsx` ở máy, đúng như push, rồi để nền tảng render nó một lần trong cùng sandbox
|
|
1063
|
+
(`POST /api/v1/code-components/preview`): lệnh in ra HTML mà một lần lưu trang sẽ lưu
|
|
1064
|
+
(`--json`: `{"html": …}`). Prop có trong schema mà `--props` bỏ trống thì lấy giá trị mặc định; prop
|
|
1065
|
+
lạ và prop `css` bị bỏ, như khi lưu trang. Không tải lên gì và không trang nào đổi. Bị từ chối —
|
|
1066
|
+
`bundle_rejected` kèm lỗi của chính sandbox, `invalid_props` nêu tên prop, `css_prop_name`, vượt giới
|
|
1067
|
+
hạn kích thước — thì in mã lỗi và thông báo rồi thoát 1, chính là thứ agent đọc để sửa component.
|
|
1068
|
+
Nền tảng đang bận (429 / 503) thì in `Retry-After` và thoát 1; không tự thử lại. `--dry-run` chỉ build.
|
|
1069
|
+
Cần API key (`wbk_…`, `pages.write`).
|
|
1070
|
+
- **Cho AI agent.** `sb site init` và `sb site components init` ghi
|
|
1071
|
+
`.claude/skills/sbuilder-components/SKILL.md` và `AGENTS.md` chỉ tới nó: khi nào nên dùng code
|
|
1072
|
+
component (ưu tiên element có sẵn), các luật về props và sandbox ở trên, dòng `<CodeComponent …/>`
|
|
1073
|
+
và vòng làm việc này. Component ví dụ trong đó được build, và đoạn trang được parse, bởi chính test của CLI.
|
|
1074
|
+
- **Liệt kê và xoá.** `sb site components list [--json]` cho thấy mọi component trên nền tảng kèm
|
|
1075
|
+
phiên bản mới nhất, số phiên bản, kích thước SSR và client của từng phiên bản, ngày tạo, và các
|
|
1076
|
+
phiên bản mà file trong repo này đang pin (bản nháp và trang đang chạy của nền tảng thì không
|
|
1077
|
+
liệt kê). `sb site components delete <Name> <version> [--yes]` xoá một phiên bản: lệnh hỏi
|
|
1078
|
+
trước, và ngoài terminal thì cần `--yes`; `--dry-run` không xoá gì: lệnh chỉ đọc phiên bản, nên phiên bản không tồn tại sẽ được nêu tên, còn việc có trang nào đang pin nó thì chỉ lệnh xoá thật mới biết.
|
|
1079
|
+
Khi còn bản nháp hay trang đang chạy, section dùng
|
|
1080
|
+
chung hoặc overlay nào dùng phiên bản đó, nền tảng từ chối: các trang nó nêu được in ra và mã
|
|
1081
|
+
thoát là 1. **Số phiên bản đã xoá không bao giờ được dùng lại** — lần tải lên sau nhận số mới,
|
|
1082
|
+
nên một pin không bao giờ đổi sang trỏ vào mã khác. Xoá cần API key (`wbk_…`, `pages.write`).
|
|
1083
|
+
- **Giới hạn.** SSR bundle 512 KiB, client bundle 256 KiB (báo tên ngay ở máy trước khi tải lên),
|
|
1084
|
+
một giây để render, đồng hồ đứng yên ở 2000-01-01 và `Math.random` có seed (`fetch`, timer và
|
|
1085
|
+
`crypto` ném lỗi),
|
|
1086
|
+
không có Server Components, Suspense data, `use`. Bundle ném lỗi khi nền tảng render thử với
|
|
1087
|
+
giá trị mặc định sẽ bị từ chối kèm lỗi của chính nó (`bundle_rejected`).
|
|
1088
|
+
- **Bundle do CLI tạo ra.** Hai hợp đồng bundle (SSR gán `globalThis.__sbComponent = { render }`; client là IIFE `__sbClient` có `hydrate(el, props)`, được máy chủ gắn vào `Name@Version`) đều do CLI sinh ra; tác giả không bao giờ tự viết chúng, chỉ viết component.
|
|
1089
|
+
- **Cái gì chạy ở đâu.** `sb site push` chạy **esbuild của repo bạn** (trong `node_modules`, do
|
|
1090
|
+
`npm install` đặt vào) trên máy bạn, như `npm run build`. CLI không có dependency riêng; `init`
|
|
1091
|
+
ghim `esbuild`, `preact` và `preact-render-to-string` ở phiên bản chính xác, nên cùng mã nguồn
|
|
1092
|
+
cho ra cùng byte. Tải lên cần khoá API (`wbk_…`, `pages.write`) trong `SB_TOKEN` hoặc `.env`;
|
|
1093
|
+
đăng nhập qua trình duyệt không tải lên được (các trang vẫn được đẩy). File trong `components/`
|
|
1094
|
+
không có `export const schema` không phải component và bị bỏ qua có nêu tên — `components/` cũng
|
|
1095
|
+
là thư mục app Next.js dùng cho component riêng của nó.
|
|
1096
|
+
|
|
994
1097
|
## `sb doctor` — kiểm tra cài đặt
|
|
995
1098
|
|
|
996
1099
|
```
|
|
997
1100
|
sb doctor # kiểm tra máy này, repo này và app Next.js của nó
|
|
998
1101
|
sb doctor --json # như trên, dạng JSON cho CI (exit 1 khi có kiểm tra hỏng)
|
|
1102
|
+
sb doctor --build # thêm: đóng gói components/ (chạy esbuild của repo)
|
|
999
1103
|
```
|
|
1000
1104
|
|
|
1001
1105
|
Chỉ đọc: nó đọc file và gửi GET, không làm gì khác. Mỗi kiểm tra không đạt đều nêu đúng lệnh hoặc
|
|
1002
1106
|
đường dẫn trong Manage để sửa (`fix:`). `ok` và `skip` là đạt; `warn` là vẫn chạy nhưng có thứ bạn
|
|
1003
1107
|
nhiều khả năng muốn đang tắt; chỉ `fail` mới làm exit code là `1`.
|
|
1004
1108
|
|
|
1109
|
+
`sb doctor` không bao giờ chạy mã từ repo nó kiểm tra. `sb doctor --build` là ngoại lệ và nói rõ
|
|
1110
|
+
điều đó: nó còn đóng gói `components/`, tức là nạp và **chạy esbuild của chính repo** từ
|
|
1111
|
+
`node_modules`. Chỉ dùng trong repo bạn tin cậy, như bạn dùng `npm run build`.
|
|
1112
|
+
|
|
1005
1113
|
| Kiểm tra | Nó xem gì | Hỏng khi |
|
|
1006
1114
|
| --- | --- | --- |
|
|
1007
1115
|
| `node` | phiên bản Node.js | cũ hơn 20 |
|
|
@@ -1010,7 +1118,10 @@ nhiều khả năng muốn đang tắt; chỉ `fail` mới làm exit code là `1
|
|
|
1010
1118
|
| `scope:write` | các quyền ghi — **không thử** (GET không thử được việc ghi); nó nói mỗi quyền chặn gì | không bao giờ |
|
|
1011
1119
|
| `site` | `sb.json` nêu một site mà key hoặc login này tới được, và `.sb-site.json` cùng site đó | không có `siteId`, JSON hỏng, manifest của site khác, site không đọc được |
|
|
1012
1120
|
| `manifest` | `.sb-site.json`: mọi đường dẫn nằm trong thư mục của loại đó dưới `design/`, không có symlink | đường dẫn ngoài `design/`, symlink (file thiếu chỉ là `warn`) |
|
|
1013
|
-
| `files` | mọi file dưới `design/` đều parse được | có file không parse: in `file:line:col` |
|
|
1121
|
+
| `files` | mọi file dưới `design/` đều parse được | có file không parse: in `file:line:col`. Cảnh báo nêu file vẫn còn `html` hoặc `clientUrl` của code component (thuộc về nền tảng; bị bỏ qua) |
|
|
1122
|
+
| `agents` | trong repo site, mọi file agent (`AGENTS.md`, các skill, cấu hình MCP, workflow CI) đúng là văn bản bản sb này ghi, hoặc là bản bạn đã giữ | có file khác hoặc thiếu (cảnh báo): `sb site agents --refresh` |
|
|
1123
|
+
| `components:build` | các file `components/<Name>.tsx` có `schema` dạng literal, và `esbuild` đã cài trong repo (chỉ tìm `package.json` của nó — không bao giờ nạp). Tĩnh: **không chạy mã nào của repo** | `schema` của một file không phải literal, liên kết tượng trưng, thiếu esbuild. Với `--build` thêm: component không build được hoặc vượt giới hạn kích thước |
|
|
1124
|
+
| `components:pins` | mọi `<CodeComponent version={n}>` trong `design/` nêu một phiên bản mà nền tảng có (GET) | có cái không có (`sb site components upgrade`, hoặc `sb site push` để tải lên) |
|
|
1014
1125
|
| `domain` | tên miền chính của cửa hàng so với `SB_PUBLIC_URL`, và việc địa chỉ có sẵn chuyển hướng | chúng khác nhau; địa chỉ có sẵn chuyển hướng về deployment của bạn (vòng lặp — sửa: Manage → Domains → Default address → *Serve this site directly*) |
|
|
1015
1126
|
| `host-secret` | host link của site (hỏi bằng GET), `SB_HOST_SECRET` / `SB_SITE_ID` có trong môi trường này hoặc `.env` không, và — với `SB_STOREFRONT` — cửa hàng còn chấp nhận secret đó không (so một GET `robots.txt` có ký với một GET không ký; xoay vòng ở nơi khác là `fail`) | có secret nhưng site không có link (đã thu hồi) hoặc thiếu site id; app Next không có link, hoặc có link mà ở đây không có secret, là `warn` |
|
|
1016
1127
|
| `next:version` | `next` đã cài nằm trong `>=15.0.0 <17` | nằm ngoài khoảng |
|
package/dist/bin/sb.js
CHANGED
|
@@ -21,6 +21,7 @@ import { servicePlan, install, uninstall, status } from '../src/service.js';
|
|
|
21
21
|
import { newSite } from '../src/new.js';
|
|
22
22
|
import { pull as sitePull, push as sitePush, publish as sitePublish, blocks as siteBlocks, } from '../src/site.js';
|
|
23
23
|
import { doctor, lines as doctorLines } from '../src/doctor.js';
|
|
24
|
+
import { componentsInit, deleteRemote as componentsDelete, listRemote as componentsList, preview as componentsPreview, upgrade as componentsUpgrade, } from '../src/components.js';
|
|
24
25
|
import { linkHost } from '../src/hostlink.js';
|
|
25
26
|
import { dev as siteDev } from '../src/sitedev.js';
|
|
26
27
|
import { status as siteStatus } from '../src/sitestatus.js';
|
|
@@ -47,9 +48,11 @@ Account
|
|
|
47
48
|
where you type the code it prints; stores a
|
|
48
49
|
credential that renews itself
|
|
49
50
|
sb logout sign this machine out and forget the credential
|
|
50
|
-
sb doctor [--json] [--dir <path>]
|
|
51
|
+
sb doctor [--json] [--build] [--dir <path>]
|
|
51
52
|
check this machine, repo and Next.js app: each
|
|
52
|
-
problem names its fix; exit 1 on any failure
|
|
53
|
+
problem names its fix; exit 1 on any failure.
|
|
54
|
+
--build also bundles components/, which RUNS this
|
|
55
|
+
repo's own esbuild (code from its node_modules)
|
|
53
56
|
sb whoami which account (and platform) this CLI acts as
|
|
54
57
|
|
|
55
58
|
Sites
|
|
@@ -94,8 +97,24 @@ Sites
|
|
|
94
97
|
sb site code push [--site <id>] [--dir <path>] [--force] [--dry-run] [--delete]
|
|
95
98
|
send local edits back; refuses a file changed
|
|
96
99
|
in the Code Dock since your pull unless --force
|
|
97
|
-
sb site
|
|
98
|
-
|
|
100
|
+
sb site components init set a repo up for code components: esbuild + preact as devDependencies,
|
|
101
|
+
components/Hero.tsx to start from (sb site push bundles and uploads them)
|
|
102
|
+
sb site components list [--json]
|
|
103
|
+
each component on the platform: latest version, how many, sizes,
|
|
104
|
+
created, and the versions this repo's files pin
|
|
105
|
+
sb site components preview <Name> [--props <json|@file>] [--json]
|
|
106
|
+
build it here and have the platform render it once: the HTML a
|
|
107
|
+
page save would store, or the sandbox's error (exit 1). Nothing uploaded
|
|
108
|
+
sb site components upgrade <Name> [--to <n>] [--dry-run]
|
|
109
|
+
move every page pin of a component to its latest (or --to) version,
|
|
110
|
+
in the page files; then sb site push saves a draft
|
|
111
|
+
sb site components delete <Name> <version> [--yes] [--dry-run]
|
|
112
|
+
delete one version (asks first; --yes off a terminal); refused while
|
|
113
|
+
a page uses it, naming the pages. A number is never reused
|
|
114
|
+
sb site agents [--refresh] write the AI-agent files (AGENTS.md, MCP configs, the
|
|
115
|
+
page and components skills) into a repo; never overwrites.
|
|
116
|
+
--refresh rewrites the ones the CLI wrote, unedited; an
|
|
117
|
+
edited one is kept, today's text beside it as <file>.new
|
|
99
118
|
sb site types [--dir <path>] [--quiet]
|
|
100
119
|
write design/sbuilder-env.d.ts (+ design/tsconfig.json if none):
|
|
101
120
|
types so VS Code / Cursor complete and check .page.tsx files
|
|
@@ -197,6 +216,18 @@ function parse(argv) {
|
|
|
197
216
|
else if (a === '--yes') {
|
|
198
217
|
args.yes = true;
|
|
199
218
|
}
|
|
219
|
+
else if (a === '--build') {
|
|
220
|
+
args.build = true;
|
|
221
|
+
}
|
|
222
|
+
else if (a === '--refresh') {
|
|
223
|
+
args.refresh = true;
|
|
224
|
+
}
|
|
225
|
+
else if (a === '--props') {
|
|
226
|
+
args.props = argv[++i];
|
|
227
|
+
}
|
|
228
|
+
else if (a === '--to') {
|
|
229
|
+
args.to = argv[++i];
|
|
230
|
+
}
|
|
200
231
|
else if (a === '--org') {
|
|
201
232
|
args.org = argv[++i];
|
|
202
233
|
}
|
|
@@ -535,6 +566,54 @@ async function siteCode(args) {
|
|
|
535
566
|
warn: (l) => console.error(l),
|
|
536
567
|
});
|
|
537
568
|
}
|
|
569
|
+
/** `sb site components init|list|upgrade|delete`. */
|
|
570
|
+
async function siteComponents(args) {
|
|
571
|
+
const sub = args._[2];
|
|
572
|
+
const usage = 'usage: sb site components init | list [--json] | preview <Name> [--props <json|@file>] [--json] | upgrade <Name> [--to <n>] [--dry-run] | delete <Name> <version> [--yes] [--dry-run]';
|
|
573
|
+
if (!sub || !SUBCOMMANDS['site components'].includes(sub)) {
|
|
574
|
+
console.error(usage);
|
|
575
|
+
return 1;
|
|
576
|
+
}
|
|
577
|
+
const dir = resolve(args.dir ?? '.');
|
|
578
|
+
if (sub === 'init') {
|
|
579
|
+
await componentsInit(dir, (l) => console.log(l));
|
|
580
|
+
return 0;
|
|
581
|
+
}
|
|
582
|
+
const env = siteEnv(dir);
|
|
583
|
+
const api = env.SB_API || apiBase();
|
|
584
|
+
const opts = {
|
|
585
|
+
api,
|
|
586
|
+
token: env.SB_TOKEN || (await credential(api)),
|
|
587
|
+
dir,
|
|
588
|
+
site: args.site,
|
|
589
|
+
dryRun: args.dryRun,
|
|
590
|
+
log: (l) => console.log(l),
|
|
591
|
+
warn: (l) => console.error(l),
|
|
592
|
+
};
|
|
593
|
+
if (sub === 'list')
|
|
594
|
+
return componentsList({ ...opts, json: args.json });
|
|
595
|
+
const name = args._[3];
|
|
596
|
+
if (!name || (sub === 'delete' && !args._[4])) {
|
|
597
|
+
console.error(usage);
|
|
598
|
+
return 1;
|
|
599
|
+
}
|
|
600
|
+
if (sub === 'preview')
|
|
601
|
+
return componentsPreview({ ...opts, name, props: args.props, json: args.json });
|
|
602
|
+
if (sub === 'delete')
|
|
603
|
+
return componentsDelete({
|
|
604
|
+
...opts,
|
|
605
|
+
name,
|
|
606
|
+
version: Number(args._[4]),
|
|
607
|
+
yes: args.yes,
|
|
608
|
+
// Asked only on a terminal; off one, `--yes` is the only way past the question.
|
|
609
|
+
confirm: process.stdin.isTTY ? async (q) => /^y/i.test(await ask(q)) : undefined,
|
|
610
|
+
});
|
|
611
|
+
return componentsUpgrade({
|
|
612
|
+
...opts,
|
|
613
|
+
name,
|
|
614
|
+
to: args.to === undefined ? undefined : Number(args.to),
|
|
615
|
+
});
|
|
616
|
+
}
|
|
538
617
|
/** `sb site …` */
|
|
539
618
|
async function siteCommand(args) {
|
|
540
619
|
const sub = args._[1];
|
|
@@ -550,14 +629,16 @@ async function siteCommand(args) {
|
|
|
550
629
|
}
|
|
551
630
|
if (sub === 'code')
|
|
552
631
|
return siteCode(args);
|
|
632
|
+
if (sub === 'components')
|
|
633
|
+
return siteComponents(args);
|
|
553
634
|
if (sub === 'mcp')
|
|
554
635
|
return mcp(args.dir);
|
|
555
636
|
if (sub === 'agents')
|
|
556
|
-
return agents({ dir: resolve(args.dir ?? '.') });
|
|
637
|
+
return agents({ dir: resolve(args.dir ?? '.'), refresh: args.refresh });
|
|
557
638
|
if (sub === 'types')
|
|
558
639
|
return siteTypes({ dir: resolve(args.dir ?? '.'), quiet: args.quiet });
|
|
559
640
|
if (!sub || !SUBCOMMANDS.site.includes(sub)) {
|
|
560
|
-
console.error('usage: sb site new|init|pull|push|publish|next|deploy|blocks|agents|types|code|mcp|status|dev [--site <id>] [--dir <path>] [--force] [--dry-run] [--all]');
|
|
641
|
+
console.error('usage: sb site new|init|pull|push|publish|next|deploy|blocks|agents|types|code|components|mcp|status|dev [--site <id>] [--dir <path>] [--force] [--dry-run] [--all]');
|
|
561
642
|
return 1;
|
|
562
643
|
}
|
|
563
644
|
if (sub === 'init') {
|
|
@@ -731,6 +812,7 @@ async function doctorCommand(args) {
|
|
|
731
812
|
api,
|
|
732
813
|
token: env.SB_TOKEN || (await credential(api)),
|
|
733
814
|
json: args.json,
|
|
815
|
+
build: args.build,
|
|
734
816
|
});
|
|
735
817
|
if (args.json)
|
|
736
818
|
console.log(JSON.stringify(report, null, 2));
|