@cloudbase/cli 2.12.5 → 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.
- package/dist/standalone/cli.js +424 -150
- package/package.json +1 -1
package/dist/standalone/cli.js
CHANGED
|
@@ -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.
|
|
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
|
|
|
@@ -398398,12 +398472,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
398398
398472
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
398399
398473
|
exports.AuthSupevisor = exports.AuthSupervisor = void 0;
|
|
398400
398474
|
const web_auth_1 = __webpack_require__(76097);
|
|
398475
|
+
const oauth_1 = __webpack_require__(92423);
|
|
398401
398476
|
const common_1 = __webpack_require__(96711);
|
|
398402
398477
|
const credential_1 = __webpack_require__(99795);
|
|
398403
398478
|
const error_1 = __webpack_require__(64119);
|
|
398404
398479
|
__exportStar(__webpack_require__(96711), exports);
|
|
398405
398480
|
__exportStar(__webpack_require__(99795), exports);
|
|
398406
398481
|
__exportStar(__webpack_require__(76097), exports);
|
|
398482
|
+
__exportStar(__webpack_require__(92423), exports);
|
|
398407
398483
|
class AuthSupervisor {
|
|
398408
398484
|
/**
|
|
398409
398485
|
* 单例模式,全局缓存
|
|
@@ -398453,7 +398529,7 @@ class AuthSupervisor {
|
|
|
398453
398529
|
*/
|
|
398454
398530
|
loginByWebAuth(options = {}) {
|
|
398455
398531
|
return __awaiter(this, void 0, void 0, function* () {
|
|
398456
|
-
const { getAuthUrl, throwError, noBrowser, callbackTimeout } = options;
|
|
398532
|
+
const { getAuthUrl, throwError, noBrowser, callbackTimeout, flow = 'device', client_id, onDeviceCode, getOAuthEndpoint, silent } = options;
|
|
398457
398533
|
if (this.cacheCredential && this.needCache && !this.isCacheExpire()) {
|
|
398458
398534
|
return this.cacheCredential;
|
|
398459
398535
|
}
|
|
@@ -398461,12 +398537,19 @@ class AuthSupervisor {
|
|
|
398461
398537
|
let credential = yield (0, credential_1.checkAndGetCredential)(this.requestConfig);
|
|
398462
398538
|
if (credential)
|
|
398463
398539
|
return credential;
|
|
398464
|
-
//
|
|
398465
|
-
|
|
398466
|
-
|
|
398467
|
-
|
|
398468
|
-
|
|
398469
|
-
|
|
398540
|
+
// 根据授权方式获取凭证
|
|
398541
|
+
if (flow === 'web') {
|
|
398542
|
+
credential = yield (0, web_auth_1.getAuthTokenFromWeb)({
|
|
398543
|
+
getAuthUrl,
|
|
398544
|
+
noBrowser,
|
|
398545
|
+
callbackTimeout,
|
|
398546
|
+
silent
|
|
398547
|
+
});
|
|
398548
|
+
}
|
|
398549
|
+
else {
|
|
398550
|
+
credential = yield (0, oauth_1.getAuthTokenByDeviceFlow)({ client_id, onDeviceCode, getOAuthEndpoint, getAuthUrl, silent });
|
|
398551
|
+
}
|
|
398552
|
+
credential = (0, common_1.resolveCredential)(credential);
|
|
398470
398553
|
try {
|
|
398471
398554
|
yield (0, common_1.checkAuth)(credential, this.requestConfig);
|
|
398472
398555
|
}
|
|
@@ -410365,7 +410448,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
410365
410448
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
410366
410449
|
};
|
|
410367
410450
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
410368
|
-
exports.getDataFromWeb = void 0;
|
|
410451
|
+
exports.getDataFromWeb = exports.openUrl = exports.isTruthyFlag = void 0;
|
|
410369
410452
|
const open_1 = __importDefault(__webpack_require__(30353));
|
|
410370
410453
|
const query_string_1 = __importDefault(__webpack_require__(86663));
|
|
410371
410454
|
const http_1 = __importDefault(__webpack_require__(58611));
|
|
@@ -410412,6 +410495,7 @@ function isTruthyFlag(value) {
|
|
|
410412
410495
|
}
|
|
410413
410496
|
return ['1', 'true', 'yes', 'on'].includes(String(value).trim().toLowerCase());
|
|
410414
410497
|
}
|
|
410498
|
+
exports.isTruthyFlag = isTruthyFlag;
|
|
410415
410499
|
function isVSCodeEnvironment() {
|
|
410416
410500
|
return Boolean(process.env.VSCODE_IPC_HOOK_CLI
|
|
410417
410501
|
|| process.env.VSCODE_PID
|
|
@@ -410467,19 +410551,23 @@ function openUrl(url) {
|
|
|
410467
410551
|
}
|
|
410468
410552
|
});
|
|
410469
410553
|
}
|
|
410554
|
+
exports.openUrl = openUrl;
|
|
410470
410555
|
// 从 Web 页面中获取数据
|
|
410471
410556
|
function getDataFromWeb(getUrl, type, options = {}) {
|
|
410472
|
-
var _a, _b;
|
|
410557
|
+
var _a, _b, _c;
|
|
410473
410558
|
return __awaiter(this, void 0, void 0, function* () {
|
|
410474
410559
|
const { server, port } = yield createLocalServer();
|
|
410475
410560
|
const noBrowser = (_a = options.noBrowser) !== null && _a !== void 0 ? _a : isTruthyFlag(process.env.TCB_NO_BROWSER);
|
|
410476
410561
|
const callbackTimeout = (_b = options.callbackTimeout) !== null && _b !== void 0 ? _b : 180000;
|
|
410562
|
+
const silent = (_c = options.silent) !== null && _c !== void 0 ? _c : false;
|
|
410477
410563
|
if (!Number.isFinite(callbackTimeout) || callbackTimeout <= 0) {
|
|
410478
410564
|
throw new error_1.CloudBaseError('callbackTimeout must be a positive number');
|
|
410479
410565
|
}
|
|
410480
410566
|
const url = getUrl(port);
|
|
410481
|
-
|
|
410482
|
-
|
|
410567
|
+
if (!silent) {
|
|
410568
|
+
console.log('\n\n若链接未自动打开,请手动复制至浏览器,或尝试其他登录方式:');
|
|
410569
|
+
console.log(`\n${url}\n`);
|
|
410570
|
+
}
|
|
410483
410571
|
if (!noBrowser) {
|
|
410484
410572
|
// 对 url 转码, 避免 wsl 无法正常打开地址
|
|
410485
410573
|
// https://www.npmjs.com/package/open#url
|
|
@@ -440152,16 +440240,23 @@ const LoginRes = {
|
|
|
440152
440240
|
};
|
|
440153
440241
|
}
|
|
440154
440242
|
};
|
|
440155
|
-
function loginByWebAuth() {
|
|
440243
|
+
function loginByWebAuth({ flow } = {}) {
|
|
440156
440244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
440157
440245
|
try {
|
|
440158
440246
|
const credential = yield utils_1.authSupevisor.loginByWebAuth({
|
|
440247
|
+
flow,
|
|
440159
440248
|
getAuthUrl: (rawUrl) => {
|
|
440160
440249
|
if ((0, i18n_1.isIntl)()) {
|
|
440161
440250
|
return rawUrl.replace('https://tcb.cloud.tencent.com/dev', utils_1.EUrl.DevPlatform);
|
|
440162
440251
|
}
|
|
440163
440252
|
return rawUrl;
|
|
440164
|
-
}
|
|
440253
|
+
},
|
|
440254
|
+
getOAuthEndpoint: (rawEndpoint) => {
|
|
440255
|
+
if ((0, i18n_1.isIntl)()) {
|
|
440256
|
+
return rawEndpoint.replace('https://tcb-api.cloud.tencent.com', 'https://tcb-api.tencentcloud.com');
|
|
440257
|
+
}
|
|
440258
|
+
return rawEndpoint;
|
|
440259
|
+
},
|
|
440165
440260
|
});
|
|
440166
440261
|
if (lodash_1.default.isEmpty(credential)) {
|
|
440167
440262
|
return LoginRes.INVALID_TOKEN;
|
|
@@ -440169,9 +440264,6 @@ function loginByWebAuth() {
|
|
|
440169
440264
|
return Object.assign({ credential }, LoginRes.SUCCESS);
|
|
440170
440265
|
}
|
|
440171
440266
|
catch (error) {
|
|
440172
|
-
console.error((0, i18n_1.t)('Web 授权登录失败,可能是环境兼容性问题'));
|
|
440173
|
-
console.error((0, i18n_1.t)('建议使用密钥登录:tcb login --key'));
|
|
440174
|
-
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' }));
|
|
440175
440267
|
return {
|
|
440176
440268
|
code: 'WEB_AUTH_FAILED',
|
|
440177
440269
|
msg: (0, i18n_1.t)('Web 授权登录失败,请使用密钥登录:tcb login --key'),
|
|
@@ -440196,8 +440288,8 @@ function loginWithKey(secretId, secretKey, token) {
|
|
|
440196
440288
|
exports.loginWithKey = loginWithKey;
|
|
440197
440289
|
function login(options = {}) {
|
|
440198
440290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
440199
|
-
const { secretId, secretKey, key, token } = options;
|
|
440200
|
-
return key ? loginWithKey(secretId, secretKey, token) : loginByWebAuth();
|
|
440291
|
+
const { secretId, secretKey, key, token, flow } = options;
|
|
440292
|
+
return key ? loginWithKey(secretId, secretKey, token) : loginByWebAuth({ flow });
|
|
440201
440293
|
});
|
|
440202
440294
|
}
|
|
440203
440295
|
exports.login = login;
|
|
@@ -467650,6 +467742,7 @@ const decorators_1 = __webpack_require__(93480);
|
|
|
467650
467742
|
const i18n_1 = __webpack_require__(69258);
|
|
467651
467743
|
const utils_2 = __webpack_require__(75213);
|
|
467652
467744
|
const constant_1 = __webpack_require__(62977);
|
|
467745
|
+
const common_utils_1 = __webpack_require__(325);
|
|
467653
467746
|
let CodeUpdate = class CodeUpdate extends common_1.Command {
|
|
467654
467747
|
get options() {
|
|
467655
467748
|
return {
|
|
@@ -467705,9 +467798,7 @@ let CodeUpdate = class CodeUpdate extends common_1.Command {
|
|
|
467705
467798
|
}
|
|
467706
467799
|
const configFiles = ['cloudbaserc.json', 'cloudbaserc.js', 'cloudbaserc.yaml', 'cloudbaserc.yml', 'cloudbaserc', 'cloudbase.config.js'];
|
|
467707
467800
|
const hasConfigFile = configFiles.some(file => fs_1.default.existsSync(path_1.default.join(process.cwd(), file)));
|
|
467708
|
-
|
|
467709
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('镜像部署时需要在配置文件中指定 imageConfig,请创建 cloudbaserc.json 并配置镜像参数'));
|
|
467710
|
-
}
|
|
467801
|
+
(0, common_utils_1.validateImageDeploy)(deployMode, hasConfigFile ? undefined : false);
|
|
467711
467802
|
const hasConfig = hasConfigFile || functions.length > 0;
|
|
467712
467803
|
if (hasConfig) {
|
|
467713
467804
|
return this.updateWithConfig({ name, dir, envId, codeSecret, deployMode, config, functions, log });
|
|
@@ -467725,26 +467816,19 @@ let CodeUpdate = class CodeUpdate extends common_1.Command {
|
|
|
467725
467816
|
log.info((0, i18n_1.t)('从配置文件读取函数 [{{name}}] 的配置', { name }));
|
|
467726
467817
|
}
|
|
467727
467818
|
else {
|
|
467819
|
+
(0, common_utils_1.validateImageDeploy)(deployMode, undefined);
|
|
467728
467820
|
func = Object.assign({ name }, constant_1.DefaultFunctionDeployConfig);
|
|
467729
467821
|
log.info((0, i18n_1.t)('未找到函数 [{{name}}] 的配置,使用默认配置', { name }));
|
|
467730
467822
|
}
|
|
467731
467823
|
const functionRootPath = path_1.default.join(process.cwd(), config.functionRoot || 'functions');
|
|
467732
|
-
|
|
467733
|
-
|
|
467734
|
-
|
|
467735
|
-
|
|
467736
|
-
|
|
467737
|
-
|
|
467738
|
-
|
|
467739
|
-
|
|
467740
|
-
}
|
|
467741
|
-
else if (func === null || func === void 0 ? void 0 : func.dir) {
|
|
467742
|
-
funcPath = path_1.default.resolve(process.cwd(), func.dir);
|
|
467743
|
-
log.info((0, i18n_1.t)('使用配置文件中的目录:{{path}}', { path: funcPath }));
|
|
467744
|
-
}
|
|
467745
|
-
else {
|
|
467746
|
-
funcPath = path_1.default.join(functionRootPath, name);
|
|
467747
|
-
}
|
|
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
|
+
});
|
|
467748
467832
|
return this.doUpdateCode({
|
|
467749
467833
|
func, funcPath, functionRootPath, envId, codeSecret, deployMode,
|
|
467750
467834
|
functionPath: dir ? funcPath : undefined, log
|
|
@@ -467754,18 +467838,13 @@ let CodeUpdate = class CodeUpdate extends common_1.Command {
|
|
|
467754
467838
|
updateWithoutConfig(options) {
|
|
467755
467839
|
return __awaiter(this, void 0, void 0, function* () {
|
|
467756
467840
|
const { name, dir, envId, codeSecret, deployMode, log } = options;
|
|
467757
|
-
|
|
467758
|
-
|
|
467759
|
-
|
|
467760
|
-
|
|
467761
|
-
|
|
467762
|
-
|
|
467763
|
-
|
|
467764
|
-
log.info((0, i18n_1.t)('将从目录 {{dir}} 更新云函数代码', { dir: updateDir }));
|
|
467765
|
-
}
|
|
467766
|
-
else {
|
|
467767
|
-
log.info((0, i18n_1.t)('未找到配置文件,将从当前目录更新云函数代码'));
|
|
467768
|
-
}
|
|
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
|
+
});
|
|
467769
467848
|
let inferredConfig = this.inferFunctionConfig(name, updateDir);
|
|
467770
467849
|
const isInferred = !!inferredConfig;
|
|
467771
467850
|
if (!inferredConfig) {
|
|
@@ -693990,9 +694069,10 @@ function updateFunctionCode(options) {
|
|
|
693990
694069
|
});
|
|
693991
694070
|
}
|
|
693992
694071
|
catch (e) {
|
|
693993
|
-
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) }), {
|
|
693994
694073
|
code: e.code,
|
|
693995
|
-
requestId: e.requestId
|
|
694074
|
+
requestId: e.requestId,
|
|
694075
|
+
original: e
|
|
693996
694076
|
});
|
|
693997
694077
|
}
|
|
693998
694078
|
});
|
|
@@ -726130,7 +726210,9 @@ const outputHelpInfo = () => {
|
|
|
726130
726210
|
hosting [cmd] ${(0, i18n_1.t)('静态托管资源管理操作')}
|
|
726131
726211
|
storage [cmd] ${(0, i18n_1.t)('云存储资源管理操作')}
|
|
726132
726212
|
service [cmd] ${(0, i18n_1.t)('HTTP 访问服务管理操作')}
|
|
726133
|
-
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)('网关管理操作')}
|
|
726134
726216
|
`;
|
|
726135
726217
|
const options = `
|
|
726136
726218
|
${(0, i18n_1.t)('选项')}
|
|
@@ -743531,16 +743613,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
743531
743613
|
});
|
|
743532
743614
|
};
|
|
743533
743615
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
743534
|
-
exports.getAuthTokenFromWeb = void 0;
|
|
743616
|
+
exports.getAuthTokenFromWeb = exports.CLI_AUTH_BASE_URL = void 0;
|
|
743535
743617
|
const common_1 = __webpack_require__(96711);
|
|
743536
743618
|
const coding_1 = __webpack_require__(40540);
|
|
743537
743619
|
const web_1 = __webpack_require__(2240);
|
|
743538
743620
|
const system_1 = __webpack_require__(62179);
|
|
743539
|
-
|
|
743621
|
+
exports.CLI_AUTH_BASE_URL = 'https://tcb.cloud.tencent.com/dev';
|
|
743540
743622
|
// 打开云开发控制台,获取授权
|
|
743541
743623
|
function getAuthTokenFromWeb(options = {}) {
|
|
743542
743624
|
return __awaiter(this, void 0, void 0, function* () {
|
|
743543
|
-
const { getAuthUrl, noBrowser, callbackTimeout } = options;
|
|
743625
|
+
const { getAuthUrl, noBrowser, callbackTimeout, silent } = options;
|
|
743544
743626
|
const mac = yield (0, system_1.getMacAddress)();
|
|
743545
743627
|
const os = (0, system_1.getOSInfo)();
|
|
743546
743628
|
const macHash = (0, coding_1.md5Encoding)(mac);
|
|
@@ -743553,7 +743635,7 @@ function getAuthTokenFromWeb(options = {}) {
|
|
|
743553
743635
|
+ '&from=cli';
|
|
743554
743636
|
const encodedCallbackUrl = encodeURIComponent(callbackUrl);
|
|
743555
743637
|
// 授权链接
|
|
743556
|
-
const rawAuthUrl = `${
|
|
743638
|
+
const rawAuthUrl = `${exports.CLI_AUTH_BASE_URL}?authCallbackUrl=${encodedCallbackUrl}#/cli-auth?${encodedQuery}`;
|
|
743557
743639
|
let cliAuthUrl = rawAuthUrl;
|
|
743558
743640
|
if (getAuthUrl) {
|
|
743559
743641
|
try {
|
|
@@ -743566,7 +743648,8 @@ function getAuthTokenFromWeb(options = {}) {
|
|
|
743566
743648
|
return cliAuthUrl;
|
|
743567
743649
|
}, 'login', {
|
|
743568
743650
|
noBrowser,
|
|
743569
|
-
callbackTimeout
|
|
743651
|
+
callbackTimeout,
|
|
743652
|
+
silent
|
|
743570
743653
|
});
|
|
743571
743654
|
const credential = (0, common_1.resolveCredential)(query);
|
|
743572
743655
|
return credential;
|
|
@@ -801600,9 +801683,12 @@ function inferNodejsConfig(targetDir, name, httpFn) {
|
|
|
801600
801683
|
runtime = 'Nodejs16.13';
|
|
801601
801684
|
}
|
|
801602
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;
|
|
801603
801689
|
return {
|
|
801604
|
-
config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime,
|
|
801605
|
-
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' } : {})),
|
|
801606
801692
|
source: (0, i18n_1.t)('Node.js 项目(package.json)')
|
|
801607
801693
|
};
|
|
801608
801694
|
}
|
|
@@ -801627,7 +801713,7 @@ function inferPythonConfig(targetDir, name, httpFn) {
|
|
|
801627
801713
|
}
|
|
801628
801714
|
}
|
|
801629
801715
|
return {
|
|
801630
|
-
config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Python3.9', handler
|
|
801716
|
+
config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Python3.9', handler }), (httpFn ? { type: 'HTTP' } : {})),
|
|
801631
801717
|
source: (0, i18n_1.t)('Python 项目({{file}})', { file: foundFile })
|
|
801632
801718
|
};
|
|
801633
801719
|
}
|
|
@@ -801660,7 +801746,7 @@ function inferPhpConfig(targetDir, name, httpFn) {
|
|
|
801660
801746
|
handler = 'index.main';
|
|
801661
801747
|
}
|
|
801662
801748
|
return {
|
|
801663
|
-
config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Php8.0', handler
|
|
801749
|
+
config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Php8.0', handler }), (httpFn ? { type: 'HTTP' } : {})),
|
|
801664
801750
|
source
|
|
801665
801751
|
};
|
|
801666
801752
|
}
|
|
@@ -801684,7 +801770,7 @@ function inferJavaConfig(targetDir, name, httpFn) {
|
|
|
801684
801770
|
}
|
|
801685
801771
|
}
|
|
801686
801772
|
return {
|
|
801687
|
-
config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Java11', handler: 'example.Hello::mainHandler'
|
|
801773
|
+
config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Java11', handler: 'example.Hello::mainHandler' }), (httpFn ? { type: 'HTTP' } : {})),
|
|
801688
801774
|
source: (0, i18n_1.t)('Java 项目({{file}})', { file: foundFile })
|
|
801689
801775
|
};
|
|
801690
801776
|
}
|
|
@@ -801707,7 +801793,7 @@ function inferGoConfig(targetDir, name, httpFn) {
|
|
|
801707
801793
|
}
|
|
801708
801794
|
}
|
|
801709
801795
|
return {
|
|
801710
|
-
config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Go1', handler: 'main'
|
|
801796
|
+
config: Object.assign(Object.assign(Object.assign({ name: funcName }, constant_1.DefaultFunctionDeployConfig), { runtime: 'Go1', handler: 'main' }), (httpFn ? { type: 'HTTP' } : {})),
|
|
801711
801797
|
source: (0, i18n_1.t)('Go 项目({{file}})', { file: foundFile })
|
|
801712
801798
|
};
|
|
801713
801799
|
}
|
|
@@ -801740,7 +801826,7 @@ function inferByFileExtension(targetDir, name, httpFn) {
|
|
|
801740
801826
|
return null;
|
|
801741
801827
|
}
|
|
801742
801828
|
return {
|
|
801743
|
-
config: Object.assign(
|
|
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' } : {})),
|
|
801744
801830
|
source: typeConfig.source
|
|
801745
801831
|
};
|
|
801746
801832
|
}
|
|
@@ -835712,6 +835798,27 @@ const decorators_1 = __webpack_require__(93480);
|
|
|
835712
835798
|
const function_2 = __webpack_require__(11686);
|
|
835713
835799
|
const i18n_1 = __webpack_require__(69258);
|
|
835714
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
|
+
}
|
|
835715
835822
|
let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
835716
835823
|
get options() {
|
|
835717
835824
|
return {
|
|
@@ -835833,26 +835940,29 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
835833
835940
|
return __awaiter(this, void 0, void 0, function* () {
|
|
835834
835941
|
const { name, dir, envId, force, codeSecret, access, httpFn, ws, deployMode, functions, functionRootPath, yes, log } = options;
|
|
835835
835942
|
let func = functions === null || functions === void 0 ? void 0 : functions.find((item) => item.name === name);
|
|
835836
|
-
let funcPath;
|
|
835837
|
-
if (
|
|
835838
|
-
|
|
835839
|
-
|
|
835840
|
-
|
|
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 }));
|
|
835841
835962
|
}
|
|
835842
|
-
funcPath = path_1.default.resolve(process.cwd(), dir);
|
|
835843
|
-
log.info((0, i18n_1.t)('使用命令行指定的目录:{{path}}', { path: funcPath }));
|
|
835844
|
-
}
|
|
835845
|
-
else if (func === null || func === void 0 ? void 0 : func.dir) {
|
|
835846
|
-
funcPath = path_1.default.resolve(process.cwd(), func.dir);
|
|
835847
|
-
log.info((0, i18n_1.t)('使用配置文件中的目录:{{path}}', { path: funcPath }));
|
|
835848
|
-
}
|
|
835849
|
-
else {
|
|
835850
|
-
funcPath = path_1.default.join(functionRootPath, name);
|
|
835851
|
-
}
|
|
835852
|
-
if (!fs_1.default.existsSync(funcPath)) {
|
|
835853
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('未找到函数 [{{name}}] 的目录:{{path}},请检查函数名称或使用 --dir 指定函数目录', { name, path: funcPath }));
|
|
835854
835963
|
}
|
|
835855
835964
|
if (!func) {
|
|
835965
|
+
(0, common_utils_1.validateImageDeploy)(deployMode, undefined);
|
|
835856
835966
|
log.warn((0, i18n_1.t)('配置文件中未找到函数 [{{name}}] 的配置', { name }));
|
|
835857
835967
|
if (yes) {
|
|
835858
835968
|
const inferredConfig = this.inferFunctionConfig(httpFn, funcPath);
|
|
@@ -835895,7 +836005,8 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
835895
836005
|
}
|
|
835896
836006
|
deployWithoutConfig(options) {
|
|
835897
836007
|
return __awaiter(this, void 0, void 0, function* () {
|
|
835898
|
-
const { envId, codeSecret, httpFn, ws, log } = options;
|
|
836008
|
+
const { envId, codeSecret, httpFn, ws, deployMode, log } = options;
|
|
836009
|
+
(0, common_utils_1.validateImageDeploy)(deployMode, false);
|
|
835899
836010
|
const { deployDir, functionName } = this.resolveFunctionInfo(options);
|
|
835900
836011
|
log.verbose((0, i18n_1.t)('正在检测云端函数状态...'));
|
|
835901
836012
|
let checkResult;
|
|
@@ -835933,19 +836044,13 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
835933
836044
|
}
|
|
835934
836045
|
resolveFunctionInfo(options) {
|
|
835935
836046
|
const { name, dir, log } = options;
|
|
835936
|
-
|
|
835937
|
-
|
|
835938
|
-
|
|
835939
|
-
|
|
835940
|
-
|
|
835941
|
-
|
|
835942
|
-
|
|
835943
|
-
log.info((0, i18n_1.t)('将从目录 {{dir}} 部署云函数', { dir: deployDir }));
|
|
835944
|
-
}
|
|
835945
|
-
else {
|
|
835946
|
-
log.info((0, i18n_1.t)('未找到配置文件,将从当前目录部署云函数'));
|
|
835947
|
-
}
|
|
835948
|
-
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);
|
|
835949
836054
|
return { deployDir, functionName };
|
|
835950
836055
|
}
|
|
835951
836056
|
handleExistingFunction(checkResult, inferredConfig, isInferred, options, deployDir) {
|
|
@@ -835953,7 +836058,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
835953
836058
|
const { envId, force, codeSecret, access, deployMode, yes, log } = options;
|
|
835954
836059
|
const conflicts = this.detectConfigConflicts(inferredConfig, checkResult.functionDetail);
|
|
835955
836060
|
if (conflicts.length > 0) {
|
|
835956
|
-
this.displayConfigConflicts(inferredConfig.name, conflicts);
|
|
836061
|
+
this.displayConfigConflicts(inferredConfig.name, conflicts, log);
|
|
835957
836062
|
throw new error_1.CloudBaseError((0, i18n_1.t)('配置冲突,无法部署'));
|
|
835958
836063
|
}
|
|
835959
836064
|
let shouldUpdate = force || yes;
|
|
@@ -835966,7 +836071,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
835966
836071
|
}
|
|
835967
836072
|
const mergedConfig = this.mergeCloudAndLocalConfig(checkResult.functionDetail, inferredConfig);
|
|
835968
836073
|
log.info((0, i18n_1.t)('✓ 函数已存在,将使用以下合并配置更新:'));
|
|
835969
|
-
this.displayMergedConfig(inferredConfig.name, mergedConfig, isInferred ? 'inferred' : 'default');
|
|
836074
|
+
this.displayMergedConfig(inferredConfig.name, mergedConfig, isInferred ? 'inferred' : 'default', log);
|
|
835970
836075
|
let finalConfig = mergedConfig;
|
|
835971
836076
|
if (!yes) {
|
|
835972
836077
|
const { action } = yield inquirer_1.default.prompt({
|
|
@@ -836163,7 +836268,11 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
836163
836268
|
type: 'confirm',
|
|
836164
836269
|
name: 'installDependency',
|
|
836165
836270
|
message: (0, i18n_1.t)('是否在线安装依赖'),
|
|
836166
|
-
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
|
+
}
|
|
836167
836276
|
}
|
|
836168
836277
|
]);
|
|
836169
836278
|
const enableWs = isWsFromCli || answers.enableWebSocket;
|
|
@@ -836175,7 +836284,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
836175
836284
|
dynamicEnabled: 'FALSE',
|
|
836176
836285
|
maxConcurrency: answers.maxConcurrency
|
|
836177
836286
|
} : undefined;
|
|
836178
|
-
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 } : {}));
|
|
836179
836288
|
});
|
|
836180
836289
|
}
|
|
836181
836290
|
promptFunctionName() {
|
|
@@ -836195,7 +836304,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
836195
836304
|
});
|
|
836196
836305
|
}
|
|
836197
836306
|
printFunctionConfig(func, log, source) {
|
|
836198
|
-
var _a, _b;
|
|
836307
|
+
var _a, _b, _c;
|
|
836199
836308
|
if (source) {
|
|
836200
836309
|
log.info((0, i18n_1.t)('配置来源:{{source}}', { source }));
|
|
836201
836310
|
}
|
|
@@ -836206,12 +836315,14 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
836206
836315
|
if (func.memorySize) {
|
|
836207
836316
|
log.info((0, i18n_1.t)(' - 内存大小:{{memorySize}} MB', { memorySize: func.memorySize }));
|
|
836208
836317
|
}
|
|
836209
|
-
|
|
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
|
+
}
|
|
836210
836321
|
if (func.type === 'HTTP') {
|
|
836211
836322
|
log.info((0, i18n_1.t)(' - 函数类型:HTTP'));
|
|
836212
836323
|
if (func.protocolType === 'WS') {
|
|
836213
836324
|
log.info((0, i18n_1.t)(' - WebSocket 协议:已启用'));
|
|
836214
|
-
const idleTimeOut = (
|
|
836325
|
+
const idleTimeOut = (_c = (_b = func.protocolParams) === null || _b === void 0 ? void 0 : _b.wsParams) === null || _c === void 0 ? void 0 : _c.idleTimeOut;
|
|
836215
836326
|
if (idleTimeOut) {
|
|
836216
836327
|
log.info((0, i18n_1.t)(' - 空闲超时时间:{{seconds}} 秒', { seconds: idleTimeOut }));
|
|
836217
836328
|
}
|
|
@@ -836282,7 +836393,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
836282
836393
|
const { func, envId, force, codeSecret, access, deployMode, functionRootPath, functionPath, yes, log, preCheckResult } = options;
|
|
836283
836394
|
let finalFunc = Object.assign({}, func);
|
|
836284
836395
|
if (deployMode === 'image') {
|
|
836285
|
-
const fileImageConfig = (
|
|
836396
|
+
const fileImageConfig = buildImageConfig(func);
|
|
836286
836397
|
if (fileImageConfig) {
|
|
836287
836398
|
finalFunc.imageConfig = fileImageConfig;
|
|
836288
836399
|
}
|
|
@@ -836292,7 +836403,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
836292
836403
|
}
|
|
836293
836404
|
if (finalFunc.type === 'HTTP' && deployMode !== 'image') {
|
|
836294
836405
|
const funcPath = functionPath === '.' ? process.cwd() : (functionPath || path_1.default.join(functionRootPath, finalFunc.name));
|
|
836295
|
-
const shouldContinue = yield (
|
|
836406
|
+
const shouldContinue = yield checkWebFunctionBootstrap(funcPath, finalFunc);
|
|
836296
836407
|
if (!shouldContinue) {
|
|
836297
836408
|
return;
|
|
836298
836409
|
}
|
|
@@ -836447,7 +836558,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
836447
836558
|
funcWithType = Object.assign(Object.assign({}, funcWithType), { type: 'HTTP', protocolType: 'WS' });
|
|
836448
836559
|
}
|
|
836449
836560
|
if (deployMode === 'image') {
|
|
836450
|
-
const fileImageConfig = (
|
|
836561
|
+
const fileImageConfig = buildImageConfig(funcWithType);
|
|
836451
836562
|
if (fileImageConfig) {
|
|
836452
836563
|
funcWithType = Object.assign(Object.assign({}, funcWithType), { imageConfig: fileImageConfig });
|
|
836453
836564
|
}
|
|
@@ -836456,21 +836567,24 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
836456
836567
|
return { status: 'skipped', name: func.name };
|
|
836457
836568
|
}
|
|
836458
836569
|
}
|
|
836459
|
-
const funcPath =
|
|
836460
|
-
|
|
836461
|
-
:
|
|
836570
|
+
const funcPath = resolveFunctionPath({
|
|
836571
|
+
functionRootPath,
|
|
836572
|
+
functionName: func.name,
|
|
836573
|
+
functionDirFromConfig: func.dir
|
|
836574
|
+
});
|
|
836462
836575
|
if (deployMode !== 'image' && !fs_1.default.existsSync(funcPath)) {
|
|
836463
836576
|
log.error((0, i18n_1.t)('未找到函数 [{{name}}] 的目录:{{path}},已跳过', { name: func.name, path: funcPath }));
|
|
836464
836577
|
return { status: 'skipped', name: func.name };
|
|
836465
836578
|
}
|
|
836466
836579
|
if (funcWithType.type === 'HTTP' && deployMode !== 'image') {
|
|
836467
|
-
const shouldContinue = yield (
|
|
836580
|
+
const shouldContinue = yield checkWebFunctionBootstrap(funcPath, funcWithType);
|
|
836468
836581
|
if (!shouldContinue) {
|
|
836469
836582
|
log.warn((0, i18n_1.t)('[{{name}}] 已跳过部署', { name: func.name }));
|
|
836470
836583
|
return { status: 'skipped', name: func.name };
|
|
836471
836584
|
}
|
|
836472
836585
|
}
|
|
836473
836586
|
loading.start((0, i18n_1.t)('云函数部署中'));
|
|
836587
|
+
let deployError = null;
|
|
836474
836588
|
try {
|
|
836475
836589
|
yield (0, function_1.createFunction)({
|
|
836476
836590
|
func: funcWithType,
|
|
@@ -836486,32 +836600,33 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
836486
836600
|
return { status: 'success', name: func.name };
|
|
836487
836601
|
}
|
|
836488
836602
|
catch (e) {
|
|
836603
|
+
deployError = e;
|
|
836489
836604
|
loading.stop();
|
|
836490
|
-
|
|
836491
|
-
|
|
836492
|
-
|
|
836493
|
-
|
|
836494
|
-
|
|
836495
|
-
|
|
836496
|
-
|
|
836497
|
-
|
|
836498
|
-
|
|
836499
|
-
|
|
836500
|
-
|
|
836501
|
-
|
|
836502
|
-
|
|
836503
|
-
|
|
836504
|
-
|
|
836505
|
-
}
|
|
836506
|
-
|
|
836507
|
-
|
|
836508
|
-
}
|
|
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 };
|
|
836509
836624
|
}
|
|
836510
836625
|
}));
|
|
836511
836626
|
if (tasks.length > 5) {
|
|
836512
836627
|
log.info((0, i18n_1.t)('函数数量较多,将使用队列部署'));
|
|
836513
836628
|
}
|
|
836514
|
-
const asyncTaskController = new utils_1.AsyncTaskParallelController(
|
|
836629
|
+
const asyncTaskController = new utils_1.AsyncTaskParallelController(MAX_PARALLEL_DEPLOY, 50);
|
|
836515
836630
|
asyncTaskController.loadTasks(tasks);
|
|
836516
836631
|
const rawResults = yield asyncTaskController.run();
|
|
836517
836632
|
const results = rawResults.map((r, index) => {
|
|
@@ -836602,7 +836717,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
836602
836717
|
}
|
|
836603
836718
|
const conflicts = this.detectConfigConflicts(func, existingFunction);
|
|
836604
836719
|
if (conflicts.length > 0) {
|
|
836605
|
-
this.displayConfigConflicts(func.name, conflicts);
|
|
836720
|
+
this.displayConfigConflicts(func.name, conflicts, log);
|
|
836606
836721
|
return 'error';
|
|
836607
836722
|
}
|
|
836608
836723
|
func = this.mergeCloudAndLocalConfig(existingFunction, func);
|
|
@@ -836947,7 +837062,22 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
836947
837062
|
}
|
|
836948
837063
|
}
|
|
836949
837064
|
getSpecificSuggestions(error, context = {}) {
|
|
837065
|
+
var _a, _b;
|
|
836950
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
|
+
}
|
|
836951
837081
|
if (error.code === 'Forbidden' || error.code === 'Unauthorized' ||
|
|
836952
837082
|
error.code === 'AuthFailure' || error.code === 'UnauthorizedOperation') {
|
|
836953
837083
|
return [
|
|
@@ -837010,33 +837140,35 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
837010
837140
|
}
|
|
837011
837141
|
});
|
|
837012
837142
|
}
|
|
837013
|
-
displayConfigConflicts(functionName, conflicts) {
|
|
837014
|
-
|
|
837143
|
+
displayConfigConflicts(functionName, conflicts, log) {
|
|
837144
|
+
const activeLogger = log || utils_1.logger;
|
|
837145
|
+
activeLogger.error((0, i18n_1.t)('函数 [{{name}}] 存在配置冲突:', { name: functionName }));
|
|
837015
837146
|
conflicts.forEach((conflict) => {
|
|
837016
|
-
|
|
837017
|
-
|
|
837147
|
+
activeLogger.error(` ✗ ${conflict.field}: 云端 ${conflict.cloudValue} ≠ 本地 ${conflict.localValue}`);
|
|
837148
|
+
activeLogger.error(` ${conflict.message}`);
|
|
837018
837149
|
});
|
|
837019
|
-
|
|
837020
|
-
|
|
837021
|
-
|
|
837022
|
-
|
|
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}} 查看云端配置', {
|
|
837023
837154
|
command: (0, utils_1.highlightCommand)(`tcb fn detail ${functionName}`)
|
|
837024
837155
|
}));
|
|
837025
837156
|
}
|
|
837026
|
-
displayMergedConfig(functionName, config, source) {
|
|
837027
|
-
|
|
837028
|
-
|
|
837029
|
-
|
|
837030
|
-
|
|
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}`);
|
|
837031
837163
|
if (config.memorySize) {
|
|
837032
|
-
|
|
837164
|
+
activeLogger.info(` ${(0, i18n_1.t)('内存')}: ${config.memorySize}MB`);
|
|
837033
837165
|
}
|
|
837034
|
-
|
|
837166
|
+
activeLogger.info(` ${(0, i18n_1.t)('超时')}: ${config.timeout}s`);
|
|
837035
837167
|
if (source === 'inferred') {
|
|
837036
|
-
|
|
837168
|
+
activeLogger.info((0, i18n_1.t)(' (配置来源: 智能推测)'));
|
|
837037
837169
|
}
|
|
837038
837170
|
else if (source === 'default') {
|
|
837039
|
-
|
|
837171
|
+
activeLogger.info((0, i18n_1.t)(' (配置来源: 默认配置)'));
|
|
837040
837172
|
}
|
|
837041
837173
|
}
|
|
837042
837174
|
confirmUpdate(functionName) {
|
|
@@ -866805,6 +866937,141 @@ const format = [format_1.default];
|
|
|
866805
866937
|
exports["default"] = format;
|
|
866806
866938
|
//# sourceMappingURL=index.js.map
|
|
866807
866939
|
|
|
866940
|
+
/***/ }),
|
|
866941
|
+
|
|
866942
|
+
/***/ 92423:
|
|
866943
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
866944
|
+
|
|
866945
|
+
"use strict";
|
|
866946
|
+
|
|
866947
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
866948
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
866949
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
866950
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
866951
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
866952
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
866953
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
866954
|
+
});
|
|
866955
|
+
};
|
|
866956
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
866957
|
+
exports.getAuthTokenByDeviceFlow = void 0;
|
|
866958
|
+
const net_1 = __webpack_require__(31153);
|
|
866959
|
+
const web_1 = __webpack_require__(2240);
|
|
866960
|
+
const error_1 = __webpack_require__(64119);
|
|
866961
|
+
const coding_1 = __webpack_require__(40540);
|
|
866962
|
+
const system_1 = __webpack_require__(62179);
|
|
866963
|
+
const web_auth_1 = __webpack_require__(76097);
|
|
866964
|
+
/** 默认国内站 应用侧可通过 getOAuthEndpoint 覆写 */
|
|
866965
|
+
const OAUTH_ENDPOINT = process.env.TCB_OAUTH_ENDPOINT || 'https://tcb-api.cloud.tencent.com/qcloud-tcb/v1/oauth';
|
|
866966
|
+
const DEFAULT_CLIENT_ID = 'cloudbase-toolbox';
|
|
866967
|
+
const POLL_ERROR_CODES = {
|
|
866968
|
+
AUTHORIZATION_PENDING: 'authorization_pending',
|
|
866969
|
+
SLOW_DOWN: 'slow_down',
|
|
866970
|
+
EXPIRED_TOKEN: 'expired_token',
|
|
866971
|
+
ACCESS_DENIED: 'access_denied',
|
|
866972
|
+
};
|
|
866973
|
+
const SUCCESS_CODE = 'NORMAL';
|
|
866974
|
+
function fetchDeviceCode(options = {}) {
|
|
866975
|
+
const { client_id = DEFAULT_CLIENT_ID, endpoint = OAUTH_ENDPOINT } = options;
|
|
866976
|
+
return (0, net_1.postFetch)(`${endpoint}/device/code`, { client_id });
|
|
866977
|
+
}
|
|
866978
|
+
function fetchPollToken(options) {
|
|
866979
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
866980
|
+
const { device_code, client_id = DEFAULT_CLIENT_ID, endpoint = OAUTH_ENDPOINT } = options;
|
|
866981
|
+
const mac = yield (0, system_1.getMacAddress)();
|
|
866982
|
+
return (0, net_1.postFetch)(`${endpoint}/token`, {
|
|
866983
|
+
device_code,
|
|
866984
|
+
client_id,
|
|
866985
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
|
|
866986
|
+
device_info: {
|
|
866987
|
+
mac,
|
|
866988
|
+
os: (0, system_1.getOSInfo)(),
|
|
866989
|
+
hash: (0, coding_1.md5Encoding)(mac),
|
|
866990
|
+
}
|
|
866991
|
+
});
|
|
866992
|
+
});
|
|
866993
|
+
}
|
|
866994
|
+
function sleep(ms) {
|
|
866995
|
+
return new Promise((resolve) => {
|
|
866996
|
+
setTimeout(resolve, ms);
|
|
866997
|
+
});
|
|
866998
|
+
}
|
|
866999
|
+
function getAuthTokenByDeviceFlow(options = {}) {
|
|
867000
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
867001
|
+
const { client_id, onDeviceCode, getOAuthEndpoint, getAuthUrl, silent } = options;
|
|
867002
|
+
const endpoint = getOAuthEndpoint ? getOAuthEndpoint(OAUTH_ENDPOINT) : OAUTH_ENDPOINT;
|
|
867003
|
+
const deviceCodeResp = yield fetchDeviceCode({ client_id, endpoint });
|
|
867004
|
+
if (deviceCodeResp.code !== SUCCESS_CODE) {
|
|
867005
|
+
throw new error_1.CloudBaseError('Device Flow fetchDeviceCode failed', {
|
|
867006
|
+
code: deviceCodeResp.code,
|
|
867007
|
+
requestId: deviceCodeResp.reqId,
|
|
867008
|
+
});
|
|
867009
|
+
}
|
|
867010
|
+
const { device_code, user_code, expires_in, interval } = deviceCodeResp.result;
|
|
867011
|
+
// 暂时不消费 verification_uri,由客户端控制跳转
|
|
867012
|
+
const defaultVerificationUri = `${web_auth_1.CLI_AUTH_BASE_URL}#/cli-auth`;
|
|
867013
|
+
// from=cli 后续考虑改用 client_id,因为 toolbox 作为公共依赖,可能被不同 client 所引用
|
|
867014
|
+
const rawVerificationUri = `${defaultVerificationUri}?user_code=${user_code}&from=cli&flow=device`;
|
|
867015
|
+
const verification_uri = getAuthUrl ? getAuthUrl(rawVerificationUri) : rawVerificationUri;
|
|
867016
|
+
if (!silent) {
|
|
867017
|
+
// 打印授权信息,引导用户操作
|
|
867018
|
+
console.log('\n\n若链接未自动打开,请手动复制至浏览器,或尝试其他登录方式:');
|
|
867019
|
+
console.log(`\n${verification_uri}`);
|
|
867020
|
+
console.log(`\n用户码: ${user_code}\n`);
|
|
867021
|
+
}
|
|
867022
|
+
// 尝试自动打开授权页面
|
|
867023
|
+
yield (0, web_1.openUrl)(verification_uri);
|
|
867024
|
+
if (onDeviceCode) {
|
|
867025
|
+
onDeviceCode({ user_code, verification_uri, device_code, expires_in });
|
|
867026
|
+
}
|
|
867027
|
+
let pollInterval = interval;
|
|
867028
|
+
const deadline = Date.now() + expires_in * 1000;
|
|
867029
|
+
while (Date.now() < deadline) {
|
|
867030
|
+
yield sleep(pollInterval * 1000);
|
|
867031
|
+
let resp;
|
|
867032
|
+
try {
|
|
867033
|
+
resp = yield fetchPollToken({ device_code, interval: pollInterval, client_id, endpoint });
|
|
867034
|
+
}
|
|
867035
|
+
catch (e) {
|
|
867036
|
+
throw new error_1.CloudBaseError('Device Flow 轮询请求失败', { original: e });
|
|
867037
|
+
}
|
|
867038
|
+
const { code, result } = resp;
|
|
867039
|
+
// 服务端返回业务错误(result 中携带 error 字段)
|
|
867040
|
+
if (result && 'error' in result) {
|
|
867041
|
+
const { error, error_description } = result;
|
|
867042
|
+
if (error === POLL_ERROR_CODES.AUTHORIZATION_PENDING) {
|
|
867043
|
+
continue;
|
|
867044
|
+
}
|
|
867045
|
+
if (error === POLL_ERROR_CODES.SLOW_DOWN) {
|
|
867046
|
+
pollInterval += 5;
|
|
867047
|
+
continue;
|
|
867048
|
+
}
|
|
867049
|
+
if (error === POLL_ERROR_CODES.EXPIRED_TOKEN) {
|
|
867050
|
+
throw new error_1.CloudBaseError('设备码已过期,请重新发起授权');
|
|
867051
|
+
}
|
|
867052
|
+
if (error === POLL_ERROR_CODES.ACCESS_DENIED) {
|
|
867053
|
+
throw new error_1.CloudBaseError('用户拒绝了授权请求');
|
|
867054
|
+
}
|
|
867055
|
+
throw new error_1.CloudBaseError(error_description || `Device Flow 授权失败,错误: ${error}`, {
|
|
867056
|
+
code: error,
|
|
867057
|
+
requestId: resp.reqId,
|
|
867058
|
+
});
|
|
867059
|
+
}
|
|
867060
|
+
// 服务端返回成功的 Credential
|
|
867061
|
+
if (code === SUCCESS_CODE && result) {
|
|
867062
|
+
return result;
|
|
867063
|
+
}
|
|
867064
|
+
throw new error_1.CloudBaseError(`Device Flow 授权失败,错误码: ${code}`, {
|
|
867065
|
+
code,
|
|
867066
|
+
requestId: resp.reqId,
|
|
867067
|
+
});
|
|
867068
|
+
}
|
|
867069
|
+
throw new error_1.CloudBaseError('授权超时,用户未在有效期内完成授权,请重试');
|
|
867070
|
+
});
|
|
867071
|
+
}
|
|
867072
|
+
exports.getAuthTokenByDeviceFlow = getAuthTokenByDeviceFlow;
|
|
867073
|
+
|
|
867074
|
+
|
|
866808
867075
|
/***/ }),
|
|
866809
867076
|
|
|
866810
867077
|
/***/ 92452:
|
|
@@ -913315,6 +913582,10 @@ let LoginCommand = class LoginCommand extends common_1.Command {
|
|
|
913315
913582
|
{
|
|
913316
913583
|
flags: '--token [token]',
|
|
913317
913584
|
desc: (0, i18n_1.t)('腾讯云 API 临时秘钥 Token')
|
|
913585
|
+
},
|
|
913586
|
+
{
|
|
913587
|
+
flags: '--flow <flow>',
|
|
913588
|
+
desc: (0, i18n_1.t)('Web 登录授权方式(device 或 web),默认 device')
|
|
913318
913589
|
}
|
|
913319
913590
|
],
|
|
913320
913591
|
desc: (0, i18n_1.t)('登录腾讯云账号'),
|
|
@@ -913325,7 +913596,7 @@ let LoginCommand = class LoginCommand extends common_1.Command {
|
|
|
913325
913596
|
execute(options, log) {
|
|
913326
913597
|
return __awaiter(this, void 0, void 0, function* () {
|
|
913327
913598
|
log.verbose(options);
|
|
913328
|
-
const { apiKeyId, apiKey, token } = options;
|
|
913599
|
+
const { apiKeyId, apiKey, token, flow } = options;
|
|
913329
913600
|
const loading = (0, utils_1.loadingFactory)();
|
|
913330
913601
|
loading.start((0, i18n_1.t)('检验登录状态'));
|
|
913331
913602
|
const credential = yield (0, utils_1.checkAndGetCredential)();
|
|
@@ -913387,7 +913658,7 @@ let LoginCommand = class LoginCommand extends common_1.Command {
|
|
|
913387
913658
|
}
|
|
913388
913659
|
else {
|
|
913389
913660
|
loading.start((0, i18n_1.t)('请在浏览器中打开的授权页面进行授权...'));
|
|
913390
|
-
const res = yield (0, auth_1.login)();
|
|
913661
|
+
const res = yield (0, auth_1.login)({ flow });
|
|
913391
913662
|
if (res.code === 'SUCCESS') {
|
|
913392
913663
|
loading.succeed((0, i18n_1.t)('登录成功!'));
|
|
913393
913664
|
yield askForCollectDataConfirm();
|
|
@@ -913395,6 +913666,9 @@ let LoginCommand = class LoginCommand extends common_1.Command {
|
|
|
913395
913666
|
}
|
|
913396
913667
|
else if (res.code === 'WEB_AUTH_FAILED') {
|
|
913397
913668
|
loading.fail((0, i18n_1.t)('Web 授权登录失败'));
|
|
913669
|
+
if (res.error) {
|
|
913670
|
+
log.error(res.error);
|
|
913671
|
+
}
|
|
913398
913672
|
console.log(chalk_1.default.yellow((0, i18n_1.t)('⚠️ 检测到环境兼容性问题')));
|
|
913399
913673
|
console.log(chalk_1.default.cyan((0, i18n_1.t)('建议使用密钥登录:')));
|
|
913400
913674
|
console.log(chalk_1.default.cyan((0, i18n_1.t)('tcb login --key')));
|