@@ -5,7 +5,7 @@ import { defineCommand, runMain } from "citty";
5
5
import consola from "consola" ;
6
6
import { getColor } from "consola/utils" ;
7
7
import { name , description , version } from "../package.json" ;
8
- import { automd } from "./automd" ;
8
+ import { AutomdResult , automd } from "./automd" ;
9
9
10
10
const main = defineCommand ( {
11
11
meta : {
@@ -48,20 +48,41 @@ const main = defineCommand({
48
48
updated : { label : "updated" , color : getColor ( "blue" ) } ,
49
49
noChanges : { label : "no changes" , color : getColor ( "green" ) } ,
50
50
alreadyUpdate : { label : "already up-to-date" , color : getColor ( "gray" ) } ,
51
+ issues : { label : "with issues" , color : getColor ( "yellow" ) } ,
52
+ } ;
53
+ const getChangeType = ( res : AutomdResult ) => {
54
+ if ( res . updates . length === 0 ) {
55
+ return changeTypes . alreadyUpdate ;
56
+ }
57
+ if ( res . hasIssues ) {
58
+ return changeTypes . issues ;
59
+ }
60
+ return res . hasChanged ? changeTypes . updated : changeTypes . noChanges ;
51
61
} ;
52
62
53
- for ( const f of fileUpdates ) {
54
- const [ input , output ] = [ f . input , f . output ] . map ( ( i ) =>
55
- relative ( f . _config . dir , i ) ,
63
+ for ( const res of fileUpdates ) {
64
+ const [ input , output ] = [ res . input , res . output ] . map ( ( i ) =>
65
+ relative ( res . _config . dir , i ) ,
56
66
) ;
57
- const fileStr =
58
- input === output ? ` ${ input } ` : ` ${ input } ~> ${ output } ` ;
67
+ const t = getChangeType ( res ) ;
68
+
69
+ const f = `${ input === output ? ` ${ input } ` : ` ${ input } ~> ${ output } ` } ` ;
59
70
60
- const t =
61
- // prettier-ignore
62
- f . updates . length === 0 ? changeTypes . alreadyUpdate : ( f . hasChanged ? changeTypes . updated : changeTypes . noChanges ) ;
71
+ consola . log ( t . color ( ` ─ ${ f } ${ t . label } ` ) ) ;
72
+ }
73
+
74
+ const issues = fileUpdates
75
+ . filter ( ( f ) => f . hasIssues )
76
+ . map (
77
+ ( f ) =>
78
+ `${ changeTypes . issues . color ( relative ( f . _config . dir , f . input ) ) } \n\n ${ f . updates . flatMap ( ( u ) => u . result . issues ) . join ( "\n" ) } ` ,
79
+ ) ;
63
80
64
- consola . log ( t . color ( ` ─ ${ fileStr } ${ t . label } ` ) ) ;
81
+ if ( issues . length > 0 ) {
82
+ consola . warn ( `Some issues happened during update!` ) ;
83
+ for ( const issue of issues ) {
84
+ consola . error ( issue ) ;
85
+ }
65
86
}
66
87
} ,
67
88
} ) ;
0 commit comments