Skip to content

Conversation

@valentinpalkovic
Copy link
Contributor

@valentinpalkovic valentinpalkovic commented Nov 26, 2025

Closes #

What I did

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Bug Fixes

    • Standardized CLI info text color to cyan across platforms.
    • Updated displayed command strings in prompts and messages to use package-manager-specific formats.
  • New Features

    • Prompts now show package-runner commands tailored to the user's package manager.
  • Style

    • Minor text casing change in installation prompts.
    • Simplified telemetry notification wording.
    • Refined recommended installation label wording.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 26, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Adds an abstract getPackageCommand(args: string[]) to JsPackageManager, implements it in NPM/PNPM/Yarn1/Yarn2/BUN proxies, updates AddonVitestService to use the computed package command string in prompts/errors, and makes small CLI text and logger message/color tweaks.

Changes

Cohort / File(s) Summary
Package manager API & proxies
code/core/src/common/js-package-manager/JsPackageManager.ts, code/core/src/common/js-package-manager/NPMProxy.ts, code/core/src/common/js-package-manager/PNPMProxy.ts, code/core/src/common/js-package-manager/BUNProxy.ts, code/core/src/common/js-package-manager/Yarn1Proxy.ts, code/core/src/common/js-package-manager/Yarn2Proxy.ts
Added abstract getPackageCommand(args: string[]): string to JsPackageManager and implemented it in each proxy to return a manager-specific command string (e.g., npx ..., pnpm exec ..., bunx ..., yarn exec ...).
CLI: Playwright install prompts
code/core/src/cli/AddonVitestService.ts
Replaced hard-coded npx ... strings with this.packageManager.getPackageCommand(playwrightCommand) for prompts and error messages; minor casing change in the install prompt text.
Logging / Telemetry / UI text
code/core/src/node-logger/logger/colors.ts, code/core/src/telemetry/notify.ts, code/lib/create-storybook/src/commands/UserPreferencesCommand.ts
Made CLI info color unconditionally cyan; collapsed telemetry notify message to a single-line wording change; adjusted recommended-install label wording.
Tests
code/core/src/cli/AddonVitestService.test.ts
Updated test mocks to include getPackageCommand on JsPackageManager and adjusted expected prompt text to match new casing and command-string usage.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant AV as AddonVitestService
  participant PM as JsPackageManager (proxy)
  participant UI as CLI Prompt / Logger

  rect rgba(230,247,255,0.6)
  note right of AV: installPlaywright (display-only change)
  AV->>PM: getPackageCommand(playwrightCommand)
  PM-->>AV: "<manager-specific> <args...>"
  AV->>UI: show prompt/error using computed command string
  end

  UI-->>AV: user confirms / aborts
  alt user confirms
    AV->>AV: run existing install flow (unchanged execution)
    UI-->>AV: success / error (uses computed command in messages)
  else abort/error
    UI-->>AV: abort/error (uses computed command in messages)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to:
    • Consistent getPackageCommand(args: string[]): string signature across JsPackageManager and all proxies.
    • Correct quoting/escaping and ordering for manager-specific strings (Yarn1 -- handling, pnpm/npx/bunx semantics).
    • Tests updated to mock the new method and that AddonVitestService uses the string only for display.

Possibly related PRs

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 698777d and f547a64.

📒 Files selected for processing (1)
  • code/core/src/cli/AddonVitestService.test.ts (3 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
code/core/src/common/js-package-manager/PNPMProxy.ts (1)

76-78: LGTM! Implementation is correct and consistent.

The implementation correctly constructs the PNPM exec command string by joining arguments. This follows the same pattern as getRunCommand and is appropriate for display purposes in prompts and error messages.

Optional enhancement: Consider adding shell escaping for arguments that contain spaces or special characters to ensure commands remain valid when users copy and paste them. For example, args with spaces could be wrapped in quotes. However, this is a minor edge case and the current implementation handles typical use cases well.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13d4773 and 24f18cc.

📒 Files selected for processing (10)
  • code/core/src/cli/AddonVitestService.ts (2 hunks)
  • code/core/src/common/js-package-manager/BUNProxy.ts (1 hunks)
  • code/core/src/common/js-package-manager/JsPackageManager.ts (1 hunks)
  • code/core/src/common/js-package-manager/NPMProxy.ts (1 hunks)
  • code/core/src/common/js-package-manager/PNPMProxy.ts (1 hunks)
  • code/core/src/common/js-package-manager/Yarn1Proxy.ts (1 hunks)
  • code/core/src/common/js-package-manager/Yarn2Proxy.ts (1 hunks)
  • code/core/src/node-logger/logger/colors.ts (1 hunks)
  • code/core/src/telemetry/notify.ts (1 hunks)
  • code/lib/create-storybook/src/commands/UserPreferencesCommand.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,js,jsx,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use camelCase for variable and function names

Files:

  • code/core/src/common/js-package-manager/NPMProxy.ts
  • code/core/src/common/js-package-manager/BUNProxy.ts
  • code/core/src/node-logger/logger/colors.ts
  • code/core/src/common/js-package-manager/PNPMProxy.ts
  • code/lib/create-storybook/src/commands/UserPreferencesCommand.ts
  • code/core/src/common/js-package-manager/Yarn1Proxy.ts
  • code/core/src/cli/AddonVitestService.ts
  • code/core/src/common/js-package-manager/Yarn2Proxy.ts
  • code/core/src/common/js-package-manager/JsPackageManager.ts
  • code/core/src/telemetry/notify.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Enable TypeScript strict mode
Export functions from modules for testing purposes

Files:

  • code/core/src/common/js-package-manager/NPMProxy.ts
  • code/core/src/common/js-package-manager/BUNProxy.ts
  • code/core/src/node-logger/logger/colors.ts
  • code/core/src/common/js-package-manager/PNPMProxy.ts
  • code/lib/create-storybook/src/commands/UserPreferencesCommand.ts
  • code/core/src/common/js-package-manager/Yarn1Proxy.ts
  • code/core/src/cli/AddonVitestService.ts
  • code/core/src/common/js-package-manager/Yarn2Proxy.ts
  • code/core/src/common/js-package-manager/JsPackageManager.ts
  • code/core/src/telemetry/notify.ts
**/*.{ts,tsx,js,jsx,json,html,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx,js,jsx,json,html,mjs}: Use ESLint and Prettier for code style enforcement
Run 'yarn prettier --write ' to format code after making changes
Run 'yarn lint:js:cmd ' to check for ESLint issues after making changes

Files:

  • code/core/src/common/js-package-manager/NPMProxy.ts
  • code/core/src/common/js-package-manager/BUNProxy.ts
  • code/core/src/node-logger/logger/colors.ts
  • code/core/src/common/js-package-manager/PNPMProxy.ts
  • code/lib/create-storybook/src/commands/UserPreferencesCommand.ts
  • code/core/src/common/js-package-manager/Yarn1Proxy.ts
  • code/core/src/cli/AddonVitestService.ts
  • code/core/src/common/js-package-manager/Yarn2Proxy.ts
  • code/core/src/common/js-package-manager/JsPackageManager.ts
  • code/core/src/telemetry/notify.ts
code/**/!(*.test).{ts,tsx,js,mjs}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

code/**/!(*.test).{ts,tsx,js,mjs}: Use 'logger' from 'storybook/internal/node-logger' for server-side (Node.js) logging, not console.log/console.warn/console.error
Use 'logger' from 'storybook/internal/client-logger' for client-side (browser) logging, not console.log/console.warn/console.error
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size

Files:

  • code/core/src/common/js-package-manager/NPMProxy.ts
  • code/core/src/common/js-package-manager/BUNProxy.ts
  • code/core/src/node-logger/logger/colors.ts
  • code/core/src/common/js-package-manager/PNPMProxy.ts
  • code/lib/create-storybook/src/commands/UserPreferencesCommand.ts
  • code/core/src/common/js-package-manager/Yarn1Proxy.ts
  • code/core/src/cli/AddonVitestService.ts
  • code/core/src/common/js-package-manager/Yarn2Proxy.ts
  • code/core/src/common/js-package-manager/JsPackageManager.ts
  • code/core/src/telemetry/notify.ts
🧠 Learnings (2)
📚 Learning: 2025-11-05T09:38:47.712Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/Select/Select.tsx:200-204
Timestamp: 2025-11-05T09:38:47.712Z
Learning: Repo: storybookjs/storybook — Guidance: Until Storybook 11 is released, do not suggest using React.useId anywhere (e.g., in code/core/src/components/components/Select/Select.tsx) to maintain compatibility with React 17 runtimes. Prefer advising: accept a caller-provided props.id and, if needed, generate a client-only fallback id to minimize SSR hydration issues — but avoid useId. Resume prompting for useId after Storybook 11.

Applied to files:

  • code/lib/create-storybook/src/commands/UserPreferencesCommand.ts
📚 Learning: 2025-11-05T09:36:55.944Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/Tabs/Tabs.stories.tsx:222-227
Timestamp: 2025-11-05T09:36:55.944Z
Learning: Repo: storybookjs/storybook PR: 32458 — In code/core/src/components/components/Button/Button.tsx (React/TypeScript), ButtonProps includes ariaLabel?: string | false and the component maps it to the DOM aria-label. Convention: ariaLabel is mandatory on all Button usages — provide a descriptive string for icon-only buttons; set ariaLabel=false when the button’s children already serve as the accessible name. Do not suggest using a raw aria-label prop on Button call sites.

Applied to files:

  • code/lib/create-storybook/src/commands/UserPreferencesCommand.ts
🧬 Code graph analysis (1)
code/core/src/cli/AddonVitestService.ts (2)
scripts/utils/tools.ts (1)
  • dedent (119-119)
code/core/src/node-logger/logger/colors.ts (1)
  • CLI_COLORS (3-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest
  • GitHub Check: get-parameters
🔇 Additional comments (9)
code/core/src/common/js-package-manager/NPMProxy.ts (1)

101-103: Standardized npm getPackageCommand looks correct

This helper cleanly mirrors the existing runPackageCommand behavior and will render commands like npx playwright install chromium --with-deps correctly for callers such as AddonVitestService.

code/lib/create-storybook/src/commands/UserPreferencesCommand.ts (1)

157-160: Install-type label wording change is safe

This is a purely textual tweak to the recommended option label; logic and telemetry behavior remain unchanged.

code/core/src/node-logger/logger/colors.ts (1)

7-8: Info color simplification to cyan is consistent and clear

Using cyan for CLI_COLORS.info on all platforms, with a clarifying comment, is a reasonable UX choice and keeps behavior consistent with cta.

code/core/src/telemetry/notify.ts (1)

21-23: Telemetry notice wording simplification preserves behavior

The new single-line message keeps the same meaning and one-time notification logic; only formatting/phrasing changed.

code/core/src/common/js-package-manager/BUNProxy.ts (1)

90-92: bun getPackageCommand aligns with existing bunx execution

This helper constructs bunx commands consistently with runPackageCommand, so displayed instructions will match the actual command being run.

code/core/src/common/js-package-manager/Yarn1Proxy.ts (1)

53-56: Yarn 1 getPackageCommand correctly mirrors exec invocation

The helper splits the first token as the binary and the rest as forwarded args, matching runPackageCommand’s yarn exec <cmd> -- <args> pattern so users see the exact command being executed.

code/core/src/cli/AddonVitestService.ts (1)

120-150: Using getPackageCommand removes hard-coded npx and respects package manager

Deriving playwrightCommandString from this.packageManager.getPackageCommand(playwrightCommand) ensures the instructions and error message reflect the actual command for each package manager (npm, pnpm, yarn, bun), while keeping the execution path unchanged. The spinner intro copy change is minor and remains clear.

code/core/src/common/js-package-manager/JsPackageManager.ts (2)

104-105: LGTM! Comment clarification is helpful.

The updated comment clarifies that getRunCommand returns a string suitable for display purposes, which helps distinguish it from execution methods.


107-108: LGTM! Well-designed interface addition.

The new abstract method provides a clean way to generate display strings for package binary execution commands. The signature is clear and the comment accurately describes its purpose.

@nx-cloud
Copy link

nx-cloud bot commented Nov 26, 2025

View your CI Pipeline Execution ↗ for commit f547a64

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 47s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-26 10:51:25 UTC

@valentinpalkovic valentinpalkovic merged commit c942f73 into next Nov 26, 2025
8 checks passed
@valentinpalkovic valentinpalkovic deleted the valentin/cli-improvements branch November 26, 2025 10:29
@valentinpalkovic valentinpalkovic changed the title CLI: Minor improvements for SB 10.1 CLI: Minor improvements Nov 26, 2025
@coderabbitai coderabbitai bot mentioned this pull request Nov 28, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants