Fixes from lint

This commit is contained in:
Jonas Bovin 2022-11-22 11:58:20 +01:00
parent 5f39025188
commit d75cec7ae6

View file

@ -1,44 +1,43 @@
import * as child from 'child_process';
import * as fs from 'fs';
export function createMetaJson(): string[] { export function createMetaJson(): string[] {
return createMetaJson('./') return createMetaJson('./')
} }
export function createMetaJson(root: string): string[] { export function createMetaJson(root: string): string[] {
var fs = require('fs'); const execSync = child.execSync;
const execSync = require('child_process').execSync;
const xmllint = execSync('sudo apt install libxml2-utils', { shell: '/bin/bash' }); const xmllint = execSync('sudo apt install libxml2-utils', { shell: '/bin/bash' });
console.log(xmllint.toString()); console.log(xmllint.toString());
var command = `#!/bin/bash let command = `#!/bin/bash
cd ` + root + ` cd ` + root + `
find . -name 'pom.xml' -type f > ` + root + `poms.txt find . -name 'pom.xml' -type f > ` + root + `poms.txt
`; `;
const output = execSync(command, { shell: '/bin/bash' }); const output = execSync(command, { shell: '/bin/bash' });
console.log(output.toString()); console.log(output.toString());
var poms = fs.readFileSync(root + 'poms.txt', 'utf8').toString(); let poms = fs.readFileSync(root + 'poms.txt', 'utf8').toString();
var ownersFile = fs.readFileSync(root + '.github/CODEOWNERS', 'utf8').toString(); let ownersFile = fs.readFileSync(root + '.github/CODEOWNERS', 'utf8').toString();
for (const pomRaw of poms.split('\n')) { for (const pomRaw of poms.split('\n')) {
var pom = pomRaw.replace("\.\/", "/"); let pom = pomRaw.replace("./", "/");
var name = pom.split("/")[2]; let name = pom.split("/")[2];
if (pom.startsWith("/components") && pom.indexOf(name + "-deployment/") > -1) { if (pom.startsWith("/components") && pom.indexOf(name + "-deployment/") > -1) {
var xml = fs.readFileSync(pomRaw, 'utf8'); let owners = [];
var owners = []; let reviewers = [];
var reviewers = [];
for (const ownerRaw of ownersFile.split('\n')) { for (const ownerRaw of ownersFile.split('\n')) {
var path = ownerRaw.split(' ')[0]; let path = ownerRaw.split(' ')[0];
if (path.length > 3 && ownerRaw.indexOf(' @') > -1 && pom.startsWith(path)) { if (path.length > 3 && ownerRaw.indexOf(' @') > -1 && pom.startsWith(path)) {
owners.push(ownerRaw.split(' ')[1]) owners.push(ownerRaw.split(' ')[1])
reviewers.push(ownerRaw.split(' ')[1]) reviewers.push(ownerRaw.split(' ')[1])
} }
} }
var gid = `#!/bin/bash let gid = `#!/bin/bash
cd ` + root + ` cd ` + root + `
xmllint --xpath "/*[local-name()='project']/*[local-name()='groupId']/text()" ` + pom + ` xmllint --xpath "/*[local-name()='project']/*[local-name()='groupId']/text()" ` + pom + `
` `
var aid = `#!/bin/bash let aid = `#!/bin/bash
cd ` + root + ` cd ` + root + `
xmllint --xpath "/*[local-name()='project']/*[local-name()='artifactId']/text()" ` + pom + ` xmllint --xpath "/*[local-name()='project']/*[local-name()='artifactId']/text()" ` + pom + `
` `
@ -46,7 +45,7 @@ export function createMetaJson(root: string): string[] {
console.log(groupId); console.log(groupId);
const artifactId = execSync(aid, { shell: '/bin/bash' }).toString(); const artifactId = execSync(aid, { shell: '/bin/bash' }).toString();
console.log(artifactId); console.log(artifactId);
var meta = {}; let meta = {};
meta['manifestSource'] = pom.replace("/pom.xml", "").substring(1); meta['manifestSource'] = pom.replace("/pom.xml", "").substring(1);
meta['manifestTarget'] = "helm-chart/components/charts/" + name + "/" + name + "-deployment/templates/"; meta['manifestTarget'] = "helm-chart/components/charts/" + name + "/" + name + "-deployment/templates/";
meta['owners'] = owners; meta['owners'] = owners;