@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
|
@@ -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.PackageStandalonegateway = void 0;
|
|
25
16
|
const common_1 = require("../../common");
|
|
@@ -32,7 +23,9 @@ const utils_1 = require("../../../utils");
|
|
|
32
23
|
const i18n_1 = require("../../../i18n");
|
|
33
24
|
let PackageStandalonegateway = class PackageStandalonegateway extends common_1.Command {
|
|
34
25
|
get options() {
|
|
35
|
-
return
|
|
26
|
+
return {
|
|
27
|
+
...(0, common_2.standalonegatewayCommonOptions)('package <operation>'),
|
|
28
|
+
options: [
|
|
36
29
|
{
|
|
37
30
|
flags: '-e, --envId <envId>',
|
|
38
31
|
desc: (0, i18n_1.t)('环境 Id')
|
|
@@ -41,35 +34,35 @@ let PackageStandalonegateway = class PackageStandalonegateway extends common_1.C
|
|
|
41
34
|
flags: '-p, --packageVersion <packageVersion>',
|
|
42
35
|
desc: (0, i18n_1.t)('套餐版本')
|
|
43
36
|
}
|
|
44
|
-
],
|
|
37
|
+
],
|
|
38
|
+
desc: (0, i18n_1.t)('套餐操作')
|
|
39
|
+
};
|
|
45
40
|
}
|
|
46
|
-
execute(envId, params, options) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
});
|
|
41
|
+
async execute(envId, params, options) {
|
|
42
|
+
const operation = params === null || params === void 0 ? void 0 : params[0];
|
|
43
|
+
if (!operation || ['list'].indexOf(operation) === -1) {
|
|
44
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入具体操作'));
|
|
45
|
+
}
|
|
46
|
+
switch (operation) {
|
|
47
|
+
case 'list':
|
|
48
|
+
{
|
|
49
|
+
let { appId, packageVersion = '' } = options;
|
|
50
|
+
appId = String(appId);
|
|
51
|
+
packageVersion = String(packageVersion);
|
|
52
|
+
const loading = (0, toolbox_1.loadingFactory)();
|
|
53
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
54
|
+
const data = await (0, run_1.listPackageStandalonegateway)({
|
|
55
|
+
envId,
|
|
56
|
+
packageVersion
|
|
57
|
+
});
|
|
58
|
+
loading.stop();
|
|
59
|
+
const head = [(0, i18n_1.t)('CPU'), (0, i18n_1.t)('内存'), (0, i18n_1.t)('版本')];
|
|
60
|
+
(0, utils_1.printHorizontalTable)(head, data);
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
73
66
|
}
|
|
74
67
|
};
|
|
75
68
|
__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.TurnStandalonegateway = void 0;
|
|
25
16
|
const common_1 = require("../../common");
|
|
@@ -31,7 +22,9 @@ const error_1 = require("../../../error");
|
|
|
31
22
|
const i18n_1 = require("../../../i18n");
|
|
32
23
|
let TurnStandalonegateway = class TurnStandalonegateway extends common_1.Command {
|
|
33
24
|
get options() {
|
|
34
|
-
return
|
|
25
|
+
return {
|
|
26
|
+
...(0, common_2.standalonegatewayCommonOptions)('turn <status>'),
|
|
27
|
+
options: [
|
|
35
28
|
{
|
|
36
29
|
flags: '-e, --envId <envId>',
|
|
37
30
|
desc: (0, i18n_1.t)('环境 Id')
|
|
@@ -44,32 +37,32 @@ let TurnStandalonegateway = class TurnStandalonegateway extends common_1.Command
|
|
|
44
37
|
flags: '-sL, --serviceList <serviceList...>',
|
|
45
38
|
desc: (0, i18n_1.t)('云托管服务列表')
|
|
46
39
|
}
|
|
47
|
-
],
|
|
40
|
+
],
|
|
41
|
+
desc: (0, i18n_1.t)('启停小租户网关')
|
|
42
|
+
};
|
|
48
43
|
}
|
|
49
|
-
execute(envId, params, options) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
serviceList
|
|
69
|
-
});
|
|
70
|
-
loading.stop();
|
|
71
|
-
console.log((0, i18n_1.t)('操作执行成功'));
|
|
44
|
+
async execute(envId, params, options) {
|
|
45
|
+
const status = params === null || params === void 0 ? void 0 : params[0];
|
|
46
|
+
if (!status || ['on', 'off'].indexOf(status) === -1) {
|
|
47
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入启停状态'));
|
|
48
|
+
}
|
|
49
|
+
let { gatewayName = '', serviceList = [] } = options;
|
|
50
|
+
gatewayName = String(gatewayName);
|
|
51
|
+
if (gatewayName === '') {
|
|
52
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入网关名'));
|
|
53
|
+
}
|
|
54
|
+
if (serviceList.length === 0) {
|
|
55
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入云托管服务列表'));
|
|
56
|
+
}
|
|
57
|
+
const loading = (0, toolbox_1.loadingFactory)();
|
|
58
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
59
|
+
await (status === 'on' ? run_1.turnOnStandalonegateway : run_1.turnOffStandalonegateway)({
|
|
60
|
+
envId,
|
|
61
|
+
gatewayName,
|
|
62
|
+
serviceList
|
|
72
63
|
});
|
|
64
|
+
loading.stop();
|
|
65
|
+
console.log((0, i18n_1.t)('操作执行成功'));
|
|
73
66
|
}
|
|
74
67
|
};
|
|
75
68
|
__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.CreateVersion = void 0;
|
|
25
16
|
const fs_1 = require("fs");
|
|
@@ -47,7 +38,9 @@ const memMap = {
|
|
|
47
38
|
};
|
|
48
39
|
let CreateVersion = class CreateVersion extends common_1.Command {
|
|
49
40
|
get options() {
|
|
50
|
-
return
|
|
41
|
+
return {
|
|
42
|
+
...(0, common_2.versionCommonOptions)('create'),
|
|
43
|
+
options: [
|
|
51
44
|
{
|
|
52
45
|
flags: '-e, --envId <envId>',
|
|
53
46
|
desc: (0, i18n_1.t)('环境 Id')
|
|
@@ -112,207 +105,207 @@ let CreateVersion = class CreateVersion extends common_1.Command {
|
|
|
112
105
|
flags: '--env <env>',
|
|
113
106
|
desc: (0, i18n_1.t)('环境变量,格式为xx=a&yy=b,默认为空')
|
|
114
107
|
}
|
|
115
|
-
],
|
|
108
|
+
],
|
|
109
|
+
desc: (0, i18n_1.t)('创建云开发环境下云托管服务的版本')
|
|
110
|
+
};
|
|
116
111
|
}
|
|
117
|
-
execute(envId, options) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
path = `./code${uid}.zip`;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
else if (_repo) {
|
|
158
|
-
const repo = _repo.split('|');
|
|
159
|
-
repositoryType = repo[0];
|
|
160
|
-
codeDetail.Name.FullName = repo[1];
|
|
161
|
-
codeDetail.Name.Name = repo[1].split('/')[1];
|
|
162
|
-
branch = repo[2];
|
|
163
|
-
}
|
|
164
|
-
else if (_image) {
|
|
165
|
-
imageInfo = {
|
|
166
|
-
ImageUrl: _image
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('请至少选择一个上传方式'));
|
|
171
|
-
}
|
|
172
|
-
containerPort = Number(_port);
|
|
173
|
-
if (isNaN(containerPort)) {
|
|
174
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的端口号'));
|
|
175
|
-
}
|
|
176
|
-
flowRatio = Number(_flow);
|
|
177
|
-
if (![100, 0].includes(flowRatio)) {
|
|
178
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的流量策略'));
|
|
179
|
-
}
|
|
180
|
-
versionRemark = _remark;
|
|
181
|
-
cpu = Number(_cpu);
|
|
182
|
-
mem = Number(_mem);
|
|
183
|
-
if (isNaN(cpu) || isNaN(mem)) {
|
|
184
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的cpu和内存规格'));
|
|
185
|
-
}
|
|
186
|
-
minNum = Number(_copy.split('~')[0]);
|
|
187
|
-
maxNum = Number(_copy.split('~')[1]);
|
|
188
|
-
if (isNaN(maxNum) || isNaN(minNum)) {
|
|
189
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的副本个数'));
|
|
190
|
-
}
|
|
191
|
-
policyType = _policy.split('|')[0];
|
|
192
|
-
policyThreshold = Number(_policy.split('|')[1]);
|
|
193
|
-
if (!['cpu', 'mem'].includes(policyType) || isNaN(policyThreshold)) {
|
|
194
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的扩缩容条件'));
|
|
112
|
+
async execute(envId, options) {
|
|
113
|
+
let envCheckType = await (0, utils_1.checkTcbrEnv)(options.envId, false);
|
|
114
|
+
if (envCheckType !== 0) {
|
|
115
|
+
(0, utils_1.logEnvCheck)(envId, envCheckType);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
let { serviceName = '', path: _path = '', repo: _repo = '', image: _image = '', port: _port = '80', flow: _flow = '0', remark: _remark = '', cpu: _cpu = '0.5', mem: _mem = '1', copy: _copy = '0~50', policy: _policy = 'cpu|60', dockerfile: _dockerfile = 'Dockerfile', log: _log = 'stdout', delay: _delay = '2', env: _env = '' } = options;
|
|
119
|
+
if (!serviceName) {
|
|
120
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('必须输入 serviceName'));
|
|
121
|
+
}
|
|
122
|
+
let path;
|
|
123
|
+
let repositoryType;
|
|
124
|
+
let branch;
|
|
125
|
+
let codeDetail;
|
|
126
|
+
let imageInfo;
|
|
127
|
+
let containerPort;
|
|
128
|
+
let flowRatio;
|
|
129
|
+
let versionRemark;
|
|
130
|
+
let cpu;
|
|
131
|
+
let mem;
|
|
132
|
+
let minNum;
|
|
133
|
+
let maxNum;
|
|
134
|
+
let policyType;
|
|
135
|
+
let policyThreshold;
|
|
136
|
+
let customLogs = 'stdout';
|
|
137
|
+
let dockerfilePath = 'Dockerfile';
|
|
138
|
+
let initialDelaySeconds = 2;
|
|
139
|
+
let envParams = '{}';
|
|
140
|
+
const uid = (0, utils_1.random)(4);
|
|
141
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
142
|
+
if (_path) {
|
|
143
|
+
path = _path;
|
|
144
|
+
if ((0, fs_1.statSync)(path).isDirectory()) {
|
|
145
|
+
loading.start((0, i18n_1.t)('正在压缩中'));
|
|
146
|
+
await (0, toolbox_1.zipDir)(path, `./code${uid}.zip`);
|
|
147
|
+
loading.succeed((0, i18n_1.t)('压缩完成'));
|
|
148
|
+
path = `./code${uid}.zip`;
|
|
195
149
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
150
|
+
}
|
|
151
|
+
else if (_repo) {
|
|
152
|
+
const repo = _repo.split('|');
|
|
153
|
+
repositoryType = repo[0];
|
|
154
|
+
codeDetail.Name.FullName = repo[1];
|
|
155
|
+
codeDetail.Name.Name = repo[1].split('/')[1];
|
|
156
|
+
branch = repo[2];
|
|
157
|
+
}
|
|
158
|
+
else if (_image) {
|
|
159
|
+
imageInfo = {
|
|
160
|
+
ImageUrl: _image
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请至少选择一个上传方式'));
|
|
165
|
+
}
|
|
166
|
+
containerPort = Number(_port);
|
|
167
|
+
if (isNaN(containerPort)) {
|
|
168
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的端口号'));
|
|
169
|
+
}
|
|
170
|
+
flowRatio = Number(_flow);
|
|
171
|
+
if (![100, 0].includes(flowRatio)) {
|
|
172
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的流量策略'));
|
|
173
|
+
}
|
|
174
|
+
versionRemark = _remark;
|
|
175
|
+
cpu = Number(_cpu);
|
|
176
|
+
mem = Number(_mem);
|
|
177
|
+
if (isNaN(cpu) || isNaN(mem)) {
|
|
178
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的cpu和内存规格'));
|
|
179
|
+
}
|
|
180
|
+
minNum = Number(_copy.split('~')[0]);
|
|
181
|
+
maxNum = Number(_copy.split('~')[1]);
|
|
182
|
+
if (isNaN(maxNum) || isNaN(minNum)) {
|
|
183
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的副本个数'));
|
|
184
|
+
}
|
|
185
|
+
policyType = _policy.split('|')[0];
|
|
186
|
+
policyThreshold = Number(_policy.split('|')[1]);
|
|
187
|
+
if (!['cpu', 'mem'].includes(policyType) || isNaN(policyThreshold)) {
|
|
188
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的扩缩容条件'));
|
|
189
|
+
}
|
|
190
|
+
dockerfilePath = _dockerfile;
|
|
191
|
+
customLogs = _log;
|
|
192
|
+
initialDelaySeconds = Number(_delay);
|
|
193
|
+
if (isNaN(initialDelaySeconds)) {
|
|
194
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请输入合法的延迟时间'));
|
|
195
|
+
}
|
|
196
|
+
let _envParams = {};
|
|
197
|
+
_env.split('&').forEach((item) => {
|
|
198
|
+
_envParams[item.split('=')[0]] = item.split('=')[1];
|
|
199
|
+
});
|
|
200
|
+
envParams = JSON.stringify(_envParams);
|
|
201
|
+
loading.start((0, i18n_1.t)('加载中...'));
|
|
202
|
+
let res = '';
|
|
203
|
+
let runId = '';
|
|
204
|
+
if (_path) {
|
|
205
|
+
loading.start((0, i18n_1.t)('正在上传中'));
|
|
206
|
+
let { PackageName, PackageVersion, UploadHeaders, UploadUrl } = await (0, run_1.createBuild)({
|
|
207
|
+
envId,
|
|
208
|
+
serviceName
|
|
205
209
|
});
|
|
206
|
-
|
|
207
|
-
loading.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
loading.
|
|
212
|
-
let { PackageName, PackageVersion, UploadHeaders, UploadUrl } = yield (0, run_1.createBuild)({
|
|
213
|
-
envId,
|
|
214
|
-
serviceName
|
|
215
|
-
});
|
|
216
|
-
yield (0, run_1.uploadZip)(path, UploadUrl, UploadHeaders[0]);
|
|
217
|
-
loading.succeed((0, i18n_1.t)('上传成功'));
|
|
218
|
-
if (path === `./code${uid}.zip`) {
|
|
219
|
-
loading.start((0, i18n_1.t)('删除本地压缩包'));
|
|
220
|
-
(0, fs_1.unlinkSync)(path);
|
|
221
|
-
loading.succeed((0, i18n_1.t)('成功删除本地压缩包'));
|
|
222
|
-
}
|
|
223
|
-
let response = yield (0, run_1.createVersion)({
|
|
224
|
-
envId,
|
|
225
|
-
serverName: serviceName,
|
|
226
|
-
containerPort,
|
|
227
|
-
uploadType: 'package',
|
|
228
|
-
packageName: PackageName,
|
|
229
|
-
packageVersion: PackageVersion,
|
|
230
|
-
flowRatio,
|
|
231
|
-
versionRemark,
|
|
232
|
-
enableUnion: true,
|
|
233
|
-
cpu,
|
|
234
|
-
mem,
|
|
235
|
-
minNum,
|
|
236
|
-
maxNum,
|
|
237
|
-
policyType,
|
|
238
|
-
policyThreshold,
|
|
239
|
-
customLogs,
|
|
240
|
-
dockerfilePath,
|
|
241
|
-
envParams,
|
|
242
|
-
initialDelaySeconds
|
|
243
|
-
});
|
|
244
|
-
res = response.Result;
|
|
245
|
-
runId = response.RunId;
|
|
210
|
+
await (0, run_1.uploadZip)(path, UploadUrl, UploadHeaders[0]);
|
|
211
|
+
loading.succeed((0, i18n_1.t)('上传成功'));
|
|
212
|
+
if (path === `./code${uid}.zip`) {
|
|
213
|
+
loading.start((0, i18n_1.t)('删除本地压缩包'));
|
|
214
|
+
(0, fs_1.unlinkSync)(path);
|
|
215
|
+
loading.succeed((0, i18n_1.t)('成功删除本地压缩包'));
|
|
246
216
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
217
|
+
let response = await (0, run_1.createVersion)({
|
|
218
|
+
envId,
|
|
219
|
+
serverName: serviceName,
|
|
220
|
+
containerPort,
|
|
221
|
+
uploadType: 'package',
|
|
222
|
+
packageName: PackageName,
|
|
223
|
+
packageVersion: PackageVersion,
|
|
224
|
+
flowRatio,
|
|
225
|
+
versionRemark,
|
|
226
|
+
enableUnion: true,
|
|
227
|
+
cpu,
|
|
228
|
+
mem,
|
|
229
|
+
minNum,
|
|
230
|
+
maxNum,
|
|
231
|
+
policyType,
|
|
232
|
+
policyThreshold,
|
|
233
|
+
customLogs,
|
|
234
|
+
dockerfilePath,
|
|
235
|
+
envParams,
|
|
236
|
+
initialDelaySeconds
|
|
237
|
+
});
|
|
238
|
+
res = response.Result;
|
|
239
|
+
runId = response.RunId;
|
|
240
|
+
}
|
|
241
|
+
else if (_image) {
|
|
242
|
+
let response = await (0, run_1.createVersion)({
|
|
243
|
+
envId,
|
|
244
|
+
serverName: serviceName,
|
|
245
|
+
containerPort,
|
|
246
|
+
uploadType: 'image',
|
|
247
|
+
imageInfo,
|
|
248
|
+
flowRatio,
|
|
249
|
+
versionRemark,
|
|
250
|
+
enableUnion: true,
|
|
251
|
+
cpu,
|
|
252
|
+
mem,
|
|
253
|
+
minNum,
|
|
254
|
+
maxNum,
|
|
255
|
+
policyType,
|
|
256
|
+
policyThreshold,
|
|
257
|
+
customLogs,
|
|
258
|
+
envParams,
|
|
259
|
+
initialDelaySeconds
|
|
260
|
+
});
|
|
261
|
+
res = response.Result;
|
|
262
|
+
runId = response.RunId;
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
let response = await (0, run_1.createVersion)({
|
|
266
|
+
envId,
|
|
267
|
+
serverName: serviceName,
|
|
268
|
+
containerPort,
|
|
269
|
+
uploadType: 'repository',
|
|
270
|
+
repositoryType,
|
|
271
|
+
branch,
|
|
272
|
+
codeDetail,
|
|
273
|
+
flowRatio,
|
|
274
|
+
versionRemark,
|
|
275
|
+
enableUnion: true,
|
|
276
|
+
cpu,
|
|
277
|
+
mem,
|
|
278
|
+
minNum,
|
|
279
|
+
maxNum,
|
|
280
|
+
policyType,
|
|
281
|
+
policyThreshold,
|
|
282
|
+
customLogs,
|
|
283
|
+
dockerfilePath,
|
|
284
|
+
envParams,
|
|
285
|
+
initialDelaySeconds
|
|
286
|
+
});
|
|
287
|
+
res = response.Result;
|
|
288
|
+
runId = response.RunId;
|
|
289
|
+
}
|
|
290
|
+
if (res !== 'succ')
|
|
291
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('提交构建任务失败'));
|
|
292
|
+
loading.start((0, i18n_1.t)('正在部署中'));
|
|
293
|
+
while (true) {
|
|
294
|
+
let { Percent, Status } = await (0, run_1.basicOperate)({ envId, runId });
|
|
295
|
+
if (Status === 'build_fail') {
|
|
296
|
+
let logs = await (0, run_1.logCreate)({ envId, runId });
|
|
297
|
+
(0, fs_1.writeFileSync)(`./log${runId}`, logs.reduce((res, item) => res + item + '\n', ''));
|
|
298
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('构建失败,日志写入{{file}}中', { file: `./log${runId}` }));
|
|
295
299
|
}
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
loading.start((0, i18n_1.t)('正在部署中'));
|
|
299
|
-
while (true) {
|
|
300
|
-
let { Percent, Status } = yield (0, run_1.basicOperate)({ envId, runId });
|
|
301
|
-
if (Status === 'build_fail') {
|
|
302
|
-
let logs = yield (0, run_1.logCreate)({ envId, runId });
|
|
303
|
-
(0, fs_1.writeFileSync)(`./log${runId}`, logs.reduce((res, item) => res + item + '\n', ''));
|
|
304
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('构建失败,日志写入{{file}}中', { file: `./log${runId}` }));
|
|
305
|
-
}
|
|
306
|
-
else if (Status !== 'creating') {
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
loading.start((0, i18n_1.t)('目前构建进度{{percent}}%', { percent: Percent }));
|
|
310
|
-
yield new Promise((resolve) => {
|
|
311
|
-
setTimeout((_) => resolve('again'), 2000);
|
|
312
|
-
});
|
|
300
|
+
else if (Status !== 'creating') {
|
|
301
|
+
break;
|
|
313
302
|
}
|
|
314
|
-
loading.
|
|
315
|
-
|
|
303
|
+
loading.start((0, i18n_1.t)('目前构建进度{{percent}}%', { percent: Percent }));
|
|
304
|
+
await new Promise((resolve) => {
|
|
305
|
+
setTimeout((_) => resolve('again'), 2000);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
loading.succeed((0, i18n_1.t)('构建成功'));
|
|
316
309
|
}
|
|
317
310
|
};
|
|
318
311
|
__decorate([
|