Skip to content

refactor: move compareDependencyVersions into cli-build#1466

Open
snocorp wants to merge 1 commit into
mainfrom
cli-build-compare-dependency-versions-2
Open

refactor: move compareDependencyVersions into cli-build#1466
snocorp wants to merge 1 commit into
mainfrom
cli-build-compare-dependency-versions-2

Conversation

@snocorp

@snocorp snocorp commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

During the integration of cli-build into the runtime cli, I realized that while it's nice to be able to inject this logic, we can't avoid running it when doing a blueprints deployment. This means we need to be able to access it from the cli-build project. The change is fairly small in impact and will allow me to continue integration.

Testing

Updated mocks as needed.


Note

Medium Risk
Major cli-build export changes (removed getModuleUrl, new compareDependencyVersions export) could break internal consumers; runtime behavior of version comparison should be unchanged but package boundaries shifted.

Overview
compareDependencyVersions (and its types) now live in @sanity/cli-build and are re-exported from @sanity/cli-build/_internal/build, so blueprints/deploy paths inside cli-build can run the same auto-update version checks without duplicating logic in @sanity/cli.

@sanity/cli build/dev actions import that helper from cli-build instead of src/util/compareDependencyVersions. The implementation stops importing getModuleUrl through the internal build barrel (local import from getAutoUpdatesImportMap instead), and getModuleUrl is dropped from the _internal/build public surface. The separate compareDependencyVersions.d.ts shim is removed in favor of in-module types.

Tests and integration coverage are retargeted to mock/import from @sanity/cli-build/_internal/build, with some Vitest import()-style mocks and shared @sanity/cli-test UX mocks. Changeset: @sanity/cli-build major, @sanity/cli patch.

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

@snocorp snocorp self-assigned this Jul 9, 2026
@snocorp snocorp requested a review from a team as a code owner July 9, 2026 20:29
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (2287ca1d)

@sanity/cli

Metric Value vs main (2287ca1)
Internal (raw) 2.2 KB -
Internal (gzip) 838 B -
Bundled (raw) 11.16 MB -
Bundled (gzip) 2.10 MB -
Import time 674ms +2ms, +0.3%

bin:sanity

Metric Value vs main (2287ca1)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.78 MB -
Import time 1.74s -9ms, -0.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 — @sanity/cli-core

Compared against main (2287ca1d)

Metric Value vs main (2287ca1)
Internal (raw) 108.1 KB -
Internal (gzip) 27.0 KB -
Bundled (raw) 21.72 MB -
Bundled (gzip) 3.46 MB -
Import time 602ms -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 (2287ca1d)

Metric Value vs main (2287ca1)
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 Jul 9, 2026

Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/cli-build/src/util/compareDependencyVersions.ts 100.0% (new)
packages/@sanity/cli/src/actions/build/buildApp.ts 77.8% (±0%)
packages/@sanity/cli/src/actions/build/buildStudio.ts 70.0% (±0%)
packages/@sanity/cli/src/actions/dev/servers/startStudioDevServer.ts 96.7% (±0%)

Comparing 4 changed files against main @ 2287ca1d4ecc3a0650480e8f1746ddc022456691

Overall Coverage

Metric Coverage
Statements 74.6% (±0%)
Branches 64.4% (±0%)
Functions 69.5% (±0%)
Lines 75.0% (±0%)

@filmaj filmaj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Integration tests are failing - I am happy to pair with you on that, review them, and I hope some of them can be dropped. I have a good sense of unit test coverage on these functions. Also I think a couple of cli-core mocks in this PR are unnecessary.


vi.mock('@sanity/cli-core', async (importOriginal) => {
const actual = await importOriginal<typeof import('@sanity/cli-core')>()
vi.mock(import('@sanity/cli-core'), async (importOriginal) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This cli-core mock and the next one can be dropped - we don't import these in the cli buildApp anymore (since those imports moved to cli-build)


vi.mock('@sanity/cli-core', async (importOriginal) => {
const actual = await importOriginal<typeof import('@sanity/cli-core')>()
vi.mock(import('@sanity/cli-core'), async (importOriginal) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here, these cli-core mocks are no longer needed

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.

2 participants