-
Notifications
You must be signed in to change notification settings - Fork 12
/
message_bus.build.js
68 lines (59 loc) · 1.58 KB
/
message_bus.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* @LastEditors: zhanghengxin [email protected]
* @LastEditTime: 2023/1/3 下午8:51
* @FilePath: /CasaOS-UI/message_bus.build.js
* @Description:
*
* Copyright (c) 2022 by IceWhale, All Rights Reserved.
*/
const events = require('./src/events/message_bus.js');
const fs = require('fs');
const path = require('path');
const outPath = '../build/sysroot/var/lib/casaos/';
const outName = 'ui-message-bus.json';
const registerShellPath = '../build/sysroot/etc/casaos/start.d/';
var array = [];
// Parse the event to array
Object.keys(events).forEach((key) => {
events[key]().then(eventObj => {
eventObj.propertyTypeList = Object.keys(eventObj.properties)
eventObj.propertyTypeList = eventObj.propertyTypeList.map((key) => {
return {
"name": key,
"discription": "",
"example": ""
}
});
delete eventObj.properties
array.push(eventObj);
});
});
// Create the output folder
fs.mkdir(outPath, {recursive: true}, (err) => {
if (err) {
console.log(err);
} else {
// Write the output file
fs.writeFile(path.join(outPath, outName), JSON.stringify(array, "", "\t"), (err) => {
if (err) {
console.log(err);
} else {
console.log('The json file has been saved!');
}
});
}
});
// Copy the register shell file to the output folder
fs.mkdir(registerShellPath, {recursive: true}, (err) => {
if (err) {
console.log(err);
} else {
fs.copyFile('./register-ui-events.sh', path.join(registerShellPath, 'register-ui-events.sh'), (err) => {
if (err) {
console.log(err);
} else {
console.log('The shell file has been saved!');
}
});
}
});