From 0a0bc6b76900c65516a16613f53da3fe7859ea12 Mon Sep 17 00:00:00 2001 From: plamen5kov Date: Tue, 8 Aug 2017 14:23:47 +0300 Subject: [PATCH 1/3] doctor doesn't crash on missing xcode tools set a better message when components are up to date --- lib/declarations.d.ts | 2 +- lib/services/doctor-service.ts | 17 ++--------------- lib/services/versions-service.ts | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index 8a6bfea5b6..439ba710a5 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -607,7 +607,7 @@ interface IVersionsService { * Gets versions information about the nativescript components with new. * @return {Promise} The version information. */ - getComponentsForUpdate(): Promise; + getComponentsForUpdate(): Promise; /** * Gets versions information about all nativescript components. diff --git a/lib/services/doctor-service.ts b/lib/services/doctor-service.ts index a96e206c95..b9f5bf6900 100644 --- a/lib/services/doctor-service.ts +++ b/lib/services/doctor-service.ts @@ -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)) { result = true; } } else { @@ -123,10 +123,8 @@ 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."); } @@ -134,17 +132,6 @@ class DoctorService implements IDoctorService { 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 { if (await this.$prompter.confirm("Do you want to visit the official documentation?", () => helpers.isInteractive())) { this.$opener.open(link); diff --git a/lib/services/versions-service.ts b/lib/services/versions-service.ts index 2334713cd8..2cbf4ec847 100644 --- a/lib/services/versions-service.ts +++ b/lib/services/versions-service.ts @@ -1,3 +1,4 @@ +import { EOL } from "os"; import * as constants from "../constants"; import * as semver from "semver"; import * as path from "path"; @@ -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(); } @@ -84,7 +86,7 @@ class VersionsService implements IVersionsService { return runtimesVersions; } - public async getComponentsForUpdate(): Promise { + public async getComponentsForUpdate() { let allComponents: IVersionInformation[] = await this.getAllComponentsVersions(); let componentsForUpdate: IVersionInformation[] = []; @@ -94,7 +96,18 @@ class VersionsService implements IVersionsService { } }); - return componentsForUpdate; + this.printVersionsInformation(componentsForUpdate, allComponents); + } + + private printVersionsInformation(versionsInformation: IVersionInformation[], allComponents: IVersionInformation[]) { + 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 { From d2a3cc69cdfec8894ff5bcc65277bd53d64ec567 Mon Sep 17 00:00:00 2001 From: plamen5kov Date: Thu, 10 Aug 2017 10:34:42 +0300 Subject: [PATCH 2/3] renamed method and fixed check --- lib/declarations.d.ts | 5 ++--- lib/services/doctor-service.ts | 4 ++-- lib/services/versions-service.ts | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index 439ba710a5..9c19342437 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -604,10 +604,9 @@ interface IVersionsService { getRuntimesVersions(): Promise; /** - * Gets versions information about the nativescript components with new. - * @return {Promise} The version information. + * Checks version information about the nativescript components and prints available updates if any. */ - getComponentsForUpdate(): Promise; + checkComponentsForUpdate(): Promise; /** * Gets versions information about all nativescript components. diff --git a/lib/services/doctor-service.ts b/lib/services/doctor-service.ts index b9f5bf6900..5b8df741a6 100644 --- a/lib/services/doctor-service.ts +++ b/lib/services/doctor-service.ts @@ -95,7 +95,7 @@ class DoctorService implements IDoctorService { result = true; } - if (sysInfo.cocoapodVer && sysInfo.cocoapodVer && await this.$xcprojService.verifyXcproj(false)) { + if (sysInfo.xcodeVer && sysInfo.cocoapodVer && await this.$xcprojService.verifyXcproj(false)) { result = true; } } else { @@ -124,7 +124,7 @@ class DoctorService implements IDoctorService { } try { - await this.$versionsService.getComponentsForUpdate(); + await this.$versionsService.checkComponentsForUpdate(); } catch (err) { this.$logger.error("Cannot get the latest versions information from npm. Please try again later."); } diff --git a/lib/services/versions-service.ts b/lib/services/versions-service.ts index 2cbf4ec847..2ae08bbf9c 100644 --- a/lib/services/versions-service.ts +++ b/lib/services/versions-service.ts @@ -86,7 +86,7 @@ class VersionsService implements IVersionsService { return runtimesVersions; } - public async getComponentsForUpdate() { + public async checkComponentsForUpdate(): Promise { let allComponents: IVersionInformation[] = await this.getAllComponentsVersions(); let componentsForUpdate: IVersionInformation[] = []; From 6013cfad8f7b1adea4e65a9109f01e99bab8b62f Mon Sep 17 00:00:00 2001 From: plamen5kov Date: Thu, 10 Aug 2017 10:36:49 +0300 Subject: [PATCH 3/3] added method return type --- lib/services/versions-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/versions-service.ts b/lib/services/versions-service.ts index 2ae08bbf9c..03e39414a4 100644 --- a/lib/services/versions-service.ts +++ b/lib/services/versions-service.ts @@ -99,7 +99,7 @@ class VersionsService implements IVersionsService { this.printVersionsInformation(componentsForUpdate, allComponents); } - private printVersionsInformation(versionsInformation: IVersionInformation[], allComponents: IVersionInformation[]) { + private printVersionsInformation(versionsInformation: IVersionInformation[], allComponents: IVersionInformation[]): void { if (versionsInformation && versionsInformation.length) { let table: any = this.createTableWithVersionsInformation(versionsInformation);