fix(cli): reject --media renderers invalid for the chosen --preset#1756
Closed
decepulis wants to merge 1 commit into
Closed
fix(cli): reject --media renderers invalid for the chosen --preset#1756decepulis wants to merge 1 commit into
decepulis wants to merge 1 commit into
Conversation
The docs `--media` flag validated only that a renderer was known, not that it was valid for the resolved use case, so the non-interactive flag path could emit nonsensical combos (e.g. `--preset audio --media dash`). The interactive prompt was already safe because it builds its renderer list from `VALID_RENDERERS[useCase]`. Add a post-resolution guard in `handleDocs` that rejects a renderer not in `VALID_RENDERERS[useCase]`, reusing `isRendererValidForUseCase` from `detect-renderer.ts` (added to the CLI's `site-modules.d.ts` shim). This brings the CLI to parity with the UI's constraint. Closes #1749. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YBzZSgYohPBiwUXBGGRS7o
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📦 Bundle Size Report🎨 @videojs/html — no changesPresets (7)
Media (10)
Players (5)
Skins (30)
UI Components (38)
Sizes are marginal over the root entry point. ⚛️ @videojs/react — no changesPresets (7)
Media (9)
Skins (27)
UI Components (32)
Sizes are marginal over the root entry point. 🧩 @videojs/core — no changesEntries (14)
🏷️ @videojs/element — no changesEntries (2)
📦 @videojs/store — no changesEntries (3)
🔧 @videojs/utils — no changesEntries (10)
📦 @videojs/spf — no changesEntries (4)
ℹ️ How to interpretJS sizes are initial static graph totals (minified + brotli). Lazy dynamic chunks are shown separately when present.
Run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1749.
Problem
The
@videojs/cli docs how-to/installationcommand's--mediaflag validated only that the value was a known renderer — not that the renderer is valid for the chosen--preset(use case). The docs UI enforces this (its renderer dropdown is built fromVALID_RENDERERS[useCase]viabuildOptions(useCase)), so the CLI's non-interactive flag path could produce renderer/use-case combinations the UI can never generate, e.g.:— a nonsensical DASH video element inside an audio player. The interactive prompt was already safe because it builds its options from
buildOptions(useCase); only the explicit--mediaflag bypassed the constraint.This was pre-existing (you could already run
--preset audio --media hls); #1732 only widened the accepted--mediaset, so this is not a regression introduced there.Fix
After the use case and renderer are resolved in
handleDocs, reject a--mediavalue not inVALID_RENDERERS[useCase], reusing the already-exportedisRendererValidForUseCasefromdetect-renderer.ts(added to the CLI'ssite-modules.d.tsshim). The error names the offending renderer, the preset, and the valid options:This brings the CLI to parity with the UI's constraint — "CLI for robots, UI for humans — same experience."
Changes
packages/cli/src/commands/docs.ts— post-resolution guard + aPRESET_NAMESreverse map for the message; importisRendererValidForUseCaseandVALID_RENDERERS.packages/cli/src/site-modules.d.ts— add theisRendererValidForUseCasesignature to thedetect-renderershim.packages/cli/src/commands/tests/docs.test.ts— two new tests covering invalid combos (dash+ audio,mux-audio+ video).Verification
pnpm -F @videojs/cli test— 64 tests pass (incl. the 2 new ones; these exercise the real site modules via aliases, not mocks).tsc --noEmit); changed files lint clean.pnpm check:workspace— 7/7 passed.🤖 Generated with Claude Code
Generated by Claude Code