Skip to content

Add negative test case for create-rsbuild pattern and fix overly permissive regex#33604

Merged
shilman merged 2 commits into
shilman/add-cli-init-telemetryfrom
copilot/sub-pr-33603
Jan 21, 2026
Merged

Add negative test case for create-rsbuild pattern and fix overly permissive regex#33604
shilman merged 2 commits into
shilman/add-cli-init-telemetryfrom
copilot/sub-pr-33603

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 21, 2026

The regex pattern for detecting create-rsbuild commands was too permissive, matching creatersbuild (no separator) when it should only match create-rsbuild or create rsbuild.

Changes

  • Added negative test case to verify npx creatersbuild is NOT matched
  • Fixed regex pattern in getCliIntegrationFromAncestry() by making separator required:
    // Before: optional separator [\s\-]? allowed matching "creatersbuild"
    /(?:^|\s)create[\s\-]?rsbuild/i
    
    // After: required separator [\s\-] correctly rejects "creatersbuild"
    /(?:^|\s)create[\s\-]rsbuild/i

Pattern now correctly matches:

  • create-rsbuild (dash)
  • create rsbuild (space)
  • creatersbuild (no separator)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: shilman <488689+shilman@users.noreply.github.com>
Copilot AI changed the title [WIP] Update CLI init telemetry to address review feedback Add negative test case for create-rsbuild pattern and fix overly permissive regex Jan 21, 2026
Copilot AI requested a review from shilman January 21, 2026 06:15
@shilman shilman marked this pull request as ready for review January 21, 2026 06:39
Copilot AI review requested due to automatic review settings January 21, 2026 06:39
@shilman shilman merged commit 0fbea1f into shilman/add-cli-init-telemetry Jan 21, 2026
@shilman shilman deleted the copilot/sub-pr-33603 branch January 21, 2026 06:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a regex pattern bug in the CLI integration detection logic. The previous regex was too permissive and would incorrectly match creatersbuild (without a separator) when it should only match create-rsbuild or create rsbuild.

Changes:

  • Fixed regex pattern by making the separator character class [\s\-] required instead of optional (removed ?)
  • Added a negative test case to verify npx creatersbuild is correctly rejected

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
code/lib/create-storybook/src/services/VersionService.ts Fixed regex pattern from `/(?:^
code/lib/create-storybook/src/services/VersionService.test.ts Added negative test case to verify creatersbuild without separator is not matched

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.

3 participants