zowe-cli-cics-deploy-plugin
Version:
IBM CICS Bundle generation and deployment for Zowe CLI
93 lines • 4.07 kB
JavaScript
;
/*
* 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 IBM Corp, 2019
*
*/
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.BundleParentHandler = void 0;
const imperative_1 = require("@zowe/imperative");
/**
* Generic Command handler for a CICS bundle action
* @export
* @class BundleParentHandler
* @implements {ICommandHandler}
*/
class BundleParentHandler {
/**
* Process a command.
* @param {IHandlerParameters} params
* @returns {Promise<void>}
* @memberof BundleParentHandler
*/
process(params) {
return __awaiter(this, void 0, void 0, function* () {
// Initialise Imperative if it is not already initialised
try {
// But not if silent mode is requested (i.e. unit tests)
if (params.arguments.silent === undefined) {
yield imperative_1.Imperative.init();
}
}
catch (err) {
// Imperative may refuse to initialise in unit tests... never mind
}
// log the arguments on entry to the Handler
const logger = imperative_1.Logger.getAppLogger();
if (params.arguments.silent === undefined) {
// Strip passwords from the data before logging it
let inputParms = JSON.stringify(params.arguments);
inputParms = this.replacePassword(inputParms, params.arguments.zpw);
inputParms = this.replacePassword(inputParms, params.arguments.spw);
inputParms = this.replacePassword(inputParms, params.arguments.cpw);
logger.debug("Arguments received by cics-deploy: " + inputParms);
}
try {
let msg;
// Perform an action. Each sub-class will implement its own action and
// either throw an Exception or return a success message.
msg = yield this.performAction(params);
// Add a newline char if its needed
if (msg.slice(-1) !== "\n") {
msg += "\n";
}
// Issue the success message
params.response.console.log(Buffer.from(msg));
if (params.arguments.silent === undefined) {
logger.debug(msg);
}
}
catch (except) {
// Construct an error message for the exception
const msg = "A failure occurred during CICS bundle " + this.actionName + ".\n Reason = " + except.message;
// Log the error message to the Imperative log
if (params.arguments.silent === undefined) {
logger.error(msg);
}
throw new imperative_1.ImperativeError({ msg, causeErrors: except });
}
});
}
replacePassword(source, pwd) {
if (pwd !== undefined) {
return source.split(pwd).join("*REDACTED*");
}
return source;
}
}
exports.BundleParentHandler = BundleParentHandler;
//# sourceMappingURL=BundleParent.handler.js.map