1 Star 0 Fork 0

马乙华/scui-for-jimmer-fast

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
generate-api.js 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
mayihua 提交于 2023-10-22 12:02 . generate-api
const http = require('http');
const fs = require('fs');
const fse = require('fs-extra');
const uuid = require('uuid');
const os = require('os');
const AdmZip = require('adm-zip');
const sourceUrl = "http://localhost:8080/ts.zip";
const tmpFilePath = os.tmpdir() + "/" + uuid.v4() + ".zip";
const generatePath = "src/api/__generated";
console.log("Downloading " + sourceUrl + "...");
const tmpFile = fs.createWriteStream(tmpFilePath);
const request = http.get(sourceUrl, (response) => {
response.pipe(tmpFile);
tmpFile.on("finish", () => {
tmpFile.close();
console.log("File save success: ", tmpFilePath);
// Remove generatePath if it exists
if (fs.existsSync(generatePath)) {
console.log("Removing existing generatePath...");
fse.removeSync(generatePath);
console.log("Existing generatePath removed.");
}
// Unzip the file using adm-zip
console.log("Unzipping the file...");
const zip = new AdmZip(tmpFilePath);
zip.extractAllTo(generatePath, true);
console.log("File unzipped successfully.");
// Remove the temporary file
console.log("Removing temporary file...");
fs.unlink(tmpFilePath, (err) => {
if (err) {
console.error("Error while removing temporary file:", err);
} else {
console.log("Temporary file removed.");
}
});
});
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mayihua/scui-for-jimmer-fast.git
git@gitee.com:mayihua/scui-for-jimmer-fast.git
mayihua
scui-for-jimmer-fast
scui-for-jimmer-fast
master

搜索帮助