提交subgame插件

This commit is contained in:
Kirito
2025-07-11 14:49:28 +08:00
commit b225060f0f
1240 changed files with 257564 additions and 0 deletions

59
dist/utils/BuildUtils.js vendored Normal file
View File

@@ -0,0 +1,59 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = __importDefault(require("child_process"));
var BuildUtils;
(function (BuildUtils) {
const LOG_SPLIT_SEPARATOR = '||||||';
const exec = (cmd) => {
const promise = new Promise((resolve) => {
let result = '';
const stream = child_process_1.default.exec(cmd);
stream.stdout.on('data', data => {
console.log('stdout: ' + data);
result += data;
});
stream.stderr.on('data', data => console.error(`stderr: ${data}`));
stream.on('close', (code) => {
if (code !== 0)
console.warn(`process exited with code ${code}`);
resolve(result || "");
});
});
return promise;
};
BuildUtils.readGitVersion = (dir) => __awaiter(this, void 0, void 0, function* () {
const commit = yield exec(`cd ${dir} && git show -s --format=%H`);
return commit.trim();
});
BuildUtils.readGitLog = (dir, startVersion) => __awaiter(this, void 0, void 0, function* () {
let command = `cd ${dir} && `;
command += startVersion ? `git log ${startVersion}.. ` : 'git log ';
command += `--pretty=format:"%an${LOG_SPLIT_SEPARATOR}%s${LOG_SPLIT_SEPARATOR}%H" --no-merges`;
const log = yield exec(command);
const logArray = log.split('\n');
const messageArray = [];
logArray.forEach((element) => {
if (!element || !element.length)
return;
const data = element.split(LOG_SPLIT_SEPARATOR);
if (!data || data.length !== 3)
return;
const [name, title, id] = data;
messageArray.push({ name, title });
});
return messageArray;
});
})(BuildUtils || (BuildUtils = {}));
exports.default = BuildUtils;

120
dist/utils/FileUtils.js vendored Normal file
View File

@@ -0,0 +1,120 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const archiver_1 = __importDefault(require("archiver"));
var FileUtils;
(function (FileUtils) {
function copy(srcFileOrDir, destFileOrDir) {
if (!fs_1.default.existsSync(srcFileOrDir))
return;
const stat = fs_1.default.statSync(srcFileOrDir);
if (stat.isDirectory()) {
mkdir(destFileOrDir);
const files = fs_1.default.readdirSync(srcFileOrDir);
files.forEach(item => copy(path_1.default.join(srcFileOrDir, item), path_1.default.join(destFileOrDir, item)));
}
else {
mkdir(path_1.default.dirname(destFileOrDir));
fs_1.default.copyFileSync(srcFileOrDir, destFileOrDir);
}
}
FileUtils.copy = copy;
function mkdir(dir) {
if (fs_1.default.existsSync(dir))
return;
let parentDir = path_1.default.dirname(dir);
mkdir(parentDir);
fs_1.default.mkdirSync(dir);
}
FileUtils.mkdir = mkdir;
function rm(fileOrDir) {
if (!fs_1.default.existsSync(fileOrDir))
return;
const stat = fs_1.default.statSync(fileOrDir);
if (stat.isDirectory()) {
const files = fs_1.default.readdirSync(fileOrDir);
files.forEach(item => rm(path_1.default.join(fileOrDir, item)));
fs_1.default.rmdirSync(fileOrDir);
}
else {
fs_1.default.unlinkSync(fileOrDir);
}
}
FileUtils.rm = rm;
function find(dir, nameOrRegExp, deepFind = false) {
if (!fs_1.default.existsSync(dir))
return null;
const files = fs_1.default.readdirSync(dir);
const check = typeof nameOrRegExp === 'string' ? (value) => value === nameOrRegExp : (value) => nameOrRegExp.test(value);
for (const file of files) {
const fullPath = path_1.default.join(dir, file);
const stat = fs_1.default.statSync(fullPath);
if (!stat.isDirectory()) {
if (check(file))
return fullPath;
}
else if (deepFind) {
const result = find(fullPath, nameOrRegExp);
if (result)
return result;
}
}
return null;
}
FileUtils.find = find;
function fileCount(dir, includeFolder = false) {
if (!fs_1.default.existsSync(dir))
return 0;
const stat = fs_1.default.statSync(dir);
if (!stat.isDirectory()) {
return 1;
}
let count = includeFolder ? 1 : 0;
const files = fs_1.default.readdirSync(dir);
files.forEach(item => count += fileCount(path_1.default.join(dir, item)));
return count;
}
FileUtils.fileCount = fileCount;
function checkFileNameIndex(fileFullPath, indexGen = index => `(${index})`) {
if (!fs_1.default.existsSync(fileFullPath))
return fileFullPath;
const extname = path_1.default.extname(fileFullPath);
const basename = path_1.default.basename(fileFullPath, extname);
const dirname = path_1.default.dirname(fileFullPath);
let i = 1;
let limit = 1000;
while (limit-- > 0) {
const newPath = path_1.default.join(dirname, `${basename}${indexGen(i)}${extname}`);
if (!fs_1.default.existsSync(newPath))
return newPath;
i++;
}
return null;
}
FileUtils.checkFileNameIndex = checkFileNameIndex;
function zipdir(srcDir, outputFile) {
mkdir(path_1.default.dirname(outputFile));
var promise = new Promise((resolve, reject) => {
const writeStream = fs_1.default.createWriteStream(outputFile);
const archive = (0, archiver_1.default)('zip', {
zlib: { level: 9 }
});
writeStream.on('close', () => {
resolve();
});
archive.on('error', function (error) {
reject(error);
});
archive.pipe(writeStream);
archive.directory(srcDir, false);
archive.finalize();
});
return promise;
}
FileUtils.zipdir = zipdir;
})(FileUtils || (FileUtils = {}));
exports.default = FileUtils;

66
dist/utils/MD5Utils.js vendored Normal file
View File

@@ -0,0 +1,66 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const crypto_1 = __importDefault(require("crypto"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
var MD5Utils;
(function (MD5Utils) {
function md5(text) {
const hash = crypto_1.default.createHash('md5');
hash.update(text);
const hex = hash.digest('hex');
return hex;
}
MD5Utils.md5 = md5;
function md5Dir(fileOrDir, output) {
output = output || [];
if (!fs_1.default.existsSync(fileOrDir))
return output;
const relativePath = fileOrDir;
const md5 = (file) => {
const stat = fs_1.default.statSync(file);
if (!stat.isDirectory()) {
const buffer = fs_1.default.readFileSync(file);
const hash = crypto_1.default.createHash('md5');
hash.update(buffer);
const hex = hash.digest('hex');
output.push({ path: path_1.default.relative(relativePath, file), md5: hex });
}
else {
const files = fs_1.default.readdirSync(file);
files.forEach(item => md5(path_1.default.join(file, item)));
}
};
md5(fileOrDir);
return output;
}
MD5Utils.md5Dir = md5Dir;
function md5Compare(source, target) {
const result = { added: [], deleted: [], changed: [], same: [] };
target = target.concat([]);
source = source.concat([]);
let sourceItem;
while (sourceItem = source.shift()) {
let matchItem = undefined;
for (let j = 0, length = target.length; j < length; j++) {
const targetItem = target[j];
if (targetItem.path !== sourceItem.path)
continue;
matchItem = targetItem;
target.splice(j, 1);
break;
}
if (!matchItem)
result.added.push(sourceItem);
else
matchItem.md5 === sourceItem.md5 ? result.same.push(sourceItem) : result.changed.push(sourceItem);
}
result.deleted.push(...target);
return result;
}
MD5Utils.md5Compare = md5Compare;
})(MD5Utils || (MD5Utils = {}));
exports.default = MD5Utils;

19
dist/utils/ProcessUtils.js vendored Normal file
View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ProcessUtils;
(function (ProcessUtils) {
function getArg(key, check) {
const index = process.argv.indexOf(key);
if (index < 0)
return null;
const value = process.argv[index + 1];
return check ? (check(value) ? value : null) : value;
}
ProcessUtils.getArg = getArg;
function haveArg(key) {
const index = process.argv.indexOf(key);
return index >= 0;
}
ProcessUtils.haveArg = haveArg;
})(ProcessUtils || (ProcessUtils = {}));
exports.default = ProcessUtils;