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 all commits
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
5 changes: 2 additions & 3 deletions lib/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,9 @@ interface IVersionsService {
getRuntimesVersions(): Promise<IVersionInformation[]>;

/**
* Gets versions information about the nativescript components with new.
* @return {Promise<IVersionInformation[]>} The version information.
* Checks version information about the nativescript components and prints available updates if any.
*/
getComponentsForUpdate(): Promise<IVersionInformation[]>;
checkComponentsForUpdate(): Promise<void>;

/**
* 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.xcodeVer && sysInfo.cocoapodVer && await this.$xcprojService.verifyXcproj(false)) {
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.checkComponentsForUpdate();
} 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 checkComponentsForUpdate(): Promise<void> {
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[]): void {
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