Skip to content

doctor doesn't crash on missing xcode tools #3043

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 3 commits into from
Aug 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ interface IVersionsService {
* Gets versions information about the nativescript components with new.
* @return {Promise<IVersionInformation[]>} The version information.
*/
getComponentsForUpdate(): Promise<IVersionInformation[]>;
getComponentsForUpdate(): Promise<void>;
Copy link
Contributor

Choose a reason for hiding this comment

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

In case the method is void, its name is incorrect as it does not get anything


/**
* Gets versions information about all nativescript components.
Expand Down
17 changes: 2 additions & 15 deletions lib/services/doctor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class DoctorService implements IDoctorService {
result = true;
}

if (await this.$xcprojService.verifyXcproj(false)) {
if (sysInfo.cocoapodVer && sysInfo.cocoapodVer && await this.$xcprojService.verifyXcproj(false)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this check should be:

if (sysInfo.xcodeVer && sysInfo.cocoapodVer && ...)

result = true;
}
} else {
Expand Down Expand Up @@ -123,28 +123,15 @@ class DoctorService implements IDoctorService {
}
}

let versionsInformation: IVersionInformation[] = [];
try {
versionsInformation = await this.$versionsService.getComponentsForUpdate();
this.printVersionsInformation(versionsInformation);
await this.$versionsService.getComponentsForUpdate();
} catch (err) {
this.$logger.error("Cannot get the latest versions information from npm. Please try again later.");
}

return doctorResult;
}

private printVersionsInformation(versionsInformation: IVersionInformation[]) {
if (versionsInformation && versionsInformation.length) {
let table: any = this.$versionsService.createTableWithVersionsInformation(versionsInformation);

this.$logger.warn("Updates available");
this.$logger.out(table.toString() + EOL);
} else {
this.$logger.out("Your components are up-to-date." + EOL);
}
}

private async promptForDocs(link: string): Promise<void> {
if (await this.$prompter.confirm("Do you want to visit the official documentation?", () => helpers.isInteractive())) {
this.$opener.open(link);
Expand Down
19 changes: 16 additions & 3 deletions lib/services/versions-service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EOL } from "os";
import * as constants from "../constants";
import * as semver from "semver";
import * as path from "path";
Expand All @@ -14,7 +15,8 @@ class VersionsService implements IVersionsService {
private $npmInstallationManager: INpmInstallationManager,
private $injector: IInjector,
private $staticConfig: Config.IStaticConfig,
private $pluginsService: IPluginsService) {
private $pluginsService: IPluginsService,
private $logger: ILogger) {
this.projectData = this.getProjectData();
}

Expand Down Expand Up @@ -84,7 +86,7 @@ class VersionsService implements IVersionsService {
return runtimesVersions;
}

public async getComponentsForUpdate(): Promise<IVersionInformation[]> {
public async getComponentsForUpdate() {
Copy link
Contributor

Choose a reason for hiding this comment

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

this method needs return type

let allComponents: IVersionInformation[] = await this.getAllComponentsVersions();
let componentsForUpdate: IVersionInformation[] = [];

Expand All @@ -94,7 +96,18 @@ class VersionsService implements IVersionsService {
}
});

return componentsForUpdate;
this.printVersionsInformation(componentsForUpdate, allComponents);
}

private printVersionsInformation(versionsInformation: IVersionInformation[], allComponents: IVersionInformation[]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this method needs return type

if (versionsInformation && versionsInformation.length) {
let table: any = this.createTableWithVersionsInformation(versionsInformation);

this.$logger.warn("Updates available");
this.$logger.out(table.toString() + EOL);
} else {
this.$logger.out(`Your components are up-to-date: ${EOL}${allComponents.map(component => component.componentName)}${EOL}`);
}
}

public async getAllComponentsVersions(): Promise<IVersionInformation[]> {
Expand Down