sproutboat 0.8.0 → 0.9.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/CHANGELOG.md +304 -0
- package/README.md +33 -1
- package/SURFACE.md +7 -4
- package/package.json +9 -5
- package/src/broker.ts +48 -5
- package/src/build.ts +8 -0
- package/src/compile.ts +42 -11
- package/src/dev.ts +2 -0
- package/src/main.ts +230 -2
- package/src/native-fetch-prelude.js +3 -3
- package/src/surface.ts +17 -3
- package/src/toolchain.ts +71 -0
- package/src/transport-broker.js +9 -0
- package/src/transport-embedded.js +4 -0
- package/src/types-gen.ts +90 -0
- package/types/sproutboat.d.ts +217 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `sproutboat` (the CLI) are documented here. Format
|
|
4
|
+
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versioning
|
|
5
|
+
follows [SemVer](https://semver.org/), pre-1.0 so a minor bump can still carry
|
|
6
|
+
a breaking change.
|
|
7
|
+
|
|
8
|
+
Reconstructed from git history on 2026-09-03 for everything through v0.4.11;
|
|
9
|
+
maintained going forward by the `release` skill.
|
|
10
|
+
|
|
11
|
+
## [Unreleased]
|
|
12
|
+
|
|
13
|
+
## [0.9.0] - 2026-09-07
|
|
14
|
+
### Added
|
|
15
|
+
- KV content management: `kv key get`, `put`, `delete`, and `list`; bounded
|
|
16
|
+
`kv bulk get`, `put`, and `delete`; and cursor-paginated `kv export` files
|
|
17
|
+
that can be restored with `kv bulk put`.
|
|
18
|
+
- CLI integration coverage for pagination, bounded batches, text and file
|
|
19
|
+
output, overwrite refusal, and cleanup after failed exports.
|
|
20
|
+
- `sproutboat-env.d.ts` generation from project bindings.
|
|
21
|
+
- Focused runnable examples for every supported binding.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
- Static assets keep arbitrary binary bytes when they travel through the broker.
|
|
25
|
+
- KV exports use a permission-restricted temporary file and move into place only
|
|
26
|
+
after a complete export. Failed exports leave neither partial output nor a
|
|
27
|
+
temporary file behind.
|
|
28
|
+
- First-host builds no longer require Git or Make.
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- Development binaries compile with Porffor `-O0` for faster iteration.
|
|
32
|
+
- The installation docs state that the CLI requires Bun and should be invoked
|
|
33
|
+
with `bunx` rather than `npx`.
|
|
34
|
+
|
|
35
|
+
## [0.8.0] — 2026-09-07
|
|
36
|
+
### Added
|
|
37
|
+
- `sproutboat build --standalone`: one executable that carries its own bindings.
|
|
38
|
+
SQLite is compiled into the sprout, so a ~2 MB file serves KV, D1, R2, queues,
|
|
39
|
+
Durable Objects, alarms, analytics and assets with nothing beside it on disk —
|
|
40
|
+
no Bun, no broker, no control plane. State lives in `<name>.data/store.sqlite`
|
|
41
|
+
plus `d1/<binding>.sqlite`, the same layout `sproutboat dev` writes, which is
|
|
42
|
+
what lets one conformance suite hold both backends to the same behaviour.
|
|
43
|
+
Secrets come from the environment (then `<data>/secrets.json`) and a missing
|
|
44
|
+
one refuses the boot, listing every name at once, rather than throwing on the
|
|
45
|
+
first request that needs it. Cron ticks, queue batches and DO alarms run on
|
|
46
|
+
in-process timers; assets are baked in, capped at 8 MB.
|
|
47
|
+
- Outbound TLS from a standalone binary. `fetch("https://…")` verifies against
|
|
48
|
+
curl's Mozilla-derived root set via BearSSL, linked in beside SQLite
|
|
49
|
+
(1.86 → 2.02 MB). `SB_CA_BUNDLE` adds a private or corporate CA to that set;
|
|
50
|
+
it only ever adds trust, and nothing disables verification.
|
|
51
|
+
- Durable Object alarms: `setAlarm` / `getAlarm` / `deleteAlarm` and the
|
|
52
|
+
`alarm()` handler. At most one alarm is pending per object and a later
|
|
53
|
+
`setAlarm` replaces it, matching Workers. Delivery claims before running, so
|
|
54
|
+
an `alarm()` that schedules its own next run is not erased by the delivery
|
|
55
|
+
that invoked it.
|
|
56
|
+
- Service bindings: `env.<BINDING>.fetch()` reaches another deployment on the
|
|
57
|
+
same node through the edge on loopback. This is the CLI half; a binding that
|
|
58
|
+
resolves to nothing reports the target as undeployed rather than failing as a
|
|
59
|
+
502.
|
|
60
|
+
- Binary values in the binding frame. An R2 object body now travels beside the
|
|
61
|
+
JSON rather than encoded inside it.
|
|
62
|
+
- `SB_FETCH_MAX_BYTES` (32 MiB default) caps an outbound response body. An
|
|
63
|
+
unbounded upstream could previously drive a sprout's memory to whatever it
|
|
64
|
+
chose to send.
|
|
65
|
+
|
|
66
|
+
### Fixed
|
|
67
|
+
- `d1.exec` ran only the first statement of a multi-statement script, so a
|
|
68
|
+
schema built in one `exec()` call silently created only its first table.
|
|
69
|
+
- `r2.get` / `head` / `put` / `list` returned flat fields where the shim reads
|
|
70
|
+
`r.object`, and `ae.query` omitted the `count` its caller reads.
|
|
71
|
+
- Trigger authentication accepted *any* caller when no token was configured.
|
|
72
|
+
The hole predates this release; a standalone binary listening on a public
|
|
73
|
+
interface is what made it reachable.
|
|
74
|
+
- Binary R2 values were corrupted in transit — `0x08` and `0x0c` arrived as
|
|
75
|
+
`b` and `f`.
|
|
76
|
+
- A retried binding call could apply a write twice. Every request now carries an
|
|
77
|
+
id and the broker replays the cached reply for a repeat of a mutating op
|
|
78
|
+
instead of performing it again.
|
|
79
|
+
|
|
80
|
+
### Changed
|
|
81
|
+
- A dropped broker connection is retried four times with 0/5/25/100 ms backoff
|
|
82
|
+
instead of failing after one attempt, which covers a broker restart mid-call.
|
|
83
|
+
- The bundled (Bun) standalone backend is gone. The embedded one passes the same
|
|
84
|
+
suite at 1.9 MB against 63 MB, and TLS removed its last real advantage.
|
|
85
|
+
- A native-fetch binary cannot see `argv` — Porffor's runtime init calls
|
|
86
|
+
`porf_init(0, NULL)` — so a standalone binary is configured through `PORT`,
|
|
87
|
+
`SB_DATA_DIR` / `SPROUTBOAT_DATA` and the environment only, never flags.
|
|
88
|
+
|
|
89
|
+
### Performance
|
|
90
|
+
- An 8 MB R2 put through the broker went from 255 MB to 149 MB peak RSS.
|
|
91
|
+
- The broker's frame reader no longer re-concatenates its buffer per chunk.
|
|
92
|
+
|
|
93
|
+
## [0.7.0] — 2026-09-06
|
|
94
|
+
### Added
|
|
95
|
+
- `compatibility_date` now reaches the artifact instead of being validated and
|
|
96
|
+
dropped. It is recorded in `manifest.json` as `compatibilityDate` and baked
|
|
97
|
+
into the binary as `__sbCompat`, so a future runtime change can be gated on
|
|
98
|
+
`__sbCompat >= "YYYY-MM-DD"` and old binaries keep the semantics they were
|
|
99
|
+
compiled with. The manifest field is optional and `schemaVersion` stays at 2,
|
|
100
|
+
so artifacts built before this release remain deployable and rollback keeps
|
|
101
|
+
working.
|
|
102
|
+
- A version-skew warning. Control planes advertise `x-sproutboat-control` and
|
|
103
|
+
`x-sproutboat-min-cli` on every `/api/` response; when this CLI is below the
|
|
104
|
+
advertised minimum it says so once per run, instead of leaving the user with
|
|
105
|
+
an unexplained 400. A control plane that predates the handshake sends no
|
|
106
|
+
headers and nothing changes.
|
|
107
|
+
- `CONTRACTS.md`, generated from source in the same style as `SURFACE.md`: the
|
|
108
|
+
broker ops, storage tables, manifest fields and config keys that a release may
|
|
109
|
+
not break, plus golden fixtures for the manifest and the storage format so a
|
|
110
|
+
regression fails a test rather than a user's deployment.
|
|
111
|
+
|
|
112
|
+
## [0.6.1] — 2026-09-06
|
|
113
|
+
### Fixed
|
|
114
|
+
- `sproutboat queues` help (and the generated `SURFACE.md`) claimed queue
|
|
115
|
+
consumers "are not implemented yet". They are implemented, and they run on
|
|
116
|
+
the deployed path as well as under `dev`: the supervisor passes
|
|
117
|
+
`--sprout-url` to the broker, which delivers messages in batches, retries a
|
|
118
|
+
failed or explicitly-retried message after 5s, and stops delivering it after
|
|
119
|
+
5 attempts. The summary now describes what actually happens.
|
|
120
|
+
|
|
121
|
+
### Changed
|
|
122
|
+
- Tooling only, no change to how the CLI behaves: oxfmt is scoped to the JS
|
|
123
|
+
family with the pre-commit hook's glob matched to it, TypeScript moves
|
|
124
|
+
5.9 → 7.0, and the GitHub Actions group is bumped.
|
|
125
|
+
|
|
126
|
+
## [0.6.0] — 2026-09-05
|
|
127
|
+
### Added
|
|
128
|
+
- `bindings.json` now carries `vars` — the baked plain values a sprout was
|
|
129
|
+
built with — so the control plane can show what a version was compiled
|
|
130
|
+
against. They ride along for display only; the broker never serves them,
|
|
131
|
+
they are compiled into the sprout itself. A project whose only binding
|
|
132
|
+
config is `vars` now gets a sidecar written at all, where before it got
|
|
133
|
+
none.
|
|
134
|
+
|
|
135
|
+
### Changed
|
|
136
|
+
- Tooling only, no change to how the CLI behaves: the tree is now formatted
|
|
137
|
+
with oxfmt 0.66.0 (the config landed in 0.5.0 but was never run over the
|
|
138
|
+
tree), markdown is excluded from formatting, a lefthook pre-commit hook
|
|
139
|
+
formats staged files and lints, the last 10 oxlint warnings are cleared,
|
|
140
|
+
and CI gates lint alongside typecheck and test.
|
|
141
|
+
- README rewritten shorter: a logo lockup that survives both GitHub themes
|
|
142
|
+
(`docs/logo-light.svg` / `docs/logo-dark.svg` behind a `<picture>`), the
|
|
143
|
+
everyday commands as a five-row table, and the full command inventory left
|
|
144
|
+
to the generated `SURFACE.md` instead of duplicated by hand.
|
|
145
|
+
|
|
146
|
+
## [0.5.0] — 2026-09-03
|
|
147
|
+
### Added
|
|
148
|
+
- `dev [--port <n>] [--no-watch]` — run the project on this machine against a
|
|
149
|
+
real broker (KV/D1/secrets/etc. all work), rebuilding on save.
|
|
150
|
+
- `build --target host` — compile for the machine doing the build instead of
|
|
151
|
+
cross-compiling for a box; what `dev` uses, and runnable standalone.
|
|
152
|
+
- Handlers may now `import` — relative modules across the project, and npm
|
|
153
|
+
packages from the project's own `node_modules`. The entry point is bundled
|
|
154
|
+
before it reaches Porffor; the capability checks run against that bundled
|
|
155
|
+
output, so a dependency can't reach `process`/`Bun`/`node:*` any more than
|
|
156
|
+
hand-written code can.
|
|
157
|
+
- `sproutboat init` scaffolds a `.gitignore` (`.sproutboat/`, `.dev.vars`,
|
|
158
|
+
`node_modules/`) alongside the project files, unless one already exists.
|
|
159
|
+
|
|
160
|
+
### Fixed
|
|
161
|
+
- Async `fetch` handlers hung indefinitely — `__sbEntry` chained the #28
|
|
162
|
+
CPU-time tag onto the handler's own promise, and Porffor's native-fetch
|
|
163
|
+
server only resolves a promise a handler returns directly, never one
|
|
164
|
+
derived from `.then()`.
|
|
165
|
+
- `new Proxy(...)` compiles under Porffor alpha-4 and then silently ignores
|
|
166
|
+
every trap — a trapped property just reads back `undefined`. `check` now
|
|
167
|
+
rejects it before that reaches a deploy as an unexplained 502.
|
|
168
|
+
- `sproutboat init` crashed with a raw `EEXIST` stack trace, and could leave
|
|
169
|
+
a half-scaffolded project, if `src/index.js` already existed but
|
|
170
|
+
`sproutboat.jsonc` didn't. Both targets are checked before either is
|
|
171
|
+
written.
|
|
172
|
+
- Re-running `sproutboat build` (or `dev`'s rebuild-on-save) could fail to
|
|
173
|
+
link: the artifact directory is content-addressed, so an unchanged rebuild
|
|
174
|
+
targeted the previous binary, which was `chmod 0555` and possibly still
|
|
175
|
+
running.
|
|
176
|
+
- The broker's local dev state directory was never created before opening
|
|
177
|
+
its SQLite file, so a first `sproutboat dev` run failed outright.
|
|
178
|
+
|
|
179
|
+
### Changed
|
|
180
|
+
- Lint: adopted the anti-slop Oxlint plugin and migrated the tree onto it —
|
|
181
|
+
no more bare `unknown`/`Record<string, unknown>` at binding boundaries,
|
|
182
|
+
every non-const type assertion carries a `SAFETY:` comment.
|
|
183
|
+
|
|
184
|
+
## [0.4.11] — 2026-09-02
|
|
185
|
+
### Changed
|
|
186
|
+
- README rewritten for current commands and config; points at the docs site.
|
|
187
|
+
|
|
188
|
+
## [0.4.10] — 2026-09-02
|
|
189
|
+
### Changed
|
|
190
|
+
- `domains`: prints the A record to add, and any DNS reachability warning.
|
|
191
|
+
|
|
192
|
+
## [0.4.9] — 2026-09-02
|
|
193
|
+
### Changed
|
|
194
|
+
- `deploy` (#80): dropped the client-side dedup check in favour of trusting
|
|
195
|
+
the server's own no-op response.
|
|
196
|
+
|
|
197
|
+
## [0.4.8] — 2026-09-02
|
|
198
|
+
### Fixed
|
|
199
|
+
- `deploy` (#80): no longer skipped the upload when only assets or bindings
|
|
200
|
+
had changed but the sprout binary hadn't.
|
|
201
|
+
|
|
202
|
+
## [0.4.7] — 2026-09-02
|
|
203
|
+
### Added
|
|
204
|
+
- `deploy` auto-provisions an id-less storage binding (wrangler-style):
|
|
205
|
+
creates the account-level resource, writes its id back into
|
|
206
|
+
`sproutboat.jsonc`.
|
|
207
|
+
|
|
208
|
+
## [0.4.6] — 2026-09-02
|
|
209
|
+
### Added
|
|
210
|
+
- `sproutboat resource` — manage account-level storage resources directly.
|
|
211
|
+
- `sproutboat.jsonc` storage bindings accept `{ binding, id }`, not just a
|
|
212
|
+
bare name.
|
|
213
|
+
### Changed
|
|
214
|
+
- Broker keys KV/R2/queue/D1 stores by resource id when one is bound, so the
|
|
215
|
+
data survives a redeploy and can be shared across projects.
|
|
216
|
+
|
|
217
|
+
## [0.4.5] — 2026-09-02
|
|
218
|
+
### Changed
|
|
219
|
+
- `deploy` dropped the "✓ serving" line — silence now means the health check
|
|
220
|
+
passed.
|
|
221
|
+
|
|
222
|
+
## [0.4.4] — 2026-09-02
|
|
223
|
+
### Added
|
|
224
|
+
- `--version`, a once-a-day update-available notice, a richer deploy echo.
|
|
225
|
+
### Changed
|
|
226
|
+
- Misuse now exits `2` (getopt convention) instead of `1`.
|
|
227
|
+
|
|
228
|
+
## [0.4.3] — 2026-09-02
|
|
229
|
+
### Changed
|
|
230
|
+
- `--help` output: grouped, emoji-labelled, aligned — was one wall-of-text
|
|
231
|
+
usage line.
|
|
232
|
+
|
|
233
|
+
## [0.4.2] — 2026-09-02
|
|
234
|
+
### Added
|
|
235
|
+
- `tail --sprout` streams the running sprout's and broker's stdout/stderr.
|
|
236
|
+
### Changed
|
|
237
|
+
- `deploy` waits for the health check and prints every binding in the
|
|
238
|
+
report; `delete` takes flexible args plus `?confirm`; the banner reads the
|
|
239
|
+
real installed version.
|
|
240
|
+
|
|
241
|
+
## [0.4.0] — 2026-09-01
|
|
242
|
+
### Added
|
|
243
|
+
- `sproutboat domains` and `sproutboat secrets` commands.
|
|
244
|
+
- `deploy` uploads the `bindings.json` / `assets.json` sidecars alongside
|
|
245
|
+
the sprout binary.
|
|
246
|
+
- The worker self-reports per-invocation CPU time (`x-sb-cpu-ms`).
|
|
247
|
+
- Deploy surfaces a Porffor pin drift warning when the live version was
|
|
248
|
+
built against a different compiler pin than the one about to deploy.
|
|
249
|
+
### Changed
|
|
250
|
+
- Renamed "worker" to "sprout" throughout the CLI, broker, and examples.
|
|
251
|
+
|
|
252
|
+
## [0.3.0] — 2026-09-01
|
|
253
|
+
### Added
|
|
254
|
+
- Published to npm via Trusted Publishing (OIDC) — no token secret in CI.
|
|
255
|
+
### Changed
|
|
256
|
+
- `src/wrap.ts` extracted with `runtime/*` subpath exports, so the monorepo
|
|
257
|
+
can consume the binding/manifest contracts as a dependency instead of a
|
|
258
|
+
hand-vendored copy.
|
|
259
|
+
- CSPRNG-backed `crypto.getRandomValues`; the deploy binary is stripped.
|
|
260
|
+
- One long-lived broker connection per worker instead of reconnecting on
|
|
261
|
+
every binding call; `env.<SECRET>` memoized; `assets.get` made synchronous
|
|
262
|
+
with the broker service; WAL + `synchronous=NORMAL` and parameterised
|
|
263
|
+
`LIMIT` back-ported from the monorepo's broker.
|
|
264
|
+
|
|
265
|
+
## [0.2.1] — 2026-08-31
|
|
266
|
+
### Changed
|
|
267
|
+
- Ships a prebuilt uWebSockets archive, so the first build needs neither
|
|
268
|
+
`git` nor `make` on `PATH`.
|
|
269
|
+
|
|
270
|
+
## [0.2.0] — 2026-08-31
|
|
271
|
+
Initial release, extracted from the `sproutboat` monorepo (`apps/cli`) as
|
|
272
|
+
its own package.
|
|
273
|
+
### Added
|
|
274
|
+
- Cross-compiles a handler to a static `linux-x86_64` binary with Porffor +
|
|
275
|
+
Zig — no Docker.
|
|
276
|
+
- Static assets binding, with the `examples/kitchen-sink` Astro app as a
|
|
277
|
+
worked example.
|
|
278
|
+
- `SURFACE.md`, generated and drift-checked against the actual command/env
|
|
279
|
+
surface.
|
|
280
|
+
### Changed
|
|
281
|
+
- Patches Porffor at build time rather than via a `postinstall` hook.
|
|
282
|
+
- Renamed the package to `sproutboat` (was `@sproutboat/cli`); dropped the
|
|
283
|
+
`sprout` bin alias in favour of a user-defined shell alias.
|
|
284
|
+
|
|
285
|
+
[Unreleased]: https://github.com/baronunread/sproutboat-cli/compare/v0.8.0...HEAD
|
|
286
|
+
[0.8.0]: https://github.com/baronunread/sproutboat-cli/compare/v0.7.0...v0.8.0
|
|
287
|
+
[0.7.0]: https://github.com/baronunread/sproutboat-cli/compare/v0.6.1...v0.7.0
|
|
288
|
+
[0.6.1]: https://github.com/baronunread/sproutboat-cli/compare/v0.6.0...v0.6.1
|
|
289
|
+
[0.6.0]: https://github.com/baronunread/sproutboat-cli/compare/v0.5.0...v0.6.0
|
|
290
|
+
[0.5.0]: https://github.com/baronunread/sproutboat-cli/compare/v0.4.11...v0.5.0
|
|
291
|
+
[0.4.11]: https://github.com/baronunread/sproutboat-cli/compare/v0.4.10...v0.4.11
|
|
292
|
+
[0.4.10]: https://github.com/baronunread/sproutboat-cli/compare/v0.4.9...v0.4.10
|
|
293
|
+
[0.4.9]: https://github.com/baronunread/sproutboat-cli/compare/v0.4.8...v0.4.9
|
|
294
|
+
[0.4.8]: https://github.com/baronunread/sproutboat-cli/compare/v0.4.7...v0.4.8
|
|
295
|
+
[0.4.7]: https://github.com/baronunread/sproutboat-cli/compare/v0.4.6...v0.4.7
|
|
296
|
+
[0.4.6]: https://github.com/baronunread/sproutboat-cli/compare/v0.4.5...v0.4.6
|
|
297
|
+
[0.4.5]: https://github.com/baronunread/sproutboat-cli/compare/v0.4.4...v0.4.5
|
|
298
|
+
[0.4.4]: https://github.com/baronunread/sproutboat-cli/compare/v0.4.3...v0.4.4
|
|
299
|
+
[0.4.3]: https://github.com/baronunread/sproutboat-cli/compare/v0.4.2...v0.4.3
|
|
300
|
+
[0.4.2]: https://github.com/baronunread/sproutboat-cli/compare/v0.4.0...v0.4.2
|
|
301
|
+
[0.4.0]: https://github.com/baronunread/sproutboat-cli/compare/v0.3.0...v0.4.0
|
|
302
|
+
[0.3.0]: https://github.com/baronunread/sproutboat-cli/compare/v0.2.1...v0.3.0
|
|
303
|
+
[0.2.1]: https://github.com/baronunread/sproutboat-cli/compare/v0.2.0...v0.2.1
|
|
304
|
+
[0.2.0]: https://github.com/baronunread/sproutboat-cli/releases/tag/v0.2.0
|
package/README.md
CHANGED
|
@@ -19,6 +19,12 @@ for agents: [sproutboat.com/llms.txt](https://sproutboat.com/llms.txt)).
|
|
|
19
19
|
|
|
20
20
|
## Using
|
|
21
21
|
|
|
22
|
+
Sproutboat is a Bun tool. It needs **Bun 1.4+** on the machine you build from,
|
|
23
|
+
and `bunx` rather than `npx`: the CLI runs on Bun's APIs, and `npm install`
|
|
24
|
+
cannot resolve it today ([#134](https://github.com/baronunread/sproutboat/issues/134)).
|
|
25
|
+
Nothing is needed on the machine that *runs* a sprout: that gets a static
|
|
26
|
+
binary.
|
|
27
|
+
|
|
22
28
|
```sh
|
|
23
29
|
bunx sproutboat init hello
|
|
24
30
|
cd hello
|
|
@@ -32,7 +38,7 @@ bunx sproutboat login --api-url https://control.example.com # one browser appr
|
|
|
32
38
|
bunx sproutboat deploy
|
|
33
39
|
```
|
|
34
40
|
|
|
35
|
-
Or install it once and drop the `bunx`:
|
|
41
|
+
Or install it once with Bun and drop the `bunx`:
|
|
36
42
|
|
|
37
43
|
```sh
|
|
38
44
|
bun add -g sproutboat # then: sproutboat deploy, sproutboat tail, ...
|
|
@@ -63,6 +69,32 @@ Run `sproutboat` with no arguments for the grouped list.
|
|
|
63
69
|
[`SURFACE.md`](SURFACE.md) is the generated inventory: every command, every
|
|
64
70
|
argument, every env var, kept honest by a drift test.
|
|
65
71
|
|
|
72
|
+
### KV data and waitlist export
|
|
73
|
+
|
|
74
|
+
Manage one namespace by its account-level name:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
sproutboat kv key list registrations --prefix email:
|
|
78
|
+
sproutboat kv key get registrations email:person@example.com --text
|
|
79
|
+
sproutboat kv key put registrations email:person@example.com joined
|
|
80
|
+
sproutboat kv key delete registrations email:person@example.com --yes
|
|
81
|
+
sproutboat kv export registrations --prefix email: --output registrations.json
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Bulk put, and therefore exported dumps, use the version 1 text-value format:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
[
|
|
88
|
+
{ "key": "email:person@example.com", "value": "joined" }
|
|
89
|
+
]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`kv bulk get` and `kv bulk delete` accept a JSON array of key strings. `kv bulk
|
|
93
|
+
put` accepts the entry array above. The CLI sends large inputs in bounded
|
|
94
|
+
batches. Export pages through the namespace and writes incrementally to a
|
|
95
|
+
permission-restricted temporary file, then renames it into place only after a
|
|
96
|
+
complete export. Existing output files require `--force`.
|
|
97
|
+
|
|
66
98
|
## Config
|
|
67
99
|
|
|
68
100
|
`sproutboat.jsonc`: the entry point plus Cloudflare-shaped `env.*` bindings.
|
package/SURFACE.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Generated by `src/surface.test.ts` from `src/surface.ts` + the pinned
|
|
4
4
|
> toolchain constants. Do not edit by hand — run `UPDATE_SURFACE=1 bun test`.
|
|
5
5
|
|
|
6
|
-
**Package:** `sproutboat` 0.
|
|
6
|
+
**Package:** `sproutboat` 0.9.0 · runs on Bun (use `bunx`, not `npx`)
|
|
7
7
|
|
|
8
8
|
## Commands
|
|
9
9
|
|
|
@@ -11,13 +11,14 @@
|
|
|
11
11
|
| --- | --- | --- |
|
|
12
12
|
| `init` | `[name]` | Scaffold sproutboat.jsonc + src/index.js in ./<name>. |
|
|
13
13
|
| `check` | `[project-dir]` | Validate the config and entry point without building. |
|
|
14
|
+
| `types` | `[project-dir]` | Write sproutboat-env.d.ts from the config, so an editor knows what `env` holds. `dev` and `deploy` refresh it when the config is newer. |
|
|
14
15
|
| `dev` | `[project-dir] [--port <n>] [--no-watch]` | Run the project on this machine against a real broker, rebuilding on save. |
|
|
15
16
|
| `build` | `[project-dir] [--target host] [--standalone]` | Cross-compile the native-fetch sprout (Porffor + Zig). `--target host` builds for this machine instead, to run locally — not deployable. `--standalone` emits one executable carrying its own bindings, with SQLite compiled in (~2 MB) and no broker process. |
|
|
16
17
|
| `deploy` | `[project-dir] [--dry-run] [--artifact <dir>] [--no-wait] [--no-provision]` | Build (unless --artifact), auto-provision id-less storage bindings and pin their ids into sproutboat.jsonc, print the report, upload, wait until the URL serves. The control plane skips an upload that matches the live artifact byte-for-byte. --dry-run stops before upload; --no-wait skips the health check; --no-provision leaves id-less bindings as ephemeral deploy-scoped stores. |
|
|
17
18
|
| `versions` | `<list | view <version-id>> [project-dir]` | List the project's deployed versions, or show one version's artifact and bindings. |
|
|
18
19
|
| `rollback` | `<version-id> [project-dir]` | Re-activate a previous version. |
|
|
19
20
|
| `tail` | `[project-dir] [--sprout]` | Print recent request logs; --sprout prints the running sprout + broker stdout/stderr instead. |
|
|
20
|
-
| `kv` | `<list | create <name> | info <name> | rename <name> <new> | delete <name
|
|
21
|
+
| `kv` | `<list | create <name> | info <name> | rename <name> <new> | delete <name>> | <key | bulk | export> ...` | KV namespaces. `create` prints the id to bind from sproutboat.jsonc; key and bulk operations manage contents, and export writes a restorable JSON dump. |
|
|
21
22
|
| `d1` | `<list | create <name> | info <name> | rename <name> <new> | delete <name>>` | D1 databases. `create` prints the id to bind from sproutboat.jsonc. |
|
|
22
23
|
| `r2` | `<list | create <name> | info <name> | rename <name> <new> | delete <name>>` | R2 buckets. `create` prints the id to bind from sproutboat.jsonc. |
|
|
23
24
|
| `queues` | `<list | create <name> | info <name> | rename <name> <new> | delete <name>>` | Queues. `create` prints the id to bind from sproutboat.jsonc; consumers deliver in batches with retries, and stop after 5 attempts. |
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
| `whoami` | — | Show the active endpoint and the account the stored token belongs to. |
|
|
30
31
|
|
|
31
32
|
```
|
|
32
|
-
usage: sproutboat <init [name] | check [project-dir] | dev [project-dir] [--port <n>] [--no-watch] | build [project-dir] [--target host] [--standalone] | deploy [project-dir] [--dry-run] [--artifact <dir>] [--no-wait] [--no-provision] | versions <list | view <version-id>> [project-dir] | rollback <version-id> [project-dir] | tail [project-dir] [--sprout] | kv <list | create <name> | info <name> | rename <name> <new> | delete <name>> | d1 <list | create <name> | info <name> | rename <name> <new> | delete <name>> | r2 <list | create <name> | info <name> | rename <name> <new> | delete <name>> | queues <list | create <name> | info <name> | rename <name> <new> | delete <name>> | domains <list | add <host> | verify <host> | delete <host>> [project-dir] | secrets <list | put <NAME> [--value <value>] | delete <NAME>> [project-dir] | delete [project-dir] [--name <project>] --yes | login [--api-url <url>] [--token <token>] | logout [--api-url <url>] | whoami>
|
|
33
|
+
usage: sproutboat <init [name] | check [project-dir] | types [project-dir] | dev [project-dir] [--port <n>] [--no-watch] | build [project-dir] [--target host] [--standalone] | deploy [project-dir] [--dry-run] [--artifact <dir>] [--no-wait] [--no-provision] | versions <list | view <version-id>> [project-dir] | rollback <version-id> [project-dir] | tail [project-dir] [--sprout] | kv <list | create <name> | info <name> | rename <name> <new> | delete <name>> | <key | bulk | export> ... | d1 <list | create <name> | info <name> | rename <name> <new> | delete <name>> | r2 <list | create <name> | info <name> | rename <name> <new> | delete <name>> | queues <list | create <name> | info <name> | rename <name> <new> | delete <name>> | domains <list | add <host> | verify <host> | delete <host>> [project-dir] | secrets <list | put <NAME> [--value <value>] | delete <NAME>> [project-dir] | delete [project-dir] [--name <project>] --yes | login [--api-url <url>] [--token <token>] | logout [--api-url <url>] | whoami>
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
## Environment variables
|
|
@@ -39,7 +40,9 @@ usage: sproutboat <init [name] | check [project-dir] | dev [project-dir] [--port
|
|
|
39
40
|
| `SPROUTBOAT_API_URL` | Control-plane URL. Overrides the saved active endpoint. |
|
|
40
41
|
| `SPROUTBOAT_TOKEN` | API token. Overrides the saved credential for the endpoint. |
|
|
41
42
|
| `SPROUTBOAT_ZIG` | Path to a Zig binary to use instead of downloading the pinned one. |
|
|
42
|
-
| `SPROUTBOAT_UWS_TARBALL` | Path to a
|
|
43
|
+
| `SPROUTBOAT_UWS_TARBALL` | Path to a uWebSockets source tarball to seed the Porffor cache with, instead of the one vendored in the package. Both targets are seeded from it. |
|
|
44
|
+
| `CC` | C compiler used to build uSockets for a host build (default `cc`). A host build needs one regardless: it is what Porffor compiles its own generated C with. |
|
|
45
|
+
| `AR` | Archiver used to assemble uSockets.a for a host build (default `ar`). |
|
|
43
46
|
| `SPROUTBOAT_COMPILE_TIMEOUT_MS` | Porffor compile timeout in ms (default 600000). |
|
|
44
47
|
| `SPROUTBOAT_VARS_JSON` | JSON object of baked `vars` (UPPER_SNAKE -> string), read by the wrapper when generating the sprout module. |
|
|
45
48
|
| `SPROUTBOAT_BINDINGS_JSON` | The artifact's bindings.json, read by the wrapper to emit the `__sbInstallBindings` line. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sproutboat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Wrangler-shaped CLI for Sproutboat. Deploys workers to any control plane via --api-url / SPROUTBOAT_API_URL.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -22,12 +22,14 @@
|
|
|
22
22
|
"sproutboat": "src/main.ts"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
|
+
"CHANGELOG.md",
|
|
26
|
+
"SURFACE.md",
|
|
25
27
|
"src",
|
|
26
|
-
"
|
|
27
|
-
"vendor"
|
|
28
|
-
"SURFACE.md"
|
|
28
|
+
"types",
|
|
29
|
+
"vendor"
|
|
29
30
|
],
|
|
30
31
|
"type": "module",
|
|
32
|
+
"types": "./types/sproutboat.d.ts",
|
|
31
33
|
"exports": {
|
|
32
34
|
"./runtime/config": "./src/config.ts",
|
|
33
35
|
"./runtime/source": "./src/source.ts",
|
|
@@ -36,12 +38,14 @@
|
|
|
36
38
|
"./runtime/broker": "./src/broker.ts",
|
|
37
39
|
"./runtime/wrap": "./src/wrap.ts",
|
|
38
40
|
"./runtime/prelude": "./src/native-fetch-prelude.js",
|
|
39
|
-
"./package.json": "./package.json"
|
|
41
|
+
"./package.json": "./package.json",
|
|
42
|
+
"./types": "./types/sproutboat.d.ts"
|
|
40
43
|
},
|
|
41
44
|
"scripts": {
|
|
42
45
|
"prepare": "lefthook install || true",
|
|
43
46
|
"typecheck": "tsc --noEmit",
|
|
44
47
|
"lint": "oxlint .",
|
|
48
|
+
"examples": "bun examples/smoke.ts",
|
|
45
49
|
"fmt": "oxfmt .",
|
|
46
50
|
"fmt:check": "oxfmt --check .",
|
|
47
51
|
"test": "bun test",
|
package/src/broker.ts
CHANGED
|
@@ -196,14 +196,14 @@ export function createBroker(opts: BrokerOptions = {}): Broker {
|
|
|
196
196
|
assetManifest = JSON.parse(readFileSync(manifestPath, "utf8")) as AssetManifest;
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
const readAsset = (path: string): { type: string; hash: string; body:
|
|
199
|
+
const readAsset = (path: string): { type: string; hash: string; body: Uint8Array } | null => {
|
|
200
200
|
if (!assetsDir || !assetManifest) return null;
|
|
201
201
|
const entry = assetManifest.files[path];
|
|
202
202
|
if (!entry) return null;
|
|
203
203
|
// path keys are `/`-prefixed and `..`-free (walkAssets), but re-check.
|
|
204
204
|
const abs = normalize(join(assetsDir, path));
|
|
205
205
|
if (!abs.startsWith(assetsDir)) return null;
|
|
206
|
-
return { type: entry.type, hash: entry.hash, body: readFileSync(abs
|
|
206
|
+
return { type: entry.type, hash: entry.hash, body: readFileSync(abs) };
|
|
207
207
|
};
|
|
208
208
|
const token = opts.token ?? "";
|
|
209
209
|
/** #63 §3 — replies to recent non-idempotent requests, keyed by op and id. */
|
|
@@ -716,16 +716,38 @@ export function createBroker(opts: BrokerOptions = {}): Broker {
|
|
|
716
716
|
const reqPath = str(msg.path) || "/";
|
|
717
717
|
const key = resolveAssetKey(reqPath, (k) => !!assetManifest?.files[k]);
|
|
718
718
|
const hit = key ? readAsset(key) : null;
|
|
719
|
-
if (hit)
|
|
719
|
+
if (hit)
|
|
720
|
+
return {
|
|
721
|
+
ok: true,
|
|
722
|
+
found: true,
|
|
723
|
+
status: 200,
|
|
724
|
+
type: hit.type,
|
|
725
|
+
hash: hit.hash,
|
|
726
|
+
body: new TextDecoder().decode(hit.body),
|
|
727
|
+
};
|
|
720
728
|
const nfh = assetManifest?.notFound ?? "none";
|
|
721
729
|
if (nfh === "single-page-application") {
|
|
722
730
|
const shell = readAsset("/index.html");
|
|
723
731
|
if (shell)
|
|
724
|
-
return {
|
|
732
|
+
return {
|
|
733
|
+
ok: true,
|
|
734
|
+
found: true,
|
|
735
|
+
status: 200,
|
|
736
|
+
type: shell.type,
|
|
737
|
+
hash: shell.hash,
|
|
738
|
+
body: new TextDecoder().decode(shell.body),
|
|
739
|
+
};
|
|
725
740
|
}
|
|
726
741
|
if (nfh === "404-page") {
|
|
727
742
|
const page = readAsset("/404.html");
|
|
728
|
-
if (page)
|
|
743
|
+
if (page)
|
|
744
|
+
return {
|
|
745
|
+
ok: true,
|
|
746
|
+
found: false,
|
|
747
|
+
status: 404,
|
|
748
|
+
type: page.type,
|
|
749
|
+
body: new TextDecoder().decode(page.body),
|
|
750
|
+
};
|
|
729
751
|
}
|
|
730
752
|
return { ok: true, found: false, status: 404, body: "Not Found" };
|
|
731
753
|
}
|
|
@@ -775,6 +797,27 @@ export function createBroker(opts: BrokerOptions = {}): Broker {
|
|
|
775
797
|
return { reply: { ok: true, found: true, object: r2Row(row) }, bytes: r2Bytes(row.body) };
|
|
776
798
|
}
|
|
777
799
|
|
|
800
|
+
if (msg.op === "assets.get") {
|
|
801
|
+
if (!bindings.assets) throw new Error("assets not bound");
|
|
802
|
+
const reqPath = str(msg.path) || "/";
|
|
803
|
+
const key = resolveAssetKey(reqPath, (candidate) => !!assetManifest?.files[candidate]);
|
|
804
|
+
let hit = key ? readAsset(key) : null;
|
|
805
|
+
let found = Boolean(hit);
|
|
806
|
+
let status = hit ? 200 : 404;
|
|
807
|
+
if (!hit && assetManifest?.notFound === "single-page-application") {
|
|
808
|
+
hit = readAsset("/index.html");
|
|
809
|
+
found = Boolean(hit);
|
|
810
|
+
status = hit ? 200 : 404;
|
|
811
|
+
} else if (!hit && assetManifest?.notFound === "404-page") {
|
|
812
|
+
hit = readAsset("/404.html");
|
|
813
|
+
}
|
|
814
|
+
if (!hit) return { reply: { ok: true, found: false, status: 404 }, bytes: new TextEncoder().encode("Not Found") };
|
|
815
|
+
return {
|
|
816
|
+
reply: { ok: true, found, status, type: hit.type, hash: hit.hash },
|
|
817
|
+
bytes: hit.body,
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
|
|
778
821
|
return { reply: await dispatchOnce(msg) };
|
|
779
822
|
}
|
|
780
823
|
|
package/src/build.ts
CHANGED
|
@@ -35,6 +35,13 @@ export type BuildInput = {
|
|
|
35
35
|
/** #15 — `embedded` compiles SQLite into the sprout instead of a broker
|
|
36
36
|
* transport. Defaults to the broker transport. */
|
|
37
37
|
transport?: Transport;
|
|
38
|
+
/**
|
|
39
|
+
* `dev` compiles at -O0, which is roughly three times faster and produces a
|
|
40
|
+
* bigger binary. Only for artifacts that cannot be deployed: `deploy` refuses
|
|
41
|
+
* a host build already, and this defaults to `release` so a caller has to ask
|
|
42
|
+
* for the fast path deliberately.
|
|
43
|
+
*/
|
|
44
|
+
optimize?: "dev" | "release";
|
|
38
45
|
};
|
|
39
46
|
|
|
40
47
|
export type BuildOutput = {
|
|
@@ -152,6 +159,7 @@ export async function buildArtifact(input: BuildInput): Promise<BuildOutput> {
|
|
|
152
159
|
assets: bakedAssets,
|
|
153
160
|
extraLink,
|
|
154
161
|
extraCflags,
|
|
162
|
+
optimize: input.optimize,
|
|
155
163
|
});
|
|
156
164
|
|
|
157
165
|
const sprout = await readFile(sproutPath);
|
package/src/compile.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
13
13
|
import { dirname, resolve } from "node:path";
|
|
14
14
|
import { ensurePorfforPatched } from "./patch-porffor";
|
|
15
|
-
import { ensureUWebSockets, porfforRoot, UwsUnavailableError } from "./toolchain";
|
|
15
|
+
import { ensureUWebSockets, ensureUWebSocketsHost, porfforRoot, UwsUnavailableError } from "./toolchain";
|
|
16
16
|
import {
|
|
17
17
|
EMPTY_BINDINGS,
|
|
18
18
|
preludePath,
|
|
@@ -54,6 +54,16 @@ export type CompileInput = {
|
|
|
54
54
|
extraLink?: string[];
|
|
55
55
|
/** #15 — flags for the compile step, so inline C can include BearSSL's header. */
|
|
56
56
|
extraCflags?: string[];
|
|
57
|
+
/**
|
|
58
|
+
* How hard the C compiler works on the generated code.
|
|
59
|
+
*
|
|
60
|
+
* Porffor defaults to `-O3` (compiler/index.js reads `-O` from its own argv),
|
|
61
|
+
* which costs most of the build: `examples/hello` is 8.4s at -O3 against 2.9s
|
|
62
|
+
* at -O0 on an M-series host. `dev` pays that on every edit for a binary that
|
|
63
|
+
* never leaves the machine, so it compiles at -O0 and takes a ~55% larger
|
|
64
|
+
* file. Anything that could be deployed stays at -O3.
|
|
65
|
+
*/
|
|
66
|
+
optimize?: "dev" | "release";
|
|
57
67
|
/** Cross-compiler for `linux-x86_64`. Not needed, and not used, for `host`. */
|
|
58
68
|
zigBin?: string;
|
|
59
69
|
/**
|
|
@@ -88,15 +98,42 @@ function compileEnv(path: string, extraLink?: string[], extraCflags?: string[])
|
|
|
88
98
|
return { ...process.env, PATH: path, SB_EXTRA_LINK: link, SB_EXTRA_CFLAGS: cflags };
|
|
89
99
|
}
|
|
90
100
|
|
|
101
|
+
/**
|
|
102
|
+
* The argument list handed to Porffor, minus the launcher.
|
|
103
|
+
*
|
|
104
|
+
* Exported for the test: the one thing worth pinning is that `-O0` reaches only
|
|
105
|
+
* a build that cannot be deployed. `-s` strips at link, because the unstripped
|
|
106
|
+
* static-musl binary is ~90% DWARF that nothing needs at runtime (12 MB down to
|
|
107
|
+
* ~1.3 MB for the kitchen-sink). `--musl` is what makes it a cross-compile; a
|
|
108
|
+
* host build omits it and Porffor targets the machine it runs on.
|
|
109
|
+
*/
|
|
110
|
+
export function porfforArgs(
|
|
111
|
+
generatedPath: string,
|
|
112
|
+
outPath: string,
|
|
113
|
+
target: CompileInput["target"],
|
|
114
|
+
optimize: CompileInput["optimize"],
|
|
115
|
+
): string[] {
|
|
116
|
+
const args = ["native", generatedPath, "-o", outPath];
|
|
117
|
+
if (target !== "host") args.push("--musl");
|
|
118
|
+
args.push("-s");
|
|
119
|
+
// Porffor reads -O from its own argv and defaults to -O3. -O0 is roughly
|
|
120
|
+
// three times faster to compile, so dev takes it and everything else does
|
|
121
|
+
// not: a deployable artifact is never built with it.
|
|
122
|
+
if (optimize === "dev" && target === "host") args.push("-O0");
|
|
123
|
+
return args;
|
|
124
|
+
}
|
|
125
|
+
|
|
91
126
|
/** Compile `sourcePath` to a native binary at `outPath` (mode 0555). */
|
|
92
127
|
export async function compileSprout(input: CompileInput): Promise<void> {
|
|
93
128
|
await ensurePorfforPatched();
|
|
94
129
|
|
|
95
130
|
// Seed the Porffor uWebSockets cache from the prebuilt archive in `vendor/` so
|
|
96
|
-
// the first build needs no `git` / `make`.
|
|
97
|
-
//
|
|
131
|
+
// the first build needs no `git` / `make`. The two targets keep separate
|
|
132
|
+
// cache trees and separate uSockets.a, so seed whichever this build wants.
|
|
133
|
+
// Fall back to Porffor's own git+make path if the archive is unusable.
|
|
98
134
|
try {
|
|
99
|
-
await
|
|
135
|
+
if (input.target === "host") await ensureUWebSocketsHost();
|
|
136
|
+
else await ensureUWebSockets();
|
|
100
137
|
} catch (error) {
|
|
101
138
|
if (!(error instanceof UwsUnavailableError)) throw error;
|
|
102
139
|
const haveGit = Bun.which("git");
|
|
@@ -149,14 +186,8 @@ export async function compileSprout(input: CompileInput): Promise<void> {
|
|
|
149
186
|
const zigDir = input.zigBin ? `${dirname(input.zigBin)}:` : "";
|
|
150
187
|
const path = `${zigDir}${binDir}:${process.env.PATH ?? ""}`;
|
|
151
188
|
|
|
152
|
-
// `-s`: strip at link. The unstripped static-musl binary is ~90% DWARF that
|
|
153
|
-
// nothing needs at runtime (12 MB -> ~1.3 MB for the kitchen-sink). Porffor
|
|
154
|
-
// forwards `-s` straight to the `zig cc` link step.
|
|
155
|
-
// `--musl` is what makes it a cross-compile; a host build simply omits it and
|
|
156
|
-
// Porffor targets the machine it is running on.
|
|
157
|
-
const crossFlags = input.target === "host" ? [] : ["--musl"];
|
|
158
189
|
const child = Bun.spawn(
|
|
159
|
-
[process.execPath, launcher,
|
|
190
|
+
[process.execPath, launcher, ...porfforArgs(generatedPath, input.outPath, input.target, input.optimize)],
|
|
160
191
|
{
|
|
161
192
|
cwd: outDir,
|
|
162
193
|
stdout: "pipe",
|
package/src/dev.ts
CHANGED
|
@@ -85,6 +85,8 @@ async function start(input: DevInput, source: string): Promise<Running> {
|
|
|
85
85
|
sourcePath: input.sourcePath,
|
|
86
86
|
source,
|
|
87
87
|
target: "host",
|
|
88
|
+
// Never deployable, rebuilt on every edit: buy the iteration loop.
|
|
89
|
+
optimize: "dev",
|
|
88
90
|
});
|
|
89
91
|
const artifactDir = artifact.artifactDir;
|
|
90
92
|
const sproutPath = resolve(artifactDir, "sprout");
|