forked from video-dev/hls.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-deployments-readme.js
76 lines (60 loc) · 1.71 KB
/
build-deployments-readme.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* eslint-disable no-console */
const fs = require('node:fs');
const path = require('node:path');
const assert = require('node:assert');
const itemCountMd = 100;
const txtFileName = 'deployments.txt';
async function go() {
// eslint-disable-next-line no-undef
const [, , deploymentsFile, outputDir] = process.argv;
assert(deploymentsFile, 'Missing deploymentsFile');
assert(outputDir, 'Missing outputDir');
const { stable, latest, individual } = JSON.parse(
await fs.promises.readFile(deploymentsFile, { encoding: 'utf-8' }),
);
const mdContent = `# Deployments
- **Stable:** [${stable}](${stable})
- **Latest:** [${latest}](${latest})
Below you can find the URL's to deployments for individual commits:
${Array.from(individual)
.reverse()
.slice(0, itemCountMd)
.map(
({ commit, version, url }) =>
`- [\`${commit.slice(
0,
8,
)} (${version})\`](https://github.com/video-dev/hls.js/commit/${commit}): [${url}](${url})`,
)
.join('\n')}
_Note for older deployments please check [${txtFileName}](./${txtFileName})._
`;
await fs.promises.writeFile(path.resolve(outputDir, 'README.md'), mdContent, {
encoding: 'utf-8',
});
const txtContent = `Deployments
===========
- Stable: ${stable}
- Latest: ${latest}
Below you can find the URL's to deployments for individual commits:
${Array.from(individual)
.reverse()
.map(
({ commit, version, url }) =>
`- ${commit.slice(0, 8)} (${version}): ${url}`,
)
.join('\n')}
`;
await fs.promises.writeFile(
path.resolve(outputDir, txtFileName),
txtContent,
{
encoding: 'utf-8',
},
);
}
go().catch((e) => {
console.error(e);
// eslint-disable-next-line no-undef
process.exit(1);
});