-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathsys-info.ts
74 lines (60 loc) · 2.34 KB
/
sys-info.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import * as path from "path";
import { format } from "util";
import { sysInfo } from "nativescript-doctor";
import { MacOSVersions, MacOSDeprecationStringFormat } from "./constants";
import { getNodeWarning } from "./common/verify-node-version";
import { exported } from "./common/decorators";
export class SysInfo implements ISysInfo {
private sysInfo: ISysInfoData = null;
constructor(private $fs: IFileSystem,
private $hostInfo: IHostInfo) { }
public async getSysInfo(config?: NativeScriptDoctor.ISysInfoConfig): Promise<NativeScriptDoctor.ISysInfoData> {
if (!this.sysInfo) {
const pathToNativeScriptCliPackageJson = (config && config.pathToNativeScriptCliPackageJson) || path.join(__dirname, "..", "package.json");
const androidToolsInfo = config && config.androidToolsInfo;
this.sysInfo = await sysInfo.getSysInfo({ pathToNativeScriptCliPackageJson, androidToolsInfo });
}
return this.sysInfo;
}
public getXcodeVersion(): Promise<string> {
return sysInfo.getXcodeVersion();
}
public getCocoaPodsVersion(): Promise<string> {
return sysInfo.getCocoaPodsVersion();
}
public getJavaCompilerVersion(): Promise<string> {
return sysInfo.getJavaCompilerVersion();
}
@exported("sysInfo")
public async getSystemWarnings(): Promise<ISystemWarning[]> {
const warnings: ISystemWarning[] = [];
const macOSWarningMessage = await this.getMacOSWarningMessage();
if (macOSWarningMessage) {
macOSWarningMessage.toString = function() { return this.message; };
warnings.push(macOSWarningMessage);
}
const nodeWarning = getNodeWarning();
if (nodeWarning) {
nodeWarning.toString = function() { return this.message; };
warnings.push(nodeWarning);
}
return warnings;
}
@exported("sysInfo")
public getSupportedNodeVersionRange(): string {
const pathToCLIPackageJson = path.join(__dirname, "..", "package.json");
const jsonContent = this.$fs.readJson(pathToCLIPackageJson);
return jsonContent && jsonContent.engines && jsonContent.engines.node;
}
public async getMacOSWarningMessage(): Promise<ISystemWarning> {
const macOSVersion = await this.$hostInfo.getMacOSVersion();
if (macOSVersion && macOSVersion < MacOSVersions.HighSierra) {
return {
message: format(MacOSDeprecationStringFormat, macOSVersion),
severity: SystemWarningsSeverity.high
};
}
return null;
}
}
$injector.register("sysInfo", SysInfo);