@cloudbase/cloudbase-mcp 2.2.0-alpha.0 → 2.3.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/README.md +1 -1
- package/dist/cli.cjs +87 -426
- package/dist/index.cjs +87 -426
- package/dist/index.js +52 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -101,7 +101,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
101
101
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
102
102
|
exports.CloudRunService = void 0;
|
|
103
103
|
exports.codeToZip = codeToZip;
|
|
104
|
-
exports.parseObjectToDiffConfigItem = parseObjectToDiffConfigItem;
|
|
105
104
|
const archiver_1 = __importDefault(__webpack_require__(99133));
|
|
106
105
|
const fs_extra_1 = __webpack_require__(21605);
|
|
107
106
|
const path_1 = __importDefault(__webpack_require__(39902));
|
|
@@ -270,7 +269,7 @@ class CloudRunService {
|
|
|
270
269
|
/**
|
|
271
270
|
* 上传部署包
|
|
272
271
|
*/
|
|
273
|
-
const zipFile = await codeToZip(targetPath, { installDependency:
|
|
272
|
+
const zipFile = await codeToZip(targetPath, { installDependency: true });
|
|
274
273
|
await (0, utils_1.upload)({
|
|
275
274
|
url: uploadUrl,
|
|
276
275
|
file: zipFile,
|
|
@@ -286,14 +285,8 @@ class CloudRunService {
|
|
|
286
285
|
if (await this._checkFunctionExist(serverName)) {
|
|
287
286
|
// 更新
|
|
288
287
|
const serverDetail = await this.detail({ serverName });
|
|
289
|
-
const _serverConfig = Object.assign(Object.assign(Object.assign({},
|
|
288
|
+
const _serverConfig = Object.assign(Object.assign(Object.assign({}, ((serverDetail === null || serverDetail === void 0 ? void 0 : serverDetail.ServerConfig) || {})), serverConfig), ((serverDetail === null || serverDetail === void 0 ? void 0 : serverDetail.ServerConfig.Tag) === 'function:' ? { Port: 3000 } : {}) // 函数型不能指定端口,需要固定为3000
|
|
290
289
|
);
|
|
291
|
-
if ((serverDetail === null || serverDetail === void 0 ? void 0 : serverDetail.ServerConfig.Tag) === 'function:') {
|
|
292
|
-
deployInfo.BuildPacks = {
|
|
293
|
-
LanguageVersion: '20.18',
|
|
294
|
-
RepoLanguage: 'Node.js'
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
290
|
deployInfo.ReleaseType = 'FULL';
|
|
298
291
|
return this._upsertFunction(false, {
|
|
299
292
|
name: serverName,
|
|
@@ -321,13 +314,7 @@ class CloudRunService {
|
|
|
321
314
|
RepoLanguage: 'Node.js'
|
|
322
315
|
};
|
|
323
316
|
}
|
|
324
|
-
const _serverConfig = Object.assign(Object.assign(Object.assign({ OpenAccessTypes: ['OA', 'PUBLIC', '
|
|
325
|
-
// Cpu: 0,
|
|
326
|
-
// Mem: 0,
|
|
327
|
-
MinNum: 0,
|
|
328
|
-
// MaxNum: 0,
|
|
329
|
-
// PolicyDetails: [],
|
|
330
|
-
EnvParams: JSON.stringify({}), InitialDelaySeconds: 0, CustomLogs: '', HasDockerfile: true, CreateTime: '', EnvId: envConfig.EnvId, ServerName: serverName, Port: type === 'container' ? 80 : 3000, Dockerfile: 'Dockerfile', BuildDir: '' }, serverConfig), (type === 'function' ? { Port: 3000 } : {})), { Tag: type === 'container' ? '' : 'function:' });
|
|
317
|
+
const _serverConfig = Object.assign(Object.assign(Object.assign({ OpenAccessTypes: ['OA', 'PUBLIC'], Cpu: 0, Mem: 0, MinNum: 0, MaxNum: 0, PolicyDetails: [], EnvParams: JSON.stringify({}), InitialDelaySeconds: 0, CustomLogs: '', HasDockerfile: true, CreateTime: '', EnvId: envConfig.EnvId, ServerName: serverName, Port: type === 'container' ? 80 : 3000, Dockerfile: 'Dockerfile', BuildDir: '' }, serverConfig), (type === 'function' ? { Port: 3000 } : {})), { Tag: type === 'container' ? '' : 'function:' });
|
|
331
318
|
return this._upsertFunction(true, {
|
|
332
319
|
name: serverName,
|
|
333
320
|
deployInfo,
|
|
@@ -361,12 +348,11 @@ class CloudRunService {
|
|
|
361
348
|
_upsertFunction(isNew, data) {
|
|
362
349
|
const { name, deployInfo, serverConfig } = data;
|
|
363
350
|
const envConfig = this.environment.lazyEnvironmentConfig;
|
|
364
|
-
const Items = parseObjectToDiffConfigItem(serverConfig);
|
|
365
351
|
return this.tcbrService.request(isNew ? 'CreateCloudRunServer' : 'UpdateCloudRunServer', {
|
|
366
352
|
EnvId: envConfig.EnvId,
|
|
367
353
|
ServerName: name,
|
|
368
354
|
DeployInfo: deployInfo,
|
|
369
|
-
|
|
355
|
+
ServerConfig: serverConfig
|
|
370
356
|
});
|
|
371
357
|
}
|
|
372
358
|
}
|
|
@@ -439,63 +425,6 @@ async function codeToZip(cwd, options) {
|
|
|
439
425
|
await archive.finalize();
|
|
440
426
|
return bufferPromise;
|
|
441
427
|
}
|
|
442
|
-
/**
|
|
443
|
-
* 提交参数变化映射
|
|
444
|
-
*/
|
|
445
|
-
const SUBMIT_DIFF_MAP = {
|
|
446
|
-
Cpu: 'CpuSpecs',
|
|
447
|
-
Mem: 'MemSpecs',
|
|
448
|
-
OpenAccessTypes: 'AccessTypes',
|
|
449
|
-
EnvParams: 'EnvParam',
|
|
450
|
-
CustomLogs: 'LogPath'
|
|
451
|
-
};
|
|
452
|
-
/**
|
|
453
|
-
* 将 object 参数转为 [{key:"Port", IntValue:80}] 的格式,并且剔除空字符串
|
|
454
|
-
*/
|
|
455
|
-
function parseObjectToDiffConfigItem(data) {
|
|
456
|
-
const kvs = Object.entries(data);
|
|
457
|
-
const Items = [];
|
|
458
|
-
kvs.forEach(([k, v]) => {
|
|
459
|
-
const Key = SUBMIT_DIFF_MAP[k] || k;
|
|
460
|
-
if ([
|
|
461
|
-
'CustomLogs',
|
|
462
|
-
'EnvParams',
|
|
463
|
-
'CreateTime',
|
|
464
|
-
'Dockerfile',
|
|
465
|
-
'BuildDir',
|
|
466
|
-
'LogType',
|
|
467
|
-
'LogSetId',
|
|
468
|
-
'LogTopicId',
|
|
469
|
-
'LogParseType',
|
|
470
|
-
'Tag',
|
|
471
|
-
'InternalAccess',
|
|
472
|
-
'InternalDomain',
|
|
473
|
-
'OperationMode',
|
|
474
|
-
'SessionAffinity'
|
|
475
|
-
].includes(k)) {
|
|
476
|
-
!!v && Items.push({ Key, Value: v });
|
|
477
|
-
}
|
|
478
|
-
else if (['MinNum', 'MaxNum', 'InitialDelaySeconds', 'Port'].includes(k)) {
|
|
479
|
-
Items.push({ Key, IntValue: v });
|
|
480
|
-
}
|
|
481
|
-
else if (['HasDockerfile'].includes(k)) {
|
|
482
|
-
Items.push({ Key, BoolValue: v });
|
|
483
|
-
}
|
|
484
|
-
else if (['Cpu', 'Mem'].includes(k)) {
|
|
485
|
-
Items.push({ Key, FloatValue: v });
|
|
486
|
-
}
|
|
487
|
-
else if (['OpenAccessTypes', 'EntryPoint', 'Cmd'].includes(k)) {
|
|
488
|
-
Items.push({ Key, ArrayValue: v });
|
|
489
|
-
}
|
|
490
|
-
else if (['PolicyDetails'].includes(k)) {
|
|
491
|
-
Items.push({ Key, PolicyDetails: v });
|
|
492
|
-
}
|
|
493
|
-
else if (['TimerScale'].includes(k)) {
|
|
494
|
-
Items.push({ Key, TimerScale: v });
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
return Items;
|
|
498
|
-
}
|
|
499
428
|
|
|
500
429
|
|
|
501
430
|
/***/ }),
|
|
@@ -48615,7 +48544,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
48615
48544
|
exports.cloudBaseRequest = cloudBaseRequest;
|
|
48616
48545
|
const auth_1 = __webpack_require__(23506);
|
|
48617
48546
|
const http_request_1 = __webpack_require__(72088);
|
|
48618
|
-
const SUPPORT_REGIONS = ['ap-shanghai', 'ap-guangzhou'
|
|
48547
|
+
const SUPPORT_REGIONS = ['ap-shanghai', 'ap-guangzhou'];
|
|
48619
48548
|
async function cloudBaseRequest(options) {
|
|
48620
48549
|
// const url = 'https://tcb-admin.tencentcloudapi.com/admin'
|
|
48621
48550
|
const { config, params = {}, method = 'POST', headers = {} } = options;
|
|
@@ -48629,11 +48558,11 @@ async function cloudBaseRequest(options) {
|
|
|
48629
48558
|
let internalRegionEndpoint = '';
|
|
48630
48559
|
if (finalRegion) {
|
|
48631
48560
|
if (SUPPORT_REGIONS.includes(finalRegion)) {
|
|
48632
|
-
internetRegionEndpoint = `${
|
|
48633
|
-
internalRegionEndpoint =
|
|
48561
|
+
internetRegionEndpoint = `${finalRegion}.tcb-api.tencentcloudapi.com`;
|
|
48562
|
+
internalRegionEndpoint = `internal.${finalRegion}.tcb-api.tencentcloudapi.com`;
|
|
48634
48563
|
}
|
|
48635
48564
|
else {
|
|
48636
|
-
console.warn('
|
|
48565
|
+
console.warn('当前仅支持上海,广州地域,其他地域默认解析到固定域名(上海地域)');
|
|
48637
48566
|
internetRegionEndpoint = `tcb-api.tencentcloudapi.com`;
|
|
48638
48567
|
internalRegionEndpoint = `internal.tcb-api.tencentcloudapi.com`;
|
|
48639
48568
|
}
|
|
@@ -90226,20 +90155,19 @@ class EnvService {
|
|
|
90226
90155
|
});
|
|
90227
90156
|
}
|
|
90228
90157
|
getCos() {
|
|
90229
|
-
const internalEndpoint = this.environment.cloudBaseContext.isInternalEndpoint();
|
|
90230
90158
|
const { secretId, secretKey, token } = this.environment.getAuthConfig();
|
|
90231
90159
|
const cosConfig = {
|
|
90232
90160
|
SecretId: secretId,
|
|
90233
90161
|
SecretKey: secretKey,
|
|
90234
90162
|
SecurityToken: token,
|
|
90235
|
-
Domain:
|
|
90163
|
+
Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* COS_ENDPOINT.INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* COS_ENDPOINT.PUBLIC */,
|
|
90236
90164
|
};
|
|
90237
90165
|
if (constant_1.COS_SDK_PROTOCOL) {
|
|
90238
90166
|
cosConfig.Protocol = (constant_1.COS_SDK_PROTOCOL.endsWith(':')
|
|
90239
90167
|
? constant_1.COS_SDK_PROTOCOL.toLowerCase()
|
|
90240
90168
|
: constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':');
|
|
90241
90169
|
}
|
|
90242
|
-
if (
|
|
90170
|
+
if (constant_1.USE_INTERNAL_ENDPOINT) {
|
|
90243
90171
|
cosConfig.Protocol = 'http:';
|
|
90244
90172
|
}
|
|
90245
90173
|
return new cos_nodejs_sdk_v5_1.default(cosConfig);
|
|
@@ -134933,7 +134861,7 @@ class TelemetryReporter {
|
|
|
134933
134861
|
const nodeVersion = process.version; // Node.js版本
|
|
134934
134862
|
const arch = os_1.default.arch(); // 系统架构
|
|
134935
134863
|
// 从构建时注入的版本号获取MCP版本信息
|
|
134936
|
-
const mcpVersion = process.env.npm_package_version || "2.
|
|
134864
|
+
const mcpVersion = process.env.npm_package_version || "2.3.0" || 0;
|
|
134937
134865
|
return {
|
|
134938
134866
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
134939
134867
|
deviceId: this.deviceId,
|
|
@@ -179531,7 +179459,6 @@ exports.sleep = sleep;
|
|
|
179531
179459
|
exports.upperCaseStringFisrt = upperCaseStringFisrt;
|
|
179532
179460
|
exports.upperCaseObjKey = upperCaseObjKey;
|
|
179533
179461
|
exports.fetchTemplates = fetchTemplates;
|
|
179534
|
-
exports.successLog = successLog;
|
|
179535
179462
|
const archiver_1 = __importDefault(__webpack_require__(99133));
|
|
179536
179463
|
const crypto_1 = __importDefault(__webpack_require__(55511));
|
|
179537
179464
|
const fs_extra_1 = __importDefault(__webpack_require__(21605));
|
|
@@ -179810,10 +179737,6 @@ const getCompleteTimeRange = (timeRange) => {
|
|
|
179810
179737
|
};
|
|
179811
179738
|
};
|
|
179812
179739
|
exports.getCompleteTimeRange = getCompleteTimeRange;
|
|
179813
|
-
function successLog(msg) {
|
|
179814
|
-
// 空格,兼容中文字符编码长度问题
|
|
179815
|
-
console.log(`${msg}`);
|
|
179816
|
-
}
|
|
179817
179740
|
|
|
179818
179741
|
|
|
179819
179742
|
/***/ }),
|
|
@@ -191142,25 +191065,20 @@ function callSuccessCallback(callback, result) {
|
|
|
191142
191065
|
/***/ }),
|
|
191143
191066
|
|
|
191144
191067
|
/***/ 65607:
|
|
191145
|
-
/***/ ((__unused_webpack_module, exports
|
|
191068
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
191146
191069
|
|
|
191147
191070
|
"use strict";
|
|
191148
191071
|
|
|
191149
191072
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
191150
191073
|
exports.CloudBaseContext = void 0;
|
|
191151
|
-
const constant_1 = __webpack_require__(40762);
|
|
191152
191074
|
class CloudBaseContext {
|
|
191153
|
-
constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = ''
|
|
191075
|
+
constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '' }) {
|
|
191154
191076
|
this.secretId = secretId;
|
|
191155
191077
|
this.secretKey = secretKey;
|
|
191156
191078
|
this.token = token;
|
|
191157
191079
|
this.proxy = proxy;
|
|
191158
191080
|
this.region = region;
|
|
191159
191081
|
this.envType = envType;
|
|
191160
|
-
this.useInternalEndpoint = useInternalEndpoint;
|
|
191161
|
-
}
|
|
191162
|
-
isInternalEndpoint() {
|
|
191163
|
-
return this.useInternalEndpoint !== undefined ? this.useInternalEndpoint : constant_1.USE_INTERNAL_ENDPOINT;
|
|
191164
191082
|
}
|
|
191165
191083
|
}
|
|
191166
191084
|
exports.CloudBaseContext = CloudBaseContext;
|
|
@@ -200687,7 +200605,7 @@ ${envIdSection}
|
|
|
200687
200605
|
## 环境信息
|
|
200688
200606
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
200689
200607
|
- Node.js版本: ${process.version}
|
|
200690
|
-
- MCP 版本:${process.env.npm_package_version || "2.
|
|
200608
|
+
- MCP 版本:${process.env.npm_package_version || "2.3.0" || 0}
|
|
200691
200609
|
- 系统架构: ${os_1.default.arch()}
|
|
200692
200610
|
- 时间: ${new Date().toISOString()}
|
|
200693
200611
|
- 请求ID: ${requestId}
|
|
@@ -203579,7 +203497,6 @@ class StorageService {
|
|
|
203579
203497
|
* 获取 COS 配置
|
|
203580
203498
|
*/
|
|
203581
203499
|
getCos(parallel = 20) {
|
|
203582
|
-
const internalEndpoint = this.environment.cloudBaseContext.isInternalEndpoint();
|
|
203583
203500
|
const { secretId, secretKey, token, proxy } = this.environment.getAuthConfig();
|
|
203584
203501
|
const cosProxy = process.env.TCB_COS_PROXY;
|
|
203585
203502
|
const cosConfig = {
|
|
@@ -203588,14 +203505,14 @@ class StorageService {
|
|
|
203588
203505
|
SecretKey: secretKey,
|
|
203589
203506
|
Proxy: cosProxy || proxy,
|
|
203590
203507
|
SecurityToken: token,
|
|
203591
|
-
Domain:
|
|
203508
|
+
Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* COS_ENDPOINT.INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* COS_ENDPOINT.PUBLIC */,
|
|
203592
203509
|
};
|
|
203593
203510
|
if (constant_1.COS_SDK_PROTOCOL) {
|
|
203594
203511
|
cosConfig.Protocol = (constant_1.COS_SDK_PROTOCOL.endsWith(':')
|
|
203595
203512
|
? constant_1.COS_SDK_PROTOCOL.toLowerCase()
|
|
203596
203513
|
: constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':');
|
|
203597
203514
|
}
|
|
203598
|
-
if (
|
|
203515
|
+
if (constant_1.USE_INTERNAL_ENDPOINT) {
|
|
203599
203516
|
cosConfig.Protocol = 'http:';
|
|
203600
203517
|
}
|
|
203601
203518
|
// COSSDK 默认开启 KeepAlive,这里提供关闭的方式
|
|
@@ -215026,12 +214943,15 @@ const IDE_TYPES = [
|
|
|
215026
214943
|
"roocode", // RooCode AI编辑器
|
|
215027
214944
|
"tongyi-lingma", // 通义灵码
|
|
215028
214945
|
"trae", // Trae AI编辑器
|
|
214946
|
+
"qoder", // Qoder AI编辑器
|
|
214947
|
+
"antigravity", // Google Antigravity AI编辑器
|
|
215029
214948
|
"vscode", // Visual Studio Code
|
|
215030
214949
|
];
|
|
215031
214950
|
// IDE到文件的映射关系
|
|
214951
|
+
// 注意:以 "/" 结尾的路径表示目录,会包含该目录下的所有文件
|
|
215032
214952
|
const IDE_FILE_MAPPINGS = {
|
|
215033
|
-
cursor: [".cursor/rules/
|
|
215034
|
-
windsurf: [".windsurf/rules/
|
|
214953
|
+
cursor: [".cursor/rules/", ".cursor/mcp.json"],
|
|
214954
|
+
windsurf: [".windsurf/rules/"],
|
|
215035
214955
|
codebuddy: [".rules/cloudbase-rules.md", "CODEBUDDY.md", ".mcp.json"],
|
|
215036
214956
|
"claude-code": [
|
|
215037
214957
|
"CLAUDE.md",
|
|
@@ -215041,7 +214961,7 @@ const IDE_FILE_MAPPINGS = {
|
|
|
215041
214961
|
".claude/commands/spec.md",
|
|
215042
214962
|
".claude/commands/no_spec.md",
|
|
215043
214963
|
],
|
|
215044
|
-
cline: [".clinerules/
|
|
214964
|
+
cline: [".clinerules/"],
|
|
215045
214965
|
"gemini-cli": [".gemini/GEMINI.md", ".gemini/settings.json"],
|
|
215046
214966
|
opencode: [".opencode.json"],
|
|
215047
214967
|
"qwen-code": [".qwen/QWEN.md", ".qwen/settings.json"],
|
|
@@ -215055,7 +214975,9 @@ const IDE_FILE_MAPPINGS = {
|
|
|
215055
214975
|
"github-copilot": [".github/copilot-instructions.md"],
|
|
215056
214976
|
roocode: [".roo/rules/cloudbaase-rules.md", ".roo/mcp.json"],
|
|
215057
214977
|
"tongyi-lingma": [".lingma/rules/cloudbaase-rules.md"],
|
|
215058
|
-
trae: [".trae/rules/
|
|
214978
|
+
trae: [".trae/rules/"],
|
|
214979
|
+
qoder: [".qoder/rules/"],
|
|
214980
|
+
antigravity: [".agent/rules/"],
|
|
215059
214981
|
vscode: [".vscode/mcp.json", ".vscode/settings.json"],
|
|
215060
214982
|
};
|
|
215061
214983
|
// 所有IDE配置文件的完整列表 - 通过IDE_FILE_MAPPINGS计算得出
|
|
@@ -215080,6 +215002,8 @@ const IDE_DESCRIPTIONS = {
|
|
|
215080
215002
|
roocode: "RooCode AI编辑器",
|
|
215081
215003
|
"tongyi-lingma": "通义灵码",
|
|
215082
215004
|
trae: "Trae AI编辑器",
|
|
215005
|
+
qoder: "Qoder AI编辑器",
|
|
215006
|
+
antigravity: "Google Antigravity AI编辑器",
|
|
215083
215007
|
vscode: "Visual Studio Code",
|
|
215084
215008
|
};
|
|
215085
215009
|
// INTEGRATION_IDE 环境变量值到 IDE 类型的映射
|
|
@@ -215101,6 +215025,8 @@ const INTEGRATION_IDE_MAPPING = {
|
|
|
215101
215025
|
RooCode: "roocode",
|
|
215102
215026
|
"Tongyi Lingma": "tongyi-lingma",
|
|
215103
215027
|
Trae: "trae",
|
|
215028
|
+
Qoder: "qoder",
|
|
215029
|
+
Antigravity: "antigravity",
|
|
215104
215030
|
VSCode: "vscode",
|
|
215105
215031
|
};
|
|
215106
215032
|
// 根据 INTEGRATION_IDE 环境变量获取默认 IDE 类型
|
|
@@ -215251,6 +215177,17 @@ function validateIDE(ide) {
|
|
|
215251
215177
|
}
|
|
215252
215178
|
return { valid: true };
|
|
215253
215179
|
}
|
|
215180
|
+
// 检查文件是否匹配给定的路径(支持文件和目录)
|
|
215181
|
+
function matchesPath(file, pathPattern) {
|
|
215182
|
+
if (pathPattern.endsWith("/")) {
|
|
215183
|
+
// 目录路径:检查文件是否在该目录下
|
|
215184
|
+
return file.startsWith(pathPattern);
|
|
215185
|
+
}
|
|
215186
|
+
else {
|
|
215187
|
+
// 文件路径:精确匹配
|
|
215188
|
+
return file === pathPattern;
|
|
215189
|
+
}
|
|
215190
|
+
}
|
|
215254
215191
|
// 文件过滤函数
|
|
215255
215192
|
function filterFilesByIDE(files, ide) {
|
|
215256
215193
|
if (ide === "all") {
|
|
@@ -215261,9 +215198,32 @@ function filterFilesByIDE(files, ide) {
|
|
|
215261
215198
|
return files; // 如果找不到映射,返回所有文件
|
|
215262
215199
|
}
|
|
215263
215200
|
// 计算需要排除的IDE文件(除了当前IDE需要的文件)
|
|
215264
|
-
const filesToExclude =
|
|
215201
|
+
const filesToExclude = [];
|
|
215202
|
+
// 遍历所有IDE文件,找出不属于当前IDE的文件
|
|
215203
|
+
for (const ideFile of ALL_IDE_FILES) {
|
|
215204
|
+
// 检查这个文件是否属于当前IDE需要的文件
|
|
215205
|
+
let isCurrentIDEFile = false;
|
|
215206
|
+
for (const currentIDEFile of ideFiles) {
|
|
215207
|
+
if (matchesPath(ideFile, currentIDEFile)) {
|
|
215208
|
+
isCurrentIDEFile = true;
|
|
215209
|
+
break;
|
|
215210
|
+
}
|
|
215211
|
+
}
|
|
215212
|
+
// 如果不属于当前IDE,加入排除列表
|
|
215213
|
+
if (!isCurrentIDEFile) {
|
|
215214
|
+
filesToExclude.push(ideFile);
|
|
215215
|
+
}
|
|
215216
|
+
}
|
|
215265
215217
|
// 排除不需要的IDE配置文件,保留其他所有文件
|
|
215266
|
-
return files.filter((file) =>
|
|
215218
|
+
return files.filter((file) => {
|
|
215219
|
+
// 检查文件是否应该被排除
|
|
215220
|
+
for (const excludePath of filesToExclude) {
|
|
215221
|
+
if (matchesPath(file, excludePath)) {
|
|
215222
|
+
return false; // 排除
|
|
215223
|
+
}
|
|
215224
|
+
}
|
|
215225
|
+
return true; // 保留
|
|
215226
|
+
});
|
|
215267
215227
|
}
|
|
215268
215228
|
// 创建过滤后的目录结构
|
|
215269
215229
|
async function createFilteredDirectory(extractDir, filteredFiles, ide) {
|
|
@@ -215290,7 +215250,7 @@ function registerSetupTools(server) {
|
|
|
215290
215250
|
title: "下载项目模板",
|
|
215291
215251
|
description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
|
|
215292
215252
|
|
|
215293
|
-
**CRITICAL**: This tool MUST be called FIRST when starting a new project.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置(默认)\n- cursor: Cursor AI编辑器\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.
|
|
215253
|
+
**CRITICAL**: This tool MUST be called FIRST when starting a new project.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置(默认)\n- cursor: Cursor AI编辑器\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- qoder: Qoder AI编辑器\n- antigravity: Google Antigravity AI编辑器\n- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.3.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
215294
215254
|
inputSchema: {
|
|
215295
215255
|
template: zod_1.z
|
|
215296
215256
|
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|
|
@@ -226392,7 +226352,6 @@ class CloudService {
|
|
|
226392
226352
|
this.cloudBaseContext = context;
|
|
226393
226353
|
}
|
|
226394
226354
|
get baseUrl() {
|
|
226395
|
-
const internalEndpoint = this.cloudBaseContext.isInternalEndpoint();
|
|
226396
226355
|
const tcb = process.env.TCB_BASE_URL || 'https://tcb.tencentcloudapi.com';
|
|
226397
226356
|
const urlMap = {
|
|
226398
226357
|
tcb,
|
|
@@ -226406,7 +226365,7 @@ class CloudService {
|
|
|
226406
226365
|
const intranetUrlMap = Object.keys(urlMap).map((service) => ({
|
|
226407
226366
|
[service]: `https://${service}.internal.tencentcloudapi.com`,
|
|
226408
226367
|
})).reduce((acc, cur) => (Object.assign(Object.assign({}, acc), cur)), {});
|
|
226409
|
-
if (
|
|
226368
|
+
if (constant_1.USE_INTERNAL_ENDPOINT) {
|
|
226410
226369
|
return intranetUrlMap[this.service];
|
|
226411
226370
|
}
|
|
226412
226371
|
if (urlMap[this.service]) {
|
|
@@ -270039,7 +269998,7 @@ class CloudBase {
|
|
|
270039
269998
|
}
|
|
270040
269999
|
constructor(config = {}) {
|
|
270041
270000
|
this.cloudBaseConfig = {};
|
|
270042
|
-
let { secretId, secretKey, token, envId, proxy, region, envType
|
|
270001
|
+
let { secretId, secretKey, token, envId, proxy, region, envType } = config;
|
|
270043
270002
|
// config 中传入的 secretId secretkey 必须同时存在
|
|
270044
270003
|
if ((secretId && !secretKey) || (!secretId && secretKey)) {
|
|
270045
270004
|
throw new Error('secretId and secretKey must be a pair');
|
|
@@ -270051,8 +270010,7 @@ class CloudBase {
|
|
|
270051
270010
|
envId,
|
|
270052
270011
|
envType,
|
|
270053
270012
|
proxy,
|
|
270054
|
-
region
|
|
270055
|
-
useInternalEndpoint
|
|
270013
|
+
region
|
|
270056
270014
|
};
|
|
270057
270015
|
// 初始化 context
|
|
270058
270016
|
this.context = new context_1.CloudBaseContext(this.cloudBaseConfig);
|
|
@@ -270107,9 +270065,6 @@ class CloudBase {
|
|
|
270107
270065
|
getManagerConfig() {
|
|
270108
270066
|
return this.cloudBaseConfig;
|
|
270109
270067
|
}
|
|
270110
|
-
get isInternalEndpoint() {
|
|
270111
|
-
return this.context.isInternalEndpoint();
|
|
270112
|
-
}
|
|
270113
270068
|
}
|
|
270114
270069
|
module.exports = CloudBase;
|
|
270115
270070
|
|
|
@@ -272188,7 +272143,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
272188
272143
|
exports.FunctionService = void 0;
|
|
272189
272144
|
const fs_1 = __importDefault(__webpack_require__(29021));
|
|
272190
272145
|
const path_1 = __importDefault(__webpack_require__(39902));
|
|
272191
|
-
const lodash_1 = __importDefault(__webpack_require__(2543));
|
|
272192
272146
|
const packer_1 = __webpack_require__(5147);
|
|
272193
272147
|
const error_1 = __webpack_require__(40430);
|
|
272194
272148
|
const utils_1 = __webpack_require__(62358);
|
|
@@ -272435,96 +272389,20 @@ class FunctionService {
|
|
|
272435
272389
|
});
|
|
272436
272390
|
return data;
|
|
272437
272391
|
}
|
|
272438
|
-
/**
|
|
272439
|
-
* 列出所有函数
|
|
272440
|
-
* @param {IListFunctionOptions} options
|
|
272441
|
-
* @returns {Promise<Record<string, string>[]>}
|
|
272442
|
-
*/
|
|
272443
|
-
async listAllFunctions(options) {
|
|
272444
|
-
const allFunctions = [];
|
|
272445
|
-
let currentOffset = 0;
|
|
272446
|
-
const pageSize = 20;
|
|
272447
|
-
const { envId } = options;
|
|
272448
|
-
while (true) {
|
|
272449
|
-
try {
|
|
272450
|
-
const res = await this.scfService.request('ListFunctions', {
|
|
272451
|
-
Namespace: envId,
|
|
272452
|
-
Limit: pageSize,
|
|
272453
|
-
Offset: currentOffset
|
|
272454
|
-
});
|
|
272455
|
-
const { Functions = [], TotalCount } = res;
|
|
272456
|
-
if (Functions.length === 0) {
|
|
272457
|
-
break;
|
|
272458
|
-
}
|
|
272459
|
-
allFunctions.push(...Functions);
|
|
272460
|
-
// 检查是否已获取所有函数
|
|
272461
|
-
if (allFunctions.length >= TotalCount || Functions.length < pageSize) {
|
|
272462
|
-
break;
|
|
272463
|
-
}
|
|
272464
|
-
currentOffset += pageSize;
|
|
272465
|
-
}
|
|
272466
|
-
catch (error) {
|
|
272467
|
-
throw new error_1.CloudBaseError(`获取函数列表失败: ${error.message}`);
|
|
272468
|
-
}
|
|
272469
|
-
}
|
|
272470
|
-
// 格式化数据
|
|
272471
|
-
const data = [];
|
|
272472
|
-
allFunctions.forEach(func => {
|
|
272473
|
-
const { FunctionId, FunctionName, Runtime, AddTime, ModTime, Status } = func;
|
|
272474
|
-
data.push({
|
|
272475
|
-
FunctionId,
|
|
272476
|
-
FunctionName,
|
|
272477
|
-
Runtime,
|
|
272478
|
-
AddTime,
|
|
272479
|
-
ModTime,
|
|
272480
|
-
Status
|
|
272481
|
-
});
|
|
272482
|
-
});
|
|
272483
|
-
return data;
|
|
272484
|
-
}
|
|
272485
272392
|
/**
|
|
272486
272393
|
* 删除云函数
|
|
272487
272394
|
* @param {string} name 云函数名称
|
|
272488
272395
|
* @param {string} qualifier 需要删除的版本号,不填默认删除函数下全部版本。
|
|
272489
272396
|
* @returns {Promise<IResponseInfo>}
|
|
272490
272397
|
*/
|
|
272491
|
-
async deleteFunction(
|
|
272492
|
-
var _a;
|
|
272398
|
+
async deleteFunction(name, qualifier) {
|
|
272493
272399
|
const { namespace } = this.getFunctionConfig();
|
|
272494
|
-
|
|
272495
|
-
const accessService = this.environment.getAccessService();
|
|
272496
|
-
const res = await accessService.getAccessList({
|
|
272497
|
-
name
|
|
272498
|
-
});
|
|
272499
|
-
// 删除绑定的 API 网关
|
|
272500
|
-
if (((_a = res === null || res === void 0 ? void 0 : res.APISet) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
272501
|
-
await accessService.deleteAccess({
|
|
272502
|
-
name
|
|
272503
|
-
});
|
|
272504
|
-
}
|
|
272505
|
-
await this.scfService.request('DeleteFunction', {
|
|
272400
|
+
return this.scfService.request('DeleteFunction', {
|
|
272506
272401
|
FunctionName: name,
|
|
272507
|
-
Namespace: namespace
|
|
272402
|
+
Namespace: namespace,
|
|
272403
|
+
Qualifier: qualifier
|
|
272508
272404
|
});
|
|
272509
272405
|
}
|
|
272510
|
-
/**
|
|
272511
|
-
* 批量删除云函数
|
|
272512
|
-
* @param {Object} options
|
|
272513
|
-
* @param {string[]} options.names 云函数名称列表
|
|
272514
|
-
* @returns {Promise<void>}
|
|
272515
|
-
*/
|
|
272516
|
-
async batchDeleteFunctions({ names }) {
|
|
272517
|
-
const promises = names.map(name => (async () => {
|
|
272518
|
-
try {
|
|
272519
|
-
await this.deleteFunction({ name });
|
|
272520
|
-
(0, utils_1.successLog)(`[${name}] 函数删除成功!`);
|
|
272521
|
-
}
|
|
272522
|
-
catch (e) {
|
|
272523
|
-
throw new error_1.CloudBaseError(e.message);
|
|
272524
|
-
}
|
|
272525
|
-
})());
|
|
272526
|
-
await Promise.all(promises);
|
|
272527
|
-
}
|
|
272528
272406
|
/**
|
|
272529
272407
|
* 获取云函数详细信息
|
|
272530
272408
|
* @param {string} name 云函数名称
|
|
@@ -272559,35 +272437,13 @@ class FunctionService {
|
|
|
272559
272437
|
}
|
|
272560
272438
|
catch (e) {
|
|
272561
272439
|
data.VpcConfig = {
|
|
272562
|
-
vpc: '
|
|
272563
|
-
subnet: '
|
|
272440
|
+
vpc: '',
|
|
272441
|
+
subnet: ''
|
|
272564
272442
|
};
|
|
272565
272443
|
}
|
|
272566
272444
|
}
|
|
272567
272445
|
return data;
|
|
272568
272446
|
}
|
|
272569
|
-
/**
|
|
272570
|
-
* 批量获取云函数详细信息
|
|
272571
|
-
* @param {Object} options
|
|
272572
|
-
* @param {string[]} options.names 云函数名称列表
|
|
272573
|
-
* @param {string} options.envId 环境 ID
|
|
272574
|
-
* @param {string} options.codeSecret
|
|
272575
|
-
* @returns {Promise<IFunctionInfo[]>}
|
|
272576
|
-
*/
|
|
272577
|
-
async batchGetFunctionsDetail({ names, envId, codeSecret }) {
|
|
272578
|
-
const data = [];
|
|
272579
|
-
const promises = names.map(name => (async () => {
|
|
272580
|
-
try {
|
|
272581
|
-
const info = await this.getFunctionDetail(name, codeSecret);
|
|
272582
|
-
data.push(info);
|
|
272583
|
-
}
|
|
272584
|
-
catch (e) {
|
|
272585
|
-
throw new error_1.CloudBaseError(`${name} 获取信息失败:${e.message}`);
|
|
272586
|
-
}
|
|
272587
|
-
})());
|
|
272588
|
-
await Promise.all(promises);
|
|
272589
|
-
return data;
|
|
272590
|
-
}
|
|
272591
272447
|
/**
|
|
272592
272448
|
* 获取函数日志
|
|
272593
272449
|
* @deprecated 请使用 getFunctionLogsV2 代替
|
|
@@ -272684,33 +272540,6 @@ class FunctionService {
|
|
|
272684
272540
|
const res = await this.tcbService.request('GetFunctionLogDetail', params);
|
|
272685
272541
|
return res;
|
|
272686
272542
|
}
|
|
272687
|
-
/**
|
|
272688
|
-
* 获取函数的完整调用日志
|
|
272689
|
-
* 该方法会自动完成两步操作:1. 获取日志请求ID列表。 2. 根据ID列表获取每条日志的详细内容。
|
|
272690
|
-
* @param {IFunctionLogOptionsV2} options - 查询选项
|
|
272691
|
-
* @returns {Promise<IFunctionLogDetailRes[]>} 返回包含完整日志详情的数组
|
|
272692
|
-
*/
|
|
272693
|
-
async getCompleteFunctionLogs(options) {
|
|
272694
|
-
// 调用 getFunctionLogsV2 获取日志请求ID列表
|
|
272695
|
-
const { name } = options;
|
|
272696
|
-
const logs = await this.getFunctionLogsV2(options);
|
|
272697
|
-
// 如果没有日志,直接返回空数组
|
|
272698
|
-
if (logs.LogList.length === 0) {
|
|
272699
|
-
return [];
|
|
272700
|
-
}
|
|
272701
|
-
const detailPromises = logs.LogList.map(async (log) => {
|
|
272702
|
-
// 对每一个日志ID,调用 getFunctionLogDetail
|
|
272703
|
-
const res = await this.getFunctionLogDetail({
|
|
272704
|
-
logRequestId: log.RequestId,
|
|
272705
|
-
startTime: options.startTime,
|
|
272706
|
-
endTime: options.endTime
|
|
272707
|
-
});
|
|
272708
|
-
return Object.assign(Object.assign({}, res), { RetCode: log.RetCode, FunctionName: name });
|
|
272709
|
-
});
|
|
272710
|
-
// 并发执行所有详情查询,等待它们全部完成
|
|
272711
|
-
const detailedLogs = await Promise.all(detailPromises);
|
|
272712
|
-
return detailedLogs;
|
|
272713
|
-
}
|
|
272714
272543
|
/**
|
|
272715
272544
|
* 更新云函数配置
|
|
272716
272545
|
* @param {ICloudFunction} func 云函数配置
|
|
@@ -272846,28 +272675,6 @@ class FunctionService {
|
|
|
272846
272675
|
throw new error_1.CloudBaseError(`[${name}] 调用失败:\n${e.message}`);
|
|
272847
272676
|
}
|
|
272848
272677
|
}
|
|
272849
|
-
/**
|
|
272850
|
-
* 批量调用云函数
|
|
272851
|
-
* @param {IFunctionBatchOptions} options
|
|
272852
|
-
* @returns {Promise<IFunctionInvokeRes[]>}
|
|
272853
|
-
*/
|
|
272854
|
-
async batchInvokeFunctions(options) {
|
|
272855
|
-
const { functions, envId, log = false } = options;
|
|
272856
|
-
const promises = functions.map(func => (async () => {
|
|
272857
|
-
try {
|
|
272858
|
-
const result = await this.invokeFunction(func.name, func.params);
|
|
272859
|
-
if (log) {
|
|
272860
|
-
(0, utils_1.successLog)(`[${func.name}] 调用成功\n响应结果:\n`);
|
|
272861
|
-
console.log(result);
|
|
272862
|
-
}
|
|
272863
|
-
return result;
|
|
272864
|
-
}
|
|
272865
|
-
catch (e) {
|
|
272866
|
-
throw new error_1.CloudBaseError(`${func.name} 函数调用失败:${e.message}`);
|
|
272867
|
-
}
|
|
272868
|
-
})());
|
|
272869
|
-
return Promise.all(promises);
|
|
272870
|
-
}
|
|
272871
272678
|
/**
|
|
272872
272679
|
* 复制云函数
|
|
272873
272680
|
* @param {string} name 云函数名称
|
|
@@ -272910,34 +272717,12 @@ class FunctionService {
|
|
|
272910
272717
|
TriggerDesc: item.config
|
|
272911
272718
|
};
|
|
272912
272719
|
});
|
|
272913
|
-
|
|
272914
|
-
|
|
272915
|
-
|
|
272916
|
-
|
|
272917
|
-
|
|
272918
|
-
|
|
272919
|
-
});
|
|
272920
|
-
}
|
|
272921
|
-
catch (e) {
|
|
272922
|
-
throw new error_1.CloudBaseError(`[${name}] 创建触发器失败:${e.message}`, {
|
|
272923
|
-
action: e.action,
|
|
272924
|
-
code: e.code
|
|
272925
|
-
});
|
|
272926
|
-
}
|
|
272927
|
-
}
|
|
272928
|
-
// 批量部署函数触发器
|
|
272929
|
-
async batchCreateTriggers(options) {
|
|
272930
|
-
const { functions, envId } = options;
|
|
272931
|
-
const promises = functions.map(func => (async () => {
|
|
272932
|
-
try {
|
|
272933
|
-
await this.createFunctionTriggers(func.name, func.triggers);
|
|
272934
|
-
(0, utils_1.successLog)(`[${func.name}] 创建云函数触发器成功!`);
|
|
272935
|
-
}
|
|
272936
|
-
catch (e) {
|
|
272937
|
-
throw new error_1.CloudBaseError(e.message);
|
|
272938
|
-
}
|
|
272939
|
-
})());
|
|
272940
|
-
await Promise.all(promises);
|
|
272720
|
+
return this.scfService.request('BatchCreateTrigger', {
|
|
272721
|
+
FunctionName: name,
|
|
272722
|
+
Namespace: namespace,
|
|
272723
|
+
Triggers: JSON.stringify(parsedTriggers),
|
|
272724
|
+
Count: parsedTriggers.length
|
|
272725
|
+
});
|
|
272941
272726
|
}
|
|
272942
272727
|
/**
|
|
272943
272728
|
* 删除云函数触发器
|
|
@@ -272947,50 +272732,12 @@ class FunctionService {
|
|
|
272947
272732
|
*/
|
|
272948
272733
|
async deleteFunctionTrigger(name, triggerName) {
|
|
272949
272734
|
const { namespace } = this.getFunctionConfig();
|
|
272950
|
-
|
|
272951
|
-
|
|
272952
|
-
|
|
272953
|
-
|
|
272954
|
-
|
|
272955
|
-
Type: 'timer'
|
|
272956
|
-
});
|
|
272957
|
-
(0, utils_1.successLog)(`[${name}] 删除云函数触发器 ${triggerName} 成功!`);
|
|
272958
|
-
}
|
|
272959
|
-
catch (e) {
|
|
272960
|
-
throw new error_1.CloudBaseError(`[${name}] 删除触发器失败:${e.message}`);
|
|
272961
|
-
}
|
|
272962
|
-
}
|
|
272963
|
-
async batchDeleteTriggers(options) {
|
|
272964
|
-
const { functions, envId } = options;
|
|
272965
|
-
const promises = functions.map(func => (async () => {
|
|
272966
|
-
try {
|
|
272967
|
-
func.triggers.forEach(async (trigger) => {
|
|
272968
|
-
await this.deleteFunctionTrigger(func.name, trigger.name);
|
|
272969
|
-
});
|
|
272970
|
-
}
|
|
272971
|
-
catch (e) {
|
|
272972
|
-
throw new error_1.CloudBaseError(e.message);
|
|
272973
|
-
}
|
|
272974
|
-
})());
|
|
272975
|
-
await Promise.all(promises);
|
|
272976
|
-
}
|
|
272977
|
-
/**
|
|
272978
|
-
* 下载云函数代码
|
|
272979
|
-
* @param {IFunctionCodeOptions} options
|
|
272980
|
-
* @returns {Promise<void>}
|
|
272981
|
-
*/
|
|
272982
|
-
async downloadFunctionCode(options) {
|
|
272983
|
-
const { destPath, envId, functionName, codeSecret } = options;
|
|
272984
|
-
// 检验路径是否存在
|
|
272985
|
-
(0, utils_1.checkFullAccess)(destPath, true);
|
|
272986
|
-
// 获取下载链接
|
|
272987
|
-
const { Url } = await this.scfService.request('GetFunctionAddress', {
|
|
272988
|
-
FunctionName: functionName,
|
|
272989
|
-
Namespace: envId,
|
|
272990
|
-
CodeSecret: codeSecret
|
|
272735
|
+
return this.scfService.request('DeleteTrigger', {
|
|
272736
|
+
FunctionName: name,
|
|
272737
|
+
Namespace: namespace,
|
|
272738
|
+
TriggerName: triggerName,
|
|
272739
|
+
Type: 'timer'
|
|
272991
272740
|
});
|
|
272992
|
-
// 下载文件
|
|
272993
|
-
return (0, utils_1.downloadAndExtractRemoteZip)(Url, destPath);
|
|
272994
272741
|
}
|
|
272995
272742
|
/**
|
|
272996
272743
|
* 获取云函数代码下载 链接
|
|
@@ -273016,68 +272763,6 @@ class FunctionService {
|
|
|
273016
272763
|
throw new error_1.CloudBaseError(`[${functionName}] 获取函数代码下载链接失败:\n${e.message}`);
|
|
273017
272764
|
}
|
|
273018
272765
|
}
|
|
273019
|
-
// 函数绑定文件层
|
|
273020
|
-
async attachLayer(options) {
|
|
273021
|
-
const { envId, functionName, layerName, layerVersion, codeSecret } = options;
|
|
273022
|
-
let { Layers = [] } = await this.getFunctionDetail(functionName, codeSecret);
|
|
273023
|
-
Layers = Layers.map(item => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
|
|
273024
|
-
// 新加的文件层添加到最后
|
|
273025
|
-
Layers.push({
|
|
273026
|
-
LayerName: layerName,
|
|
273027
|
-
LayerVersion: layerVersion
|
|
273028
|
-
});
|
|
273029
|
-
const res = await this.scfService.request('UpdateFunctionConfiguration', {
|
|
273030
|
-
Layers,
|
|
273031
|
-
Namespace: envId,
|
|
273032
|
-
FunctionName: functionName
|
|
273033
|
-
});
|
|
273034
|
-
return res;
|
|
273035
|
-
}
|
|
273036
|
-
// 函数解绑文件层
|
|
273037
|
-
async unAttachLayer(options) {
|
|
273038
|
-
const { envId, functionName, layerName, layerVersion, codeSecret } = options;
|
|
273039
|
-
let { Layers } = await this.getFunctionDetail(functionName, codeSecret);
|
|
273040
|
-
Layers = Layers.map(item => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
|
|
273041
|
-
const index = Layers.findIndex(item => item.LayerName === layerName && item.LayerVersion === layerVersion);
|
|
273042
|
-
if (index === -1) {
|
|
273043
|
-
throw new error_1.CloudBaseError('层不存在');
|
|
273044
|
-
}
|
|
273045
|
-
// 删除指定的层
|
|
273046
|
-
Layers.splice(index, 1);
|
|
273047
|
-
const apiParams = {
|
|
273048
|
-
Namespace: envId,
|
|
273049
|
-
FunctionName: functionName,
|
|
273050
|
-
Layers: Layers.length > 0 ? Layers : [{
|
|
273051
|
-
LayerName: '',
|
|
273052
|
-
LayerVersion: 0
|
|
273053
|
-
}]
|
|
273054
|
-
};
|
|
273055
|
-
return this.scfService.request('UpdateFunctionConfiguration', apiParams);
|
|
273056
|
-
}
|
|
273057
|
-
// 更新云函数层
|
|
273058
|
-
async updateFunctionLayer(options) {
|
|
273059
|
-
const { envId, functionName, layers } = options;
|
|
273060
|
-
return this.scfService.request('UpdateFunctionConfiguration', {
|
|
273061
|
-
Layers: layers,
|
|
273062
|
-
Namespace: envId,
|
|
273063
|
-
FunctionName: functionName
|
|
273064
|
-
});
|
|
273065
|
-
}
|
|
273066
|
-
// 下载文件层 ZIP 文件
|
|
273067
|
-
async downloadLayer(options) {
|
|
273068
|
-
const { name, version, destPath } = options;
|
|
273069
|
-
const res = await this.scfService.request('GetLayerVersion', {
|
|
273070
|
-
LayerName: name,
|
|
273071
|
-
LayerVersion: version
|
|
273072
|
-
});
|
|
273073
|
-
const url = res === null || res === void 0 ? void 0 : res.Location;
|
|
273074
|
-
const zipPath = path_1.default.join(destPath, `${name}-${version}.zip`);
|
|
273075
|
-
if ((0, utils_1.checkFullAccess)(zipPath)) {
|
|
273076
|
-
throw new error_1.CloudBaseError(`文件已存在:${zipPath}`);
|
|
273077
|
-
}
|
|
273078
|
-
// 下载文件
|
|
273079
|
-
return (0, utils_1.downloadAndExtractRemoteZip)(url, destPath);
|
|
273080
|
-
}
|
|
273081
272766
|
// 创建文件层版本
|
|
273082
272767
|
async createLayer(options) {
|
|
273083
272768
|
const { env } = this.getFunctionConfig();
|
|
@@ -273150,7 +272835,7 @@ class FunctionService {
|
|
|
273150
272835
|
Limit: limit,
|
|
273151
272836
|
Offset: offset,
|
|
273152
272837
|
SearchKey: searchKey,
|
|
273153
|
-
|
|
272838
|
+
SearchSrc: `TCB_${env}`
|
|
273154
272839
|
};
|
|
273155
272840
|
if (runtime) {
|
|
273156
272841
|
param.CompatibleRuntime = runtime;
|
|
@@ -273479,18 +273164,12 @@ __decorate([
|
|
|
273479
273164
|
__decorate([
|
|
273480
273165
|
(0, utils_1.preLazy)()
|
|
273481
273166
|
], FunctionService.prototype, "listFunctions", null);
|
|
273482
|
-
__decorate([
|
|
273483
|
-
(0, utils_1.preLazy)()
|
|
273484
|
-
], FunctionService.prototype, "listAllFunctions", null);
|
|
273485
273167
|
__decorate([
|
|
273486
273168
|
(0, utils_1.preLazy)()
|
|
273487
273169
|
], FunctionService.prototype, "deleteFunction", null);
|
|
273488
273170
|
__decorate([
|
|
273489
273171
|
(0, utils_1.preLazy)()
|
|
273490
273172
|
], FunctionService.prototype, "getFunctionDetail", null);
|
|
273491
|
-
__decorate([
|
|
273492
|
-
(0, utils_1.preLazy)()
|
|
273493
|
-
], FunctionService.prototype, "batchGetFunctionsDetail", null);
|
|
273494
273173
|
__decorate([
|
|
273495
273174
|
(0, utils_1.preLazy)()
|
|
273496
273175
|
], FunctionService.prototype, "getFunctionLogs", null);
|
|
@@ -273500,9 +273179,6 @@ __decorate([
|
|
|
273500
273179
|
__decorate([
|
|
273501
273180
|
(0, utils_1.preLazy)()
|
|
273502
273181
|
], FunctionService.prototype, "getFunctionLogDetail", null);
|
|
273503
|
-
__decorate([
|
|
273504
|
-
(0, utils_1.preLazy)()
|
|
273505
|
-
], FunctionService.prototype, "getCompleteFunctionLogs", null);
|
|
273506
273182
|
__decorate([
|
|
273507
273183
|
(0, utils_1.preLazy)()
|
|
273508
273184
|
], FunctionService.prototype, "updateFunctionConfig", null);
|
|
@@ -273512,9 +273188,6 @@ __decorate([
|
|
|
273512
273188
|
__decorate([
|
|
273513
273189
|
(0, utils_1.preLazy)()
|
|
273514
273190
|
], FunctionService.prototype, "invokeFunction", null);
|
|
273515
|
-
__decorate([
|
|
273516
|
-
(0, utils_1.preLazy)()
|
|
273517
|
-
], FunctionService.prototype, "batchInvokeFunctions", null);
|
|
273518
273191
|
__decorate([
|
|
273519
273192
|
(0, utils_1.preLazy)()
|
|
273520
273193
|
], FunctionService.prototype, "copyFunction", null);
|
|
@@ -273527,18 +273200,6 @@ __decorate([
|
|
|
273527
273200
|
__decorate([
|
|
273528
273201
|
(0, utils_1.preLazy)()
|
|
273529
273202
|
], FunctionService.prototype, "getFunctionDownloadUrl", null);
|
|
273530
|
-
__decorate([
|
|
273531
|
-
(0, utils_1.preLazy)()
|
|
273532
|
-
], FunctionService.prototype, "attachLayer", null);
|
|
273533
|
-
__decorate([
|
|
273534
|
-
(0, utils_1.preLazy)()
|
|
273535
|
-
], FunctionService.prototype, "unAttachLayer", null);
|
|
273536
|
-
__decorate([
|
|
273537
|
-
(0, utils_1.preLazy)()
|
|
273538
|
-
], FunctionService.prototype, "updateFunctionLayer", null);
|
|
273539
|
-
__decorate([
|
|
273540
|
-
(0, utils_1.preLazy)()
|
|
273541
|
-
], FunctionService.prototype, "downloadLayer", null);
|
|
273542
273203
|
__decorate([
|
|
273543
273204
|
(0, utils_1.preLazy)()
|
|
273544
273205
|
], FunctionService.prototype, "createLayer", null);
|