commit c85bea899eafb078b9d045b84e273e4bafa0fe63 Author: Kirito Date: Thu Jul 24 11:56:37 2025 +0800 提交工具 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ae5b6d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/python/switchBundle.spec +/python/build diff --git a/nodejs/switchGame.js b/nodejs/switchGame.js new file mode 100644 index 0000000..1f7c7e0 --- /dev/null +++ b/nodejs/switchGame.js @@ -0,0 +1,106 @@ +var fs = require('fs'); +var path = require('path'); + +var GameID = process.argv[2] + +var absPath = path.resolve('../build/web-mobile/') + '\\' +console.log(absPath) + + +const BundleConfig = { + '6001': 'whot', + '6002': 'whot', + '6003': 'whot', + '6005': 'BRWhot', + '2001': 'roulette', + '2002': 'wajeSpin', + '2003': 'bottleSpin', + '2004': 'blackjack', + '2006': 'betterjack', + '6007': 'whot', + '2008': 'slots', +} + +var emptyDir = function (fileUrl) { + var files = fs.readdirSync(fileUrl);//读取该文件夹 + files.forEach(function (file) { + var stats = fs.statSync(fileUrl + '/' + file); + if (stats.isDirectory()) { + emptyDir(fileUrl + '/' + file); + } else { + fs.unlinkSync(fileUrl + '/' + file); + // console.log("删除文件" + fileUrl + '/' + file + "成功"); + } + }); +} + +//删除所有的空文件夹 +var rmEmptyDir = function (fileUrl) { + var files = fs.readdirSync(fileUrl); + if (files.length > 0) { + var tempFile = 0; + files.forEach(function (fileName) { + tempFile++; + rmEmptyDir(fileUrl + '/' + fileName); + }); + if (tempFile == files.length) {//删除母文件夹下的所有字空文件夹后,将母文件夹也删除 + fs.rmdirSync(fileUrl); + // console.log('删除空文件夹' + fileUrl + '成功'); + } + } else { + fs.rmdirSync(fileUrl); + // console.log('删除空文件夹' + fileUrl + '成功'); + } +} + +function checkDirectory(dst) { + let arr = dst.substring(0, dst.lastIndexOf('/') + 1).split('/') + let dstPath = '' + while (arr.length) { + dstPath += arr.splice(0, 1) + dstPath += '/' + try { + fs.accessSync(dstPath) + } catch (error) { + fs.mkdirSync(dstPath) + } + } +} + + +const unlinkArray = [ + 'cocos2d-js-min.13181.js', + 'physics-min.ce5ee.js', + 'style-desktop.dfd76.css', + 'style-mobile.6e9cd.css' +] +const filesArray = fs.readdirSync(absPath) + +filesArray.forEach(function (fname) { + const file = path.join(absPath, fname) + if (unlinkArray.includes(fname)) { + // 删除公用文件 + fs.unlinkSync(file) + } +}) + +const keepArray = [ + 'main', + 'internal', + 'resources', + BundleConfig[GameID] +] + +const bundleRoot = path.join(absPath, 'assets') +const bundleArray = fs.readdirSync(bundleRoot) + +bundleArray.forEach(function (fname) { + const dir = path.join(bundleRoot, fname) + if (!keepArray.includes(fname)) { + // 删除公用文件 + // fs.unlinkSync(file) + // console.log(dir) + emptyDir(dir) + rmEmptyDir(dir) + } +}) \ No newline at end of file diff --git a/python/dist/switchBundle.exe b/python/dist/switchBundle.exe new file mode 100644 index 0000000..c160288 Binary files /dev/null and b/python/dist/switchBundle.exe differ diff --git a/python/switchBundle.py b/python/switchBundle.py new file mode 100644 index 0000000..c41db6a --- /dev/null +++ b/python/switchBundle.py @@ -0,0 +1,66 @@ +import os +import sys +import subprocess + +if len(sys.argv) < 3: + exit() +if '123!@#' != sys.argv[2]: + exit() + +ProjDir = sys.argv[1] +BuildDir = ProjDir + '\\build\\web-mobile\\' +SubgamePath = 's3://web-h5game-test/internal/' + +BundleConfig = { + '6001': 'whot', + '6002': 'whot', + '6003': 'whot', + '6005': 'BRWhot', + '2001': 'roulette', + '2002': 'wajeSpin', + '2003': 'bottleSpin', + '2004': 'blackjack', + '2006': 'betterjack', + '6007': 'whot', + '2008': 'slots', +} + +unlinkArray = [ + 'cocos2d-js-min.13181.js', + 'physics-min.ce5ee.js', + 'style-desktop.dfd76.css', + 'style-mobile.6e9cd.css', + 'splash.85cfd.png' +] + +def remove_folder(path): + if os.path.exists(path): + if os.path.isfile(path) or os.path.islink(path): + os.remove(path) + else: + for filename in os.listdir(path): + remove_folder(os.path.join(path, filename)) + os.rmdir(path) + +for filename in os.listdir(BuildDir): + file_path = os.path.join(BuildDir, filename) + if filename in unlinkArray: + os.remove(file_path) + +for gameid in BundleConfig: + awsPath = SubgamePath + gameid + '/assets/' + BundleConfig[gameid] +'/' + subgameDir = BuildDir + 'assets\\' + BundleConfig[gameid] +'\\' + cmd = 'call aws s3 cp '+ subgameDir +' '+awsPath + ' --recursive --region ap-east-1' + result = subprocess.run(['cmd', '/c', cmd], capture_output=True, text=True) + print(result) + +for gameid in BundleConfig: + awsPath = SubgamePath + gameid + '/assets/' + BundleConfig[gameid] +'/' + subgameDir = BuildDir + 'assets\\' + BundleConfig[gameid] + remove_folder(subgameDir) + +for gameid in BundleConfig: + awsPath = SubgamePath + gameid + '/' + cmd = 'call aws s3 cp '+ BuildDir +' '+awsPath + ' --recursive --region ap-east-1' + result = subprocess.run(['cmd', '/c', cmd], capture_output=True, text=True) + print(result) \ No newline at end of file