Publish a static frontend as a Sui object without leaving Claude Code.
Port publish.sh to TypeScript: validate publish inputs, build the site-builder argv,
parse the site_object_id out of stdout, then construct the SuiNS link Move call that points a name at
the new site. Replaces the IPNS + Cloudflare gateway stack with one Sui object and one SuiNS transaction.
What you'll write
Two TypeScript modules — src/publish.ts (input validation, argv building, output parsing) and
src/suins-link.ts (the SuiNS Move call payload). Pure functions only; the vitest suite asserts on
return values without ever spawning a real CLI.
-
s01 · validate inputs
Validating publish inputs
The site-name regex
^[A-Za-z0-9._-]{1,64}$is a conservative-shell-safety hat.site-builderitself accepts almost anything, but the name flows through bash wrappers, CI logs, and (after linking) a SuiNS label — restricting it to filename-safe characters means no entry in the pipeline has to defend against quoting, control chars, or pathological lengths. -
s02 · build argv
Building the
site-builderargv--context <network>is a GLOBAL flag onsite-builder, not a subcommand flag — it must precedepublishin the argv. The function returns the argv as a string array (not a single shell-quoted string) so callers feed it toexecFile/spawn, which sidesteps shell injection on the site name. -
s03 · parse output
Parsing
site_object_idfrom stdoutAnchoring on the line shape (with the
mregex flag) rather than greedy text matching keeps the parser tolerant to upstream log changes — a future CLI version can rearrange the surrounding text without breaking us as long as the linesite_object_id: 0x<hex>survives. -
s04 · suins link
Building the SuiNS link Move call
One Sui Move call to
<suins-pkg>::controller::set_target_walrus_site, taking the NameRegistration object id and the site object id (in that order). Returning the payload as data —{ target, args }— instead of a builtTransactionlets the test assert on PTB shape without pulling in@mysten/sui, and lets the caller pick eithertx.moveCall(...)orsui client call.
Verification
Two vitest suites, 23 tests total. Run them inside the workspace:
pnpm install
pnpm vitest run
publish.test.ts (16) covers validation, argv layout, stdout parsing, and the MAX_EPOCHS=53 Walrus cap. suins-link.test.ts (7) pins the target string, arg order, network-keyed package id, and the package-id override path.
Sources
Read the reference-app on GitHub, or follow the design context on the upstream walkthrough.
- Reference-app: lessons/02-walrus-sites/reference-app/ — vitest workspace, no live network or CLI required.
- Lesson sections: lessons/02-walrus-sites/sections/ — the four section prompts.
- evm-sui walkthrough: 02-walrus-sites — Walrus Sites for dApp frontend hosting — the production-shape source the lesson teaches toward.
- Walrus Sites docs: Installing site-builder.