-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
Conversation
7f52de6
to
1407c43
Compare
run ci |
fb1641a
to
67c1cc3
Compare
You should add references to the two new commands in |
docs/man_pages/cloud/cloud-setup.md
Outdated
------|------- | ||
Install the nativescript-cloud extension | `$ tns cloud setup` | ||
|
||
Install the nativescript-cloud extension to configure your environment for cloud builds. |
There was a problem hiding this comment.
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
lib/android-tools-info.ts
Outdated
} 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 { |
There was a problem hiding this comment.
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
lib/commands/build.ts
Outdated
$bundleValidatorHelper: IBundleValidatorHelper) { | ||
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper); | ||
$bundleValidatorHelper: IBundleValidatorHelper, | ||
$platformEnvironmentRequirements: IPlatformEnvironmentRequirements) { |
There was a problem hiding this comment.
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
lib/commands/build.ts
Outdated
$bundleValidatorHelper: IBundleValidatorHelper) { | ||
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper); | ||
$bundleValidatorHelper: IBundleValidatorHelper, | ||
$platformEnvironmentRequirements: IPlatformEnvironmentRequirements) { |
There was a problem hiding this comment.
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
lib/commands/setup.ts
Outdated
constructor(private $extensibilityService: IExtensibilityService) { } | ||
|
||
public async execute(args: string[]): Promise<any> { | ||
return this.$extensibilityService.installExtension("nativescript-cloud"); |
There was a problem hiding this comment.
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.
67c1cc3
to
26ef91b
Compare
lib/commands/setup.ts
Outdated
return this.$doctorService.runSetupScript(); | ||
} | ||
|
||
public async canExecute(args: string[]): Promise<boolean> { |
There was a problem hiding this comment.
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
lib/commands/setup.ts
Outdated
return true; | ||
} | ||
} | ||
$injector.registerCommand("cloud|setup", CloudSetupCommand); |
There was a problem hiding this comment.
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 💭
lib/commands/setup.ts
Outdated
} | ||
} | ||
|
||
public async canExecute(args: string[]): Promise<boolean> { |
There was a problem hiding this comment.
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
lib/commands/setup.ts
Outdated
|
||
public async execute(args: string[]): Promise<any> { | ||
const installedExtensions = this.$extensibilityService.getInstalledExtensions(); | ||
if (!installedExtensions["nativescript-cloud"]) { |
There was a problem hiding this comment.
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
lib/commands/setup.ts
Outdated
|
||
constructor(private $extensibilityService: IExtensibilityService) { } | ||
|
||
public async execute(args: string[]): Promise<any> { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 {}; }; |
There was a problem hiding this comment.
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 {}; }; |
There was a problem hiding this comment.
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 {}; }; |
There was a problem hiding this comment.
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
3f8a29d
to
af0198d
Compare
run ci |
There was a problem hiding this 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
a924214
to
bb1a886
Compare
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.}"
bb1a886
to
4e51bc6
Compare
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