-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.js
43 lines (34 loc) · 1.25 KB
/
build.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
const dotenv = require('dotenv')
const fs = require('fs-extra')
dotenv.config()
// Create a dist folder
const createDirectory = () => fs.mkdirp('./dist')
// Copy public contents
const copyFiles = () => fs.copy('./public', './dist')
// Generate v1 and v1.1 manifest list files
const generateAPI = () => {
const url = process.env.URL;
const v1_ManifestList = require('./v1.json');
const v1_1_ManifestList = require('./v1.1.json');
function prepareManifestUrls(manifestList) {
manifestList.options = manifestList.options.map(firmware => {
firmware.versions.map(manifest => {
manifest.manifest = `${url}${manifest.manifest}`;
return manifest;
});
return firmware;
});
}
[v1_ManifestList, v1_1_ManifestList].forEach(prepareManifestUrls);
v1_1_ManifestList.options =
v1_ManifestList.options
.concat(v1_1_ManifestList.options);
fs.writeFile('./dist/v1/manifest-list.json', JSON.stringify(v1_ManifestList))
fs.writeFile('./dist/v1.1/manifest-list.json', JSON.stringify(v1_1_ManifestList))
}
// build
const build = () =>
createDirectory()
.then(copyFiles)
.then(generateAPI)
build()