Skip to content

client: add upload progress callback to PublishSite#118

Merged
acoshift merged 1 commit into
mainfrom
site-progress
Jun 26, 2026
Merged

client: add upload progress callback to PublishSite#118
acoshift merged 1 commit into
mainfrom
site-progress

Conversation

@acoshift

Copy link
Copy Markdown
Member

What

Adds an optional Progress func(SitePublishProgress) callback to client.SitePublishOptions, plus a SitePublishProgress struct, so CLI/MCP callers can render an upload progress bar for PublishSite.

The callback is invoked once up front (Done == 0, with the final Total file count and BytesTotal) and once after each file is processed, carrying running Uploaded/Skipped/BytesDone counts and the current request path. A nil callback is a no-op, so existing callers are unaffected.

How

To give the callback a real Total up front, PublishSite now walks the directory in two passes:

  1. collect the regular files (and their sizes) — this also lets an empty publish fail without a server round-trip;
  2. open the upload session and upload each file as before.

The Files / Uploaded / Skipped counting semantics are preserved exactly (including duplicate-content-within-run dedup and the "no files" error).

Consumer

The deploys CLI uses this to render an upload progress bar for site publish / site deploy / site preview (separate PR, which re-pins to this commit).

PublishSite now accepts an optional Progress callback on SitePublishOptions
so CLI/MCP callers can render an upload progress bar. The callback is invoked
once up front (Done 0 of Total, with the total file count and byte size) and
once after each file is processed, carrying running uploaded/skipped/bytes
counts and the current request path.

To give the callback a real Total up front, PublishSite now walks the
directory in two passes: it first collects the regular files (and their
sizes), then opens the session and uploads. Collecting first also lets an
empty publish fail without a server round-trip. The callback defaults to a
no-op, so existing callers are unaffected.
@acoshift acoshift merged commit 3aeaedf into main Jun 26, 2026
@acoshift acoshift deleted the site-progress branch June 26, 2026 15:35
acoshift added a commit to deploys-app/deploys that referenced this pull request Jun 26, 2026
acoshift added a commit to deploys-app/deploys that referenced this pull request Jun 26, 2026
* site: add `site deploy` and an upload progress bar

`site deploy` publishes a local directory and deploys it as a permanent
(non-TTL) Static deployment in one command, then prints the deployment
(url + releaseUrl). It is the permanent counterpart of `site preview`:
the differences are that the release environment defaults to production
and that it clears any TTL (so a same-named throwaway preview is promoted
to a non-expiring deployment). `site publish` is unchanged and still just
prints a site:// ref, keeping it composable.

publish/deploy/preview now share a deployPublishedStatic helper, and all
three render a single-line upload progress bar while files upload. The bar
is driven by the new PublishSite Progress callback, drawn on stderr (so it
never corrupts -output json/yaml on stdout), and suppressed when stderr is
not a terminal (pipes, redirects, CI). ASCII-only and TTY-detected via the
char-device mode bit, so no new dependency.

Re-pins github.com/deploys-app/api to the commit adding the Progress
callback (deploys-app/api#118).

* go.mod: re-pin api to main after deploys-app/api#118 merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant