Skip to content

refactor(deploy): restructure studio deploy on the shared deploy checks#1407

Open
gu-stav wants to merge 5 commits into
refactor/deploy-coreappfrom
refactor/deploy-studio
Open

refactor(deploy): restructure studio deploy on the shared deploy checks#1407
gu-stav wants to merge 5 commits into
refactor/deploy-coreappfrom
refactor/deploy-studio

Conversation

@gu-stav

@gu-stav gu-stav commented Jun 30, 2026

Copy link
Copy Markdown
Member

Description

Second of two PRs splitting the deploy refactor; builds on the core app PR (#1406). This one restructures the studio deploy onto the shared scaffolding introduced there.

deployStudio now runs through a single createStudioDeployment using the same checks seam, with studio target resolution added alongside the app rules (it subsumes the inline host/URL validation). With both deploy paths refactored, the two interactive "find application" adapters collapse into one module and the two "create application" helpers into another.

No behavior change — this is a restructure.

What to review

  • createStudioDeployment against the old deployStudio: prompts, spinners, error messages and exit codes should be unchanged.
  • The merged findUserApplication / createUserApplication modules and the studio target resolution in resolveDeployTarget.

Testing

The integration deploy tests pass unchanged.


Note

Medium Risk
Large refactor of user-facing sanity deploy flows for studios and apps; risk is mitigated by claimed behavior parity and added unit tests, but regressions in prompts, exit codes, or host resolution are still possible.

Overview
Restructures studio deploy (and aligns app deploy) on the shared scaffolding from the prior refactor: both entry points now go through runDeploy with a fail-fast CheckReporter, shared package-version / auto-updates / build / output verification checks, and centralized error handling in deployRunner.

Studio target resolution moves into resolveStudioDeployTarget (including --url / studioHost validation and appId precedence), with a matching read-only checkStudioTarget for dry runs. The old per-type helpers are collapsed into findUserApplication (app + studio interactive resolution) and createUserApplication (core app + studio creation).

Unit tests cover studio target resolution guards and checkStudioTarget verdict mapping; integration deploy tests are unchanged per the PR description.

Reviewed by Cursor Bugbot for commit ab3c200. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against refactor/deploy-coreapp (cb42bf23)

@sanity/cli

Metric Value vs refactor/deploy-coreapp (cb42bf2)
Internal (raw) 2.7 KB -
Internal (gzip) 1.0 KB -
Bundled (raw) 11.16 MB -
Bundled (gzip) 2.10 MB -
Import time 925ms +48ms, +5.5%

bin:sanity

Metric Value vs refactor/deploy-coreapp (cb42bf2)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.78 MB -
Import time 970ms +43ms, +4.6%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — @sanity/cli-core

Compared against refactor/deploy-coreapp (cb42bf23)

Metric Value vs refactor/deploy-coreapp (cb42bf2)
Internal (raw) 106.7 KB -
Internal (gzip) 26.7 KB -
Bundled (raw) 21.72 MB -
Bundled (gzip) 3.46 MB -
Import time 811ms +27ms, +3.4%

🗺️ View treemap · Artifacts

Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

📦 Bundle Stats — create-sanity

Compared against refactor/deploy-coreapp (cb42bf23)

Metric Value vs refactor/deploy-coreapp (cb42bf2)
Internal (raw) 908 B -
Internal (gzip) 483 B -
Bundled (raw) 931 B -
Bundled (gzip) 491 B -
Import time ❌ ChildProcess denied: node -
Details
  • Import time regressions over 10% are flagged with ⚠️
  • Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/cli/src/actions/build/shouldAutoUpdate.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/deploy/deployChecks.ts 71.0% (new)
packages/@sanity/cli/src/actions/deploy/resolveDeployTarget.ts 57.1% (new)
packages/@sanity/cli/src/actions/manifest/extractCoreAppManifest.ts 94.4% (+ 0.5%)
packages/@sanity/cli/src/util/errorMessages.ts 100.0% (±0%)
packages/@sanity/workbench-cli/src/actions/deploy/checkBuiltOutput.ts 100.0% (new)
packages/@sanity/workbench-cli/src/actions/deploy/getWorkbench.ts 87.5% (- 12.5%)
packages/@sanity/workbench-cli/src/actions/deploy/viewDeployment.ts 66.7% (new)

Comparing 8 changed files against main @ e56340aea13282b039ed01625801c5268fee9964

Overall Coverage

Metric Coverage
Statements 74.2% (- 0.2%)
Branches 64.2% (- 0.2%)
Functions 68.8% (- 0.1%)
Lines 74.8% (- 0.3%)

@gu-stav gu-stav force-pushed the refactor/deploy-coreapp branch from 40e56d8 to baf39fd Compare June 30, 2026 14:47
@gu-stav gu-stav force-pushed the refactor/deploy-studio branch from 03ca34d to 5ba5e26 Compare June 30, 2026 14:48
@gu-stav gu-stav force-pushed the refactor/deploy-coreapp branch from baf39fd to 9260e52 Compare June 30, 2026 14:54
@gu-stav gu-stav force-pushed the refactor/deploy-studio branch from 5ba5e26 to 6dddb52 Compare June 30, 2026 14:57
@gu-stav gu-stav force-pushed the refactor/deploy-coreapp branch from 9260e52 to 2ba1b26 Compare June 30, 2026 15:11
@gu-stav gu-stav force-pushed the refactor/deploy-studio branch from 6dddb52 to 847bdf1 Compare June 30, 2026 15:11
@gu-stav gu-stav force-pushed the refactor/deploy-coreapp branch from 2ba1b26 to 9e824bc Compare June 30, 2026 15:15
@gu-stav gu-stav force-pushed the refactor/deploy-studio branch from 847bdf1 to 63a81c2 Compare June 30, 2026 15:16
@gu-stav gu-stav force-pushed the refactor/deploy-coreapp branch from 9e824bc to 26139a7 Compare June 30, 2026 15:48
@gu-stav gu-stav force-pushed the refactor/deploy-studio branch from 63a81c2 to 819d4d1 Compare June 30, 2026 15:51
@gu-stav

This comment was marked as outdated.

@squiggler-app

This comment was marked as outdated.

@gu-stav gu-stav force-pushed the refactor/deploy-studio branch from 819d4d1 to 224aef2 Compare July 1, 2026 08:41
@gu-stav gu-stav marked this pull request as ready for review July 1, 2026 08:56
@gu-stav gu-stav requested a review from a team as a code owner July 1, 2026 08:56
Comment thread packages/@sanity/cli/src/actions/deploy/resolveDeployTarget.ts Outdated
@gu-stav gu-stav force-pushed the refactor/deploy-studio branch from 224aef2 to fab52aa Compare July 1, 2026 09:06
@gu-stav gu-stav force-pushed the refactor/deploy-studio branch 5 times, most recently from bf39e53 to e7375aa Compare July 2, 2026 07:13

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e7375aa. Configure here.

Comment thread packages/@sanity/cli/src/actions/deploy/deployStudio.ts
@gu-stav gu-stav force-pushed the refactor/deploy-coreapp branch from 1a67719 to cb42bf2 Compare July 2, 2026 08:05
gu-stav added 2 commits July 2, 2026 10:05
Builds on the core app refactor: deployStudio now runs through a single
createStudioDeployment using the shared checks seam, with studio target
resolution (resolveStudioDeployTarget) and the studio target check added to the
shared modules.

With both deploy paths refactored, the two interactive adapters merge into one
findUserApplication module and the two creators into createUserApplication, and
cannotPromptForStudioHost gets one home. deployStudio carries the tightened
seams through: it asks getWorkbench for an isWorkbenchApp boolean, and the
studio target models isExternal as its own field.

No behavior change — the integration deploy tests pass unchanged.
gu-stav added 3 commits July 2, 2026 10:05
…cation

The switch's own output.error({exit}) calls were thrown inside the broad
try/catch, which re-wrapped them via output.error(error) with oclif's default
exit 2 — masking the intended exit codes. Scope the try to just the deploy
target fetch (mirroring findUserApplicationForStudio) so intentional exits
surface as thrown.
Both flows now drive a single runDeploy skeleton (fail-fast reporter + one
normalized error handler) and read as the same top-to-bottom sequence of
reported steps, with the ship/title/schema work pulled into named helpers.
Removes the drift between the two deploy paths and their error handling.
Populates `solution` for the remaining blockers: missing organization/project id,
external-host misuse, an unresolved studio/app target, and a non-deployable
federated app. The dry-run report lists each under its problem.
@gu-stav gu-stav force-pushed the refactor/deploy-studio branch from e7375aa to ab3c200 Compare July 2, 2026 08:07
@gu-stav gu-stav requested review from joshuaellis and snocorp July 2, 2026 08:18
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