1- import fs from 'fs-extra' ;
21import chalk from 'chalk' ;
3- import semver from 'semver' ;
42import { PluginManager } from 'live-plugin-manager' ;
53import { NoTransformsExistError } from './errors' ;
64
@@ -20,18 +18,35 @@ export default async function list(packages: string[]) {
2018 ) ;
2119 }
2220
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 ) ;
3123
3224 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+ }
3651 }
3752}
0 commit comments