perf: 优化更新日志生成

This commit is contained in:
kuaifan 2023-02-15 16:10:59 +08:00
parent 6a2c56da3e
commit 30b511891e
5 changed files with 1825 additions and 11 deletions

1
.gitignore vendored
View File

@ -8,7 +8,6 @@
/vendor /vendor
/build /build
/tmp /tmp
/CHANGELOG.md
._* ._*
.env .env
.idea .idea

1801
CHANGELOG.md Normal file

File diff suppressed because it is too large Load Diff

9
electron/build.js vendored
View File

@ -30,7 +30,7 @@ function cloneDrawio(systemInfo) {
fse.copySync(drawioCoverDir, drawioDestDir) fse.copySync(drawioCoverDir, drawioDestDir)
// //
const preConfigFile = path.resolve(drawioDestDir, "js/PreConfig.js"); const preConfigFile = path.resolve(drawioDestDir, "js/PreConfig.js");
if (!fse.existsSync(preConfigFile)) { if (!fs.existsSync(preConfigFile)) {
console.log("clone drawio error!"); console.log("clone drawio error!");
process.exit() process.exit()
} }
@ -41,9 +41,8 @@ function cloneDrawio(systemInfo) {
} }
function changeLog() { function changeLog() {
child_process.execSync("docker run -t --rm -v \"$(pwd)\":/app/ orhunp/git-cliff:latest > CHANGELOG.md", {stdio: "inherit"});
let filePath = path.resolve(__dirname, "../CHANGELOG.md"); let filePath = path.resolve(__dirname, "../CHANGELOG.md");
if (!fse.existsSync(filePath)) { if (!fs.existsSync(filePath)) {
return ""; return "";
} }
let content = fs.readFileSync(filePath, 'utf8') let content = fs.readFileSync(filePath, 'utf8')
@ -70,7 +69,7 @@ function genericPublish({url, version, output}) {
} else { } else {
for (const filename of files) { for (const filename of files) {
const localFile = path.join(filePath, filename) const localFile = path.join(filePath, filename)
if (fse.existsSync(localFile)) { if (fs.existsSync(localFile)) {
const fileStat = fs.statSync(localFile) const fileStat = fs.statSync(localFile)
if (fileStat.isFile()) { if (fileStat.isFile()) {
const uploadOra = ora(`${filename} uploading...`).start() const uploadOra = ora(`${filename} uploading...`).start()
@ -191,7 +190,7 @@ if (["dev"].includes(argv[2])) {
} else if (["app"].includes(argv[2])) { } else if (["app"].includes(argv[2])) {
// 编译给app // 编译给app
let mobileSrcDir = path.resolve(__dirname, "../resources/mobile"); let mobileSrcDir = path.resolve(__dirname, "../resources/mobile");
if (!fse.existsSync(mobileSrcDir)) { if (!fs.existsSync(mobileSrcDir)) {
console.log("mobile directory does not exist!"); console.log("mobile directory does not exist!");
process.exit() process.exit()
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "DooTask", "name": "DooTask",
"version": "0.22.99", "version": "0.23.2",
"description": "DooTask is task management system.", "description": "DooTask is task management system.",
"scripts": { "scripts": {
"start": "./cmd dev", "start": "./cmd dev",

23
version.js vendored
View File

@ -2,6 +2,7 @@ const fs = require('fs');
const path = require("path"); const path = require("path");
const exec = require('child_process').exec; const exec = require('child_process').exec;
const packageFile = path.resolve(process.cwd(), "package.json"); const packageFile = path.resolve(process.cwd(), "package.json");
const changeFile = path.resolve(process.cwd(), "CHANGELOG.md");
function runExec(command, cb) { function runExec(command, cb) {
exec(command, function (err, stdout, stderr) { exec(command, function (err, stdout, stderr) {
@ -20,15 +21,29 @@ runExec("git rev-list --count HEAD $(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
console.error(err); console.error(err);
return; return;
} }
let num = parseInt(response) const num = parseInt(response)
if (isNaN(num) || Math.floor(num % 100) < 0) { if (isNaN(num) || Math.floor(num % 100) < 0) {
console.error("get version error " + response); console.error("get version error " + response);
return; return;
} }
let ver = Math.floor(num / 10000) + "." + Math.floor(num / 100) + "." + Math.floor(num % 100) const ver = Math.floor(num / 10000) + "." + Math.floor(num / 100) + "." + Math.floor(num % 100)
// //
let newResult = fs.readFileSync(packageFile, 'utf8').replace(/"version":\s*"(.*?)"/, `"version": "${ver}"`); const newResult = fs.readFileSync(packageFile, 'utf8').replace(/"version":\s*"(.*?)"/, `"version": "${ver}"`);
fs.writeFileSync(packageFile, newResult, 'utf8'); fs.writeFileSync(packageFile, newResult, 'utf8');
// //
console.log("new version: " + ver); console.log("New version: " + ver);
//
runExec("docker run -t --rm -v \"$(pwd)\":/app/ orhunp/git-cliff:0.8.0 > CHANGELOG.md", function (err, response) {
if (err) {
console.error(err);
return;
}
if (!fs.existsSync(changeFile)) {
console.error("Change file does not exist");
return "";
}
const newContent = fs.readFileSync(changeFile, 'utf8').replace("## [Unreleased]", `## [${ver}]`);
fs.writeFileSync(changeFile, newContent, 'utf8');
console.log("Log file: CHANGELOG.md");
});
}); });