Skip to content

refactor(deploy): extract deploy target resolution and auto-update rules#1254

Draft
gu-stav wants to merge 1 commit into
mainfrom
refactor/deploy-target-resolution
Draft

refactor(deploy): extract deploy target resolution and auto-update rules#1254
gu-stav wants to merge 1 commit into
mainfrom
refactor/deploy-target-resolution

Conversation

@gu-stav

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

Copy link
Copy Markdown
Member

Description

The studio and app deploy commands had grown into long, interleaved functions — validation, prompting, building, schema upload, packaging and reporting all in one body. Hard to follow, and impossible to reuse for a read-only check.

Each deploy now runs through a single createStudioDeployment / createAppDeployment that validates, prepares and ships the deployment, reporting through a checks seam — so the commands read as one clear call, and the same sequence can back a read-only --dry-run (follow-up #1255).

Consolidate the deploy modules into logical homes:

  • deployChecks owns the checks seam, the shared step helpers, and the verdict→target mapping (checkStudioTarget/checkAppTarget).
  • resolveDeployTarget owns the verdicts — it already held the --url/studioHost/appId precedence and external-URL validation, so it supersedes the inline resolveAppHost.
  • findUserApplication merges the two interactive adapters; createUserApplication merges the two interactive creators.
  • Auto-update rules get one home in resolveAutoUpdates/getAutoUpdateIssueMessage.

Move workbench-specific validation out of the CLI: viewDeployment goes into @sanity/workbench-cli, exposed through the workbench object.

No behavior change for real deploys.

What to review

  • createStudioDeployment/createAppDeployment against the previous flow — prompts, spinners, error messages and exit codes should be unchanged.
  • The consolidated findUserApplication/createUserApplication modules and the verdict→target mapping in deployChecks.
  • viewDeployment now living in @sanity/workbench-cli.

Testing

The integration deploy tests pass unchanged. New unit tests cover the checks seam and the verdict→target mapping.

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (def5e11e)

@sanity/cli

Metric Value vs main (def5e11)
Internal (raw) 2.7 KB -
Internal (gzip) 1.0 KB -
Bundled (raw) 11.16 MB -
Bundled (gzip) 2.10 MB -
Import time 861ms -1ms, -0.1%

bin:sanity

Metric Value vs main (def5e11)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.78 MB -
Import time 2.22s -18ms, -0.8%

🗺️ 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 main (def5e11e)

Metric Value vs main (def5e11)
Internal (raw) 106.7 KB -
Internal (gzip) 26.7 KB -
Bundled (raw) 21.72 MB -
Bundled (gzip) 3.46 MB -
Import time 764ms -11ms, -1.5%

🗺️ 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 main (def5e11e)

Metric Value vs main (def5e11)
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.

@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 faad45d. Configure here.

reason: 'app-not-found',
type: 'invalid',
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

appId beaten by host validation

Medium Severity

For external studio deploys, resolveStudioDeployTarget normalizes and validates studioHost before it looks up deployment.appId. A stale or invalid studioHost can trigger invalid-host even when appId would resolve an existing application, which breaks the intended appId-over-host precedence.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit faad45d. Configure here.

@github-actions

github-actions Bot commented Jun 11, 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 58.3% (new)
packages/@sanity/cli/src/actions/manifest/extractCoreAppManifest.ts 86.1% (- 7.8%)
packages/@sanity/cli/src/util/errorMessages.ts 100.0% (±0%)
packages/@sanity/workbench-cli/src/actions/deploy/getWorkbench.ts 94.1% (- 5.9%)
packages/@sanity/workbench-cli/src/actions/deploy/viewDeployment.ts 66.7% (new)

Comparing 6 changed files against main @ def5e11efbe0e7859a3e3b014d17b3e6425feb21

Overall Coverage

Metric Coverage
Statements 74.2% (- 0.1%)
Branches 64.0% (- 0.2%)
Functions 68.6% (- 0.2%)
Lines 74.8% (- 0.1%)

@gu-stav gu-stav marked this pull request as draft June 30, 2026 11:13
@gu-stav gu-stav force-pushed the refactor/deploy-target-resolution branch 3 times, most recently from 074e2b7 to 17d7b54 Compare June 30, 2026 13:21
The studio and app deploy commands had grown into long, interleaved
functions. Each deploy now runs through a single createStudioDeployment /
createAppDeployment that validates, prepares and ships the deployment,
reporting through a checks seam, so the commands read as one clear call.

Consolidate the deploy modules into logical homes:

- deployChecks owns the checks seam, the shared step helpers and the
  verdict→target mapping (checkStudioTarget/checkAppTarget). resolveDeployTarget
  owns the verdicts — it already held the --url/studioHost/appId precedence and
  external-URL validation, so it supersedes the inline resolveAppHost.
- findUserApplication merges the two interactive adapters; createUserApplication
  merges the two interactive creators.
- Auto-update rules get one home in resolveAutoUpdates/getAutoUpdateIssueMessage.

Move workbench-specific validation out of the CLI: viewDeployment goes into
@sanity/workbench-cli, exposed through the workbench object.

No behavior change for real deploys — the integration deploy tests pass
unchanged.
@gu-stav gu-stav force-pushed the refactor/deploy-target-resolution branch from 17d7b54 to 2a4579f Compare June 30, 2026 13:42
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