Skip to content

Getting started improvements #3426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 12, 2018
Merged

Conversation

Fatme
Copy link
Contributor

@Fatme Fatme commented Mar 7, 2018

When build or run command is executed, checks if the environment is properly configured for executing local builds. If it is not properly configured, {N} CLI shows a prompt and user is able to choice if to run setup script or use cloud builds.

If cloud builds option is selected, {N} CLI installs the nativescript-cloud extension and prints that user can use the $ tns login command to log in with his/her account and then $ tns cloud run/build android/ios command to build his/her app in the cloud.

If setup script option is selected, {N} CLI runs the setup script to try and automatically configure the environment. If the environment is not properly configured after executing the setup script, {N} CLI shows a prompt and user is able to choice if to use cloud builds or manually setup the environment. If the manually setup option is selected, {N} CLI prints: "To be able to build for android/ios, verify that your environment is configured according to the system requirements described at https://docs.nativescript.org/start/ns-setup-os-x.}"

Should be merged after this PR https://github.com/telerik/mobile-cli-lib/pull/1058/files

ping @rosen-vladimirov @Mitko-Kerezov

@Fatme Fatme force-pushed the fatme/getting-started-improvements branch 5 times, most recently from 7f52de6 to 1407c43 Compare March 8, 2018 08:14
@Fatme
Copy link
Contributor Author

Fatme commented Mar 8, 2018

run ci

@Fatme Fatme force-pushed the fatme/getting-started-improvements branch 3 times, most recently from fb1641a to 67c1cc3 Compare March 8, 2018 14:38
@Mitko-Kerezov
Copy link
Contributor

You should add references to the two new commands in index.md so that they are listed in tns -h

------|-------
Install the nativescript-cloud extension | `$ tns cloud setup`

Install the nativescript-cloud extension to configure your environment for cloud builds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer nativescript-cloud to be surrounded in backticks -> `nativescript-cloud`
A personal preference though, not a merge-stopper

} else if (!targetSdk || targetSdk > this.getMaxSupportedVersion()) {
this.$logger.warn(`Support for the selected Android target SDK ${newTarget} is not verified. Your Android app might not work as expected.`);
}
public validateTargetSdk(options?: { showWarningsAsErrors: boolean }): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can extract { showWarningsAsErrors: boolean } as an interface.
While you're on it you can extract { validateTargetSdk: boolean} too and reuse both everywhere

$bundleValidatorHelper: IBundleValidatorHelper) {
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper);
$bundleValidatorHelper: IBundleValidatorHelper,
$platformEnvironmentRequirements: IPlatformEnvironmentRequirements) {
Copy link
Contributor Author

@Fatme Fatme Mar 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed. It is not used

$bundleValidatorHelper: IBundleValidatorHelper) {
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper);
$bundleValidatorHelper: IBundleValidatorHelper,
$platformEnvironmentRequirements: IPlatformEnvironmentRequirements) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not used, should be removed

constructor(private $extensibilityService: IExtensibilityService) { }

public async execute(args: string[]): Promise<any> {
return this.$extensibilityService.installExtension("nativescript-cloud");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check if extension is already installed. If this is the case it shouldn't install again.

@Fatme Fatme force-pushed the fatme/getting-started-improvements branch from 67c1cc3 to 26ef91b Compare March 9, 2018 07:16
return this.$doctorService.runSetupScript();
}

public async canExecute(args: string[]): Promise<boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why implement a canExecute method at all

return true;
}
}
$injector.registerCommand("cloud|setup", CloudSetupCommand);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the other cloud operations have both cloud <operation> as well as <operation> cloud
Ping @rosen-vladimirov what do you think - should we add "setup|cloud" to the list 💭

}
}

public async canExecute(args: string[]): Promise<boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can skip implementing canExecute here


public async execute(args: string[]): Promise<any> {
const installedExtensions = this.$extensibilityService.getInstalledExtensions();
if (!installedExtensions["nativescript-cloud"]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can extract "nativescript-cloud" to a constant and reuse it here and inplatform-environment-requirements.ts


constructor(private $extensibilityService: IExtensibilityService) { }

public async execute(args: string[]): Promise<any> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need for this method to be async

let isPromptForChoiceCalled = false;
const prompter = testInjector.resolve("prompter");
prompter.promptForChoice = () => {
if (index === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too

let isPromptForChoiceCalled = false;
const prompter = testInjector.resolve("prompter");
prompter.promptForChoice = () => {
if (index === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

let isInstallExtensionCalled = false;
const extensibilityService = testInjector.resolve("extensibilityService");
extensibilityService.installExtension = () => {isInstallExtensionCalled = true; };
extensibilityService.getInstalledExtensions = () => { return {}; };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the short syntax to return an object here:
extensibilityService.getInstalledExtensions = () => ({});

let isInstallExtensionCalled = false;
const extensibilityService = testInjector.resolve("extensibilityService");
extensibilityService.installExtension = () => isInstallExtensionCalled = true;
extensibilityService.getInstalledExtensions = () => { return {}; };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can shorten the syntax here

let isInstallExtensionCalled = false;
const extensibilityService = testInjector.resolve("extensibilityService");
extensibilityService.installExtension = () => isInstallExtensionCalled = true;
extensibilityService.getInstalledExtensions = () => { return {}; };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can shorten the syntax here

@Fatme Fatme force-pushed the fatme/getting-started-improvements branch 3 times, most recently from 3f8a29d to af0198d Compare March 12, 2018 07:05
@dtopuzov
Copy link
Contributor

run ci

Copy link
Contributor

@Mitko-Kerezov Mitko-Kerezov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me

@Fatme Fatme force-pushed the fatme/getting-started-improvements branch 2 times, most recently from a924214 to bb1a886 Compare March 12, 2018 09:54
Fatme added 7 commits March 12, 2018 13:18
When build or run command is executed, checks if the environment is properly configured for executing local builds. If it is not properly configured, {N} CLI shows a prompt and user is able to choice if to run setup script or use cloud builds.

If cloud builds option is selected, {N} CLI installs the nativescript-cloud extension and prints that user can use the $ tns login command to log in with his/her account and then $ tns cloud run/build android/ios command to build his/her app in the cloud.

If setup script option is selected, {N} CLI runs the setup script to try and automatically configure the environment. If the environment is not properly configured after executing the setup script, {N} CLI shows a prompt and user is able to choice if to use cloud builds or manually setup the environment. If the manually setup option is selected, {N} CLI prints: "To be able to build for android/ios, verify that your environment is configured according to the system requirements described at https://docs.nativescript.org/start/ns-setup-os-x.}"
@Fatme Fatme force-pushed the fatme/getting-started-improvements branch from bb1a886 to 4e51bc6 Compare March 12, 2018 11:19
@Fatme Fatme merged commit 8a6b640 into master Mar 12, 2018
@Fatme Fatme deleted the fatme/getting-started-improvements branch March 12, 2018 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants