1
1
import type { Codemods } from '../types' ;
2
2
3
3
import * as p from '@clack/prompts' ;
4
+ import { LOCKS } from '@helpers/detect' ;
4
5
import { exec } from '@helpers/exec' ;
5
6
import { Logger } from '@helpers/logger' ;
6
7
import chalk from 'chalk' ;
@@ -38,6 +39,7 @@ export async function migrateAction(projectPaths?: string[], options = {} as Mig
38
39
const dotFiles = await findFiles ( transformedPaths , { dot : true } ) ;
39
40
const extraFiles = dotFiles . filter ( ( file ) => EXTRA_FILES . some ( ( extra ) => file . includes ( extra ) ) ) ;
40
41
const files = [ ...baseFiles , ...extraFiles ] ;
42
+ const { cmd, packageManager} = await getInstallCommand ( ) ;
41
43
42
44
// Store the raw content of the files
43
45
storePathsRawContent ( files ) ;
@@ -133,7 +135,8 @@ export async function migrateAction(projectPaths?: string[], options = {} as Mig
133
135
/** ======================== 6. Migrate npmrc optional (Pnpm only) ======================== */
134
136
const runMigrateNpmrc = getCanRunCodemod ( codemod , 'npmrc' ) ;
135
137
136
- if ( runMigrateNpmrc ) {
138
+ // Pnpm only
139
+ if ( runMigrateNpmrc && packageManager === 'pnpm' ) {
137
140
const npmrcFiles = dotFiles . filter ( ( path ) => path . includes ( '.npmrc' ) ) ;
138
141
139
142
p . log . step ( `${ step } . Migrating "npmrc" (Pnpm only)` ) ;
@@ -152,7 +155,7 @@ export async function migrateAction(projectPaths?: string[], options = {} as Mig
152
155
const remainingFiles = [
153
156
...nextuiFiles . filter ( ( file ) => ! affectedFiles . has ( file ) ) ,
154
157
...remainingNextuiFiles
155
- ] ;
158
+ ] . filter ( ( file ) => ! Object . keys ( LOCKS ) . some ( ( lock ) => file . includes ( lock ) ) ) ; // Should ignore lock files
156
159
const runCheckLeftFiles = remainingFiles . length > 0 ;
157
160
158
161
// If user not using individual codemod, we need to ask user to replace left files
@@ -204,8 +207,6 @@ export async function migrateAction(projectPaths?: string[], options = {} as Mig
204
207
} ) ;
205
208
206
209
if ( selectReinstallDependencies ) {
207
- const { cmd} = await getInstallCommand ( ) ;
208
-
209
210
try {
210
211
await exec ( cmd ) ;
211
212
} catch {
0 commit comments