trm-core
Version:
TRM (Transport Request Manager) Core
50 lines (49 loc) • 3.14 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.getSourceCode = void 0;
const trm_commons_1 = require("trm-commons");
const systemConnector_1 = require("../../systemConnector");
const abapgit_1 = require("../../abapgit");
const minimatch_1 = require("minimatch");
exports.getSourceCode = {
name: 'get-source-code',
run: (context) => __awaiter(void 0, void 0, void 0, function* () {
trm_commons_1.Logger.log('Get source code step', true);
try {
trm_commons_1.Logger.loading(`Reading ${context.rawInput.packageData.devclass} source code...`);
const sourceCode = yield systemConnector_1.SystemConnector.getAbapgitSource(context.rawInput.packageData.devclass);
context.runtime.abapGitData.sourceCode.zip = sourceCode.zip;
context.runtime.abapGitData.dotAbapGit = yield abapgit_1.DotAbapGit.fromDevclass(context.rawInput.packageData.devclass);
const ignoredPatterns = context.runtime.abapGitData.dotAbapGit.getIgnoredFiles();
context.runtime.packageData.tadir.forEach(o => {
const abapgitObject = sourceCode.objects.find(k => k.pgmid === o.pgmid && k.object === o.object && k.objName === o.objName);
if (abapgitObject) {
ignoredPatterns.forEach(pattern => {
if ((0, minimatch_1.minimatch)(abapgitObject.fullPath, pattern, { matchBase: true })) {
if (!context.runtime.abapGitData.sourceCode.ignoredObjects.find(k => k.pgmid === o.pgmid && k.object === o.object && k.objName === o.objName)) {
context.runtime.abapGitData.sourceCode.ignoredObjects.push(o);
trm_commons_1.Logger.log(`Excluding ${o.pgmid} ${o.object} ${o.objName} (.abapgit ignore)`, true);
}
}
});
}
});
if (ignoredPatterns.length > 0) {
trm_commons_1.Logger.info(`Excluding ${context.runtime.abapGitData.sourceCode.ignoredObjects.length} object(s) as configured in .abapgit.xml: ${ignoredPatterns.join(', ')}`);
}
}
catch (e) {
trm_commons_1.Logger.error(e.toString(), true);
trm_commons_1.Logger.info(`AbapGit Developer Edition was not found, skipping source code and git ignore extraction.`, true);
}
})
};