1
- import fs from 'fs-extra' ;
2
1
import chalk from 'chalk' ;
3
- import semver from 'semver' ;
4
2
import { PluginManager } from 'live-plugin-manager' ;
5
3
import { NoTransformsExistError } from './errors' ;
6
4
@@ -20,18 +18,35 @@ export default async function list(packages: string[]) {
20
18
) ;
21
19
}
22
20
23
- const info = await packageManager . getInfo ( codemodName ) ;
24
-
25
- /**
26
- * TODO: currently jscodeshift only accepts a path to a transform rather than a function or module.
27
- * The below logic will need to be refactored once this is fixed
28
- */
29
- const modulePath = `${ info ?. location } /src` ;
30
- const directories = await fs . readdir ( modulePath ) ;
21
+ await packageManager . install ( codemodName ) ;
22
+ const { default : codeshiftConfig } = packageManager . require ( codemodName ) ;
31
23
32
24
console . log ( chalk . bold ( pkg ) ) ;
33
- directories
34
- . filter ( dir => semver . valid ( dir ) )
35
- . forEach ( dir => console . log ( `├─${ dir } ` ) ) ;
25
+
26
+ if ( codeshiftConfig . transforms ) {
27
+ console . log ( `├─ transforms` ) ,
28
+ Object . keys ( codeshiftConfig . transforms ) . forEach (
29
+ ( transform , index , array ) => {
30
+ if ( index + 1 === array . length ) {
31
+ console . log ( `| └─ ${ transform } ` ) ;
32
+ return ;
33
+ }
34
+ console . log ( `| ├─ ${ transform } ` ) ;
35
+ } ,
36
+ ) ;
37
+ }
38
+
39
+ if ( codeshiftConfig . presets ) {
40
+ console . log ( `└─ presets` ) ,
41
+ Object . keys ( codeshiftConfig . presets ) . forEach (
42
+ ( transform , index , array ) => {
43
+ if ( index + 1 === array . length ) {
44
+ console . log ( ` └─ ${ transform } ` ) ;
45
+ return ;
46
+ }
47
+ console . log ( `| ├─ ${ transform } ` ) ;
48
+ } ,
49
+ ) ;
50
+ }
36
51
}
37
52
}
0 commit comments