@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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
16
|
};
|
|
@@ -37,7 +28,10 @@ const common_2 = require("./common");
|
|
|
37
28
|
const i18n_1 = require("../../../i18n");
|
|
38
29
|
let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
|
|
39
30
|
get options() {
|
|
40
|
-
return
|
|
31
|
+
return {
|
|
32
|
+
...(0, common_2.layerCommonOptions)('download'),
|
|
33
|
+
deprecateCmd: 'functions:layer:download',
|
|
34
|
+
options: [
|
|
41
35
|
{
|
|
42
36
|
flags: '-e, --envId <envId>',
|
|
43
37
|
desc: (0, i18n_1.t)('环境 Id')
|
|
@@ -46,56 +40,56 @@ let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
|
|
|
46
40
|
flags: '--dest <dest>',
|
|
47
41
|
desc: (0, i18n_1.t)('下载文件存放的地址')
|
|
48
42
|
}
|
|
49
|
-
],
|
|
43
|
+
],
|
|
44
|
+
desc: (0, i18n_1.t)('下载云函数文件层')
|
|
45
|
+
};
|
|
50
46
|
}
|
|
51
|
-
execute(envId, options) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
name: layer
|
|
96
|
-
});
|
|
97
|
-
loading.succeed((0, i18n_1.t)('文件下载成功!'));
|
|
47
|
+
async execute(envId, options) {
|
|
48
|
+
const { dest } = options;
|
|
49
|
+
const functionService = await (0, function_1.getFunctionService)(envId);
|
|
50
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
51
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
52
|
+
const listLayersRes = await functionService.listLayers({
|
|
53
|
+
offset: 0,
|
|
54
|
+
limit: 200,
|
|
55
|
+
});
|
|
56
|
+
const layers = listLayersRes.Layers || [];
|
|
57
|
+
loading.stop();
|
|
58
|
+
if (!layers.length) {
|
|
59
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('当前环境没有可用的文件层,请先创建文件层!'));
|
|
60
|
+
}
|
|
61
|
+
const { layer } = await (0, enquirer_1.prompt)({
|
|
62
|
+
type: 'select',
|
|
63
|
+
name: 'layer',
|
|
64
|
+
message: (0, i18n_1.t)('选择文件层名称'),
|
|
65
|
+
choices: layers.map((item) => item.LayerName)
|
|
66
|
+
});
|
|
67
|
+
let listLayerVersionsRes = await functionService.listLayerVersions({
|
|
68
|
+
name: layer
|
|
69
|
+
});
|
|
70
|
+
const layerVersions = listLayerVersionsRes.LayerVersions || [];
|
|
71
|
+
const versions = layerVersions.map((item) => String(item.LayerVersion));
|
|
72
|
+
const { version } = await (0, enquirer_1.prompt)({
|
|
73
|
+
type: 'select',
|
|
74
|
+
name: 'version',
|
|
75
|
+
message: (0, i18n_1.t)('选择文件层版本'),
|
|
76
|
+
choices: versions
|
|
77
|
+
});
|
|
78
|
+
let destPath;
|
|
79
|
+
if (!dest) {
|
|
80
|
+
destPath = path_1.default.resolve(process.cwd(), 'layers');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
destPath = path_1.default.resolve(dest);
|
|
84
|
+
}
|
|
85
|
+
loading.start((0, i18n_1.t)('文件下载中...'));
|
|
86
|
+
await fs_extra_1.default.ensureDir(destPath);
|
|
87
|
+
await functionService.downloadLayer({
|
|
88
|
+
destPath,
|
|
89
|
+
version: Number(version),
|
|
90
|
+
name: layer
|
|
98
91
|
});
|
|
92
|
+
loading.succeed((0, i18n_1.t)('文件下载成功!'));
|
|
99
93
|
}
|
|
100
94
|
};
|
|
101
95
|
__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.ListFileLayer = void 0;
|
|
25
16
|
const common_1 = require("../../common");
|
|
@@ -30,7 +21,10 @@ const common_2 = require("./common");
|
|
|
30
21
|
const i18n_1 = require("../../../i18n");
|
|
31
22
|
let ListFileLayer = class ListFileLayer extends common_1.Command {
|
|
32
23
|
get options() {
|
|
33
|
-
return
|
|
24
|
+
return {
|
|
25
|
+
...(0, common_2.layerCommonOptions)('list'),
|
|
26
|
+
deprecateCmd: 'functions:layer:list',
|
|
27
|
+
options: [
|
|
34
28
|
{
|
|
35
29
|
flags: '-e, --envId <envId>',
|
|
36
30
|
desc: (0, i18n_1.t)('环境 Id')
|
|
@@ -47,47 +41,47 @@ let ListFileLayer = class ListFileLayer extends common_1.Command {
|
|
|
47
41
|
flags: '--code-secret, <codeSecret>',
|
|
48
42
|
desc: (0, i18n_1.t)('代码加密的函数的 CodeSecret')
|
|
49
43
|
}
|
|
50
|
-
],
|
|
44
|
+
],
|
|
45
|
+
desc: (0, i18n_1.t)('展示文件层列表')
|
|
46
|
+
};
|
|
51
47
|
}
|
|
52
|
-
execute(envId, options, log) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
log.info((0, i18n_1.t)('Tips:函数绑定多个版本时,同名文件将按优先级从小到大的顺序进行覆盖执行。'));
|
|
90
|
-
});
|
|
48
|
+
async execute(envId, options, log) {
|
|
49
|
+
const { name, layer, codeSecret } = options;
|
|
50
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
51
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
52
|
+
let data;
|
|
53
|
+
const functionService = await (0, function_1.getFunctionService)(envId);
|
|
54
|
+
if (layer && typeof layer === 'string') {
|
|
55
|
+
const layerName = `${layer}_${envId}`;
|
|
56
|
+
const listLayerVersionsRes = await functionService.listLayerVersions({
|
|
57
|
+
name: layerName
|
|
58
|
+
});
|
|
59
|
+
data = listLayerVersionsRes.LayerVersions || [];
|
|
60
|
+
}
|
|
61
|
+
else if (name && typeof name === 'string') {
|
|
62
|
+
const res = await functionService.getFunctionDetail(name, codeSecret);
|
|
63
|
+
data = (res === null || res === void 0 ? void 0 : res.Layers) || [];
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const listLayersRes = await functionService.listLayers({
|
|
67
|
+
offset: 0,
|
|
68
|
+
limit: 200
|
|
69
|
+
});
|
|
70
|
+
data = listLayersRes.Layers || [];
|
|
71
|
+
}
|
|
72
|
+
loading.stop();
|
|
73
|
+
const head = [(0, i18n_1.t)('优先级'), (0, i18n_1.t)('名称'), (0, i18n_1.t)('状态'), (0, i18n_1.t)('版本'), (0, i18n_1.t)('证书'), (0, i18n_1.t)('支持运行时'), (0, i18n_1.t)('创建时间')];
|
|
74
|
+
const tableData = data.map((item, index) => [
|
|
75
|
+
index + 1,
|
|
76
|
+
item.LayerName,
|
|
77
|
+
item.Status,
|
|
78
|
+
item.LayerVersion,
|
|
79
|
+
item.LicenseInfo || (0, i18n_1.t)('空'),
|
|
80
|
+
item.CompatibleRuntimes.join(' | '),
|
|
81
|
+
item.AddTime
|
|
82
|
+
]);
|
|
83
|
+
(0, utils_1.printHorizontalTable)(head, tableData);
|
|
84
|
+
log.info((0, i18n_1.t)('Tips:函数绑定多个版本时,同名文件将按优先级从小到大的顺序进行覆盖执行。'));
|
|
91
85
|
}
|
|
92
86
|
};
|
|
93
87
|
__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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
16
|
};
|
|
@@ -36,7 +27,10 @@ const common_2 = require("./common");
|
|
|
36
27
|
const i18n_1 = require("../../../i18n");
|
|
37
28
|
let SortFileLayer = class SortFileLayer extends common_1.Command {
|
|
38
29
|
get options() {
|
|
39
|
-
return
|
|
30
|
+
return {
|
|
31
|
+
...(0, common_2.layerCommonOptions)('sort <name>'),
|
|
32
|
+
deprecateCmd: 'functions:layer:sort <name>',
|
|
33
|
+
options: [
|
|
40
34
|
{
|
|
41
35
|
flags: '-e, --envId <envId>',
|
|
42
36
|
desc: (0, i18n_1.t)('环境 Id')
|
|
@@ -45,44 +39,44 @@ let SortFileLayer = class SortFileLayer extends common_1.Command {
|
|
|
45
39
|
flags: '--code-secret, <codeSecret>',
|
|
46
40
|
desc: (0, i18n_1.t)('代码加密的函数的 CodeSecret')
|
|
47
41
|
}
|
|
48
|
-
],
|
|
42
|
+
],
|
|
43
|
+
desc: (0, i18n_1.t)('重新排列云函数绑定的文件层的顺序')
|
|
44
|
+
};
|
|
49
45
|
}
|
|
50
|
-
execute(ctx) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
46
|
+
async execute(ctx) {
|
|
47
|
+
const { envId, options, params } = ctx;
|
|
48
|
+
const { codeSecret } = options;
|
|
49
|
+
const fnName = params === null || params === void 0 ? void 0 : params[0];
|
|
50
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
51
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
52
|
+
const functionService = await (0, function_1.getFunctionService)(envId);
|
|
53
|
+
const detail = await functionService.getFunctionDetail(fnName, codeSecret);
|
|
54
|
+
loading.stop();
|
|
55
|
+
const layers = detail.Layers.map((item) => ({
|
|
56
|
+
name: `${item.LayerName} - ${item.LayerVersion}`,
|
|
57
|
+
value: item
|
|
58
|
+
}));
|
|
59
|
+
if (!layers.length) {
|
|
60
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('没有可用的文件层,请先创建文件层!'));
|
|
61
|
+
}
|
|
62
|
+
let { sortLayers } = await (0, enquirer_1.prompt)({
|
|
63
|
+
type: 'sort',
|
|
64
|
+
name: 'sortLayers',
|
|
65
|
+
message: (0, i18n_1.t)('选择文件层'),
|
|
66
|
+
numbered: true,
|
|
67
|
+
choices: layers,
|
|
68
|
+
result(choices) {
|
|
69
|
+
return Object.values(this.map(choices));
|
|
66
70
|
}
|
|
67
|
-
let { sortLayers } = yield (0, enquirer_1.prompt)({
|
|
68
|
-
type: 'sort',
|
|
69
|
-
name: 'sortLayers',
|
|
70
|
-
message: (0, i18n_1.t)('选择文件层'),
|
|
71
|
-
numbered: true,
|
|
72
|
-
choices: layers,
|
|
73
|
-
result(choices) {
|
|
74
|
-
return Object.values(this.map(choices));
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
sortLayers = sortLayers.map((item) => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
|
|
78
|
-
loading.start((0, i18n_1.t)('文件层排序中...'));
|
|
79
|
-
yield functionService.updateFunctionLayer({
|
|
80
|
-
envId,
|
|
81
|
-
functionName: fnName,
|
|
82
|
-
layers: sortLayers
|
|
83
|
-
});
|
|
84
|
-
loading.succeed((0, i18n_1.t)('文件层排序成功!'));
|
|
85
71
|
});
|
|
72
|
+
sortLayers = sortLayers.map((item) => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
|
|
73
|
+
loading.start((0, i18n_1.t)('文件层排序中...'));
|
|
74
|
+
await functionService.updateFunctionLayer({
|
|
75
|
+
envId,
|
|
76
|
+
functionName: fnName,
|
|
77
|
+
layers: sortLayers
|
|
78
|
+
});
|
|
79
|
+
loading.succeed((0, i18n_1.t)('文件层排序成功!'));
|
|
86
80
|
}
|
|
87
81
|
};
|
|
88
82
|
__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.ListFunction = void 0;
|
|
25
16
|
const common_1 = require("../common");
|
|
@@ -49,33 +40,31 @@ let ListFunction = class ListFunction extends common_1.Command {
|
|
|
49
40
|
desc: (0, i18n_1.t)('展示云函数列表')
|
|
50
41
|
};
|
|
51
42
|
}
|
|
52
|
-
execute(envId, options) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
(0, utils_1.printHorizontalTable)(head, tableData);
|
|
78
|
-
});
|
|
43
|
+
async execute(envId, options) {
|
|
44
|
+
const functionsService = await (0, function_1.getFunctionService)(envId);
|
|
45
|
+
let { limit = 20, offset = 0 } = options;
|
|
46
|
+
limit = Number(limit);
|
|
47
|
+
offset = Number(offset);
|
|
48
|
+
if (!Number.isInteger(limit) || !Number.isInteger(offset)) {
|
|
49
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('limit 和 offset 必须为整数'));
|
|
50
|
+
}
|
|
51
|
+
if (limit < 0 || offset < 0) {
|
|
52
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('limit 和 offset 必须为大于 0 的整数'));
|
|
53
|
+
}
|
|
54
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
55
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
56
|
+
const data = await functionsService.listFunctions(Number(limit), Number(offset));
|
|
57
|
+
loading.stop();
|
|
58
|
+
const head = [(0, i18n_1.t)('函数 Id'), (0, i18n_1.t)('函数名称'), (0, i18n_1.t)('运行时'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('修改时间'), (0, i18n_1.t)('状态')];
|
|
59
|
+
const tableData = data.map((item) => [
|
|
60
|
+
item.FunctionId,
|
|
61
|
+
item.FunctionName,
|
|
62
|
+
item.Runtime,
|
|
63
|
+
item.AddTime,
|
|
64
|
+
item.ModTime,
|
|
65
|
+
constant_1.StatusMap[item.Status]
|
|
66
|
+
]);
|
|
67
|
+
(0, utils_1.printHorizontalTable)(head, tableData);
|
|
79
68
|
}
|
|
80
69
|
};
|
|
81
70
|
__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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
16
|
};
|
|
@@ -74,70 +65,71 @@ let FunctionLog = class FunctionLog extends common_1.Command {
|
|
|
74
65
|
desc: (0, i18n_1.t)('打印云函数日志')
|
|
75
66
|
};
|
|
76
67
|
}
|
|
77
|
-
execute(ctx, argsParams, log) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return `${ResMap[key]}:${
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
68
|
+
async execute(ctx, argsParams, log) {
|
|
69
|
+
const { envId, options } = ctx;
|
|
70
|
+
const name = argsParams === null || argsParams === void 0 ? void 0 : argsParams[0];
|
|
71
|
+
let { offset = 0, limit = 10, order, orderBy, error, success, startTime, endTime, reqId: requestId, qualifier } = options;
|
|
72
|
+
if (!name) {
|
|
73
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('云函数名称不能为空'));
|
|
74
|
+
}
|
|
75
|
+
const TimeLength = 19;
|
|
76
|
+
if (typeof startTime !== 'undefined' &&
|
|
77
|
+
typeof endTime !== 'undefined' &&
|
|
78
|
+
(startTime.length !== TimeLength || endTime.length !== TimeLength)) {
|
|
79
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('时间格式错误,必须为 2019-05-16 20:59:59 类型'));
|
|
80
|
+
}
|
|
81
|
+
if (new Date(endTime).getTime() < new Date(startTime).getTime()) {
|
|
82
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('开始时间不能晚于结束时间'));
|
|
83
|
+
}
|
|
84
|
+
const OneDay = 86400000;
|
|
85
|
+
if (new Date(endTime).getTime() - new Date(startTime).getTime() > OneDay) {
|
|
86
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('endTime 与 startTime 只能相差一天之内'));
|
|
87
|
+
}
|
|
88
|
+
let params = {
|
|
89
|
+
order,
|
|
90
|
+
orderBy,
|
|
91
|
+
startTime,
|
|
92
|
+
endTime,
|
|
93
|
+
requestId,
|
|
94
|
+
offset: Number(offset),
|
|
95
|
+
limit: Number(limit),
|
|
96
|
+
qualifier
|
|
97
|
+
};
|
|
98
|
+
error && (params.filter = { RetCode: 'not0' });
|
|
99
|
+
success && (params.filter = { RetCode: 'is0' });
|
|
100
|
+
params = JSON.parse(JSON.stringify(params));
|
|
101
|
+
const functionService = await (0, function_1.getFunctionService)(envId);
|
|
102
|
+
const logs = await functionService.getCompleteFunctionLogs({
|
|
103
|
+
name,
|
|
104
|
+
...params
|
|
105
|
+
});
|
|
106
|
+
const ResMap = {
|
|
107
|
+
StartTime: (0, i18n_1.t)('请求时间'),
|
|
108
|
+
FunctionName: (0, i18n_1.t)('函数名称'),
|
|
109
|
+
Duration: (0, i18n_1.t)('运行时间(ms)'),
|
|
110
|
+
MemUsage: (0, i18n_1.t)('占用内存'),
|
|
111
|
+
RequestId: (0, i18n_1.t)('请求 Id'),
|
|
112
|
+
RetCode: (0, i18n_1.t)('调用状态'),
|
|
113
|
+
RetMsg: (0, i18n_1.t)('返回结果')
|
|
114
|
+
};
|
|
115
|
+
log.success(chalk_1.default.green((0, i18n_1.t)('函数:{{name}} 调用日志:\n', { name })));
|
|
116
|
+
if (logs.length === 0) {
|
|
117
|
+
return log.info((0, i18n_1.t)('无调用日志'));
|
|
118
|
+
}
|
|
119
|
+
logs.forEach((log) => {
|
|
120
|
+
const info = Object.keys(ResMap)
|
|
121
|
+
.map((key) => {
|
|
122
|
+
if (key === 'RetCode') {
|
|
123
|
+
return `${ResMap[key]}:${Number(log[key]) === 0 ? (0, i18n_1.t)('成功') : (0, i18n_1.t)('失败')}\n`;
|
|
124
|
+
}
|
|
125
|
+
if (key === 'MemUsage') {
|
|
126
|
+
const str = Number(Number(log[key]) / 1024 / 1024).toFixed(3);
|
|
127
|
+
return `${ResMap[key]}:${str} MB\n`;
|
|
128
|
+
}
|
|
129
|
+
return `${ResMap[key]}:${log[key]} \n`;
|
|
130
|
+
})
|
|
131
|
+
.reduce((prev, next) => prev + next);
|
|
132
|
+
console.log(info + (0, i18n_1.t)('日志:\n {{log}} \n', { log: log.LogJson }));
|
|
141
133
|
});
|
|
142
134
|
}
|
|
143
135
|
};
|