@yangrunchi/a_6 1.0.0

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.
@@ -0,0 +1,98 @@
1
+ // -- 作者: 杨润池
2
+ // -- 日期: 2025年10月23日
3
+ // -- 版本: 2.3
4
+ // -- 描述: 协议自动更新(只负责同步,不生成类)
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+ const iconv = require('iconv-lite');
9
+ const svnUtils = require('../Tools/svn-utils');
10
+
11
+ // ==================== 配置 ====================
12
+
13
+ const NetMsgrPath = path.join(__dirname, '../../../../NetMsg');
14
+ const aPath = path.join(__dirname, '../../../../MirServer/Mir200/Envir/QuestDiary/net/', 'NetMsgCfg.lua');
15
+ const bPath = path.join(__dirname, '../../../dev/GUILayout/ssrgame/net', 'NetMsgCfg.lua');
16
+
17
+ // 标记定义(统一管理,避免硬编码)
18
+ const MARKERS = {
19
+ NetStart: '--------------------------------前端自动生成开始 这是标签 ↓↓↓ start---------------------------------------',
20
+ NetEnd: '--------------------------------前端自动生结束 这是标签 ↓↓↓ end---------------------------------------',
21
+ };
22
+
23
+ console.log('🚀 开始执行协议同步流程...');
24
+ console.log('📁 当前工作目录:', __dirname);
25
+
26
+ // ==================== 主流程 ====================
27
+
28
+ // 1. 更新 SVN
29
+ console.log('\n=== SVN 更新阶段 ===');
30
+ svnUtils.runCommand(NetMsgrPath, '更新 NetMsg 目录');
31
+ svnUtils.runCommand(aPath, '更新后端 NetMsgCfg.lua');
32
+ svnUtils.runCommand(bPath, '更新前端 NetMsgCfg.lua');
33
+
34
+ // 2. 检查文件是否存在
35
+ console.log('\n=== 文件检查阶段 ===');
36
+ if (!fs.existsSync(aPath)) {
37
+ console.log('❌ 服务器端 NetMsgCfg.lua 文件不存在');
38
+ process.exit(1);
39
+ }
40
+ if (!fs.existsSync(bPath)) {
41
+ console.log('❌ 客户端 NetMsgCfg.lua 文件不存在');
42
+ process.exit(1);
43
+ }
44
+ console.log('✅ 文件检查通过');
45
+
46
+ // 3. 执行同步
47
+ console.log('\n=== 协议同步阶段 ===');
48
+ try {
49
+ const aData = fs.readFileSync(aPath);
50
+ const aContent = iconv.decode(aData, 'gb2312');
51
+ const bContent = fs.readFileSync(bPath, 'utf8');
52
+
53
+ const pattern = new RegExp(`${MARKERS.NetStart}[\\s\\S]*?${MARKERS.NetEnd}`, 'g');
54
+ console.log(`🔍 正则表达式: ${pattern}`);
55
+ console.log(`🔍 查找起始: ${MARKERS.NetStart}`);
56
+ console.log(`🔍 查找结束: ${MARKERS.NetEnd}`);
57
+
58
+ const match = aContent.match(pattern);
59
+
60
+ if (match) {
61
+ const newBContent = bContent.replace(pattern, match[0]);
62
+ fs.writeFileSync(bPath, newBContent, 'utf8');
63
+ console.log('✅ 协议同步完成:服务器 → 客户端');
64
+
65
+ // 4. 提交前端更改到SVN
66
+ console.log('\n=== SVN 提交阶段 ===');
67
+ const commitSuccess = svnUtils.runCommit(bPath, '提交客户端 NetMsgCfg.lua 到 SVN');
68
+
69
+ if (commitSuccess) {
70
+ console.log('✅ 协议同步完成,已提交到SVN');
71
+
72
+ // 5. 调用生成器生成 funcData
73
+ console.log('\n=== 调用生成器 ===');
74
+ const generatorPath = path.join(__dirname, 'A5_generate-funcdata.js');
75
+ if (fs.existsSync(generatorPath)) {
76
+ const { exec } = require('child_process');
77
+ exec(`node "${generatorPath}"`, (error, stdout, stderr) => {
78
+ if (error) {
79
+ console.error(`❌ 生成器执行失败: ${error.message}`);
80
+ return;
81
+ }
82
+ if (stdout) console.log(stdout);
83
+ if (stderr) console.error(stderr);
84
+ });
85
+ } else {
86
+ console.log('⚠️ 未找到生成器文件,请手动运行 A5_generate-funcdata.js');
87
+ }
88
+ } else {
89
+ console.log('⚠️ 同步完成,但SVN提交失败,请手动提交');
90
+ }
91
+
92
+ } else {
93
+ console.log('❌ 在服务器端文件中未找到匹配内容');
94
+ }
95
+ } catch (error) {
96
+ console.log('❌ 发生错误:', error.message);
97
+ console.error(error.stack);
98
+ }
@@ -0,0 +1,20 @@
1
+ // -- 作者: 杨润池
2
+ // -- 日期: 2026年5月12日
3
+ // -- 版本: 2.3
4
+ // -- 描述: 更新VN
5
+
6
+ const path = require('path');
7
+ const iconv = require('iconv-lite');
8
+ const svnUtils = require('../Tools/svn-utils');
9
+
10
+ // ==================== 配置 ====================
11
+
12
+ const ProjecPath = path.join(__dirname, '../../../../../Project');
13
+
14
+ console.log('🚀 开始执行协议同步流程...');
15
+ console.log('📁 当前工作目录:', __dirname);
16
+
17
+
18
+ // 1. 更新 SVN
19
+ console.log('\n=== SVN 更新阶段 ===');
20
+ svnUtils.runCommand(ProjecPath, '更新 Project 目录');
@@ -0,0 +1,117 @@
1
+ // -- 作者: 杨润池
2
+ // -- 日期: 2025年10月25日
3
+ // -- 版本: 2.0
4
+ // -- 描述: 添加快捷键
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+
9
+ function installProjectKeys() {
10
+ try {
11
+ // 1. 检查项目配置文件是否存在
12
+ const projectKeysPath = path.join(__dirname, 'project-keys.json');
13
+ if (!fs.existsSync(projectKeysPath)) {
14
+ console.log('❌ 项目快捷键配置文件不存在:', projectKeysPath);
15
+ console.log('💡 请创建 .vscode/project-keys.json 文件');
16
+ return false;
17
+ }
18
+
19
+ // 2. 读取项目配置
20
+ let projectKeys;
21
+ try {
22
+ const projectKeysContent = fs.readFileSync(projectKeysPath, 'utf8');
23
+ projectKeys = JSON.parse(projectKeysContent);
24
+ } catch (error) {
25
+ console.log('❌ 读取项目快捷键配置失败:', error.message);
26
+ return false;
27
+ }
28
+
29
+ // 3. 确定全局快捷键文件路径
30
+ const globalKeysPath = path.join(
31
+ process.env.APPDATA ||
32
+ (process.platform === 'darwin' ? process.env.HOME + '/Library/Application Support' : process.env.HOME + '/.config'),
33
+ 'Code/User/keybindings.json'
34
+ );
35
+
36
+ // 4. 确保目录存在
37
+ const globalKeysDir = path.dirname(globalKeysPath);
38
+ if (!fs.existsSync(globalKeysDir)) {
39
+ fs.mkdirSync(globalKeysDir, { recursive: true });
40
+ }
41
+
42
+ // 5. 读取或创建全局配置
43
+ let globalKeys = [];
44
+ if (fs.existsSync(globalKeysPath)) {
45
+ try {
46
+ const globalKeysContent = fs.readFileSync(globalKeysPath, 'utf8');
47
+ globalKeys = JSON.parse(globalKeysContent);
48
+ if (!Array.isArray(globalKeys)) {
49
+ console.log('⚠️ 全局快捷键配置不是数组格式,重置为数组');
50
+ globalKeys = [];
51
+ }
52
+ } catch (error) {
53
+ console.log('⚠️ 读取全局快捷键配置失败,创建新配置:', error.message);
54
+ globalKeys = [];
55
+ }
56
+ }
57
+
58
+ // 6. 获取项目名称用于条件
59
+ const projectName = path.basename(process.cwd());
60
+ console.log(`📁 项目名称: ${projectName}`);
61
+
62
+ // 7. 移除已存在的本项目快捷键(避免重复)
63
+ const existingKeysCount = globalKeys.length;
64
+ globalKeys = globalKeys.filter(item =>
65
+ !(item.when && item.when.includes(projectName))
66
+ );
67
+ const removedCount = existingKeysCount - globalKeys.length;
68
+ if (removedCount > 0) {
69
+ console.log(`🗑️ 移除了 ${removedCount} 个已存在的项目快捷键`);
70
+ }
71
+
72
+ // 8. 添加新的项目快捷键
73
+ if (projectKeys.shortcuts && Array.isArray(projectKeys.shortcuts)) {
74
+ projectKeys.shortcuts.forEach((shortcut, index) => {
75
+ // 深拷贝避免修改原对象
76
+ const newShortcut = JSON.parse(JSON.stringify(shortcut));
77
+
78
+ // 添加条件限制
79
+ if (!newShortcut.when) {
80
+ newShortcut.when = `resourcePath =~ /${projectName}/`;
81
+ }
82
+
83
+ globalKeys.push(newShortcut);
84
+ console.log(`✅ 添加快捷键 ${index + 1}: ${newShortcut.key} -> ${newShortcut.command}`);
85
+ });
86
+ } else {
87
+ console.log('❌ 项目配置中缺少 shortcuts 数组');
88
+ return false;
89
+ }
90
+
91
+ // 9. 写回全局配置
92
+ try {
93
+ fs.writeFileSync(globalKeysPath, JSON.stringify(globalKeys, null, 4));
94
+ console.log(`🎉 项目快捷键安装成功! 共添加 ${projectKeys.shortcuts.length} 个快捷键`);
95
+ console.log(`📝 全局配置文件: ${globalKeysPath}`);
96
+ return true;
97
+ } catch (error) {
98
+ console.log('❌ 写入全局快捷键配置失败:', error.message);
99
+ return false;
100
+ }
101
+
102
+ } catch (error) {
103
+ console.log('💥 安装过程中发生未知错误:', error.message);
104
+ return false;
105
+ }
106
+ }
107
+
108
+ // 执行安装
109
+ if (require.main === module) {
110
+ installProjectKeys();
111
+ }
112
+
113
+ module.exports = installProjectKeys;
114
+
115
+ //Preferences: Open Keyboard Shortcuts
116
+
117
+ //node a_tools/a_node/Tools/install-keys.js
@@ -0,0 +1,24 @@
1
+ {
2
+ "shortcuts": [
3
+ {
4
+ "key": "ctrl+f1",
5
+ "command": "workbench.action.tasks.runTask",
6
+ "args": "Run AutoCode"
7
+ },
8
+ {
9
+ "key": "ctrl+f2",
10
+ "command": "workbench.action.tasks.runTask",
11
+ "args": "Run Table Client"
12
+ },
13
+ {
14
+ "key": "ctrl+f3",
15
+ "command": "workbench.action.tasks.runTask",
16
+ "args": "Run NetMsg Sync"
17
+ },
18
+ {
19
+ "key": "ctrl+f6",
20
+ "command": "workbench.action.tasks.runTask",
21
+ "args": "Run 996M2 Client"
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,126 @@
1
+ // -- 作者: 杨润池
2
+ // -- 日期: 2025年10月25日
3
+ // -- 版本: 2.0
4
+ // -- 描述: SVN 工具
5
+
6
+ const fs = require('fs');
7
+ const { execSync, spawnSync } = require('child_process');
8
+ // 详细检测 SVN 是否可用
9
+ function checkSvnEnvironment() {
10
+ const pathEnv = process.env.PATH || '';
11
+
12
+ // 尝试多种方式检测 SVN
13
+ const testCommands = [
14
+ 'svn --version',
15
+ '"C:\\Program Files\\TortoiseSVN\\bin\\svn.exe" --version',
16
+ '"C:\\Program Files (x86)\\TortoiseSVN\\bin\\svn.exe" --version'
17
+ ];
18
+
19
+ for (const cmd of testCommands) {
20
+ try {
21
+ execSync(cmd, { stdio: 'ignore' });
22
+ console.log(`✅ SVN 可用: ${cmd}`);
23
+ return true;
24
+ } catch (error) {
25
+ console.log(`❌ SVN 不可用: ${cmd}`);
26
+ }
27
+ }
28
+
29
+ console.log('💡 建议: 请确保已安装 TortoiseSVN 并勾选"命令行客户端工具"');
30
+ return false;
31
+ }
32
+
33
+ // 检测 SVN 是否可用
34
+ function isSvnAvailable() {
35
+ return checkSvnEnvironment();
36
+ }
37
+
38
+ function runCommand(svnPath, description) {
39
+ if (!isSvnAvailable()) {
40
+ console.log(`⚠️ ${description}跳过: SVN环境问题`);
41
+ return false;
42
+ }
43
+
44
+ try {
45
+ const result = spawnSync('svn', ['update', svnPath], {
46
+ encoding: 'utf8',
47
+ stdio: 'inherit'
48
+ });
49
+
50
+ if (result.status === 0) {
51
+ console.log(`✅ ${description}成功`);
52
+ return true;
53
+ } else {
54
+ console.log(`❌ ${description}失败: SVN命令执行出错 (状态码: ${result.status})`);
55
+ return false;
56
+ }
57
+ } catch (error) {
58
+ console.log(`❌ ${description}失败: ${error.message}`);
59
+ return false;
60
+ }
61
+ }
62
+
63
+ function runCommit(filePaths, description) {
64
+ if (!isSvnAvailable()) {
65
+ console.log(`⚠️ ${description}跳过: SVN环境问题`);
66
+ return false;
67
+ }
68
+
69
+ try {
70
+ // 如果传入的是数组,转换为多个参数
71
+ const paths = Array.isArray(filePaths) ? filePaths : [filePaths];
72
+ const args = ['commit', ...paths, '-m', description];
73
+
74
+ const result = spawnSync('svn', args, {
75
+ encoding: 'buffer',
76
+ env: { ...process.env, LANG: 'zh_CN.UTF-8' },
77
+ stdio: 'inherit'
78
+ });
79
+
80
+ if (result.status === 0) {
81
+ console.log(`✅ ${description}成功`);
82
+ return true;
83
+ } else {
84
+ console.log(`❌ ${description}失败: SVN命令执行出错 (状态码: ${result.status})`);
85
+ return false;
86
+ }
87
+ } catch (error) {
88
+ console.log(`❌ ${description}失败: ${error.message}`);
89
+ return false;
90
+ }
91
+ }
92
+
93
+ // 清理目录函数
94
+ function cleanDirectory(targetPath) {
95
+ try {
96
+ if (!fs.existsSync(targetPath)) {
97
+ console.log(`ℹ️ 目录不存在: ${targetPath}`);
98
+ return true;
99
+ }
100
+
101
+ // console.log(`🗑️ 清理目录: ${targetPath}`);
102
+
103
+ // 使用 rd /s /q 命令强制删除目录(Windows)
104
+ if (process.platform === 'win32') {
105
+ execSync(`rd /s /q "${targetPath}"`, { stdio: 'inherit' });
106
+ } else {
107
+ // Linux/macOS 使用 rm -rf
108
+ execSync(`rm -rf "${targetPath}"`, { stdio: 'inherit' });
109
+ }
110
+
111
+ console.log(`✅ 目录清理成功: ${targetPath}`);
112
+ return true;
113
+ } catch (error) {
114
+ console.log(`❌ 目录清理失败: ${targetPath} - ${error.message}`);
115
+ return false;
116
+ }
117
+ }
118
+
119
+ // 导出所有函数
120
+ module.exports = {
121
+ checkSvnEnvironment,
122
+ isSvnAvailable,
123
+ runCommand,
124
+ runCommit,
125
+ cleanDirectory
126
+ };
@@ -0,0 +1,65 @@
1
+ // -- 作者: 杨润池
2
+ // -- 日期: 2025年10月25日
3
+ // -- 版本: 2.0
4
+ // -- 描述: 删除快捷键
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+
9
+ function uninstallProjectKeys() {
10
+ try {
11
+ // 确定全局快捷键文件路径
12
+ const globalKeysPath = path.join(
13
+ process.env.APPDATA ||
14
+ (process.platform === 'darwin' ? process.env.HOME + '/Library/Application Support' : process.env.HOME + '/.config'),
15
+ 'Code/User/keybindings.json'
16
+ );
17
+
18
+ if (!fs.existsSync(globalKeysPath)) {
19
+ console.log('ℹ️ 全局快捷键配置文件不存在,无需卸载');
20
+ return true;
21
+ }
22
+
23
+ // 读取全局配置
24
+ let globalKeys = [];
25
+ try {
26
+ const globalKeysContent = fs.readFileSync(globalKeysPath, 'utf8');
27
+ globalKeys = JSON.parse(globalKeysContent);
28
+ if (!Array.isArray(globalKeys)) {
29
+ console.log('⚠️ 全局快捷键配置不是数组格式,重置为数组');
30
+ globalKeys = [];
31
+ }
32
+ } catch (error) {
33
+ console.log('❌ 读取全局快捷键配置失败:', error.message);
34
+ return false;
35
+ }
36
+
37
+ // 获取项目名称
38
+ const projectName = path.basename(process.cwd());
39
+
40
+ // 移除本项目相关的快捷键
41
+ const initialCount = globalKeys.length;
42
+ globalKeys = globalKeys.filter(item =>
43
+ !(item.when && item.when.includes(projectName))
44
+ );
45
+ const removedCount = initialCount - globalKeys.length;
46
+
47
+ // 写回全局配置
48
+ fs.writeFileSync(globalKeysPath, JSON.stringify(globalKeys, null, 4));
49
+ console.log(`🗑️ 卸载完成! 移除了 ${removedCount} 个项目快捷键`);
50
+ return true;
51
+
52
+ } catch (error) {
53
+ console.log('💥 卸载过程中发生错误:', error.message);
54
+ return false;
55
+ }
56
+ }
57
+
58
+ // 执行卸载
59
+ if (require.main === module) {
60
+ uninstallProjectKeys();
61
+ }
62
+
63
+ module.exports = uninstallProjectKeys;
64
+
65
+ //node a_tools/a_node/Tools/uninstall-keys.js