UNPKG

@zowe/imperative

Version:
51 lines 2.51 kB
"use strict"; /* * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v20.html * * SPDX-License-Identifier: EPL-2.0 * * Copyright Contributors to the Zowe Project. * */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.update = update; const PMFConstants_1 = require("../PMFConstants"); const logger_1 = require("../../../../../logger"); const NpmFunctions_1 = require("../NpmFunctions"); /** * @TODO - allow multiple packages to be updated? * Common function that abstracts the update process. * * @param {string} packageName A package name. This value is a valid npm package name. * * @param {INpmRegistryInfo} registryInfo The npm registry to use. * */ function update(packageName, registryInfo) { return __awaiter(this, void 0, void 0, function* () { const iConsole = logger_1.Logger.getImperativeLogger(); const npmPackage = packageName; iConsole.debug(`updating package: ${packageName}`); // NOTE: Using npm install in order to retrieve the version which may be updated iConsole.info("updating package...this may take some time."); (0, NpmFunctions_1.installPackages)(npmPackage, Object.assign({ prefix: PMFConstants_1.PMFConstants.instance.PLUGIN_INSTALL_LOCATION }, registryInfo.npmArgs)); // We fetch the package version of newly installed plugin const packageInfo = (0, NpmFunctions_1.getPackageInfo)(npmPackage); const packageVersion = packageInfo.version; iConsole.info("Update complete"); // return the package version so the plugins.json file can be updated return packageVersion; }); } //# sourceMappingURL=update.js.map