@@ -17,10 +17,15 @@ class DoctorService implements IDoctorService {
1717 private $childProcess : IChildProcess ,
1818 private $opener : IOpener ,
1919 private $prompter : IPrompter ,
20+ private $terminalSpinnerService : ITerminalSpinnerService ,
2021 private $versionsService : IVersionsService ) { }
2122
2223 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 ) ;
2429 const hasWarnings = warnings . length > 0 ;
2530
2631 const hasAndroidWarnings = warnings . filter ( warning => _ . includes ( warning . platforms , constants . ANDROID_PLATFORM_NAME ) ) . length > 0 ;
@@ -32,20 +37,11 @@ class DoctorService implements IDoctorService {
3237 await this . $analyticsService . track ( "DoctorEnvironmentSetup" , hasWarnings ? "incorrect" : "correct" ) ;
3338 }
3439
35- if ( hasWarnings ) {
36- warnings . map ( warning => {
37- this . $logger . warn ( warning . warning ) ;
38- this . $logger . out ( warning . additionalInformation ) ;
39- } ) ;
40+ this . printInfosCore ( infos ) ;
4041
42+ if ( hasWarnings ) {
4143 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 ( ) ;
4945 }
5046
5147 try {
@@ -63,20 +59,46 @@ class DoctorService implements IDoctorService {
6359 }
6460 }
6561
66- private async promptForHelp ( link : string , commandName : string , commandArguments : string [ ] ) : Promise < void > {
62+ private async promptForHelpCore ( link : string , commandName : string , commandArguments : string [ ] ) : Promise < void > {
6763 await this . promptForDocs ( link ) ;
6864
6965 if ( await this . $prompter . confirm ( "Do you want to run the setup script?" , ( ) => helpers . isInteractive ( ) ) ) {
7066 await this . $childProcess . spawnFromEvent ( commandName , commandArguments , "close" , { stdio : "inherit" } ) ;
7167 }
7268 }
7369
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+
7480 private printPackageManagerTip ( ) {
7581 if ( this . $hostInfo . isWindows ) {
7682 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 ) ;
7783 } else if ( this . $hostInfo . isDarwin ) {
7884 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 ) ;
7985 }
8086 }
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+ }
81103}
82104$injector . register ( "doctorService" , DoctorService ) ;
0 commit comments