From b83229b5dad91ae9de03ef6ed33e9862283b383b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 27 Oct 2024 22:30:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=8A=A8=E5=8C=96=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=91=E5=B8=83=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/checkVersion.cjs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/script/checkVersion.cjs b/script/checkVersion.cjs index 1f62e0c0..bc6a0702 100644 --- a/script/checkVersion.cjs +++ b/script/checkVersion.cjs @@ -4,16 +4,27 @@ const process = require("process"); console.log("[NapCat] [CheckVersion] 开始检测当前仓库版本..."); try { const packageJson = require("../package.json"); + const manifsetJson = require("../manifest.json"); + const currentVersion = packageJson.version; const targetVersion = process.env.VERSION; + const manifestCurrentVersion = manifsetJson.version; + const manifestTargetVersion = process.env.VERSION; + console.log("[NapCat] [CheckVersion] currentVersion:", currentVersion, "targetVersion:", targetVersion); + console.log("[NapCat] [CheckVersion] manifestCurrentVersion:", manifestCurrentVersion, "manifestTargetVersion:", manifestTargetVersion); // 验证 targetVersion 格式 if (!targetVersion || typeof targetVersion !== 'string') { console.log("[NapCat] [CheckVersion] 目标版本格式不正确或未设置!"); return; } + // 验证 manifestTargetVersion 格式 + if (!manifestTargetVersion || typeof manifestTargetVersion !== 'string') { + console.log("[NapCat] [CheckVersion] manifest目标版本格式不正确或未设置!"); + return; + } // 写入脚本文件的统一函数 const writeScriptToFile = (content) => { @@ -21,7 +32,7 @@ try { console.log("[NapCat] [CheckVersion] checkVersion.sh 文件已更新。"); }; - if (currentVersion === targetVersion) { + if (currentVersion === targetVersion && manifestCurrentVersion === manifestTargetVersion) { // 不需要更新版本,写入一个简单的脚本 const simpleScript = "#!/bin/bash\necho \"CheckVersion Is Done\""; writeScriptToFile(simpleScript); @@ -32,6 +43,9 @@ try { git config --global user.email "bot@test.wumiao.wang" git config --global user.name "Version" sed -i "s/\\\"version\\\": \\\"${currentVersion}\\\"/\\\"version\\\": \\\"${targetVersion}\\\"/g" package.json + sed -i "s/\\\"version\\\": \\\"${manifestCurrentVersion}\\\"/\\\"version\\\": \\\"${manifestTargetVersion}\\\"/g" manifest.json + sed -i "s/napCatVersion = '\\${currentVersion}'/napCatVersion = '\\${targetVersion}'/g" ./src/common/version.ts + sed -i 's/SettingButton("V[0-9]\+\.[0-9]\+\.[0-9]\+", "napcat-update-button", "secondary")/SettingButton("'"${NEW_VERSION}"'", "napcat-update-button", "secondary")/g' ./static/assets/renderer.js git add . git commit -m "chore:version change" git push -u origin main`;