-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (52 loc) · 1.33 KB
/
index.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
const fs = require("fs");
const path = require("path");
const yaml = require("./js-yaml");
// @ts-ignore
const { exec } = require("child_process");
const config = {
version: "1.3.0-9",
files: {
url: "",
sha512: "",
size: "",
},
path: "Frigga_Data_Center_1.3.0-9_.exe",
sha512: "",
releaseDate: "",
};
const filePath = `./OutFile/${config.path}`;
const outPath = `./OutFile/${config.path}.blockmap`;
const ymlPath = `./OutFile/${config.path}.latest.yml`;
const buildBlockmapCmd = `${path.join(
process.cwd(),
"app-builder.exe"
)} blockmap -i ${path.join(process.cwd(), filePath)} -o ${path.join(
process.cwd(),
outPath
)} `;
exec(buildBlockmapCmd, (error, stdout, stderr) => {
if (error) {
console.error(`执行命令时出错: ${error}`);
return;
}
// @ts-ignore
config.releaseDate = new Date();
const data = JSON.parse(stdout);
config.files = {
url: config.path,
sha512: data.sha512,
size: data.size,
};
config.sha512 = data.sha512;
console.log(config);
try {
// 将数据转换为YAML格式的字符串
const yamlData = yaml.dump(config, { lineWidth: -1 });
console.log(yamlData);
// 将数据写入YAML文件
fs.writeFileSync(ymlPath, yamlData, "utf8");
console.log("YAML文件已创建并写入数据。");
} catch (e) {
console.log(e);
}
});