Skip to content

refactor: move internal build logic to cli-build package#1412

Open
snocorp wants to merge 2 commits into
mainfrom
cli-build-app-studio
Open

refactor: move internal build logic to cli-build package#1412
snocorp wants to merge 2 commits into
mainfrom
cli-build-app-studio

Conversation

@snocorp

@snocorp snocorp commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Description

This is the last PR needed before integrating the build logic into the runtime CLI. The logic for building studios and apps has been ported to the cli-build package.

Note

This is a breaking change for the cli-build package as it removed some un used exports. The cli package is the only dependent of the cli-build package so this is a safe bump.

Testing

Tests were ported or updated as needed. Note that I did not port the buildStaticFiles test as it requires a fixture that is not available in the cli-build package and would add a lot of complexity just for that one test suite if ported.


Note

Medium Risk
Large refactor of the build command path; behavior is intended to be preserved via ported tests, but @sanity/cli-build is a breaking major for internal export consumers.

Overview
Moves the full studio and app build orchestration from @sanity/cli into @sanity/cli-build, so the runtime CLI can call the same paths without duplicating Vite/auto-updates logic.

buildApp and buildStudio now live in cli-build with a flag-free BuildOptions API—CLI actions only map cliConfig/flags and inject CLI-specific hooks (checkAppId, compareDependencyVersions, upgradePackages, determineBasePath). @sanity/cli-build/_internal/build is updated accordingly (major: drops some unused exports, adds buildApp/buildStudio and shared compare types).

Tests for build behavior move to cli-build (injected deps); CLI keeps thinner appId-warning tests that mock the internal builders.

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

@snocorp snocorp self-assigned this Jun 30, 2026
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (65e9ebfc)

@sanity/cli

Metric Value vs main (65e9ebf)
Internal (raw) 2.7 KB -
Internal (gzip) 1.0 KB -
Bundled (raw) 11.16 MB -
Bundled (gzip) 2.10 MB -
Import time 827ms -12ms, -1.4%

bin:sanity

Metric Value vs main (65e9ebf)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.78 MB -
Import time 2.14s -65ms, -2.9%

🗺️ 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 (65e9ebfc)

Metric Value vs main (65e9ebf)
Internal (raw) 106.7 KB -
Internal (gzip) 26.7 KB -
Bundled (raw) 21.72 MB -
Bundled (gzip) 3.46 MB -
Import time 708ms -26ms, -3.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 — create-sanity

Compared against main (65e9ebfc)

Metric Value vs main (65e9ebf)
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

Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/cli-build/src/actions/build/buildApp.ts 93.8% (new)
packages/@sanity/cli-build/src/actions/build/buildStudio.ts 94.0% (new)
packages/@sanity/cli-build/src/actions/build/handlePrereleaseVersions.ts 100.0% (new)
packages/@sanity/cli/src/actions/build/buildApp.ts 77.8% (- 16.7%)
packages/@sanity/cli/src/actions/build/buildStudio.ts 70.0% (- 24.7%)
packages/@sanity/cli/src/util/compareDependencyVersions.ts 100.0% (±0%)

Comparing 6 changed files against main @ 65e9ebfcedf7ff617c644cf382fdec4651260eb6

Overall Coverage

Metric Coverage
Statements 73.4% (- 0.9%)
Branches 63.5% (- 0.7%)
Functions 67.0% (- 1.7%)
Lines 74.0% (- 0.9%)

@snocorp snocorp marked this pull request as ready for review June 30, 2026 21:01
@snocorp snocorp requested a review from a team as a code owner June 30, 2026 21:01
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