@locofy/mcp 1.0.1 → 1.0.3
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.
|
@@ -34,17 +34,16 @@ export async function runPullComponentsTool(args) {
|
|
|
34
34
|
// Check for code changes and mark changed files
|
|
35
35
|
await checkForCodeChanges(result.data);
|
|
36
36
|
// clean the directory structure
|
|
37
|
-
const cleanedResult =
|
|
38
|
-
const resultJSON = cleanedResult;
|
|
37
|
+
const cleanedResult = processDirectoryStructure(result.data);
|
|
39
38
|
// write resultJSON to a file
|
|
40
39
|
if (process.env.DEBUG_MODE === 'true') {
|
|
41
|
-
fs.writeFileSync('result.json', JSON.stringify(
|
|
40
|
+
fs.writeFileSync('result.json', JSON.stringify(cleanedResult, null, 2));
|
|
42
41
|
}
|
|
43
42
|
return {
|
|
44
43
|
content: [
|
|
45
44
|
{
|
|
46
45
|
type: 'text',
|
|
47
|
-
text: JSON.stringify(
|
|
46
|
+
text: JSON.stringify(cleanedResult, null, 2)
|
|
48
47
|
}
|
|
49
48
|
]
|
|
50
49
|
};
|
|
@@ -414,7 +413,7 @@ function normalizeForComparison(code) {
|
|
|
414
413
|
* @param directoryStructure The directory structure to clean
|
|
415
414
|
* @returns The cleaned directory structure
|
|
416
415
|
*/
|
|
417
|
-
function
|
|
416
|
+
function processDirectoryStructure(directoryStructure) {
|
|
418
417
|
const propertiesToRemove = [
|
|
419
418
|
'files',
|
|
420
419
|
'component',
|
|
@@ -427,6 +426,40 @@ function cleanDirectoryStructure(directoryStructure) {
|
|
|
427
426
|
'storybookFileName',
|
|
428
427
|
'isAutoSyncNode'
|
|
429
428
|
];
|
|
429
|
+
const componentsToUpdate = [];
|
|
430
|
+
const componentsUnchanged = [];
|
|
431
|
+
function collectChangeStatus(node) {
|
|
432
|
+
// Check if this is a component node with a name and change status
|
|
433
|
+
if (node.name && node.codeChanged !== undefined) {
|
|
434
|
+
if (node.codeChanged) {
|
|
435
|
+
componentsToUpdate.push(node.name);
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
componentsUnchanged.push(node.name);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
// Check dependencies
|
|
442
|
+
if (node.exportData && node.exportData.dependencies) {
|
|
443
|
+
node.exportData.dependencies.forEach((dep) => {
|
|
444
|
+
if (dep.compName && dep.codeChanged !== undefined) {
|
|
445
|
+
if (dep.codeChanged) {
|
|
446
|
+
componentsToUpdate.push(dep.compName);
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
componentsUnchanged.push(dep.compName);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
// Check nested dependencies
|
|
453
|
+
if (dep.dependencies && Array.isArray(dep.dependencies)) {
|
|
454
|
+
dep.dependencies.forEach((nestedDep) => collectChangeStatus(nestedDep));
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
// Process children recursively
|
|
459
|
+
if (node.children && Array.isArray(node.children)) {
|
|
460
|
+
node.children.forEach((child) => collectChangeStatus(child));
|
|
461
|
+
}
|
|
462
|
+
}
|
|
430
463
|
function cleanNode(node) {
|
|
431
464
|
// Remove unwanted properties from the current node
|
|
432
465
|
propertiesToRemove.forEach(prop => {
|
|
@@ -449,7 +482,16 @@ function cleanDirectoryStructure(directoryStructure) {
|
|
|
449
482
|
node.children.forEach((child) => cleanNode(child));
|
|
450
483
|
}
|
|
451
484
|
}
|
|
452
|
-
//
|
|
485
|
+
// First collect all change statuses
|
|
486
|
+
collectChangeStatus(directoryStructure);
|
|
487
|
+
// Then clean the structure
|
|
453
488
|
cleanNode(directoryStructure);
|
|
454
|
-
|
|
489
|
+
// Get the first child (the actual component data we want)
|
|
490
|
+
const result = directoryStructure.children && directoryStructure.children.length > 0
|
|
491
|
+
? directoryStructure.children[0]
|
|
492
|
+
: directoryStructure;
|
|
493
|
+
// Add the component lists to the component data
|
|
494
|
+
result.componentsToUpdate = [...new Set(componentsToUpdate)];
|
|
495
|
+
result.componentsUnchanged = [...new Set(componentsUnchanged)];
|
|
496
|
+
return result;
|
|
455
497
|
}
|