Skip to content

Commit e64b143

Browse files
committed
feat: 构建产物文件名添加客户端前缀
- cfw: auto-routing.js → cfw-auto-routing.js - cvr: auto-routing.js → cvr-auto-routing.js - clash-party: auto-routing.js → cparty-auto-routing.js - global-proxy 同理 更新所有消费者引用同步新路径
1 parent 504c1ce commit e64b143

8 files changed

Lines changed: 15 additions & 9 deletions

File tree

.github/workflows/release-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: |
3535
mkdir -p dist-renamed
3636
for file in $(find dist -name "*.js"); do
37-
# 获取相对路径,例如 cfw/global-proxy.js
37+
# 获取相对路径,例如 cfw/cfw-global-proxy.js
3838
relative_path=${file#dist/}
3939
# 将 / 替换为 - 作为前缀,例如 cfw-global-proxy.js
4040
new_name=$(echo "$relative_path" | sed 's/\//-/g')

VPN-Servers/NCR-AutoClash-Server/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ async function applyAutoRouting(proxies: any[]): Promise<any> {
457457
const currentDir = path.dirname(__filename);
458458
// 从 VPN-Servers/auto-routing/ 向上两级到 parser/
459459
const projectRoot = path.resolve(currentDir, '../..');
460-
const scriptPath = path.join(projectRoot, 'dist/cvr/auto-routing.js');
460+
const scriptPath = path.join(projectRoot, 'dist/cvr/cvr-auto-routing.js');
461461

462462
// 读取编译后的脚本
463463
const scriptContent = readFileSync(scriptPath, 'utf-8');

VPN-Servers/NCR-AutoClash-Server/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if [ ! -d "node_modules" ]; then
2828
fi
2929

3030
# 检查编译后的文件是否存在
31-
if [ ! -f "../../dist/cvr/auto-routing.js" ]; then
31+
if [ ! -f "../../dist/cvr/cvr-auto-routing.js" ]; then
3232
echo "🔨 编译 CVR Auto-Routing 脚本..."
3333
cd ../..
3434
npm run build:cvr:auto

custom-rules-config/DIRECTORY_STRUCTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Mihomo AND 规则
120120
↓ (集成)
121121
src/AutoRoutingConfig.ts
122122
↓ (构建)
123-
dist/cvr/auto-routing.js
123+
dist/cvr/cvr-auto-routing.js
124124
```
125125

126126
---

docs/TEST_REPORT_3D_RULES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ npm run build:cvr:auto:custom
116116
规则数据大小: 645.37 KB
117117
尝试加载用户自定义规则: Z:\parser\custom-rules-config\user-rules.ts
118118
✅ 用户自定义规则加载成功: rules3D=5, simpleRules(prepend=0, append=0), groups=0
119-
asset cvr/auto-routing.js 697 KiB [emitted] [minimized] (name: cvr-auto-routing)
119+
asset cvr/cvr-auto-routing.js 697 KiB [emitted] [minimized] (name: cvr-auto-routing)
120120
webpack 5.105.4 compiled successfully in 1570 ms
121121
```
122122

@@ -147,7 +147,7 @@ const importPath = isWindows
147147

148148
#### 产物位置
149149
```
150-
dist/cvr/auto-routing.js
150+
dist/cvr/cvr-auto-routing.js
151151
```
152152

153153
#### 产物大小

tests/check-main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const { readFileSync } = require('fs');
33
const { join } = require('path');
44

5-
const filePath = join(__dirname, '..', 'dist', 'cvr', 'global-proxy.js');
5+
const filePath = join(__dirname, '..', 'dist', 'cvr', 'cvr-global-proxy.js');
66
const code = readFileSync(filePath, 'utf-8');
77

88
console.log('执行前 globalThis.main:', typeof globalThis.main);

tests/clash-client-host.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function loadAndExecuteBuild(
8181

8282
// 返回一个包装函数,在调用时才通过子进程执行
8383
const mainFunc = (config?: any) => {
84-
const buildPath = join(process.cwd(), 'dist', client, `${mode}.js`);
84+
const buildPath = join(process.cwd(), 'dist', client, `${client}-${mode}.js`);
8585
const tempFile = join(process.cwd(), 'tests', '.temp-test.js');
8686

8787
try {

webpack.base.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ if (args['user-rules']) {
9696
console.log('💡 未指定用户自定义规则文件,使用 --user-rules 参数加载');
9797
}
9898

99+
// 获取客户端的短前缀用于文件名
100+
function clientPrefix(client: string): string {
101+
return client === 'clash-party' ? 'cparty' : client;
102+
}
103+
99104
const conf: Configuration = {
100105
mode: 'production',
101106
entry: {
@@ -105,7 +110,8 @@ const conf: Configuration = {
105110
: clientArg === 'cvr'
106111
? './src/clients/clash-verge/main.ts'
107112
: './src/clients/clash-party/main.ts',
108-
filename: `${clientArg}/${modeArg}.js`,
113+
// 为不同客户端生成可区分的文件前缀
114+
filename: `${clientArg}/${clientPrefix(clientArg)}-${modeArg}.js`,
109115
// CFW 需要 commonjs2 导出,CVR 和 Clash Party 不配置 library,直接在源码中导出
110116
...(clientArg === 'cfw' ? { library: { type: 'commonjs2' } } : {})
111117
}

0 commit comments

Comments
 (0)