@yangrunchi/a_6 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AutoCfg/A6_generate-tablemgr.js +4 -3
- package/AutoCfg/csvcfg.js +4 -4
- package/AutoCode/A2_generate-panel.js +3 -2
- package/AutoCode/A3_watcher.js +2 -1
- package/AutoNetMsg/A5_generate-funcdata.js +3 -2
- package/AutoNetMsg/A5_sync-netmsg.js +4 -3
- package/SVNUpdate/svn_996.js +2 -1
- package/Tools/project-root.js +41 -0
- package/cli.js +28 -19
- package/package.json +1 -1
|
@@ -8,11 +8,12 @@ const path = require('path');
|
|
|
8
8
|
const { execSync } = require('child_process');
|
|
9
9
|
|
|
10
10
|
// ==================== 配置 ====================
|
|
11
|
+
const projectRoot = require('../Tools/project-root')();
|
|
11
12
|
|
|
12
13
|
// 目录路径配置
|
|
13
|
-
const csvcfgDir = path.join(
|
|
14
|
-
const mgrDir = path.join(
|
|
15
|
-
const gameConfigDir = path.join(
|
|
14
|
+
const csvcfgDir = path.join(projectRoot, 'dev/GUILayout/ssrgame/csvcfg'); // CSV配置目录
|
|
15
|
+
const mgrDir = path.join(projectRoot, 'dev/GUILayout/ssrgame/mgr'); // 管理器目录
|
|
16
|
+
const gameConfigDir = path.join(projectRoot, 'dev/scripts/game_config'); // 游戏配置目录
|
|
16
17
|
const tableMgrPath = path.join(mgrDir, 'TableMgr.lua'); // 输出文件路径
|
|
17
18
|
|
|
18
19
|
// 标记定义 - 用于识别文件中需要自动更新的区域
|
package/AutoCfg/csvcfg.js
CHANGED
|
@@ -10,8 +10,8 @@ const iconv = require('iconv-lite');
|
|
|
10
10
|
const { execSync } = require('child_process');
|
|
11
11
|
|
|
12
12
|
// ==================== 路径配置 ====================
|
|
13
|
-
const projectRoot =
|
|
14
|
-
const moduleTableRoot = path.join(
|
|
13
|
+
const projectRoot = require('../Tools/project-root')();
|
|
14
|
+
const moduleTableRoot = path.join(projectRoot, '..', 'ModuleTable');
|
|
15
15
|
|
|
16
16
|
// 源文件目录(xlsx 文件)
|
|
17
17
|
const tPath = path.join(moduleTableRoot, 'table');
|
|
@@ -20,10 +20,10 @@ const tPath = path.join(moduleTableRoot, 'table');
|
|
|
20
20
|
const toolPath = path.join(moduleTableRoot, 'tool');
|
|
21
21
|
|
|
22
22
|
// 服务端输出目录
|
|
23
|
-
const sPath = path.join(
|
|
23
|
+
const sPath = path.join(projectRoot, '..', 'MirServer/Mir200/Envir/QuestDiary/cfgcsv');
|
|
24
24
|
|
|
25
25
|
// 客户端输出目录
|
|
26
|
-
const cPath = path.join(
|
|
26
|
+
const cPath = path.join(projectRoot, 'dev/GUILayout/ssrgame/csvcfg');
|
|
27
27
|
|
|
28
28
|
// 打印路径信息
|
|
29
29
|
console.log('========================================');
|
|
@@ -40,8 +40,9 @@ try {
|
|
|
40
40
|
process.exit(1);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const
|
|
44
|
-
const
|
|
43
|
+
const projectRoot = require('../Tools/project-root')();
|
|
44
|
+
const guiExportDir = path.join(projectRoot, 'dev/GUIExport');
|
|
45
|
+
const guiLayoutDir = path.join(projectRoot, 'dev/GUILayout');
|
|
45
46
|
const author = config.author;
|
|
46
47
|
|
|
47
48
|
console.log(`[DEBUG] guiExportDir: ${guiExportDir}`);
|
package/AutoCode/A3_watcher.js
CHANGED
|
@@ -20,7 +20,8 @@ if (config.watchEnabled === false) {
|
|
|
20
20
|
process.exit(0);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const projectRoot = require('../Tools/project-root')();
|
|
24
|
+
const watchDir = path.join(projectRoot, 'dev/GUIExport');
|
|
24
25
|
const generateScript = path.join(__dirname, 'A2_generate-panel.js');
|
|
25
26
|
|
|
26
27
|
console.log(`[WATCH] Directory: ${watchDir}`);
|
|
@@ -9,9 +9,10 @@ const { execSync } = require('child_process');
|
|
|
9
9
|
const os = require('os');
|
|
10
10
|
|
|
11
11
|
// ==================== 配置 ====================
|
|
12
|
+
const projectRoot = require('../Tools/project-root')();
|
|
12
13
|
|
|
13
|
-
const bPath = path.join(
|
|
14
|
-
const ssrgameRoot = path.join(
|
|
14
|
+
const bPath = path.join(projectRoot, 'dev/GUILayout/ssrgame/net/NetMsgCfg.lua');
|
|
15
|
+
const ssrgameRoot = path.join(projectRoot, 'dev/GUILayout/ssrgame');
|
|
15
16
|
const funcDataDir = path.join(ssrgameRoot, 'funcData');
|
|
16
17
|
const mgrDir = path.join(ssrgameRoot, 'mgr');
|
|
17
18
|
|
|
@@ -9,10 +9,11 @@ const iconv = require('iconv-lite');
|
|
|
9
9
|
const svnUtils = require('../Tools/svn-utils');
|
|
10
10
|
|
|
11
11
|
// ==================== 配置 ====================
|
|
12
|
+
const projectRoot = require('../Tools/project-root')();
|
|
12
13
|
|
|
13
|
-
const NetMsgrPath = path.join(
|
|
14
|
-
const aPath = path.join(
|
|
15
|
-
const bPath = path.join(
|
|
14
|
+
const NetMsgrPath = path.join(projectRoot, '..', 'NetMsg');
|
|
15
|
+
const aPath = path.join(projectRoot, '..', 'MirServer/Mir200/Envir/QuestDiary/net/NetMsgCfg.lua');
|
|
16
|
+
const bPath = path.join(projectRoot, 'dev/GUILayout/ssrgame/net/NetMsgCfg.lua');
|
|
16
17
|
|
|
17
18
|
// 标记定义(统一管理,避免硬编码)
|
|
18
19
|
const MARKERS = {
|
package/SVNUpdate/svn_996.js
CHANGED
|
@@ -8,8 +8,9 @@ const iconv = require('iconv-lite');
|
|
|
8
8
|
const svnUtils = require('../Tools/svn-utils');
|
|
9
9
|
|
|
10
10
|
// ==================== 配置 ====================
|
|
11
|
+
const projectRoot = require('../Tools/project-root')();
|
|
11
12
|
|
|
12
|
-
const ProjecPath = path.join(
|
|
13
|
+
const ProjecPath = path.join(projectRoot, '..', 'Project');
|
|
13
14
|
|
|
14
15
|
console.log('🚀 开始执行协议同步流程...');
|
|
15
16
|
console.log('📁 当前工作目录:', __dirname);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 项目根路径查找模块
|
|
3
|
+
* 通过查找 996M2_Client.exe 或 env.json 定位项目根目录
|
|
4
|
+
*/
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
let _cachedRoot = null;
|
|
9
|
+
|
|
10
|
+
function findProjectRoot() {
|
|
11
|
+
if (_cachedRoot) return _cachedRoot;
|
|
12
|
+
|
|
13
|
+
// 优先从环境变量获取(cli.js 会设置)
|
|
14
|
+
if (process.env.M2_PROJECT_ROOT) {
|
|
15
|
+
_cachedRoot = process.env.M2_PROJECT_ROOT;
|
|
16
|
+
return _cachedRoot;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 从当前工作目录向上查找
|
|
20
|
+
let cwd = process.cwd();
|
|
21
|
+
const markers = ['996M2_Client.exe', 'env.json', 'game.dat'];
|
|
22
|
+
|
|
23
|
+
for (let i = 0; i < 6; i++) {
|
|
24
|
+
for (const marker of markers) {
|
|
25
|
+
if (fs.existsSync(path.join(cwd, marker))) {
|
|
26
|
+
_cachedRoot = cwd;
|
|
27
|
+
return _cachedRoot;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const parent = path.dirname(cwd);
|
|
31
|
+
if (parent === cwd) break;
|
|
32
|
+
cwd = parent;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 找不到则报错
|
|
36
|
+
console.error('错误: 找不到 996M2_Client 项目根目录');
|
|
37
|
+
console.error('请在 996M2_Client 项目目录下运行此命令');
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = findProjectRoot;
|
package/cli.js
CHANGED
|
@@ -24,30 +24,35 @@ if (!commands[action]) {
|
|
|
24
24
|
process.exit(0);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// 特殊处理:启动客户端需要找到项目根目录的 exe
|
|
30
|
-
if (action === '1') {
|
|
31
|
-
console.log(`🚀 执行: ${cmd.desc}`);
|
|
32
|
-
// 从当前工作目录向上查找 996M2_Client.exe
|
|
27
|
+
// 从当前工作目录向上查找项目根目录
|
|
28
|
+
function findProjectRoot() {
|
|
33
29
|
let cwd = process.cwd();
|
|
34
|
-
|
|
35
|
-
for (let i = 0; i <
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
const markers = ['996M2_Client.exe', 'env.json', 'game.dat'];
|
|
31
|
+
for (let i = 0; i < 6; i++) {
|
|
32
|
+
for (const marker of markers) {
|
|
33
|
+
if (fs.existsSync(path.join(cwd, marker))) {
|
|
34
|
+
return cwd;
|
|
35
|
+
}
|
|
40
36
|
}
|
|
41
37
|
const parent = path.dirname(cwd);
|
|
42
|
-
if (parent === cwd) break;
|
|
38
|
+
if (parent === cwd) break;
|
|
43
39
|
cwd = parent;
|
|
44
40
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const projectRoot = findProjectRoot();
|
|
45
|
+
const cmd = commands[action];
|
|
46
|
+
|
|
47
|
+
if (action === '1') {
|
|
48
|
+
// 特殊处理:启动客户端
|
|
49
|
+
if (!projectRoot) {
|
|
50
|
+
console.error('错误: 找不到 996M2_Client 项目目录');
|
|
51
|
+
console.error('请在项目目录下运行 a_6 1');
|
|
49
52
|
process.exit(1);
|
|
50
53
|
}
|
|
54
|
+
const exePath = path.join(projectRoot, '996M2_Client.exe');
|
|
55
|
+
console.log(`🚀 执行: ${cmd.desc}`);
|
|
51
56
|
console.log(`启动 996M2 客户端...`);
|
|
52
57
|
console.log(`路径: ${exePath}`);
|
|
53
58
|
exec(`start "" "${exePath}"`, (err) => {
|
|
@@ -57,10 +62,14 @@ if (action === '1') {
|
|
|
57
62
|
}
|
|
58
63
|
console.log('客户端已启动');
|
|
59
64
|
});
|
|
60
|
-
// 给异步回调一点时间
|
|
61
65
|
setTimeout(() => process.exit(0), 2000);
|
|
62
66
|
} else {
|
|
67
|
+
// 设置环境变量,让子脚本也能找到项目根目录
|
|
68
|
+
const env = { ...process.env };
|
|
69
|
+
if (projectRoot) {
|
|
70
|
+
env.M2_PROJECT_ROOT = projectRoot;
|
|
71
|
+
}
|
|
63
72
|
const batFile = path.join(__dirname, cmd.file);
|
|
64
73
|
console.log(`🚀 执行: ${cmd.desc}`);
|
|
65
|
-
execSync(`"${batFile}"`, { stdio: 'inherit', shell: true });
|
|
74
|
+
execSync(`"${batFile}"`, { stdio: 'inherit', shell: true, env });
|
|
66
75
|
}
|