Skip to content

Commit 7fbd177

Browse files
Merge pull request #17 from NativeScript/vladimirov/add-ns-cloud-version
Add getting version of nativescript-cloud library
2 parents d78a8a2 + b13f45f commit 7fbd177

File tree

5 files changed

+49
-6
lines changed

5 files changed

+49
-6
lines changed

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,12 @@ Library that helps identifying if the environment can be used for development of
303303

304304
// node stuff
305305
/**
306-
* node.js version, returned by `process.version`.
306+
* node.js version, returned by node -v.
307307
* @type {string}
308308
*/
309309
nodeVer: string;
310310

311-
/**
311+
/**
312312
* npm version, returned by `npm -v`.
313313
* @type {string}
314314
*/
@@ -405,6 +405,12 @@ Library that helps identifying if the environment can be used for development of
405405
*/
406406
nativeScriptCliVersion: string;
407407

408+
/**
409+
* The version of `nativescript-cloud` library, as returned by `tns cloud lib version`.
410+
* @type {string}
411+
*/
412+
nativeScriptCloudVersion: string;
413+
408414
/**
409415
* Information about xcproj.
410416
* @type {string}

lib/sys-info.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
2626
private javaCompilerVerCache: string;
2727
private xCodeVerCache: string;
2828
private npmVerCache: string;
29+
private nodeVerCache: string;
2930
private nodeGypVerCache: string;
3031
private xCodeprojGemLocationCache: string;
3132
private iTunesInstalledCache: boolean;
@@ -39,6 +40,7 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
3940
private sysInfoCache: NativeScriptDoctor.ISysInfoData;
4041
private isCocoaPodsWorkingCorrectlyCache: boolean;
4142
private nativeScriptCliVersionCache: string;
43+
private nativeScriptCloudVersionCache: string;
4244
private xcprojInfoCache: NativeScriptDoctor.IXcprojInfo;
4345
private isCocoaPodsUpdateRequiredCache: boolean;
4446
private shouldCache: boolean = true;
@@ -91,7 +93,15 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
9193
}
9294

9395
public async getNodeVersion(): Promise<string> {
94-
return this.getVersionFromString(process.version);
96+
return this.getValueForProperty(() => this.nodeVerCache, async (): Promise<string> => {
97+
const output = await this.execCommand("node -v");
98+
if (output) {
99+
const version = this.getVersionFromString(output);
100+
return version || output;
101+
}
102+
103+
return null;
104+
});
95105
}
96106

97107
public getNpmVersion(): Promise<string> {
@@ -243,7 +253,10 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
243253
result.gitVer = await this.getGitVersion();
244254
result.gradleVer = await this.getGradleVersion();
245255
result.isCocoaPodsWorkingCorrectly = await this.isCocoaPodsWorkingCorrectly();
256+
246257
result.nativeScriptCliVersion = await this.getNativeScriptCliVersion();
258+
result.nativeScriptCloudVersion = await this.getNativeScriptCloudVersion();
259+
247260
result.isCocoaPodsUpdateRequired = await this.isCocoaPodsUpdateRequired();
248261
result.isAndroidSdkConfiguredCorrectly = await this.isAndroidSdkConfiguredCorrectly();
249262

@@ -285,6 +298,13 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
285298
});
286299
}
287300

301+
public getNativeScriptCloudVersion(): Promise<string> {
302+
return this.getValueForProperty(() => this.nativeScriptCloudVersionCache, async (): Promise<string> => {
303+
const output = await this.execCommand("tns cloud lib version");
304+
return output ? output.trim() : output;
305+
});
306+
}
307+
288308
public getXcprojInfo(): Promise<NativeScriptDoctor.IXcprojInfo> {
289309
return this.getValueForProperty(() => this.xcprojInfoCache, async (): Promise<NativeScriptDoctor.IXcprojInfo> => {
290310
const cocoaPodsVersion = await this.getCocoaPodsVersion();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-doctor",
3-
"version": "0.3.4",
3+
"version": "0.4.0",
44
"description": "Library that helps identifying if the environment can be used for development of {N} apps.",
55
"main": "lib/index.js",
66
"types": "./typings/nativescript-doctor.d.ts",

test/sys-info.ts

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface IChildProcessResultDescription {
1616
interface IChildProcessResults {
1717
uname: IChildProcessResultDescription;
1818
npmV: IChildProcessResultDescription;
19+
nodeV: IChildProcessResultDescription;
1920
javaVersion: IChildProcessResultDescription;
2021
javacVersion: IChildProcessResultDescription;
2122
nodeGypVersion: IChildProcessResultDescription;
@@ -65,6 +66,7 @@ function createChildProcessResults(childProcessResult: IChildProcessResults): ID
6566
return {
6667
"uname -a": childProcessResult.uname,
6768
"npm -v": childProcessResult.npmV,
69+
"node -v": childProcessResult.nodeV,
6870
"java": childProcessResult.javaVersion,
6971
'"javac" -version': childProcessResult.javacVersion,
7072
"node-gyp -v": childProcessResult.nodeGypVersion,
@@ -207,6 +209,7 @@ describe("SysInfo unit tests", () => {
207209
childProcessResult = {
208210
uname: { result: setStdOut("name") },
209211
npmV: { result: setStdOut("2.14.1") },
212+
nodeV: { result: setStdOut("v6.0.0") },
210213
javaVersion: { result: setStdErr('java version "1.8.0_60"') },
211214
javacVersion: { result: setStdErr("javac 1.8.0_60") },
212215
nodeGypVersion: { result: setStdOut("2.0.0") },
@@ -233,6 +236,7 @@ describe("SysInfo unit tests", () => {
233236
describe("returns correct results when everything is installed", () => {
234237
let assertCommonValues = (result: NativeScriptDoctor.ISysInfoData) => {
235238
assert.deepEqual(result.npmVer, childProcessResult.npmV.result.stdout);
239+
assert.deepEqual(result.nodeVer, "6.0.0");
236240
assert.deepEqual(result.javaVer, "1.8.0");
237241
assert.deepEqual(result.javacVersion, "1.8.0_60");
238242
assert.deepEqual(result.nodeGypVer, childProcessResult.nodeGypVersion.result.stdout);
@@ -308,6 +312,7 @@ describe("SysInfo unit tests", () => {
308312
childProcessResult = {
309313
uname: { shouldThrowError: true },
310314
npmV: { shouldThrowError: true },
315+
nodeV: { shouldThrowError: true },
311316
javaVersion: { shouldThrowError: true },
312317
javacVersion: { shouldThrowError: true },
313318
nodeGypVersion: { shouldThrowError: true },

typings/interfaces.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ declare module NativeScriptDoctor {
9999
*/
100100
getNativeScriptCliVersion(): Promise<string>;
101101

102+
/**
103+
* Returns the version of the installed `nativescript-cloud` version.
104+
* @return {Promise<string>} Returns the version of the installed `nativescript-cloud` version.
105+
*/
106+
getNativeScriptCloudVersion(): Promise<string>;
107+
102108
/**
103109
* Checks if xcproj is required to build projects and if it is installed.
104110
* @return {Promise<IXcprojInfo>} Returns the collected information aboud xcproj.
@@ -177,12 +183,12 @@ declare module NativeScriptDoctor {
177183

178184
// node stuff
179185
/**
180-
* node.js version, returned by `process.version`.
186+
* node.js version, returned by node -v.
181187
* @type {string}
182188
*/
183189
nodeVer: string;
184190

185-
/**
191+
/**
186192
* npm version, returned by `npm -v`.
187193
* @type {string}
188194
*/
@@ -279,6 +285,12 @@ declare module NativeScriptDoctor {
279285
*/
280286
nativeScriptCliVersion: string;
281287

288+
/**
289+
* The version of `nativescript-cloud` library, as returned by `tns cloud lib version`.
290+
* @type {string}
291+
*/
292+
nativeScriptCloudVersion: string;
293+
282294
/**
283295
* Information about xcproj.
284296
* @type {string}

0 commit comments

Comments
 (0)