@@ -9,10 +9,12 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
9
9
private $logger : ILogger ,
10
10
private $nativeScriptCloudExtensionService : INativeScriptCloudExtensionService ,
11
11
private $prompter : IPrompter ,
12
- private $staticConfig : IStaticConfig ) { }
12
+ private $staticConfig : IStaticConfig ,
13
+ private $analyticsService : IAnalyticsService ) { }
13
14
14
15
public static CLOUD_SETUP_OPTION_NAME = "Configure for Cloud Builds" ;
15
16
public static LOCAL_SETUP_OPTION_NAME = "Configure for Local Builds" ;
17
+ public static TRY_CLOUD_OPERATION_OPTION_NAME = "Try Cloud Operation" ;
16
18
public static MANUALLY_SETUP_OPTION_NAME = "Skip Step and Configure Manually" ;
17
19
private static BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME = "Configure for Both Local and Cloud Builds" ;
18
20
private static CHOOSE_OPTIONS_MESSAGE = "To continue, choose one of the following options: " ;
@@ -27,14 +29,24 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
27
29
"deploy" : "tns cloud deploy"
28
30
} ;
29
31
30
- public async checkEnvironmentRequirements ( platform : string ) : Promise < boolean > {
32
+ public async checkEnvironmentRequirements ( platform : string , projectDir : string ) : Promise < boolean > {
31
33
if ( process . env . NS_SKIP_ENV_CHECK ) {
34
+ await this . $analyticsService . trackEventActionInGoogleAnalytics ( {
35
+ action : "Check Environment Requirements" ,
36
+ additionalData : "Skipped:NS_SKIP_ENV_CHECK is set" ,
37
+ projectDir
38
+ } ) ;
32
39
return true ;
33
40
}
34
41
35
42
const canExecute = await this . $doctorService . canExecuteLocalBuild ( platform ) ;
36
43
if ( ! canExecute ) {
37
44
if ( ! isInteractive ( ) ) {
45
+ await this . $analyticsService . trackEventActionInGoogleAnalytics ( {
46
+ action : "Check Environment Requirements" ,
47
+ additionalData : "Non-interactive terminal, unable to execute local builds." ,
48
+ projectDir
49
+ } ) ;
38
50
this . fail ( this . getNonInteractiveConsoleMessage ( platform ) ) ;
39
51
}
40
52
@@ -74,6 +86,11 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
74
86
75
87
this . processManuallySetup ( platform ) ;
76
88
}
89
+
90
+ if ( selectedOption === PlatformEnvironmentRequirements . TRY_CLOUD_OPERATION_OPTION_NAME ) {
91
+ const message = `You can use ${ _ . lowerFirst ( this . getCloudBuildsMessage ( platform ) ) } ` ;
92
+ this . fail ( message ) ;
93
+ }
77
94
}
78
95
79
96
return true ;
@@ -166,18 +183,25 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
166
183
] ) ;
167
184
}
168
185
169
- private promptForChoice ( ) : Promise < string > {
186
+ private async promptForChoice ( ) : Promise < string > {
170
187
const choices = this . $nativeScriptCloudExtensionService . isInstalled ( ) ? [
188
+ PlatformEnvironmentRequirements . TRY_CLOUD_OPERATION_OPTION_NAME ,
171
189
PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME ,
172
190
PlatformEnvironmentRequirements . MANUALLY_SETUP_OPTION_NAME ,
173
191
] : [
174
- PlatformEnvironmentRequirements . CLOUD_SETUP_OPTION_NAME ,
175
- PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME ,
176
- PlatformEnvironmentRequirements . BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME ,
177
- PlatformEnvironmentRequirements . MANUALLY_SETUP_OPTION_NAME ,
178
- ] ;
179
-
180
- return this . $prompter . promptForChoice ( PlatformEnvironmentRequirements . CHOOSE_OPTIONS_MESSAGE , choices ) ;
192
+ PlatformEnvironmentRequirements . CLOUD_SETUP_OPTION_NAME ,
193
+ PlatformEnvironmentRequirements . LOCAL_SETUP_OPTION_NAME ,
194
+ PlatformEnvironmentRequirements . BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME ,
195
+ PlatformEnvironmentRequirements . MANUALLY_SETUP_OPTION_NAME ,
196
+ ] ;
197
+
198
+ const selection = await this . $prompter . promptForChoice ( PlatformEnvironmentRequirements . CHOOSE_OPTIONS_MESSAGE , choices ) ;
199
+ await this . $analyticsService . trackEventActionInGoogleAnalytics ( {
200
+ action : "Check Environment Requirements" ,
201
+ additionalData : `User selected: ${ selection } `
202
+ // consider passing projectDir here
203
+ } ) ;
204
+ return selection ;
181
205
}
182
206
183
207
private getEnvVerificationMessage ( ) {
0 commit comments