feat(config): 添加 dist.zip 到 .gitignore 并更新构建和部署脚本

This commit is contained in:
2024-12-20 22:05:48 +08:00
parent bb7d50ac85
commit 1a5a9e2edd
6 changed files with 89475 additions and 11 deletions

19
zip.js
View File

@@ -1,7 +1,6 @@
const fs = require("fs");
const path = require('path');
const JSZip = require("jszip");
const { log } = require("console");
const folderPath = "./configs"
const start = () => {
const files = fs.readdirSync(folderPath);
@@ -11,23 +10,23 @@ const start = () => {
// 并行读取所有的 JSON 文件内容
const combinedJson = {}
const jsonContents = jsonFiles.forEach(file => {
const fileData = JSON.parse(fs.readFileSync(path.join(folderPath, file), 'utf8'))
combinedJson[path.basename(file, '.json')] = fileData
jsonFiles.forEach(file => {
combinedJson[path.basename(file, '.json')] = JSON.parse(fs.readFileSync(path.join(folderPath, file), 'utf8'))
});
compress(JSON.stringify(combinedJson, null, 2))
return compress(JSON.stringify(combinedJson, null, 2))
}
const compress = json => {
const compress = json =>new Promise(resolve => {
const zip = new JSZip();
// 将JSON文件内容添加到ZIP实例中
zip.file('config.json', json, { compression: "DEFLATE", compressionOptions: { level: 9 } });
zip.file('config.json', json, {compression: "DEFLATE", compressionOptions: {level: 9}});
// 生成ZIP文件内容
zip.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
zip.generateNodeStream({type: 'nodebuffer', streamFiles: true})
.pipe(fs.createWriteStream('config.xml'))
.on('finish', function () {
console.log('ZIP file created.');
resolve()
});
}
start()
})
module.exports = {start}