UNPKG

nativescript

Version:

Command-line interface for building NativeScript projects

104 lines 4.21 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SysInfo = void 0; const path = require("path"); const util_1 = require("util"); const doctor_1 = require("@nativescript/doctor"); const constants_1 = require("./constants"); const verify_node_version_1 = require("./common/verify-node-version"); const decorators_1 = require("./common/decorators"); const semver = require("semver"); const yok_1 = require("./common/yok"); class SysInfo { constructor($fs, $hostInfo) { this.$fs = $fs; this.$hostInfo = $hostInfo; this.sysInfo = null; } async getSysInfo(config) { if (!this.sysInfo) { const pathToNativeScriptCliPackageJson = (config && config.pathToNativeScriptCliPackageJson) || path.join(__dirname, "..", "package.json"); const androidToolsInfo = config && config.androidToolsInfo; this.sysInfo = await doctor_1.sysInfo.getSysInfo({ pathToNativeScriptCliPackageJson, androidToolsInfo, }); } return this.sysInfo; } getXcodeVersion() { return doctor_1.sysInfo.getXcodeVersion(); } getCocoaPodsVersion() { return doctor_1.sysInfo.getCocoaPodsVersion(); } getJavaPath() { return doctor_1.sysInfo.getJavaPath(); } getJavaCompilerVersion() { return doctor_1.sysInfo.getJavaCompilerVersion(); } getJavaVersionFromPath() { return doctor_1.sysInfo.getJavaVersionFromPath(); } getJavaVersionFromJavaHome() { return doctor_1.sysInfo.getJavaVersionFromJavaHome(); } async getSystemWarnings() { const warnings = []; const macOSWarningMessage = await this.getMacOSWarningMessage(); if (macOSWarningMessage) { macOSWarningMessage.toString = function () { return this.message; }; warnings.push(macOSWarningMessage); } const nodeWarning = (0, verify_node_version_1.getNodeWarning)(); if (nodeWarning) { nodeWarning.toString = function () { return this.message; }; warnings.push(nodeWarning); } return warnings; } getSupportedNodeVersionRange() { const pathToCLIPackageJson = path.join(__dirname, "..", "package.json"); const jsonContent = this.$fs.readJson(pathToCLIPackageJson); return jsonContent && jsonContent.engines && jsonContent.engines.node; } async getMacOSWarningMessage() { const macOSVersion = await this.$hostInfo.getMacOSVersion(); if (macOSVersion && macOSVersion < constants_1.MacOSVersions.HighSierra) { return { message: (0, util_1.format)(constants_1.MacOSDeprecationStringFormat, macOSVersion), severity: "high" /* SystemWarningsSeverity.high */, }; } return null; } async getXcodeWarning() { const xcodeVersion = await this.getXcodeVersion(); if (xcodeVersion && semver.lt(semver.coerce(xcodeVersion), "11.0.0")) { const message = (0, util_1.format)(constants_1.XcodeDeprecationStringFormat, xcodeVersion); return message; } return null; } } exports.SysInfo = SysInfo; __decorate([ (0, decorators_1.exported)("sysInfo") ], SysInfo.prototype, "getSystemWarnings", null); __decorate([ (0, decorators_1.exported)("sysInfo") ], SysInfo.prototype, "getSupportedNodeVersionRange", null); yok_1.injector.register("sysInfo", SysInfo); //# sourceMappingURL=sys-info.js.map