@axway/axway-central-cli
Version:
Manage APIs, services and publish to the Amplify Marketplace
162 lines (158 loc) • 9.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.testables = exports.gatewayConnectivity = exports.completeInstall = exports.askConfigType = exports.askBundleType = exports.SoftwareAGWebMethodsInstallMethods = exports.ConfigFiles = void 0;
var _chalk = _interopRequireDefault(require("chalk"));
var _snooplogg = _interopRequireDefault(require("snooplogg"));
var _basicPrompts = require("../../common/basicPrompts");
var _types = require("../../common/types");
var _utils = require("../../common/utils");
var helpers = _interopRequireWildcard(require("./helpers"));
var _softwareAGWebMethodsTemplates = require("./helpers/templates/softwareAGWebMethodsTemplates");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
// @ts-ignore
const {
log
} = (0, _snooplogg.default)('central: install: agents: Software AG Web Methods');
const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.SOFTWAREAGWEBMETHODS_DA}`;
const taImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.SOFTWAREAGWEBMETHODS_TA}`;
// ConfigFiles - all the config file that are used in the setup
const ConfigFiles = exports.ConfigFiles = {
DAEnvVars: `${helpers.configFiles.DA_ENV_VARS}`,
TAEnvVars: `${helpers.configFiles.TA_ENV_VARS}`
};
// WebMethods - prompts for user inputs
const prompts = {
pathURL: 'Enter the base URL to connect to your Software AG WebMethods API service',
pathUsername: 'Enter the username to authenticate to Software AG WebMethods',
pathPassword: 'Enter the password to authenticate to Software AG WebMethods',
pathOauth2Server: 'Enter the OAuth2 server to authenticate. Defaults to local gateway auth'
};
const askBundleType = async () => {
return await (0, _basicPrompts.askList)({
msg: helpers.agentMessages.selectAgentType,
choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY, _types.BundleType.TRACEABILITY]
});
};
exports.askBundleType = askBundleType;
const askConfigType = async () => {
return _types.AgentConfigTypes.DOCKERIZED;
};
//
// Questions for the configuration of Software AG WebMethods agents
//
exports.askConfigType = askConfigType;
async function askCommonPrompts(webMethodsAgentValues) {
// Software AG WebMethods Path URL
webMethodsAgentValues.pathURL = await askPathURL();
// Software AG WebMethods Path Username
webMethodsAgentValues.pathUsername = await askPathUsername();
// Software AG WebMethods Path Password
webMethodsAgentValues.pathPassword = await askPathPassword();
// Software AG WebMethods Path Oauth2Server
webMethodsAgentValues.pathOauth2Server = await askPathOauth2Server();
if (webMethodsAgentValues.pathOauth2Server.trim() === '') {
webMethodsAgentValues.pathOauth2Server = 'local';
}
}
const askPathURL = async () => await (0, _basicPrompts.askInput)({
msg: prompts.pathURL
});
const askPathUsername = async () => await (0, _basicPrompts.askInput)({
msg: prompts.pathUsername
});
const askPathPassword = async () => await (0, _basicPrompts.askInput)({
msg: prompts.pathPassword
});
const askPathOauth2Server = async () => await (0, _basicPrompts.askInput)({
msg: prompts.pathOauth2Server,
allowEmptyInput: true,
defaultValue: "local"
});
const gatewayConnectivity = async installConfig => {
const webMethodsAgentValues = new _softwareAGWebMethodsTemplates.SoftwareAGWebMethodsAgentValues();
console.log('\nCONNECTION TO Software AG WebMethods:');
console.log(_chalk.default.gray(`The discovery agent needs to connect to the Software AG WebMethods Gateway to discover API's for publishing to Amplify.\nThe traceability agent needs to connect to Software AG WebMethods for collecting APIs transactions. These will be forwarded to the Business Insights.\n`));
if (installConfig.switches.isDaEnabled || installConfig.switches.isTaEnabled) {
await askCommonPrompts(webMethodsAgentValues);
}
return webMethodsAgentValues;
};
exports.gatewayConnectivity = gatewayConnectivity;
const generateSuccessHelpMsg = installConfig => {
if (installConfig.centralConfig.ampcDosaInfo.isNew && !installConfig.switches.isHelmInstall) {
console.log(_chalk.default.yellow('\nPlease make sure to copy the "private_key.pem" and "public_key.pem" files for the existing service account you selected.'));
}
dockerSuccessMsg(installConfig);
console.log(_chalk.default.gray(`\nAdditional information about agent features can be found here:\n${helpers.agentsDocsUrl.SOFTWAREAGWEBMETHODS}`));
};
const dockerSuccessMsg = installConfig => {
let dockerInfo;
const runDaLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
const runDaWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
const runTaLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.TA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
const runTaWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.TA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
const startDaLinuxMsg = `\nStart the Discovery Agent on a Linux based machine`;
const startDaWinMsg = `\nStart the Discovery Agent on a Windows machine`;
const startTaLinuxMsg = `\nStart the Traceability Agent on a Linux based machine`;
const startTaWinMsg = `\nStart the Traceability Agent on a Windows machine`;
if (installConfig.switches.isDaEnabled && installConfig.switches.isTaEnabled) {
dockerInfo = `To utilize the agents, pull the latest Docker images and run them using the appropriate supplied environment files, (${helpers.configFiles.DA_ENV_VARS} & ${helpers.configFiles.TA_ENV_VARS}):`;
} else if (installConfig.switches.isDaEnabled) {
dockerInfo = `To utilize the discovery agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.DA_ENV_VARS}):`;
} else {
dockerInfo = `To utilize the traceability agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.TA_ENV_VARS}):`;
}
console.log(_chalk.default.whiteBright(dockerInfo), '\n');
if (installConfig.switches.isDaEnabled) {
const daImageVersion = `${daImage}:${installConfig.daVersion}`;
console.log(_chalk.default.white('Pull the latest image of the Discovery Agent:'));
console.log(_chalk.default.cyan(`docker pull ${daImageVersion}`));
console.log(_chalk.default.white(_utils.isWindows ? startDaWinMsg : startDaLinuxMsg));
console.log(_chalk.default.cyan(_utils.isWindows ? runDaWinMsg : runDaLinuxMsg));
console.log('\t', _chalk.default.cyan(`-v /data ${daImageVersion}`), '\n');
}
if (installConfig.switches.isTaEnabled) {
const taImageVersion = `${taImage}:${installConfig.taVersion}`;
console.log(_chalk.default.white('Pull the latest image of the Traceability Agent:'));
console.log(_chalk.default.cyan(`docker pull ${taImageVersion}`));
console.log(_chalk.default.white(_utils.isWindows ? startTaWinMsg : startTaLinuxMsg));
console.log(_chalk.default.cyan(_utils.isWindows ? runTaWinMsg : runTaLinuxMsg));
console.log('\t', _chalk.default.cyan(`-v /data ${taImageVersion}`), '\n');
}
};
const completeInstall = async installConfig => {
// Add final settings to softwareAGWebMethodsAgentValues
const softwareAGWebMethodsAgentValues = installConfig.gatewayConfig;
softwareAGWebMethodsAgentValues.centralConfig = installConfig.centralConfig;
softwareAGWebMethodsAgentValues.traceabilityConfig = installConfig.traceabilityConfig;
console.log('Generating the configuration file(s)...');
if (installConfig.switches.isDaEnabled) {
(0, _utils.writeTemplates)(ConfigFiles.DAEnvVars, softwareAGWebMethodsAgentValues, helpers.softwareAGWebMethodsDAEnvVarTemplate);
}
if (installConfig.switches.isTaEnabled) {
(0, _utils.writeTemplates)(ConfigFiles.TAEnvVars, softwareAGWebMethodsAgentValues, helpers.softwareAGWebMethodsTAEnvVarTemplate);
}
console.log('Configuration file(s) have been successfully created.\n');
generateSuccessHelpMsg(installConfig);
};
exports.completeInstall = completeInstall;
const SoftwareAGWebMethodsInstallMethods = exports.SoftwareAGWebMethodsInstallMethods = {
GetBundleType: askBundleType,
GetDeploymentType: askConfigType,
AskGatewayQuestions: gatewayConnectivity,
FinalizeGatewayInstall: completeInstall,
ConfigFiles: Object.values(ConfigFiles),
AgentNameMap: {
[_types.AgentTypes.da]: _types.AgentNames.SOFTWAREAGWEBMETHODS_DA,
[_types.AgentTypes.ta]: _types.AgentNames.SOFTWAREAGWEBMETHODS_TA
},
GatewayDisplay: _types.GatewayTypes.SOFTWAREAGWEBMETHODS
};
const testables = exports.testables = {
prompts,
ConfigFiles
};