Skip to content

feat(cli): support unattended mode for media library commands#1502

Open
jonahsnider wants to merge 9 commits into
mainfrom
aigro-5168/unattended-media-library
Open

feat(cli): support unattended mode for media library commands#1502
jonahsnider wants to merge 9 commits into
mainfrom
aigro-5168/unattended-media-library

Conversation

@jonahsnider

@jonahsnider jonahsnider commented Jul 13, 2026

Copy link
Copy Markdown
Member

Description

Adds unattended-mode support for media library commands.

What to review

Review the flags, prompt handling, and automated coverage.

Testing


Note

Low Risk
CLI-only behavior changes with explicit opt-in via non-interactive runs; interactive flows are largely unchanged aside from clearer errors and delete cancel exit code.

Overview
Media library CLI commands now run in unattended mode (non-TTY / CI) without hanging on prompts, by requiring explicit flags and tightening destructive flows.

media create-aspect adds --title and --name; unattended runs must pass --title, and the aspect name defaults from the title when --name is omitted.

Deploy, import, export, and delete require --media-library-id when unattended. media export picks a default output path ({mediaLibraryId}-export.tar.gz in the cwd) instead of prompting. media delete-aspect in unattended mode also requires --yes; declining confirmation exits with USER_ABORT.

Several validation paths now use exitCodes.USAGE_ERROR instead of generic failure codes, with clearer usage messages. Tests cover unattended behavior via isInteractive: false.

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

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (fb5247ca)

@sanity/cli

Metric Value vs main (fb5247c)
Internal (raw) 2.2 KB -
Internal (gzip) 838 B -
Bundled (raw) 11.20 MB -
Bundled (gzip) 2.11 MB -
Import time 891ms -43ms, -4.6%

bin:sanity

Metric Value vs main (fb5247c)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.90 MB -
Bundled (gzip) 1.78 MB -
Import time 2.32s -71ms, -3.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 — @sanity/cli-core

Compared against main (fb5247ca)

Metric Value vs main (fb5247c)
Internal (raw) 113.4 KB -
Internal (gzip) 29.0 KB -
Bundled (raw) 21.76 MB -
Bundled (gzip) 3.46 MB -
Import time 810ms +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 — @sanity/cli-build

Compared against main (fb5247ca)

@sanity/cli-build/_internal/build

Metric Value vs main (fb5247c)
Internal (raw) 113.8 KB -
Internal (gzip) 28.7 KB -
Bundled (raw) 18.10 MB -
Bundled (gzip) 3.64 MB -
Import time 1.41s +41ms, +3.0%

@sanity/cli-build/_internal/env

Metric Value vs main (fb5247c)
Internal (raw) 1.8 KB -
Internal (gzip) 644 B -
Bundled (raw) 1.31 MB -
Bundled (gzip) 333.8 KB -
Import time 127ms +2ms, +1.8%

@sanity/cli-build/_internal/extract

Metric Value vs main (fb5247c)
Internal (raw) 8.6 KB -
Internal (gzip) 2.7 KB -
Bundled (raw) 155.0 KB -
Bundled (gzip) 39.5 KB -
Import time 250ms +3ms, +1.1%

🗺️ ./_internal/env · ./_internal/extract · @sanity/cli-build:./_internal/build treemap too large to embed · 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 (fb5247ca)

Metric Value vs main (fb5247c)
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 13, 2026

Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/cli/src/commands/media/create-aspect.ts 100.0% (±0%)
packages/@sanity/cli/src/commands/media/delete-aspect.ts 100.0% (±0%)
packages/@sanity/cli/src/commands/media/deploy-aspect.ts 97.0% (+ 0.1%)
packages/@sanity/cli/src/commands/media/export.ts 78.8% (+ 0.5%)
packages/@sanity/cli/src/commands/media/import.ts 91.8% (+ 0.3%)

Comparing 5 changed files against main @ fb5247cab0aff4f51b806a7cc6b9fcff005682de

Overall Coverage

Metric Coverage
Statements 78.0% (+ 0.0%)
Branches 69.7% (+ 0.1%)
Functions 73.7% (±0%)
Lines 78.5% (+ 0.0%)

@jonahsnider
jonahsnider marked this pull request as ready for review July 14, 2026 05:16
@jonahsnider
jonahsnider requested a review from a team as a code owner July 14, 2026 05:16
Comment thread packages/@sanity/cli/src/commands/media/delete-aspect.ts Outdated
@jonahsnider
jonahsnider changed the base branch from main to aigro-5168/unattended-datasets-advanced July 16, 2026 01:58
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-media-library branch from 0d8eb00 to 851cc0f Compare July 16, 2026 01:58

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

Comment thread packages/@sanity/cli/src/actions/init/initAction.ts
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-media-library branch from 851cc0f to eea8beb Compare July 16, 2026 02:05
shapirodaniel
shapirodaniel previously approved these changes Jul 16, 2026
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-media-library branch from eea8beb to f1f697f Compare July 17, 2026 00:50
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-datasets-advanced branch from 1f81861 to 20e7797 Compare July 17, 2026 00:50
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-media-library branch from f1f697f to 8def726 Compare July 17, 2026 15:34
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-datasets-advanced branch from 20e7797 to 448dc5a Compare July 17, 2026 15:34
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-datasets-advanced branch from 448dc5a to 7450444 Compare July 17, 2026 15:54
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-media-library branch from 8def726 to 569bdfd Compare July 17, 2026 15:54
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-media-library branch from 569bdfd to 7f5aecb Compare July 17, 2026 16:02
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-datasets-advanced branch from 7450444 to ebb3dc3 Compare July 17, 2026 16:02
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-media-library branch from 7f5aecb to f132d2d Compare July 17, 2026 17:51
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-datasets-advanced branch from ebb3dc3 to 0414913 Compare July 17, 2026 17:51
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-media-library branch from f132d2d to 84f42b2 Compare July 17, 2026 21:05
@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-datasets-advanced branch from 0414913 to 5f3db70 Compare July 17, 2026 21:06
Base automatically changed from aigro-5168/unattended-datasets-advanced to main July 17, 2026 21:18
@jonahsnider
jonahsnider dismissed shapirodaniel’s stale review July 17, 2026 21:18

The base branch was changed.

@jonahsnider
jonahsnider force-pushed the aigro-5168/unattended-media-library branch from 84f42b2 to 46d3a8b Compare July 17, 2026 21:24
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