@cloudbase/cli 2.10.0-beta.0 → 2.11.0-beta.0
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/lib/auth/login.js +51 -65
- package/lib/auth/logout.js +3 -14
- package/lib/commands/account/login.js +136 -149
- package/lib/commands/account/logout.js +3 -14
- package/lib/commands/ag/base.js +203 -0
- package/lib/commands/ag/create.js +301 -0
- package/lib/commands/ag/debug/index.html +699 -0
- package/lib/commands/ag/delete.js +200 -0
- package/lib/commands/ag/deploy.js +185 -0
- package/lib/commands/ag/detail.js +113 -0
- package/lib/commands/ag/index.js +22 -0
- package/lib/commands/ag/list.js +155 -0
- package/lib/commands/ag/run.js +644 -0
- package/lib/commands/ai/index.js +76 -95
- package/lib/commands/cloudfunction/base.js +182 -203
- package/lib/commands/cloudrun/base.js +578 -603
- package/lib/commands/common.js +48 -63
- package/lib/commands/config/delete.js +16 -27
- package/lib/commands/config/get.js +13 -24
- package/lib/commands/config/list.js +16 -27
- package/lib/commands/config/set.js +33 -44
- package/lib/commands/db/base.js +221 -240
- package/lib/commands/env/base.js +36 -49
- package/lib/commands/env/domain.js +79 -94
- package/lib/commands/env/login.js +120 -135
- package/lib/commands/framework/index.js +32 -49
- package/lib/commands/fun/base.js +223 -244
- package/lib/commands/functions/alias/getRoute.js +33 -44
- package/lib/commands/functions/alias/setRoute.js +36 -47
- package/lib/commands/functions/code-download.js +43 -54
- package/lib/commands/functions/code-update.js +23 -34
- package/lib/commands/functions/concurrency/delete.js +11 -22
- package/lib/commands/functions/concurrency/list.js +20 -31
- package/lib/commands/functions/concurrency/set.js +13 -24
- package/lib/commands/functions/config-update.js +30 -41
- package/lib/commands/functions/copy.js +12 -23
- package/lib/commands/functions/delete.js +30 -41
- package/lib/commands/functions/deploy.js +184 -202
- package/lib/commands/functions/detail.js +23 -34
- package/lib/commands/functions/invoke.js +69 -75
- package/lib/commands/functions/layer/bind.js +102 -105
- package/lib/commands/functions/layer/create.js +29 -35
- package/lib/commands/functions/layer/delete.js +42 -48
- package/lib/commands/functions/layer/download.js +52 -58
- package/lib/commands/functions/layer/list.js +44 -50
- package/lib/commands/functions/layer/sort.js +39 -45
- package/lib/commands/functions/list.js +25 -36
- package/lib/commands/functions/log.js +65 -73
- package/lib/commands/functions/run.js +118 -116
- package/lib/commands/functions/trigger-create.js +32 -43
- package/lib/commands/functions/trigger-delete.js +50 -61
- package/lib/commands/functions/version/list.js +29 -40
- package/lib/commands/functions/version/publish.js +11 -22
- package/lib/commands/gateway/create.js +50 -61
- package/lib/commands/gateway/delete.js +38 -49
- package/lib/commands/gateway/domain.js +65 -80
- package/lib/commands/gateway/list.js +31 -42
- package/lib/commands/gateway/switch.js +48 -61
- package/lib/commands/helpers/init.js +226 -249
- package/lib/commands/helpers/new.js +35 -46
- package/lib/commands/helpers/open.js +22 -33
- package/lib/commands/hosting/hosting.js +157 -178
- package/lib/commands/index.js +1 -0
- package/lib/commands/lowcode/app.js +114 -144
- package/lib/commands/lowcode/comps.js +136 -127
- package/lib/commands/lowcode/utils.js +11 -22
- package/lib/commands/pull/pull.js +33 -46
- package/lib/commands/run/delete.js +35 -46
- package/lib/commands/run/image/delete.js +32 -39
- package/lib/commands/run/image/download.js +26 -33
- package/lib/commands/run/image/list.js +41 -48
- package/lib/commands/run/image/upload.js +26 -33
- package/lib/commands/run/list.js +32 -43
- package/lib/commands/run/service/config.js +17 -28
- package/lib/commands/run/service/deploy.js +15 -26
- package/lib/commands/run/service/list.js +48 -59
- package/lib/commands/run/service/update.js +7 -18
- package/lib/commands/run/standalonegateway/create.js +35 -42
- package/lib/commands/run/standalonegateway/destroy.js +23 -30
- package/lib/commands/run/standalonegateway/list.js +19 -26
- package/lib/commands/run/standalonegateway/package.js +31 -38
- package/lib/commands/run/standalonegateway/turn.js +27 -34
- package/lib/commands/run/version/create.js +198 -205
- package/lib/commands/run/version/delete.js +31 -38
- package/lib/commands/run/version/list.js +42 -49
- package/lib/commands/run/version/modify.js +27 -34
- package/lib/commands/run/version/update.js +201 -208
- package/lib/commands/runf/base.js +216 -237
- package/lib/commands/self-update.js +59 -72
- package/lib/commands/smart.js +66 -79
- package/lib/commands/storage/storage.js +192 -219
- package/lib/commands/third/thirdAttach.js +16 -27
- package/lib/commands/utils.js +119 -149
- package/lib/db/index.js +48 -67
- package/lib/decorators/captureError.js +10 -21
- package/lib/decorators/guard.js +11 -22
- package/lib/decorators/injectParams.js +29 -40
- package/lib/decorators/params/common.js +5 -2
- package/lib/decorators/params/index.js +3 -12
- package/lib/env/domain.js +13 -28
- package/lib/env/index.js +25 -44
- package/lib/env/login.js +30 -45
- package/lib/function/alias.js +31 -44
- package/lib/function/base.js +187 -215
- package/lib/function/code.js +8 -19
- package/lib/function/concurrency.js +43 -58
- package/lib/function/create.js +43 -53
- package/lib/function/delete.js +22 -35
- package/lib/function/layer/attach.js +33 -46
- package/lib/function/layer/create.js +34 -45
- package/lib/function/layer/delete.js +5 -16
- package/lib/function/layer/download.js +11 -22
- package/lib/function/layer/list.js +12 -25
- package/lib/function/layer/sort.js +6 -17
- package/lib/function/trigger.js +65 -82
- package/lib/function/update.js +24 -32
- package/lib/function/version.js +29 -42
- package/lib/function/vpc.js +12 -25
- package/lib/gateway/index.js +77 -104
- package/lib/hosting.js +157 -188
- package/lib/run/delete.js +3 -12
- package/lib/run/image/build.js +6 -15
- package/lib/run/image/delete.js +3 -12
- package/lib/run/image/info.js +3 -12
- package/lib/run/image/list.js +6 -15
- package/lib/run/list.js +19 -30
- package/lib/run/repo.js +6 -15
- package/lib/run/service/common.js +160 -173
- package/lib/run/service/config.js +44 -57
- package/lib/run/service/deployPackage.js +33 -44
- package/lib/run/service/list.js +8 -14
- package/lib/run/service/showLogs.js +69 -90
- package/lib/run/service/update.js +50 -63
- package/lib/run/standalonegateway/create.js +3 -12
- package/lib/run/standalonegateway/destroy.js +3 -12
- package/lib/run/standalonegateway/list.js +3 -12
- package/lib/run/standalonegateway/package/list.js +3 -12
- package/lib/run/standalonegateway/turn/off.js +3 -12
- package/lib/run/standalonegateway/turn/on.js +3 -12
- package/lib/run/version/create.js +41 -31
- package/lib/run/version/delete.js +3 -12
- package/lib/run/version/list.js +3 -12
- package/lib/run/version/modify.js +3 -12
- package/lib/run/version/repo.js +6 -15
- package/lib/run/version/update.js +37 -26
- package/lib/storage.js +62 -93
- package/lib/third/index.js +6 -17
- package/lib/utils/ai/banner.js +49 -60
- package/lib/utils/ai/claudeWindows.js +2 -2
- package/lib/utils/ai/config.js +169 -206
- package/lib/utils/ai/ensureFiles.js +6 -17
- package/lib/utils/ai/env.js +16 -27
- package/lib/utils/ai/envLocalManager.js +35 -52
- package/lib/utils/ai/router.js +927 -1005
- package/lib/utils/ai/setup.js +527 -563
- package/lib/utils/auth.js +3 -14
- package/lib/utils/checkTcbrEnv.js +20 -31
- package/lib/utils/cli-table.js +6 -1
- package/lib/utils/config.js +4 -13
- package/lib/utils/dts.js +98 -113
- package/lib/utils/env.js +154 -175
- package/lib/utils/function-packer.js +29 -42
- package/lib/utils/log.js +10 -21
- package/lib/utils/mcp-config-modifier.js +105 -120
- package/lib/utils/net/cloud-api-request.js +15 -23
- package/lib/utils/net/credential.js +26 -39
- package/lib/utils/net/http-request.js +63 -80
- package/lib/utils/net/manager-service.js +22 -35
- package/lib/utils/notice.js +16 -27
- package/lib/utils/output/loading.js +3 -12
- package/lib/utils/parallel.js +32 -43
- package/lib/utils/platform/mac.js +4 -15
- package/lib/utils/platform/port.js +4 -15
- package/lib/utils/prompt/select.js +6 -15
- package/lib/utils/report.js +28 -33
- package/lib/utils/reporter/agree.js +11 -22
- package/lib/utils/reporter/download.js +17 -28
- package/lib/utils/reporter/usage.js +12 -23
- package/lib/utils/store/auth.js +17 -30
- package/lib/utils/store/config.js +11 -25
- package/lib/utils/store/db.js +17 -36
- package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
- package/lib/utils/template-manager.js +215 -242
- package/lib/utils/template.js +81 -96
- package/lib/utils/tools/common.js +45 -56
- package/lib/utils/tools/time.js +5 -16
- package/lib/utils/url.js +10 -4
- package/package.json +2 -2
- package/specs/ag-command/design.md +421 -0
- package/specs/ag-command/doc.md +204 -0
- package/specs/ag-command/requirements.md +173 -0
- package/specs/ag-command/summary.md +174 -0
- package/specs/ag-command/tasks.md +197 -0
- package/specs/ag-command/usage-guide.md +420 -0
- package/tsconfig.json +1 -1
- package/types/commands/ag/base.d.ts +44 -0
- package/types/commands/ag/create.d.ts +25 -0
- package/types/commands/ag/delete.d.ts +32 -0
- package/types/commands/ag/deploy.d.ts +31 -0
- package/types/commands/ag/detail.d.ts +28 -0
- package/types/commands/ag/index.d.ts +6 -0
- package/types/commands/ag/list.d.ts +35 -0
- package/types/commands/ag/run.d.ts +52 -0
- package/types/commands/cloudrun/base.d.ts +10 -0
- package/types/commands/index.d.ts +1 -0
package/lib/auth/login.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -39,73 +30,68 @@ const LoginRes = {
|
|
|
39
30
|
};
|
|
40
31
|
}
|
|
41
32
|
};
|
|
42
|
-
function loginByWebAuth() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return rawUrl.replace('https://tcb.cloud.tencent.com/dev', utils_1.EUrl.DevPlatform);
|
|
49
|
-
}
|
|
50
|
-
return rawUrl;
|
|
33
|
+
async function loginByWebAuth() {
|
|
34
|
+
try {
|
|
35
|
+
const credential = await utils_1.authSupevisor.loginByWebAuth({
|
|
36
|
+
getAuthUrl: (rawUrl) => {
|
|
37
|
+
if ((0, i18n_1.isIntl)()) {
|
|
38
|
+
return rawUrl.replace('https://tcb.cloud.tencent.com/dev', utils_1.EUrl.DevPlatform);
|
|
51
39
|
}
|
|
52
|
-
|
|
53
|
-
if (lodash_1.default.isEmpty(credential)) {
|
|
54
|
-
return LoginRes.INVALID_TOKEN;
|
|
40
|
+
return rawUrl;
|
|
55
41
|
}
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
console.error((0, i18n_1.t)('Web 授权登录失败,可能是环境兼容性问题'));
|
|
60
|
-
console.error((0, i18n_1.t)('建议使用密钥登录:tcb login --key'));
|
|
61
|
-
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' }));
|
|
62
|
-
return {
|
|
63
|
-
code: 'WEB_AUTH_FAILED',
|
|
64
|
-
msg: (0, i18n_1.t)('Web 授权登录失败,请使用密钥登录:tcb login --key'),
|
|
65
|
-
error: error.message
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
exports.loginByWebAuth = loginByWebAuth;
|
|
71
|
-
function loginWithKey(secretId, secretKey, token) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
if (!secretId || !secretKey) {
|
|
74
|
-
return LoginRes.INVALID_PARAM((0, i18n_1.t)('SecretID 或 SecretKey 不能为空'));
|
|
75
|
-
}
|
|
76
|
-
const credential = yield utils_1.authSupevisor.loginByApiSecret(secretId, secretKey, token);
|
|
42
|
+
});
|
|
77
43
|
if (lodash_1.default.isEmpty(credential)) {
|
|
78
44
|
return LoginRes.INVALID_TOKEN;
|
|
79
45
|
}
|
|
80
|
-
return
|
|
81
|
-
|
|
46
|
+
return {
|
|
47
|
+
credential,
|
|
48
|
+
...LoginRes.SUCCESS
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error((0, i18n_1.t)('Web 授权登录失败,可能是环境兼容性问题'));
|
|
53
|
+
console.error((0, i18n_1.t)('建议使用密钥登录:tcb login --key'));
|
|
54
|
+
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' }));
|
|
55
|
+
return {
|
|
56
|
+
code: 'WEB_AUTH_FAILED',
|
|
57
|
+
msg: (0, i18n_1.t)('Web 授权登录失败,请使用密钥登录:tcb login --key'),
|
|
58
|
+
error: error.message
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.loginByWebAuth = loginByWebAuth;
|
|
63
|
+
async function loginWithKey(secretId, secretKey, token) {
|
|
64
|
+
if (!secretId || !secretKey) {
|
|
65
|
+
return LoginRes.INVALID_PARAM((0, i18n_1.t)('SecretID 或 SecretKey 不能为空'));
|
|
66
|
+
}
|
|
67
|
+
const credential = await utils_1.authSupevisor.loginByApiSecret(secretId, secretKey, token);
|
|
68
|
+
if (lodash_1.default.isEmpty(credential)) {
|
|
69
|
+
return LoginRes.INVALID_TOKEN;
|
|
70
|
+
}
|
|
71
|
+
return LoginRes.SUCCESS;
|
|
82
72
|
}
|
|
83
73
|
exports.loginWithKey = loginWithKey;
|
|
84
|
-
function login(options = {}) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return key ? loginWithKey(secretId, secretKey, token) : loginByWebAuth();
|
|
88
|
-
});
|
|
74
|
+
async function login(options = {}) {
|
|
75
|
+
const { secretId, secretKey, key, token } = options;
|
|
76
|
+
return key ? loginWithKey(secretId, secretKey, token) : loginByWebAuth();
|
|
89
77
|
}
|
|
90
78
|
exports.login = login;
|
|
91
|
-
function checkLogin() {
|
|
79
|
+
async function checkLogin() {
|
|
92
80
|
var _a;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
yield (0, utils_1.checkEnvAvaliable)(envId);
|
|
106
|
-
}
|
|
81
|
+
const credential = await (0, utils_1.checkAndGetCredential)();
|
|
82
|
+
if (lodash_1.default.isEmpty(credential)) {
|
|
83
|
+
log.info((0, i18n_1.t)('你还没有登录,请在控制台中授权登录'));
|
|
84
|
+
const res = await (0, utils_1.execWithLoading)(() => login(), {
|
|
85
|
+
startTip: (0, i18n_1.t)('请在浏览器中打开的授权页面进行授权...'),
|
|
86
|
+
successTip: (0, i18n_1.t)('授权登录成功!')
|
|
87
|
+
});
|
|
88
|
+
const envId = (_a = res === null || res === void 0 ? void 0 : res.credential) === null || _a === void 0 ? void 0 : _a.envId;
|
|
89
|
+
if (envId) {
|
|
90
|
+
const env = await (0, env_1.getEnvInfo)(envId);
|
|
91
|
+
if (env.Status === "UNAVAILABLE") {
|
|
92
|
+
await (0, utils_1.checkEnvAvaliable)(envId);
|
|
107
93
|
}
|
|
108
94
|
}
|
|
109
|
-
}
|
|
95
|
+
}
|
|
110
96
|
}
|
|
111
97
|
exports.checkLogin = checkLogin;
|
package/lib/auth/logout.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.logout = void 0;
|
|
13
4
|
const utils_1 = require("../utils");
|
|
14
|
-
function logout() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
yield utils_1.authSupevisor.logout();
|
|
18
|
-
});
|
|
5
|
+
async function logout() {
|
|
6
|
+
process.emit('logout');
|
|
7
|
+
await utils_1.authSupevisor.logout();
|
|
19
8
|
}
|
|
20
9
|
exports.logout = logout;
|
|
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
14
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
16
|
};
|
|
@@ -49,22 +40,20 @@ ${chalk_1.default.gray('–')} ${(0, i18n_1.t)('查看命令使用介绍')}
|
|
|
49
40
|
${(0, i18n_1.t)('Tips:可以使用简写命令 tcb 代替 cloudbase')}`;
|
|
50
41
|
console.log(tips);
|
|
51
42
|
}
|
|
52
|
-
function askForCollectDataConfirm() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
default: true
|
|
62
|
-
});
|
|
63
|
-
if (confirm) {
|
|
64
|
-
yield utils_1.usageStore.set('agreeCollect', true);
|
|
65
|
-
}
|
|
66
|
-
yield (0, utils_1.collectAgree)(confirm);
|
|
43
|
+
async function askForCollectDataConfirm() {
|
|
44
|
+
const agree = await utils_1.usageStore.get('agreeCollect');
|
|
45
|
+
if (agree)
|
|
46
|
+
return;
|
|
47
|
+
const { confirm } = await inquirer_1.default.prompt({
|
|
48
|
+
type: 'confirm',
|
|
49
|
+
name: 'confirm',
|
|
50
|
+
message: (0, i18n_1.t)('是否同意 Cloudbase CLI 收集您的使用数据以改进产品?'),
|
|
51
|
+
default: true
|
|
67
52
|
});
|
|
53
|
+
if (confirm) {
|
|
54
|
+
await utils_1.usageStore.set('agreeCollect', true);
|
|
55
|
+
}
|
|
56
|
+
await (0, utils_1.collectAgree)(confirm);
|
|
68
57
|
}
|
|
69
58
|
let LoginCommand = class LoginCommand extends common_1.Command {
|
|
70
59
|
get options() {
|
|
@@ -93,149 +82,147 @@ let LoginCommand = class LoginCommand extends common_1.Command {
|
|
|
93
82
|
withoutAuth: true
|
|
94
83
|
};
|
|
95
84
|
}
|
|
96
|
-
execute(options, log) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
85
|
+
async execute(options, log) {
|
|
86
|
+
log.verbose(options);
|
|
87
|
+
const { apiKeyId, apiKey, token } = options;
|
|
88
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
89
|
+
loading.start((0, i18n_1.t)('检验登录状态'));
|
|
90
|
+
const credential = await (0, utils_1.checkAndGetCredential)();
|
|
91
|
+
if (!lodash_1.default.isEmpty(credential)) {
|
|
92
|
+
loading.succeed((0, i18n_1.t)('您已登录,无需再次登录!'));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
loading.stop();
|
|
97
|
+
}
|
|
98
|
+
if (apiKey && apiKeyId) {
|
|
99
|
+
loading.start((0, i18n_1.t)('正在验证腾讯云密钥...'));
|
|
100
|
+
const res = await (0, auth_1.login)({
|
|
101
|
+
token,
|
|
102
|
+
key: true,
|
|
103
|
+
secretKey: apiKey,
|
|
104
|
+
secretId: apiKeyId
|
|
105
|
+
});
|
|
106
|
+
if (res.code === 'SUCCESS') {
|
|
107
|
+
loading.succeed((0, i18n_1.t)('登录成功!'));
|
|
108
|
+
printSuggestion();
|
|
106
109
|
}
|
|
107
110
|
else {
|
|
108
|
-
loading.
|
|
111
|
+
loading.fail((0, i18n_1.t)('腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!'));
|
|
112
|
+
return process.exit(1);
|
|
109
113
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
114
|
+
}
|
|
115
|
+
else if (options.key) {
|
|
116
|
+
const clickableLink = (0, utils_1.genClickableLink)(`${utils_1.EUrl.Console}/cam/capi`);
|
|
117
|
+
console.log((0, i18n_1.t)('您可以访问 {{link}} 获取 API 秘钥', { link: clickableLink }));
|
|
118
|
+
const { secretId } = await inquirer_1.default.prompt({
|
|
119
|
+
type: 'input',
|
|
120
|
+
name: 'secretId',
|
|
121
|
+
message: (0, i18n_1.t)('请输入腾讯云 SecretID:')
|
|
122
|
+
});
|
|
123
|
+
const { secretKey } = await inquirer_1.default.prompt({
|
|
124
|
+
type: 'input',
|
|
125
|
+
name: 'secretKey',
|
|
126
|
+
message: (0, i18n_1.t)('请输入腾讯云 SecretKey:')
|
|
127
|
+
});
|
|
128
|
+
if (!secretId || !secretKey) {
|
|
129
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('SecretID 或 SecretKey 不能为空'));
|
|
126
130
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
name: 'secretKey',
|
|
138
|
-
message: (0, i18n_1.t)('请输入腾讯云 SecretKey:')
|
|
139
|
-
});
|
|
140
|
-
if (!secretId || !secretKey) {
|
|
141
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('SecretID 或 SecretKey 不能为空'));
|
|
142
|
-
}
|
|
143
|
-
loading.start((0, i18n_1.t)('正在验证腾讯云密钥...'));
|
|
144
|
-
const res = yield (0, auth_1.login)({
|
|
145
|
-
key: true,
|
|
146
|
-
secretId,
|
|
147
|
-
secretKey
|
|
148
|
-
});
|
|
149
|
-
if (res.code === 'SUCCESS') {
|
|
150
|
-
loading.succeed((0, i18n_1.t)('登录成功!'));
|
|
151
|
-
yield askForCollectDataConfirm();
|
|
152
|
-
printSuggestion();
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
loading.fail((0, i18n_1.t)('腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!'));
|
|
156
|
-
return process.exit(1);
|
|
157
|
-
}
|
|
131
|
+
loading.start((0, i18n_1.t)('正在验证腾讯云密钥...'));
|
|
132
|
+
const res = await (0, auth_1.login)({
|
|
133
|
+
key: true,
|
|
134
|
+
secretId,
|
|
135
|
+
secretKey
|
|
136
|
+
});
|
|
137
|
+
if (res.code === 'SUCCESS') {
|
|
138
|
+
loading.succeed((0, i18n_1.t)('登录成功!'));
|
|
139
|
+
await askForCollectDataConfirm();
|
|
140
|
+
printSuggestion();
|
|
158
141
|
}
|
|
159
142
|
else {
|
|
160
|
-
loading.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
143
|
+
loading.fail((0, i18n_1.t)('腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!'));
|
|
144
|
+
return process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
loading.start((0, i18n_1.t)('请在浏览器中打开的授权页面进行授权...'));
|
|
149
|
+
const res = await (0, auth_1.login)();
|
|
150
|
+
if (res.code === 'SUCCESS') {
|
|
151
|
+
loading.succeed((0, i18n_1.t)('登录成功!'));
|
|
152
|
+
await askForCollectDataConfirm();
|
|
153
|
+
printSuggestion();
|
|
154
|
+
}
|
|
155
|
+
else if (res.code === 'WEB_AUTH_FAILED') {
|
|
156
|
+
loading.fail((0, i18n_1.t)('Web 授权登录失败'));
|
|
157
|
+
console.log(chalk_1.default.yellow((0, i18n_1.t)('⚠️ 检测到环境兼容性问题')));
|
|
158
|
+
console.log(chalk_1.default.cyan((0, i18n_1.t)('建议使用密钥登录:')));
|
|
159
|
+
console.log(chalk_1.default.cyan((0, i18n_1.t)('tcb login --key')));
|
|
160
|
+
console.log(chalk_1.default.gray((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' })));
|
|
161
|
+
console.log('');
|
|
162
|
+
const { useKey } = await inquirer_1.default.prompt({
|
|
163
|
+
type: 'confirm',
|
|
164
|
+
name: 'useKey',
|
|
165
|
+
message: (0, i18n_1.t)('是否切换到密钥登录模式?'),
|
|
166
|
+
default: true
|
|
167
|
+
});
|
|
168
|
+
if (useKey) {
|
|
169
|
+
const clickableLink = (0, utils_1.genClickableLink)('https://console.cloud.tencent.com/cam/capi');
|
|
170
|
+
console.log((0, i18n_1.t)('您可以访问 {{link}} 获取 API 秘钥', { link: clickableLink }));
|
|
171
|
+
const { secretId } = await inquirer_1.default.prompt({
|
|
172
|
+
type: 'input',
|
|
173
|
+
name: 'secretId',
|
|
174
|
+
message: (0, i18n_1.t)('请输入腾讯云 SecretID:')
|
|
175
|
+
});
|
|
176
|
+
const { secretKey } = await inquirer_1.default.prompt({
|
|
177
|
+
type: 'input',
|
|
178
|
+
name: 'secretKey',
|
|
179
|
+
message: (0, i18n_1.t)('请输入腾讯云 SecretKey:')
|
|
179
180
|
});
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (!secretId || !secretKey) {
|
|
194
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('SecretID 或 SecretKey 不能为空'));
|
|
195
|
-
}
|
|
196
|
-
loading.start((0, i18n_1.t)('正在验证腾讯云密钥...'));
|
|
197
|
-
const keyRes = yield (0, auth_1.login)({
|
|
198
|
-
key: true,
|
|
199
|
-
secretId,
|
|
200
|
-
secretKey
|
|
201
|
-
});
|
|
202
|
-
if (keyRes.code === 'SUCCESS') {
|
|
203
|
-
loading.succeed((0, i18n_1.t)('登录成功!'));
|
|
204
|
-
yield askForCollectDataConfirm();
|
|
205
|
-
printSuggestion();
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
loading.fail((0, i18n_1.t)('腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!'));
|
|
209
|
-
return process.exit(1);
|
|
210
|
-
}
|
|
181
|
+
if (!secretId || !secretKey) {
|
|
182
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('SecretID 或 SecretKey 不能为空'));
|
|
183
|
+
}
|
|
184
|
+
loading.start((0, i18n_1.t)('正在验证腾讯云密钥...'));
|
|
185
|
+
const keyRes = await (0, auth_1.login)({
|
|
186
|
+
key: true,
|
|
187
|
+
secretId,
|
|
188
|
+
secretKey
|
|
189
|
+
});
|
|
190
|
+
if (keyRes.code === 'SUCCESS') {
|
|
191
|
+
loading.succeed((0, i18n_1.t)('登录成功!'));
|
|
192
|
+
await askForCollectDataConfirm();
|
|
193
|
+
printSuggestion();
|
|
211
194
|
}
|
|
212
195
|
else {
|
|
196
|
+
loading.fail((0, i18n_1.t)('腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!'));
|
|
213
197
|
return process.exit(1);
|
|
214
198
|
}
|
|
215
199
|
}
|
|
216
200
|
else {
|
|
217
|
-
loading.fail(res.msg);
|
|
218
|
-
console.log((0, i18n_1.t)('Web 授权登录失败,秘钥校验失败!'));
|
|
219
201
|
return process.exit(1);
|
|
220
202
|
}
|
|
221
203
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
log.warn((0, i18n_1.t)('您还没有可用的环境,请前往控制台 {{link}} 创建环境', { link: (0, utils_1.genClickableLink)(consoleUrl) }));
|
|
227
|
-
}
|
|
204
|
+
else {
|
|
205
|
+
loading.fail(res.msg);
|
|
206
|
+
console.log((0, i18n_1.t)('Web 授权登录失败,秘钥校验失败!'));
|
|
207
|
+
return process.exit(1);
|
|
228
208
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
throw e;
|
|
236
|
-
}
|
|
209
|
+
}
|
|
210
|
+
const consoleUrl = `${utils_1.EUrl.TcbConsole}/env/index?action=CreateEnv&from=cli`;
|
|
211
|
+
try {
|
|
212
|
+
const envs = await (0, env_1.listEnvs)();
|
|
213
|
+
if (!envs.length) {
|
|
214
|
+
log.warn((0, i18n_1.t)('您还没有可用的环境,请前往控制台 {{link}} 创建环境', { link: (0, utils_1.genClickableLink)(consoleUrl) }));
|
|
237
215
|
}
|
|
238
|
-
}
|
|
216
|
+
}
|
|
217
|
+
catch (e) {
|
|
218
|
+
if (e.code === 'ResourceNotFound.UserNotExists') {
|
|
219
|
+
log.error((0, i18n_1.t)('您还没有可用的环境,请前往控制台 {{link}} 创建环境', { link: (0, utils_1.genClickableLink)(consoleUrl) }));
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
console.error(e);
|
|
223
|
+
throw e;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
239
226
|
}
|
|
240
227
|
};
|
|
241
228
|
__decorate([
|
|
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
15
|
exports.LogoutCommand = void 0;
|
|
25
16
|
const common_1 = require("../common");
|
|
@@ -36,11 +27,9 @@ let LogoutCommand = class LogoutCommand extends common_1.Command {
|
|
|
36
27
|
withoutAuth: true
|
|
37
28
|
};
|
|
38
29
|
}
|
|
39
|
-
execute(log) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
log.success((0, i18n_1.t)('注销登录成功!'));
|
|
43
|
-
});
|
|
30
|
+
async execute(log) {
|
|
31
|
+
await (0, auth_1.logout)();
|
|
32
|
+
log.success((0, i18n_1.t)('注销登录成功!'));
|
|
44
33
|
}
|
|
45
34
|
};
|
|
46
35
|
__decorate([
|