@catchmexz/fedin-vibe-mcp-server 0.1.7 → 0.1.9
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/operations/codeup/files.js +35 -36
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { yunxiaoRequest, buildUrl, pathEscape } from "../../common/utils.js";
|
|
2
2
|
import { FileContentSchema, CreateFileResponseSchema, DeleteFileResponseSchema, FileInfoSchema } from "./types.js";
|
|
3
|
-
import * as fs from
|
|
4
|
-
import pkg from
|
|
5
|
-
import * as path from
|
|
3
|
+
import * as fs from "fs";
|
|
4
|
+
import pkg from "fs-extra";
|
|
5
|
+
import * as path from "path";
|
|
6
6
|
import minimatch from "minimatch";
|
|
7
7
|
const { removeSync } = pkg;
|
|
8
8
|
function readGitignore(projectPath) {
|
|
@@ -85,7 +85,7 @@ function getAllFiles(dir, ignorePatterns) {
|
|
|
85
85
|
try {
|
|
86
86
|
const relativePath = path.relative(dir, fullPath);
|
|
87
87
|
// 将Windows的反斜杠路径分隔符转换为正斜杠,以适配远程仓库
|
|
88
|
-
const normalizedPath = relativePath.replace(/\\/g,
|
|
88
|
+
const normalizedPath = relativePath.replace(/\\/g, "/");
|
|
89
89
|
let content;
|
|
90
90
|
let encoding = "text";
|
|
91
91
|
if (isBinaryFile(fullPath)) {
|
|
@@ -254,29 +254,27 @@ export async function pushFilesFunc(organizationId, repositoryId, commitMessage,
|
|
|
254
254
|
// 读取 .gitignore 模式
|
|
255
255
|
// const ignorePatterns = readGitignore(projectPath);
|
|
256
256
|
const ignorePatterns = [
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
257
|
+
"dist",
|
|
258
|
+
".next",
|
|
259
|
+
"node_modules",
|
|
260
|
+
".git",
|
|
261
|
+
".vercel",
|
|
262
|
+
".cache",
|
|
263
|
+
"build",
|
|
264
|
+
"out",
|
|
265
|
+
".nuxt",
|
|
266
|
+
".svelte-kit",
|
|
267
|
+
"package-lock.json",
|
|
268
|
+
".DS_Store"
|
|
269
269
|
];
|
|
270
270
|
// 获取所有文件
|
|
271
271
|
const files = getAllFiles(projectPath, ignorePatterns);
|
|
272
272
|
// 检测项目类型
|
|
273
273
|
let projectType = "default"; // 默认值
|
|
274
274
|
// 检查是否存在 Next.js 配置文件
|
|
275
|
-
const hasNextConfig = files.some(file => file.path ===
|
|
276
|
-
file.path === 'next.config.ts');
|
|
275
|
+
const hasNextConfig = files.some((file) => file.path === "next.config.js" || file.path === "next.config.ts");
|
|
277
276
|
// 检查是否存在 Vite 配置文件
|
|
278
|
-
const hasViteConfig = files.some(file => file.path ===
|
|
279
|
-
file.path === 'vite.config.ts');
|
|
277
|
+
const hasViteConfig = files.some((file) => file.path === "vite.config.js" || file.path === "vite.config.ts");
|
|
280
278
|
// 根据配置文件设置项目类型
|
|
281
279
|
if (hasNextConfig) {
|
|
282
280
|
projectType = "fc";
|
|
@@ -325,22 +323,23 @@ export async function pushFilesFunc(organizationId, repositoryId, commitMessage,
|
|
|
325
323
|
deleteFileErrors.push(error.message);
|
|
326
324
|
}
|
|
327
325
|
}
|
|
328
|
-
const
|
|
326
|
+
const pipelineBody = {
|
|
327
|
+
name: projectId,
|
|
328
|
+
projectId: projectId,
|
|
329
|
+
repoUrl: `https://codeup.aliyun.com/ctrod/fedin-ai-project/${projectId}.git`,
|
|
330
|
+
projectType,
|
|
331
|
+
organizationId: organizationId,
|
|
332
|
+
token: process.env.YUNXIAO_ACCESS_TOKEN
|
|
333
|
+
};
|
|
334
|
+
const pipelineResponse = await fetch("https://ai.fedin.cn/api/alicloud/create-pipeline-run", {
|
|
329
335
|
method: "POST",
|
|
330
|
-
body: JSON.stringify(
|
|
331
|
-
name: projectId,
|
|
332
|
-
projectId: projectId,
|
|
333
|
-
repoUrl: `https://codeup.aliyun.com/ctrod/fedin-ai-project/${projectId}.git`,
|
|
334
|
-
projectType,
|
|
335
|
-
organizationId: organizationId,
|
|
336
|
-
token: process.env.YUNXIAO_ACCESS_TOKEN
|
|
337
|
-
}),
|
|
336
|
+
body: JSON.stringify(pipelineBody),
|
|
338
337
|
headers: {
|
|
339
338
|
"Content-Type": "application/json",
|
|
340
339
|
token: "fedin_ac_9x7k2m8p4w6q1z5n3v7b9c2e8r4t6"
|
|
341
340
|
}
|
|
342
341
|
});
|
|
343
|
-
const pipelineResult = await pipelineResponse.json();
|
|
342
|
+
const pipelineResult = (await pipelineResponse.json());
|
|
344
343
|
let onlineUrl;
|
|
345
344
|
if (pipelineResult.success && pipelineResult.data?.onlineUrl) {
|
|
346
345
|
onlineUrl = pipelineResult.data.onlineUrl;
|
|
@@ -352,9 +351,9 @@ export async function pushFilesFunc(organizationId, repositoryId, commitMessage,
|
|
|
352
351
|
updateFilesSuccess,
|
|
353
352
|
updateFileErrors,
|
|
354
353
|
deleteFilesSuccess,
|
|
355
|
-
deleteFileErrors
|
|
354
|
+
deleteFileErrors
|
|
356
355
|
},
|
|
357
|
-
onlineUrl: onlineUrl ||
|
|
356
|
+
onlineUrl: onlineUrl || ""
|
|
358
357
|
};
|
|
359
358
|
}
|
|
360
359
|
/**
|
|
@@ -378,16 +377,16 @@ export async function pullFilesFunc(organizationId, repositoryId, currntProjectP
|
|
|
378
377
|
const fileDir = path.dirname(fullPath);
|
|
379
378
|
fs.mkdirSync(fileDir, { recursive: true });
|
|
380
379
|
// 根据编码写入文件
|
|
381
|
-
if (fileBlob.encoding ===
|
|
382
|
-
const buffer = Buffer.from(fileBlob.content ||
|
|
380
|
+
if (fileBlob.encoding === "base64") {
|
|
381
|
+
const buffer = Buffer.from(fileBlob.content || "", "base64");
|
|
383
382
|
fs.writeFileSync(fullPath, buffer);
|
|
384
383
|
}
|
|
385
384
|
else {
|
|
386
|
-
fs.writeFileSync(fullPath, fileBlob.content ||
|
|
385
|
+
fs.writeFileSync(fullPath, fileBlob.content || "", "utf-8");
|
|
387
386
|
}
|
|
388
387
|
}
|
|
389
388
|
catch (error) {
|
|
390
|
-
console.error(
|
|
389
|
+
console.error("[获取文件内容失败]:", error);
|
|
391
390
|
}
|
|
392
391
|
}
|
|
393
392
|
return allRemoteFilesPath;
|