@cloudbase/cli 2.8.20 → 2.8.23
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/bin/tcb.js +11 -7
- package/dist/standalone/cli.js +67 -38
- package/lib/commands/ai/index.js +21 -7
- package/lib/commands/common.js +9 -5
- package/lib/utils/report.js +20 -15
- package/package.json +1 -1
- package/specs/ssl-fix/design.md +93 -0
- package/specs/ssl-fix/requirements.md +47 -0
- package/specs/ssl-fix/tasks.md +65 -0
- package/build/entries/ccr-main.js +0 -15
- package/build/entries/cli-main.js +0 -36
- package/build/launchers/ccr +0 -32
- package/build/launchers/cloudbase +0 -32
- package/build/launchers/cloudbase-mcp +0 -32
- package/build/launchers/tcb +0 -33
- package/build/patches/ccr-cli-patch.js +0 -40
- package/build/shims/cloud-api-pkg.cjs +0 -6
- package/build/shims/framework-core-pkg.cjs +0 -6
- package/build/shims/functions-framework-pkg.cjs +0 -6
- package/build/shims/generic-pkg.cjs +0 -9
- package/build/shims/hexoid.cjs +0 -14
- package/build/shims/iac-core-pkg.cjs +0 -6
- package/build/shims/lowcode-pkg.cjs +0 -8
- package/build/shims/manager-node-pkg.cjs +0 -6
- package/build/shims/prettier.cjs +0 -11
- package/build/shims/read-pkg-up.cjs +0 -21
- package/build/shims/toolbox-pkg.cjs +0 -6
- package/build/shims/update-notifier.cjs +0 -9
- package/build/webpack/ccr.cjs +0 -85
- package/build/webpack/cli.cjs +0 -114
package/bin/tcb.js
CHANGED
|
@@ -148,13 +148,17 @@ async function main() {
|
|
|
148
148
|
* 处理异常
|
|
149
149
|
*/
|
|
150
150
|
async function errorHandler(err) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
151
|
+
try {
|
|
152
|
+
await beaconAction.report('tcb_cli_error', {
|
|
153
|
+
name: err.name,
|
|
154
|
+
message: err.message,
|
|
155
|
+
stack: err.stack,
|
|
156
|
+
requestId: err.requestId,
|
|
157
|
+
canIgnore: 'false'
|
|
158
|
+
})
|
|
159
|
+
} catch (error) {
|
|
160
|
+
// 静默处理上报错误,不影响主程序运行
|
|
161
|
+
}
|
|
158
162
|
process.emit('tcbError')
|
|
159
163
|
const stackIngoreErrors = ['TencentCloudSDKHttpException', 'CloudBaseError']
|
|
160
164
|
// 忽略自定义错误的错误栈
|
package/dist/standalone/cli.js
CHANGED
|
@@ -155,13 +155,17 @@ async function main() {
|
|
|
155
155
|
* 处理异常
|
|
156
156
|
*/
|
|
157
157
|
async function errorHandler(err) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
try {
|
|
159
|
+
await beaconAction.report('tcb_cli_error', {
|
|
160
|
+
name: err.name,
|
|
161
|
+
message: err.message,
|
|
162
|
+
stack: err.stack,
|
|
163
|
+
requestId: err.requestId,
|
|
164
|
+
canIgnore: 'false'
|
|
165
|
+
})
|
|
166
|
+
} catch (error) {
|
|
167
|
+
// 静默处理上报错误,不影响主程序运行
|
|
168
|
+
}
|
|
165
169
|
process.emit('tcbError')
|
|
166
170
|
const stackIngoreErrors = ['TencentCloudSDKHttpException', 'CloudBaseError']
|
|
167
171
|
// 忽略自定义错误的错误栈
|
|
@@ -313,9 +317,11 @@ async function main() {
|
|
|
313
317
|
updateCheckInterval: CheckInterval
|
|
314
318
|
})
|
|
315
319
|
|
|
316
|
-
notifier.
|
|
317
|
-
|
|
318
|
-
|
|
320
|
+
if (notifier.update) {
|
|
321
|
+
console.log('\n发现新版本:' + notifier.update.latest)
|
|
322
|
+
console.log('当前版本:' + notifier.update.current)
|
|
323
|
+
console.log('请参考升级文档:https://docs.cloudbase.net/cli-v1/install\n')
|
|
324
|
+
}
|
|
319
325
|
}
|
|
320
326
|
|
|
321
327
|
if (__webpack_require__.c[__webpack_require__.s] === module) {
|
|
@@ -997,16 +1003,30 @@ AICommand = __decorate([
|
|
|
997
1003
|
], AICommand);
|
|
998
1004
|
exports.AICommand = AICommand;
|
|
999
1005
|
function reportAIUsage(agent, hasEnvId, subCommand) {
|
|
1000
|
-
return
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1006
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1007
|
+
try {
|
|
1008
|
+
return yield report_1.beaconAction.report('ai_command_usage', {
|
|
1009
|
+
agent,
|
|
1010
|
+
hasEnvId,
|
|
1011
|
+
subCommand
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
catch (error) {
|
|
1015
|
+
return null;
|
|
1016
|
+
}
|
|
1004
1017
|
});
|
|
1005
1018
|
}
|
|
1006
1019
|
function reportAIError(agent, error) {
|
|
1007
|
-
return
|
|
1008
|
-
|
|
1009
|
-
|
|
1020
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1021
|
+
try {
|
|
1022
|
+
return yield report_1.beaconAction.report('ai_command_error', {
|
|
1023
|
+
agent,
|
|
1024
|
+
error
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
catch (error) {
|
|
1028
|
+
return null;
|
|
1029
|
+
}
|
|
1010
1030
|
});
|
|
1011
1031
|
}
|
|
1012
1032
|
|
|
@@ -2656,11 +2676,15 @@ class Command extends events_1.EventEmitter {
|
|
|
2656
2676
|
login_uin: loginState === null || loginState === void 0 ? void 0 : loginState['uin'],
|
|
2657
2677
|
envId: envId || (loginState === null || loginState === void 0 ? void 0 : loginState['envId'])
|
|
2658
2678
|
});
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2679
|
+
try {
|
|
2680
|
+
yield report_1.beaconAction.report('tcb_cli_exec_command', {
|
|
2681
|
+
cmd,
|
|
2682
|
+
childCmd,
|
|
2683
|
+
desc
|
|
2684
|
+
});
|
|
2685
|
+
}
|
|
2686
|
+
catch (error) {
|
|
2687
|
+
}
|
|
2664
2688
|
const ctx = {
|
|
2665
2689
|
cmd,
|
|
2666
2690
|
envId,
|
|
@@ -23749,21 +23773,26 @@ class BeaconAction {
|
|
|
23749
23773
|
report(eventCode, eventData = {}) {
|
|
23750
23774
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23751
23775
|
const now = Date.now();
|
|
23752
|
-
|
|
23753
|
-
|
|
23754
|
-
|
|
23755
|
-
|
|
23756
|
-
|
|
23757
|
-
|
|
23758
|
-
|
|
23759
|
-
|
|
23760
|
-
|
|
23761
|
-
|
|
23762
|
-
|
|
23763
|
-
|
|
23764
|
-
|
|
23765
|
-
|
|
23766
|
-
|
|
23776
|
+
try {
|
|
23777
|
+
return yield (0, net_1.postFetch)('https://otheve.beacon.qq.com/analytics/v2_upload', {
|
|
23778
|
+
appVersion: '',
|
|
23779
|
+
sdkId: 'js',
|
|
23780
|
+
sdkVersion: '4.5.14-web',
|
|
23781
|
+
mainAppKey: '0WEB0AD0GM4PUUU1',
|
|
23782
|
+
platformId: 3,
|
|
23783
|
+
common: Object.assign({ A2: this.deviceId, A101: this.userAgent, from: 'tcb-cli', xDeployEnv: "production" }, this.additionalParams),
|
|
23784
|
+
events: [
|
|
23785
|
+
{
|
|
23786
|
+
eventCode,
|
|
23787
|
+
eventTime: String(now),
|
|
23788
|
+
mapValue: Object.assign({}, eventData)
|
|
23789
|
+
}
|
|
23790
|
+
]
|
|
23791
|
+
});
|
|
23792
|
+
}
|
|
23793
|
+
catch (error) {
|
|
23794
|
+
return null;
|
|
23795
|
+
}
|
|
23767
23796
|
});
|
|
23768
23797
|
}
|
|
23769
23798
|
addAdditionalParams(params) {
|
|
@@ -617770,7 +617799,7 @@ module.exports = {"version":"3.13.1"};
|
|
|
617770
617799
|
/***/ ((module) => {
|
|
617771
617800
|
|
|
617772
617801
|
"use strict";
|
|
617773
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.8.
|
|
617802
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.8.22","description":"cli tool for cloudbase","main":"lib/index.js","scripts":{"build":"rimraf lib types && tsc --resolveJsonModule && cpx \\"src/**/*.html\\" lib","watch":"rimraf lib types && tsc -w","dev":"rimraf lib types && cpx \\"src/**/*.html\\" lib && tsc -w","eslint":"eslint \\"./**/*.ts\\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000","tsc":"tsc","pkg":"pkg ./bin/cloudbase.js --out-path ./pkg","postinstall":"node ./post-install.js || exit 0 && patch-package","prepublishOnly":"npm run build","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs","package:darwin-arm64":"OS=darwin ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:darwin-x64":"OS=darwin ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-arm64":"OS=linux ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-x64":"OS=linux ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:all":"bash build/scripts/build-all.sh","node:fetch:one":"node -e \\"require(\'child_process\').execSync(\'bash build/scripts/fetch-node.sh\',{stdio:\'inherit\'})\\"","node:fetch:all":"NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh --all","node:fetch:win-x64":"OS=windows ARCH=x64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","node:fetch:win-arm64":"OS=windows ARCH=arm64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","package:windows-x64":"OS=windows ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-arm64":"OS=windows ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-all":"npm run -s node:fetch:win-x64 && npm run -s node:fetch:win-arm64 && npm run -s package:windows-x64 && npm run -s package:windows-arm64","out:prune":"bash build/scripts/prune-out.sh"},"repository":{"type":"git","url":"https://github.com/TencentCloudBase/cloud-base-cli.git"},"bin":{"cloudbase":"bin/cloudbase.js","cloudbase-mcp":"bin/cloudbase-mcp.cjs","tcb":"bin/tcb.js","ccr":"bin/ccr.js"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^1.8.32","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.11","@cloudbase/lowcode-cli":"^0.22.2","@cloudbase/manager-node":"4.4.4","@cloudbase/toolbox":"^0.7.7","@dotenvx/dotenvx":"^1.48.3","@musistudio/claude-code-router":"1.0.36","address":"^1.1.2","camelcase-keys":"^7.0.2","chalk":"^2.4.2","cli-table3":"^0.5.1","commander":"7","del":"^5.1.0","didyoumean":"^1.2.2","enquirer":"^2.3.6","execa":"^4.0.3","figlet":"^1.7.0","fs-extra":"^8.1.0","gradient-string":"^2.0.2","https-proxy-agent":"^5.0.1","inquirer":"^6.5.0","json-schema-to-typescript":"^14.0.5","lodash":"^4.17.21","log-symbols":"^3.0.0","lowdb":"^1.0.0","make-dir":"^3.0.0","node-fetch":"^2.6.0","nodemon":"^3.1.4","open":"^7.0.0","ora":"^4.0.2","patch-package":"^8.0.0","portfinder":"^1.0.28","progress":"^2.0.3","query-string":"^6.8.1","reflect-metadata":"^0.1.13","semver":"^7.3.7","tar-fs":"^2.0.1","terminal-link":"^2.1.1","toml":"^3.0.0","unzipper":"^0.10.10","update-notifier":"^4.0.0","xdg-basedir":"^4.0.0","yargs":"^16.2.0","yargs-parser":"^21.0.1","zod":"^4.0.13"},"devDependencies":{"@types/fs-extra":"^11.0.4","@types/jest":"^27","@types/koa__router":"^8.0.11","@types/lodash":"^4.14.182","@types/node":"^12.12.38","@types/node-fetch":"^2.5.4","@types/react":"^17.0.37","@types/semver":"^7.3.9","@types/unzipper":"^0.10.11","@types/webpack-dev-server":"^3.11.1","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","cpx":"^1.5.0","eslint":"^7.14.0","eslint-config-alloy":"^3.8.2","husky":"^3.0.9","jest":"^27","rimraf":"^3.0.2","ts-jest":"^27","typescript":"^4.7.2","webpack":"^5.92.0","webpack-cli":"^5.1.4"},"packageManager":"yarn@3.6.2+sha512.2c2f8b9615e6659773f65cdec7cf92ef773a98a99e611579601f61c7a91ec94c89c929aac86f1cee819421a9b0db7acfd53ec3ebb95af44f77f77634b08b9557"}');
|
|
617774
617803
|
|
|
617775
617804
|
/***/ })
|
|
617776
617805
|
|
package/lib/commands/ai/index.js
CHANGED
|
@@ -157,15 +157,29 @@ AICommand = __decorate([
|
|
|
157
157
|
], AICommand);
|
|
158
158
|
exports.AICommand = AICommand;
|
|
159
159
|
function reportAIUsage(agent, hasEnvId, subCommand) {
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
try {
|
|
162
|
+
return yield report_1.beaconAction.report('ai_command_usage', {
|
|
163
|
+
agent,
|
|
164
|
+
hasEnvId,
|
|
165
|
+
subCommand
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
164
171
|
});
|
|
165
172
|
}
|
|
166
173
|
function reportAIError(agent, error) {
|
|
167
|
-
return
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
try {
|
|
176
|
+
return yield report_1.beaconAction.report('ai_command_error', {
|
|
177
|
+
agent,
|
|
178
|
+
error
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
170
184
|
});
|
|
171
185
|
}
|
package/lib/commands/common.js
CHANGED
|
@@ -162,11 +162,15 @@ class Command extends events_1.EventEmitter {
|
|
|
162
162
|
login_uin: loginState === null || loginState === void 0 ? void 0 : loginState['uin'],
|
|
163
163
|
envId: envId || (loginState === null || loginState === void 0 ? void 0 : loginState['envId'])
|
|
164
164
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
try {
|
|
166
|
+
yield report_1.beaconAction.report('tcb_cli_exec_command', {
|
|
167
|
+
cmd,
|
|
168
|
+
childCmd,
|
|
169
|
+
desc
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
}
|
|
170
174
|
const ctx = {
|
|
171
175
|
cmd,
|
|
172
176
|
envId,
|
package/lib/utils/report.js
CHANGED
|
@@ -48,21 +48,26 @@ class BeaconAction {
|
|
|
48
48
|
report(eventCode, eventData = {}) {
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
50
|
const now = Date.now();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
try {
|
|
52
|
+
return yield (0, net_1.postFetch)('https://otheve.beacon.qq.com/analytics/v2_upload', {
|
|
53
|
+
appVersion: '',
|
|
54
|
+
sdkId: 'js',
|
|
55
|
+
sdkVersion: '4.5.14-web',
|
|
56
|
+
mainAppKey: '0WEB0AD0GM4PUUU1',
|
|
57
|
+
platformId: 3,
|
|
58
|
+
common: Object.assign({ A2: this.deviceId, A101: this.userAgent, from: 'tcb-cli', xDeployEnv: process.env.NODE_ENV }, this.additionalParams),
|
|
59
|
+
events: [
|
|
60
|
+
{
|
|
61
|
+
eventCode,
|
|
62
|
+
eventTime: String(now),
|
|
63
|
+
mapValue: Object.assign({}, eventData)
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
73
|
addAdditionalParams(params) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# SSL错误修复技术方案设计
|
|
2
|
+
|
|
3
|
+
## 架构概述
|
|
4
|
+
|
|
5
|
+
采用多层解决方案架构,从检测到自动修复,提供完整的SSL错误处理流程。
|
|
6
|
+
|
|
7
|
+
## 技术栈
|
|
8
|
+
|
|
9
|
+
- **错误检测层**:Node.js错误捕获 + SSL协议检测
|
|
10
|
+
- **配置管理层**:环境变量管理 + Node.js配置
|
|
11
|
+
- **网络适配层**:代理配置 + SSL降级处理
|
|
12
|
+
- **用户交互层**:CLI交互 + 自动修复
|
|
13
|
+
|
|
14
|
+
## 技术选型
|
|
15
|
+
|
|
16
|
+
### 1. SSL错误检测
|
|
17
|
+
- 使用 `process.on('uncaughtException')` 捕获SSL错误
|
|
18
|
+
- 通过错误信息模式匹配识别SSL协议问题
|
|
19
|
+
- 集成环境信息收集功能
|
|
20
|
+
|
|
21
|
+
### 2. SSL配置优化
|
|
22
|
+
- 使用 `process.env.NODE_OPTIONS` 设置SSL配置
|
|
23
|
+
- 支持 `--tls-min-v1.2` 和 `--tls-max-v1.3` 参数
|
|
24
|
+
- 提供环境变量配置选项
|
|
25
|
+
|
|
26
|
+
### 3. 网络适配
|
|
27
|
+
- 集成现有的代理配置系统
|
|
28
|
+
- 支持企业网络环境检测
|
|
29
|
+
- 提供SSL证书验证选项
|
|
30
|
+
|
|
31
|
+
## 数据库/接口设计
|
|
32
|
+
|
|
33
|
+
### 配置存储
|
|
34
|
+
```typescript
|
|
35
|
+
interface SSLConfig {
|
|
36
|
+
tlsMinVersion: string;
|
|
37
|
+
tlsMaxVersion: string;
|
|
38
|
+
secureProtocol: string;
|
|
39
|
+
rejectUnauthorized: boolean;
|
|
40
|
+
proxyEnabled: boolean;
|
|
41
|
+
proxyUrl?: string;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 错误诊断接口
|
|
46
|
+
```typescript
|
|
47
|
+
interface SSLDiagnostic {
|
|
48
|
+
errorType: 'EPROTO' | 'CERTIFICATE' | 'PROXY' | 'UNKNOWN';
|
|
49
|
+
errorMessage: string;
|
|
50
|
+
environment: {
|
|
51
|
+
nodeVersion: string;
|
|
52
|
+
platform: string;
|
|
53
|
+
arch: string;
|
|
54
|
+
sslVersion: string;
|
|
55
|
+
};
|
|
56
|
+
solutions: SSLSolution[];
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 测试策略
|
|
61
|
+
|
|
62
|
+
1. **单元测试**:SSL配置函数测试
|
|
63
|
+
2. **集成测试**:错误检测和修复流程测试
|
|
64
|
+
3. **环境测试**:Windows 11 PowerShell环境测试
|
|
65
|
+
4. **兼容性测试**:不同Node.js版本兼容性测试
|
|
66
|
+
|
|
67
|
+
## 安全性
|
|
68
|
+
|
|
69
|
+
- 保持SSL证书验证的完整性
|
|
70
|
+
- 提供安全的代理配置选项
|
|
71
|
+
- 避免降低安全性的降级方案
|
|
72
|
+
|
|
73
|
+
## 实施计划
|
|
74
|
+
|
|
75
|
+
### 阶段1:错误检测与诊断
|
|
76
|
+
- 实现SSL错误自动检测
|
|
77
|
+
- 添加环境信息收集
|
|
78
|
+
- 提供诊断报告功能
|
|
79
|
+
|
|
80
|
+
### 阶段2:配置优化
|
|
81
|
+
- 实现SSL配置自动优化
|
|
82
|
+
- 添加环境变量配置
|
|
83
|
+
- 提供代理配置选项
|
|
84
|
+
|
|
85
|
+
### 阶段3:降级处理
|
|
86
|
+
- 实现TLS版本降级
|
|
87
|
+
- 添加兼容性模式
|
|
88
|
+
- 提供自动修复功能
|
|
89
|
+
|
|
90
|
+
### 阶段4:用户交互
|
|
91
|
+
- 实现CLI交互界面
|
|
92
|
+
- 添加自动修复选项
|
|
93
|
+
- 提供配置管理功能
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# SSL错误修复需求文档
|
|
2
|
+
|
|
3
|
+
## 介绍
|
|
4
|
+
|
|
5
|
+
Windows 11 PowerShell环境下运行 `tcb ai` 时出现SSL协议版本不匹配错误,需要提供多种解决方案。
|
|
6
|
+
|
|
7
|
+
## 需求
|
|
8
|
+
|
|
9
|
+
### 需求 1 - SSL错误检测与诊断
|
|
10
|
+
|
|
11
|
+
**用户故事:** 当用户遇到SSL错误时,系统应当能够自动检测并提供诊断信息
|
|
12
|
+
|
|
13
|
+
#### 验收标准
|
|
14
|
+
|
|
15
|
+
1. When 检测到SSL错误时,the 系统 shall 提供详细的错误诊断信息
|
|
16
|
+
2. When 检测到SSL错误时,the 系统 shall 提供多种解决方案选项
|
|
17
|
+
3. When 检测到SSL错误时,the 系统 shall 提供环境信息收集功能
|
|
18
|
+
|
|
19
|
+
### 需求 2 - SSL配置优化
|
|
20
|
+
|
|
21
|
+
**用户故事:** 系统应当提供SSL配置优化选项来解决协议版本不匹配问题
|
|
22
|
+
|
|
23
|
+
#### 验收标准
|
|
24
|
+
|
|
25
|
+
1. When 用户选择SSL配置优化时,the 系统 shall 提供Node.js SSL配置选项
|
|
26
|
+
2. When 用户选择SSL配置优化时,the 系统 shall 提供环境变量配置选项
|
|
27
|
+
3. When 用户选择SSL配置优化时,the 系统 shall 提供代理配置选项
|
|
28
|
+
|
|
29
|
+
### 需求 3 - 降级兼容性处理
|
|
30
|
+
|
|
31
|
+
**用户故事:** 系统应当提供降级到兼容SSL版本的选项
|
|
32
|
+
|
|
33
|
+
#### 验收标准
|
|
34
|
+
|
|
35
|
+
1. When 用户选择降级处理时,the 系统 shall 自动设置兼容的SSL协议版本
|
|
36
|
+
2. When 用户选择降级处理时,the 系统 shall 提供TLS 1.2兼容模式
|
|
37
|
+
3. When 用户选择降级处理时,the 系统 shall 保持功能完整性
|
|
38
|
+
|
|
39
|
+
### 需求 4 - 网络环境适配
|
|
40
|
+
|
|
41
|
+
**用户故事:** 系统应当能够适配不同的网络环境配置
|
|
42
|
+
|
|
43
|
+
#### 验收标准
|
|
44
|
+
|
|
45
|
+
1. When 检测到企业网络环境时,the 系统 shall 提供代理配置指导
|
|
46
|
+
2. When 检测到防火墙限制时,the 系统 shall 提供绕过方案
|
|
47
|
+
3. When 检测到SSL证书问题时,the 系统 shall 提供证书验证选项
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# SSL错误修复实施计划
|
|
2
|
+
|
|
3
|
+
## 任务拆分
|
|
4
|
+
|
|
5
|
+
- [x] 1. SSL错误检测模块开发
|
|
6
|
+
- 实现SSL错误自动捕获机制
|
|
7
|
+
- 添加错误模式识别功能
|
|
8
|
+
- 集成环境信息收集
|
|
9
|
+
- _需求: 需求1
|
|
10
|
+
|
|
11
|
+
- [x] 2. SSL配置优化模块开发
|
|
12
|
+
- 实现Node.js SSL配置自动设置
|
|
13
|
+
- 添加环境变量配置功能
|
|
14
|
+
- 集成代理配置选项
|
|
15
|
+
- _需求: 需求2
|
|
16
|
+
|
|
17
|
+
- [x] 3. 降级兼容性处理模块开发
|
|
18
|
+
- 实现TLS版本降级功能
|
|
19
|
+
- 添加TLS 1.2兼容模式
|
|
20
|
+
- 确保功能完整性
|
|
21
|
+
- _需求: 需求3
|
|
22
|
+
|
|
23
|
+
- [x] 4. 网络环境适配模块开发
|
|
24
|
+
- 实现企业网络环境检测
|
|
25
|
+
- 添加防火墙绕过方案
|
|
26
|
+
- 提供证书验证选项
|
|
27
|
+
- _需求: 需求4
|
|
28
|
+
|
|
29
|
+
- [x] 5. 用户交互界面开发
|
|
30
|
+
- 实现CLI交互界面
|
|
31
|
+
- 添加自动修复选项
|
|
32
|
+
- 提供配置管理功能
|
|
33
|
+
- _需求: 需求1, 需求2, 需求3, 需求4
|
|
34
|
+
|
|
35
|
+
- [x] 6. 测试与验证
|
|
36
|
+
- 单元测试编写
|
|
37
|
+
- 集成测试执行
|
|
38
|
+
- Windows 11环境测试
|
|
39
|
+
- 兼容性测试验证
|
|
40
|
+
- _需求: 需求1, 需求2, 需求3, 需求4
|
|
41
|
+
|
|
42
|
+
- [x] 7. 文档与部署
|
|
43
|
+
- 用户使用文档编写
|
|
44
|
+
- 故障排除指南更新
|
|
45
|
+
- 部署脚本更新
|
|
46
|
+
- _需求: 需求1, 需求2, 需求3, 需求4
|
|
47
|
+
|
|
48
|
+
## 优先级排序
|
|
49
|
+
|
|
50
|
+
1. **高优先级**:任务1、任务2(核心功能)
|
|
51
|
+
2. **中优先级**:任务3、任务4(兼容性)
|
|
52
|
+
3. **低优先级**:任务5、任务6、任务7(完善)
|
|
53
|
+
|
|
54
|
+
## 风险评估
|
|
55
|
+
|
|
56
|
+
- **技术风险**:SSL配置可能影响其他功能
|
|
57
|
+
- **兼容性风险**:不同Node.js版本兼容性
|
|
58
|
+
- **安全风险**:降级方案可能降低安全性
|
|
59
|
+
|
|
60
|
+
## 成功标准
|
|
61
|
+
|
|
62
|
+
- SSL错误自动检测准确率 > 95%
|
|
63
|
+
- 自动修复成功率 > 90%
|
|
64
|
+
- 用户满意度 > 85%
|
|
65
|
+
- 无安全漏洞引入
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
// Suppress noisy Node deprecation warnings in standalone runtime
|
|
5
|
-
if (!process.env.NODE_NO_WARNINGS) {
|
|
6
|
-
process.env.NODE_NO_WARNINGS = '1'
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// Load and run the ccr command from @musistudio/claude-code-router
|
|
10
|
-
try {
|
|
11
|
-
require('@musistudio/claude-code-router/dist/cli.js')
|
|
12
|
-
} catch (error) {
|
|
13
|
-
console.error('Failed to load ccr:', error)
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
// Suppress noisy Node deprecation warnings in standalone runtime
|
|
5
|
-
if (!process.env.NODE_NO_WARNINGS) {
|
|
6
|
-
process.env.NODE_NO_WARNINGS = '1'
|
|
7
|
-
}
|
|
8
|
-
try {
|
|
9
|
-
// Swallow runtime warnings (e.g., punycode deprecation)
|
|
10
|
-
process.emitWarning = function () { /* no-op */ }
|
|
11
|
-
process.on('warning', function () { /* no-op */ })
|
|
12
|
-
} catch (_) {}
|
|
13
|
-
|
|
14
|
-
// Guard against accidental console.log([NaN]) from bundled deps when showing help
|
|
15
|
-
try {
|
|
16
|
-
const originalConsoleLog = console.log
|
|
17
|
-
console.log = function patchedConsoleLog(...args) {
|
|
18
|
-
if (
|
|
19
|
-
args.length === 1 &&
|
|
20
|
-
Array.isArray(args[0]) &&
|
|
21
|
-
args[0].length === 1 &&
|
|
22
|
-
Number.isNaN(args[0][0])
|
|
23
|
-
) {
|
|
24
|
-
try {
|
|
25
|
-
// Debug trace for locating [NaN] origin during dev
|
|
26
|
-
// eslint-disable-next-line no-console
|
|
27
|
-
originalConsoleLog('[NaN] suppressed; caller stack below:')
|
|
28
|
-
console.trace()
|
|
29
|
-
} catch (_) {}
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
return originalConsoleLog.apply(this, args)
|
|
33
|
-
}
|
|
34
|
-
} catch (_) {}
|
|
35
|
-
|
|
36
|
-
require('../../bin/tcb').main()
|
package/build/launchers/ccr
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -eo pipefail
|
|
3
|
-
|
|
4
|
-
SCRIPT_PATH="${BASH_SOURCE[0]}"
|
|
5
|
-
while [ -L "$SCRIPT_PATH" ]; do
|
|
6
|
-
TARGET="$(readlink "$SCRIPT_PATH")"
|
|
7
|
-
if [[ "$TARGET" == /* ]]; then
|
|
8
|
-
SCRIPT_PATH="$TARGET"
|
|
9
|
-
else
|
|
10
|
-
SCRIPT_PATH="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)/$TARGET"
|
|
11
|
-
fi
|
|
12
|
-
done
|
|
13
|
-
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)"
|
|
14
|
-
|
|
15
|
-
export CLI_BIN_NAME=ccr
|
|
16
|
-
|
|
17
|
-
# 检测是否为 Android/Termux 环境
|
|
18
|
-
if [[ -f "/data/data/com.termux/files/usr/bin/bash" ]] ||
|
|
19
|
-
[[ "$PREFIX" == "/data/data/com.termux/files/usr" ]] ||
|
|
20
|
-
[[ -n "$TERMUX_VERSION" ]] ||
|
|
21
|
-
[[ "$(uname -o 2>/dev/null)" == "Android" ]]; then
|
|
22
|
-
# Android/Termux: 使用系统 node
|
|
23
|
-
if command -v node >/dev/null 2>&1; then
|
|
24
|
-
node "${SCRIPT_DIR}/../ccr.js" "$@"
|
|
25
|
-
else
|
|
26
|
-
echo "error: Node.js not found. Please install it with: pkg install nodejs" >&2
|
|
27
|
-
exit 1
|
|
28
|
-
fi
|
|
29
|
-
else
|
|
30
|
-
# 标准 Linux/macOS: 使用打包的 node
|
|
31
|
-
"${SCRIPT_DIR}/../node" "${SCRIPT_DIR}/../ccr.js" "$@"
|
|
32
|
-
fi
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -eo pipefail
|
|
3
|
-
|
|
4
|
-
SCRIPT_PATH="${BASH_SOURCE[0]}"
|
|
5
|
-
while [ -L "$SCRIPT_PATH" ]; do
|
|
6
|
-
TARGET="$(readlink "$SCRIPT_PATH")"
|
|
7
|
-
if [[ "$TARGET" == /* ]]; then
|
|
8
|
-
SCRIPT_PATH="$TARGET"
|
|
9
|
-
else
|
|
10
|
-
SCRIPT_PATH="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)/$TARGET"
|
|
11
|
-
fi
|
|
12
|
-
done
|
|
13
|
-
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)"
|
|
14
|
-
|
|
15
|
-
export CLI_BIN_NAME=cloudbase
|
|
16
|
-
|
|
17
|
-
# 检测是否为 Android/Termux 环境
|
|
18
|
-
if [[ -f "/data/data/com.termux/files/usr/bin/bash" ]] ||
|
|
19
|
-
[[ "$PREFIX" == "/data/data/com.termux/files/usr" ]] ||
|
|
20
|
-
[[ -n "$TERMUX_VERSION" ]] ||
|
|
21
|
-
[[ "$(uname -o 2>/dev/null)" == "Android" ]]; then
|
|
22
|
-
# Android/Termux: 使用系统 node
|
|
23
|
-
if command -v node >/dev/null 2>&1; then
|
|
24
|
-
node "${SCRIPT_DIR}/../cli.js" "$@"
|
|
25
|
-
else
|
|
26
|
-
echo "error: Node.js not found. Please install it with: pkg install nodejs" >&2
|
|
27
|
-
exit 1
|
|
28
|
-
fi
|
|
29
|
-
else
|
|
30
|
-
# 标准 Linux/macOS: 使用打包的 node
|
|
31
|
-
"${SCRIPT_DIR}/../node" "${SCRIPT_DIR}/../cli.js" "$@"
|
|
32
|
-
fi
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -eo pipefail
|
|
3
|
-
|
|
4
|
-
SCRIPT_PATH="${BASH_SOURCE[0]}"
|
|
5
|
-
while [ -L "$SCRIPT_PATH" ]; do
|
|
6
|
-
TARGET="$(readlink "$SCRIPT_PATH")"
|
|
7
|
-
if [[ "$TARGET" == /* ]]; then
|
|
8
|
-
SCRIPT_PATH="$TARGET"
|
|
9
|
-
else
|
|
10
|
-
SCRIPT_PATH="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)/$TARGET"
|
|
11
|
-
fi
|
|
12
|
-
done
|
|
13
|
-
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)"
|
|
14
|
-
|
|
15
|
-
export CLI_BIN_NAME=cloudbase-mcp
|
|
16
|
-
|
|
17
|
-
# 检测是否为 Android/Termux 环境
|
|
18
|
-
if [[ -f "/data/data/com.termux/files/usr/bin/bash" ]] ||
|
|
19
|
-
[[ "$PREFIX" == "/data/data/com.termux/files/usr" ]] ||
|
|
20
|
-
[[ -n "$TERMUX_VERSION" ]] ||
|
|
21
|
-
[[ "$(uname -o 2>/dev/null)" == "Android" ]]; then
|
|
22
|
-
# Android/Termux: 使用系统 node
|
|
23
|
-
if command -v node >/dev/null 2>&1; then
|
|
24
|
-
node "${SCRIPT_DIR}/../mcp.js" "$@"
|
|
25
|
-
else
|
|
26
|
-
echo "error: Node.js not found. Please install it with: pkg install nodejs" >&2
|
|
27
|
-
exit 1
|
|
28
|
-
fi
|
|
29
|
-
else
|
|
30
|
-
# 标准 Linux/macOS: 使用打包的 node
|
|
31
|
-
"${SCRIPT_DIR}/../node" "${SCRIPT_DIR}/../mcp.js" "$@"
|
|
32
|
-
fi
|
package/build/launchers/tcb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -eo pipefail
|
|
3
|
-
|
|
4
|
-
# Resolve symlink to real script path
|
|
5
|
-
SCRIPT_PATH="${BASH_SOURCE[0]}"
|
|
6
|
-
while [ -L "$SCRIPT_PATH" ]; do
|
|
7
|
-
TARGET="$(readlink "$SCRIPT_PATH")"
|
|
8
|
-
if [[ "$TARGET" == /* ]]; then
|
|
9
|
-
SCRIPT_PATH="$TARGET"
|
|
10
|
-
else
|
|
11
|
-
SCRIPT_PATH="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)/$TARGET"
|
|
12
|
-
fi
|
|
13
|
-
done
|
|
14
|
-
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)"
|
|
15
|
-
|
|
16
|
-
export CLI_BIN_NAME=tcb
|
|
17
|
-
|
|
18
|
-
# 检测是否为 Android/Termux 环境
|
|
19
|
-
if [[ -f "/data/data/com.termux/files/usr/bin/bash" ]] ||
|
|
20
|
-
[[ "${PREFIX:-}" == "/data/data/com.termux/files/usr" ]] ||
|
|
21
|
-
[[ -n "${TERMUX_VERSION:-}" ]] ||
|
|
22
|
-
[[ "$(uname -o 2>/dev/null)" == "Android" ]]; then
|
|
23
|
-
# Android/Termux: 使用系统 node
|
|
24
|
-
if command -v node >/dev/null 2>&1; then
|
|
25
|
-
node "${SCRIPT_DIR}/../cli.js" "$@"
|
|
26
|
-
else
|
|
27
|
-
echo "error: Node.js not found. Please install it with: pkg install nodejs" >&2
|
|
28
|
-
exit 1
|
|
29
|
-
fi
|
|
30
|
-
else
|
|
31
|
-
# 标准 Linux/macOS: 使用打包的 node
|
|
32
|
-
"${SCRIPT_DIR}/../node" "${SCRIPT_DIR}/../cli.js" "$@"
|
|
33
|
-
fi
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
|
|
6
|
-
const cliPath = path.resolve(__dirname, '../../node_modules/@musistudio/claude-code-router/dist/cli.js')
|
|
7
|
-
|
|
8
|
-
// 读取原始文件
|
|
9
|
-
let content = fs.readFileSync(cliPath, 'utf8')
|
|
10
|
-
|
|
11
|
-
// 替换所有的 node cliPath 为 ccr
|
|
12
|
-
// 1. 第77872行附近
|
|
13
|
-
content = content.replace(
|
|
14
|
-
/const startProcess2 = \(0, import_child_process3\.spawn\)\("node", \[cliPath2, "start"\],/g,
|
|
15
|
-
'const startProcess2 = (0, import_child_process3.spawn)("ccr", ["start"],'
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
// 2. 第77899行附近
|
|
19
|
-
content = content.replace(
|
|
20
|
-
/const startProcess2 = \(0, import_child_process3\.spawn\)\("node", \[cliPath2, "start"\],/g,
|
|
21
|
-
'const startProcess2 = (0, import_child_process3.spawn)("ccr", ["start"],'
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
// 3. 第77936行附近
|
|
25
|
-
content = content.replace(
|
|
26
|
-
/const restartProcess = \(0, import_child_process3\.spawn\)\("node", \[cliPath2, "start"\],/g,
|
|
27
|
-
'const restartProcess = (0, import_child_process3.spawn)("ccr", ["start"],'
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
// 4. 第78007行附近
|
|
31
|
-
content = content.replace(
|
|
32
|
-
/const startProcess = \(0, import_child_process3\.spawn\)\("node", \[cliPath, "start"\],/g,
|
|
33
|
-
'const startProcess = (0, import_child_process3.spawn)("ccr", ["start"],'
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
// 写回文件
|
|
37
|
-
fs.writeFileSync(cliPath, content, 'utf8')
|
|
38
|
-
|
|
39
|
-
console.log('✅ CCR CLI patch applied successfully!')
|
|
40
|
-
console.log('Modified file:', cliPath)
|
package/build/shims/hexoid.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Minimal hexoid compatible shim for standalone bundle
|
|
2
|
-
// Usage: const toHexoId = hexoid(25); const id = toHexoId();
|
|
3
|
-
const crypto = require('crypto')
|
|
4
|
-
|
|
5
|
-
function hexoid(length = 16) {
|
|
6
|
-
const bytes = Math.ceil(length / 2)
|
|
7
|
-
return function generateHexId() {
|
|
8
|
-
return crypto.randomBytes(bytes).toString('hex').slice(0, length)
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
module.exports = hexoid
|
|
13
|
-
|
|
14
|
-
|
package/build/shims/prettier.cjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Mock prettier to avoid runtime errors
|
|
2
|
-
module.exports = {
|
|
3
|
-
format: (code, options) => {
|
|
4
|
-
// Return the code as-is without formatting
|
|
5
|
-
return code;
|
|
6
|
-
},
|
|
7
|
-
resolveConfig: () => ({}),
|
|
8
|
-
getFileInfo: () => ({ ignored: false }),
|
|
9
|
-
check: () => true,
|
|
10
|
-
version: '0.0.0'
|
|
11
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
// Shim for read-pkg-up to avoid package.json access issues in standalone bundle
|
|
4
|
-
function sync(options = {}) {
|
|
5
|
-
// Return a mock package.json object with version information
|
|
6
|
-
return {
|
|
7
|
-
packageJson: {
|
|
8
|
-
name: '@cloudbase/functions-framework',
|
|
9
|
-
version: process.env.CLOUDBASE_FUNCTIONS_FRAMEWORK_VERSION || '1.16.0',
|
|
10
|
-
description: 'CloudBase Functions Framework',
|
|
11
|
-
main: 'index.js',
|
|
12
|
-
dependencies: {},
|
|
13
|
-
devDependencies: {}
|
|
14
|
-
},
|
|
15
|
-
path: '/mock/package.json'
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = {
|
|
20
|
-
sync
|
|
21
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// No-op shim for update-notifier in standalone bundle
|
|
2
|
-
// Usage: const notifier = updateNotifier(opts); notifier.notify({ isGlobal: true })
|
|
3
|
-
module.exports = function updateNotifier() {
|
|
4
|
-
return {
|
|
5
|
-
notify: function notify() {
|
|
6
|
-
// intentionally no-op in standalone distribution
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}
|
package/build/webpack/ccr.cjs
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/* CCR standalone bundle config
|
|
2
|
-
* - Entries: ccr-main.js
|
|
3
|
-
* - Output: dist/standalone/ccr.js
|
|
4
|
-
*/
|
|
5
|
-
const path = require('path')
|
|
6
|
-
const webpack = require('webpack')
|
|
7
|
-
|
|
8
|
-
/** @type {import('webpack').Configuration} */
|
|
9
|
-
module.exports = {
|
|
10
|
-
mode: 'production',
|
|
11
|
-
target: 'node',
|
|
12
|
-
entry: {
|
|
13
|
-
ccr: path.resolve(__dirname, '../entries/ccr-main.js')
|
|
14
|
-
},
|
|
15
|
-
output: {
|
|
16
|
-
path: path.resolve(__dirname, '../../dist/standalone'),
|
|
17
|
-
filename: '[name].js',
|
|
18
|
-
libraryTarget: 'commonjs2',
|
|
19
|
-
clean: false // 不清理,因为要和 cli.js 共存
|
|
20
|
-
},
|
|
21
|
-
resolve: {
|
|
22
|
-
extensions: ['.js', '.json'],
|
|
23
|
-
alias: {
|
|
24
|
-
// Mock read-pkg-up to avoid dynamic package.json access
|
|
25
|
-
'read-pkg-up': path.resolve(__dirname, '../shims/read-pkg-up.cjs')
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
module: {
|
|
29
|
-
rules: [
|
|
30
|
-
{
|
|
31
|
-
test: /\.wasm$/,
|
|
32
|
-
type: 'asset/resource'
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
optimization: {
|
|
37
|
-
minimize: false,
|
|
38
|
-
splitChunks: false,
|
|
39
|
-
runtimeChunk: false
|
|
40
|
-
},
|
|
41
|
-
plugins: [
|
|
42
|
-
// Force single-file bundle
|
|
43
|
-
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
|
|
44
|
-
|
|
45
|
-
// Add shebang to the output file
|
|
46
|
-
new webpack.BannerPlugin({
|
|
47
|
-
banner: '#!/usr/bin/env node',
|
|
48
|
-
raw: true
|
|
49
|
-
}),
|
|
50
|
-
|
|
51
|
-
// 处理动态 require 的 package.json 访问
|
|
52
|
-
new webpack.NormalModuleReplacementPlugin(
|
|
53
|
-
/^([^/]+)\/package\.json$/,
|
|
54
|
-
(resource) => {
|
|
55
|
-
const packageName = resource.request.match(/^([^/]+)\/package\.json$/)[1]
|
|
56
|
-
if (packageName.startsWith('@musistudio/')) {
|
|
57
|
-
resource.request = path.resolve(__dirname, '../shims/generic-pkg.cjs')
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
),
|
|
61
|
-
|
|
62
|
-
// 处理 read-pkg-up 的访问
|
|
63
|
-
new webpack.NormalModuleReplacementPlugin(
|
|
64
|
-
/^read-pkg-up$/,
|
|
65
|
-
(resource) => {
|
|
66
|
-
resource.request = path.resolve(__dirname, '../shims/read-pkg-up.cjs')
|
|
67
|
-
}
|
|
68
|
-
)
|
|
69
|
-
],
|
|
70
|
-
externals: [
|
|
71
|
-
function ({ context, request }, callback) {
|
|
72
|
-
const externals = new Set([
|
|
73
|
-
'fsevents', 'esbuild', 'bufferutil', 'utf-8-validate',
|
|
74
|
-
'canvas', 'sharp', 'serialport', 'node-pty', 'keytar'
|
|
75
|
-
])
|
|
76
|
-
if (externals.has(request)) {
|
|
77
|
-
return callback(null, 'commonjs ' + request)
|
|
78
|
-
}
|
|
79
|
-
return callback()
|
|
80
|
-
}
|
|
81
|
-
],
|
|
82
|
-
stats: {
|
|
83
|
-
errorDetails: true
|
|
84
|
-
}
|
|
85
|
-
}
|
package/build/webpack/cli.cjs
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/* CLI standalone bundle config (tidy layout)
|
|
2
|
-
* - Entries: cli.js (main)
|
|
3
|
-
* - Output: dist/standalone/cli.js
|
|
4
|
-
*/
|
|
5
|
-
const path = require('path')
|
|
6
|
-
const webpack = require('webpack')
|
|
7
|
-
|
|
8
|
-
/** @type {import('webpack').Configuration} */
|
|
9
|
-
module.exports = {
|
|
10
|
-
mode: 'production',
|
|
11
|
-
target: 'node',
|
|
12
|
-
entry: {
|
|
13
|
-
cli: path.resolve(__dirname, '../entries/cli-main.js')
|
|
14
|
-
},
|
|
15
|
-
output: {
|
|
16
|
-
path: path.resolve(__dirname, '../../dist/standalone'),
|
|
17
|
-
filename: '[name].js',
|
|
18
|
-
libraryTarget: 'commonjs2',
|
|
19
|
-
clean: true
|
|
20
|
-
},
|
|
21
|
-
resolve: {
|
|
22
|
-
extensions: ['.js', '.json'],
|
|
23
|
-
alias: {
|
|
24
|
-
hexoid: path.resolve(__dirname, '../shims/hexoid.cjs'),
|
|
25
|
-
// Replace update-notifier with a no-op shim to avoid pulling optional deps like is-ci
|
|
26
|
-
'update-notifier': path.resolve(__dirname, '../shims/update-notifier.cjs'),
|
|
27
|
-
// Mock lowcode package.json to avoid hard dep in tcb --version
|
|
28
|
-
'@cloudbase/lowcode-cli/package.json': path.resolve(__dirname, '../shims/lowcode-pkg.cjs'),
|
|
29
|
-
// Mock cloud-api package.json to avoid SDKVersion error
|
|
30
|
-
'@cloudbase/cloud-api/package.json': path.resolve(__dirname, '../shims/cloud-api-pkg.cjs'),
|
|
31
|
-
// Mock other CloudBase packages to avoid package.json access errors
|
|
32
|
-
'@cloudbase/toolbox/package.json': path.resolve(__dirname, '../shims/toolbox-pkg.cjs'),
|
|
33
|
-
'@cloudbase/manager-node/package.json': path.resolve(__dirname, '../shims/manager-node-pkg.cjs'),
|
|
34
|
-
'@cloudbase/functions-framework/package.json': path.resolve(__dirname, '../shims/functions-framework-pkg.cjs'),
|
|
35
|
-
'@cloudbase/framework-core/package.json': path.resolve(__dirname, '../shims/framework-core-pkg.cjs'),
|
|
36
|
-
'@cloudbase/iac-core/package.json': path.resolve(__dirname, '../shims/iac-core-pkg.cjs'),
|
|
37
|
-
// Mock read-pkg-up to avoid dynamic package.json access
|
|
38
|
-
'read-pkg-up': path.resolve(__dirname, '../shims/read-pkg-up.cjs')
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
module: {
|
|
42
|
-
rules: []
|
|
43
|
-
},
|
|
44
|
-
optimization: {
|
|
45
|
-
minimize: false,
|
|
46
|
-
splitChunks: false,
|
|
47
|
-
runtimeChunk: false
|
|
48
|
-
},
|
|
49
|
-
plugins: [
|
|
50
|
-
// Force single-file bundle
|
|
51
|
-
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
|
|
52
|
-
|
|
53
|
-
// 剔除低码链路及其重型依赖,避免被静态收集(但保留 package.json 以便 -v 读取,交由 alias mock)
|
|
54
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^@cloudbase\/lowcode-cli(?!\/package\.json)(\/.*)?$/ }),
|
|
55
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^@cloudbase\/lowcode-builder(\/.*)?$/ }),
|
|
56
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^@cloudbase\/lowcode-deployer(\/.*)?$/ }),
|
|
57
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^vue-loader(\/.*)?$/ }),
|
|
58
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^@vue\/compiler-sfc(\/.*)?$/ }),
|
|
59
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^consolidate(\/.*)?$/ }),
|
|
60
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^@pmmmwh\/react-refresh-webpack-plugin(\/.*)?$/ }),
|
|
61
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^webpack-dev-server(\/.*)?$/ }),
|
|
62
|
-
// 将 prettier 替换为 mock(必须在 IgnorePlugin 之前)
|
|
63
|
-
new webpack.NormalModuleReplacementPlugin(
|
|
64
|
-
/^prettier$/,
|
|
65
|
-
(resource) => {
|
|
66
|
-
resource.request = path.resolve(__dirname, '../shims/prettier.cjs')
|
|
67
|
-
}
|
|
68
|
-
),
|
|
69
|
-
|
|
70
|
-
// 剔除开发期进程树相关依赖,避免在 bundle 中出现 CLI 副作用输出(数组打印)
|
|
71
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^nodemon(\/.*)?$/ }),
|
|
72
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^ps-tree(\/.*)?$/ }),
|
|
73
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^pidtree(\/.*)?$/ }),
|
|
74
|
-
|
|
75
|
-
// 剔除 prettier 依赖,避免在运行时包含格式化工具
|
|
76
|
-
new webpack.IgnorePlugin({ resourceRegExp: /^prettier(\/.*)?$/ }),
|
|
77
|
-
|
|
78
|
-
// 处理动态 require 的 package.json 访问
|
|
79
|
-
new webpack.NormalModuleReplacementPlugin(
|
|
80
|
-
/^([^/]+)\/package\.json$/,
|
|
81
|
-
(resource) => {
|
|
82
|
-
const packageName = resource.request.match(/^([^/]+)\/package\.json$/)[1]
|
|
83
|
-
if (packageName.startsWith('@cloudbase/')) {
|
|
84
|
-
resource.request = path.resolve(__dirname, '../shims/generic-pkg.cjs')
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
),
|
|
88
|
-
|
|
89
|
-
// 处理 read-pkg-up 的访问
|
|
90
|
-
new webpack.NormalModuleReplacementPlugin(
|
|
91
|
-
/^read-pkg-up$/,
|
|
92
|
-
(resource) => {
|
|
93
|
-
resource.request = path.resolve(__dirname, '../shims/read-pkg-up.cjs')
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
],
|
|
97
|
-
externals: [
|
|
98
|
-
function ({ context, request }, callback) {
|
|
99
|
-
const externals = new Set([
|
|
100
|
-
'fsevents', 'esbuild', 'bufferutil', 'utf-8-validate',
|
|
101
|
-
'canvas', 'sharp', 'serialport', 'node-pty', 'keytar',
|
|
102
|
-
// 以防万一,即便未被 IgnorePlugin 命中,也不将其打入包内
|
|
103
|
-
'nodemon', 'ps-tree', 'pidtree'
|
|
104
|
-
])
|
|
105
|
-
if (externals.has(request)) {
|
|
106
|
-
return callback(null, 'commonjs ' + request)
|
|
107
|
-
}
|
|
108
|
-
return callback()
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
stats: {
|
|
112
|
-
errorDetails: true
|
|
113
|
-
}
|
|
114
|
-
}
|