Skip to content

Commit 9940fdd

Browse files
committed
Fix PR comments
1 parent 28a0cbd commit 9940fdd

File tree

3 files changed

+47
-34
lines changed

3 files changed

+47
-34
lines changed

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ export class NativescriptCloudExtensionService implements INativescriptCloudExte
2929
}
3030

3131
private getExtensionData(): IExtensionData {
32-
return this.$extensibilityService.getInstalledExtensionsData()
33-
.find(extensionData => extensionData.extensionName === constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME);
32+
return _.find(this.$extensibilityService.getInstalledExtensionsData(), extensionData => extensionData.extensionName === constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME);
3433
}
3534
}
3635
$injector.register("nativescriptCloudExtensionService", NativescriptCloudExtensionService);

lib/services/platform-environment-requirements.ts

+43-30
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
1515
public static LOCAL_SETUP_OPTION_NAME = "Configure for Local Builds";
1616
public static MANUALLY_SETUP_OPTION_NAME = "Skip Step and Configure Manually";
1717
private static BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME = "Configure for Both Local and Cloud Builds";
18-
private static NOT_CONFIGURED_ENV_MESSAGE = "To continue, choose one of the following options: ";
19-
private static NOT_CONFIGURED_ENV_AFTER_SETUP_SCRIPT_MESSAGE = "The setup script was not able to configure your environment for local builds. To execute local builds, you have to set up your environment manually. In case you have any issues, you can ask in our forum. To continue, choose one of the following options:";
20-
private static MISSING_LOCAL_AND_CLOUD_SETUP_MESSAGE = `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: `;
21-
private static MISSING_LOCAL_SETUP_MESSAGE = 'Your environment is not configured properly and you will not be able to execute local builds.';
18+
private static CHOOSE_OPTIONS_MESSAGE = "To continue, choose one of the following options: ";
19+
private static NOT_CONFIGURED_ENV_AFTER_SETUP_SCRIPT_MESSAGE = `The setup script was not able to configure your environment for local builds. To execute local builds, you have to set up your environment manually. In case you have any questions, you can check our forum: 'http://forum.nativescript.org' and our public Slack channel: 'https://nativescriptcommunity.slack.com/'. ${PlatformEnvironmentRequirements.CHOOSE_OPTIONS_MESSAGE}`;
20+
private static MISSING_LOCAL_SETUP_MESSAGE = "Your environment is not configured properly and you will not be able to execute local builds.";
21+
private static MISSING_LOCAL_AND_CLOUD_SETUP_MESSAGE = `You are missing the ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension and you will not be able to execute cloud builds. ${PlatformEnvironmentRequirements.MISSING_LOCAL_SETUP_MESSAGE} ${PlatformEnvironmentRequirements.CHOOSE_OPTIONS_MESSAGE} `;
22+
private static RUN_TNS_SETUP_MESSAGE = 'Run $ tns setup command to run the setup script to try to automatically configure your environment for local builds.';
2223

2324
private cliCommandToCloudCommandName: IStringDictionary = {
2425
"build": "tns cloud build",
@@ -131,34 +132,38 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
131132
}
132133

133134
private getNonInteractiveConsoleMessage(platform: string) {
134-
if (this.$nativescriptCloudExtensionService.isInstalled()) {
135-
return `${PlatformEnvironmentRequirements.MISSING_LOCAL_SETUP_MESSAGE} To continue, choose one of the following options: ` + EOL
136-
+ "Run $ tns setup command to run the setup script to try to automatically configure your environment for local builds." + EOL
137-
+ `${this.getCloudBuildsMessage(platform)}` + EOL
138-
+ `Verify that your environment is configured according to the system requirements described at ${this.$staticConfig.SYS_REQUIREMENTS_LINK}.`;
139-
}
140-
141-
return `${PlatformEnvironmentRequirements.MISSING_LOCAL_AND_CLOUD_SETUP_MESSAGE}` + EOL
142-
+ "Run $ tns setup command to run the setup script to try to automatically configure your environment for local builds." + EOL
143-
+ `Run $ tns cloud setup command to install the ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension to configure your environment for cloud builds.` + EOL
144-
+ `Verify that your environment is configured according to the system requirements described at ${this.$staticConfig.SYS_REQUIREMENTS_LINK}.`;
135+
return this.$nativescriptCloudExtensionService.isInstalled() ?
136+
this.buildMultilineMessage([
137+
`${PlatformEnvironmentRequirements.MISSING_LOCAL_SETUP_MESSAGE} ${PlatformEnvironmentRequirements.CHOOSE_OPTIONS_MESSAGE}`,
138+
PlatformEnvironmentRequirements.RUN_TNS_SETUP_MESSAGE,
139+
this.getCloudBuildsMessage(platform),
140+
this.getEnvVerificationMessage()
141+
]) :
142+
this.buildMultilineMessage([
143+
PlatformEnvironmentRequirements.MISSING_LOCAL_AND_CLOUD_SETUP_MESSAGE,
144+
PlatformEnvironmentRequirements.RUN_TNS_SETUP_MESSAGE,
145+
`Run $ tns cloud setup command to install the ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension to configure your environment for cloud builds.`,
146+
this.getEnvVerificationMessage()
147+
]);
145148
}
146149

147150
private getInteractiveConsoleMessage(platform: string) {
148-
if (this.$nativescriptCloudExtensionService.isInstalled()) {
149-
const message = `The ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension is installed and you can ${_.lowerFirst(this.getCloudBuildsMessage(platform))}`;
150-
151-
return `${message.bold}` + EOL
152-
+ `${PlatformEnvironmentRequirements.MISSING_LOCAL_SETUP_MESSAGE} To continue, choose one of the following options: ` + EOL
153-
+ `Select "Configure for Local Builds" to run the setup script and automatically configure your environment for local builds.` + EOL
154-
+ `Select "Skip Step and Configure Manually" to disregard this option and install any required components manually.`;
155-
}
156-
157-
return `${PlatformEnvironmentRequirements.MISSING_LOCAL_AND_CLOUD_SETUP_MESSAGE}` + EOL
158-
+ `Select "Configure for Cloud Builds" to install the ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension and automatically configure your environment for cloud builds.` + EOL
159-
+ `Select "Configure for Local Builds" to run the setup script and automatically configure your environment for local builds.`
160-
+ `Select "Configure for Both Local and Cloud Builds" to automatically configure your environment for both options.`
161-
+ `Select "Skip Step and Configure Manually" to disregard these options and install any required components manually.`;
151+
const message = `The ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension is installed and you can ${_.lowerFirst(this.getCloudBuildsMessage(platform))}`;
152+
153+
return this.$nativescriptCloudExtensionService.isInstalled() ?
154+
this.buildMultilineMessage([
155+
`${message.bold}`,
156+
`${PlatformEnvironmentRequirements.MISSING_LOCAL_SETUP_MESSAGE} ${PlatformEnvironmentRequirements.CHOOSE_OPTIONS_MESSAGE}`,
157+
`Select "Configure for Local Builds" to run the setup script and automatically configure your environment for local builds.`,
158+
`Select "Skip Step and Configure Manually" to disregard this option and install any required components manually.`
159+
]) :
160+
this.buildMultilineMessage([
161+
PlatformEnvironmentRequirements.MISSING_LOCAL_AND_CLOUD_SETUP_MESSAGE,
162+
`Select "Configure for Cloud Builds" to install the ${constants.NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension and automatically configure your environment for cloud builds.`,
163+
`Select "Configure for Local Builds" to run the setup script and automatically configure your environment for local builds.`,
164+
`Select "Configure for Both Local and Cloud Builds" to automatically configure your environment for both options.`,
165+
`Select "Configure for Both Local and Cloud Builds" to automatically configure your environment for both options.`
166+
]);
162167
}
163168

164169
private promptForChoice(): Promise<string> {
@@ -172,7 +177,15 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
172177
PlatformEnvironmentRequirements.MANUALLY_SETUP_OPTION_NAME,
173178
];
174179

175-
return this.$prompter.promptForChoice(PlatformEnvironmentRequirements.NOT_CONFIGURED_ENV_MESSAGE, choices);
180+
return this.$prompter.promptForChoice(PlatformEnvironmentRequirements.CHOOSE_OPTIONS_MESSAGE, choices);
181+
}
182+
183+
private getEnvVerificationMessage() {
184+
return `Verify that your environment is configured according to the system requirements described at ${this.$staticConfig.SYS_REQUIREMENTS_LINK}.`;
185+
}
186+
187+
private buildMultilineMessage(parts: string[]): string {
188+
return parts.join(EOL);
176189
}
177190
}
178191
$injector.register("platformEnvironmentRequirements", PlatformEnvironmentRequirements);

test/services/platform-environment-requirements.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { Yok } from "../../lib/common/yok";
22
import { PlatformEnvironmentRequirements } from '../../lib/services/platform-environment-requirements';
33
import * as stubs from "../stubs";
44
import { assert } from "chai";
5+
import { EOL } from "os";
56

67
const platform = "android";
78
const cloudBuildsErrorMessage = `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.`;
89
const manuallySetupErrorMessage = `To be able to build for ${platform}, verify that your environment is configured according to the system requirements described at `;
9-
const nonInteractiveConsoleMessageWhenExtensionIsNotInstalled = `You are missing the nativescript-cloud 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: \nRun $ tns setup command to run the setup script to try to automatically configure your environment for local builds.\nRun $ tns cloud setup command to install the nativescript-cloud extension to configure your environment for cloud builds.\nVerify that your environment is configured according to the system requirements described at `;
10-
const nonInteractiveConsoleMessageWhenExtensionIsInstalled = `Your environment is not configured properly and you will not be able to execute local builds. To continue, choose one of the following options: \nRun $ tns setup command to run the setup script to try to automatically configure your environment for local builds.\nIn 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.\nVerify that your environment is configured according to the system requirements described at .`;
10+
const nonInteractiveConsoleMessageWhenExtensionIsNotInstalled = `You are missing the nativescript-cloud 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}Run $ tns setup command to run the setup script to try to automatically configure your environment for local builds.${EOL}Run $ tns cloud setup command to install the nativescript-cloud extension to configure your environment for cloud builds.${EOL}Verify that your environment is configured according to the system requirements described at `;
11+
const nonInteractiveConsoleMessageWhenExtensionIsInstalled = `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}Run $ tns setup command to run the setup script to try to automatically configure your environment for local builds.${EOL}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.${EOL}Verify that your environment is configured according to the system requirements described at .`;
1112

1213
function createTestInjector() {
1314
const testInjector = new Yok();

0 commit comments

Comments
 (0)