@@ -29,9 +29,18 @@ export interface VersionMismatchOptions {
2929/**
3030 * Extract exact version from npm version specifier
3131 * Handles: ^1.2.3, ~1.2.3, 1.2.3, >=1.2.3, workspace:*, etc.
32+ * Returns null for unsupported specifiers (workspace:*, tags, ranges without exact version)
3233 */
33- function extractExactVersion ( version : unknown ) : string | null {
34+ export function extractExactVersion ( version : unknown ) : string | null {
3435 if ( typeof version !== 'string' ) return null
36+
37+ // Handle unsupported specifiers
38+ if ( version . includes ( ':' ) || version . includes ( ' ' ) || version === '*' || version === 'latest' ) {
39+ // workspace:*, file:, link:, git:, tags, etc.
40+ return null
41+ }
42+
43+ // Extract exact version from specifier (e.g., "^5.0.0" -> "5.0.0")
3544 const match = version . match ( / \d + \. \d + \. \d + (?: - [ 0 - 9 A - Z a - z . - ] + ) ? / )
3645 return match ?. [ 0 ] ?? null
3746}
@@ -80,14 +89,21 @@ export async function checkVersionMismatch(
8089
8190 try {
8291 // Normalize global version (extract exact version from specifier)
83- const normalizedGlobalVersion = extractExactVersion ( globalVersion ) ?? globalVersion
92+ const normalizedGlobalVersion = extractExactVersion ( globalVersion )
93+
94+ // If global version is unsupported specifier, skip check
95+ if ( ! normalizedGlobalVersion ) {
96+ return null
97+ }
8498
8599 const localClientVersionRaw = await getClientVersion ( cwd )
86- const localClientVersion = extractExactVersion ( localClientVersionRaw ) ?? localClientVersionRaw
100+ const localClientVersion = extractExactVersion ( localClientVersionRaw )
87101
88- const localPrismaVersion = await getLocalPrismaVersion ( cwd )
102+ const localPrismaVersionSpecifier = await getLocalPrismaVersion ( cwd )
103+ const localPrismaVersion = extractExactVersion ( localPrismaVersionSpecifier )
89104
90105 // Check @prisma /client version mismatch
106+ // Only check if we can extract exact versions from both sides
91107 if ( localClientVersion && localClientVersion !== normalizedGlobalVersion ) {
92108 return {
93109 hasMismatch : true ,
@@ -98,6 +114,7 @@ export async function checkVersionMismatch(
98114 }
99115
100116 // Check local prisma version mismatch
117+ // Only check if we can extract exact versions from both sides
101118 if ( localPrismaVersion && localPrismaVersion !== normalizedGlobalVersion ) {
102119 return {
103120 hasMismatch : true ,
@@ -107,6 +124,8 @@ export async function checkVersionMismatch(
107124 }
108125 }
109126
127+ // If we have unsupported specifiers (workspace:*, tags, etc.), treat as "unable to verify"
128+ // Don't trigger false mismatch warnings
110129 return null
111130 } catch {
112131 return null
0 commit comments