@cloudbase/cli 2.8.2-beta.2 → 2.8.2-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.
- package/lib/utils/ai/env.js +29 -0
- package/lib/utils/ai/router.js +5 -0
- package/package.json +1 -1
- package/types/utils/ai/env.d.ts +2 -0
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ensureValidEnv = void 0;
|
|
13
|
+
const env_1 = require("../../env");
|
|
14
|
+
const constants_1 = require("../../commands/constants");
|
|
15
|
+
function ensureValidEnv(envId, log) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const envs = yield (0, env_1.listEnvs)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
18
|
+
const validEnv = envs.find((env) => env.EnvId === envId);
|
|
19
|
+
if (!validEnv) {
|
|
20
|
+
log.error(`❌ 环境 ${envId} 与当前账号不匹配,请运行 tcb ai --setup 配置其他环境`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
if (validEnv.Status !== constants_1.EnvStatus.NORMAL) {
|
|
24
|
+
log.error(`❌ 环境 ${envId} 不可用,请运行 tcb ai --setup 配置其他环境 ${validEnv.Status}`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.ensureValidEnv = ensureValidEnv;
|
package/lib/utils/ai/router.js
CHANGED
|
@@ -53,6 +53,7 @@ const utils_1 = require("../../commands/utils");
|
|
|
53
53
|
const auth_1 = require("../../auth");
|
|
54
54
|
const nodeVersion_1 = require("./nodeVersion");
|
|
55
55
|
const claudeWindows_1 = require("./claudeWindows");
|
|
56
|
+
const env_1 = require("./env");
|
|
56
57
|
const IDE_FILE_MAPPINGS = {
|
|
57
58
|
cursor: [
|
|
58
59
|
{ path: '.cursor/rules/cloudbase-rules.mdc' },
|
|
@@ -513,6 +514,7 @@ class AICommandRouter {
|
|
|
513
514
|
const envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
514
515
|
yield (0, auth_1.checkLogin)();
|
|
515
516
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
517
|
+
yield (0, env_1.ensureValidEnv)(envId, log);
|
|
516
518
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
517
519
|
envId,
|
|
518
520
|
secretId: credential.secretId,
|
|
@@ -592,6 +594,7 @@ class AICommandRouter {
|
|
|
592
594
|
const envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
593
595
|
yield (0, auth_1.checkLogin)();
|
|
594
596
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
597
|
+
yield (0, env_1.ensureValidEnv)(envId, log);
|
|
595
598
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
596
599
|
envId,
|
|
597
600
|
secretId: credential.secretId,
|
|
@@ -789,6 +792,7 @@ class AICommandRouter {
|
|
|
789
792
|
const envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
790
793
|
yield (0, auth_1.checkLogin)();
|
|
791
794
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
795
|
+
yield (0, env_1.ensureValidEnv)(envId, log);
|
|
792
796
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
793
797
|
envId,
|
|
794
798
|
secretId: credential.secretId,
|
|
@@ -857,6 +861,7 @@ class AICommandRouter {
|
|
|
857
861
|
const envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
858
862
|
yield (0, auth_1.checkLogin)();
|
|
859
863
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
864
|
+
yield (0, env_1.ensureValidEnv)(envId, log);
|
|
860
865
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
861
866
|
envId,
|
|
862
867
|
secretId: credential.secretId,
|
package/package.json
CHANGED