@@ -4,93 +4,51 @@ const chalk = require('chalk').default;
44const microApp = require ( '@micro-app/core' ) ;
55const logger = microApp . logger ;
66
7+ function showLoggerList ( microConfig , type ) {
8+ const aliasName = microConfig . name ;
9+ if ( aliasName ) {
10+ const aliasKey = aliasName [ 0 ] !== '@' ? `@${ aliasName } ` : aliasName ;
11+ Object . keys ( microConfig [ type ] ) . forEach ( key => {
12+ if ( microConfig [ type ] [ key ] ) {
13+ const currAlias = microConfig . config . alias || { } ;
14+ const desc = currAlias [ key ] && currAlias [ key ] . description || false ;
15+ const textStrs = [ ` * ${ chalk . yellow ( `${ aliasKey } /${ key } ` ) } ` ] ;
16+ if ( desc && typeof desc === 'string' ) {
17+ textStrs . push ( `(${ chalk . gray ( desc ) } )` ) ;
18+ }
19+ logger . logo ( textStrs . join ( ' ' ) ) ;
20+ }
21+ } ) ;
22+ }
23+ }
24+
725module . exports = name => {
826 const microAppConfig = microApp . self ( ) ;
927 if ( ! microAppConfig ) return ;
1028 const micros = microAppConfig . micros ;
1129 switch ( name ) {
1230 case 'alias' :
13- {
14- logger . logo ( `${ chalk . green ( 'Alias List' ) } :` ) ;
15- micros . forEach ( item => {
16- const microConfig = microApp ( item ) ;
17- if ( microConfig ) {
18- const aliasName = microConfig . name ;
19- if ( aliasName ) {
20- const aliasKey = aliasName [ 0 ] !== '@' ? `@${ aliasName } ` : aliasName ;
21- Object . keys ( microConfig . alias ) . forEach ( key => {
22- if ( microConfig . alias [ key ] ) {
23- const currAlias = microConfig . config . alias || { } ;
24- const desc = currAlias [ key ] && currAlias [ key ] . description || false ;
25- const textStrs = [ ` * ${ chalk . yellow ( `${ aliasKey } /${ key } ` ) } ` ] ;
26- if ( desc && typeof desc === 'string' ) {
27- textStrs . push ( `(${ chalk . gray ( ) } )` ) ;
28- }
29- logger . logo ( textStrs . join ( ' ' ) ) ;
30- }
31- } ) ;
32- }
33- }
34- } ) ;
35- // self
36- const aliasName = microAppConfig . name ;
37- if ( aliasName ) {
38- const aliasKey = aliasName [ 0 ] !== '@' ? `@${ aliasName } ` : aliasName ;
39- Object . keys ( microAppConfig . alias ) . forEach ( key => {
40- if ( microAppConfig . alias [ key ] ) {
41- const currAlias = microAppConfig . config . alias || { } ;
42- const desc = currAlias [ key ] && currAlias [ key ] . description || false ;
43- const textStrs = [ ` * ${ chalk . yellow ( `${ aliasKey } /${ key } ` ) } ` ] ;
44- if ( desc && typeof desc === 'string' ) {
45- textStrs . push ( `(${ chalk . gray ( ) } )` ) ;
46- }
47- logger . logo ( textStrs . join ( ' ' ) ) ;
48- }
49- } ) ;
31+ logger . logo ( `${ chalk . green ( 'Alias List' ) } :` ) ;
32+ micros . forEach ( item => {
33+ const microConfig = microApp ( item ) ;
34+ if ( microConfig ) {
35+ showLoggerList ( microConfig , 'alias' ) ;
5036 }
51- }
37+ } ) ;
38+ // self
39+ showLoggerList ( microAppConfig , 'alias' ) ;
5240 break ;
5341 case 'share' :
5442 case 'shared' :
55- {
56- logger . logo ( `${ chalk . green ( 'Shared List' ) } :` ) ;
57- micros . forEach ( item => {
58- const microConfig = microApp ( item ) ;
59- if ( microConfig ) {
60- const aliasName = microConfig . name ;
61- if ( aliasName ) {
62- const aliasKey = aliasName [ 0 ] !== '@' ? `@${ aliasName } ` : aliasName ;
63- Object . keys ( microConfig . shared ) . forEach ( key => {
64- if ( microConfig . shared [ key ] ) {
65- const currAlias = microConfig . config . alias || { } ;
66- const desc = currAlias [ key ] && currAlias [ key ] . description || false ;
67- const textStrs = [ ` * ${ chalk . yellow ( `${ aliasKey } /${ key } ` ) } ` ] ;
68- if ( desc && typeof desc === 'string' ) {
69- textStrs . push ( `(${ chalk . gray ( ) } )` ) ;
70- }
71- logger . logo ( textStrs . join ( ' ' ) ) ;
72- }
73- } ) ;
74- }
75- }
76- } ) ;
77- // self
78- const aliasName = microAppConfig . name ;
79- if ( aliasName ) {
80- const aliasKey = aliasName [ 0 ] !== '@' ? `@${ aliasName } ` : aliasName ;
81- Object . keys ( microAppConfig . shared ) . forEach ( key => {
82- if ( microAppConfig . shared [ key ] ) {
83- const currAlias = microAppConfig . config . alias || { } ;
84- const desc = currAlias [ key ] && currAlias [ key ] . description || false ;
85- const textStrs = [ ` * ${ chalk . yellow ( `${ aliasKey } /${ key } ` ) } ` ] ;
86- if ( desc && typeof desc === 'string' ) {
87- textStrs . push ( `(${ chalk . gray ( ) } )` ) ;
88- }
89- logger . logo ( textStrs . join ( ' ' ) ) ;
90- }
91- } ) ;
43+ logger . logo ( `${ chalk . green ( 'Shared List' ) } :` ) ;
44+ micros . forEach ( item => {
45+ const microConfig = microApp ( item ) ;
46+ if ( microConfig ) {
47+ showLoggerList ( microConfig , 'shared' ) ;
9248 }
93- }
49+ } ) ;
50+ // self
51+ showLoggerList ( microAppConfig , 'shared' ) ;
9452 break ;
9553 default :
9654 logger . logo ( `${ chalk . green ( 'Show Details' ) } :` ) ;
0 commit comments