@cloudbase/cli 2.8.0 → 2.8.1-beta.1
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/cloudbase-cli-2.7.8.tgz +0 -0
- package/lib/commands/functions/deploy.js +5 -12
- package/lib/commands/functions/layer/bind.js +1 -1
- package/lib/function/base.js +45 -1
- package/package.json +2 -2
- package/types/commands/functions/deploy.d.ts +1 -1
- package/types/function/base.d.ts +1 -0
- package/.claude/settings.local.json +0 -6
|
Binary file
|
|
@@ -218,20 +218,13 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
218
218
|
codeSecret,
|
|
219
219
|
functionRootPath
|
|
220
220
|
});
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
yield this.waitForFunctionReady(envId, func.name, loading);
|
|
222
|
+
loading.succeed(`[${func.name}] 云函数配置更新中...`);
|
|
223
223
|
yield (0, function_2.updateFunctionConfig)({
|
|
224
224
|
envId,
|
|
225
225
|
functionName: func.name,
|
|
226
226
|
config: func
|
|
227
227
|
});
|
|
228
|
-
const config_text = '配置';
|
|
229
|
-
yield this.waitForFunctionReady(envId, func.name, loading, config_text);
|
|
230
|
-
yield (0, function_2.createFunctionTriggers)({
|
|
231
|
-
envId,
|
|
232
|
-
functionName: func.name,
|
|
233
|
-
triggers
|
|
234
|
-
});
|
|
235
228
|
loading.succeed(`[${func.name}] 云函数更新成功!`);
|
|
236
229
|
yield this.printSuccessTips(envId);
|
|
237
230
|
}
|
|
@@ -245,7 +238,7 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
245
238
|
throw e;
|
|
246
239
|
});
|
|
247
240
|
}
|
|
248
|
-
waitForFunctionReady(envId, functionName, loading,
|
|
241
|
+
waitForFunctionReady(envId, functionName, loading, timeoutMinutes = 5) {
|
|
249
242
|
return __awaiter(this, void 0, void 0, function* () {
|
|
250
243
|
const scfService = yield (0, function_2.getFunctionService)(envId);
|
|
251
244
|
const timeoutMs = timeoutMinutes * 60 * 1000;
|
|
@@ -261,11 +254,11 @@ let FunctionDeploy = class FunctionDeploy extends common_1.Command {
|
|
|
261
254
|
if ((functionInfo === null || functionInfo === void 0 ? void 0 : functionInfo.Status) === 'Active') {
|
|
262
255
|
clearTimeout(timeoutId);
|
|
263
256
|
clearInterval(intervalId);
|
|
264
|
-
loading.succeed(`[${functionName}]
|
|
257
|
+
loading.succeed(`[${functionName}] 云函数代码已更新!`);
|
|
265
258
|
resolve();
|
|
266
259
|
}
|
|
267
260
|
else {
|
|
268
|
-
loading.text = `正在更新[${functionName}]
|
|
261
|
+
loading.text = `正在更新[${functionName}] 云函数代码... 当前状态: ${(functionInfo === null || functionInfo === void 0 ? void 0 : functionInfo.Status) || '未知'}`;
|
|
269
262
|
}
|
|
270
263
|
}
|
|
271
264
|
catch (error) {
|
|
@@ -54,7 +54,7 @@ let AttachFileLayer = class AttachFileLayer extends common_1.Command {
|
|
|
54
54
|
const fnName = params === null || params === void 0 ? void 0 : params[0];
|
|
55
55
|
const loading = (0, utils_1.loadingFactory)();
|
|
56
56
|
loading.start('数据加载中...');
|
|
57
|
-
const envFunctions = yield (0, function_1.
|
|
57
|
+
const envFunctions = yield (0, function_1.listAllFunctions)({
|
|
58
58
|
envId
|
|
59
59
|
});
|
|
60
60
|
const exist = envFunctions.find((fn) => fn.FunctionName === fnName);
|
package/lib/function/base.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.copyFunction = exports.batchInvokeFunctions = exports.invokeFunction = exports.batchUpdateFunctionConfig = exports.updateFunctionConfig = exports.getFunctionLog = exports.batchGetFunctionsDetail = exports.getFunctionDetail = exports.listFunction = exports.getFunctionService = void 0;
|
|
15
|
+
exports.copyFunction = exports.batchInvokeFunctions = exports.invokeFunction = exports.batchUpdateFunctionConfig = exports.updateFunctionConfig = exports.getFunctionLog = exports.batchGetFunctionsDetail = exports.getFunctionDetail = exports.listAllFunctions = exports.listFunction = exports.getFunctionService = void 0;
|
|
16
16
|
const manager_node_1 = __importDefault(require("@cloudbase/manager-node"));
|
|
17
17
|
const utils_1 = require("../utils");
|
|
18
18
|
const logger_1 = require("../logger");
|
|
@@ -61,6 +61,50 @@ function listFunction(options) {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
exports.listFunction = listFunction;
|
|
64
|
+
function listAllFunctions(options) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const allFunctions = [];
|
|
67
|
+
let currentOffset = 0;
|
|
68
|
+
const pageSize = 20;
|
|
69
|
+
const { envId } = options;
|
|
70
|
+
console.log(`这是listAllFunctions函数,envId: ${envId}`);
|
|
71
|
+
while (true) {
|
|
72
|
+
try {
|
|
73
|
+
const res = yield scfService.request('ListFunctions', {
|
|
74
|
+
Namespace: envId,
|
|
75
|
+
Limit: pageSize,
|
|
76
|
+
Offset: currentOffset
|
|
77
|
+
});
|
|
78
|
+
const { Functions = [], TotalCount } = res;
|
|
79
|
+
if (Functions.length === 0) {
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
allFunctions.push(...Functions);
|
|
83
|
+
if (allFunctions.length >= TotalCount || Functions.length < pageSize) {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
currentOffset += pageSize;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
throw new error_1.CloudBaseError(`获取函数列表失败: ${error.message}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const data = [];
|
|
93
|
+
allFunctions.forEach(func => {
|
|
94
|
+
const { FunctionId, FunctionName, Runtime, AddTime, ModTime, Status } = func;
|
|
95
|
+
data.push({
|
|
96
|
+
FunctionId,
|
|
97
|
+
FunctionName,
|
|
98
|
+
Runtime,
|
|
99
|
+
AddTime,
|
|
100
|
+
ModTime,
|
|
101
|
+
Status
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
return data;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
exports.listAllFunctions = listAllFunctions;
|
|
64
108
|
function getFunctionDetail(options) {
|
|
65
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
110
|
const { functionName, envId, codeSecret } = options;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cli",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.1-beta.1",
|
|
4
4
|
"description": "cli tool for cloudbase",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@cloudbase/functions-framework": "1.16.0",
|
|
39
39
|
"@cloudbase/iac-core": "0.0.3-alpha.11",
|
|
40
40
|
"@cloudbase/lowcode-cli": "^0.22.2",
|
|
41
|
-
"@cloudbase/manager-node": "4.
|
|
41
|
+
"@cloudbase/manager-node": "4.4.3",
|
|
42
42
|
"@cloudbase/toolbox": "^0.7.7",
|
|
43
43
|
"@dotenvx/dotenvx": "^1.48.3",
|
|
44
44
|
"address": "^1.1.2",
|
|
@@ -16,7 +16,7 @@ export declare class FunctionDeploy extends Command {
|
|
|
16
16
|
execute(ctx: any, params: any, log: Logger): Promise<void>;
|
|
17
17
|
deployAllFunction(options: any): Promise<void>;
|
|
18
18
|
handleDeployFail(e: CloudBaseError, options: ICreateFunctionOptions): Promise<void>;
|
|
19
|
-
waitForFunctionReady(envId: string, functionName: string, loading: any,
|
|
19
|
+
waitForFunctionReady(envId: string, functionName: string, loading: any, timeoutMinutes?: number): Promise<void>;
|
|
20
20
|
printSuccessTips(envId: string, log?: Logger): Promise<void>;
|
|
21
21
|
genApiGateway(envId: string, name: string): Promise<void>;
|
|
22
22
|
}
|
package/types/function/base.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface IDetailOptions extends IBaseOptions {
|
|
|
17
17
|
}
|
|
18
18
|
export declare function getFunctionService(envId: string): Promise<import("@cloudbase/manager-node/types/function").FunctionService>;
|
|
19
19
|
export declare function listFunction(options: IListFunctionOptions): Promise<Record<string, string>[]>;
|
|
20
|
+
export declare function listAllFunctions(options: IListFunctionOptions): Promise<Record<string, string>[]>;
|
|
20
21
|
export declare function getFunctionDetail(options: IDetailOptions): Promise<Record<string, any>>;
|
|
21
22
|
export declare function batchGetFunctionsDetail({ names, envId, codeSecret }: {
|
|
22
23
|
names: any;
|