trm-client
Version:
TRM (Transport Request Manager) Client
88 lines (87 loc) • 3.48 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.check = check;
const trm_core_1 = require("trm-core");
const commons_1 = require("./commons");
const trm_commons_1 = require("trm-commons");
var systemPackages = [];
const _dependencies = (oPackage) => __awaiter(void 0, void 0, void 0, function* () {
trm_commons_1.Logger.loading(`Analyzing package dependencies...`);
const packages = yield commons_1.CommandContext.getSystemPackages();
yield (0, trm_core_1.checkPackageDependencies)({
contextData: {
systemPackages: packages
},
packageData: {
package: oPackage
},
printOptions: {
dependencyStatus: true,
information: true
}
});
});
const _sapEntries = (oPackage) => __awaiter(void 0, void 0, void 0, function* () {
trm_commons_1.Logger.loading(`Analyzing package SAP Entries...`);
yield (0, trm_core_1.checkSapEntries)({
packageData: {
package: oPackage
},
printOptions: {
entriesStatus: true,
information: true
}
});
});
function check(commandArgs) {
return __awaiter(this, void 0, void 0, function* () {
const packageName = commandArgs.package;
const analysisTypes = [{
name: `Dependencies only`,
value: `DEPENDENCIES`
}, {
name: `SAP Entries only`,
value: `SAPENTRIES`
}, {
name: `All`,
value: `ALL`
}];
var analysisType = commandArgs.analysisType;
if (!analysisType || !analysisTypes.map(o => o.value).includes(analysisType)) {
const inq1 = yield trm_commons_1.Inquirer.prompt({
message: `Analysis type`,
name: `analysisType`,
type: `list`,
choices: analysisTypes
});
analysisType = inq1.analysisType;
}
trm_commons_1.Logger.loading(`Searching package "${packageName}"...`);
systemPackages = yield commons_1.CommandContext.getSystemPackages();
const oPackage = systemPackages.find(o => o.compareName(packageName) && o.compareRegistry(commons_1.CommandContext.getRegistry()));
if (!oPackage) {
throw new Error(`Package "${packageName}" not found.`);
}
switch (analysisType) {
case `DEPENDENCIES`:
yield _dependencies(oPackage);
break;
case `SAPENTRIES`:
yield _sapEntries(oPackage);
break;
default:
yield _dependencies(oPackage);
yield _sapEntries(oPackage);
break;
}
});
}