Bladeren bron

📦 升级更新脚本

快乐的梦鱼 1 maand geleden
bovenliggende
commit
b57ec95e88
2 gewijzigde bestanden met toevoegingen van 10 en 5 verwijderingen
  1. 3 3
      src/scripts/UpdateScript/postUpdate.mjs
  2. 7 2
      src/scripts/UpdateScript/utils.mjs

+ 3 - 3
src/scripts/UpdateScript/postUpdate.mjs

@@ -50,7 +50,7 @@ async function getUpdateInfo(postConfig) {
   if (updateInfo === 'git') {
     console.log('开始获取git提交信息');
     updateInfo = await execAsync('git log -1 --pretty=format:"%h %s"');
-    console.log('使用git提交信息作为更新信息');
+    console.log('使用git提交信息 "' + updateInfo + '" 作为更新信息');
   }
   return updateInfo;
 }
@@ -145,7 +145,7 @@ async function aliOSSMultipartUpload(client, fileName, uploadFile, progressCallb
 
 export async function postAppUpdate(axiosInstance, param) {
   const postConfig = await getConfig();
-  const { versionId, versionName } = await selectVersion(false, postConfig.lastVersion);
+  const { versionId, versionName } = await selectVersion(postConfig.lastVersion);
   const updateInfo = await getUpdateInfo(postConfig);
 
   const serverConfig = await axiosInstance.post('/update-post', { 
@@ -339,7 +339,7 @@ export async function postWebUpdate(axiosInstance, param) {
   const noDelete = param.ndelete;
   
   const postConfig = await getConfig();
-  const { versionId, versionName } = await selectVersion(false, postConfig.lastVersion);
+  const { versionId, versionName } = await selectVersion(postConfig.lastVersion);
   const updateInfo = await getUpdateInfo(postConfig);
 
   postConfig.lastVersion = versionId;

+ 7 - 2
src/scripts/UpdateScript/utils.mjs

@@ -56,10 +56,14 @@ export async function compressZip(dir, targetFilePath, skipFiles) {
   });
   archive.pipe(output);
 
-  function checkPathSkip(path) {
+  function checkPathSkip(pathString) {
+    if (!pathString)
+      return true;
+    if (pathString.startsWith('.') || pathString.startsWith('/.'))
+      return true;
     if (!skipFiles || skipFiles.length === 0)
       return;
-    return skipFiles.find((item) => path.startsWith(item));
+    return skipFiles.find((item) => pathString.startsWith(item) || pathString.startsWith(`/${item}`));
   }
 
   async function loopDir(path, subPrefix) {
@@ -68,6 +72,7 @@ export async function compressZip(dir, targetFilePath, skipFiles) {
       const subPath = subPrefix + '/' + file;
       if (checkPathSkip(subPath))
         continue;
+      console.log('File: ' + subPath);
       const filestat = await stat(dir + subPath);
       if (filestat.isDirectory()) {
         await loopDir(dir + subPath, subPath);