@@ -26,96 +26,118 @@ class DoctorService implements IDoctorService {
2626 private $npm : INodePackageManager ,
2727 private $opener : IOpener ,
2828 private $prompter : IPrompter ,
29- private $fs : IFileSystem ) { }
29+ private $fs : IFileSystem ,
30+ private $versionsService : IVersionsService ) { }
3031
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 ( ) ;
5236
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 ) ;
5643
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 ( ) ;
6245 result = true ;
6346 }
6447
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 ( ) ;
6956 result = true ;
7057 }
7158
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: Your current CocoaPods version is not a valid semver string.` ) ;
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 installed a CocoaPods version which is a valid semver string and is at least ${ DoctorService . MIN_SUPPORTED_POD_VERSION } .` ) ;
7787 result = true ;
7888 }
89+
90+ if ( sysInfo . cocoapodVer && semver . valid ( sysInfo . cocoapodVer ) && semver . lt ( sysInfo . cocoapodVer , DoctorService . MIN_SUPPORTED_POD_VERSION ) ) {
91+ this . $logger . warn ( `WARNING: Your current CocoaPods version is earlier 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 ) ;
7999 }
80100
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 ( ) ;
86107 }
87108
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+ }
93118 }
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- }
98119
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 [ ] = [ ] ;
121+ try {
122+ versionsInformation = this . $versionsService . getComponentsForUpdate ( ) . wait ( ) ;
123+ this . printVersionsInformation ( versionsInformation ) ;
124+ } catch ( err ) {
125+ this . $logger . error ( "Cannot get the latest versions information from npm. Please try again later." ) ;
126+ }
102127
103- if ( ! configOptions || configOptions . trackResult ) {
104- this . $analyticsService . track ( "DoctorEnvironmentSetup" , doctorResult ? "incorrect" : "correct" ) . wait ( ) ;
105- }
128+ return doctorResult ;
129+ } ) . future < boolean > ( ) ( ) ;
130+ }
106131
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- }
132+ private printVersionsInformation ( versionsInformation : IVersionInformation [ ] ) {
133+ if ( versionsInformation && versionsInformation . length ) {
134+ let table : any = this . $versionsService . createTableWithVersionsInformation ( versionsInformation ) ;
117135
118- return doctorResult ;
136+ this . $logger . warn ( "Updates available" ) ;
137+ this . $logger . out ( table . toString ( ) + EOL ) ;
138+ } else {
139+ this . $logger . out ( "Your components are up-to-date." + EOL ) ;
140+ }
119141 }
120142
121143 private promptForDocs ( link : string ) : IFuture < void > {
@@ -165,17 +187,17 @@ class DoctorService implements IDoctorService {
165187 spinner . message ( "Verifying CocoaPods. This may take some time, please be patient." ) ;
166188 spinner . start ( ) ;
167189 let future = this . $childProcess . spawnFromEvent (
168- this . $config . USE_POD_SANDBOX ? "sandbox-pod" : "pod" ,
190+ this . $config . USE_POD_SANDBOX ? "sandbox-pod" : "pod" ,
169191 [ "install" ] ,
170192 "exit" ,
171- { stdio : "inherit" , cwd : iosDir } ,
193+ { stdio : "inherit" , cwd : iosDir } ,
172194 { throwError : true }
173- ) ;
195+ ) ;
174196
175197 this . $progressIndicator . showProgressIndicator ( future , 5000 ) . wait ( ) ;
176198
177199 return ! ( this . $fs . exists ( path . join ( iosDir , "__PROJECT_NAME__.xcworkspace" ) ) . wait ( ) ) ;
178- } catch ( err ) {
200+ } catch ( err ) {
179201 this . $logger . trace ( `verifyCocoaPods error: ${ err } ` ) ;
180202 return true ;
181203 } finally {
0 commit comments