|
1 |
| - |
| 1 | +import * as child from 'child_process'; |
| 2 | +import * as fs from 'fs'; |
2 | 3 |
|
3 | 4 | export function createMetaJson(): string[] {
|
4 | 5 | return createMetaJson('./')
|
5 | 6 | }
|
6 | 7 |
|
7 | 8 | export function createMetaJson(root: string): string[] {
|
8 |
| - var fs = require('fs'); |
9 |
| - const execSync = require('child_process').execSync; |
| 9 | + const execSync = child.execSync; |
10 | 10 |
|
11 | 11 | const xmllint = execSync('sudo apt install libxml2-utils', { shell: '/bin/bash' });
|
12 | 12 | console.log(xmllint.toString());
|
13 |
| - var command = `#!/bin/bash |
| 13 | + let command = `#!/bin/bash |
14 | 14 | cd ` + root + `
|
15 | 15 | find . -name 'pom.xml' -type f > ` + root + `poms.txt
|
16 | 16 | `;
|
17 | 17 | const output = execSync(command, { shell: '/bin/bash' });
|
18 | 18 | console.log(output.toString());
|
19 | 19 |
|
20 |
| - var poms = fs.readFileSync(root + 'poms.txt', 'utf8').toString(); |
21 |
| - var ownersFile = fs.readFileSync(root + '.github/CODEOWNERS', 'utf8').toString(); |
| 20 | + let poms = fs.readFileSync(root + 'poms.txt', 'utf8').toString(); |
| 21 | + let ownersFile = fs.readFileSync(root + '.github/CODEOWNERS', 'utf8').toString(); |
22 | 22 | for (const pomRaw of poms.split('\n')) {
|
23 |
| - var pom = pomRaw.replace("\.\/", "/"); |
24 |
| - var name = pom.split("/")[2]; |
| 23 | + let pom = pomRaw.replace("./", "/"); |
| 24 | + let name = pom.split("/")[2]; |
25 | 25 | if (pom.startsWith("/components") && pom.indexOf(name + "-deployment/") > -1) {
|
26 |
| - var xml = fs.readFileSync(pomRaw, 'utf8'); |
27 |
| - var owners = []; |
28 |
| - var reviewers = []; |
| 26 | + let owners = []; |
| 27 | + let reviewers = []; |
29 | 28 | for (const ownerRaw of ownersFile.split('\n')) {
|
30 |
| - var path = ownerRaw.split(' ')[0]; |
| 29 | + let path = ownerRaw.split(' ')[0]; |
31 | 30 |
|
32 | 31 | if (path.length > 3 && ownerRaw.indexOf(' @') > -1 && pom.startsWith(path)) {
|
33 | 32 | owners.push(ownerRaw.split(' ')[1])
|
34 | 33 | reviewers.push(ownerRaw.split(' ')[1])
|
35 | 34 | }
|
36 | 35 | }
|
37 |
| - var gid = `#!/bin/bash |
| 36 | + let gid = `#!/bin/bash |
38 | 37 | cd ` + root + `
|
39 | 38 | xmllint --xpath "/*[local-name()='project']/*[local-name()='groupId']/text()" ` + pom + `
|
40 | 39 | `
|
41 |
| - var aid = `#!/bin/bash |
| 40 | + let aid = `#!/bin/bash |
42 | 41 | cd ` + root + `
|
43 | 42 | xmllint --xpath "/*[local-name()='project']/*[local-name()='artifactId']/text()" ` + pom + `
|
44 | 43 | `
|
45 | 44 | const groupId = execSync(gid, { shell: '/bin/bash' }).toString();
|
46 | 45 | console.log(groupId);
|
47 | 46 | const artifactId = execSync(aid, { shell: '/bin/bash' }).toString();
|
48 | 47 | console.log(artifactId);
|
49 |
| - var meta = {}; |
| 48 | + let meta = {}; |
50 | 49 | meta['manifestSource'] = pom.replace("/pom.xml", "").substring(1);
|
51 | 50 | meta['manifestTarget'] = "helm-chart/components/charts/" + name + "/" + name + "-deployment/templates/";
|
52 | 51 | meta['owners'] = owners;
|
|
0 commit comments