Skip to content

CLI: Add vike CLI metadata#34189

Merged
yannbf merged 1 commit into
nextfrom
yann/add-vike-cli-metadata
Mar 18, 2026
Merged

CLI: Add vike CLI metadata#34189
yannbf merged 1 commit into
nextfrom
yann/add-vike-cli-metadata

Conversation

@yannbf
Copy link
Copy Markdown
Member

@yannbf yannbf commented Mar 18, 2026

Closes #

What I did

This PR adds Vike as part of the cliIntegration detection for telemetry

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 is a small change on an already solid work. I believe this can only be properly tested once released.

  • run npm create vike@latest --- --react --storybook with STORYBOOK_TELEMETRY_DEBUG=1 set in the environment
  • See Vike as cliIntegration in the payload

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

  • New Features

    • Added support for detecting vike as a CLI integration, enabling the system to properly recognize vike commands during setup and configuration.
  • Tests

    • Added test coverage for vike detection functionality.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Mar 18, 2026

View your CI Pipeline Execution ↗ for commit d5e0d30

Command Status Duration Result
nx run-many -t compile -c production --parallel=1 ✅ Succeeded 5m 45s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-18 06:40:55 UTC

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

This PR extends the getCliIntegrationFromAncestry function to recognize and detect "vike" as a CLI integration type. A corresponding test case is added to validate the new detection logic for vike-based project creation commands.

Changes

Cohort / File(s) Summary
Vike Integration Detection
code/lib/create-storybook/src/services/VersionService.ts, code/lib/create-storybook/src/services/VersionService.test.ts
Added detection logic in getCliIntegrationFromAncestry to recognize "vike" commands and return the "vike" integration type. Includes corresponding test case validating detection of commands like pnpm create vike@latest --- --react --storybook.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
📝 Coding Plan
  • Generate coding plan for human review comments

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

Tip

CodeRabbit can use your project's `biome` configuration to improve the quality of JS/TS/CSS/JSON code reviews.

Add a configuration file to your project to customize how CodeRabbit runs biome.

Copy link
Copy Markdown
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/lib/create-storybook/src/services/VersionService.test.ts (1)

186-192: Add one negative regression test for non-invocation vike tokens.

This new test covers the happy path. Please also add a case where vike appears only as an argument (not a CLI integration) to prevent future overmatching regressions.

Suggested additional test
     it('should detect vike new command', () => {
       const ancestry = [{ command: 'pnpm create vike@latest --- --react --storybook' }];

       const integration = versionService.getCliIntegrationFromAncestry(ancestry as any);

       expect(integration).toBe('vike');
     });
+
+    it('should not detect vike when it is only a non-command argument', () => {
+      const ancestry = [{ command: 'npm create vite@latest -- --template vike' }];
+
+      const integration = versionService.getCliIntegrationFromAncestry(ancestry as any);
+
+      expect(integration).toBeUndefined();
+    });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@code/lib/create-storybook/src/services/VersionService.test.ts` around lines
186 - 192, Add a negative regression test in VersionService.test.ts that ensures
getCliIntegrationFromAncestry does not return 'vike' when the token "vike"
appears only as an argument (not as the invoked CLI). Specifically, add a new
it(...) case where ancestry contains a command string like 'pnpm create
`@something` latest --template vike' or 'node script.js vike' and assert that
versionService.getCliIntegrationFromAncestry(ancestry as any) returns
null/undefined/'' (matching existing negative expectation style); place the test
near the existing 'should detect vike new command' case and reference
getCliIntegrationFromAncestry and the integration variable to mirror the test
pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@code/lib/create-storybook/src/services/VersionService.ts`:
- Around line 67-69: The current Vike detection in VersionService (the check on
ancestor.command?.includes('vike')) can misclassify commands that merely contain
the substring "vike"; update the detection logic in the same place where you
currently return 'vike' so it only matches actual invocations (e.g., use a
word-boundary regex or tokenized command check against ancestor.command to match
whole word "vike" or known binaries like "vike" or "npx vike"), ensuring the
check targets the ancestor.command string exactly rather than any substring to
avoid false telemetry attribution.

---

Nitpick comments:
In `@code/lib/create-storybook/src/services/VersionService.test.ts`:
- Around line 186-192: Add a negative regression test in VersionService.test.ts
that ensures getCliIntegrationFromAncestry does not return 'vike' when the token
"vike" appears only as an argument (not as the invoked CLI). Specifically, add a
new it(...) case where ancestry contains a command string like 'pnpm create
`@something` latest --template vike' or 'node script.js vike' and assert that
versionService.getCliIntegrationFromAncestry(ancestry as any) returns
null/undefined/'' (matching existing negative expectation style); place the test
near the existing 'should detect vike new command' case and reference
getCliIntegrationFromAncestry and the integration variable to mirror the test
pattern.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dbaf7e6c-ca16-4720-a88b-37eb3c586f7a

📥 Commits

Reviewing files that changed from the base of the PR and between 271bd1e and d5e0d30.

📒 Files selected for processing (2)
  • code/lib/create-storybook/src/services/VersionService.test.ts
  • code/lib/create-storybook/src/services/VersionService.ts

Comment on lines +67 to +69
// Check for vike
if (ancestor.command?.includes('vike')) {
return 'vike';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Tighten Vike detection to avoid false telemetry attribution.

Line 68 uses a raw substring check, so commands that merely contain vike (not actual Vike invocation) can be misclassified as cliIntegration: 'vike'.

Proposed fix
-      // Check for vike
-      if (ancestor.command?.includes('vike')) {
+      // Check for Vike invocation forms
+      const command = ancestor.command ?? '';
+      const isVikeCommand =
+        /(?:^|\s)create\s+vike(?:@[^ ]+)?(?:\s|$)/i.test(command) ||
+        /(?:^|\s)vike(?:@[^ ]+)?\s+(?:new|init|create)\b/i.test(command);
+      if (isVikeCommand) {
         return 'vike';
       }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Check for vike
if (ancestor.command?.includes('vike')) {
return 'vike';
// Check for Vike invocation forms
const command = ancestor.command ?? '';
const isVikeCommand =
/(?:^|\s)create\s+vike(?:@[^ ]+)?(?:\s|$)/i.test(command) ||
/(?:^|\s)vike(?:@[^ ]+)?\s+(?:new|init|create)\b/i.test(command);
if (isVikeCommand) {
return 'vike';
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@code/lib/create-storybook/src/services/VersionService.ts` around lines 67 -
69, The current Vike detection in VersionService (the check on
ancestor.command?.includes('vike')) can misclassify commands that merely contain
the substring "vike"; update the detection logic in the same place where you
currently return 'vike' so it only matches actual invocations (e.g., use a
word-boundary regex or tokenized command check against ancestor.command to match
whole word "vike" or known binaries like "vike" or "npx vike"), ensuring the
check targets the ancestor.command string exactly rather than any substring to
avoid false telemetry attribution.

@yannbf yannbf merged commit e3c5772 into next Mar 18, 2026
127 of 134 checks passed
@yannbf yannbf deleted the yann/add-vike-cli-metadata branch March 18, 2026 08:15
@github-actions github-actions Bot mentioned this pull request Mar 18, 2026
9 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