Skip to content

feat(deploy): add --dry-run flag for instant deployability feedback#1255

Draft
gu-stav wants to merge 1 commit into
refactor/deploy-target-resolutionfrom
feat/deploy-dry-run
Draft

feat(deploy): add --dry-run flag for instant deployability feedback#1255
gu-stav wants to merge 1 commit into
refactor/deploy-target-resolutionfrom
feat/deploy-dry-run

Conversation

@gu-stav

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

Copy link
Copy Markdown
Member

Description

sanity deploy --dry-run answers "can this deploy" without deploying — a fast feedback loop for agents and CI. Stacked on #1254; it runs the same createStudioDeployment/createAppDeployment sequence read-only:

  • Target resolution returns a verdict instead of prompting or creating an application.
  • The schema worker validates and extracts without uploading, and still writes the create-manifest locally so the file list matches a real deploy.
  • The output directory is listed (with sizes) instead of packed.

Failures aggregate instead of bailing on the first, so one run reports every problem. It never prompts — would-prompt situations become failed checks with the fix in the message — and exits 2 when not deployable.

--json emits the {deployable, checks, target, files} report via oclif's enableJsonFlag. The exit code is set without throwing, so the full report still reaches stdout on failure.

The only new seam implementation is the aggregating checks collector; real deploys keep failing fast through the same steps, so a real deploy fails with the same message its dry run reports.

What to review

  • The dryRun branches in createStudioDeployment/createAppDeployment — target verdict, schema validate-only, output listing, title as a check.
  • The aggregating vs fail-fast adapters in deployChecks.
  • Check names and report shape — a machine contract for --json consumers.

Testing

deploy.dry-run.test.ts covers both deploy types: all-checks-pass with file listing, would-create hostname, aggregated failures with exit 2, --json output, and the would-prompt failure when no appId is configured.

@gu-stav gu-stav requested a review from a team as a code owner June 11, 2026 09:45
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against refactor/deploy-target-resolution (2a4579f9)

@sanity/cli

Metric Value vs refactor/deploy-target-resolution (2a4579f)
Internal (raw) 2.7 KB -
Internal (gzip) 1.0 KB -
Bundled (raw) 11.16 MB -
Bundled (gzip) 2.10 MB -
Import time 867ms +7ms, +0.8%

bin:sanity

Metric Value vs refactor/deploy-target-resolution (2a4579f)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.78 MB -
Import time 2.26s +17ms, +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 refactor/deploy-target-resolution (2a4579f9)

Metric Value vs refactor/deploy-target-resolution (2a4579f)
Internal (raw) 106.7 KB -
Internal (gzip) 26.7 KB -
Bundled (raw) 21.72 MB -
Bundled (gzip) 3.46 MB -
Import time 771ms +8ms, +1.0%

🗺️ 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-target-resolution (2a4579f9)

Metric Value vs refactor/deploy-target-resolution (2a4579f)
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 2 potential issues.

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 fa77286. Configure here.


static override description = 'Builds and deploys Sanity Studio or application to Sanity hosting'

static override enableJsonFlag = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Non-dry-run deploy exposes json flag

Medium Severity

enableJsonFlag applies to every sanity deploy invocation, but only the dry-run path returns a DryRunReport. A real deploy finishes with undefined, so --json advertises machine-readable output that is not defined for actual deployments.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fa77286. Configure here.

}

return report
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Custom output dir prompt skipped

Medium Severity

--dry-run returns before the logic that warns when a non-default sourceDir exists and is non-empty and would prompt to proceed. Dry-run can report deployable while a normal deploy would block or cancel on that confirmation.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fa77286. Configure here.

@gu-stav gu-stav marked this pull request as draft June 11, 2026 09:52
@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 51.9% (new)
packages/@sanity/cli/src/actions/deploy/listDeploymentFiles.ts 0.0% (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 7 changed files against main @ def5e11efbe0e7859a3e3b014d17b3e6425feb21

Overall Coverage

Metric Coverage
Statements 74.0% (- 0.3%)
Branches 63.9% (- 0.3%)
Functions 68.3% (- 0.5%)
Lines 74.6% (- 0.3%)

@gu-stav gu-stav force-pushed the refactor/deploy-target-resolution branch from faad45d to 6e348e6 Compare June 30, 2026 12:01
@gu-stav gu-stav force-pushed the feat/deploy-dry-run branch from 219e23f to ebf7c4a Compare June 30, 2026 12:16
@gu-stav gu-stav force-pushed the refactor/deploy-target-resolution branch from 6e348e6 to 074e2b7 Compare June 30, 2026 12:44
@gu-stav gu-stav force-pushed the feat/deploy-dry-run branch from ebf7c4a to dd385aa Compare June 30, 2026 12:44
@gu-stav gu-stav force-pushed the refactor/deploy-target-resolution branch from 074e2b7 to 17d7b54 Compare June 30, 2026 13:21
@gu-stav gu-stav force-pushed the feat/deploy-dry-run branch from dd385aa to e95da02 Compare June 30, 2026 13:21
`sanity deploy --dry-run` answers "can this deploy" without deploying — a
fast feedback loop for agents and CI. It runs the same createStudioDeployment /
createAppDeployment sequence read-only: target resolution returns a verdict
instead of prompting or creating, the schema worker validates and extracts
without uploading, and the output directory is listed instead of packed.

Failures aggregate so one run reports every problem, never prompts, and exits 2
when not deployable. `--json` emits the {deployable, checks, target, files}
report via oclif's enableJsonFlag, with the exit code set without throwing so
the full report still reaches stdout on failure.
@gu-stav gu-stav force-pushed the refactor/deploy-target-resolution branch from 17d7b54 to 2a4579f Compare June 30, 2026 13:42
@gu-stav gu-stav force-pushed the feat/deploy-dry-run branch from e95da02 to 9663058 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