Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

fix getxcodeversion usage #996

Merged
merged 3 commits into from
Aug 4, 2017
Merged

Conversation

Plamen5kov
Copy link
Contributor

problem
related issue: NativeScript/nativescript-cli#2810
getxcodeversion returning null isn't handled correctly in tns doctor

solution
handle erroneous case and remove unnecessary code

let xcodeVer = await sysInfoBase.getXCodeVersion();
if (!xcodeVer) {
this.$errors.fail("xcodebuild execution failed. Make sure that you have latest Xcode and tools installed.");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add one new line after this }

sys-info-base.ts Outdated
}

return this.xCodeVerCache;
return this.$hostInfo.isDarwin ? await this.exec("xcodebuild -version") : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we don't want to have cache anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'll return the cache

sys-info-base.ts Outdated
@@ -157,9 +147,9 @@ export class SysInfoBase implements ISysInfo {
res.procArch = process.arch;
res.nodeVer = process.version;

res.npmVer = await this.getNpmVersion();
res.npmVer = await this.getNpmVersion(); //not used anywhere except for tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check if we use this in the AppBuilder CLI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i got no private access to look at the repo, i'll remove the comments

sys-info-base.ts Outdated

res.javaVer = await this.getJavaVersion();
res.javaVer = await this.getJavaVersion(); //not used anywhere except for tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check if we use this in the AppBuilder CLI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i got no private access to look at the repo, i'll remove the comments

sys-info-base.ts Outdated
@@ -207,6 +197,7 @@ export class SysInfoBase implements ISysInfo {
}
} catch (e) {
// if we got an error, assume not working
this.$logger.trace(`Error while executing child process: ${e}`);
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 change child process to ${cmd}. Also I think if we log ${e} here, in the logs we will see [object object] instead of the error. You can log e.message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

@Plamen5kov Plamen5kov force-pushed the plamen5kov/fix-getxcodeversion-usage branch from 423ea30 to 20888cf Compare August 2, 2017 09:59
@Plamen5kov Plamen5kov self-assigned this Aug 2, 2017
xcodeVersionMatch = xcodeVer.match(/Xcode (.*)/),
let xcodeVer = await sysInfoBase.getXCodeVersion();
if (!xcodeVer) {
this.$errors.fail("xcodebuild execution failed. Make sure that you have latest Xcode and tools installed.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use this.$errors.failWithoutHelp here or we need to use fail?

Copy link
Contributor Author

@Plamen5kov Plamen5kov Aug 3, 2017

Choose a reason for hiding this comment

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

I originally made it to failWithoutHelp, but for consistency with https://github.com/NativeScript/nativescript-cli/blob/1955028ac3ded6a012813476f08d0f4f0d89dddd/lib/services/ios-project-service.ts#L1190 i
If you insist I have no objection of making it fail without help. I just want to have the same behavior in the code.

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 it is better to use this.$errors.failWithoutHelp in the services.

@Plamen5kov Plamen5kov merged commit b5b3db1 into master Aug 4, 2017
@Plamen5kov Plamen5kov deleted the plamen5kov/fix-getxcodeversion-usage branch August 4, 2017 12:16
@rosen-vladimirov
Copy link
Collaborator

This code will not fix the mentioned issue, it will just fail with different error when executing tns doctor.
By definition tns doctor should detect all issues and print them, it should not fail and stop execution once a single issue is detected.

@Plamen5kov am I missing something here, maybe there's another PR in {N} CLI that would fix the doctor failure?

@Plamen5kov
Copy link
Contributor Author

@rosen-vladimirov I thought failing was the expected behavior, my bad. I'll fix it in another PR.

@rosen-vladimirov
Copy link
Collaborator

@Plamen5kov the failure in the current code (changed in this PR) is fine IMO. But tns doctor should catch this error and show warning or something like this. Or even - tns doctor should not get here in case we already know Xcode is not installed.

@Plamen5kov
Copy link
Contributor Author

Yes, my plan was to add a check to tns doctor on the expected default tools on mac, just like we do here. Will fix as soon as I get the time

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants