@@ -4,7 +4,13 @@ import {
4
4
CollectAndPersistReportsOptions ,
5
5
collectAndPersistReports ,
6
6
} from '@code-pushup/core' ;
7
+ import { link } from '@code-pushup/utils' ;
7
8
import { CLI_NAME } from '../constants' ;
9
+ import {
10
+ collectSuccessfulLog ,
11
+ renderConfigureCategoriesHint ,
12
+ ui ,
13
+ } from '../implementation/logging' ;
8
14
import { yargsOnlyPluginsOptionsDefinition } from '../implementation/only-plugins.options' ;
9
15
10
16
export function yargsCollectCommandObject ( ) : CommandModule {
@@ -15,33 +21,51 @@ export function yargsCollectCommandObject(): CommandModule {
15
21
builder : yargsOnlyPluginsOptionsDefinition ( ) ,
16
22
handler : async < T > ( args : ArgumentsCamelCase < T > ) => {
17
23
const options = args as unknown as CollectAndPersistReportsOptions ;
18
- console . info ( chalk . bold ( CLI_NAME ) ) ;
19
- console . info ( chalk . gray ( `Run ${ command } ...` ) ) ;
24
+ ui ( ) . logger . log ( chalk . bold ( CLI_NAME ) ) ;
25
+ ui ( ) . logger . info ( chalk . gray ( `Run ${ command } ...` ) ) ;
26
+
20
27
await collectAndPersistReports ( options ) ;
28
+ collectSuccessfulLog ( ) ;
21
29
22
30
if ( options . categories . length === 0 ) {
23
- console . info (
24
- chalk . gray (
25
- '💡 Configure categories to see the scores in an overview table. See: https://github.com/code-pushup/cli/blob/main/packages/cli/README.md' ,
26
- ) ,
27
- ) ;
31
+ renderConfigureCategoriesHint ( ) ;
28
32
}
29
33
30
34
const { upload = { } } = args as unknown as Record <
31
35
'upload' ,
32
36
object | undefined
33
37
> ;
34
38
if ( Object . keys ( upload ) . length === 0 ) {
35
- console . info (
36
- [
37
- '💡 Visualize your reports:' ,
38
- '- npx code-pushup upload - Run upload to upload the created report to the server' ,
39
- ' https://github.com/code-pushup/cli/tree/main/packages/cli#upload-command' ,
40
- '- npx code-pushup autorun - Run collect & upload' ,
41
- ' https://github.com/code-pushup/cli/tree/main/packages/cli#autorun-command' ,
42
- ] . join ( '\n' ) ,
43
- ) ;
39
+ renderUploadAutorunHint ( ) ;
44
40
}
45
41
} ,
46
42
} satisfies CommandModule ;
47
43
}
44
+
45
+ export function renderUploadAutorunHint ( ) : void {
46
+ ui ( )
47
+ . sticker ( )
48
+ . add ( chalk . bold ( chalk . gray ( '💡 Visualize your reports' ) ) )
49
+ . add ( '' )
50
+ . add (
51
+ `${ chalk . gray ( '❯' ) } npx code-pushup upload - ${ chalk . gray (
52
+ 'Run upload to upload the created report to the server' ,
53
+ ) } `,
54
+ )
55
+ . add (
56
+ ` ${ link (
57
+ 'https://github.com/code-pushup/cli/tree/main/packages/cli#upload-command' ,
58
+ ) } `,
59
+ )
60
+ . add (
61
+ `${ chalk . gray ( '❯' ) } npx code-pushup autorun - ${ chalk . gray (
62
+ 'Run collect & upload' ,
63
+ ) } `,
64
+ )
65
+ . add (
66
+ ` ${ link (
67
+ 'https://github.com/code-pushup/cli/tree/main/packages/cli#autorun-command' ,
68
+ ) } `,
69
+ )
70
+ . render ( ) ;
71
+ }
0 commit comments