mirror of
https://github.com/actions/github-script.git
synced 2026-04-08 07:00:05 +00:00
Ran prettier
This commit is contained in:
parent
31d5a27e0d
commit
4a70df81cd
5 changed files with 344 additions and 219 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import * as core from '@actions/core'
|
||||
import * as exec from '@actions/exec'
|
||||
import { Context } from '@actions/github/lib/context'
|
||||
import { GitHub } from '@actions/github/lib/utils'
|
||||
import {Context} from '@actions/github/lib/context'
|
||||
import {GitHub} from '@actions/github/lib/utils'
|
||||
import * as glob from '@actions/glob'
|
||||
import * as io from '@actions/io'
|
||||
import * as se from './se'
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import {RequestRequestOptions} from '@octokit/types'
|
|||
import {callAsyncFunction} from './async-function'
|
||||
import {getRetryOptions, parseNumberArray, RetryOptions} from './retry-options'
|
||||
import {wrapRequire} from './wrap-require'
|
||||
import * as se from './se'
|
||||
|
||||
process.on('unhandledRejection', handleError)
|
||||
main().catch(handleError)
|
||||
|
|
@ -56,7 +57,8 @@ async function main(): Promise<void> {
|
|||
core,
|
||||
exec,
|
||||
glob,
|
||||
io
|
||||
io,
|
||||
se
|
||||
},
|
||||
script
|
||||
)
|
||||
|
|
|
|||
140
src/se.ts
140
src/se.ts
|
|
@ -1,60 +1,92 @@
|
|||
import * as child from 'child_process';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export function createMetaJson(): string[] {
|
||||
return createMetaJson('./')
|
||||
}
|
||||
import * as child from 'child_process'
|
||||
import * as fs from 'fs'
|
||||
|
||||
export function createMetaJson(root: string): string[] {
|
||||
const execSync = child.execSync;
|
||||
const execSync = child.execSync
|
||||
|
||||
const xmllint = execSync('sudo apt install libxml2-utils', { shell: '/bin/bash' });
|
||||
console.log(xmllint.toString());
|
||||
const command = `#!/bin/bash
|
||||
cd ` + root + `
|
||||
find . -name 'pom.xml' -type f > ` + root + `poms.txt
|
||||
`;
|
||||
const output = execSync(command, { shell: '/bin/bash' });
|
||||
console.log(output.toString());
|
||||
const xmllint = execSync('sudo apt install libxml2-utils', {
|
||||
shell: '/bin/bash'
|
||||
})
|
||||
console.log(xmllint.toString())
|
||||
const command =
|
||||
`#!/bin/bash
|
||||
cd ` +
|
||||
root +
|
||||
`
|
||||
find . -name 'pom.xml' -type f > ` +
|
||||
root +
|
||||
`poms.txt
|
||||
`
|
||||
const output = execSync(command, {shell: '/bin/bash'})
|
||||
console.log(output.toString())
|
||||
const ret: string[] = []
|
||||
const poms = fs.readFileSync(root + 'poms.txt', 'utf8').toString()
|
||||
const ownersFile = 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 owners = []
|
||||
const reviewers = []
|
||||
for (const ownerRaw of ownersFile.split('\n')) {
|
||||
const path = ownerRaw.split(' ')[0]
|
||||
|
||||
const poms = fs.readFileSync(root + 'poms.txt', 'utf8').toString();
|
||||
const ownersFile = 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 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)) {
|
||||
owners.push(ownerRaw.split(' ')[1])
|
||||
reviewers.push(ownerRaw.split(' ')[1])
|
||||
}
|
||||
}
|
||||
const gid = `#!/bin/bash
|
||||
cd ` + root + `
|
||||
xmllint --xpath "/*[local-name()='project']/*[local-name()='groupId']/text()" ` + pom + `
|
||||
`
|
||||
const aid = `#!/bin/bash
|
||||
cd ` + root + `
|
||||
xmllint --xpath "/*[local-name()='project']/*[local-name()='artifactId']/text()" ` + pom + `
|
||||
`
|
||||
const groupId = execSync(gid, { shell: '/bin/bash' }).toString();
|
||||
console.log(groupId);
|
||||
const artifactId = execSync(aid, { shell: '/bin/bash' }).toString();
|
||||
console.log(artifactId);
|
||||
const meta = {};
|
||||
meta['manifestSource'] = pom.replace("/pom.xml", "").substring(1);
|
||||
meta['manifestTarget'] = "helm-chart/components/charts/" + name + "/" + name + "-deployment/templates/";
|
||||
meta['owners'] = owners;
|
||||
meta['reviewers'] = reviewers;
|
||||
meta['branchName'] = name + "-deployment";
|
||||
meta['mavenGroupId'] = groupId.trim();
|
||||
meta['mavenArtifactId'] = artifactId.trim();
|
||||
console.log(JSON.stringify(meta));
|
||||
fs.writeFileSync(root + pomRaw.replace("/pom.xml", "/meta.json").substring(1), JSON.stringify(meta));
|
||||
if (
|
||||
path.length > 3 &&
|
||||
ownerRaw.indexOf(' @') > -1 &&
|
||||
pom.startsWith(path)
|
||||
) {
|
||||
owners.push(ownerRaw.split(' ')[1])
|
||||
reviewers.push(ownerRaw.split(' ')[1])
|
||||
}
|
||||
}
|
||||
const gid =
|
||||
`#!/bin/bash
|
||||
cd ` +
|
||||
root +
|
||||
`
|
||||
xmllint --xpath "/*[local-name()='project']/*[local-name()='groupId']/text()" ` +
|
||||
pom +
|
||||
`
|
||||
`
|
||||
const aid =
|
||||
`#!/bin/bash
|
||||
cd ` +
|
||||
root +
|
||||
`
|
||||
xmllint --xpath "/*[local-name()='project']/*[local-name()='artifactId']/text()" ` +
|
||||
pom +
|
||||
`
|
||||
`
|
||||
const groupId = execSync(gid, {shell: '/bin/bash'}).toString()
|
||||
console.log(groupId)
|
||||
const artifactId = execSync(aid, {shell: '/bin/bash'}).toString()
|
||||
console.log(artifactId)
|
||||
const meta: {[key: string]: any} = {}
|
||||
meta['manifestSource'] = pom.replace('/pom.xml', '').substring(1)
|
||||
meta['manifestTarget'] =
|
||||
'helm-chart/components/charts/' +
|
||||
name +
|
||||
'/' +
|
||||
name +
|
||||
'-deployment/templates/'
|
||||
meta['owners'] = owners
|
||||
meta['reviewers'] = reviewers
|
||||
meta['branchName'] = 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))
|
||||
fs.writeFileSync(
|
||||
root + pomRaw.replace('/pom.xml', '/meta.json').substring(1),
|
||||
JSON.stringify(meta)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue