@cloudbase/cli 2.10.0-beta.0 → 2.11.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth/login.js +51 -65
- package/lib/auth/logout.js +3 -14
- package/lib/commands/account/login.js +136 -149
- package/lib/commands/account/logout.js +3 -14
- package/lib/commands/ag/base.js +203 -0
- package/lib/commands/ag/create.js +301 -0
- package/lib/commands/ag/debug/index.html +699 -0
- package/lib/commands/ag/delete.js +200 -0
- package/lib/commands/ag/deploy.js +185 -0
- package/lib/commands/ag/detail.js +113 -0
- package/lib/commands/ag/index.js +22 -0
- package/lib/commands/ag/list.js +155 -0
- package/lib/commands/ag/run.js +644 -0
- package/lib/commands/ai/index.js +76 -95
- package/lib/commands/cloudfunction/base.js +182 -203
- package/lib/commands/cloudrun/base.js +578 -603
- package/lib/commands/common.js +48 -63
- package/lib/commands/config/delete.js +16 -27
- package/lib/commands/config/get.js +13 -24
- package/lib/commands/config/list.js +16 -27
- package/lib/commands/config/set.js +33 -44
- package/lib/commands/db/base.js +221 -240
- package/lib/commands/env/base.js +36 -49
- package/lib/commands/env/domain.js +79 -94
- package/lib/commands/env/login.js +120 -135
- package/lib/commands/framework/index.js +32 -49
- package/lib/commands/fun/base.js +223 -244
- package/lib/commands/functions/alias/getRoute.js +33 -44
- package/lib/commands/functions/alias/setRoute.js +36 -47
- package/lib/commands/functions/code-download.js +43 -54
- package/lib/commands/functions/code-update.js +23 -34
- package/lib/commands/functions/concurrency/delete.js +11 -22
- package/lib/commands/functions/concurrency/list.js +20 -31
- package/lib/commands/functions/concurrency/set.js +13 -24
- package/lib/commands/functions/config-update.js +30 -41
- package/lib/commands/functions/copy.js +12 -23
- package/lib/commands/functions/delete.js +30 -41
- package/lib/commands/functions/deploy.js +184 -202
- package/lib/commands/functions/detail.js +23 -34
- package/lib/commands/functions/invoke.js +69 -75
- package/lib/commands/functions/layer/bind.js +102 -105
- package/lib/commands/functions/layer/create.js +29 -35
- package/lib/commands/functions/layer/delete.js +42 -48
- package/lib/commands/functions/layer/download.js +52 -58
- package/lib/commands/functions/layer/list.js +44 -50
- package/lib/commands/functions/layer/sort.js +39 -45
- package/lib/commands/functions/list.js +25 -36
- package/lib/commands/functions/log.js +65 -73
- package/lib/commands/functions/run.js +118 -116
- package/lib/commands/functions/trigger-create.js +32 -43
- package/lib/commands/functions/trigger-delete.js +50 -61
- package/lib/commands/functions/version/list.js +29 -40
- package/lib/commands/functions/version/publish.js +11 -22
- package/lib/commands/gateway/create.js +50 -61
- package/lib/commands/gateway/delete.js +38 -49
- package/lib/commands/gateway/domain.js +65 -80
- package/lib/commands/gateway/list.js +31 -42
- package/lib/commands/gateway/switch.js +48 -61
- package/lib/commands/helpers/init.js +226 -249
- package/lib/commands/helpers/new.js +35 -46
- package/lib/commands/helpers/open.js +22 -33
- package/lib/commands/hosting/hosting.js +157 -178
- package/lib/commands/index.js +1 -0
- package/lib/commands/lowcode/app.js +114 -144
- package/lib/commands/lowcode/comps.js +136 -127
- package/lib/commands/lowcode/utils.js +11 -22
- package/lib/commands/pull/pull.js +33 -46
- package/lib/commands/run/delete.js +35 -46
- package/lib/commands/run/image/delete.js +32 -39
- package/lib/commands/run/image/download.js +26 -33
- package/lib/commands/run/image/list.js +41 -48
- package/lib/commands/run/image/upload.js +26 -33
- package/lib/commands/run/list.js +32 -43
- package/lib/commands/run/service/config.js +17 -28
- package/lib/commands/run/service/deploy.js +15 -26
- package/lib/commands/run/service/list.js +48 -59
- package/lib/commands/run/service/update.js +7 -18
- package/lib/commands/run/standalonegateway/create.js +35 -42
- package/lib/commands/run/standalonegateway/destroy.js +23 -30
- package/lib/commands/run/standalonegateway/list.js +19 -26
- package/lib/commands/run/standalonegateway/package.js +31 -38
- package/lib/commands/run/standalonegateway/turn.js +27 -34
- package/lib/commands/run/version/create.js +198 -205
- package/lib/commands/run/version/delete.js +31 -38
- package/lib/commands/run/version/list.js +42 -49
- package/lib/commands/run/version/modify.js +27 -34
- package/lib/commands/run/version/update.js +201 -208
- package/lib/commands/runf/base.js +216 -237
- package/lib/commands/self-update.js +59 -72
- package/lib/commands/smart.js +66 -79
- package/lib/commands/storage/storage.js +192 -219
- package/lib/commands/third/thirdAttach.js +16 -27
- package/lib/commands/utils.js +119 -149
- package/lib/db/index.js +48 -67
- package/lib/decorators/captureError.js +10 -21
- package/lib/decorators/guard.js +11 -22
- package/lib/decorators/injectParams.js +29 -40
- package/lib/decorators/params/common.js +5 -2
- package/lib/decorators/params/index.js +3 -12
- package/lib/env/domain.js +13 -28
- package/lib/env/index.js +25 -44
- package/lib/env/login.js +30 -45
- package/lib/function/alias.js +31 -44
- package/lib/function/base.js +187 -215
- package/lib/function/code.js +8 -19
- package/lib/function/concurrency.js +43 -58
- package/lib/function/create.js +43 -53
- package/lib/function/delete.js +22 -35
- package/lib/function/layer/attach.js +33 -46
- package/lib/function/layer/create.js +34 -45
- package/lib/function/layer/delete.js +5 -16
- package/lib/function/layer/download.js +11 -22
- package/lib/function/layer/list.js +12 -25
- package/lib/function/layer/sort.js +6 -17
- package/lib/function/trigger.js +65 -82
- package/lib/function/update.js +24 -32
- package/lib/function/version.js +29 -42
- package/lib/function/vpc.js +12 -25
- package/lib/gateway/index.js +77 -104
- package/lib/hosting.js +157 -188
- package/lib/run/delete.js +3 -12
- package/lib/run/image/build.js +6 -15
- package/lib/run/image/delete.js +3 -12
- package/lib/run/image/info.js +3 -12
- package/lib/run/image/list.js +6 -15
- package/lib/run/list.js +19 -30
- package/lib/run/repo.js +6 -15
- package/lib/run/service/common.js +160 -173
- package/lib/run/service/config.js +44 -57
- package/lib/run/service/deployPackage.js +33 -44
- package/lib/run/service/list.js +8 -14
- package/lib/run/service/showLogs.js +69 -90
- package/lib/run/service/update.js +50 -63
- package/lib/run/standalonegateway/create.js +3 -12
- package/lib/run/standalonegateway/destroy.js +3 -12
- package/lib/run/standalonegateway/list.js +3 -12
- package/lib/run/standalonegateway/package/list.js +3 -12
- package/lib/run/standalonegateway/turn/off.js +3 -12
- package/lib/run/standalonegateway/turn/on.js +3 -12
- package/lib/run/version/create.js +41 -31
- package/lib/run/version/delete.js +3 -12
- package/lib/run/version/list.js +3 -12
- package/lib/run/version/modify.js +3 -12
- package/lib/run/version/repo.js +6 -15
- package/lib/run/version/update.js +37 -26
- package/lib/storage.js +62 -93
- package/lib/third/index.js +6 -17
- package/lib/utils/ai/banner.js +49 -60
- package/lib/utils/ai/claudeWindows.js +2 -2
- package/lib/utils/ai/config.js +169 -206
- package/lib/utils/ai/ensureFiles.js +6 -17
- package/lib/utils/ai/env.js +16 -27
- package/lib/utils/ai/envLocalManager.js +35 -52
- package/lib/utils/ai/router.js +927 -1005
- package/lib/utils/ai/setup.js +527 -563
- package/lib/utils/auth.js +3 -14
- package/lib/utils/checkTcbrEnv.js +20 -31
- package/lib/utils/cli-table.js +6 -1
- package/lib/utils/config.js +4 -13
- package/lib/utils/dts.js +98 -113
- package/lib/utils/env.js +154 -175
- package/lib/utils/function-packer.js +29 -42
- package/lib/utils/log.js +10 -21
- package/lib/utils/mcp-config-modifier.js +105 -120
- package/lib/utils/net/cloud-api-request.js +15 -23
- package/lib/utils/net/credential.js +26 -39
- package/lib/utils/net/http-request.js +63 -80
- package/lib/utils/net/manager-service.js +22 -35
- package/lib/utils/notice.js +16 -27
- package/lib/utils/output/loading.js +3 -12
- package/lib/utils/parallel.js +32 -43
- package/lib/utils/platform/mac.js +4 -15
- package/lib/utils/platform/port.js +4 -15
- package/lib/utils/prompt/select.js +6 -15
- package/lib/utils/report.js +28 -33
- package/lib/utils/reporter/agree.js +11 -22
- package/lib/utils/reporter/download.js +17 -28
- package/lib/utils/reporter/usage.js +12 -23
- package/lib/utils/store/auth.js +17 -30
- package/lib/utils/store/config.js +11 -25
- package/lib/utils/store/db.js +17 -36
- package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
- package/lib/utils/template-manager.js +215 -242
- package/lib/utils/template.js +81 -96
- package/lib/utils/tools/common.js +45 -56
- package/lib/utils/tools/time.js +5 -16
- package/lib/utils/url.js +10 -4
- package/package.json +2 -2
- package/specs/ag-command/design.md +421 -0
- package/specs/ag-command/doc.md +204 -0
- package/specs/ag-command/requirements.md +173 -0
- package/specs/ag-command/summary.md +174 -0
- package/specs/ag-command/tasks.md +197 -0
- package/specs/ag-command/usage-guide.md +420 -0
- package/tsconfig.json +1 -1
- package/types/commands/ag/base.d.ts +44 -0
- package/types/commands/ag/create.d.ts +25 -0
- package/types/commands/ag/delete.d.ts +32 -0
- package/types/commands/ag/deploy.d.ts +31 -0
- package/types/commands/ag/detail.d.ts +28 -0
- package/types/commands/ag/index.d.ts +6 -0
- package/types/commands/ag/list.d.ts +35 -0
- package/types/commands/ag/run.d.ts +52 -0
- package/types/commands/cloudrun/base.d.ts +10 -0
- package/types/commands/index.d.ts +1 -0
package/lib/function/create.js
CHANGED
|
@@ -1,72 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.batchCreateFunctions = exports.createFunction = void 0;
|
|
13
4
|
const utils_1 = require("../utils");
|
|
14
5
|
const error_1 = require("../error");
|
|
15
6
|
const base_1 = require("./base");
|
|
16
7
|
const i18n_1 = require("../i18n");
|
|
17
|
-
function createFunction(options) {
|
|
8
|
+
async function createFunction(options) {
|
|
18
9
|
var _a;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
const { envId, accessPath, codeSecret, force = false, functionPath, base64Code = '', functionRootPath = '' } = options;
|
|
11
|
+
const func = {
|
|
12
|
+
...(_a = options === null || options === void 0 ? void 0 : options.func) === null || _a === void 0 ? void 0 : _a.config,
|
|
13
|
+
...options.func
|
|
14
|
+
};
|
|
15
|
+
accessPath && (func.path = accessPath);
|
|
16
|
+
const funcName = func.name;
|
|
17
|
+
const scfService = await (0, base_1.getFunctionService)(envId);
|
|
18
|
+
func.isWaitInstall = true;
|
|
19
|
+
try {
|
|
20
|
+
await scfService.createFunction({
|
|
21
|
+
func,
|
|
22
|
+
force,
|
|
23
|
+
base64Code,
|
|
24
|
+
codeSecret,
|
|
25
|
+
functionPath,
|
|
26
|
+
functionRootPath
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
if (e.message && !force) {
|
|
31
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('[{{name}}] 部署失败,{{error}}', { name: funcName, error: e.message }), {
|
|
32
|
+
code: e.code,
|
|
33
|
+
original: e
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.createFunction = createFunction;
|
|
40
|
+
async function batchCreateFunctions(options) {
|
|
41
|
+
const { functions, functionRootPath = '', envId, force, codeSecret, log = false } = options;
|
|
42
|
+
const promises = functions.map((func) => (async () => {
|
|
43
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
26
44
|
try {
|
|
27
|
-
|
|
45
|
+
log && loading.start((0, i18n_1.t)('[{{name}}] 函数部署中...', { name: func.name }));
|
|
46
|
+
await createFunction({
|
|
28
47
|
func,
|
|
48
|
+
envId,
|
|
29
49
|
force,
|
|
30
|
-
base64Code,
|
|
31
50
|
codeSecret,
|
|
32
|
-
functionPath,
|
|
33
51
|
functionRootPath
|
|
34
52
|
});
|
|
53
|
+
log && loading.succeed((0, i18n_1.t)('[{{name}}] 函数部署成功', { name: func.name }));
|
|
35
54
|
}
|
|
36
55
|
catch (e) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
code: e.code,
|
|
40
|
-
original: e
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
throw e;
|
|
56
|
+
log && loading.fail((0, i18n_1.t)('[{{name}}] 函数部署失败', { name: func.name }));
|
|
57
|
+
throw new error_1.CloudBaseError(e.message);
|
|
44
58
|
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
exports.createFunction = createFunction;
|
|
48
|
-
function batchCreateFunctions(options) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const { functions, functionRootPath = '', envId, force, codeSecret, log = false } = options;
|
|
51
|
-
const promises = functions.map((func) => (() => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const loading = (0, utils_1.loadingFactory)();
|
|
53
|
-
try {
|
|
54
|
-
log && loading.start((0, i18n_1.t)('[{{name}}] 函数部署中...', { name: func.name }));
|
|
55
|
-
yield createFunction({
|
|
56
|
-
func,
|
|
57
|
-
envId,
|
|
58
|
-
force,
|
|
59
|
-
codeSecret,
|
|
60
|
-
functionRootPath
|
|
61
|
-
});
|
|
62
|
-
log && loading.succeed((0, i18n_1.t)('[{{name}}] 函数部署成功', { name: func.name }));
|
|
63
|
-
}
|
|
64
|
-
catch (e) {
|
|
65
|
-
log && loading.fail((0, i18n_1.t)('[{{name}}] 函数部署失败', { name: func.name }));
|
|
66
|
-
throw new error_1.CloudBaseError(e.message);
|
|
67
|
-
}
|
|
68
|
-
}))());
|
|
69
|
-
yield Promise.all(promises);
|
|
70
|
-
});
|
|
59
|
+
})());
|
|
60
|
+
await Promise.all(promises);
|
|
71
61
|
}
|
|
72
62
|
exports.batchCreateFunctions = batchCreateFunctions;
|
package/lib/function/delete.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.batchDeleteFunctions = exports.deleteFunction = void 0;
|
|
13
4
|
const logger_1 = require("../logger");
|
|
@@ -16,38 +7,34 @@ const utils_1 = require("../utils");
|
|
|
16
7
|
const gateway_1 = require("../gateway");
|
|
17
8
|
const i18n_1 = require("../i18n");
|
|
18
9
|
const scfService = utils_1.CloudApiService.getInstance('scf');
|
|
19
|
-
function deleteFunction({ functionName, envId }) {
|
|
10
|
+
async function deleteFunction({ functionName, envId }) {
|
|
20
11
|
var _a;
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
const res = await (0, gateway_1.queryGateway)({
|
|
13
|
+
envId,
|
|
14
|
+
name: functionName
|
|
15
|
+
});
|
|
16
|
+
if (((_a = res === null || res === void 0 ? void 0 : res.APISet) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
17
|
+
await (0, gateway_1.deleteGateway)({
|
|
23
18
|
envId,
|
|
24
19
|
name: functionName
|
|
25
20
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
yield scfService.request('DeleteFunction', {
|
|
33
|
-
FunctionName: functionName,
|
|
34
|
-
Namespace: envId
|
|
35
|
-
});
|
|
21
|
+
}
|
|
22
|
+
await scfService.request('DeleteFunction', {
|
|
23
|
+
FunctionName: functionName,
|
|
24
|
+
Namespace: envId
|
|
36
25
|
});
|
|
37
26
|
}
|
|
38
27
|
exports.deleteFunction = deleteFunction;
|
|
39
|
-
function batchDeleteFunctions({ names, envId }) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
yield Promise.all(promises);
|
|
51
|
-
});
|
|
28
|
+
async function batchDeleteFunctions({ names, envId }) {
|
|
29
|
+
const promises = names.map(name => (async () => {
|
|
30
|
+
try {
|
|
31
|
+
await deleteFunction({ functionName: name, envId });
|
|
32
|
+
(0, logger_1.successLog)((0, i18n_1.t)('[{{name}}] 函数删除成功!', { name }));
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
throw new error_1.CloudBaseError(e.message);
|
|
36
|
+
}
|
|
37
|
+
})());
|
|
38
|
+
await Promise.all(promises);
|
|
52
39
|
}
|
|
53
40
|
exports.batchDeleteFunctions = batchDeleteFunctions;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -19,45 +10,41 @@ const error_1 = require("../../error");
|
|
|
19
10
|
const i18n_1 = require("../../i18n");
|
|
20
11
|
const __1 = require("../");
|
|
21
12
|
const scfService = new utils_1.CloudApiService('scf');
|
|
22
|
-
function attachLayer(options) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
LayerVersion: layerVersion
|
|
31
|
-
});
|
|
32
|
-
const res = yield scfService.request('UpdateFunctionConfiguration', {
|
|
33
|
-
Layers,
|
|
34
|
-
Namespace: envId,
|
|
35
|
-
FunctionName: functionName
|
|
36
|
-
});
|
|
37
|
-
return res;
|
|
13
|
+
async function attachLayer(options) {
|
|
14
|
+
const { envId, functionName, layerName, layerVersion, codeSecret } = options;
|
|
15
|
+
const functionService = await (0, __1.getFunctionService)(envId);
|
|
16
|
+
let { Layers } = await functionService.getFunctionDetail(functionName, codeSecret);
|
|
17
|
+
Layers = Layers.map(item => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
|
|
18
|
+
Layers.push({
|
|
19
|
+
LayerName: layerName,
|
|
20
|
+
LayerVersion: layerVersion
|
|
38
21
|
});
|
|
22
|
+
const res = await scfService.request('UpdateFunctionConfiguration', {
|
|
23
|
+
Layers,
|
|
24
|
+
Namespace: envId,
|
|
25
|
+
FunctionName: functionName
|
|
26
|
+
});
|
|
27
|
+
return res;
|
|
39
28
|
}
|
|
40
29
|
exports.attachLayer = attachLayer;
|
|
41
|
-
function unAttachLayer(options) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return scfService.request('UpdateFunctionConfiguration', apiParams);
|
|
61
|
-
});
|
|
30
|
+
async function unAttachLayer(options) {
|
|
31
|
+
const { envId, functionName, layerName, layerVersion, codeSecret } = options;
|
|
32
|
+
const functionService = await (0, __1.getFunctionService)(envId);
|
|
33
|
+
let { Layers } = await functionService.getFunctionDetail(functionName, codeSecret);
|
|
34
|
+
Layers = Layers.map(item => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
|
|
35
|
+
const index = Layers.findIndex(item => item.LayerName === layerName && item.LayerVersion === layerVersion);
|
|
36
|
+
if (index === -1) {
|
|
37
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('层不存在'));
|
|
38
|
+
}
|
|
39
|
+
Layers.splice(index, 1);
|
|
40
|
+
const apiParams = {
|
|
41
|
+
Namespace: envId,
|
|
42
|
+
FunctionName: functionName,
|
|
43
|
+
Layers: Layers.length > 0 ? Layers : [{
|
|
44
|
+
LayerName: '',
|
|
45
|
+
LayerVersion: 0
|
|
46
|
+
}]
|
|
47
|
+
};
|
|
48
|
+
return scfService.request('UpdateFunctionConfiguration', apiParams);
|
|
62
49
|
}
|
|
63
50
|
exports.unAttachLayer = unAttachLayer;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -19,45 +10,43 @@ const toolbox_1 = require("@cloudbase/toolbox");
|
|
|
19
10
|
const utils_1 = require("../../utils");
|
|
20
11
|
const i18n_1 = require("../../i18n");
|
|
21
12
|
const scfService = new utils_1.CloudApiService('scf');
|
|
22
|
-
function createLayer(options) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if ((0, utils_1.checkFullAccess)(dest)) {
|
|
38
|
-
(0, utils_1.delSync)(dest);
|
|
39
|
-
}
|
|
40
|
-
yield (0, toolbox_1.zipDir)(contentPath, dest);
|
|
41
|
-
const fileBuffer = yield fs_1.default.promises.readFile(dest);
|
|
42
|
-
base64 = fileBuffer.toString('base64');
|
|
13
|
+
async function createLayer(options) {
|
|
14
|
+
const { envId, contentPath = '', layerName, base64Content = '', runtimes = [] } = options;
|
|
15
|
+
(0, utils_1.checkFullAccess)(contentPath);
|
|
16
|
+
const validRuntime = ['Nodejs8.9', 'Php7', 'Java8', 'Nodejs12.16'];
|
|
17
|
+
if (runtimes.some((item) => validRuntime.indexOf(item) === -1)) {
|
|
18
|
+
throw new toolbox_1.CloudBaseError(`Invalid runtime value. Now only support: ${validRuntime.join(', ')}`);
|
|
19
|
+
}
|
|
20
|
+
let base64;
|
|
21
|
+
if (base64Content) {
|
|
22
|
+
base64 = base64Content;
|
|
23
|
+
}
|
|
24
|
+
else if ((0, utils_1.isDirectory)(contentPath)) {
|
|
25
|
+
const dirName = path_1.default.parse(contentPath).name;
|
|
26
|
+
const dest = path_1.default.join(process.cwd(), `cli-${dirName}.zip`);
|
|
27
|
+
if ((0, utils_1.checkFullAccess)(dest)) {
|
|
43
28
|
(0, utils_1.delSync)(dest);
|
|
44
29
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
30
|
+
await (0, toolbox_1.zipDir)(contentPath, dest);
|
|
31
|
+
const fileBuffer = await fs_1.default.promises.readFile(dest);
|
|
32
|
+
base64 = fileBuffer.toString('base64');
|
|
33
|
+
(0, utils_1.delSync)(dest);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const fileType = path_1.default.extname(contentPath);
|
|
37
|
+
if (fileType !== '.zip') {
|
|
38
|
+
throw new toolbox_1.CloudBaseError((0, i18n_1.t)('文件类型不正确,目前只支持 ZIP 文件!'));
|
|
39
|
+
}
|
|
40
|
+
const fileBuffer = await fs_1.default.promises.readFile(contentPath);
|
|
41
|
+
base64 = fileBuffer.toString('base64');
|
|
42
|
+
}
|
|
43
|
+
return scfService.request('PublishLayerVersion', {
|
|
44
|
+
LayerName: layerName,
|
|
45
|
+
CompatibleRuntimes: runtimes,
|
|
46
|
+
Src: `TCB_${envId}`,
|
|
47
|
+
Content: {
|
|
48
|
+
ZipFile: base64
|
|
52
49
|
}
|
|
53
|
-
return scfService.request('PublishLayerVersion', {
|
|
54
|
-
LayerName: layerName,
|
|
55
|
-
CompatibleRuntimes: runtimes,
|
|
56
|
-
Src: `TCB_${envId}`,
|
|
57
|
-
Content: {
|
|
58
|
-
ZipFile: base64
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
50
|
});
|
|
62
51
|
}
|
|
63
52
|
exports.createLayer = createLayer;
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.deleteLayer = void 0;
|
|
13
4
|
const utils_1 = require("../../utils");
|
|
14
5
|
const scfService = new utils_1.CloudApiService('scf');
|
|
15
|
-
function deleteLayer(options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
LayerVersion: version
|
|
21
|
-
});
|
|
6
|
+
async function deleteLayer(options) {
|
|
7
|
+
const { name, version } = options;
|
|
8
|
+
return scfService.request('DeleteLayerVersion', {
|
|
9
|
+
LayerName: name,
|
|
10
|
+
LayerVersion: version
|
|
22
11
|
});
|
|
23
12
|
}
|
|
24
13
|
exports.deleteLayer = deleteLayer;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -19,19 +10,17 @@ const error_1 = require("../../error");
|
|
|
19
10
|
const common_1 = require("../../utils/tools/common");
|
|
20
11
|
const i18n_1 = require("../../i18n");
|
|
21
12
|
const scfService = new utils_1.CloudApiService('scf');
|
|
22
|
-
function downloadLayer(options) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
LayerVersion: version
|
|
28
|
-
});
|
|
29
|
-
const url = res === null || res === void 0 ? void 0 : res.Location;
|
|
30
|
-
const zipPath = path_1.default.join(destPath, `${name}-${version}.zip`);
|
|
31
|
-
if ((0, utils_1.checkFullAccess)(zipPath)) {
|
|
32
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('文件已存在:{{path}}', { path: zipPath }));
|
|
33
|
-
}
|
|
34
|
-
return (0, common_1.downloadAndExtractRemoteZip)(url, destPath);
|
|
13
|
+
async function downloadLayer(options) {
|
|
14
|
+
const { name, version, destPath } = options;
|
|
15
|
+
const res = await scfService.request('GetLayerVersion', {
|
|
16
|
+
LayerName: name,
|
|
17
|
+
LayerVersion: version
|
|
35
18
|
});
|
|
19
|
+
const url = res === null || res === void 0 ? void 0 : res.Location;
|
|
20
|
+
const zipPath = path_1.default.join(destPath, `${name}-${version}.zip`);
|
|
21
|
+
if ((0, utils_1.checkFullAccess)(zipPath)) {
|
|
22
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('文件已存在:{{path}}', { path: zipPath }));
|
|
23
|
+
}
|
|
24
|
+
return (0, common_1.downloadAndExtractRemoteZip)(url, destPath);
|
|
36
25
|
}
|
|
37
26
|
exports.downloadLayer = downloadLayer;
|
|
@@ -1,36 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.listLayerVersions = exports.listLayers = void 0;
|
|
13
4
|
const utils_1 = require("../../utils");
|
|
14
5
|
const scfService = new utils_1.CloudApiService('scf');
|
|
15
|
-
function listLayers(options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
SearchSrc: searchSrc
|
|
22
|
-
});
|
|
23
|
-
return (res === null || res === void 0 ? void 0 : res.Layers) || [];
|
|
6
|
+
async function listLayers(options) {
|
|
7
|
+
const { offset, limit, searchSrc } = options;
|
|
8
|
+
const res = await scfService.request('ListLayers', {
|
|
9
|
+
Offset: offset,
|
|
10
|
+
Limit: limit,
|
|
11
|
+
SearchSrc: searchSrc
|
|
24
12
|
});
|
|
13
|
+
return (res === null || res === void 0 ? void 0 : res.Layers) || [];
|
|
25
14
|
}
|
|
26
15
|
exports.listLayers = listLayers;
|
|
27
|
-
function listLayerVersions(options) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
LayerName: name
|
|
32
|
-
});
|
|
33
|
-
return (res === null || res === void 0 ? void 0 : res.LayerVersions) || [];
|
|
16
|
+
async function listLayerVersions(options) {
|
|
17
|
+
const { name } = options;
|
|
18
|
+
const res = await scfService.request('ListLayerVersions', {
|
|
19
|
+
LayerName: name
|
|
34
20
|
});
|
|
21
|
+
return (res === null || res === void 0 ? void 0 : res.LayerVersions) || [];
|
|
35
22
|
}
|
|
36
23
|
exports.listLayerVersions = listLayerVersions;
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.sortLayer = void 0;
|
|
13
4
|
const utils_1 = require("../../utils");
|
|
14
5
|
const scfService = new utils_1.CloudApiService('scf');
|
|
15
|
-
function sortLayer(options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
FunctionName: functionName
|
|
22
|
-
});
|
|
6
|
+
async function sortLayer(options) {
|
|
7
|
+
const { envId, functionName, layers } = options;
|
|
8
|
+
return scfService.request('UpdateFunctionConfiguration', {
|
|
9
|
+
Layers: layers,
|
|
10
|
+
Namespace: envId,
|
|
11
|
+
FunctionName: functionName
|
|
23
12
|
});
|
|
24
13
|
}
|
|
25
14
|
exports.sortLayer = sortLayer;
|