forked from MyPureCloud/genesys-cloud-webrtc-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-manifest.js
52 lines (45 loc) · 1.25 KB
/
create-manifest.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
#!/usr/bin/env node
const fs = require('fs');
const buildDate = new Date();
const manifest = {
name: process.env.APP_NAME,
version: process.env.VERSION,
build: process.env.BUILD_ID,
buildDate: buildDate.toISOString(),
indexFiles: []
};
/* read top level genesys-cloud-webrtc-sdk file variations */
const files = fs.readdirSync('dist/');
files.forEach(file => {
/* skip directories and non-js files */
if (
fs.lstatSync('dist/' + file).isDirectory() ||
!file.startsWith('genesys-cloud-webrtc-sdk')
) {
return;
}
manifest.indexFiles.push({ file });
});
try {
const files = fs.readdirSync('dist/demo/');
files.forEach(file => {
if (fs.lstatSync('dist/demo/' + file).isDirectory()) {
const dirFiles = fs.readdirSync('dist/demo/' + file);
dirFiles.forEach(dirFile => {
if (fs.lstatSync('dist/demo/' + file + '/' + dirFile).isDirectory()) {
return;
}
manifest.indexFiles.push({
file: '/demo/' + file + '/' + dirFile
});
});
return;
}
manifest.indexFiles.push({
file: '/demo/' + file
});
});
} catch (e) {
// demo dir (examples don't exist)
}
fs.writeFileSync('./dist/manifest.json', JSON.stringify(manifest, null, 2), { encoding: 'utf8' });