@@ -17,10 +17,15 @@ class DoctorService implements IDoctorService {
17
17
private $childProcess : IChildProcess ,
18
18
private $opener : IOpener ,
19
19
private $prompter : IPrompter ,
20
+ private $terminalSpinnerService : ITerminalSpinnerService ,
20
21
private $versionsService : IVersionsService ) { }
21
22
22
23
public async printWarnings ( configOptions ?: { trackResult : boolean } ) : Promise < boolean > {
23
- const warnings = await doctor . getWarnings ( ) ;
24
+ const infos = await this . $terminalSpinnerService . execute < NativeScriptDoctor . IInfo [ ] > ( {
25
+ text : `Getting environment information ${ EOL } `
26
+ } , ( ) => doctor . getInfos ( ) ) ;
27
+
28
+ const warnings = infos . filter ( info => info . type === constants . WARNING_TYPE_NAME ) ;
24
29
const hasWarnings = warnings . length > 0 ;
25
30
26
31
const hasAndroidWarnings = warnings . filter ( warning => _ . includes ( warning . platforms , constants . ANDROID_PLATFORM_NAME ) ) . length > 0 ;
@@ -32,20 +37,11 @@ class DoctorService implements IDoctorService {
32
37
await this . $analyticsService . track ( "DoctorEnvironmentSetup" , hasWarnings ? "incorrect" : "correct" ) ;
33
38
}
34
39
35
- if ( hasWarnings ) {
36
- warnings . map ( warning => {
37
- this . $logger . warn ( warning . warning ) ;
38
- this . $logger . out ( warning . additionalInformation ) ;
39
- } ) ;
40
+ this . printInfosCore ( infos ) ;
40
41
42
+ if ( hasWarnings ) {
41
43
this . $logger . info ( "There seem to be issues with your configuration." ) ;
42
- if ( this . $hostInfo . isDarwin ) {
43
- await this . promptForHelp ( DoctorService . DarwinSetupDocsLink , DoctorService . DarwinSetupScriptLocation , [ ] ) ;
44
- } else if ( this . $hostInfo . isWindows ) {
45
- await this . promptForHelp ( DoctorService . WindowsSetupDocsLink , DoctorService . WindowsSetupScriptExecutable , DoctorService . WindowsSetupScriptArguments ) ;
46
- } else {
47
- await this . promptForDocs ( DoctorService . LinuxSetupDocsLink ) ;
48
- }
44
+ await this . promptForHelp ( ) ;
49
45
}
50
46
51
47
try {
@@ -63,20 +59,46 @@ class DoctorService implements IDoctorService {
63
59
}
64
60
}
65
61
66
- private async promptForHelp ( link : string , commandName : string , commandArguments : string [ ] ) : Promise < void > {
62
+ private async promptForHelpCore ( link : string , commandName : string , commandArguments : string [ ] ) : Promise < void > {
67
63
await this . promptForDocs ( link ) ;
68
64
69
65
if ( await this . $prompter . confirm ( "Do you want to run the setup script?" , ( ) => helpers . isInteractive ( ) ) ) {
70
66
await this . $childProcess . spawnFromEvent ( commandName , commandArguments , "close" , { stdio : "inherit" } ) ;
71
67
}
72
68
}
73
69
70
+ private async promptForHelp ( ) : Promise < void > {
71
+ if ( this . $hostInfo . isDarwin ) {
72
+ await this . promptForHelpCore ( DoctorService . DarwinSetupDocsLink , DoctorService . DarwinSetupScriptLocation , [ ] ) ;
73
+ } else if ( this . $hostInfo . isWindows ) {
74
+ await this . promptForHelpCore ( DoctorService . WindowsSetupDocsLink , DoctorService . WindowsSetupScriptExecutable , DoctorService . WindowsSetupScriptArguments ) ;
75
+ } else {
76
+ await this . promptForDocs ( DoctorService . LinuxSetupDocsLink ) ;
77
+ }
78
+ }
79
+
74
80
private printPackageManagerTip ( ) {
75
81
if ( this . $hostInfo . isWindows ) {
76
82
this . $logger . out ( "TIP: To avoid setting up the necessary environment variables, you can use the chocolatey package manager to install the Android SDK and its dependencies." + EOL ) ;
77
83
} else if ( this . $hostInfo . isDarwin ) {
78
84
this . $logger . out ( "TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies." + EOL ) ;
79
85
}
80
86
}
87
+
88
+ private printInfosCore ( infos : NativeScriptDoctor . IInfo [ ] ) : void {
89
+ infos . filter ( info => info . type === constants . INFO_TYPE_NAME )
90
+ . map ( info => {
91
+ const spinner = this . $terminalSpinnerService . createSpinner ( ) ;
92
+ spinner . text = info . message ;
93
+ spinner . succeed ( ) ;
94
+ } ) ;
95
+
96
+ infos . filter ( info => info . type === constants . WARNING_TYPE_NAME )
97
+ . map ( info => {
98
+ const spinner = this . $terminalSpinnerService . createSpinner ( ) ;
99
+ spinner . text = `${ info . message . yellow } ${ EOL } ${ info . additionalInformation } ${ EOL } ` ;
100
+ spinner . fail ( ) ;
101
+ } ) ;
102
+ }
81
103
}
82
104
$injector . register ( "doctorService" , DoctorService ) ;
0 commit comments