@@ -26,96 +26,114 @@ class DoctorService implements IDoctorService {
26
26
private $npm : INodePackageManager ,
27
27
private $opener : IOpener ,
28
28
private $prompter : IPrompter ,
29
- private $fs : IFileSystem ) { }
29
+ private $fs : IFileSystem ,
30
+ private $versionsService : IVersionsService ) { }
30
31
31
- public printWarnings ( configOptions ?: { trackResult : boolean } ) : boolean {
32
- let result = false ;
33
- let sysInfo = this . $sysInfo . getSysInfo ( path . join ( __dirname , ".." , ".." , "package.json" ) ) . wait ( ) ;
34
-
35
- if ( ! sysInfo . adbVer ) {
36
- this . $logger . warn ( "WARNING: adb from the Android SDK is not installed or is not configured properly." ) ;
37
- this . $logger . out ( "For Android-related operations, the NativeScript CLI will use a built-in version of adb." + EOL
38
- + "To avoid possible issues with the native Android emulator, Genymotion or connected" + EOL
39
- + "Android devices, verify that you have installed the latest Android SDK and" + EOL
40
- + "its dependencies as described in http://developer.android.com/sdk/index.html#Requirements" + EOL ) ;
41
-
42
- this . printPackageManagerTip ( ) ;
43
- result = true ;
44
- }
45
-
46
- if ( ! sysInfo . androidInstalled ) {
47
- this . $logger . warn ( "WARNING: The Android SDK is not installed or is not configured properly." ) ;
48
- this . $logger . out ( "You will not be able to build your projects for Android and run them in the native emulator." + EOL
49
- + "To be able to build for Android and run apps in the native emulator, verify that you have" + EOL
50
- + "installed the latest Android SDK and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements" + EOL
51
- ) ;
32
+ public printWarnings ( configOptions ?: { trackResult : boolean } ) : IFuture < boolean > {
33
+ return ( ( ) => {
34
+ let result = false ;
35
+ let sysInfo = this . $sysInfo . getSysInfo ( path . join ( __dirname , ".." , ".." , "package.json" ) ) . wait ( ) ;
52
36
53
- this . printPackageManagerTip ( ) ;
54
- result = true ;
55
- }
37
+ if ( ! sysInfo . adbVer ) {
38
+ this . $logger . warn ( "WARNING: adb from the Android SDK is not installed or is not configured properly." ) ;
39
+ this . $logger . out ( "For Android-related operations, the NativeScript CLI will use a built-in version of adb." + EOL
40
+ + "To avoid possible issues with the native Android emulator, Genymotion or connected" + EOL
41
+ + "Android devices, verify that you have installed the latest Android SDK and" + EOL
42
+ + "its dependencies as described in http://developer.android.com/sdk/index.html#Requirements" + EOL ) ;
56
43
57
- if ( this . $hostInfo . isDarwin ) {
58
- if ( ! sysInfo . xcodeVer ) {
59
- this . $logger . warn ( "WARNING: Xcode is not installed or is not configured properly." ) ;
60
- this . $logger . out ( "You will not be able to build your projects for iOS or run them in the iOS Simulator." + EOL
61
- + "To be able to build for iOS and run apps in the native emulator, verify that you have installed Xcode." + EOL ) ;
44
+ this . printPackageManagerTip ( ) ;
62
45
result = true ;
63
46
}
64
47
65
- if ( ! sysInfo . cocoapodVer ) {
66
- this . $logger . warn ( "WARNING: CocoaPods is not installed or is not configured properly." ) ;
67
- this . $logger . out ( "You will not be able to build your projects for iOS if they contain plugin with CocoaPod file." + EOL
68
- + "To be able to build such projects, verify that you have installed CocoaPods." ) ;
48
+ if ( ! sysInfo . androidInstalled ) {
49
+ this . $logger . warn ( "WARNING: The Android SDK is not installed or is not configured properly." ) ;
50
+ this . $logger . out ( "You will not be able to build your projects for Android and run them in the native emulator." + EOL
51
+ + "To be able to build for Android and run apps in the native emulator, verify that you have" + EOL
52
+ + "installed the latest Android SDK and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements" + EOL
53
+ ) ;
54
+
55
+ this . printPackageManagerTip ( ) ;
69
56
result = true ;
70
57
}
71
58
72
- if ( sysInfo . xcodeVer && sysInfo . cocoapodVer ) {
73
- let problemWithCocoaPods = this . verifyCocoaPods ( ) ;
74
- if ( problemWithCocoaPods ) {
75
- this . $logger . warn ( "WARNING: There was a problem with CocoaPods" ) ;
76
- this . $logger . out ( "Verify that CocoaPods are configured properly." ) ;
59
+ if ( this . $hostInfo . isDarwin ) {
60
+ if ( ! sysInfo . xcodeVer ) {
61
+ this . $logger . warn ( "WARNING: Xcode is not installed or is not configured properly." ) ;
62
+ this . $logger . out ( "You will not be able to build your projects for iOS or run them in the iOS Simulator." + EOL
63
+ + "To be able to build for iOS and run apps in the native emulator, verify that you have installed Xcode." + EOL ) ;
64
+ result = true ;
65
+ }
66
+
67
+ if ( ! sysInfo . cocoapodVer ) {
68
+ this . $logger . warn ( "WARNING: CocoaPods is not installed or is not configured properly." ) ;
69
+ this . $logger . out ( "You will not be able to build your projects for iOS if they contain plugin with CocoaPod file." + EOL
70
+ + "To be able to build such projects, verify that you have installed CocoaPods." ) ;
71
+ result = true ;
72
+ }
73
+
74
+ if ( sysInfo . xcodeVer && sysInfo . cocoapodVer ) {
75
+ let problemWithCocoaPods = this . verifyCocoaPods ( ) ;
76
+ if ( problemWithCocoaPods ) {
77
+ this . $logger . warn ( "WARNING: There was a problem with CocoaPods" ) ;
78
+ this . $logger . out ( "Verify that CocoaPods are configured properly." ) ;
79
+ result = true ;
80
+ }
81
+ }
82
+
83
+ if ( sysInfo . cocoapodVer && semver . valid ( sysInfo . cocoapodVer ) === null ) {
84
+ this . $logger . warn ( `WARNING: CocoaPods version is not a valid semver version.` ) ;
85
+ this . $logger . out ( "You will not be able to build your projects for iOS if they contain plugin with CocoaPod file." + EOL
86
+ + `To be able to build such projects, verify that you have at least ${ DoctorService . MIN_SUPPORTED_POD_VERSION } version installed.` ) ;
77
87
result = true ;
78
88
}
89
+
90
+ if ( sysInfo . cocoapodVer && semver . valid ( sysInfo . cocoapodVer ) && semver . lt ( sysInfo . cocoapodVer , DoctorService . MIN_SUPPORTED_POD_VERSION ) ) {
91
+ this . $logger . warn ( `WARNING: CocoaPods version is lower than ${ DoctorService . MIN_SUPPORTED_POD_VERSION } .` ) ;
92
+ this . $logger . out ( "You will not be able to build your projects for iOS if they contain plugin with CocoaPod file." + EOL
93
+ + `To be able to build such projects, verify that you have at least ${ DoctorService . MIN_SUPPORTED_POD_VERSION } version installed.` ) ;
94
+ result = true ;
95
+ }
96
+ } else {
97
+ this . $logger . out ( "NOTE: You can develop for iOS only on Mac OS X systems." ) ;
98
+ this . $logger . out ( "To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later." + EOL ) ;
79
99
}
80
100
81
- if ( sysInfo . cocoapodVer && semver . valid ( sysInfo . cocoapodVer ) === null ) {
82
- this . $logger . warn ( `WARNING: CocoaPods version is not a valid semver version.` ) ;
83
- this . $logger . out ( "You will not be able to build your projects for iOS if they contain plugin with CocoaPod file." + EOL
84
- + `To be able to build such projects, verify that you have at least ${ DoctorService . MIN_SUPPORTED_POD_VERSION } version installed.` ) ;
85
- result = true ;
101
+ let androidToolsIssues = this . $androidToolsInfo . validateInfo ( ) . wait ( ) ;
102
+ let javaVersionIssue = this . $androidToolsInfo . validateJavacVersion ( sysInfo . javacVersion ) . wait ( ) ;
103
+ let doctorResult = result || androidToolsIssues || javaVersionIssue ;
104
+
105
+ if ( ! configOptions || configOptions . trackResult ) {
106
+ this . $analyticsService . track ( "DoctorEnvironmentSetup" , doctorResult ? "incorrect" : "correct" ) . wait ( ) ;
86
107
}
87
108
88
- if ( sysInfo . cocoapodVer && semver . valid ( sysInfo . cocoapodVer ) && semver . lt ( sysInfo . cocoapodVer , DoctorService . MIN_SUPPORTED_POD_VERSION ) ) {
89
- this . $logger . warn ( `WARNING: CocoaPods version is lower than ${ DoctorService . MIN_SUPPORTED_POD_VERSION } .` ) ;
90
- this . $logger . out ( "You will not be able to build your projects for iOS if they contain plugin with CocoaPod file." + EOL
91
- + `To be able to build such projects, verify that you have at least ${ DoctorService . MIN_SUPPORTED_POD_VERSION } version installed.` ) ;
92
- result = true ;
109
+ if ( doctorResult ) {
110
+ this . $logger . info ( "There seem to be issues with your configuration." ) ;
111
+ if ( this . $hostInfo . isDarwin ) {
112
+ this . promptForHelp ( DoctorService . DarwinSetupDocsLink , DoctorService . DarwinSetupScriptLocation , [ ] ) . wait ( ) ;
113
+ } else if ( this . $hostInfo . isWindows ) {
114
+ this . promptForHelp ( DoctorService . WindowsSetupDocsLink , DoctorService . WindowsSetupScriptExecutable , DoctorService . WindowsSetupScriptArguments ) . wait ( ) ;
115
+ } else {
116
+ this . promptForDocs ( DoctorService . LinuxSetupDocsLink ) . wait ( ) ;
117
+ }
93
118
}
94
- } else {
95
- this . $logger . out ( "NOTE: You can develop for iOS only on Mac OS X systems." ) ;
96
- this . $logger . out ( "To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later." + EOL ) ;
97
- }
98
119
99
- let androidToolsIssues = this . $androidToolsInfo . validateInfo ( ) . wait ( ) ;
100
- let javaVersionIssue = this . $androidToolsInfo . validateJavacVersion ( sysInfo . javacVersion ) . wait ( ) ;
101
- let doctorResult = result || androidToolsIssues || javaVersionIssue ;
120
+ let versionsInformation : IVersionInformation [ ] = this . $versionsService . getComponentsForUpdate ( ) . wait ( ) ;
102
121
103
- if ( ! configOptions || configOptions . trackResult ) {
104
- this . $analyticsService . track ( "DoctorEnvironmentSetup" , doctorResult ? "incorrect" : "correct" ) . wait ( ) ;
105
- }
122
+ this . printVersionsInformation ( versionsInformation ) ;
106
123
107
- if ( doctorResult ) {
108
- this . $logger . info ( "There seem to be issues with your configuration." ) ;
109
- if ( this . $hostInfo . isDarwin ) {
110
- this . promptForHelp ( DoctorService . DarwinSetupDocsLink , DoctorService . DarwinSetupScriptLocation , [ ] ) . wait ( ) ;
111
- } else if ( this . $hostInfo . isWindows ) {
112
- this . promptForHelp ( DoctorService . WindowsSetupDocsLink , DoctorService . WindowsSetupScriptExecutable , DoctorService . WindowsSetupScriptArguments ) . wait ( ) ;
113
- } else {
114
- this . promptForDocs ( DoctorService . LinuxSetupDocsLink ) . wait ( ) ;
115
- }
116
- }
124
+ return doctorResult ;
125
+ } ) . future < boolean > ( ) ( ) ;
126
+ }
127
+
128
+ private printVersionsInformation ( versionsInformation : IVersionInformation [ ] ) {
129
+ if ( versionsInformation && versionsInformation . length ) {
130
+ let table : any = helpers . createTableWithVersionsInformation ( versionsInformation ) ;
117
131
118
- return doctorResult ;
132
+ this . $logger . warn ( "Updates available" ) ;
133
+ this . $logger . out ( table . toString ( ) + EOL ) ;
134
+ } else {
135
+ this . $logger . out ( "Your components are up to date." + EOL ) ;
136
+ }
119
137
}
120
138
121
139
private promptForDocs ( link : string ) : IFuture < void > {
@@ -165,17 +183,17 @@ class DoctorService implements IDoctorService {
165
183
spinner . message ( "Verifying CocoaPods. This may take some time, please be patient." ) ;
166
184
spinner . start ( ) ;
167
185
let future = this . $childProcess . spawnFromEvent (
168
- this . $config . USE_POD_SANDBOX ? "sandbox-pod" : "pod" ,
186
+ this . $config . USE_POD_SANDBOX ? "sandbox-pod" : "pod" ,
169
187
[ "install" ] ,
170
188
"exit" ,
171
- { stdio : "inherit" , cwd : iosDir } ,
189
+ { stdio : "inherit" , cwd : iosDir } ,
172
190
{ throwError : true }
173
- ) ;
191
+ ) ;
174
192
175
193
this . $progressIndicator . showProgressIndicator ( future , 5000 ) . wait ( ) ;
176
194
177
195
return ! ( this . $fs . exists ( path . join ( iosDir , "__PROJECT_NAME__.xcworkspace" ) ) . wait ( ) ) ;
178
- } catch ( err ) {
196
+ } catch ( err ) {
179
197
this . $logger . trace ( `verifyCocoaPods error: ${ err } ` ) ;
180
198
return true ;
181
199
} finally {
0 commit comments