@@ -109,6 +109,14 @@ export const codemodCamelToKebab = async ({ cwd }: { cwd: string }) => {
109109
110110 // helper to replace and track changes
111111 const replacer = ( _ : string , p2 : string ) => {
112+ // DEBUG: Trace specific problem paths
113+ if ( p2 . includes ( "initDrizzle" ) || p2 . includes ( "createStripeCli" ) ) {
114+ console . log ( `[DEBUG] File: ${ relPath } ` )
115+ console . log ( ` Path: "${ p2 } "` )
116+ const computed = kebabifyPath ( p2 )
117+ console . log ( ` -> "${ computed } "` )
118+ }
119+
112120 const newPath = kebabifyPath ( p2 )
113121 if ( p2 !== newPath ) {
114122 changed = true
@@ -117,6 +125,31 @@ export const codemodCamelToKebab = async ({ cwd }: { cwd: string }) => {
117125 return p2
118126 }
119127
128+ // a1 & a2) Update imports using the project's standard regex (covers side-effects and type imports too)
129+ // Regex adapted from bin/constants/regex.ts
130+ const importRegex =
131+ / i m p o r t \s + t y p e \s + [ \s \S ] + ?f r o m \s + [ ' " ] [ ^ ' " ] + [ ' " ] | i m p o r t \s + [ ' " ] [ ^ ' " ] + [ ' " ] | i m p o r t \s + [ \s \S ] + ?f r o m \s + [ ' " ] [ ^ ' " ] + [ ' " ] / g
132+
133+ content = content . replace ( importRegex , ( statement ) => {
134+ // Extract path: look for the last quoted string
135+ const match = statement . match ( / [ ' " ] ( [ ^ ' " ] + ) [ ' " ] $ / )
136+ if ( ! match ) return statement
137+
138+ const [ quotedPath , rawPath ] = match
139+ const newPath = replacer ( statement , rawPath )
140+
141+ // If no change, return original
142+ if ( rawPath === newPath ) return statement
143+
144+ // Replace the path inside the statement (careful to replace only the path part)
145+ // We reconstruct the string to be safe
146+ return (
147+ statement . substring ( 0 , statement . length - quotedPath . length ) +
148+ quotedPath . replace ( rawPath , newPath )
149+ )
150+ } )
151+
152+ /*
120153 // a1) update real imports: from "…"
121154 content = content.replace(
122155 /(from\s+['"`])([^'"`]+)(['"`])/g,
@@ -128,6 +161,7 @@ export const codemodCamelToKebab = async ({ cwd }: { cwd: string }) => {
128161 /(import\s+['"`])([^'"`]+)(['"`])/g,
129162 (_full, p1, p2, p3) => `${p1}${replacer(_full, p2)}${p3}`,
130163 )
164+ */
131165
132166 // a3) update dynamic imports & require: import("…"), require("…")
133167 content = content . replace (
0 commit comments