@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
|
};
|
|
@@ -51,78 +42,81 @@ let InvokeFunction = class InvokeFunction extends common_1.Command {
|
|
|
51
42
|
desc: (0, i18n_1.t)('触发云端部署的云函数')
|
|
52
43
|
};
|
|
53
44
|
}
|
|
54
|
-
execute(ctx, argsParams, log) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
|
|
70
|
-
}
|
|
45
|
+
async execute(ctx, argsParams, log) {
|
|
46
|
+
const { envId, config: { functions }, options } = ctx;
|
|
47
|
+
const name = argsParams === null || argsParams === void 0 ? void 0 : argsParams[0];
|
|
48
|
+
let isBatchInvoke = false;
|
|
49
|
+
const functionService = await (0, function_1.getFunctionService)(envId);
|
|
50
|
+
if (!name) {
|
|
51
|
+
const { isBatch } = await inquirer_1.default.prompt({
|
|
52
|
+
type: 'confirm',
|
|
53
|
+
name: 'isBatch',
|
|
54
|
+
message: (0, i18n_1.t)('无云函数名称,是否需要触发配置文件中的全部云函数?'),
|
|
55
|
+
default: false
|
|
56
|
+
});
|
|
57
|
+
isBatchInvoke = isBatch;
|
|
58
|
+
if (!isBatchInvoke) {
|
|
59
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
|
|
71
60
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
61
|
+
}
|
|
62
|
+
let params;
|
|
63
|
+
const jsonStringParams = options.params;
|
|
64
|
+
if (jsonStringParams) {
|
|
65
|
+
try {
|
|
66
|
+
params = JSON.parse(jsonStringParams);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
console.log(e);
|
|
70
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('jsonStringParams 参数不是正确的 JSON 字符串'));
|
|
82
71
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
72
|
+
}
|
|
73
|
+
if (isBatchInvoke) {
|
|
74
|
+
return functionService.batchInvokeFunctions({
|
|
75
|
+
envId,
|
|
76
|
+
functions,
|
|
77
|
+
log: true
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const func = functions.find((item) => item.name === name);
|
|
81
|
+
const configParams = (func === null || func === void 0 ? void 0 : func.params) ? func.params : undefined;
|
|
82
|
+
params = params || configParams;
|
|
83
|
+
const result = await functionService.invokeFunction(name, params);
|
|
84
|
+
if (result.InvokeResult === 0) {
|
|
85
|
+
log.success((0, i18n_1.t)('[{{name}}] 调用成功\n', { name }));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
log.error((0, i18n_1.t)('[{{name}}] 调用失败\n', { name }));
|
|
89
|
+
}
|
|
90
|
+
const ResMap = {
|
|
91
|
+
Duration: (0, i18n_1.t)('运行时间'),
|
|
92
|
+
MemUsage: (0, i18n_1.t)('内存占用'),
|
|
93
|
+
BillDuration: (0, i18n_1.t)('计费时间'),
|
|
94
|
+
FunctionRequestId: (0, i18n_1.t)('请求 Id '),
|
|
95
|
+
RetMsg: (0, i18n_1.t)('返回结果'),
|
|
96
|
+
ErrMsg: (0, i18n_1.t)('错误信息'),
|
|
97
|
+
Log: (0, i18n_1.t)('调用日志')
|
|
98
|
+
};
|
|
99
|
+
const formatInfo = {
|
|
100
|
+
...result,
|
|
101
|
+
Duration: Number(result.Duration).toFixed(2) + 'ms',
|
|
102
|
+
MemUsage: Number(Number(result.MemUsage) / Math.pow(1024, 2)).toFixed(2) + 'MB',
|
|
103
|
+
BillDuration: result.BillDuration + 'ms'
|
|
104
|
+
};
|
|
105
|
+
const logInfo = Object.keys(ResMap)
|
|
106
|
+
.map((key) => {
|
|
107
|
+
if (key === 'Log') {
|
|
108
|
+
return `${chalk_1.default.bold.cyan(ResMap[key])}:\n${formatInfo[key]}`;
|
|
89
109
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
params = params || configParams;
|
|
93
|
-
const result = yield functionService.invokeFunction(name, params);
|
|
94
|
-
if (result.InvokeResult === 0) {
|
|
95
|
-
log.success((0, i18n_1.t)('[{{name}}] 调用成功\n', { name }));
|
|
110
|
+
else if (result.InvokeResult === 0 && key === 'ErrMsg') {
|
|
111
|
+
return false;
|
|
96
112
|
}
|
|
97
113
|
else {
|
|
98
|
-
|
|
114
|
+
return `${chalk_1.default.bold.cyan(ResMap[key])}:${formatInfo[key]}`;
|
|
99
115
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
FunctionRequestId: (0, i18n_1.t)('请求 Id '),
|
|
105
|
-
RetMsg: (0, i18n_1.t)('返回结果'),
|
|
106
|
-
ErrMsg: (0, i18n_1.t)('错误信息'),
|
|
107
|
-
Log: (0, i18n_1.t)('调用日志')
|
|
108
|
-
};
|
|
109
|
-
const formatInfo = Object.assign(Object.assign({}, result), { Duration: Number(result.Duration).toFixed(2) + 'ms', MemUsage: Number(Number(result.MemUsage) / Math.pow(1024, 2)).toFixed(2) + 'MB', BillDuration: result.BillDuration + 'ms' });
|
|
110
|
-
const logInfo = Object.keys(ResMap)
|
|
111
|
-
.map((key) => {
|
|
112
|
-
if (key === 'Log') {
|
|
113
|
-
return `${chalk_1.default.bold.cyan(ResMap[key])}:\n${formatInfo[key]}`;
|
|
114
|
-
}
|
|
115
|
-
else if (result.InvokeResult === 0 && key === 'ErrMsg') {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
return `${chalk_1.default.bold.cyan(ResMap[key])}:${formatInfo[key]}`;
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
.filter((item) => item)
|
|
123
|
-
.join('\n');
|
|
124
|
-
console.log(logInfo);
|
|
125
|
-
});
|
|
116
|
+
})
|
|
117
|
+
.filter((item) => item)
|
|
118
|
+
.join('\n');
|
|
119
|
+
console.log(logInfo);
|
|
126
120
|
}
|
|
127
121
|
};
|
|
128
122
|
__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.UnAttachFileLayer = exports.AttachFileLayer = void 0;
|
|
25
16
|
const enquirer_1 = require("enquirer");
|
|
@@ -38,7 +29,10 @@ const LayerStatusMap = {
|
|
|
38
29
|
};
|
|
39
30
|
let AttachFileLayer = class AttachFileLayer extends common_1.Command {
|
|
40
31
|
get options() {
|
|
41
|
-
return
|
|
32
|
+
return {
|
|
33
|
+
...(0, common_2.layerCommonOptions)('bind <name>'),
|
|
34
|
+
deprecateCmd: 'functions:layer:bind <name>',
|
|
35
|
+
options: [
|
|
42
36
|
{
|
|
43
37
|
flags: '-e, --envId <envId>',
|
|
44
38
|
desc: (0, i18n_1.t)('环境 Id')
|
|
@@ -47,69 +41,69 @@ let AttachFileLayer = class AttachFileLayer 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, params, 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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return keys[0];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
let listLayerVersionsRes = yield functionService.listLayerVersions({
|
|
90
|
-
name: layer
|
|
91
|
-
});
|
|
92
|
-
let layerVersions = listLayerVersionsRes.LayerVersions || [];
|
|
93
|
-
const versions = layerVersions.map((item) => String(item.LayerVersion));
|
|
94
|
-
if (!versions.length) {
|
|
95
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('没有可用的文件层版本,请先创建文件层版本!'));
|
|
48
|
+
async execute(envId, params, options) {
|
|
49
|
+
const { codeSecret } = options;
|
|
50
|
+
const fnName = params === null || params === void 0 ? void 0 : params[0];
|
|
51
|
+
const functionService = await (0, function_1.getFunctionService)(envId);
|
|
52
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
53
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
54
|
+
const envFunctions = await functionService.listAllFunctions({
|
|
55
|
+
envId
|
|
56
|
+
});
|
|
57
|
+
const exist = envFunctions.find((fn) => fn.FunctionName === fnName);
|
|
58
|
+
if (!exist) {
|
|
59
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('当前环境不存在此函数 [{{fnName}}]', { fnName }));
|
|
60
|
+
}
|
|
61
|
+
const listLayersRes = await functionService.listLayers({
|
|
62
|
+
offset: 0,
|
|
63
|
+
limit: 200,
|
|
64
|
+
});
|
|
65
|
+
const layers = listLayersRes.Layers || [];
|
|
66
|
+
loading.stop();
|
|
67
|
+
const newLayers = layers.map((item) => ({
|
|
68
|
+
name: `[${LayerStatusMap[item.Status] || (0, i18n_1.t)('异常')}] ${item.LayerName}`,
|
|
69
|
+
value: item.LayerName
|
|
70
|
+
}));
|
|
71
|
+
if (!newLayers.length) {
|
|
72
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('没有可用的文件层,请先创建文件层!'));
|
|
73
|
+
}
|
|
74
|
+
const { layer } = await (0, enquirer_1.prompt)({
|
|
75
|
+
type: 'select',
|
|
76
|
+
name: 'layer',
|
|
77
|
+
message: (0, i18n_1.t)('选择文件层名称'),
|
|
78
|
+
choices: newLayers,
|
|
79
|
+
result(choices) {
|
|
80
|
+
const keys = Object.values(this.map(choices));
|
|
81
|
+
return keys[0];
|
|
96
82
|
}
|
|
97
|
-
const { version } = yield (0, enquirer_1.prompt)({
|
|
98
|
-
type: 'select',
|
|
99
|
-
name: 'version',
|
|
100
|
-
message: (0, i18n_1.t)('选择文件层版本'),
|
|
101
|
-
choices: versions
|
|
102
|
-
});
|
|
103
|
-
loading.start((0, i18n_1.t)('文件层绑定中...'));
|
|
104
|
-
yield functionService.attachLayer({
|
|
105
|
-
envId,
|
|
106
|
-
functionName: fnName,
|
|
107
|
-
layerName: layer,
|
|
108
|
-
layerVersion: Number(version),
|
|
109
|
-
codeSecret
|
|
110
|
-
});
|
|
111
|
-
loading.succeed((0, i18n_1.t)('文件层绑定成功!'));
|
|
112
83
|
});
|
|
84
|
+
let listLayerVersionsRes = await functionService.listLayerVersions({
|
|
85
|
+
name: layer
|
|
86
|
+
});
|
|
87
|
+
let layerVersions = listLayerVersionsRes.LayerVersions || [];
|
|
88
|
+
const versions = layerVersions.map((item) => String(item.LayerVersion));
|
|
89
|
+
if (!versions.length) {
|
|
90
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('没有可用的文件层版本,请先创建文件层版本!'));
|
|
91
|
+
}
|
|
92
|
+
const { version } = await (0, enquirer_1.prompt)({
|
|
93
|
+
type: 'select',
|
|
94
|
+
name: 'version',
|
|
95
|
+
message: (0, i18n_1.t)('选择文件层版本'),
|
|
96
|
+
choices: versions
|
|
97
|
+
});
|
|
98
|
+
loading.start((0, i18n_1.t)('文件层绑定中...'));
|
|
99
|
+
await functionService.attachLayer({
|
|
100
|
+
envId,
|
|
101
|
+
functionName: fnName,
|
|
102
|
+
layerName: layer,
|
|
103
|
+
layerVersion: Number(version),
|
|
104
|
+
codeSecret
|
|
105
|
+
});
|
|
106
|
+
loading.succeed((0, i18n_1.t)('文件层绑定成功!'));
|
|
113
107
|
}
|
|
114
108
|
};
|
|
115
109
|
__decorate([
|
|
@@ -127,7 +121,10 @@ AttachFileLayer = __decorate([
|
|
|
127
121
|
exports.AttachFileLayer = AttachFileLayer;
|
|
128
122
|
let UnAttachFileLayer = class UnAttachFileLayer extends common_1.Command {
|
|
129
123
|
get options() {
|
|
130
|
-
return
|
|
124
|
+
return {
|
|
125
|
+
...(0, common_2.layerCommonOptions)('unbind <name>'),
|
|
126
|
+
deprecateCmd: 'functions:layer:unbind <name>',
|
|
127
|
+
options: [
|
|
131
128
|
{
|
|
132
129
|
flags: '-e, --envId <envId>',
|
|
133
130
|
desc: (0, i18n_1.t)('环境 Id')
|
|
@@ -136,44 +133,44 @@ let UnAttachFileLayer = class UnAttachFileLayer extends common_1.Command {
|
|
|
136
133
|
flags: '--code-secret, <codeSecret>',
|
|
137
134
|
desc: (0, i18n_1.t)('代码加密的函数的 CodeSecret')
|
|
138
135
|
}
|
|
139
|
-
],
|
|
136
|
+
],
|
|
137
|
+
desc: (0, i18n_1.t)('删除云函数绑定的文件层')
|
|
138
|
+
};
|
|
140
139
|
}
|
|
141
|
-
execute(envId, params, options) {
|
|
140
|
+
async execute(envId, params, options) {
|
|
142
141
|
var _a;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
142
|
+
const { codeSecret } = options;
|
|
143
|
+
const fnName = params === null || params === void 0 ? void 0 : params[0];
|
|
144
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
145
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
146
|
+
const functionService = await (0, function_1.getFunctionService)(envId);
|
|
147
|
+
const detail = await functionService.getFunctionDetail(fnName, codeSecret);
|
|
148
|
+
if (!((_a = detail === null || detail === void 0 ? void 0 : detail.Layers) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
149
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('该云函数未绑定文件层!'));
|
|
150
|
+
}
|
|
151
|
+
loading.stop();
|
|
152
|
+
const layers = detail.Layers.map((item) => ({
|
|
153
|
+
name: (0, i18n_1.t)('名称:{{layerName}} / 版本: {{layerVersion}}', { layerName: item.LayerName, layerVersion: item.LayerVersion }),
|
|
154
|
+
value: item
|
|
155
|
+
}));
|
|
156
|
+
const { layer } = await (0, enquirer_1.prompt)({
|
|
157
|
+
type: 'select',
|
|
158
|
+
name: 'layer',
|
|
159
|
+
message: (0, i18n_1.t)('选择文件层'),
|
|
160
|
+
choices: layers,
|
|
161
|
+
result(choice) {
|
|
162
|
+
return this.map(choice)[choice];
|
|
152
163
|
}
|
|
153
|
-
loading.stop();
|
|
154
|
-
const layers = detail.Layers.map((item) => ({
|
|
155
|
-
name: (0, i18n_1.t)('名称:{{layerName}} / 版本: {{layerVersion}}', { layerName: item.LayerName, layerVersion: item.LayerVersion }),
|
|
156
|
-
value: item
|
|
157
|
-
}));
|
|
158
|
-
const { layer } = yield (0, enquirer_1.prompt)({
|
|
159
|
-
type: 'select',
|
|
160
|
-
name: 'layer',
|
|
161
|
-
message: (0, i18n_1.t)('选择文件层'),
|
|
162
|
-
choices: layers,
|
|
163
|
-
result(choice) {
|
|
164
|
-
return this.map(choice)[choice];
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
loading.start((0, i18n_1.t)('文件层解绑中...'));
|
|
168
|
-
yield functionService.unAttachLayer({
|
|
169
|
-
envId,
|
|
170
|
-
functionName: fnName,
|
|
171
|
-
layerName: layer.LayerName,
|
|
172
|
-
layerVersion: layer.LayerVersion,
|
|
173
|
-
codeSecret
|
|
174
|
-
});
|
|
175
|
-
loading.succeed((0, i18n_1.t)('文件层解绑成功!'));
|
|
176
164
|
});
|
|
165
|
+
loading.start((0, i18n_1.t)('文件层解绑中...'));
|
|
166
|
+
await functionService.unAttachLayer({
|
|
167
|
+
envId,
|
|
168
|
+
functionName: fnName,
|
|
169
|
+
layerName: layer.LayerName,
|
|
170
|
+
layerVersion: layer.LayerVersion,
|
|
171
|
+
codeSecret
|
|
172
|
+
});
|
|
173
|
+
loading.succeed((0, i18n_1.t)('文件层解绑成功!'));
|
|
177
174
|
}
|
|
178
175
|
};
|
|
179
176
|
__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
|
};
|
|
@@ -35,7 +26,10 @@ const toolbox_1 = require("@cloudbase/toolbox");
|
|
|
35
26
|
const i18n_1 = require("../../../i18n");
|
|
36
27
|
let CreateFileLayer = class CreateFileLayer extends common_1.Command {
|
|
37
28
|
get options() {
|
|
38
|
-
return
|
|
29
|
+
return {
|
|
30
|
+
...(0, common_2.layerCommonOptions)('create <alias>'),
|
|
31
|
+
deprecateCmd: 'functions:layer:create <alias>',
|
|
32
|
+
options: [
|
|
39
33
|
{
|
|
40
34
|
flags: '-e, --envId <envId>',
|
|
41
35
|
desc: (0, i18n_1.t)('环境 Id')
|
|
@@ -44,33 +38,33 @@ let CreateFileLayer = class CreateFileLayer extends common_1.Command {
|
|
|
44
38
|
flags: '--file, <file>',
|
|
45
39
|
desc: (0, i18n_1.t)('文件路径')
|
|
46
40
|
}
|
|
47
|
-
],
|
|
41
|
+
],
|
|
42
|
+
desc: (0, i18n_1.t)('创建函数文件层')
|
|
43
|
+
};
|
|
48
44
|
}
|
|
49
|
-
execute(envId, options, params) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
contentPath: filePath
|
|
71
|
-
});
|
|
72
|
-
loading.succeed((0, i18n_1.t)('文件层创建成功!'));
|
|
45
|
+
async execute(envId, options, params) {
|
|
46
|
+
const functionsService = await (0, function_1.getFunctionService)(envId);
|
|
47
|
+
const alias = params === null || params === void 0 ? void 0 : params[0];
|
|
48
|
+
const { file } = options;
|
|
49
|
+
const layerName = `${alias}_${envId}`;
|
|
50
|
+
const listLayerRes = await functionsService.listLayers({
|
|
51
|
+
offset: 0,
|
|
52
|
+
limit: 200
|
|
53
|
+
});
|
|
54
|
+
const layers = listLayerRes.Layers || [];
|
|
55
|
+
if (layers.find(({ LayerName }) => LayerName === layerName)) {
|
|
56
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('层名称 {{layerName}} 已被您的当前环境或其他环境占用,请换用别的名称', { layerName }));
|
|
57
|
+
}
|
|
58
|
+
const filePath = path_1.default.resolve(file);
|
|
59
|
+
const runtimes = ['Nodejs14.18', 'Nodejs12.16', 'Nodejs8.9', 'Php7', 'Java8'];
|
|
60
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
61
|
+
loading.start((0, i18n_1.t)('文件层创建中...'));
|
|
62
|
+
await functionsService.createLayer({
|
|
63
|
+
name: layerName,
|
|
64
|
+
runtimes,
|
|
65
|
+
contentPath: filePath
|
|
73
66
|
});
|
|
67
|
+
loading.succeed((0, i18n_1.t)('文件层创建成功!'));
|
|
74
68
|
}
|
|
75
69
|
};
|
|
76
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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
15
|
exports.DeleteFileLayer = void 0;
|
|
25
16
|
const enquirer_1 = require("enquirer");
|
|
@@ -32,51 +23,54 @@ const common_2 = require("./common");
|
|
|
32
23
|
const i18n_1 = require("../../../i18n");
|
|
33
24
|
let DeleteFileLayer = class DeleteFileLayer extends common_1.Command {
|
|
34
25
|
get options() {
|
|
35
|
-
return
|
|
26
|
+
return {
|
|
27
|
+
...(0, common_2.layerCommonOptions)('delete'),
|
|
28
|
+
deprecateCmd: 'functions:layer:delete',
|
|
29
|
+
options: [
|
|
36
30
|
{
|
|
37
31
|
flags: '-e, --envId <envId>',
|
|
38
32
|
desc: (0, i18n_1.t)('环境 Id')
|
|
39
33
|
}
|
|
40
|
-
],
|
|
34
|
+
],
|
|
35
|
+
desc: (0, i18n_1.t)('删除当前环境的文件层')
|
|
36
|
+
};
|
|
41
37
|
}
|
|
42
|
-
execute(envId) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
version: Number(version)
|
|
77
|
-
});
|
|
78
|
-
loading.succeed((0, i18n_1.t)('文件层删除成功!'));
|
|
38
|
+
async execute(envId) {
|
|
39
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
40
|
+
loading.start((0, i18n_1.t)('数据加载中...'));
|
|
41
|
+
const functionService = await (0, function_1.getFunctionService)(envId);
|
|
42
|
+
const listLayersRes = await functionService.listLayers({
|
|
43
|
+
offset: 0,
|
|
44
|
+
limit: 200,
|
|
45
|
+
});
|
|
46
|
+
loading.stop();
|
|
47
|
+
const layers = listLayersRes.Layers || [];
|
|
48
|
+
if (!layers.length) {
|
|
49
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('当前环境没有可用的文件层,请先创建文件层!'));
|
|
50
|
+
}
|
|
51
|
+
const { layer } = await (0, enquirer_1.prompt)({
|
|
52
|
+
type: 'select',
|
|
53
|
+
name: 'layer',
|
|
54
|
+
message: (0, i18n_1.t)('选择文件层名称'),
|
|
55
|
+
choices: layers.map((item) => item.LayerName)
|
|
56
|
+
});
|
|
57
|
+
let listLayerVersionsRes = await functionService.listLayerVersions({
|
|
58
|
+
name: layer
|
|
59
|
+
});
|
|
60
|
+
const layerVersions = listLayerVersionsRes.LayerVersions || [];
|
|
61
|
+
const versions = layerVersions.map((item) => String(item.LayerVersion));
|
|
62
|
+
const { version } = await (0, enquirer_1.prompt)({
|
|
63
|
+
type: 'select',
|
|
64
|
+
name: 'version',
|
|
65
|
+
message: (0, i18n_1.t)('选择文件层版本'),
|
|
66
|
+
choices: versions
|
|
67
|
+
});
|
|
68
|
+
loading.start((0, i18n_1.t)('文件层删除中...'));
|
|
69
|
+
await functionService.deleteLayerVersion({
|
|
70
|
+
name: layer,
|
|
71
|
+
version: Number(version)
|
|
79
72
|
});
|
|
73
|
+
loading.succeed((0, i18n_1.t)('文件层删除成功!'));
|
|
80
74
|
}
|
|
81
75
|
};
|
|
82
76
|
__decorate([
|