Skip to content

Commit ad23f8c

Browse files
committed
[WIP] Fix env messages
1 parent 3f2cb1f commit ad23f8c

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

lib/declarations.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,11 @@ interface INativescriptCloudExtensionService {
794794
* @return {Promise<IExtensionData>} returns the extension data
795795
*/
796796
install(): Promise<IExtensionData>;
797+
/**
798+
* Checks if nativescript-cloud extension is installed
799+
* @return {boolean} returns true in case when nativescript-cloud extension is installed, false otherwise
800+
*/
801+
isInstalled(): boolean
797802
}
798803

799804
/**

lib/services/nativescript-cloud-extension-service.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ export class NativescriptCloudExtensionService implements INativescriptCloudExte
66
private $logger: ILogger) { }
77

88
public install(): Promise<IExtensionData> {
9-
const installedExtensions = this.$extensibilityService.getInstalledExtensions() || {};
10-
if (!installedExtensions[constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME]) {
9+
if (!this.isInstalled()) {
1110
return this.$extensibilityService.installExtension(constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME);
1211
}
1312

1413
this.$logger.out(`Extension ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} is already installed.`);
1514
}
15+
16+
public isInstalled(): boolean {
17+
return !!this.getInstalledExtensions()[constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME];
18+
}
19+
20+
private getInstalledExtensions(): IStringDictionary {
21+
return this.$extensibilityService.getInstalledExtensions() || {};
22+
}
1623
}
1724
$injector.register("nativescriptCloudExtensionService", NativescriptCloudExtensionService);

lib/services/platform-environment-requirements.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
3232
const canExecute = await this.$doctorService.canExecuteLocalBuild(platform);
3333
if (!canExecute) {
3434
if (!isInteractive()) {
35-
this.fail(`You are missing the ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension and you will not be able to execute cloud builds. Your environment is not configured properly and you will not be able to execute local builds. To continue, choose one of the following options: ` + EOL
36-
+ "Run $ tns setup command to run the setup script to try to automatically configure your environment for local builds." + EOL
37-
+ `Run $ tns cloud setup command to install the ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension to configure your environment for cloud builds.` + EOL
38-
+ `Verify that your environment is configured according to the system requirements described at ${this.$staticConfig.SYS_REQUIREMENTS_LINK}`);
35+
this.fail(this.getNonInteractiveConsoleMessage(platform));
3936
}
4037

41-
this.$logger.info(`You are missing the ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension and you will not be able to execute cloud builds. Your environment is not configured properly and you will not be able to execute local builds. ` + EOL
38+
this.$logger.info(`` + EOL
4239
+ `Select "Configure for Cloud Builds" to install the ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension and automatically configure your environment for cloud builds.` + EOL
4340
+ `Select "Configure for Local Builds" to run the setup script and automatically configure your environment for local builds.`
4441
+ `Select "Configure for Both Local and Cloud Builds" to automatically configure your environment for both options.`
@@ -100,7 +97,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
10097
return this.$nativescriptCloudExtensionService.install();
10198
}
10299

103-
private getCloudBuildsMessage(platform: string): string {
100+
private getCloudBuildsMessage(platform: string): string {
104101
const cloudCommandName = this.cliCommandToCloudCommandName[this.$commandsService.currentCommandData.commandName];
105102
if (!cloudCommandName) {
106103
return `In order to test your application use the $ tns login command to log in with your account and then $ tns cloud build command to build your app in the cloud.`;
@@ -136,5 +133,19 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
136133
private fail(message: string): void {
137134
this.$errors.fail({ formatStr: message, suppressCommandHelp: true, printOnStdout: true });
138135
}
136+
137+
private getNonInteractiveConsoleMessage(platform: string) {
138+
if (!this.$nativescriptCloudExtensionService.isInstalled()) {
139+
return `You are missing the ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension and you will not be able to execute cloud builds. Your environment is not configured properly and you will not be able to execute local builds. To continue, choose one of the following options: ` + EOL
140+
+ "Run $ tns setup command to run the setup script to try to automatically configure your environment for local builds." + EOL
141+
+ `Run $ tns cloud setup command to install the ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension to configure your environment for cloud builds.` + EOL
142+
+ `Verify that your environment is configured according to the system requirements described at ${this.$staticConfig.SYS_REQUIREMENTS_LINK}.`
143+
}
144+
145+
return `Your environment is not configured properly and you will not be able to execute local builds. To continue, choose one of the following options: ` + EOL
146+
+ "Run $ tns setup command to run the setup script to try to automatically configure your environment for local builds." + EOL
147+
+ `${this.getCloudBuildsMessage(platform)}` + EOL
148+
+ `Verify that your environment is configured according to the system requirements described at ${this.$staticConfig.SYS_REQUIREMENTS_LINK}.`;
149+
}
139150
}
140151
$injector.register("platformEnvironmentRequirements", PlatformEnvironmentRequirements);

0 commit comments

Comments
 (0)