refactor: Move buildApp and buildStudio logic to cli-build package#1148
refactor: Move buildApp and buildStudio logic to cli-build package#1148snocorp wants to merge 7 commits into
Conversation
|
Claude finished @snocorp's task in 5m 42s —— View job Claude PR Review
Bugbot findings — statusAll three Cursor Bugbot findings have already been addressed in later commits on this branch:
Issues1. Dead
The actual driver of behavior is 2. Inconsistent The two new test files break the repo's
Neighboring tests ( 3. Changeset summary is incomplete (minor)
But the PR's primary change — described in the title and body — is moving Observations (not blocking)
|
📦 Bundle Stats —
|
| Metric | Value | vs main (87cd8f2) |
|---|---|---|
| Internal (raw) | 2.1 KB | - |
| Internal (gzip) | 799 B | - |
| Bundled (raw) | 10.97 MB | - |
| Bundled (gzip) | 2.06 MB | - |
| Import time | 818ms | +2ms, +0.2% |
bin:sanity
| Metric | Value | vs main (87cd8f2) |
|---|---|---|
| Internal (raw) | 1023 B | - |
| Internal (gzip) | 486 B | - |
| Bundled (raw) | 9.87 MB | - |
| Bundled (gzip) | 1.77 MB | - |
| Import time | 1.92s | +21ms, +1.1% |
🗺️ 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 (87cd8f26)
| Metric | Value | vs main (87cd8f2) |
|---|---|---|
| Internal (raw) | 96.3 KB | - |
| Internal (gzip) | 22.7 KB | - |
| Bundled (raw) | 21.64 MB | - |
| Bundled (gzip) | 3.43 MB | - |
| Import time | 782ms | +1ms, +0.1% |
🗺️ 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 (87cd8f26)
| Metric | Value | vs main (87cd8f2) |
|---|---|---|
| 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.
Coverage Delta
Comparing 17 changed files against main @ Overall Coverage
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 970cf61. Configure here.

Description
This PR finally allows us to build studios and apps from the runtime-cli. There may be a few tweaks needed once we integrate but this refactor covers the initial requirements.
What to review
Ensure I didn't refactor the tests in a way that makes them useless. Had to move a bunch of tests that relied on mocking that was no longer possible.
Testing
Lots of test changes but coverage should remain intact.
Note
Medium Risk
Large refactor of the build and auto-update prompt paths with a breaking change to
@sanity/cli-build/_internal/buildexports; risk is mitigated by relocated tests and thin CLI adapters, but runtime-cli integration still needs validation.Overview
Moves studio and app build orchestration from
@sanity/cliinto@sanity/cli-build, so the same paths can be reused (e.g. from runtime-cli) without going through Oclif flags.@sanity/clibuildApp/buildStudioare now thin wrappers: they map CLI config and flags into aBuildOptionsobject and call the internal implementations, including a newviteReactPluginFactoryso@vitejs/plugin-reactstays on the CLI side whilegetViteConfigonly receives abuildViteReactPlugincallback.The
@sanity/cli-build/_internal/buildsurface is narrowed (drops several helpers likebuildDebug,finalizeViteConfig, telemetry types, etc.) and addsbuildApp,buildStudio,checkRequiredDependencies, andcompareDependencyVersions(moved from CLI).buildStaticFilesstops re-exporting through_internaland takes injected env vars instead of hard-coded app/studio getters.Tests for auto-update prompts, version mismatches, and prerelease handling move from CLI command tests into
cli-buildintegration-style tests againstbuildApp/buildStudiodirectly; CLI build tests keep command-level coverage.cli-buildvitest gets worker globalSetup; dev server imports shared checks fromcli-build.Reviewed by Cursor Bugbot for commit ade3f12. Bugbot is set up for automated code reviews on this repo. Configure here.