Extracted poms

This commit is contained in:
Jonas Bovin 2022-11-23 12:44:11 +01:00
parent d226a0fe29
commit b17e8805d3
2 changed files with 74 additions and 41 deletions

55
dist/index.js vendored
View file

@ -13607,13 +13607,8 @@ class se_Helper {
this.currentBuild = currentBuild;
this.github = github;
}
createMetaJson(root) {
listPoms(root) {
const execSync = external_child_process_.execSync;
console.log('Run number: ' + this.currentBuild.runNumber);
const xmllint = execSync('sudo apt install libxml2-utils', {
shell: '/bin/bash'
});
console.log(xmllint.toString());
const command = `#!/bin/bash
cd ` +
root +
@ -13626,20 +13621,39 @@ class se_Helper {
console.log(output.toString());
const ret = [];
const poms = Object(external_fs_.readFileSync)(root + 'poms.txt', 'utf8').toString();
const ownersFile = Object(external_fs_.readFileSync)(root + '.github/CODEOWNERS', 'utf8')
.toString();
for (const pomRaw of poms.split('\n')) {
const pom = pomRaw.replace('./', '/');
const name = pom.split('/')[2];
if (pom.startsWith('/components') &&
pom.indexOf(name + '-deployment/') > -1) {
const pomEntity = {};
pomEntity['path'] = pom.replace('/pom.xml', '').substring(1);
pomEntity['raw'] = pomRaw;
pomEntity['pom'] = pom;
pomEntity['name'] = pom.split('/')[2];
pomEntity['fullPath'] = root + pomRaw.substring(1);
ret.push(pomEntity);
}
return ret;
}
createMetaJson(root) {
const execSync = external_child_process_.execSync;
console.log('Run number: ' + this.currentBuild.runNumber);
const xmllint = execSync('sudo apt install libxml2-utils', {
shell: '/bin/bash'
});
console.log(xmllint.toString());
const ret = [];
const poms = this.listPoms(root);
const ownersFile = Object(external_fs_.readFileSync)(root + '.github/CODEOWNERS', 'utf8')
.toString();
for (const pomEntity of poms) {
if (pomEntity['pom'].startsWith('/components') &&
pomEntity['pom'].indexOf(name + '-deployment/') > -1) {
const owners = [];
const reviewers = [];
for (const ownerRaw of ownersFile.split('\n')) {
const path = ownerRaw.split(' ')[0];
if (path.length > 3 &&
ownerRaw.indexOf(' @') > -1 &&
pom.startsWith(path)) {
pomEntity['pom'].startsWith(path)) {
owners.push(ownerRaw.split(' ')[1]);
reviewers.push(ownerRaw.split(' ')[1]);
}
@ -13649,7 +13663,7 @@ class se_Helper {
root +
`
xmllint --xpath "/*[local-name()='project']/*[local-name()='groupId']/text()" .` +
pom +
pomEntity['pom'] +
`
`;
const aid = `#!/bin/bash
@ -13657,7 +13671,7 @@ class se_Helper {
root +
`
xmllint --xpath "/*[local-name()='project']/*[local-name()='artifactId']/text()" .` +
pom +
pomEntity['pom'] +
`
`;
const groupId = execSync(gid, { shell: '/bin/bash' }).toString();
@ -13665,21 +13679,22 @@ class se_Helper {
const artifactId = execSync(aid, { shell: '/bin/bash' }).toString();
console.log(artifactId);
const meta = {};
meta['manifestSource'] = pom.replace('/pom.xml', '').substring(1);
meta['manifestSource'] = pomEntity['path'];
meta['manifestTarget'] =
'helm-chart/components/charts/' +
name +
pomEntity['name'] +
'/' +
name +
pomEntity['name'] +
'-deployment/templates/';
meta['owners'] = owners;
meta['reviewers'] = reviewers;
meta['branchName'] = name + '-deployment';
meta['branchName'] = pomEntity['name'] + '-deployment';
meta['mavenGroupId'] = groupId.trim();
meta['mavenArtifactId'] = artifactId.trim();
console.log(JSON.stringify(meta));
ret.push(pomRaw.replace('/pom.xml', '/meta.json').substring(1));
Object(external_fs_.writeFileSync)(root + pomRaw.replace('/pom.xml', '/meta.json').substring(1), JSON.stringify(meta));
ret.push(pomEntity['pomRaw'].replace('/pom.xml', '/meta.json').substring(1));
Object(external_fs_.writeFileSync)(root +
pomEntity['pomRaw'].replace('/pom.xml', '/meta.json').substring(1), JSON.stringify(meta));
}
}
return ret;