Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions code/lib/create-storybook/src/services/VersionService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ describe('VersionService', () => {

expect(integration).toBe('@tanstack/start');
});

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');
});
});

describe('getVersionInfo', () => {
Expand Down
4 changes: 4 additions & 0 deletions code/lib/create-storybook/src/services/VersionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export class VersionService {
if (ancestor.command?.includes('@tanstack/start')) {
return '@tanstack/start';
}
// Check for vike
if (ancestor.command?.includes('vike')) {
return 'vike';
Comment on lines +67 to +69
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.

}
}
return undefined;
}
Expand Down
Loading