@cloudbase/cli 2.9.4 → 2.9.5
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/dist/standalone/cli.js +228 -74
- package/lib/utils/template-manager.js +78 -10
- package/package.json +1 -1
- package/types/utils/template-manager.d.ts +2 -0
package/dist/standalone/cli.js
CHANGED
|
@@ -11675,12 +11675,13 @@ let DeleteFileLayer = class DeleteFileLayer extends common_1.Command {
|
|
|
11675
11675
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11676
11676
|
const loading = (0, utils_1.loadingFactory)();
|
|
11677
11677
|
loading.start('数据加载中...');
|
|
11678
|
-
const
|
|
11678
|
+
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
11679
|
+
const listLayersRes = yield functionService.listLayers({
|
|
11679
11680
|
offset: 0,
|
|
11680
11681
|
limit: 200,
|
|
11681
|
-
searchSrc: `TCB_${envId}`
|
|
11682
11682
|
});
|
|
11683
11683
|
loading.stop();
|
|
11684
|
+
const layers = listLayersRes.Layers || [];
|
|
11684
11685
|
if (!layers.length) {
|
|
11685
11686
|
throw new error_1.CloudBaseError('当前环境没有可用的文件层,请先创建文件层!');
|
|
11686
11687
|
}
|
|
@@ -11690,10 +11691,11 @@ let DeleteFileLayer = class DeleteFileLayer extends common_1.Command {
|
|
|
11690
11691
|
message: '选择文件层名称',
|
|
11691
11692
|
choices: layers.map((item) => item.LayerName)
|
|
11692
11693
|
});
|
|
11693
|
-
let
|
|
11694
|
+
let listLayerVersionsRes = yield functionService.listLayerVersions({
|
|
11694
11695
|
name: layer
|
|
11695
11696
|
});
|
|
11696
|
-
|
|
11697
|
+
const layerVersions = listLayerVersionsRes.LayerVersions || [];
|
|
11698
|
+
const versions = layerVersions.map((item) => String(item.LayerVersion));
|
|
11697
11699
|
const { version } = yield (0, enquirer_1.prompt)({
|
|
11698
11700
|
type: 'select',
|
|
11699
11701
|
name: 'version',
|
|
@@ -11701,7 +11703,7 @@ let DeleteFileLayer = class DeleteFileLayer extends common_1.Command {
|
|
|
11701
11703
|
choices: versions
|
|
11702
11704
|
});
|
|
11703
11705
|
loading.start('文件层删除中...');
|
|
11704
|
-
yield
|
|
11706
|
+
yield functionService.deleteLayerVersion({
|
|
11705
11707
|
name: layer,
|
|
11706
11708
|
version: Number(version)
|
|
11707
11709
|
});
|
|
@@ -17486,7 +17488,7 @@ let PullCommand = class PullCommand extends common_1.Command {
|
|
|
17486
17488
|
desc: '强制清理目标输出目录(慎用)'
|
|
17487
17489
|
}
|
|
17488
17490
|
],
|
|
17489
|
-
desc: '拉取项目模板\n\n支持的内置模板:\n miniprogram - 微信小程序 + CloudBase\n react - Web 应用 - React + CloudBase\n vue - Web 应用 - Vue + CloudBase\n uniapp - 跨端应用 - UniApp + CloudBase\n rules - AI 规则和配置\n\n支持的 Git 仓库:\n GitHub: https://github.com/user/repo\n Gitee: https://gitee.com/user/repo\n SSH: git@github.com:user/repo.git\n\n支持 Git 子目录:\n https://github.com/user/repo/tree/main/src/templates\n\n示例:\n tcb pull miniprogram\n tcb pull https://github.com/user/repo\n tcb pull https://
|
|
17491
|
+
desc: '拉取项目模板\n\n支持的内置模板:\n miniprogram - 微信小程序 + CloudBase\n react - Web 应用 - React + CloudBase\n vue - Web 应用 - Vue + CloudBase\n uniapp - 跨端应用 - UniApp + CloudBase\n rules - AI 规则和配置\n\n支持的 Git 仓库:\n GitHub: https://github.com/user/repo\n Gitee: https://gitee.com/user/repo\n CNB: https://cnb.cool/user/repo\n SSH: git@github.com:user/repo.git\n\n支持 Git 子目录:\n https://github.com/user/repo/tree/main/src/templates\n https://cnb.cool/user/repo/tree/main/examples\n\n示例:\n tcb pull miniprogram\n tcb pull https://github.com/user/repo\n tcb pull https://cnb.cool/user/repo\n tcb pull https://cnb.cool/user/repo/tree/main/examples --output ./my-project',
|
|
17490
17492
|
requiredEnvId: false,
|
|
17491
17493
|
withoutAuth: true
|
|
17492
17494
|
};
|
|
@@ -17525,6 +17527,7 @@ let PullCommand = class PullCommand extends common_1.Command {
|
|
|
17525
17527
|
log.info('\n🌐 支持的 Git 仓库格式:');
|
|
17526
17528
|
log.info(' GitHub: https://github.com/user/repo');
|
|
17527
17529
|
log.info(' Gitee: https://gitee.com/user/repo');
|
|
17530
|
+
log.info(' CNB: https://cnb.cool/user/repo');
|
|
17528
17531
|
log.info(' SSH: git@github.com:user/repo.git');
|
|
17529
17532
|
log.info('\n📁 支持 Git 子目录:');
|
|
17530
17533
|
log.info(' https://github.com/user/repo/tree/main/src/templates');
|
|
@@ -42400,7 +42403,7 @@ module.exports = function generate_pattern(it, $keyword, $ruleType) {
|
|
|
42400
42403
|
/***/ ((module) => {
|
|
42401
42404
|
|
|
42402
42405
|
"use strict";
|
|
42403
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.9.
|
|
42406
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.9.4","description":"cli tool for cloudbase","main":"lib/index.js","scripts":{"build":"rimraf lib types && tsc --resolveJsonModule && cpx \\"src/**/*.html\\" lib","watch":"rimraf lib types && tsc -w","dev":"rimraf lib types && cpx \\"src/**/*.html\\" lib && tsc -w","eslint":"eslint \\"./**/*.ts\\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000","tsc":"tsc","pkg":"pkg ./bin/cloudbase.js --out-path ./pkg","postinstall":"node ./post-install.js || exit 0 && patch-package","prepublishOnly":"npm run build","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs","package:darwin-arm64":"OS=darwin ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:darwin-x64":"OS=darwin ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-arm64":"OS=linux ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-x64":"OS=linux ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:all":"bash build/scripts/build-all.sh","node:fetch:one":"node -e \\"require(\'child_process\').execSync(\'bash build/scripts/fetch-node.sh\',{stdio:\'inherit\'})\\"","node:fetch:all":"NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh --all","node:fetch:win-x64":"OS=windows ARCH=x64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","node:fetch:win-arm64":"OS=windows ARCH=arm64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","package:windows-x64":"OS=windows ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-arm64":"OS=windows ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-all":"npm run -s node:fetch:win-x64 && npm run -s node:fetch:win-arm64 && npm run -s package:windows-x64 && npm run -s package:windows-arm64","out:prune":"bash build/scripts/prune-out.sh"},"repository":{"type":"git","url":"https://github.com/TencentCloudBase/cloud-base-cli.git"},"bin":{"ccr":"bin/ccr.js","cloudbase":"bin/cloudbase.js","cloudbase-mcp":"bin/cloudbase-mcp.cjs","tcb":"bin/tcb.js"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^1.8.41","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.11","@cloudbase/lowcode-cli":"^0.22.2","@cloudbase/manager-node":"4.6.1","@cloudbase/toolbox":"^0.7.9","@dotenvx/dotenvx":"^1.48.3","@musistudio/claude-code-router":"1.0.36","address":"^1.1.2","camelcase-keys":"^7.0.2","chalk":"^2.4.2","cli-table3":"^0.5.1","commander":"7","del":"^5.1.0","didyoumean":"^1.2.2","enquirer":"^2.3.6","execa":"^4.0.3","figlet":"^1.7.0","fs-extra":"^8.1.0","gradient-string":"^2.0.2","https-proxy-agent":"^5.0.1","i":"^0.3.7","inquirer":"^6.5.0","json-schema-to-typescript":"^14.0.5","lodash":"^4.17.21","log-symbols":"^3.0.0","lowdb":"^1.0.0","make-dir":"^3.0.0","node-fetch":"^2.6.0","nodemon":"^3.1.4","npm":"^11.5.2","open":"^7.0.0","ora":"^4.0.2","patch-package":"^8.0.0","portfinder":"^1.0.28","progress":"^2.0.3","query-string":"^6.8.1","reflect-metadata":"^0.1.13","semver":"^7.3.7","simple-git":"^3.28.0","tar-fs":"^2.0.1","terminal-link":"^2.1.1","toml":"^3.0.0","unzipper":"^0.10.10","update-notifier":"^4.0.0","xdg-basedir":"^4.0.0","yargs":"^16.2.0","yargs-parser":"^21.0.1","zod":"^4.0.13"},"devDependencies":{"@types/fs-extra":"^11.0.4","@types/jest":"^27","@types/koa__router":"^8.0.11","@types/lodash":"^4.14.182","@types/node":"^12.12.38","@types/node-fetch":"^2.5.4","@types/react":"^17.0.37","@types/semver":"^7.3.9","@types/unzipper":"^0.10.11","@types/webpack-dev-server":"^3.11.1","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","cpx":"^1.5.0","eslint":"^7.14.0","eslint-config-alloy":"^3.8.2","husky":"^3.0.9","jest":"^27","rimraf":"^3.0.2","ts-jest":"^27","typescript":"^4.7.2","webpack":"^5.92.0","webpack-cli":"^5.1.4"},"packageManager":"yarn@3.6.2+sha512.2c2f8b9615e6659773f65cdec7cf92ef773a98a99e611579601f61c7a91ec94c89c929aac86f1cee819421a9b0db7acfd53ec3ebb95af44f77f77634b08b9557"}');
|
|
42404
42407
|
|
|
42405
42408
|
/***/ }),
|
|
42406
42409
|
|
|
@@ -42799,6 +42802,7 @@ const getArgs = () => {
|
|
|
42799
42802
|
.help(false)
|
|
42800
42803
|
.alias('e', 'envId')
|
|
42801
42804
|
.alias('r', 'region')
|
|
42805
|
+
.alias('v', 'version')
|
|
42802
42806
|
.argv;
|
|
42803
42807
|
};
|
|
42804
42808
|
exports.getArgs = getArgs;
|
|
@@ -67569,8 +67573,8 @@ class AISetupWizard {
|
|
|
67569
67573
|
type: 'list',
|
|
67570
67574
|
name: 'agent',
|
|
67571
67575
|
message: `${message} ${const_1.LIST_HINT}`,
|
|
67572
|
-
choices: [const_1.
|
|
67573
|
-
default: const_1.
|
|
67576
|
+
choices: [const_1.CODEBUDDY, const_1.CLAUDE, const_1.QWEN, const_1.CODEX, const_1.CURSOR, const_1.AIDER, ...(includeNone ? [const_1.NONE] : [])],
|
|
67577
|
+
default: const_1.CODEBUDDY.value
|
|
67574
67578
|
}
|
|
67575
67579
|
]);
|
|
67576
67580
|
return agent;
|
|
@@ -67646,6 +67650,10 @@ class AISetupWizard {
|
|
|
67646
67650
|
name: 'DeepSeek - https://api.deepseek.com/anthropic',
|
|
67647
67651
|
value: 'https://api.deepseek.com/anthropic'
|
|
67648
67652
|
},
|
|
67653
|
+
{
|
|
67654
|
+
name: 'LongCat - https://api.longcat.chat/anthropic',
|
|
67655
|
+
value: 'https://api.longcat.chat/anthropic'
|
|
67656
|
+
},
|
|
67649
67657
|
{ name: '🛠️ 自定义 URL', value: 'custom' }
|
|
67650
67658
|
],
|
|
67651
67659
|
default: 'https://api.moonshot.cn/anthropic'
|
|
@@ -67670,7 +67678,7 @@ class AISetupWizard {
|
|
|
67670
67678
|
{
|
|
67671
67679
|
type: 'password',
|
|
67672
67680
|
name: 'apiKey',
|
|
67673
|
-
message: '
|
|
67681
|
+
message: 'Auth Token:',
|
|
67674
67682
|
validate: (input) => input.length > 0 || '请输入有效的 Auth Token'
|
|
67675
67683
|
}
|
|
67676
67684
|
]);
|
|
@@ -67687,6 +67695,9 @@ class AISetupWizard {
|
|
|
67687
67695
|
else if (baseUrl === 'https://api.deepseek.com/anthropic') {
|
|
67688
67696
|
defaultModel = 'deepseek-chat';
|
|
67689
67697
|
}
|
|
67698
|
+
else if (baseUrl === 'https://api.longcat.chat/anthropic') {
|
|
67699
|
+
defaultModel = 'LongCat-Flash-Chat';
|
|
67700
|
+
}
|
|
67690
67701
|
else {
|
|
67691
67702
|
defaultModel = '';
|
|
67692
67703
|
}
|
|
@@ -67745,7 +67756,7 @@ class AISetupWizard {
|
|
|
67745
67756
|
{
|
|
67746
67757
|
type: 'password',
|
|
67747
67758
|
name: 'apiKey',
|
|
67748
|
-
message: '
|
|
67759
|
+
message: 'API Key:',
|
|
67749
67760
|
validate: (input) => input.length > 0 || '请输入有效的 API Key'
|
|
67750
67761
|
},
|
|
67751
67762
|
{
|
|
@@ -67801,6 +67812,10 @@ class AISetupWizard {
|
|
|
67801
67812
|
name: '智谱 - https://open.bigmodel.cn/api/paas/v4',
|
|
67802
67813
|
value: 'https://open.bigmodel.cn/api/paas/v4'
|
|
67803
67814
|
},
|
|
67815
|
+
{
|
|
67816
|
+
name: 'LongCat - https://api.longcat.chat/openai',
|
|
67817
|
+
value: 'https://api.longcat.chat/openai'
|
|
67818
|
+
},
|
|
67804
67819
|
{ name: '🛠️ 自定义 URL', value: 'custom' }
|
|
67805
67820
|
],
|
|
67806
67821
|
default: 'https://api.moonshot.cn/v1'
|
|
@@ -67880,6 +67895,10 @@ class AISetupWizard {
|
|
|
67880
67895
|
name: '智谱 - https://open.bigmodel.cn/api/paas/v4',
|
|
67881
67896
|
value: 'https://open.bigmodel.cn/api/paas/v4'
|
|
67882
67897
|
},
|
|
67898
|
+
{
|
|
67899
|
+
name: 'LongCat - https://api.longcat.chat/openai',
|
|
67900
|
+
value: 'https://api.longcat.chat/openai'
|
|
67901
|
+
},
|
|
67883
67902
|
{ name: '🛠️ 自定义 URL', value: 'custom' }
|
|
67884
67903
|
],
|
|
67885
67904
|
default: 'https://api.moonshot.cn/v1'
|
|
@@ -68044,8 +68063,8 @@ class AISetupWizard {
|
|
|
68044
68063
|
{
|
|
68045
68064
|
type: 'password',
|
|
68046
68065
|
name: 'apiKey',
|
|
68047
|
-
message: '
|
|
68048
|
-
validate: (input) => input.trim().length > 0 || 'API Key
|
|
68066
|
+
message: 'API Key:',
|
|
68067
|
+
validate: (input) => input.trim().length > 0 || '请输入有效的 API Key'
|
|
68049
68068
|
}
|
|
68050
68069
|
]);
|
|
68051
68070
|
yield this.aiConfigManager.updateCodebuddyConfig('custom', {
|
|
@@ -107404,6 +107423,7 @@ let CreateTrigger = class CreateTrigger extends common_1.Command {
|
|
|
107404
107423
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107405
107424
|
const { envId, config: { functions } } = ctx;
|
|
107406
107425
|
const name = params === null || params === void 0 ? void 0 : params[0];
|
|
107426
|
+
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
107407
107427
|
let isBatchCreateTrigger = false;
|
|
107408
107428
|
if (!name) {
|
|
107409
107429
|
const { isBatch } = yield inquirer_1.default.prompt({
|
|
@@ -107418,7 +107438,7 @@ let CreateTrigger = class CreateTrigger extends common_1.Command {
|
|
|
107418
107438
|
}
|
|
107419
107439
|
}
|
|
107420
107440
|
if (isBatchCreateTrigger) {
|
|
107421
|
-
return
|
|
107441
|
+
return functionService.batchCreateTriggers({
|
|
107422
107442
|
envId,
|
|
107423
107443
|
functions
|
|
107424
107444
|
});
|
|
@@ -107431,11 +107451,7 @@ let CreateTrigger = class CreateTrigger extends common_1.Command {
|
|
|
107431
107451
|
if (!triggers || !triggers.length) {
|
|
107432
107452
|
throw new error_1.CloudBaseError('触发器配置不能为空');
|
|
107433
107453
|
}
|
|
107434
|
-
yield (
|
|
107435
|
-
envId,
|
|
107436
|
-
functionName: name,
|
|
107437
|
-
triggers
|
|
107438
|
-
});
|
|
107454
|
+
yield functionService.createFunctionTriggers(name, triggers);
|
|
107439
107455
|
(0, logger_1.successLog)(`[${name}] 创建云函数触发器成功!`);
|
|
107440
107456
|
});
|
|
107441
107457
|
}
|
|
@@ -134606,6 +134622,7 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
|
|
|
134606
134622
|
const { envId, config: { functions } } = ctx;
|
|
134607
134623
|
const name = params === null || params === void 0 ? void 0 : params[0];
|
|
134608
134624
|
const triggerName = params === null || params === void 0 ? void 0 : params[1];
|
|
134625
|
+
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
134609
134626
|
let isBatchDeleteTriggers;
|
|
134610
134627
|
let isBatchDeleteFunctionTriggers = false;
|
|
134611
134628
|
if (!name) {
|
|
@@ -134629,7 +134646,7 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
|
|
|
134629
134646
|
}
|
|
134630
134647
|
}
|
|
134631
134648
|
if (isBatchDeleteTriggers) {
|
|
134632
|
-
return
|
|
134649
|
+
return functionService.batchDeleteTriggers({
|
|
134633
134650
|
envId,
|
|
134634
134651
|
functions
|
|
134635
134652
|
});
|
|
@@ -134648,7 +134665,7 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
|
|
|
134648
134665
|
}
|
|
134649
134666
|
if (isBatchDeleteFunctionTriggers) {
|
|
134650
134667
|
const func = functions.find((item) => item.name === name);
|
|
134651
|
-
return
|
|
134668
|
+
return functionService.batchDeleteTriggers({
|
|
134652
134669
|
envId,
|
|
134653
134670
|
functions: [func]
|
|
134654
134671
|
});
|
|
@@ -134656,11 +134673,7 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
|
|
|
134656
134673
|
if (!triggerName) {
|
|
134657
134674
|
throw new error_1.CloudBaseError('触发器名称不能为空');
|
|
134658
134675
|
}
|
|
134659
|
-
yield (
|
|
134660
|
-
envId,
|
|
134661
|
-
functionName: name,
|
|
134662
|
-
triggerName
|
|
134663
|
-
});
|
|
134676
|
+
yield functionService.deleteFunctionTrigger(name, triggerName);
|
|
134664
134677
|
});
|
|
134665
134678
|
}
|
|
134666
134679
|
};
|
|
@@ -175263,13 +175276,14 @@ let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
|
|
|
175263
175276
|
execute(envId, options) {
|
|
175264
175277
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175265
175278
|
const { dest } = options;
|
|
175279
|
+
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
175266
175280
|
const loading = (0, utils_1.loadingFactory)();
|
|
175267
175281
|
loading.start('数据加载中...');
|
|
175268
|
-
const
|
|
175282
|
+
const listLayersRes = yield functionService.listLayers({
|
|
175269
175283
|
offset: 0,
|
|
175270
175284
|
limit: 200,
|
|
175271
|
-
searchSrc: `TCB_${envId}`
|
|
175272
175285
|
});
|
|
175286
|
+
const layers = listLayersRes.Layers || [];
|
|
175273
175287
|
loading.stop();
|
|
175274
175288
|
if (!layers.length) {
|
|
175275
175289
|
throw new error_1.CloudBaseError('当前环境没有可用的文件层,请先创建文件层!');
|
|
@@ -175280,10 +175294,11 @@ let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
|
|
|
175280
175294
|
message: '选择文件层名称',
|
|
175281
175295
|
choices: layers.map((item) => item.LayerName)
|
|
175282
175296
|
});
|
|
175283
|
-
let
|
|
175297
|
+
let listLayerVersionsRes = yield functionService.listLayerVersions({
|
|
175284
175298
|
name: layer
|
|
175285
175299
|
});
|
|
175286
|
-
|
|
175300
|
+
const layerVersions = listLayerVersionsRes.LayerVersions || [];
|
|
175301
|
+
const versions = layerVersions.map((item) => String(item.LayerVersion));
|
|
175287
175302
|
const { version } = yield (0, enquirer_1.prompt)({
|
|
175288
175303
|
type: 'select',
|
|
175289
175304
|
name: 'version',
|
|
@@ -175294,9 +175309,12 @@ let DownloadFileLayer = class DownloadFileLayer extends common_1.Command {
|
|
|
175294
175309
|
if (!dest) {
|
|
175295
175310
|
destPath = path_1.default.resolve(process.cwd(), 'layers');
|
|
175296
175311
|
}
|
|
175312
|
+
else {
|
|
175313
|
+
destPath = path_1.default.resolve(dest);
|
|
175314
|
+
}
|
|
175297
175315
|
loading.start('文件下载中...');
|
|
175298
175316
|
yield fs_extra_1.default.ensureDir(destPath);
|
|
175299
|
-
yield
|
|
175317
|
+
yield functionService.downloadLayer({
|
|
175300
175318
|
destPath,
|
|
175301
175319
|
version: Number(version),
|
|
175302
175320
|
name: layer
|
|
@@ -217365,7 +217383,7 @@ let SortFileLayer = class SortFileLayer extends common_1.Command {
|
|
|
217365
217383
|
});
|
|
217366
217384
|
sortLayers = sortLayers.map((item) => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
|
|
217367
217385
|
loading.start('文件层排序中...');
|
|
217368
|
-
yield
|
|
217386
|
+
yield functionService.updateFunctionLayer({
|
|
217369
217387
|
envId,
|
|
217370
217388
|
functionName: fnName,
|
|
217371
217389
|
layers: sortLayers
|
|
@@ -229527,20 +229545,20 @@ let CreateFileLayer = class CreateFileLayer extends common_1.Command {
|
|
|
229527
229545
|
const alias = params === null || params === void 0 ? void 0 : params[0];
|
|
229528
229546
|
const { file } = options;
|
|
229529
229547
|
const layerName = `${alias}_${envId}`;
|
|
229530
|
-
const
|
|
229548
|
+
const listLayerRes = yield functionsService.listLayers({
|
|
229531
229549
|
offset: 0,
|
|
229532
229550
|
limit: 200
|
|
229533
229551
|
});
|
|
229552
|
+
const layers = listLayerRes.Layers || [];
|
|
229534
229553
|
if (layers.find(({ LayerName }) => LayerName === layerName)) {
|
|
229535
229554
|
throw new toolbox_1.CloudBaseError(`层名称 ${layerName} 已被您的当前环境或其他环境占用,请换用别的名称`);
|
|
229536
229555
|
}
|
|
229537
229556
|
const filePath = path_1.default.resolve(file);
|
|
229538
|
-
const runtimes = ['Nodejs12.16', 'Nodejs8.9', 'Php7', 'Java8'];
|
|
229557
|
+
const runtimes = ['Nodejs14.18', 'Nodejs12.16', 'Nodejs8.9', 'Php7', 'Java8'];
|
|
229539
229558
|
const loading = (0, utils_1.loadingFactory)();
|
|
229540
229559
|
loading.start('文件层创建中...');
|
|
229541
|
-
yield
|
|
229542
|
-
|
|
229543
|
-
layerName,
|
|
229560
|
+
yield functionsService.createLayer({
|
|
229561
|
+
name: layerName,
|
|
229544
229562
|
runtimes,
|
|
229545
229563
|
contentPath: filePath
|
|
229546
229564
|
});
|
|
@@ -385273,7 +385291,6 @@ const path_1 = __importDefault(__webpack_require__(16928));
|
|
|
385273
385291
|
const unzipper_1 = __importDefault(__webpack_require__(50283));
|
|
385274
385292
|
const constant_1 = __webpack_require__(40762);
|
|
385275
385293
|
const http_request_1 = __webpack_require__(72088);
|
|
385276
|
-
const log_symbols_1 = __importDefault(__webpack_require__(68329));
|
|
385277
385294
|
__exportStar(__webpack_require__(23506), exports);
|
|
385278
385295
|
__exportStar(__webpack_require__(81670), exports);
|
|
385279
385296
|
__exportStar(__webpack_require__(12430), exports);
|
|
@@ -385546,7 +385563,7 @@ const getCompleteTimeRange = (timeRange) => {
|
|
|
385546
385563
|
exports.getCompleteTimeRange = getCompleteTimeRange;
|
|
385547
385564
|
function successLog(msg) {
|
|
385548
385565
|
// 空格,兼容中文字符编码长度问题
|
|
385549
|
-
console.log(`${
|
|
385566
|
+
console.log(`${msg}`);
|
|
385550
385567
|
}
|
|
385551
385568
|
|
|
385552
385569
|
|
|
@@ -468138,6 +468155,12 @@ exports.CLOUDBASE_PROVIDERS = [
|
|
|
468138
468155
|
models: ['deepseek-v3'],
|
|
468139
468156
|
transformer: 'deepseek'
|
|
468140
468157
|
},
|
|
468158
|
+
{
|
|
468159
|
+
name: 'LongCat',
|
|
468160
|
+
value: 'longcat',
|
|
468161
|
+
models: ['LongCat-Flash-Chat'],
|
|
468162
|
+
transformer: undefined
|
|
468163
|
+
},
|
|
468141
468164
|
];
|
|
468142
468165
|
function getDefaultConfig(agent) {
|
|
468143
468166
|
const agentConfig = exports.AGENTS.find((a) => a.value === agent);
|
|
@@ -468163,7 +468186,8 @@ function getAgentConfigValidator(agent) {
|
|
|
468163
468186
|
exports.getAgentConfigValidator = getAgentConfigValidator;
|
|
468164
468187
|
exports.BASE_URL_MODEL_MAPPING = {
|
|
468165
468188
|
'https://api.moonshot.cn/v1': 'kimi-k2-0711-preview',
|
|
468166
|
-
'https://open.bigmodel.cn/api/paas/v4': 'glm-4.5'
|
|
468189
|
+
'https://open.bigmodel.cn/api/paas/v4': 'glm-4.5',
|
|
468190
|
+
'https://api.longcat.chat/openai': 'LongCat-Flash-Chat'
|
|
468167
468191
|
};
|
|
468168
468192
|
function getDefaultModelByBaseUrl(baseUrl) {
|
|
468169
468193
|
return exports.BASE_URL_MODEL_MAPPING[baseUrl] || 'gpt-4';
|
|
@@ -469999,7 +470023,8 @@ class TemplateManager {
|
|
|
469999
470023
|
if (!source || typeof source !== 'string') {
|
|
470000
470024
|
return false;
|
|
470001
470025
|
}
|
|
470002
|
-
return source.startsWith('http') || source.startsWith('git@') ||
|
|
470026
|
+
return source.startsWith('http') || source.startsWith('git@') ||
|
|
470027
|
+
source.includes('github.com') || source.includes('gitee.com') || source.includes('cnb.cool');
|
|
470003
470028
|
}
|
|
470004
470029
|
parseGitUrl(url) {
|
|
470005
470030
|
const githubMatch = url.match(/https?:\/\/github\.com\/([^\/]+)\/([^\/]+)(?:\/tree\/([^\/]+)\/(.+))?/);
|
|
@@ -470022,10 +470047,23 @@ class TemplateManager {
|
|
|
470022
470047
|
subpath: giteeMatch[4]
|
|
470023
470048
|
};
|
|
470024
470049
|
}
|
|
470050
|
+
const cnbMatch = url.match(/https?:\/\/cnb\.cool\/(.+?)(?:\/tree\/([^\/]+)\/(.+))?$/);
|
|
470051
|
+
if (cnbMatch) {
|
|
470052
|
+
const pathParts = cnbMatch[1].split('/').filter(p => p.length > 0);
|
|
470053
|
+
if (pathParts.length >= 2) {
|
|
470054
|
+
return {
|
|
470055
|
+
platform: 'cnb',
|
|
470056
|
+
owner: pathParts[0],
|
|
470057
|
+
repo: pathParts.slice(1).join('/'),
|
|
470058
|
+
branch: cnbMatch[2] || 'main',
|
|
470059
|
+
subpath: cnbMatch[3]
|
|
470060
|
+
};
|
|
470061
|
+
}
|
|
470062
|
+
}
|
|
470025
470063
|
const sshMatch = url.match(/git@([^:]+):([^\/]+)\/([^\/]+)\.git/);
|
|
470026
470064
|
if (sshMatch) {
|
|
470027
470065
|
return {
|
|
470028
|
-
platform: sshMatch[1] === 'github.com' ? 'github' : 'gitee',
|
|
470066
|
+
platform: sshMatch[1] === 'github.com' ? 'github' : (sshMatch[1] === 'cnb.cool' ? 'cnb' : 'gitee'),
|
|
470029
470067
|
owner: sshMatch[2],
|
|
470030
470068
|
repo: sshMatch[3],
|
|
470031
470069
|
branch: 'main'
|
|
@@ -470040,6 +470078,9 @@ class TemplateManager {
|
|
|
470040
470078
|
else if (gitInfo.platform === 'gitee') {
|
|
470041
470079
|
return `https://gitee.com/${gitInfo.owner}/${gitInfo.repo}.git`;
|
|
470042
470080
|
}
|
|
470081
|
+
else if (gitInfo.platform === 'cnb') {
|
|
470082
|
+
return `https://cnb.cool/${gitInfo.owner}/${gitInfo.repo}.git`;
|
|
470083
|
+
}
|
|
470043
470084
|
throw new error_1.CloudBaseError(`不支持的 Git 平台: ${gitInfo.platform}`);
|
|
470044
470085
|
}
|
|
470045
470086
|
cloneWithSubpath(gitUrl, tempDir, gitInfo, log) {
|
|
@@ -505038,9 +505079,9 @@ let AttachFileLayer = class AttachFileLayer extends common_1.Command {
|
|
|
505038
505079
|
return __awaiter(this, void 0, void 0, function* () {
|
|
505039
505080
|
const { codeSecret } = options;
|
|
505040
505081
|
const fnName = params === null || params === void 0 ? void 0 : params[0];
|
|
505082
|
+
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
505041
505083
|
const loading = (0, utils_1.loadingFactory)();
|
|
505042
505084
|
loading.start('数据加载中...');
|
|
505043
|
-
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
505044
505085
|
const envFunctions = yield functionService.listAllFunctions({
|
|
505045
505086
|
envId
|
|
505046
505087
|
});
|
|
@@ -505048,33 +505089,34 @@ let AttachFileLayer = class AttachFileLayer extends common_1.Command {
|
|
|
505048
505089
|
if (!exist) {
|
|
505049
505090
|
throw new error_1.CloudBaseError(`当前环境不存在此函数 [${fnName}]`);
|
|
505050
505091
|
}
|
|
505051
|
-
|
|
505092
|
+
const listLayersRes = yield functionService.listLayers({
|
|
505052
505093
|
offset: 0,
|
|
505053
505094
|
limit: 200,
|
|
505054
|
-
searchSrc: `TCB_${envId}`
|
|
505055
505095
|
});
|
|
505096
|
+
const layers = listLayersRes.Layers || [];
|
|
505056
505097
|
loading.stop();
|
|
505057
|
-
|
|
505098
|
+
const newLayers = layers.map((item) => ({
|
|
505058
505099
|
name: `[${LayerStatusMap[item.Status] || '异常'}] ${item.LayerName}`,
|
|
505059
505100
|
value: item.LayerName
|
|
505060
505101
|
}));
|
|
505061
|
-
if (!
|
|
505102
|
+
if (!newLayers.length) {
|
|
505062
505103
|
throw new error_1.CloudBaseError('没有可用的文件层,请先创建文件层!');
|
|
505063
505104
|
}
|
|
505064
505105
|
const { layer } = yield (0, enquirer_1.prompt)({
|
|
505065
505106
|
type: 'select',
|
|
505066
505107
|
name: 'layer',
|
|
505067
505108
|
message: '选择文件层名称',
|
|
505068
|
-
choices:
|
|
505109
|
+
choices: newLayers,
|
|
505069
505110
|
result(choices) {
|
|
505070
505111
|
const keys = Object.values(this.map(choices));
|
|
505071
505112
|
return keys[0];
|
|
505072
505113
|
}
|
|
505073
505114
|
});
|
|
505074
|
-
let
|
|
505115
|
+
let listLayerVersionsRes = yield functionService.listLayerVersions({
|
|
505075
505116
|
name: layer
|
|
505076
505117
|
});
|
|
505077
|
-
|
|
505118
|
+
let layerVersions = listLayerVersionsRes.LayerVersions || [];
|
|
505119
|
+
const versions = layerVersions.map((item) => String(item.LayerVersion));
|
|
505078
505120
|
if (!versions.length) {
|
|
505079
505121
|
throw new error_1.CloudBaseError('没有可用的文件层版本,请先创建文件层版本!');
|
|
505080
505122
|
}
|
|
@@ -505085,7 +505127,7 @@ let AttachFileLayer = class AttachFileLayer extends common_1.Command {
|
|
|
505085
505127
|
choices: versions
|
|
505086
505128
|
});
|
|
505087
505129
|
loading.start('文件层绑定中...');
|
|
505088
|
-
yield
|
|
505130
|
+
yield functionService.attachLayer({
|
|
505089
505131
|
envId,
|
|
505090
505132
|
functionName: fnName,
|
|
505091
505133
|
layerName: layer,
|
|
@@ -505149,7 +505191,7 @@ let UnAttachFileLayer = class UnAttachFileLayer extends common_1.Command {
|
|
|
505149
505191
|
}
|
|
505150
505192
|
});
|
|
505151
505193
|
loading.start('文件层解绑中...');
|
|
505152
|
-
yield
|
|
505194
|
+
yield functionService.unAttachLayer({
|
|
505153
505195
|
envId,
|
|
505154
505196
|
functionName: fnName,
|
|
505155
505197
|
layerName: layer.LayerName,
|
|
@@ -575404,26 +575446,21 @@ let ListFileLayer = class ListFileLayer extends common_1.Command {
|
|
|
575404
575446
|
const functionService = yield (0, function_1.getFunctionService)(envId);
|
|
575405
575447
|
if (layer && typeof layer === 'string') {
|
|
575406
575448
|
const layerName = `${layer}_${envId}`;
|
|
575407
|
-
|
|
575449
|
+
const listLayerVersionsRes = yield functionService.listLayerVersions({
|
|
575408
575450
|
name: layerName
|
|
575409
575451
|
});
|
|
575452
|
+
data = listLayerVersionsRes.LayerVersions || [];
|
|
575410
575453
|
}
|
|
575411
575454
|
else if (name && typeof name === 'string') {
|
|
575412
575455
|
const res = yield functionService.getFunctionDetail(name, codeSecret);
|
|
575413
575456
|
data = (res === null || res === void 0 ? void 0 : res.Layers) || [];
|
|
575414
575457
|
}
|
|
575415
|
-
else if (envId) {
|
|
575416
|
-
data = yield (0, function_1.listLayers)({
|
|
575417
|
-
offset: 0,
|
|
575418
|
-
limit: 200,
|
|
575419
|
-
searchSrc: `TCB_${envId}`
|
|
575420
|
-
});
|
|
575421
|
-
}
|
|
575422
575458
|
else {
|
|
575423
|
-
|
|
575459
|
+
const listLayersRes = yield functionService.listLayers({
|
|
575424
575460
|
offset: 0,
|
|
575425
575461
|
limit: 200
|
|
575426
575462
|
});
|
|
575463
|
+
data = listLayersRes.Layers || [];
|
|
575427
575464
|
}
|
|
575428
575465
|
loading.stop();
|
|
575429
575466
|
const head = ['优先级', '名称', '状态', '版本', '证书', '支持运行时', '创建时间'];
|
|
@@ -613951,6 +613988,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
613951
613988
|
exports.FunctionService = void 0;
|
|
613952
613989
|
const fs_1 = __importDefault(__webpack_require__(79896));
|
|
613953
613990
|
const path_1 = __importDefault(__webpack_require__(16928));
|
|
613991
|
+
const lodash_1 = __importDefault(__webpack_require__(24924));
|
|
613954
613992
|
const packer_1 = __webpack_require__(5147);
|
|
613955
613993
|
const error_1 = __webpack_require__(40430);
|
|
613956
613994
|
const utils_1 = __webpack_require__(62358);
|
|
@@ -614672,12 +614710,34 @@ class FunctionService {
|
|
|
614672
614710
|
TriggerDesc: item.config
|
|
614673
614711
|
};
|
|
614674
614712
|
});
|
|
614675
|
-
|
|
614676
|
-
|
|
614677
|
-
|
|
614678
|
-
|
|
614679
|
-
|
|
614680
|
-
|
|
614713
|
+
try {
|
|
614714
|
+
return await this.scfService.request('BatchCreateTrigger', {
|
|
614715
|
+
FunctionName: name,
|
|
614716
|
+
Namespace: namespace,
|
|
614717
|
+
Triggers: JSON.stringify(parsedTriggers),
|
|
614718
|
+
Count: parsedTriggers.length
|
|
614719
|
+
});
|
|
614720
|
+
}
|
|
614721
|
+
catch (e) {
|
|
614722
|
+
throw new error_1.CloudBaseError(`[${name}] 创建触发器失败:${e.message}`, {
|
|
614723
|
+
action: e.action,
|
|
614724
|
+
code: e.code
|
|
614725
|
+
});
|
|
614726
|
+
}
|
|
614727
|
+
}
|
|
614728
|
+
// 批量部署函数触发器
|
|
614729
|
+
async batchCreateTriggers(options) {
|
|
614730
|
+
const { functions, envId } = options;
|
|
614731
|
+
const promises = functions.map(func => (async () => {
|
|
614732
|
+
try {
|
|
614733
|
+
await this.createFunctionTriggers(func.name, func.triggers);
|
|
614734
|
+
(0, utils_1.successLog)(`[${func.name}] 创建云函数触发器成功!`);
|
|
614735
|
+
}
|
|
614736
|
+
catch (e) {
|
|
614737
|
+
throw new error_1.CloudBaseError(e.message);
|
|
614738
|
+
}
|
|
614739
|
+
})());
|
|
614740
|
+
await Promise.all(promises);
|
|
614681
614741
|
}
|
|
614682
614742
|
/**
|
|
614683
614743
|
* 删除云函数触发器
|
|
@@ -614687,12 +614747,32 @@ class FunctionService {
|
|
|
614687
614747
|
*/
|
|
614688
614748
|
async deleteFunctionTrigger(name, triggerName) {
|
|
614689
614749
|
const { namespace } = this.getFunctionConfig();
|
|
614690
|
-
|
|
614691
|
-
|
|
614692
|
-
|
|
614693
|
-
|
|
614694
|
-
|
|
614695
|
-
|
|
614750
|
+
try {
|
|
614751
|
+
await this.scfService.request('DeleteTrigger', {
|
|
614752
|
+
FunctionName: name,
|
|
614753
|
+
Namespace: namespace,
|
|
614754
|
+
TriggerName: triggerName,
|
|
614755
|
+
Type: 'timer'
|
|
614756
|
+
});
|
|
614757
|
+
(0, utils_1.successLog)(`[${name}] 删除云函数触发器 ${triggerName} 成功!`);
|
|
614758
|
+
}
|
|
614759
|
+
catch (e) {
|
|
614760
|
+
throw new error_1.CloudBaseError(`[${name}] 删除触发器失败:${e.message}`);
|
|
614761
|
+
}
|
|
614762
|
+
}
|
|
614763
|
+
async batchDeleteTriggers(options) {
|
|
614764
|
+
const { functions, envId } = options;
|
|
614765
|
+
const promises = functions.map(func => (async () => {
|
|
614766
|
+
try {
|
|
614767
|
+
func.triggers.forEach(async (trigger) => {
|
|
614768
|
+
await this.deleteFunctionTrigger(func.name, trigger.name);
|
|
614769
|
+
});
|
|
614770
|
+
}
|
|
614771
|
+
catch (e) {
|
|
614772
|
+
throw new error_1.CloudBaseError(e.message);
|
|
614773
|
+
}
|
|
614774
|
+
})());
|
|
614775
|
+
await Promise.all(promises);
|
|
614696
614776
|
}
|
|
614697
614777
|
/**
|
|
614698
614778
|
* 下载云函数代码
|
|
@@ -614736,6 +614816,68 @@ class FunctionService {
|
|
|
614736
614816
|
throw new error_1.CloudBaseError(`[${functionName}] 获取函数代码下载链接失败:\n${e.message}`);
|
|
614737
614817
|
}
|
|
614738
614818
|
}
|
|
614819
|
+
// 函数绑定文件层
|
|
614820
|
+
async attachLayer(options) {
|
|
614821
|
+
const { envId, functionName, layerName, layerVersion, codeSecret } = options;
|
|
614822
|
+
let { Layers = [] } = await this.getFunctionDetail(functionName, codeSecret);
|
|
614823
|
+
Layers = Layers.map(item => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
|
|
614824
|
+
// 新加的文件层添加到最后
|
|
614825
|
+
Layers.push({
|
|
614826
|
+
LayerName: layerName,
|
|
614827
|
+
LayerVersion: layerVersion
|
|
614828
|
+
});
|
|
614829
|
+
const res = await this.scfService.request('UpdateFunctionConfiguration', {
|
|
614830
|
+
Layers,
|
|
614831
|
+
Namespace: envId,
|
|
614832
|
+
FunctionName: functionName
|
|
614833
|
+
});
|
|
614834
|
+
return res;
|
|
614835
|
+
}
|
|
614836
|
+
// 函数解绑文件层
|
|
614837
|
+
async unAttachLayer(options) {
|
|
614838
|
+
const { envId, functionName, layerName, layerVersion, codeSecret } = options;
|
|
614839
|
+
let { Layers } = await this.getFunctionDetail(functionName, codeSecret);
|
|
614840
|
+
Layers = Layers.map(item => lodash_1.default.pick(item, ['LayerName', 'LayerVersion']));
|
|
614841
|
+
const index = Layers.findIndex(item => item.LayerName === layerName && item.LayerVersion === layerVersion);
|
|
614842
|
+
if (index === -1) {
|
|
614843
|
+
throw new error_1.CloudBaseError('层不存在');
|
|
614844
|
+
}
|
|
614845
|
+
// 删除指定的层
|
|
614846
|
+
Layers.splice(index, 1);
|
|
614847
|
+
const apiParams = {
|
|
614848
|
+
Namespace: envId,
|
|
614849
|
+
FunctionName: functionName,
|
|
614850
|
+
Layers: Layers.length > 0 ? Layers : [{
|
|
614851
|
+
LayerName: '',
|
|
614852
|
+
LayerVersion: 0
|
|
614853
|
+
}]
|
|
614854
|
+
};
|
|
614855
|
+
return this.scfService.request('UpdateFunctionConfiguration', apiParams);
|
|
614856
|
+
}
|
|
614857
|
+
// 更新云函数层
|
|
614858
|
+
async updateFunctionLayer(options) {
|
|
614859
|
+
const { envId, functionName, layers } = options;
|
|
614860
|
+
return this.scfService.request('UpdateFunctionConfiguration', {
|
|
614861
|
+
Layers: layers,
|
|
614862
|
+
Namespace: envId,
|
|
614863
|
+
FunctionName: functionName
|
|
614864
|
+
});
|
|
614865
|
+
}
|
|
614866
|
+
// 下载文件层 ZIP 文件
|
|
614867
|
+
async downloadLayer(options) {
|
|
614868
|
+
const { name, version, destPath } = options;
|
|
614869
|
+
const res = await this.scfService.request('GetLayerVersion', {
|
|
614870
|
+
LayerName: name,
|
|
614871
|
+
LayerVersion: version
|
|
614872
|
+
});
|
|
614873
|
+
const url = res === null || res === void 0 ? void 0 : res.Location;
|
|
614874
|
+
const zipPath = path_1.default.join(destPath, `${name}-${version}.zip`);
|
|
614875
|
+
if ((0, utils_1.checkFullAccess)(zipPath)) {
|
|
614876
|
+
throw new error_1.CloudBaseError(`文件已存在:${zipPath}`);
|
|
614877
|
+
}
|
|
614878
|
+
// 下载文件
|
|
614879
|
+
return (0, utils_1.downloadAndExtractRemoteZip)(url, destPath);
|
|
614880
|
+
}
|
|
614739
614881
|
// 创建文件层版本
|
|
614740
614882
|
async createLayer(options) {
|
|
614741
614883
|
const { env } = this.getFunctionConfig();
|
|
@@ -614808,7 +614950,7 @@ class FunctionService {
|
|
|
614808
614950
|
Limit: limit,
|
|
614809
614951
|
Offset: offset,
|
|
614810
614952
|
SearchKey: searchKey,
|
|
614811
|
-
SearchSrc: `TCB_${env}`
|
|
614953
|
+
// SearchSrc: `TCB_${env}`
|
|
614812
614954
|
};
|
|
614813
614955
|
if (runtime) {
|
|
614814
614956
|
param.CompatibleRuntime = runtime;
|
|
@@ -615185,6 +615327,18 @@ __decorate([
|
|
|
615185
615327
|
__decorate([
|
|
615186
615328
|
(0, utils_1.preLazy)()
|
|
615187
615329
|
], FunctionService.prototype, "getFunctionDownloadUrl", null);
|
|
615330
|
+
__decorate([
|
|
615331
|
+
(0, utils_1.preLazy)()
|
|
615332
|
+
], FunctionService.prototype, "attachLayer", null);
|
|
615333
|
+
__decorate([
|
|
615334
|
+
(0, utils_1.preLazy)()
|
|
615335
|
+
], FunctionService.prototype, "unAttachLayer", null);
|
|
615336
|
+
__decorate([
|
|
615337
|
+
(0, utils_1.preLazy)()
|
|
615338
|
+
], FunctionService.prototype, "updateFunctionLayer", null);
|
|
615339
|
+
__decorate([
|
|
615340
|
+
(0, utils_1.preLazy)()
|
|
615341
|
+
], FunctionService.prototype, "downloadLayer", null);
|
|
615188
615342
|
__decorate([
|
|
615189
615343
|
(0, utils_1.preLazy)()
|
|
615190
615344
|
], FunctionService.prototype, "createLayer", null);
|
|
@@ -124,6 +124,19 @@ class TemplateManager {
|
|
|
124
124
|
subpath: giteeMatch[4]
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
+
const cnbMatchWithDash = url.match(/https?:\/\/cnb\.cool\/(.+?)\/-\/tree\/([^\/]+)\/(.+)$/);
|
|
128
|
+
if (cnbMatchWithDash) {
|
|
129
|
+
const pathParts = cnbMatchWithDash[1].split('/').filter(p => p.length > 0);
|
|
130
|
+
if (pathParts.length >= 2) {
|
|
131
|
+
return {
|
|
132
|
+
platform: 'cnb',
|
|
133
|
+
owner: pathParts[0],
|
|
134
|
+
repo: pathParts.slice(1).join('/'),
|
|
135
|
+
branch: cnbMatchWithDash[2] || 'main',
|
|
136
|
+
subpath: cnbMatchWithDash[3]
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
127
140
|
const cnbMatch = url.match(/https?:\/\/cnb\.cool\/(.+?)(?:\/tree\/([^\/]+)\/(.+))?$/);
|
|
128
141
|
if (cnbMatch) {
|
|
129
142
|
const pathParts = cnbMatch[1].split('/').filter(p => p.length > 0);
|
|
@@ -160,6 +173,38 @@ class TemplateManager {
|
|
|
160
173
|
}
|
|
161
174
|
throw new error_1.CloudBaseError(`不支持的 Git 平台: ${gitInfo.platform}`);
|
|
162
175
|
}
|
|
176
|
+
cloneWithSubpathOptimized(gitUrl, tempDir, gitInfo, log) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
try {
|
|
179
|
+
yield this.git.clone(gitUrl, tempDir, [
|
|
180
|
+
'--depth', '1',
|
|
181
|
+
'--single-branch',
|
|
182
|
+
'--branch', gitInfo.branch,
|
|
183
|
+
'--filter=blob:none'
|
|
184
|
+
]);
|
|
185
|
+
const subpathFull = path_1.default.join(tempDir, gitInfo.subpath);
|
|
186
|
+
if (!(yield fs_extra_1.default.pathExists(subpathFull))) {
|
|
187
|
+
throw new error_1.CloudBaseError(`子目录不存在: ${gitInfo.subpath}`);
|
|
188
|
+
}
|
|
189
|
+
const tempContentDir = path_1.default.join(tempDir, '.temp-content-' + Date.now());
|
|
190
|
+
yield fs_extra_1.default.move(subpathFull, tempContentDir);
|
|
191
|
+
const tempFiles = yield fs_extra_1.default.readdir(tempDir);
|
|
192
|
+
for (const file of tempFiles) {
|
|
193
|
+
if (file !== path_1.default.basename(tempContentDir)) {
|
|
194
|
+
yield fs_extra_1.default.remove(path_1.default.join(tempDir, file));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const contentFiles = yield fs_extra_1.default.readdir(tempContentDir);
|
|
198
|
+
for (const file of contentFiles) {
|
|
199
|
+
yield fs_extra_1.default.move(path_1.default.join(tempContentDir, file), path_1.default.join(tempDir, file));
|
|
200
|
+
}
|
|
201
|
+
yield fs_extra_1.default.remove(tempContentDir);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
throw new error_1.CloudBaseError(`克隆子目录失败: ${error.message}`, { original: error });
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
163
208
|
cloneWithSubpath(gitUrl, tempDir, gitInfo, log) {
|
|
164
209
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
210
|
try {
|
|
@@ -212,10 +257,10 @@ class TemplateManager {
|
|
|
212
257
|
log.info(`📦 正在从 ${gitInfo.platform} 下载模板到临时目录...`);
|
|
213
258
|
try {
|
|
214
259
|
if (gitInfo.subpath) {
|
|
215
|
-
yield this.
|
|
260
|
+
yield this.cloneWithSubpathOptimized(gitUrl, tempDir, gitInfo, log);
|
|
216
261
|
}
|
|
217
262
|
else {
|
|
218
|
-
yield this.git.clone(gitUrl, tempDir);
|
|
263
|
+
yield this.git.clone(gitUrl, tempDir, ['--depth', '1', '--single-branch', '--branch', gitInfo.branch]);
|
|
219
264
|
}
|
|
220
265
|
log.info(`✅ Git 模板下载完成到临时目录`);
|
|
221
266
|
}
|
|
@@ -271,10 +316,14 @@ class TemplateManager {
|
|
|
271
316
|
if (stat.isDirectory()) {
|
|
272
317
|
yield fs_extra_1.default.ensureDir(destPath);
|
|
273
318
|
const entries = yield fs_extra_1.default.readdir(srcPath, { withFileTypes: true });
|
|
274
|
-
|
|
319
|
+
const copyPromises = entries.map(entry => {
|
|
275
320
|
const entrySrcPath = path_1.default.join(srcPath, entry.name);
|
|
276
321
|
const entryDestPath = path_1.default.join(destPath, entry.name);
|
|
277
|
-
|
|
322
|
+
return copyFile(entrySrcPath, entryDestPath);
|
|
323
|
+
});
|
|
324
|
+
const chunks = this.chunkArray(copyPromises, 10);
|
|
325
|
+
for (const chunk of chunks) {
|
|
326
|
+
yield Promise.all(chunk);
|
|
278
327
|
}
|
|
279
328
|
}
|
|
280
329
|
else {
|
|
@@ -295,10 +344,14 @@ class TemplateManager {
|
|
|
295
344
|
}
|
|
296
345
|
});
|
|
297
346
|
const entries = yield fs_extra_1.default.readdir(sourceDir, { withFileTypes: true });
|
|
298
|
-
|
|
347
|
+
const copyPromises = entries.map(entry => {
|
|
299
348
|
const srcPath = path_1.default.join(sourceDir, entry.name);
|
|
300
349
|
const destPath = path_1.default.join(targetDir, entry.name);
|
|
301
|
-
|
|
350
|
+
return copyFile(srcPath, destPath);
|
|
351
|
+
});
|
|
352
|
+
const chunks = this.chunkArray(copyPromises, 5);
|
|
353
|
+
for (const chunk of chunks) {
|
|
354
|
+
yield Promise.all(chunk);
|
|
302
355
|
}
|
|
303
356
|
log.info(`📊 复制统计: ${copiedCount} 个新文件复制, ${overwrittenCount} 个文件覆盖`);
|
|
304
357
|
});
|
|
@@ -313,10 +366,14 @@ class TemplateManager {
|
|
|
313
366
|
if (stat.isDirectory()) {
|
|
314
367
|
yield fs_extra_1.default.ensureDir(destPath);
|
|
315
368
|
const entries = yield fs_extra_1.default.readdir(srcPath, { withFileTypes: true });
|
|
316
|
-
|
|
369
|
+
const copyPromises = entries.map(entry => {
|
|
317
370
|
const entrySrcPath = path_1.default.join(srcPath, entry.name);
|
|
318
371
|
const entryDestPath = path_1.default.join(destPath, entry.name);
|
|
319
|
-
|
|
372
|
+
return copyFile(entrySrcPath, entryDestPath);
|
|
373
|
+
});
|
|
374
|
+
const chunks = this.chunkArray(copyPromises, 10);
|
|
375
|
+
for (const chunk of chunks) {
|
|
376
|
+
yield Promise.all(chunk);
|
|
320
377
|
}
|
|
321
378
|
}
|
|
322
379
|
else {
|
|
@@ -337,14 +394,25 @@ class TemplateManager {
|
|
|
337
394
|
}
|
|
338
395
|
});
|
|
339
396
|
const entries = yield fs_extra_1.default.readdir(sourceDir, { withFileTypes: true });
|
|
340
|
-
|
|
397
|
+
const copyPromises = entries.map(entry => {
|
|
341
398
|
const srcPath = path_1.default.join(sourceDir, entry.name);
|
|
342
399
|
const destPath = path_1.default.join(targetDir, entry.name);
|
|
343
|
-
|
|
400
|
+
return copyFile(srcPath, destPath);
|
|
401
|
+
});
|
|
402
|
+
const chunks = this.chunkArray(copyPromises, 5);
|
|
403
|
+
for (const chunk of chunks) {
|
|
404
|
+
yield Promise.all(chunk);
|
|
344
405
|
}
|
|
345
406
|
log.info(`📊 复制统计: ${copiedCount} 个文件复制完成, ${skippedCount} 个文件跳过`);
|
|
346
407
|
});
|
|
347
408
|
}
|
|
409
|
+
chunkArray(array, chunkSize) {
|
|
410
|
+
const chunks = [];
|
|
411
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
412
|
+
chunks.push(array.slice(i, i + chunkSize));
|
|
413
|
+
}
|
|
414
|
+
return chunks;
|
|
415
|
+
}
|
|
348
416
|
getBuiltinTemplates() {
|
|
349
417
|
const templates = {};
|
|
350
418
|
for (const [key, template] of Object.entries(BUILTIN_TEMPLATES)) {
|
package/package.json
CHANGED
|
@@ -12,12 +12,14 @@ export declare class TemplateManager {
|
|
|
12
12
|
private isGitUrl;
|
|
13
13
|
private parseGitUrl;
|
|
14
14
|
private buildGitUrl;
|
|
15
|
+
private cloneWithSubpathOptimized;
|
|
15
16
|
private cloneWithSubpath;
|
|
16
17
|
private downloadBuiltinTemplateToTemp;
|
|
17
18
|
private downloadGitTemplateToTemp;
|
|
18
19
|
private copyFromTempToTarget;
|
|
19
20
|
private copyFilesWithOverwrite;
|
|
20
21
|
private copyFilesSkipExisting;
|
|
22
|
+
private chunkArray;
|
|
21
23
|
getBuiltinTemplates(): Record<string, string>;
|
|
22
24
|
}
|
|
23
25
|
export {};
|