@yangrunchi/a_6 1.1.0 → 1.1.1
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.
|
@@ -78,7 +78,8 @@ try {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// 自动获取 SVN 账户名(覆盖 config.author)
|
|
81
|
-
|
|
81
|
+
const projectRootForAuthor = path.resolve(__dirname, '../../..');
|
|
82
|
+
config.author = getSVNAuthor(projectRootForAuthor, config.author);
|
|
82
83
|
console.log('✅ 已加载配置, 作者:', config.author);
|
|
83
84
|
|
|
84
85
|
console.log('🚀 开始生成 funcData 类...');
|
|
@@ -132,12 +133,10 @@ function commitToSvn(filePath, action, responseCount = 0, requestCount = 0) {
|
|
|
132
133
|
|
|
133
134
|
try {
|
|
134
135
|
const fileName = path.basename(filePath);
|
|
135
|
-
// 使用模块级 projectRoot 而非 __dirname 推算(npm 全局安装时 __dirname 在 node_modules 下)
|
|
136
|
-
const projectRootForSvn = projectRoot;
|
|
137
136
|
|
|
138
137
|
let isVersioned = false;
|
|
139
138
|
try {
|
|
140
|
-
execSync(`svn info "${filePath}"`, { stdio: 'ignore'
|
|
139
|
+
execSync(`svn info "${filePath}"`, { stdio: 'ignore' });
|
|
141
140
|
isVersioned = true;
|
|
142
141
|
} catch (err) {
|
|
143
142
|
isVersioned = false;
|
|
@@ -145,17 +144,17 @@ function commitToSvn(filePath, action, responseCount = 0, requestCount = 0) {
|
|
|
145
144
|
|
|
146
145
|
if (!isVersioned) {
|
|
147
146
|
console.log(` 📝 添加新文件: ${fileName}`);
|
|
148
|
-
execSync(`svn add "${filePath}"`, { stdio: 'ignore'
|
|
147
|
+
execSync(`svn add "${filePath}"`, { stdio: 'ignore' });
|
|
149
148
|
}
|
|
150
149
|
|
|
151
|
-
const statusOutput = execSync(`svn status "${filePath}"`, { encoding: 'utf8'
|
|
150
|
+
const statusOutput = execSync(`svn status "${filePath}"`, { encoding: 'utf8' });
|
|
152
151
|
const needCommit = statusOutput.trim().length > 0 &&
|
|
153
152
|
(statusOutput.trim().startsWith('M') || statusOutput.trim().startsWith('A'));
|
|
154
153
|
|
|
155
154
|
if (needCommit) {
|
|
156
155
|
const commitMsg = getCommitMessage(action, fileName, responseCount, requestCount);
|
|
157
156
|
console.log(` 📤 提交: ${fileName} - ${commitMsg}`);
|
|
158
|
-
execSync(`svn commit "${filePath}" -m "${commitMsg}"`, { stdio: 'ignore'
|
|
157
|
+
execSync(`svn commit "${filePath}" -m "${commitMsg}"`, { stdio: 'ignore' });
|
|
159
158
|
return true;
|
|
160
159
|
}
|
|
161
160
|
return false;
|
package/Tools/svn-utils.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
// -- 描述: SVN 工具函数集
|
|
5
5
|
|
|
6
6
|
const fs = require('fs');
|
|
7
|
-
const path = require('path');
|
|
8
7
|
const { execSync, spawnSync } = require('child_process');
|
|
9
8
|
|
|
10
9
|
// 详细检测 SVN 是否可用
|
|
@@ -37,20 +36,6 @@ function isSvnAvailable() {
|
|
|
37
36
|
return checkSvnEnvironment();
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
// 从给定路径向上查找包含 .svn 的目录(包含自身)
|
|
41
|
-
function findSvnRoot(startPath) {
|
|
42
|
-
let dir = startPath;
|
|
43
|
-
while (dir) {
|
|
44
|
-
if (fs.existsSync(path.join(dir, '.svn'))) {
|
|
45
|
-
return dir;
|
|
46
|
-
}
|
|
47
|
-
const parent = path.dirname(dir);
|
|
48
|
-
if (parent === dir) break;
|
|
49
|
-
dir = parent;
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
39
|
function runCommand(svnPath, description) {
|
|
55
40
|
if (!isSvnAvailable()) {
|
|
56
41
|
console.log(`⚠️ ${description}跳过: SVN环境问题`);
|
|
@@ -58,16 +43,9 @@ function runCommand(svnPath, description) {
|
|
|
58
43
|
}
|
|
59
44
|
|
|
60
45
|
try {
|
|
61
|
-
// 从 svnPath 向上查找 .svn,找不到则从 M2_PROJECT_ROOT 查找
|
|
62
|
-
let projectRoot = findSvnRoot(svnPath);
|
|
63
|
-
if (!projectRoot && process.env.M2_PROJECT_ROOT) {
|
|
64
|
-
projectRoot = findSvnRoot(process.env.M2_PROJECT_ROOT);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
46
|
const result = spawnSync('svn', ['update', svnPath], {
|
|
68
47
|
encoding: 'utf8',
|
|
69
|
-
stdio: 'inherit'
|
|
70
|
-
cwd: projectRoot || process.cwd()
|
|
48
|
+
stdio: 'inherit'
|
|
71
49
|
});
|
|
72
50
|
|
|
73
51
|
if (result.status === 0) {
|
|
@@ -92,20 +70,12 @@ function runCommit(filePaths, description) {
|
|
|
92
70
|
try {
|
|
93
71
|
// 如果传入的是数组,转换为多个参数
|
|
94
72
|
const paths = Array.isArray(filePaths) ? filePaths : [filePaths];
|
|
95
|
-
|
|
96
|
-
// 从文件路径向上查找 .svn,找不到则从 M2_PROJECT_ROOT 查找
|
|
97
|
-
let projectRoot = findSvnRoot(paths[0]);
|
|
98
|
-
if (!projectRoot && process.env.M2_PROJECT_ROOT) {
|
|
99
|
-
projectRoot = findSvnRoot(process.env.M2_PROJECT_ROOT);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
73
|
const args = ['commit', ...paths, '-m', description];
|
|
103
74
|
|
|
104
75
|
const result = spawnSync('svn', args, {
|
|
105
76
|
encoding: 'buffer',
|
|
106
77
|
env: { ...process.env, LANG: 'zh_CN.UTF-8' },
|
|
107
|
-
stdio: 'inherit'
|
|
108
|
-
cwd: projectRoot || process.cwd()
|
|
78
|
+
stdio: 'inherit'
|
|
109
79
|
});
|
|
110
80
|
|
|
111
81
|
if (result.status === 0) {
|
|
@@ -153,13 +123,9 @@ function cleanDirectory(targetPath) {
|
|
|
153
123
|
*/
|
|
154
124
|
function getSVNAuthor(projectRoot, fallbackAuthor) {
|
|
155
125
|
try {
|
|
156
|
-
// 找到 SVN 工作目录作为 cwd
|
|
157
|
-
const svnCwd = findSvnRoot(projectRoot) || process.env.M2_PROJECT_ROOT || projectRoot;
|
|
158
|
-
|
|
159
126
|
// 获取当前仓库的地址(用于匹配 svn auth 中的 realm)
|
|
160
127
|
const reposUrl = execSync(`svn info --show-item=repos-root-url "${projectRoot}"`, {
|
|
161
|
-
encoding: 'utf-8'
|
|
162
|
-
cwd: svnCwd
|
|
128
|
+
encoding: 'utf-8'
|
|
163
129
|
}).trim();
|
|
164
130
|
|
|
165
131
|
// 提取仓库主机地址(如 "192.168.13.64"),兼容有无端口号、不同协议
|
|
@@ -167,8 +133,7 @@ function getSVNAuthor(projectRoot, fallbackAuthor) {
|
|
|
167
133
|
|
|
168
134
|
// 解析 svn auth 输出,匹配当前仓库的用户名
|
|
169
135
|
const authOutput = execSync('svn auth --non-interactive', {
|
|
170
|
-
encoding: 'utf-8'
|
|
171
|
-
cwd: svnCwd
|
|
136
|
+
encoding: 'utf-8'
|
|
172
137
|
});
|
|
173
138
|
|
|
174
139
|
// 按分隔线分割每个认证条目
|