forked from ortelius/ortelius-charts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
49 lines (41 loc) · 1.27 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const axios = require("axios");
const yaml = require('js-yaml');
const fs = require('fs');
const chartRepos = [
"ortelius/ortelius",
"ortelius/ortelius-ms-dep-pkg-cud",
"ortelius/ortelius-ms-dep-pkg-r",
"ortelius/ortelius-ms-textfile-crud",
"ortelius/ortelius-ms-compitem-crud",
"ortelius/ortelius-ms-validate-user",
]
// Helper functions
async function getChartEntries() {
for (let i = 0; i < chartRepos.length; i++) {
const repoUrl = `https://github.com/${chartRepos[i]}/raw/gh-pages/index.yaml`;
await axios.get(repoUrl).then(response => {
let parsedYaml = yaml.load(response.data)
let entries = parsedYaml.entries
Object.keys(entries).forEach(key => {
chartEntries[key] = entries[key]
});
return entries
})
}
}
function createYamlOutput() {
const output = yaml.dump({
apiVersion: "v1",
entries: chartEntries,
generated: new Date().toISOString()
}, {noArrayIndent: true})
return output
}
// -----------------
let chartEntries = {}
getChartEntries().then(() => {
const yamlOutput = createYamlOutput()
fs.writeFileSync("./index-temp.yaml", yamlOutput, "utf8", (err) => {
console.log(err)
})
})