@cloudbase/cli 2.12.6 → 2.12.7

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.
Files changed (2) hide show
  1. package/dist/standalone/cli.js +238 -125
  2. package/package.json +1 -1
@@ -2447,6 +2447,80 @@ function* pattern(...rest) {
2447
2447
  }
2448
2448
  //# sourceMappingURL=exec.js.map
2449
2449
 
2450
+ /***/ }),
2451
+
2452
+ /***/ 325:
2453
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2454
+
2455
+ "use strict";
2456
+
2457
+ var __importDefault = (this && this.__importDefault) || function (mod) {
2458
+ return (mod && mod.__esModule) ? mod : { "default": mod };
2459
+ };
2460
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2461
+ exports.validateImageDeploy = exports.resolveFuncPathWithConfig = exports.resolveFunctionName = exports.resolveAndValidateFunctionDir = void 0;
2462
+ const path_1 = __importDefault(__webpack_require__(16928));
2463
+ const error_1 = __webpack_require__(66759);
2464
+ const i18n_1 = __webpack_require__(69258);
2465
+ const utils_1 = __webpack_require__(82079);
2466
+ function resolveAndValidateFunctionDir(options) {
2467
+ const { dir, defaultDir, action, log } = options;
2468
+ let targetDir = defaultDir;
2469
+ if (dir) {
2470
+ (0, utils_1.checkFullAccess)(dir, true);
2471
+ if (!(0, utils_1.isDirectory)(dir)) {
2472
+ throw new error_1.CloudBaseError((0, i18n_1.t)('--dir 参数必须指定为云函数的文件夹路径'));
2473
+ }
2474
+ targetDir = path_1.default.resolve(defaultDir, dir);
2475
+ log === null || log === void 0 ? void 0 : log.info((0, i18n_1.t)(`将从目录 {{dir}} ${action}云函数`, { dir: targetDir }));
2476
+ }
2477
+ else {
2478
+ log === null || log === void 0 ? void 0 : log.info((0, i18n_1.t)(`未找到配置文件,将从当前目录${action}云函数`));
2479
+ }
2480
+ return targetDir;
2481
+ }
2482
+ exports.resolveAndValidateFunctionDir = resolveAndValidateFunctionDir;
2483
+ function resolveFunctionName(name, deployDir) {
2484
+ return name || path_1.default.basename(deployDir);
2485
+ }
2486
+ exports.resolveFunctionName = resolveFunctionName;
2487
+ function resolveFuncPathWithConfig(options) {
2488
+ const { dir, funcDir, functionRootPath, name, deployMode, log } = options;
2489
+ if (deployMode === 'image') {
2490
+ return '';
2491
+ }
2492
+ let funcPath = '';
2493
+ if (dir) {
2494
+ (0, utils_1.checkFullAccess)(dir, true);
2495
+ if (!(0, utils_1.isDirectory)(dir)) {
2496
+ throw new error_1.CloudBaseError((0, i18n_1.t)('--dir 参数必须指定为云函数的文件夹路径'));
2497
+ }
2498
+ funcPath = path_1.default.resolve(process.cwd(), dir);
2499
+ log.info((0, i18n_1.t)('使用命令行指定的目录:{{path}}', { path: funcPath }));
2500
+ }
2501
+ else if (funcDir) {
2502
+ funcPath = path_1.default.resolve(process.cwd(), funcDir);
2503
+ log.info((0, i18n_1.t)('使用配置文件中的目录:{{path}}', { path: funcPath }));
2504
+ }
2505
+ else {
2506
+ funcPath = path_1.default.join(functionRootPath, name);
2507
+ }
2508
+ return funcPath;
2509
+ }
2510
+ exports.resolveFuncPathWithConfig = resolveFuncPathWithConfig;
2511
+ function validateImageDeploy(deployMode, hasConfig) {
2512
+ if (deployMode === 'image') {
2513
+ if (hasConfig === false) {
2514
+ throw new error_1.CloudBaseError((0, i18n_1.t)('镜像部署时需要在配置文件中指定 imageConfig'));
2515
+ }
2516
+ if (hasConfig === undefined) {
2517
+ throw new error_1.CloudBaseError((0, i18n_1.t)('镜像部署时需要在配置文件中指定函数配置和 imageConfig'));
2518
+ }
2519
+ }
2520
+ }
2521
+ exports.validateImageDeploy = validateImageDeploy;
2522
+
2523
+
2450
2524
  /***/ }),
2451
2525
 
2452
2526
  /***/ 340:
@@ -326254,7 +326328,7 @@ module.exports = function generate_pattern(it, $keyword, $ruleType) {
326254
326328
  /***/ ((module) => {
326255
326329
 
326256
326330
  "use strict";
326257
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.12.6","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":"node ./scripts/check-publish-source.js","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs && node build/scripts/copy-figlet-fonts.js","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","package:npm":"npm run build && npm run build:bundle && bash build/scripts/prepare-publish.sh","out:prune":"bash build/scripts/prune-out.sh","i18n:scan":"i18next-scanner --config locales/i18next-scanner.config.js && node locales/scripts/generate.js","i18n:sync":"node locales/scripts/sync.js sync","publish":"node ./scripts/publish.js"},"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"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^2.7.3","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.14","@cloudbase/lowcode-cli":"^0.23.0","@cloudbase/manager-node":"4.10.2","@cloudbase/toolbox":"0.7.17","@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","i":"^0.3.7","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","npm":"^11.5.2","open":"^7.0.0","ora":"^4.0.2","os-locale":"5.0.0","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","simple-git":"^3.28.0","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":{"@babel/parser":"^7.28.4","@babel/traverse":"^7.28.4","@babel/types":"^7.28.4","@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","i18next-scanner":"^4.6.0","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","ai":{"skills":"./skills","skillsIndex":"./skills/index.json","compatible":["codebuddy","cursor","copilot","claude","windsurf"],"description":"CloudBase CLI - 腾讯云云开发命令行工具,支持云函数、云数据库、静态托管等全栈云开发能力"}}');
326331
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.12.7","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":"node ./scripts/check-publish-source.js","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs && node build/scripts/copy-figlet-fonts.js","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","package:npm":"npm run build && npm run build:bundle && bash build/scripts/prepare-publish.sh","out:prune":"bash build/scripts/prune-out.sh","i18n:scan":"i18next-scanner --config locales/i18next-scanner.config.js && node locales/scripts/generate.js","i18n:sync":"node locales/scripts/sync.js sync","publish":"node ./scripts/publish.js"},"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"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^2.7.3","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.14","@cloudbase/lowcode-cli":"^0.23.0","@cloudbase/manager-node":"4.10.2","@cloudbase/toolbox":"0.7.17","@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","i":"^0.3.7","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","npm":"^11.5.2","open":"^7.0.0","ora":"^4.0.2","os-locale":"5.0.0","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","simple-git":"^3.28.0","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":{"@babel/parser":"^7.28.4","@babel/traverse":"^7.28.4","@babel/types":"^7.28.4","@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","i18next-scanner":"^4.6.0","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","ai":{"skills":"./skills","skillsIndex":"./skills/index.json","compatible":["codebuddy","cursor","copilot","claude","windsurf"],"description":"CloudBase CLI - 腾讯云云开发命令行工具,支持云函数、云数据库、静态托管等全栈云开发能力"}}');
326258
326332
 
326259
326333
  /***/ }),
326260
326334
 
@@ -467668,6 +467742,7 @@ const decorators_1 = __webpack_require__(93480);
467668
467742
  const i18n_1 = __webpack_require__(69258);
467669
467743
  const utils_2 = __webpack_require__(75213);
467670
467744
  const constant_1 = __webpack_require__(62977);
467745
+ const common_utils_1 = __webpack_require__(325);
467671
467746
  let CodeUpdate = class CodeUpdate extends common_1.Command {
467672
467747
  get options() {
467673
467748
  return {
@@ -467723,9 +467798,7 @@ let CodeUpdate = class CodeUpdate extends common_1.Command {
467723
467798
  }
467724
467799
  const configFiles = ['cloudbaserc.json', 'cloudbaserc.js', 'cloudbaserc.yaml', 'cloudbaserc.yml', 'cloudbaserc', 'cloudbase.config.js'];
467725
467800
  const hasConfigFile = configFiles.some(file => fs_1.default.existsSync(path_1.default.join(process.cwd(), file)));
467726
- if (deployMode === 'image' && !hasConfigFile) {
467727
- throw new error_1.CloudBaseError((0, i18n_1.t)('镜像部署时需要在配置文件中指定 imageConfig,请创建 cloudbaserc.json 并配置镜像参数'));
467728
- }
467801
+ (0, common_utils_1.validateImageDeploy)(deployMode, hasConfigFile ? undefined : false);
467729
467802
  const hasConfig = hasConfigFile || functions.length > 0;
467730
467803
  if (hasConfig) {
467731
467804
  return this.updateWithConfig({ name, dir, envId, codeSecret, deployMode, config, functions, log });
@@ -467743,26 +467816,19 @@ let CodeUpdate = class CodeUpdate extends common_1.Command {
467743
467816
  log.info((0, i18n_1.t)('从配置文件读取函数 [{{name}}] 的配置', { name }));
467744
467817
  }
467745
467818
  else {
467819
+ (0, common_utils_1.validateImageDeploy)(deployMode, undefined);
467746
467820
  func = Object.assign({ name }, constant_1.DefaultFunctionDeployConfig);
467747
467821
  log.info((0, i18n_1.t)('未找到函数 [{{name}}] 的配置,使用默认配置', { name }));
467748
467822
  }
467749
467823
  const functionRootPath = path_1.default.join(process.cwd(), config.functionRoot || 'functions');
467750
- let funcPath;
467751
- if (dir) {
467752
- (0, utils_1.checkFullAccess)(dir, true);
467753
- if (!(0, utils_1.isDirectory)(dir)) {
467754
- throw new error_1.CloudBaseError((0, i18n_1.t)('--dir 参数必须指定为云函数的文件夹路径'));
467755
- }
467756
- funcPath = path_1.default.resolve(process.cwd(), dir);
467757
- log.info((0, i18n_1.t)('使用命令行指定的目录:{{path}}', { path: funcPath }));
467758
- }
467759
- else if (func === null || func === void 0 ? void 0 : func.dir) {
467760
- funcPath = path_1.default.resolve(process.cwd(), func.dir);
467761
- log.info((0, i18n_1.t)('使用配置文件中的目录:{{path}}', { path: funcPath }));
467762
- }
467763
- else {
467764
- funcPath = path_1.default.join(functionRootPath, name);
467765
- }
467824
+ const funcPath = (0, common_utils_1.resolveFuncPathWithConfig)({
467825
+ dir,
467826
+ funcDir: func === null || func === void 0 ? void 0 : func.dir,
467827
+ functionRootPath,
467828
+ name,
467829
+ deployMode,
467830
+ log
467831
+ });
467766
467832
  return this.doUpdateCode({
467767
467833
  func, funcPath, functionRootPath, envId, codeSecret, deployMode,
467768
467834
  functionPath: dir ? funcPath : undefined, log
@@ -467772,18 +467838,13 @@ let CodeUpdate = class CodeUpdate extends common_1.Command {
467772
467838
  updateWithoutConfig(options) {
467773
467839
  return __awaiter(this, void 0, void 0, function* () {
467774
467840
  const { name, dir, envId, codeSecret, deployMode, log } = options;
467775
- let updateDir = process.cwd();
467776
- if (dir) {
467777
- (0, utils_1.checkFullAccess)(dir, true);
467778
- if (!(0, utils_1.isDirectory)(dir)) {
467779
- throw new error_1.CloudBaseError((0, i18n_1.t)('--dir 参数必须指定为云函数的文件夹路径'));
467780
- }
467781
- updateDir = path_1.default.resolve(process.cwd(), dir);
467782
- log.info((0, i18n_1.t)('将从目录 {{dir}} 更新云函数代码', { dir: updateDir }));
467783
- }
467784
- else {
467785
- log.info((0, i18n_1.t)('未找到配置文件,将从当前目录更新云函数代码'));
467786
- }
467841
+ (0, common_utils_1.validateImageDeploy)(deployMode, false);
467842
+ const updateDir = (0, common_utils_1.resolveAndValidateFunctionDir)({
467843
+ dir,
467844
+ defaultDir: process.cwd(),
467845
+ action: '更新',
467846
+ log
467847
+ });
467787
467848
  let inferredConfig = this.inferFunctionConfig(name, updateDir);
467788
467849
  const isInferred = !!inferredConfig;
467789
467850
  if (!inferredConfig) {
@@ -694008,9 +694069,10 @@ function updateFunctionCode(options) {
694008
694069
  });
694009
694070
  }
694010
694071
  catch (e) {
694011
- throw new error_1.CloudBaseError((0, i18n_1.t)('[{{name}}] 函数代码更新失败: {{error}}', { name: funcName, error: e.message }), {
694072
+ throw new error_1.CloudBaseError((0, i18n_1.t)('[{{name}}] 函数代码更新失败: {{error}}', { name: funcName, error: e.message || String(e) }), {
694012
694073
  code: e.code,
694013
- requestId: e.requestId
694074
+ requestId: e.requestId,
694075
+ original: e
694014
694076
  });
694015
694077
  }
694016
694078
  });
@@ -726148,7 +726210,9 @@ const outputHelpInfo = () => {
726148
726210
  hosting [cmd] ${(0, i18n_1.t)('静态托管资源管理操作')}
726149
726211
  storage [cmd] ${(0, i18n_1.t)('云存储资源管理操作')}
726150
726212
  service [cmd] ${(0, i18n_1.t)('HTTP 访问服务管理操作')}
726151
- cloudrun [cmd] ${(0, i18n_1.t)('云托管服务管理操作`')}
726213
+ cloudrun [cmd] ${(0, i18n_1.t)('云托管服务管理操作')}
726214
+ config [cmd] ${(0, i18n_1.t)('配置文件管理操作')}
726215
+ gateway [cmd] ${(0, i18n_1.t)('网关管理操作')}
726152
726216
  `;
726153
726217
  const options = `
726154
726218
  ${(0, i18n_1.t)('选项')}
@@ -801619,9 +801683,12 @@ function inferNodejsConfig(targetDir, name, httpFn) {
801619
801683
  runtime = 'Nodejs16.13';
801620
801684
  }
801621
801685
  }
801686
+ const hasDependencies = Boolean(packageJson.dependencies && Object.keys(packageJson.dependencies).length > 0);
801687
+ const hasDevDependencies = Boolean(packageJson.devDependencies && Object.keys(packageJson.devDependencies).length > 0);
801688
+ const shouldInstallDeps = hasDependencies || hasDevDependencies;
801622
801689
  return {
801623
- config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime,
801624
- handler, installDependency: true }), (httpFn ? { type: 'HTTP' } : {})),
801690
+ config: Object.assign(Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime,
801691
+ handler }), (shouldInstallDeps ? { installDependency: true } : {})), (httpFn ? { type: 'HTTP' } : {})),
801625
801692
  source: (0, i18n_1.t)('Node.js 项目(package.json)')
801626
801693
  };
801627
801694
  }
@@ -801646,7 +801713,7 @@ function inferPythonConfig(targetDir, name, httpFn) {
801646
801713
  }
801647
801714
  }
801648
801715
  return {
801649
- config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Python3.9', handler, installDependency: true }), (httpFn ? { type: 'HTTP' } : {})),
801716
+ config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Python3.9', handler }), (httpFn ? { type: 'HTTP' } : {})),
801650
801717
  source: (0, i18n_1.t)('Python 项目({{file}})', { file: foundFile })
801651
801718
  };
801652
801719
  }
@@ -801679,7 +801746,7 @@ function inferPhpConfig(targetDir, name, httpFn) {
801679
801746
  handler = 'index.main';
801680
801747
  }
801681
801748
  return {
801682
- config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Php8.0', handler, installDependency: fs_1.default.existsSync(composerJsonPath) }), (httpFn ? { type: 'HTTP' } : {})),
801749
+ config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Php8.0', handler }), (httpFn ? { type: 'HTTP' } : {})),
801683
801750
  source
801684
801751
  };
801685
801752
  }
@@ -801703,7 +801770,7 @@ function inferJavaConfig(targetDir, name, httpFn) {
801703
801770
  }
801704
801771
  }
801705
801772
  return {
801706
- config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Java11', handler: 'example.Hello::mainHandler', installDependency: true }), (httpFn ? { type: 'HTTP' } : {})),
801773
+ config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Java11', handler: 'example.Hello::mainHandler' }), (httpFn ? { type: 'HTTP' } : {})),
801707
801774
  source: (0, i18n_1.t)('Java 项目({{file}})', { file: foundFile })
801708
801775
  };
801709
801776
  }
@@ -801726,7 +801793,7 @@ function inferGoConfig(targetDir, name, httpFn) {
801726
801793
  }
801727
801794
  }
801728
801795
  return {
801729
- config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Go1', handler: 'main', installDependency: true }), (httpFn ? { type: 'HTTP' } : {})),
801796
+ config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Go1', handler: 'main' }), (httpFn ? { type: 'HTTP' } : {})),
801730
801797
  source: (0, i18n_1.t)('Go 项目({{file}})', { file: foundFile })
801731
801798
  };
801732
801799
  }
@@ -801759,7 +801826,7 @@ function inferByFileExtension(targetDir, name, httpFn) {
801759
801826
  return null;
801760
801827
  }
801761
801828
  return {
801762
- config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: typeConfig.runtime, handler: typeConfig.handler }), (httpFn ? { type: 'HTTP' } : {})),
801829
+ config: Object.assign({ name: funcName, timeout: constant_1.DefaultFunctionDeployConfig.timeout, runtime: typeConfig.runtime, handler: typeConfig.handler, ignore: constant_1.DefaultFunctionDeployConfig.ignore }, (httpFn ? { type: 'HTTP' } : {})),
801763
801830
  source: typeConfig.source
801764
801831
  };
801765
801832
  }
@@ -835731,6 +835798,27 @@ const decorators_1 = __webpack_require__(93480);
835731
835798
  const function_2 = __webpack_require__(11686);
835732
835799
  const i18n_1 = __webpack_require__(69258);
835733
835800
  const utils_2 = __webpack_require__(75213);
835801
+ const common_utils_1 = __webpack_require__(325);
835802
+ const MAX_PARALLEL_DEPLOY = 5;
835803
+ function buildImageConfig(functionConf) {
835804
+ const fileImageConfig = (0, function_2.buildImageConfigFromConfig)(functionConf);
835805
+ if (!fileImageConfig) {
835806
+ return null;
835807
+ }
835808
+ return fileImageConfig;
835809
+ }
835810
+ function checkWebFunctionBootstrap(functionPath, functionConf) {
835811
+ return __awaiter(this, void 0, void 0, function* () {
835812
+ return yield (0, function_1.checkAndCreateBootstrap)(functionPath, functionConf);
835813
+ });
835814
+ }
835815
+ function resolveFunctionPath(options) {
835816
+ const { functionRootPath, functionName, functionDirFromConfig } = options;
835817
+ if (functionDirFromConfig) {
835818
+ return path_1.default.resolve(process.cwd(), functionDirFromConfig);
835819
+ }
835820
+ return path_1.default.join(functionRootPath, functionName);
835821
+ }
835734
835822
  let FunctionDeploy = class FunctionDeploy extends common_1.Command {
835735
835823
  get options() {
835736
835824
  return {
@@ -835852,26 +835940,29 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
835852
835940
  return __awaiter(this, void 0, void 0, function* () {
835853
835941
  const { name, dir, envId, force, codeSecret, access, httpFn, ws, deployMode, functions, functionRootPath, yes, log } = options;
835854
835942
  let func = functions === null || functions === void 0 ? void 0 : functions.find((item) => item.name === name);
835855
- let funcPath;
835856
- if (dir) {
835857
- (0, utils_1.checkFullAccess)(dir, true);
835858
- if (!(0, utils_1.isDirectory)(dir)) {
835859
- throw new error_1.CloudBaseError((0, i18n_1.t)('--dir 参数必须指定为云函数的文件夹路径'));
835943
+ let funcPath = '';
835944
+ if (deployMode !== 'image') {
835945
+ if (dir) {
835946
+ (0, utils_1.checkFullAccess)(dir, true);
835947
+ if (!(0, utils_1.isDirectory)(dir)) {
835948
+ throw new error_1.CloudBaseError((0, i18n_1.t)('--dir 参数必须指定为云函数的文件夹路径'));
835949
+ }
835950
+ funcPath = path_1.default.resolve(process.cwd(), dir);
835951
+ log.info((0, i18n_1.t)('使用命令行指定的目录:{{path}}', { path: funcPath }));
835952
+ }
835953
+ else if (func === null || func === void 0 ? void 0 : func.dir) {
835954
+ funcPath = path_1.default.resolve(process.cwd(), func.dir);
835955
+ log.info((0, i18n_1.t)('使用配置文件中的目录:{{path}}', { path: funcPath }));
835956
+ }
835957
+ else {
835958
+ funcPath = path_1.default.join(functionRootPath, name);
835959
+ }
835960
+ if (!fs_1.default.existsSync(funcPath)) {
835961
+ throw new error_1.CloudBaseError((0, i18n_1.t)('未找到函数 [{{name}}] 的目录:{{path}},请检查函数名称或使用 --dir 指定函数目录', { name, path: funcPath }));
835860
835962
  }
835861
- funcPath = path_1.default.resolve(process.cwd(), dir);
835862
- log.info((0, i18n_1.t)('使用命令行指定的目录:{{path}}', { path: funcPath }));
835863
- }
835864
- else if (func === null || func === void 0 ? void 0 : func.dir) {
835865
- funcPath = path_1.default.resolve(process.cwd(), func.dir);
835866
- log.info((0, i18n_1.t)('使用配置文件中的目录:{{path}}', { path: funcPath }));
835867
- }
835868
- else {
835869
- funcPath = path_1.default.join(functionRootPath, name);
835870
- }
835871
- if (!fs_1.default.existsSync(funcPath)) {
835872
- throw new error_1.CloudBaseError((0, i18n_1.t)('未找到函数 [{{name}}] 的目录:{{path}},请检查函数名称或使用 --dir 指定函数目录', { name, path: funcPath }));
835873
835963
  }
835874
835964
  if (!func) {
835965
+ (0, common_utils_1.validateImageDeploy)(deployMode, undefined);
835875
835966
  log.warn((0, i18n_1.t)('配置文件中未找到函数 [{{name}}] 的配置', { name }));
835876
835967
  if (yes) {
835877
835968
  const inferredConfig = this.inferFunctionConfig(httpFn, funcPath);
@@ -835914,7 +836005,8 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
835914
836005
  }
835915
836006
  deployWithoutConfig(options) {
835916
836007
  return __awaiter(this, void 0, void 0, function* () {
835917
- const { envId, codeSecret, httpFn, ws, log } = options;
836008
+ const { envId, codeSecret, httpFn, ws, deployMode, log } = options;
836009
+ (0, common_utils_1.validateImageDeploy)(deployMode, false);
835918
836010
  const { deployDir, functionName } = this.resolveFunctionInfo(options);
835919
836011
  log.verbose((0, i18n_1.t)('正在检测云端函数状态...'));
835920
836012
  let checkResult;
@@ -835952,19 +836044,13 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
835952
836044
  }
835953
836045
  resolveFunctionInfo(options) {
835954
836046
  const { name, dir, log } = options;
835955
- let deployDir = process.cwd();
835956
- if (dir) {
835957
- (0, utils_1.checkFullAccess)(dir, true);
835958
- if (!(0, utils_1.isDirectory)(dir)) {
835959
- throw new error_1.CloudBaseError((0, i18n_1.t)('--dir 参数必须指定为云函数的文件夹路径'));
835960
- }
835961
- deployDir = path_1.default.resolve(process.cwd(), dir);
835962
- log.info((0, i18n_1.t)('将从目录 {{dir}} 部署云函数', { dir: deployDir }));
835963
- }
835964
- else {
835965
- log.info((0, i18n_1.t)('未找到配置文件,将从当前目录部署云函数'));
835966
- }
835967
- const functionName = name || path_1.default.basename(deployDir);
836047
+ const deployDir = (0, common_utils_1.resolveAndValidateFunctionDir)({
836048
+ dir,
836049
+ defaultDir: process.cwd(),
836050
+ action: '部署',
836051
+ log
836052
+ });
836053
+ const functionName = (0, common_utils_1.resolveFunctionName)(name, deployDir);
835968
836054
  return { deployDir, functionName };
835969
836055
  }
835970
836056
  handleExistingFunction(checkResult, inferredConfig, isInferred, options, deployDir) {
@@ -835972,7 +836058,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
835972
836058
  const { envId, force, codeSecret, access, deployMode, yes, log } = options;
835973
836059
  const conflicts = this.detectConfigConflicts(inferredConfig, checkResult.functionDetail);
835974
836060
  if (conflicts.length > 0) {
835975
- this.displayConfigConflicts(inferredConfig.name, conflicts);
836061
+ this.displayConfigConflicts(inferredConfig.name, conflicts, log);
835976
836062
  throw new error_1.CloudBaseError((0, i18n_1.t)('配置冲突,无法部署'));
835977
836063
  }
835978
836064
  let shouldUpdate = force || yes;
@@ -835985,7 +836071,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
835985
836071
  }
835986
836072
  const mergedConfig = this.mergeCloudAndLocalConfig(checkResult.functionDetail, inferredConfig);
835987
836073
  log.info((0, i18n_1.t)('✓ 函数已存在,将使用以下合并配置更新:'));
835988
- this.displayMergedConfig(inferredConfig.name, mergedConfig, isInferred ? 'inferred' : 'default');
836074
+ this.displayMergedConfig(inferredConfig.name, mergedConfig, isInferred ? 'inferred' : 'default', log);
835989
836075
  let finalConfig = mergedConfig;
835990
836076
  if (!yes) {
835991
836077
  const { action } = yield inquirer_1.default.prompt({
@@ -836182,7 +836268,11 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
836182
836268
  type: 'confirm',
836183
836269
  name: 'installDependency',
836184
836270
  message: (0, i18n_1.t)('是否在线安装依赖'),
836185
- default: defaultConfig.installDependency
836271
+ default: defaultConfig.installDependency,
836272
+ when: (answers) => {
836273
+ const runtime = answers.runtime || defaultConfig.runtime;
836274
+ return runtime === null || runtime === void 0 ? void 0 : runtime.startsWith('Nodejs');
836275
+ }
836186
836276
  }
836187
836277
  ]);
836188
836278
  const enableWs = isWsFromCli || answers.enableWebSocket;
@@ -836194,7 +836284,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
836194
836284
  dynamicEnabled: 'FALSE',
836195
836285
  maxConcurrency: answers.maxConcurrency
836196
836286
  } : undefined;
836197
- return Object.assign(Object.assign(Object.assign(Object.assign({ name: answers.name.trim(), runtime: answers.runtime, handler: answers.handler, timeout: answers.timeout, memorySize: answers.memorySize, installDependency: answers.installDependency, ignore: defaultConfig.ignore || constant_1.DefaultFunctionDeployConfig.ignore }, (isHttpFnFromCli || answers.isHttpFn ? { type: 'HTTP' } : {})), (protocolType ? { protocolType } : {})), (protocolParams ? { protocolParams } : {})), (instanceConcurrencyConfig ? { instanceConcurrencyConfig } : {}));
836287
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name: answers.name.trim(), runtime: answers.runtime, handler: answers.handler, timeout: answers.timeout, memorySize: answers.memorySize }, (answers.installDependency !== undefined ? { installDependency: answers.installDependency } : {})), { ignore: defaultConfig.ignore || constant_1.DefaultFunctionDeployConfig.ignore }), (isHttpFnFromCli || answers.isHttpFn ? { type: 'HTTP' } : {})), (protocolType ? { protocolType } : {})), (protocolParams ? { protocolParams } : {})), (instanceConcurrencyConfig ? { instanceConcurrencyConfig } : {}));
836198
836288
  });
836199
836289
  }
836200
836290
  promptFunctionName() {
@@ -836214,7 +836304,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
836214
836304
  });
836215
836305
  }
836216
836306
  printFunctionConfig(func, log, source) {
836217
- var _a, _b;
836307
+ var _a, _b, _c;
836218
836308
  if (source) {
836219
836309
  log.info((0, i18n_1.t)('配置来源:{{source}}', { source }));
836220
836310
  }
@@ -836225,12 +836315,14 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
836225
836315
  if (func.memorySize) {
836226
836316
  log.info((0, i18n_1.t)(' - 内存大小:{{memorySize}} MB', { memorySize: func.memorySize }));
836227
836317
  }
836228
- log.info((0, i18n_1.t)(' - 在线安装依赖:{{installDependency}}', { installDependency: func.installDependency ? (0, i18n_1.t)('') : (0, i18n_1.t)('否') }));
836318
+ if (((_a = func.runtime) === null || _a === void 0 ? void 0 : _a.startsWith('Nodejs')) && func.installDependency !== undefined) {
836319
+ log.info((0, i18n_1.t)(' - 在线安装依赖:{{installDependency}}', { installDependency: func.installDependency ? (0, i18n_1.t)('是') : (0, i18n_1.t)('否') }));
836320
+ }
836229
836321
  if (func.type === 'HTTP') {
836230
836322
  log.info((0, i18n_1.t)(' - 函数类型:HTTP'));
836231
836323
  if (func.protocolType === 'WS') {
836232
836324
  log.info((0, i18n_1.t)(' - WebSocket 协议:已启用'));
836233
- const idleTimeOut = (_b = (_a = func.protocolParams) === null || _a === void 0 ? void 0 : _a.wsParams) === null || _b === void 0 ? void 0 : _b.idleTimeOut;
836325
+ const idleTimeOut = (_c = (_b = func.protocolParams) === null || _b === void 0 ? void 0 : _b.wsParams) === null || _c === void 0 ? void 0 : _c.idleTimeOut;
836234
836326
  if (idleTimeOut) {
836235
836327
  log.info((0, i18n_1.t)(' - 空闲超时时间:{{seconds}} 秒', { seconds: idleTimeOut }));
836236
836328
  }
@@ -836301,7 +836393,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
836301
836393
  const { func, envId, force, codeSecret, access, deployMode, functionRootPath, functionPath, yes, log, preCheckResult } = options;
836302
836394
  let finalFunc = Object.assign({}, func);
836303
836395
  if (deployMode === 'image') {
836304
- const fileImageConfig = (0, function_2.buildImageConfigFromConfig)(func);
836396
+ const fileImageConfig = buildImageConfig(func);
836305
836397
  if (fileImageConfig) {
836306
836398
  finalFunc.imageConfig = fileImageConfig;
836307
836399
  }
@@ -836311,7 +836403,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
836311
836403
  }
836312
836404
  if (finalFunc.type === 'HTTP' && deployMode !== 'image') {
836313
836405
  const funcPath = functionPath === '.' ? process.cwd() : (functionPath || path_1.default.join(functionRootPath, finalFunc.name));
836314
- const shouldContinue = yield (0, function_1.checkAndCreateBootstrap)(funcPath, finalFunc);
836406
+ const shouldContinue = yield checkWebFunctionBootstrap(funcPath, finalFunc);
836315
836407
  if (!shouldContinue) {
836316
836408
  return;
836317
836409
  }
@@ -836466,7 +836558,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
836466
836558
  funcWithType = Object.assign(Object.assign({}, funcWithType), { type: 'HTTP', protocolType: 'WS' });
836467
836559
  }
836468
836560
  if (deployMode === 'image') {
836469
- const fileImageConfig = (0, function_2.buildImageConfigFromConfig)(funcWithType);
836561
+ const fileImageConfig = buildImageConfig(funcWithType);
836470
836562
  if (fileImageConfig) {
836471
836563
  funcWithType = Object.assign(Object.assign({}, funcWithType), { imageConfig: fileImageConfig });
836472
836564
  }
@@ -836475,21 +836567,24 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
836475
836567
  return { status: 'skipped', name: func.name };
836476
836568
  }
836477
836569
  }
836478
- const funcPath = func.dir
836479
- ? path_1.default.resolve(process.cwd(), func.dir)
836480
- : path_1.default.join(functionRootPath, func.name);
836570
+ const funcPath = resolveFunctionPath({
836571
+ functionRootPath,
836572
+ functionName: func.name,
836573
+ functionDirFromConfig: func.dir
836574
+ });
836481
836575
  if (deployMode !== 'image' && !fs_1.default.existsSync(funcPath)) {
836482
836576
  log.error((0, i18n_1.t)('未找到函数 [{{name}}] 的目录:{{path}},已跳过', { name: func.name, path: funcPath }));
836483
836577
  return { status: 'skipped', name: func.name };
836484
836578
  }
836485
836579
  if (funcWithType.type === 'HTTP' && deployMode !== 'image') {
836486
- const shouldContinue = yield (0, function_1.checkAndCreateBootstrap)(funcPath, funcWithType);
836580
+ const shouldContinue = yield checkWebFunctionBootstrap(funcPath, funcWithType);
836487
836581
  if (!shouldContinue) {
836488
836582
  log.warn((0, i18n_1.t)('[{{name}}] 已跳过部署', { name: func.name }));
836489
836583
  return { status: 'skipped', name: func.name };
836490
836584
  }
836491
836585
  }
836492
836586
  loading.start((0, i18n_1.t)('云函数部署中'));
836587
+ let deployError = null;
836493
836588
  try {
836494
836589
  yield (0, function_1.createFunction)({
836495
836590
  func: funcWithType,
@@ -836505,32 +836600,33 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
836505
836600
  return { status: 'success', name: func.name };
836506
836601
  }
836507
836602
  catch (e) {
836603
+ deployError = e;
836508
836604
  loading.stop();
836509
- try {
836510
- const result = yield this.handleDeployFail(e, {
836511
- func: funcWithType,
836512
- envId,
836513
- force,
836514
- codeSecret,
836515
- functionRootPath,
836516
- functionPath: func.dir ? funcPath : undefined,
836517
- accessPath: access,
836518
- yes: yes || force || functionsToOverwrite.has(func.name),
836519
- batchMode: true,
836520
- logger: log,
836521
- deployMode
836522
- });
836523
- return { status: result || 'error', name: func.name };
836524
- }
836525
- catch (handleError) {
836526
- return { status: 'error', name: func.name, error: handleError };
836527
- }
836605
+ }
836606
+ try {
836607
+ const result = yield this.handleDeployFail(deployError, {
836608
+ func: funcWithType,
836609
+ envId,
836610
+ force,
836611
+ codeSecret,
836612
+ functionRootPath,
836613
+ functionPath: func.dir ? funcPath : undefined,
836614
+ accessPath: access,
836615
+ yes: yes || force || functionsToOverwrite.has(func.name),
836616
+ batchMode: true,
836617
+ logger: log,
836618
+ deployMode
836619
+ });
836620
+ return { status: result || 'error', name: func.name };
836621
+ }
836622
+ catch (handleError) {
836623
+ return { status: 'error', name: func.name, error: handleError };
836528
836624
  }
836529
836625
  }));
836530
836626
  if (tasks.length > 5) {
836531
836627
  log.info((0, i18n_1.t)('函数数量较多,将使用队列部署'));
836532
836628
  }
836533
- const asyncTaskController = new utils_1.AsyncTaskParallelController(5, 50);
836629
+ const asyncTaskController = new utils_1.AsyncTaskParallelController(MAX_PARALLEL_DEPLOY, 50);
836534
836630
  asyncTaskController.loadTasks(tasks);
836535
836631
  const rawResults = yield asyncTaskController.run();
836536
836632
  const results = rawResults.map((r, index) => {
@@ -836621,7 +836717,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
836621
836717
  }
836622
836718
  const conflicts = this.detectConfigConflicts(func, existingFunction);
836623
836719
  if (conflicts.length > 0) {
836624
- this.displayConfigConflicts(func.name, conflicts);
836720
+ this.displayConfigConflicts(func.name, conflicts, log);
836625
836721
  return 'error';
836626
836722
  }
836627
836723
  func = this.mergeCloudAndLocalConfig(existingFunction, func);
@@ -836966,7 +837062,22 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
836966
837062
  }
836967
837063
  }
836968
837064
  getSpecificSuggestions(error, context = {}) {
837065
+ var _a, _b;
836969
837066
  const { functionName } = context;
837067
+ if (((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('COS 上传失败')) || ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('上传失败'))) {
837068
+ const suggestions = [(0, i18n_1.t)('检查网络连接是否正常')];
837069
+ if (error.code === 'AccessDenied') {
837070
+ suggestions.push((0, i18n_1.t)('签名或权限不正确,拒绝访问'));
837071
+ suggestions.push((0, i18n_1.t)('运行 {{command}} 重新登录', { command: (0, utils_1.highlightCommand)('tcb login') }));
837072
+ }
837073
+ else if (error.code === 'NoSuchBucket') {
837074
+ suggestions.push((0, i18n_1.t)('指定的存储桶不存在,请检查环境配置'));
837075
+ }
837076
+ else if (error.code === 'RequestTimeout') {
837077
+ suggestions.push((0, i18n_1.t)('请求超时,可能是文件过大或网络不稳定'));
837078
+ }
837079
+ return suggestions;
837080
+ }
836970
837081
  if (error.code === 'Forbidden' || error.code === 'Unauthorized' ||
836971
837082
  error.code === 'AuthFailure' || error.code === 'UnauthorizedOperation') {
836972
837083
  return [
@@ -837029,33 +837140,35 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
837029
837140
  }
837030
837141
  });
837031
837142
  }
837032
- displayConfigConflicts(functionName, conflicts) {
837033
- utils_1.logger.error((0, i18n_1.t)('函数 [{{name}}] 存在配置冲突:', { name: functionName }));
837143
+ displayConfigConflicts(functionName, conflicts, log) {
837144
+ const activeLogger = log || utils_1.logger;
837145
+ activeLogger.error((0, i18n_1.t)('函数 [{{name}}] 存在配置冲突:', { name: functionName }));
837034
837146
  conflicts.forEach((conflict) => {
837035
- utils_1.logger.error(` ✗ ${conflict.field}: 云端 ${conflict.cloudValue} ≠ 本地 ${conflict.localValue}`);
837036
- utils_1.logger.error(` ${conflict.message}`);
837147
+ activeLogger.error(` ✗ ${conflict.field}: 云端 ${conflict.cloudValue} ≠ 本地 ${conflict.localValue}`);
837148
+ activeLogger.error(` ${conflict.message}`);
837037
837149
  });
837038
- utils_1.logger.info((0, i18n_1.t)('解决建议:'));
837039
- utils_1.logger.info((0, i18n_1.t)(' 1. 修改本地配置使其与云端一致'));
837040
- utils_1.logger.info((0, i18n_1.t)(' 2. 删除云端函数后重新创建'));
837041
- utils_1.logger.info((0, i18n_1.t)(' 3. 使用 {{command}} 查看云端配置', {
837150
+ activeLogger.info((0, i18n_1.t)('解决建议:'));
837151
+ activeLogger.info((0, i18n_1.t)(' 1. 修改本地配置使其与云端一致'));
837152
+ activeLogger.info((0, i18n_1.t)(' 2. 删除云端函数后重新创建'));
837153
+ activeLogger.info((0, i18n_1.t)(' 3. 使用 {{command}} 查看云端配置', {
837042
837154
  command: (0, utils_1.highlightCommand)(`tcb fn detail ${functionName}`)
837043
837155
  }));
837044
837156
  }
837045
- displayMergedConfig(functionName, config, source) {
837046
- utils_1.logger.info((0, i18n_1.t)('函数 [{{name}}] 最终配置:', { name: functionName }));
837047
- utils_1.logger.info(` ${(0, i18n_1.t)('类型')}: ${config.type || 'Event'}`);
837048
- utils_1.logger.info(` ${(0, i18n_1.t)('运行时')}: ${config.runtime}`);
837049
- utils_1.logger.info(` ${(0, i18n_1.t)('入口')}: ${config.handler}`);
837157
+ displayMergedConfig(functionName, config, source, log) {
837158
+ const activeLogger = log || utils_1.logger;
837159
+ activeLogger.info((0, i18n_1.t)('函数 [{{name}}] 最终配置:', { name: functionName }));
837160
+ activeLogger.info(` ${(0, i18n_1.t)('类型')}: ${config.type || 'Event'}`);
837161
+ activeLogger.info(` ${(0, i18n_1.t)('运行时')}: ${config.runtime}`);
837162
+ activeLogger.info(` ${(0, i18n_1.t)('入口')}: ${config.handler}`);
837050
837163
  if (config.memorySize) {
837051
- utils_1.logger.info(` ${(0, i18n_1.t)('内存')}: ${config.memorySize}MB`);
837164
+ activeLogger.info(` ${(0, i18n_1.t)('内存')}: ${config.memorySize}MB`);
837052
837165
  }
837053
- utils_1.logger.info(` ${(0, i18n_1.t)('超时')}: ${config.timeout}s`);
837166
+ activeLogger.info(` ${(0, i18n_1.t)('超时')}: ${config.timeout}s`);
837054
837167
  if (source === 'inferred') {
837055
- utils_1.logger.info((0, i18n_1.t)(' (配置来源: 智能推测)'));
837168
+ activeLogger.info((0, i18n_1.t)(' (配置来源: 智能推测)'));
837056
837169
  }
837057
837170
  else if (source === 'default') {
837058
- utils_1.logger.info((0, i18n_1.t)(' (配置来源: 默认配置)'));
837171
+ activeLogger.info((0, i18n_1.t)(' (配置来源: 默认配置)'));
837059
837172
  }
837060
837173
  }
837061
837174
  confirmUpdate(functionName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cli",
3
- "version": "2.12.6",
3
+ "version": "2.12.7",
4
4
  "description": "CLI for Tencent CloudBase (standalone bundle)",
5
5
  "bin": {
6
6
  "tcb": "bin/tcb",