@cloudbase/cli 2.10.0-beta.0 → 2.11.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth/login.js +51 -65
- package/lib/auth/logout.js +3 -14
- package/lib/commands/account/login.js +136 -149
- package/lib/commands/account/logout.js +3 -14
- package/lib/commands/ag/base.js +203 -0
- package/lib/commands/ag/create.js +301 -0
- package/lib/commands/ag/debug/index.html +699 -0
- package/lib/commands/ag/delete.js +200 -0
- package/lib/commands/ag/deploy.js +185 -0
- package/lib/commands/ag/detail.js +113 -0
- package/lib/commands/ag/index.js +22 -0
- package/lib/commands/ag/list.js +155 -0
- package/lib/commands/ag/run.js +644 -0
- package/lib/commands/ai/index.js +76 -95
- package/lib/commands/cloudfunction/base.js +182 -203
- package/lib/commands/cloudrun/base.js +578 -603
- package/lib/commands/common.js +48 -63
- package/lib/commands/config/delete.js +16 -27
- package/lib/commands/config/get.js +13 -24
- package/lib/commands/config/list.js +16 -27
- package/lib/commands/config/set.js +33 -44
- package/lib/commands/db/base.js +221 -240
- package/lib/commands/env/base.js +36 -49
- package/lib/commands/env/domain.js +79 -94
- package/lib/commands/env/login.js +120 -135
- package/lib/commands/framework/index.js +32 -49
- package/lib/commands/fun/base.js +223 -244
- package/lib/commands/functions/alias/getRoute.js +33 -44
- package/lib/commands/functions/alias/setRoute.js +36 -47
- package/lib/commands/functions/code-download.js +43 -54
- package/lib/commands/functions/code-update.js +23 -34
- package/lib/commands/functions/concurrency/delete.js +11 -22
- package/lib/commands/functions/concurrency/list.js +20 -31
- package/lib/commands/functions/concurrency/set.js +13 -24
- package/lib/commands/functions/config-update.js +30 -41
- package/lib/commands/functions/copy.js +12 -23
- package/lib/commands/functions/delete.js +30 -41
- package/lib/commands/functions/deploy.js +184 -202
- package/lib/commands/functions/detail.js +23 -34
- package/lib/commands/functions/invoke.js +69 -75
- package/lib/commands/functions/layer/bind.js +102 -105
- package/lib/commands/functions/layer/create.js +29 -35
- package/lib/commands/functions/layer/delete.js +42 -48
- package/lib/commands/functions/layer/download.js +52 -58
- package/lib/commands/functions/layer/list.js +44 -50
- package/lib/commands/functions/layer/sort.js +39 -45
- package/lib/commands/functions/list.js +25 -36
- package/lib/commands/functions/log.js +65 -73
- package/lib/commands/functions/run.js +118 -116
- package/lib/commands/functions/trigger-create.js +32 -43
- package/lib/commands/functions/trigger-delete.js +50 -61
- package/lib/commands/functions/version/list.js +29 -40
- package/lib/commands/functions/version/publish.js +11 -22
- package/lib/commands/gateway/create.js +50 -61
- package/lib/commands/gateway/delete.js +38 -49
- package/lib/commands/gateway/domain.js +65 -80
- package/lib/commands/gateway/list.js +31 -42
- package/lib/commands/gateway/switch.js +48 -61
- package/lib/commands/helpers/init.js +226 -249
- package/lib/commands/helpers/new.js +35 -46
- package/lib/commands/helpers/open.js +22 -33
- package/lib/commands/hosting/hosting.js +157 -178
- package/lib/commands/index.js +1 -0
- package/lib/commands/lowcode/app.js +114 -144
- package/lib/commands/lowcode/comps.js +136 -127
- package/lib/commands/lowcode/utils.js +11 -22
- package/lib/commands/pull/pull.js +33 -46
- package/lib/commands/run/delete.js +35 -46
- package/lib/commands/run/image/delete.js +32 -39
- package/lib/commands/run/image/download.js +26 -33
- package/lib/commands/run/image/list.js +41 -48
- package/lib/commands/run/image/upload.js +26 -33
- package/lib/commands/run/list.js +32 -43
- package/lib/commands/run/service/config.js +17 -28
- package/lib/commands/run/service/deploy.js +15 -26
- package/lib/commands/run/service/list.js +48 -59
- package/lib/commands/run/service/update.js +7 -18
- package/lib/commands/run/standalonegateway/create.js +35 -42
- package/lib/commands/run/standalonegateway/destroy.js +23 -30
- package/lib/commands/run/standalonegateway/list.js +19 -26
- package/lib/commands/run/standalonegateway/package.js +31 -38
- package/lib/commands/run/standalonegateway/turn.js +27 -34
- package/lib/commands/run/version/create.js +198 -205
- package/lib/commands/run/version/delete.js +31 -38
- package/lib/commands/run/version/list.js +42 -49
- package/lib/commands/run/version/modify.js +27 -34
- package/lib/commands/run/version/update.js +201 -208
- package/lib/commands/runf/base.js +216 -237
- package/lib/commands/self-update.js +59 -72
- package/lib/commands/smart.js +66 -79
- package/lib/commands/storage/storage.js +192 -219
- package/lib/commands/third/thirdAttach.js +16 -27
- package/lib/commands/utils.js +119 -149
- package/lib/db/index.js +48 -67
- package/lib/decorators/captureError.js +10 -21
- package/lib/decorators/guard.js +11 -22
- package/lib/decorators/injectParams.js +29 -40
- package/lib/decorators/params/common.js +5 -2
- package/lib/decorators/params/index.js +3 -12
- package/lib/env/domain.js +13 -28
- package/lib/env/index.js +25 -44
- package/lib/env/login.js +30 -45
- package/lib/function/alias.js +31 -44
- package/lib/function/base.js +187 -215
- package/lib/function/code.js +8 -19
- package/lib/function/concurrency.js +43 -58
- package/lib/function/create.js +43 -53
- package/lib/function/delete.js +22 -35
- package/lib/function/layer/attach.js +33 -46
- package/lib/function/layer/create.js +34 -45
- package/lib/function/layer/delete.js +5 -16
- package/lib/function/layer/download.js +11 -22
- package/lib/function/layer/list.js +12 -25
- package/lib/function/layer/sort.js +6 -17
- package/lib/function/trigger.js +65 -82
- package/lib/function/update.js +24 -32
- package/lib/function/version.js +29 -42
- package/lib/function/vpc.js +12 -25
- package/lib/gateway/index.js +77 -104
- package/lib/hosting.js +157 -188
- package/lib/run/delete.js +3 -12
- package/lib/run/image/build.js +6 -15
- package/lib/run/image/delete.js +3 -12
- package/lib/run/image/info.js +3 -12
- package/lib/run/image/list.js +6 -15
- package/lib/run/list.js +19 -30
- package/lib/run/repo.js +6 -15
- package/lib/run/service/common.js +160 -173
- package/lib/run/service/config.js +44 -57
- package/lib/run/service/deployPackage.js +33 -44
- package/lib/run/service/list.js +8 -14
- package/lib/run/service/showLogs.js +69 -90
- package/lib/run/service/update.js +50 -63
- package/lib/run/standalonegateway/create.js +3 -12
- package/lib/run/standalonegateway/destroy.js +3 -12
- package/lib/run/standalonegateway/list.js +3 -12
- package/lib/run/standalonegateway/package/list.js +3 -12
- package/lib/run/standalonegateway/turn/off.js +3 -12
- package/lib/run/standalonegateway/turn/on.js +3 -12
- package/lib/run/version/create.js +41 -31
- package/lib/run/version/delete.js +3 -12
- package/lib/run/version/list.js +3 -12
- package/lib/run/version/modify.js +3 -12
- package/lib/run/version/repo.js +6 -15
- package/lib/run/version/update.js +37 -26
- package/lib/storage.js +62 -93
- package/lib/third/index.js +6 -17
- package/lib/utils/ai/banner.js +49 -60
- package/lib/utils/ai/claudeWindows.js +2 -2
- package/lib/utils/ai/config.js +169 -206
- package/lib/utils/ai/ensureFiles.js +6 -17
- package/lib/utils/ai/env.js +16 -27
- package/lib/utils/ai/envLocalManager.js +35 -52
- package/lib/utils/ai/router.js +927 -1005
- package/lib/utils/ai/setup.js +527 -563
- package/lib/utils/auth.js +3 -14
- package/lib/utils/checkTcbrEnv.js +20 -31
- package/lib/utils/cli-table.js +6 -1
- package/lib/utils/config.js +4 -13
- package/lib/utils/dts.js +98 -113
- package/lib/utils/env.js +154 -175
- package/lib/utils/function-packer.js +29 -42
- package/lib/utils/log.js +10 -21
- package/lib/utils/mcp-config-modifier.js +105 -120
- package/lib/utils/net/cloud-api-request.js +15 -23
- package/lib/utils/net/credential.js +26 -39
- package/lib/utils/net/http-request.js +63 -80
- package/lib/utils/net/manager-service.js +22 -35
- package/lib/utils/notice.js +16 -27
- package/lib/utils/output/loading.js +3 -12
- package/lib/utils/parallel.js +32 -43
- package/lib/utils/platform/mac.js +4 -15
- package/lib/utils/platform/port.js +4 -15
- package/lib/utils/prompt/select.js +6 -15
- package/lib/utils/report.js +28 -33
- package/lib/utils/reporter/agree.js +11 -22
- package/lib/utils/reporter/download.js +17 -28
- package/lib/utils/reporter/usage.js +12 -23
- package/lib/utils/store/auth.js +17 -30
- package/lib/utils/store/config.js +11 -25
- package/lib/utils/store/db.js +17 -36
- package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
- package/lib/utils/template-manager.js +215 -242
- package/lib/utils/template.js +81 -96
- package/lib/utils/tools/common.js +45 -56
- package/lib/utils/tools/time.js +5 -16
- package/lib/utils/url.js +10 -4
- package/package.json +2 -2
- package/specs/ag-command/design.md +421 -0
- package/specs/ag-command/doc.md +204 -0
- package/specs/ag-command/requirements.md +173 -0
- package/specs/ag-command/summary.md +174 -0
- package/specs/ag-command/tasks.md +197 -0
- package/specs/ag-command/usage-guide.md +420 -0
- package/tsconfig.json +1 -1
- package/types/commands/ag/base.d.ts +44 -0
- package/types/commands/ag/create.d.ts +25 -0
- package/types/commands/ag/delete.d.ts +32 -0
- package/types/commands/ag/deploy.d.ts +31 -0
- package/types/commands/ag/detail.d.ts +28 -0
- package/types/commands/ag/index.d.ts +6 -0
- package/types/commands/ag/list.d.ts +35 -0
- package/types/commands/ag/run.d.ts +52 -0
- package/types/commands/cloudrun/base.d.ts +10 -0
- package/types/commands/index.d.ts +1 -0
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
27
|
};
|
|
@@ -69,33 +60,31 @@ class TemplateManager {
|
|
|
69
60
|
this.git = (0, simple_git_1.simpleGit)();
|
|
70
61
|
this.mcpConfigModifier = new mcp_config_modifier_1.MCPConfigModifier();
|
|
71
62
|
}
|
|
72
|
-
pullTemplate(source, options = {}, log) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
yield this.downloadBuiltinTemplateToTemp(source, tempDir, log);
|
|
81
|
-
}
|
|
82
|
-
else if (this.isZipUrl(source)) {
|
|
83
|
-
yield this.downloadZipTemplateToTemp(source, tempDir, log);
|
|
84
|
-
}
|
|
85
|
-
else if (this.isGitUrl(source)) {
|
|
86
|
-
const gitInfo = this.parseGitUrl(source);
|
|
87
|
-
yield this.downloadGitTemplateToTemp(gitInfo, tempDir, log);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('不支持的模板来源: {{source}}', { source: typeof source === 'string' ? source : JSON.stringify(source) }));
|
|
91
|
-
}
|
|
92
|
-
yield this.copyFromTempToTarget(tempDir, targetPath, force, log);
|
|
93
|
-
log.info((0, i18n_1.t)('✅ 模板拉取完成: {{targetPath}}', { targetPath }));
|
|
63
|
+
async pullTemplate(source, options = {}, log) {
|
|
64
|
+
const targetPath = options.output || process.cwd();
|
|
65
|
+
const { force = false } = options;
|
|
66
|
+
await fs_extra_1.default.ensureDir(targetPath);
|
|
67
|
+
const tempDir = path_1.default.join(process.cwd(), '.temp-template-' + Date.now());
|
|
68
|
+
try {
|
|
69
|
+
if (this.isBuiltinTemplate(source)) {
|
|
70
|
+
await this.downloadBuiltinTemplateToTemp(source, tempDir, log);
|
|
94
71
|
}
|
|
95
|
-
|
|
96
|
-
|
|
72
|
+
else if (this.isZipUrl(source)) {
|
|
73
|
+
await this.downloadZipTemplateToTemp(source, tempDir, log);
|
|
97
74
|
}
|
|
98
|
-
|
|
75
|
+
else if (this.isGitUrl(source)) {
|
|
76
|
+
const gitInfo = this.parseGitUrl(source);
|
|
77
|
+
await this.downloadGitTemplateToTemp(gitInfo, tempDir, log);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('不支持的模板来源: {{source}}', { source: typeof source === 'string' ? source : JSON.stringify(source) }));
|
|
81
|
+
}
|
|
82
|
+
await this.copyFromTempToTarget(tempDir, targetPath, force, log);
|
|
83
|
+
log.info((0, i18n_1.t)('✅ 模板拉取完成: {{targetPath}}', { targetPath }));
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
await fs_extra_1.default.remove(tempDir);
|
|
87
|
+
}
|
|
99
88
|
}
|
|
100
89
|
isBuiltinTemplate(source) {
|
|
101
90
|
return Object.keys(BUILTIN_TEMPLATES).includes(source);
|
|
@@ -194,251 +183,235 @@ class TemplateManager {
|
|
|
194
183
|
}
|
|
195
184
|
throw new error_1.CloudBaseError((0, i18n_1.t)('不支持的 Git 平台: {{platform}}', { platform: gitInfo.platform }));
|
|
196
185
|
}
|
|
197
|
-
cloneWithSubpathOptimized(gitUrl, tempDir, gitInfo, log) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('子目录不存在: {{subpath}}', { subpath: gitInfo.subpath }));
|
|
209
|
-
}
|
|
210
|
-
const tempContentDir = path_1.default.join(tempDir, '.temp-content-' + Date.now());
|
|
211
|
-
yield fs_extra_1.default.move(subpathFull, tempContentDir);
|
|
212
|
-
const tempFiles = yield fs_extra_1.default.readdir(tempDir);
|
|
213
|
-
for (const file of tempFiles) {
|
|
214
|
-
if (file !== path_1.default.basename(tempContentDir)) {
|
|
215
|
-
yield fs_extra_1.default.remove(path_1.default.join(tempDir, file));
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
const contentFiles = yield fs_extra_1.default.readdir(tempContentDir);
|
|
219
|
-
for (const file of contentFiles) {
|
|
220
|
-
yield fs_extra_1.default.move(path_1.default.join(tempContentDir, file), path_1.default.join(tempDir, file));
|
|
221
|
-
}
|
|
222
|
-
yield fs_extra_1.default.remove(tempContentDir);
|
|
223
|
-
}
|
|
224
|
-
catch (error) {
|
|
225
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('克隆子目录失败: {{error}}', { error: error.message }), { original: error });
|
|
186
|
+
async cloneWithSubpathOptimized(gitUrl, tempDir, gitInfo, log) {
|
|
187
|
+
try {
|
|
188
|
+
await this.git.clone(gitUrl, tempDir, [
|
|
189
|
+
'--depth', '1',
|
|
190
|
+
'--single-branch',
|
|
191
|
+
'--branch', gitInfo.branch,
|
|
192
|
+
'--filter=blob:none'
|
|
193
|
+
]);
|
|
194
|
+
const subpathFull = path_1.default.join(tempDir, gitInfo.subpath);
|
|
195
|
+
if (!await fs_extra_1.default.pathExists(subpathFull)) {
|
|
196
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('子目录不存在: {{subpath}}', { subpath: gitInfo.subpath }));
|
|
226
197
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const tempGit = (0, simple_git_1.simpleGit)(tempDir);
|
|
234
|
-
yield tempGit.checkout(gitInfo.branch);
|
|
235
|
-
const subpathFull = path_1.default.join(tempDir, gitInfo.subpath);
|
|
236
|
-
if (!(yield fs_extra_1.default.pathExists(subpathFull))) {
|
|
237
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('子目录不存在: {{subpath}}', { subpath: gitInfo.subpath }));
|
|
238
|
-
}
|
|
239
|
-
const tempContentDir = path_1.default.join(tempDir, '.temp-content-' + Date.now());
|
|
240
|
-
yield fs_extra_1.default.move(subpathFull, tempContentDir);
|
|
241
|
-
const tempFiles = yield fs_extra_1.default.readdir(tempDir);
|
|
242
|
-
for (const file of tempFiles) {
|
|
243
|
-
if (file !== path_1.default.basename(tempContentDir)) {
|
|
244
|
-
yield fs_extra_1.default.remove(path_1.default.join(tempDir, file));
|
|
245
|
-
}
|
|
198
|
+
const tempContentDir = path_1.default.join(tempDir, '.temp-content-' + Date.now());
|
|
199
|
+
await fs_extra_1.default.move(subpathFull, tempContentDir);
|
|
200
|
+
const tempFiles = await fs_extra_1.default.readdir(tempDir);
|
|
201
|
+
for (const file of tempFiles) {
|
|
202
|
+
if (file !== path_1.default.basename(tempContentDir)) {
|
|
203
|
+
await fs_extra_1.default.remove(path_1.default.join(tempDir, file));
|
|
246
204
|
}
|
|
247
|
-
const contentFiles = yield fs_extra_1.default.readdir(tempContentDir);
|
|
248
|
-
for (const file of contentFiles) {
|
|
249
|
-
yield fs_extra_1.default.move(path_1.default.join(tempContentDir, file), path_1.default.join(tempDir, file));
|
|
250
|
-
}
|
|
251
|
-
yield fs_extra_1.default.remove(tempContentDir);
|
|
252
205
|
}
|
|
253
|
-
|
|
254
|
-
|
|
206
|
+
const contentFiles = await fs_extra_1.default.readdir(tempContentDir);
|
|
207
|
+
for (const file of contentFiles) {
|
|
208
|
+
await fs_extra_1.default.move(path_1.default.join(tempContentDir, file), path_1.default.join(tempDir, file));
|
|
255
209
|
}
|
|
256
|
-
|
|
210
|
+
await fs_extra_1.default.remove(tempContentDir);
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('克隆子目录失败: {{error}}', { error: error.message }), { original: error });
|
|
214
|
+
}
|
|
257
215
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
216
|
+
async cloneWithSubpath(gitUrl, tempDir, gitInfo, log) {
|
|
217
|
+
try {
|
|
218
|
+
await this.git.clone(gitUrl, tempDir);
|
|
219
|
+
const tempGit = (0, simple_git_1.simpleGit)(tempDir);
|
|
220
|
+
await tempGit.checkout(gitInfo.branch);
|
|
221
|
+
const subpathFull = path_1.default.join(tempDir, gitInfo.subpath);
|
|
222
|
+
if (!await fs_extra_1.default.pathExists(subpathFull)) {
|
|
223
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('子目录不存在: {{subpath}}', { subpath: gitInfo.subpath }));
|
|
263
224
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
225
|
+
const tempContentDir = path_1.default.join(tempDir, '.temp-content-' + Date.now());
|
|
226
|
+
await fs_extra_1.default.move(subpathFull, tempContentDir);
|
|
227
|
+
const tempFiles = await fs_extra_1.default.readdir(tempDir);
|
|
228
|
+
for (const file of tempFiles) {
|
|
229
|
+
if (file !== path_1.default.basename(tempContentDir)) {
|
|
230
|
+
await fs_extra_1.default.remove(path_1.default.join(tempDir, file));
|
|
231
|
+
}
|
|
269
232
|
}
|
|
270
|
-
|
|
271
|
-
|
|
233
|
+
const contentFiles = await fs_extra_1.default.readdir(tempContentDir);
|
|
234
|
+
for (const file of contentFiles) {
|
|
235
|
+
await fs_extra_1.default.move(path_1.default.join(tempContentDir, file), path_1.default.join(tempDir, file));
|
|
272
236
|
}
|
|
273
|
-
|
|
237
|
+
await fs_extra_1.default.remove(tempContentDir);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('克隆子目录失败: {{error}}', { error: error.message }), { original: error });
|
|
241
|
+
}
|
|
274
242
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
243
|
+
async downloadBuiltinTemplateToTemp(templateId, tempDir, log) {
|
|
244
|
+
const template = BUILTIN_TEMPLATES[templateId];
|
|
245
|
+
if (!template) {
|
|
246
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('未知的内置模板: {{templateId}}', { templateId }));
|
|
247
|
+
}
|
|
248
|
+
log.info((0, i18n_1.t)('📦 正在下载 {{templateName}} 模板到临时目录...', { templateName: template.name }));
|
|
249
|
+
try {
|
|
250
|
+
const { downloadAndExtractRemoteZip } = await Promise.resolve().then(() => __importStar(require('./tools/common')));
|
|
251
|
+
await downloadAndExtractRemoteZip(template.url, tempDir);
|
|
252
|
+
log.info((0, i18n_1.t)('✅ {{templateName}} 模板下载完成到临时目录', { templateName: template.name }));
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('下载内置模板失败: {{error}}', { error: error.message }), { original: error });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async downloadZipTemplateToTemp(zipUrl, tempDir, log) {
|
|
259
|
+
log.info((0, i18n_1.t)('📦 正在下载 zip 文件模板到临时目录: {{zipUrl}}', { zipUrl }));
|
|
260
|
+
try {
|
|
261
|
+
const { downloadAndExtractRemoteZip } = await Promise.resolve().then(() => __importStar(require('./tools/common')));
|
|
262
|
+
await downloadAndExtractRemoteZip(zipUrl, tempDir);
|
|
263
|
+
log.info((0, i18n_1.t)('✅ zip 文件模板下载完成到临时目录'));
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('下载 zip 文件模板失败: {{error}}', { error: error.message }), { original: error });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
async downloadGitTemplateToTemp(gitInfo, tempDir, log) {
|
|
270
|
+
const gitUrl = this.buildGitUrl(gitInfo);
|
|
271
|
+
log.info((0, i18n_1.t)('📦 正在从 {{platform}} 下载模板到临时目录...', { platform: gitInfo.platform }));
|
|
272
|
+
try {
|
|
273
|
+
if (gitInfo.subpath) {
|
|
274
|
+
await this.cloneWithSubpathOptimized(gitUrl, tempDir, gitInfo, log);
|
|
282
275
|
}
|
|
283
|
-
|
|
284
|
-
|
|
276
|
+
else {
|
|
277
|
+
await this.git.clone(gitUrl, tempDir, ['--depth', '1', '--single-branch', '--branch', gitInfo.branch]);
|
|
285
278
|
}
|
|
286
|
-
|
|
279
|
+
log.info((0, i18n_1.t)('✅ Git 模板下载完成到临时目录'));
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('Git 模板下载失败: {{error}}', { error: error.message }), { original: error });
|
|
283
|
+
}
|
|
287
284
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
285
|
+
async copyFromTempToTarget(tempDir, targetPath, force, log) {
|
|
286
|
+
log.info((0, i18n_1.t)('📦 正在从临时目录复制到目标目录 {{targetPath}}...', { targetPath }));
|
|
287
|
+
try {
|
|
288
|
+
if (force) {
|
|
289
|
+
if (await fs_extra_1.default.pathExists(targetPath)) {
|
|
290
|
+
const files = await fs_extra_1.default.readdir(targetPath);
|
|
291
|
+
if (files.length > 0) {
|
|
292
|
+
log.info((0, i18n_1.t)('⚠️ 使用 --force 参数,将覆盖目标目录中的现有文件'));
|
|
293
|
+
}
|
|
295
294
|
}
|
|
296
|
-
|
|
297
|
-
|
|
295
|
+
await this.copyFilesWithOverwrite(tempDir, targetPath, log);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
if (await fs_extra_1.default.pathExists(targetPath)) {
|
|
299
|
+
const files = await fs_extra_1.default.readdir(targetPath);
|
|
300
|
+
if (files.length > 0) {
|
|
301
|
+
log.info((0, i18n_1.t)('ℹ️ 目标目录不为空,将跳过已存在的文件,只复制新文件'));
|
|
302
|
+
}
|
|
298
303
|
}
|
|
299
|
-
|
|
304
|
+
await this.copyFilesSkipExisting(tempDir, targetPath, log);
|
|
305
|
+
}
|
|
306
|
+
log.info((0, i18n_1.t)('✅ 模板复制完成'));
|
|
307
|
+
try {
|
|
308
|
+
log.debug((0, i18n_1.t)('🔧 开始调用 MCP 配置修改器...'));
|
|
309
|
+
await this.mcpConfigModifier.modifyMCPConfigs(targetPath, log);
|
|
310
|
+
log.debug((0, i18n_1.t)('✅ MCP 配置修改器调用完成'));
|
|
300
311
|
}
|
|
301
312
|
catch (error) {
|
|
302
|
-
|
|
313
|
+
log.warn((0, i18n_1.t)('⚠️ MCP 配置修改失败: {{error}}', { error: error.message }));
|
|
303
314
|
}
|
|
304
|
-
}
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('复制模板失败: {{error}}', { error: error.message }), { original: error });
|
|
318
|
+
}
|
|
305
319
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
320
|
+
async copyFilesWithOverwrite(sourceDir, targetDir, log) {
|
|
321
|
+
let copiedCount = 0;
|
|
322
|
+
let overwrittenCount = 0;
|
|
323
|
+
const copyFile = async (srcPath, destPath) => {
|
|
309
324
|
try {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
325
|
+
const stat = await fs_extra_1.default.stat(srcPath);
|
|
326
|
+
if (stat.isDirectory()) {
|
|
327
|
+
await fs_extra_1.default.ensureDir(destPath);
|
|
328
|
+
const entries = await fs_extra_1.default.readdir(srcPath, { withFileTypes: true });
|
|
329
|
+
const copyPromises = entries.map(entry => {
|
|
330
|
+
const entrySrcPath = path_1.default.join(srcPath, entry.name);
|
|
331
|
+
const entryDestPath = path_1.default.join(destPath, entry.name);
|
|
332
|
+
return copyFile(entrySrcPath, entryDestPath);
|
|
333
|
+
});
|
|
334
|
+
const chunks = this.chunkArray(copyPromises, 10);
|
|
335
|
+
for (const chunk of chunks) {
|
|
336
|
+
await Promise.all(chunk);
|
|
316
337
|
}
|
|
317
|
-
yield this.copyFilesWithOverwrite(tempDir, targetPath, log);
|
|
318
338
|
}
|
|
319
339
|
else {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
340
|
+
const exists = await fs_extra_1.default.pathExists(destPath);
|
|
341
|
+
await fs_extra_1.default.ensureDir(path_1.default.dirname(destPath));
|
|
342
|
+
await fs_extra_1.default.copy(srcPath, destPath);
|
|
343
|
+
const relativePath = path_1.default.relative(sourceDir, srcPath);
|
|
344
|
+
if (exists) {
|
|
345
|
+
overwrittenCount++;
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
copiedCount++;
|
|
325
349
|
}
|
|
326
|
-
yield this.copyFilesSkipExisting(tempDir, targetPath, log);
|
|
327
|
-
}
|
|
328
|
-
log.info((0, i18n_1.t)('✅ 模板复制完成'));
|
|
329
|
-
try {
|
|
330
|
-
log.debug((0, i18n_1.t)('🔧 开始调用 MCP 配置修改器...'));
|
|
331
|
-
yield this.mcpConfigModifier.modifyMCPConfigs(targetPath, log);
|
|
332
|
-
log.debug((0, i18n_1.t)('✅ MCP 配置修改器调用完成'));
|
|
333
|
-
}
|
|
334
|
-
catch (error) {
|
|
335
|
-
log.warn((0, i18n_1.t)('⚠️ MCP 配置修改失败: {{error}}', { error: error.message }));
|
|
336
350
|
}
|
|
337
351
|
}
|
|
338
352
|
catch (error) {
|
|
339
|
-
|
|
353
|
+
log.warn((0, i18n_1.t)('⚠️ 复制失败: {{path}} - {{error}}', { path: path_1.default.relative(sourceDir, srcPath), error: error.message }));
|
|
340
354
|
}
|
|
355
|
+
};
|
|
356
|
+
const entries = await fs_extra_1.default.readdir(sourceDir, { withFileTypes: true });
|
|
357
|
+
const copyPromises = entries.map(entry => {
|
|
358
|
+
const srcPath = path_1.default.join(sourceDir, entry.name);
|
|
359
|
+
const destPath = path_1.default.join(targetDir, entry.name);
|
|
360
|
+
return copyFile(srcPath, destPath);
|
|
341
361
|
});
|
|
362
|
+
const chunks = this.chunkArray(copyPromises, 5);
|
|
363
|
+
for (const chunk of chunks) {
|
|
364
|
+
await Promise.all(chunk);
|
|
365
|
+
}
|
|
366
|
+
log.info((0, i18n_1.t)('📊 复制统计: {{copiedCount}} 个新文件复制, {{overwrittenCount}} 个文件覆盖', { copiedCount, overwrittenCount }));
|
|
342
367
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
yield Promise.all(chunk);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
const exists = yield fs_extra_1.default.pathExists(destPath);
|
|
365
|
-
yield fs_extra_1.default.ensureDir(path_1.default.dirname(destPath));
|
|
366
|
-
yield fs_extra_1.default.copy(srcPath, destPath);
|
|
367
|
-
const relativePath = path_1.default.relative(sourceDir, srcPath);
|
|
368
|
-
if (exists) {
|
|
369
|
-
overwrittenCount++;
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
copiedCount++;
|
|
373
|
-
}
|
|
368
|
+
async copyFilesSkipExisting(sourceDir, targetDir, log) {
|
|
369
|
+
let copiedCount = 0;
|
|
370
|
+
let skippedCount = 0;
|
|
371
|
+
const copyFile = async (srcPath, destPath) => {
|
|
372
|
+
try {
|
|
373
|
+
const stat = await fs_extra_1.default.stat(srcPath);
|
|
374
|
+
if (stat.isDirectory()) {
|
|
375
|
+
await fs_extra_1.default.ensureDir(destPath);
|
|
376
|
+
const entries = await fs_extra_1.default.readdir(srcPath, { withFileTypes: true });
|
|
377
|
+
const copyPromises = entries.map(entry => {
|
|
378
|
+
const entrySrcPath = path_1.default.join(srcPath, entry.name);
|
|
379
|
+
const entryDestPath = path_1.default.join(destPath, entry.name);
|
|
380
|
+
return copyFile(entrySrcPath, entryDestPath);
|
|
381
|
+
});
|
|
382
|
+
const chunks = this.chunkArray(copyPromises, 10);
|
|
383
|
+
for (const chunk of chunks) {
|
|
384
|
+
await Promise.all(chunk);
|
|
374
385
|
}
|
|
375
386
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
const srcPath = path_1.default.join(sourceDir, entry.name);
|
|
383
|
-
const destPath = path_1.default.join(targetDir, entry.name);
|
|
384
|
-
return copyFile(srcPath, destPath);
|
|
385
|
-
});
|
|
386
|
-
const chunks = this.chunkArray(copyPromises, 5);
|
|
387
|
-
for (const chunk of chunks) {
|
|
388
|
-
yield Promise.all(chunk);
|
|
389
|
-
}
|
|
390
|
-
log.info((0, i18n_1.t)('📊 复制统计: {{copiedCount}} 个新文件复制, {{overwrittenCount}} 个文件覆盖', { copiedCount, overwrittenCount }));
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
copyFilesSkipExisting(sourceDir, targetDir, log) {
|
|
394
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
395
|
-
let copiedCount = 0;
|
|
396
|
-
let skippedCount = 0;
|
|
397
|
-
const copyFile = (srcPath, destPath) => __awaiter(this, void 0, void 0, function* () {
|
|
398
|
-
try {
|
|
399
|
-
const stat = yield fs_extra_1.default.stat(srcPath);
|
|
400
|
-
if (stat.isDirectory()) {
|
|
401
|
-
yield fs_extra_1.default.ensureDir(destPath);
|
|
402
|
-
const entries = yield fs_extra_1.default.readdir(srcPath, { withFileTypes: true });
|
|
403
|
-
const copyPromises = entries.map(entry => {
|
|
404
|
-
const entrySrcPath = path_1.default.join(srcPath, entry.name);
|
|
405
|
-
const entryDestPath = path_1.default.join(destPath, entry.name);
|
|
406
|
-
return copyFile(entrySrcPath, entryDestPath);
|
|
407
|
-
});
|
|
408
|
-
const chunks = this.chunkArray(copyPromises, 10);
|
|
409
|
-
for (const chunk of chunks) {
|
|
410
|
-
yield Promise.all(chunk);
|
|
411
|
-
}
|
|
387
|
+
else {
|
|
388
|
+
if (!await fs_extra_1.default.pathExists(destPath)) {
|
|
389
|
+
await fs_extra_1.default.ensureDir(path_1.default.dirname(destPath));
|
|
390
|
+
await fs_extra_1.default.copy(srcPath, destPath);
|
|
391
|
+
const relativePath = path_1.default.relative(sourceDir, srcPath);
|
|
392
|
+
copiedCount++;
|
|
412
393
|
}
|
|
413
394
|
else {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
yield fs_extra_1.default.copy(srcPath, destPath);
|
|
417
|
-
const relativePath = path_1.default.relative(sourceDir, srcPath);
|
|
418
|
-
copiedCount++;
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
const relativePath = path_1.default.relative(sourceDir, srcPath);
|
|
422
|
-
skippedCount++;
|
|
423
|
-
}
|
|
395
|
+
const relativePath = path_1.default.relative(sourceDir, srcPath);
|
|
396
|
+
skippedCount++;
|
|
424
397
|
}
|
|
425
398
|
}
|
|
426
|
-
catch (error) {
|
|
427
|
-
log.warn((0, i18n_1.t)('⚠️ 复制失败: {{path}} - {{error}}', { path: path_1.default.relative(sourceDir, srcPath), error: error.message }));
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
const entries = yield fs_extra_1.default.readdir(sourceDir, { withFileTypes: true });
|
|
431
|
-
const copyPromises = entries.map(entry => {
|
|
432
|
-
const srcPath = path_1.default.join(sourceDir, entry.name);
|
|
433
|
-
const destPath = path_1.default.join(targetDir, entry.name);
|
|
434
|
-
return copyFile(srcPath, destPath);
|
|
435
|
-
});
|
|
436
|
-
const chunks = this.chunkArray(copyPromises, 5);
|
|
437
|
-
for (const chunk of chunks) {
|
|
438
|
-
yield Promise.all(chunk);
|
|
439
399
|
}
|
|
440
|
-
|
|
400
|
+
catch (error) {
|
|
401
|
+
log.warn((0, i18n_1.t)('⚠️ 复制失败: {{path}} - {{error}}', { path: path_1.default.relative(sourceDir, srcPath), error: error.message }));
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
const entries = await fs_extra_1.default.readdir(sourceDir, { withFileTypes: true });
|
|
405
|
+
const copyPromises = entries.map(entry => {
|
|
406
|
+
const srcPath = path_1.default.join(sourceDir, entry.name);
|
|
407
|
+
const destPath = path_1.default.join(targetDir, entry.name);
|
|
408
|
+
return copyFile(srcPath, destPath);
|
|
441
409
|
});
|
|
410
|
+
const chunks = this.chunkArray(copyPromises, 5);
|
|
411
|
+
for (const chunk of chunks) {
|
|
412
|
+
await Promise.all(chunk);
|
|
413
|
+
}
|
|
414
|
+
log.info((0, i18n_1.t)('📊 复制统计: {{copiedCount}} 个文件复制完成, {{skippedCount}} 个文件跳过', { copiedCount, skippedCount }));
|
|
442
415
|
}
|
|
443
416
|
chunkArray(array, chunkSize) {
|
|
444
417
|
const chunks = [];
|