@cloudbase/cli 2.12.5-beta.2 → 2.12.5-beta.3

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.
@@ -326169,7 +326169,7 @@ module.exports = function generate_pattern(it, $keyword, $ruleType) {
326169
326169
  /***/ ((module) => {
326170
326170
 
326171
326171
  "use strict";
326172
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.12.5-beta.2","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.7.4","@cloudbase/toolbox":"0.7.17-beta.1","@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 - 腾讯云云开发命令行工具,支持云函数、云数据库、静态托管等全栈云开发能力"}}');
326172
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.12.5-beta.3","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.7.4","@cloudbase/toolbox":"0.7.17-beta.3","@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 - 腾讯云云开发命令行工具,支持云函数、云数据库、静态托管等全栈云开发能力"}}');
326173
326173
 
326174
326174
  /***/ }),
326175
326175
 
@@ -398369,7 +398369,7 @@ class AuthSupervisor {
398369
398369
  */
398370
398370
  loginByWebAuth(options = {}) {
398371
398371
  return __awaiter(this, void 0, void 0, function* () {
398372
- const { getAuthUrl, throwError, noBrowser, callbackTimeout, mode: AuthFlowMode, client_id, onDeviceCode } = options;
398372
+ const { getAuthUrl, throwError, noBrowser, callbackTimeout, flow = 'device', client_id, onDeviceCode, getOAuthEndpoint, silent } = options;
398373
398373
  if (this.cacheCredential && this.needCache && !this.isCacheExpire()) {
398374
398374
  return this.cacheCredential;
398375
398375
  }
@@ -398378,15 +398378,16 @@ class AuthSupervisor {
398378
398378
  if (credential)
398379
398379
  return credential;
398380
398380
  // 根据授权方式获取凭证
398381
- if (AuthFlowMode === 'web') {
398381
+ if (flow === 'web') {
398382
398382
  credential = yield (0, web_auth_1.getAuthTokenFromWeb)({
398383
398383
  getAuthUrl,
398384
398384
  noBrowser,
398385
- callbackTimeout
398385
+ callbackTimeout,
398386
+ silent
398386
398387
  });
398387
398388
  }
398388
398389
  else {
398389
- credential = yield (0, oauth_1.getAuthTokenByDeviceFlow)({ client_id, onDeviceCode });
398390
+ credential = yield (0, oauth_1.getAuthTokenByDeviceFlow)({ client_id, onDeviceCode, getOAuthEndpoint, getAuthUrl, silent });
398390
398391
  }
398391
398392
  credential = (0, common_1.resolveCredential)(credential);
398392
398393
  try {
@@ -410393,17 +410394,20 @@ function openUrl(url) {
410393
410394
  exports.openUrl = openUrl;
410394
410395
  // 从 Web 页面中获取数据
410395
410396
  function getDataFromWeb(getUrl, type, options = {}) {
410396
- var _a, _b;
410397
+ var _a, _b, _c;
410397
410398
  return __awaiter(this, void 0, void 0, function* () {
410398
410399
  const { server, port } = yield createLocalServer();
410399
410400
  const noBrowser = (_a = options.noBrowser) !== null && _a !== void 0 ? _a : isTruthyFlag(process.env.TCB_NO_BROWSER);
410400
410401
  const callbackTimeout = (_b = options.callbackTimeout) !== null && _b !== void 0 ? _b : 180000;
410402
+ const silent = (_c = options.silent) !== null && _c !== void 0 ? _c : false;
410401
410403
  if (!Number.isFinite(callbackTimeout) || callbackTimeout <= 0) {
410402
410404
  throw new error_1.CloudBaseError('callbackTimeout must be a positive number');
410403
410405
  }
410404
410406
  const url = getUrl(port);
410405
- console.log('\n\n若链接未自动打开,请手动复制至浏览器,或尝试其他登录方式:');
410406
- console.log(`\n${url}\n`);
410407
+ if (!silent) {
410408
+ console.log('\n\n若链接未自动打开,请手动复制至浏览器,或尝试其他登录方式:');
410409
+ console.log(`\n${url}\n`);
410410
+ }
410407
410411
  if (!noBrowser) {
410408
410412
  // 对 url 转码, 避免 wsl 无法正常打开地址
410409
410413
  // https://www.npmjs.com/package/open#url
@@ -440076,16 +440080,23 @@ const LoginRes = {
440076
440080
  };
440077
440081
  }
440078
440082
  };
440079
- function loginByWebAuth() {
440083
+ function loginByWebAuth({ flow } = {}) {
440080
440084
  return __awaiter(this, void 0, void 0, function* () {
440081
440085
  try {
440082
440086
  const credential = yield utils_1.authSupevisor.loginByWebAuth({
440087
+ flow,
440083
440088
  getAuthUrl: (rawUrl) => {
440084
440089
  if ((0, i18n_1.isIntl)()) {
440085
440090
  return rawUrl.replace('https://tcb.cloud.tencent.com/dev', utils_1.EUrl.DevPlatform);
440086
440091
  }
440087
440092
  return rawUrl;
440088
- }
440093
+ },
440094
+ getOAuthEndpoint: (rawEndpoint) => {
440095
+ if ((0, i18n_1.isIntl)()) {
440096
+ return rawEndpoint.replace('https://tcb-api.cloud.tencent.com', 'https://tcb-api.tencentcloud.com');
440097
+ }
440098
+ return rawEndpoint;
440099
+ },
440089
440100
  });
440090
440101
  if (lodash_1.default.isEmpty(credential)) {
440091
440102
  return LoginRes.INVALID_TOKEN;
@@ -440093,9 +440104,6 @@ function loginByWebAuth() {
440093
440104
  return Object.assign({ credential }, LoginRes.SUCCESS);
440094
440105
  }
440095
440106
  catch (error) {
440096
- console.error((0, i18n_1.t)('Web 授权登录失败,可能是环境兼容性问题'));
440097
- console.error((0, i18n_1.t)('建议使用密钥登录:tcb login --key'));
440098
- console.error((0, i18n_1.t)('详细说明请参考:{{url}}', { url: 'https://docs.cloudbase.net/cli-v1/login#%E8%85%BE%E8%AE%AF%E4%BA%91-%E4%BA%91%E5%BC%80%E5%8F%91%E6%8E%A7%E5%88%B6%E5%8F%B0%E6%8E%88%E6%9D%83' }));
440099
440107
  return {
440100
440108
  code: 'WEB_AUTH_FAILED',
440101
440109
  msg: (0, i18n_1.t)('Web 授权登录失败,请使用密钥登录:tcb login --key'),
@@ -440120,8 +440128,8 @@ function loginWithKey(secretId, secretKey, token) {
440120
440128
  exports.loginWithKey = loginWithKey;
440121
440129
  function login(options = {}) {
440122
440130
  return __awaiter(this, void 0, void 0, function* () {
440123
- const { secretId, secretKey, key, token } = options;
440124
- return key ? loginWithKey(secretId, secretKey, token) : loginByWebAuth();
440131
+ const { secretId, secretKey, key, token, flow } = options;
440132
+ return key ? loginWithKey(secretId, secretKey, token) : loginByWebAuth({ flow });
440125
440133
  });
440126
440134
  }
440127
440135
  exports.login = login;
@@ -743409,7 +743417,7 @@ exports.CLI_AUTH_BASE_URL = 'https://tcb.cloud.tencent.com/dev';
743409
743417
  // 打开云开发控制台,获取授权
743410
743418
  function getAuthTokenFromWeb(options = {}) {
743411
743419
  return __awaiter(this, void 0, void 0, function* () {
743412
- const { getAuthUrl, noBrowser, callbackTimeout } = options;
743420
+ const { getAuthUrl, noBrowser, callbackTimeout, silent } = options;
743413
743421
  const mac = yield (0, system_1.getMacAddress)();
743414
743422
  const os = (0, system_1.getOSInfo)();
743415
743423
  const macHash = (0, coding_1.md5Encoding)(mac);
@@ -743435,7 +743443,8 @@ function getAuthTokenFromWeb(options = {}) {
743435
743443
  return cliAuthUrl;
743436
743444
  }, 'login', {
743437
743445
  noBrowser,
743438
- callbackTimeout
743446
+ callbackTimeout,
743447
+ silent
743439
743448
  });
743440
743449
  const credential = (0, common_1.resolveCredential)(query);
743441
743450
  return credential;
@@ -866675,6 +866684,7 @@ const error_1 = __webpack_require__(64119);
866675
866684
  const coding_1 = __webpack_require__(40540);
866676
866685
  const system_1 = __webpack_require__(62179);
866677
866686
  const web_auth_1 = __webpack_require__(76097);
866687
+ /** 默认国内站 应用侧可通过 getOAuthEndpoint 覆写 */
866678
866688
  const OAUTH_ENDPOINT = process.env.TCB_OAUTH_ENDPOINT || 'https://tcb-api.cloud.tencent.com/qcloud-tcb/v1/oauth';
866679
866689
  const DEFAULT_CLIENT_ID = 'cloudbase-toolbox';
866680
866690
  const POLL_ERROR_CODES = {
@@ -866685,14 +866695,14 @@ const POLL_ERROR_CODES = {
866685
866695
  };
866686
866696
  const SUCCESS_CODE = 'NORMAL';
866687
866697
  function fetchDeviceCode(options = {}) {
866688
- const { client_id = DEFAULT_CLIENT_ID } = options;
866689
- return (0, net_1.postFetch)(`${OAUTH_ENDPOINT}/device/code`, { client_id });
866698
+ const { client_id = DEFAULT_CLIENT_ID, endpoint = OAUTH_ENDPOINT } = options;
866699
+ return (0, net_1.postFetch)(`${endpoint}/device/code`, { client_id });
866690
866700
  }
866691
866701
  function fetchPollToken(options) {
866692
866702
  return __awaiter(this, void 0, void 0, function* () {
866693
- const { device_code, client_id = DEFAULT_CLIENT_ID } = options;
866703
+ const { device_code, client_id = DEFAULT_CLIENT_ID, endpoint = OAUTH_ENDPOINT } = options;
866694
866704
  const mac = yield (0, system_1.getMacAddress)();
866695
- return (0, net_1.postFetch)(`${OAUTH_ENDPOINT}/token`, {
866705
+ return (0, net_1.postFetch)(`${endpoint}/token`, {
866696
866706
  device_code,
866697
866707
  client_id,
866698
866708
  grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
@@ -866711,8 +866721,9 @@ function sleep(ms) {
866711
866721
  }
866712
866722
  function getAuthTokenByDeviceFlow(options = {}) {
866713
866723
  return __awaiter(this, void 0, void 0, function* () {
866714
- const { client_id, onDeviceCode } = options;
866715
- const deviceCodeResp = yield fetchDeviceCode({ client_id });
866724
+ const { client_id, onDeviceCode, getOAuthEndpoint, getAuthUrl, silent } = options;
866725
+ const endpoint = getOAuthEndpoint ? getOAuthEndpoint(OAUTH_ENDPOINT) : OAUTH_ENDPOINT;
866726
+ const deviceCodeResp = yield fetchDeviceCode({ client_id, endpoint });
866716
866727
  if (deviceCodeResp.code !== SUCCESS_CODE) {
866717
866728
  throw new error_1.CloudBaseError('Device Flow fetchDeviceCode failed', {
866718
866729
  code: deviceCodeResp.code,
@@ -866720,15 +866731,17 @@ function getAuthTokenByDeviceFlow(options = {}) {
866720
866731
  });
866721
866732
  }
866722
866733
  const { device_code, user_code, expires_in, interval } = deviceCodeResp.result;
866723
- // const defaultVerificationUri = deviceCodeResp.result.verification_uri || `${CLI_AUTH_BASE_URL}#/cli-auth`;
866724
866734
  // 暂时不消费 verification_uri,由客户端控制跳转
866725
866735
  const defaultVerificationUri = `${web_auth_1.CLI_AUTH_BASE_URL}#/cli-auth`;
866726
866736
  // from=cli 后续考虑改用 client_id,因为 toolbox 作为公共依赖,可能被不同 client 所引用
866727
- const verification_uri = `${defaultVerificationUri}?user_code=${user_code}&from=cli&mode=device`;
866728
- // 打印授权信息,引导用户操作
866729
- console.log('\n\n若链接未自动打开,请手动复制至浏览器,或尝试其他登录方式:');
866730
- console.log(`\n${verification_uri}`);
866731
- console.log(`\n用户码: ${user_code}\n`);
866737
+ const rawVerificationUri = `${defaultVerificationUri}?user_code=${user_code}&from=cli&flow=device`;
866738
+ const verification_uri = getAuthUrl ? getAuthUrl(rawVerificationUri) : rawVerificationUri;
866739
+ if (!silent) {
866740
+ // 打印授权信息,引导用户操作
866741
+ console.log('\n\n若链接未自动打开,请手动复制至浏览器,或尝试其他登录方式:');
866742
+ console.log(`\n${verification_uri}`);
866743
+ console.log(`\n用户码: ${user_code}\n`);
866744
+ }
866732
866745
  // 尝试自动打开授权页面
866733
866746
  yield (0, web_1.openUrl)(verification_uri);
866734
866747
  if (onDeviceCode) {
@@ -866740,7 +866753,7 @@ function getAuthTokenByDeviceFlow(options = {}) {
866740
866753
  yield sleep(pollInterval * 1000);
866741
866754
  let resp;
866742
866755
  try {
866743
- resp = yield fetchPollToken({ device_code, interval: pollInterval, client_id });
866756
+ resp = yield fetchPollToken({ device_code, interval: pollInterval, client_id, endpoint });
866744
866757
  }
866745
866758
  catch (e) {
866746
866759
  throw new error_1.CloudBaseError('Device Flow 轮询请求失败', { original: e });
@@ -913213,6 +913226,10 @@ let LoginCommand = class LoginCommand extends common_1.Command {
913213
913226
  {
913214
913227
  flags: '--token [token]',
913215
913228
  desc: (0, i18n_1.t)('腾讯云 API 临时秘钥 Token')
913229
+ },
913230
+ {
913231
+ flags: '--flow <flow>',
913232
+ desc: (0, i18n_1.t)('Web 登录授权方式(device 或 web),默认 device')
913216
913233
  }
913217
913234
  ],
913218
913235
  desc: (0, i18n_1.t)('登录腾讯云账号'),
@@ -913223,7 +913240,7 @@ let LoginCommand = class LoginCommand extends common_1.Command {
913223
913240
  execute(options, log) {
913224
913241
  return __awaiter(this, void 0, void 0, function* () {
913225
913242
  log.verbose(options);
913226
- const { apiKeyId, apiKey, token } = options;
913243
+ const { apiKeyId, apiKey, token, flow } = options;
913227
913244
  const loading = (0, utils_1.loadingFactory)();
913228
913245
  loading.start((0, i18n_1.t)('检验登录状态'));
913229
913246
  const credential = yield (0, utils_1.checkAndGetCredential)();
@@ -913285,7 +913302,7 @@ let LoginCommand = class LoginCommand extends common_1.Command {
913285
913302
  }
913286
913303
  else {
913287
913304
  loading.start((0, i18n_1.t)('请在浏览器中打开的授权页面进行授权...'));
913288
- const res = yield (0, auth_1.login)();
913305
+ const res = yield (0, auth_1.login)({ flow });
913289
913306
  if (res.code === 'SUCCESS') {
913290
913307
  loading.succeed((0, i18n_1.t)('登录成功!'));
913291
913308
  yield askForCollectDataConfirm();
@@ -913293,6 +913310,9 @@ let LoginCommand = class LoginCommand extends common_1.Command {
913293
913310
  }
913294
913311
  else if (res.code === 'WEB_AUTH_FAILED') {
913295
913312
  loading.fail((0, i18n_1.t)('Web 授权登录失败'));
913313
+ if (res.error) {
913314
+ log.error(res.error);
913315
+ }
913296
913316
  console.log(chalk_1.default.yellow((0, i18n_1.t)('⚠️ 检测到环境兼容性问题')));
913297
913317
  console.log(chalk_1.default.cyan((0, i18n_1.t)('建议使用密钥登录:')));
913298
913318
  console.log(chalk_1.default.cyan((0, i18n_1.t)('tcb login --key')));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cli",
3
- "version": "2.12.5-beta.2",
3
+ "version": "2.12.5-beta.3",
4
4
  "description": "CLI for Tencent CloudBase (standalone bundle)",
5
5
  "bin": {
6
6
  "tcb": "bin/tcb",