Skip to content

feat(scripts): add deployments publish for rollbacks#92

Open
jamie-at-bunny wants to merge 4 commits into
mainfrom
feat/scripts-deployment-publish
Open

feat(scripts): add deployments publish for rollbacks#92
jamie-at-bunny wants to merge 4 commits into
mainfrom
feat/scripts-deployment-publish

Conversation

@jamie-at-bunny
Copy link
Copy Markdown
Member

No description provided.

@bogdan-at-bunny
Copy link
Copy Markdown

@codex review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 4, 2026

🦋 Changeset detected

Latest commit: 856415a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@bunny.net/cli Minor
@bunny.net/cli-linux-x64 Minor
@bunny.net/cli-linux-arm64 Minor
@bunny.net/cli-darwin-x64 Minor
@bunny.net/cli-darwin-arm64 Minor
@bunny.net/cli-windows-x64 Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread packages/cli/src/commands/scripts/deployments/publish.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e14d9ee6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cli/src/commands/scripts/deployments/publish.ts Outdated
Comment thread packages/cli/src/commands/scripts/deployments/publish.ts Outdated
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Jun 4, 2026

Greptile Summary

This PR adds bunny scripts deployments publish <release> — a rollback command that re-publishes a past release by ID without re-uploading code. It also consolidates duplicated hostname-fetching and display logic from deploy.ts and show.ts into shared helpers (fetchScriptHostnames, logLiveHostnames, findAcrossPages, liveHostnames) and upgrades the deployments list command to show full custom-domain URLs instead of just the zone's DefaultHostname.

  • New publish command walks paginated releases via findAcrossPages, validates the target release exists and is not deleted, prompts for confirmation (or --force), and prints the live URL after publishing.
  • Shared hostname helpers (fetchHostnamesForZones, liveHostnames) added to core/hostnames/client.ts and consumed across deploy.ts, show.ts, and both deployment subcommands.
  • deployments list now fetches full pull-zone hostnames for a richer "Live at:" display, though this introduces additional API calls that happen after the spinner has already stopped.

Confidence Score: 5/5

Safe to merge; the new publish command and hostname-consolidation refactor are correct, well-tested, and consistent with existing patterns.

The rollback command is logically sound, the shared hostname helpers are cleanly extracted and guarded, and the tests for findAcrossPages cover the key pagination edge cases. The only new finding is a cosmetic UX gap in list.ts where the hostname fetch happens after the spinner has stopped.

No files require special attention beyond the already-flagged issues in publish.ts and list.ts.

Important Files Changed

Filename Overview
packages/cli/src/commands/scripts/deployments/publish.ts New command for rolling back to a past release. Core flow is well-structured with release lookup, confirmation prompt, and post-publish hostname display. The publish API response is not inspected for errors (previously flagged).
packages/cli/src/commands/scripts/api.ts Adds shared helpers: findAcrossPages (paginated search), findRelease, fetchScriptHostnames, and logLiveHostnames. The custom-hostname fallback logic is correct; liveHostnames correctly separates primary from customs and the DefaultHostname fallback only fires when both are empty.
packages/cli/src/core/hostnames/client.ts Adds fetchHostnamesForZones (parallel, per-zone error-tolerant) and liveHostnames (picks system hostname as primary, returns custom-domain URLs). Both functions are clean and well-guarded.
packages/cli/src/commands/scripts/deployments/list.ts Upgraded to show full custom-domain hostname list instead of DefaultHostname only, but the extra API calls for hostnames happen after the spinner has stopped and the table is already rendered, creating a silent delay.
packages/cli/src/commands/scripts/deploy.ts Refactored to use shared fetchScript, fetchScriptHostnames, and logLiveHostnames helpers, replacing ~50 lines of inline logic with 3 clean calls. Behavior is preserved.
packages/cli/src/commands/scripts/api.test.ts New unit tests for findAcrossPages covering early-stop on match, exhaustive search returning undefined, and the empty-page guard against a misbehaving hasMore flag.
packages/cli/src/commands/scripts/show.ts Refactored hostname fetch loop to use the new fetchScriptHostnames helper. No behavioral change.
packages/cli/src/core/hostnames/index.ts Re-exports fetchHostnamesForZones and liveHostnames from client.ts. Straightforward barrel update.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as publish.ts
    participant Compute as Compute API
    participant Core as Core API

    User->>CLI: bunny scripts deployments publish 42 [id]
    CLI->>Compute: "GET /compute/script/{id}/releases (paginated)"
    Compute-->>CLI: releases page(s)
    CLI->>User: prompt: Publish release 42?
    User-->>CLI: yes
    CLI->>Compute: "POST /compute/script/{id}/publish/{uuid}"
    Compute-->>CLI: (response unchecked)
    CLI->>Compute: "GET /compute/script/{id}"
    Compute-->>CLI: script (with LinkedPullZones)
    CLI->>Core: "GET /pullzone/{id} (per linked zone, parallel)"
    Core-->>CLI: hostnames
    CLI->>User: Release 42 published. Live at: https://...
Loading

Fix All in Claude Code

Reviews (2): Last reviewed commit: "further refactoring" | Re-trigger Greptile

Comment thread packages/cli/src/commands/scripts/api.ts
Comment on lines +134 to +142
const pubSpin = spinner("Publishing...");
pubSpin.start();

await client.POST("/compute/script/{id}/publish/{uuid}", {
params: { path: { id, uuid: release.Uuid } },
body: {},
});

pubSpin.stop();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Publish API error is silently ignored

The response from the POST /compute/script/{id}/publish/{uuid} call is never inspected. If the API returns a 4xx or 5xx error, openapi-fetch does not throw — it returns { data: undefined, error: ... }. The spinner stops normally, and the code continues to print Release X published. (or { published: true } in JSON mode), even though the rollback never happened. Consider destructuring { error } from the response and throwing a UserError when it is truthy.

Fix in Claude Code

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.

2 participants