trm-client
Version:
TRM (Transport Request Manager) Client
86 lines (85 loc) • 4.18 kB
JavaScript
;
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.registerCommand = registerCommand;
const executeCommand_1 = require("./executeCommand");
const settings_1 = require("../settings");
function registerCommand(command, args) {
const commandName = command.name();
if (!args) {
args = {};
}
const requiresConnection = args.requiresConnection ? true : false;
const addNoConnection = args.addNoConnection ? true : false;
const requiresTrmDependencies = args.requiresTrmDependencies ? true : false;
const requiresRegistry = args.requiresRegistry ? true : false;
const ignoreRegistryUnreachable = args.ignoreRegistryUnreachable ? true : false;
const noSystemAlias = args.noSystemAlias ? true : false;
const registryAuthBlacklist = args.registryAuthBlacklist || [];
const defaultLogger = settings_1.Settings.getInstance().data.loggerType;
const logOutputFolder = settings_1.Settings.getInstance().data.logOutputFolder;
if (requiresConnection || commandName === 'createAlias') {
command.option(`-de, --dest <dest>`, `System ID.`)
.option(`-us, --user <user>`, `System User Logon.`)
.option(`-pw, --passwd <passwd>`, `System User Logon Password.`)
.option(`-cl, --client <client>`, `System Logon Client.`)
.option(`-la, --lang <lang>`, `System User Logon Language.`)
.option(`-ah, --ashost <ashost>`, `System application server address.`)
.option(`-sr, --saprouter <sapRouter>`, `System SAP Router string.`)
.option(`-sn, --sysnr <sysnr>`, `System instance number.`)
.option(`-ep, --endpoint <endpoint>`, `System REST endpoint.`)
.option(`-fd, --forwardRfcDest <forwardRfcDest>`, `System REST forward destination.`, `NONE`);
if (!noSystemAlias) {
command.option(`-a, --systemAlias <systemAlias>`, `System Alias.`);
}
}
if (requiresRegistry) {
command.option(`-r, --registry <registry>`, `Registry name.`);
command.option(`-re, --registryEndpoint <endpoint>`, `Registry endpoint.`);
command.option(`-ra, --registryAuth <authentication>`, `Registry authentication (in JSON format).`);
}
command.option(`-log, --logType <logType>`, `Log type.`, defaultLogger);
command.option(`-dbg, --debug`, `Debug logging.`, false);
command.action((arg1, arg2) => __awaiter(this, void 0, void 0, function* () {
var args = Object.assign({
command: commandName,
requiresConnection,
addNoConnection,
requiresTrmDependencies,
requiresRegistry,
registryAuthBlacklist,
noSystemAlias,
ignoreRegistryUnreachable,
logOutputFolder
}, (command['_optionValues'] || {}));
if (!arg1) {
arg1 = {};
}
if (!arg2) {
arg2 = {};
}
if (typeof (arg1) === 'string') {
const oArg1 = command["_args"][0];
args[oArg1.name()] = arg1;
if (typeof (arg2) === 'string') {
const oArg2 = command["_args"][1];
args[oArg2.name()] = arg2;
}
else {
args = Object.assign(Object.assign({}, args), arg2);
}
}
else {
args = Object.assign(Object.assign({}, args), arg1);
}
yield (0, executeCommand_1.executeCommand)(args);
}));
}