@primeuicom/mcp 1.2.0 → 1.2.1
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/service.js +111 -29
- package/dist/service.js.map +1 -1
- package/package.json +1 -1
package/dist/service.js
CHANGED
|
@@ -3739,6 +3739,8 @@ import { readFile as readFile7, writeFile as writeFile6 } from "fs/promises";
|
|
|
3739
3739
|
import path13 from "path";
|
|
3740
3740
|
var PACKAGE_JSON_RELATIVE_PATH2 = "package.json";
|
|
3741
3741
|
var VIRTUAL_ROUTE_SEGMENT = "__primeui-component-export";
|
|
3742
|
+
var COMPONENT_PAGES_PREFIX = "src/components/pages/";
|
|
3743
|
+
var COMPONENT_UI_PREFIX = "src/components/ui/";
|
|
3742
3744
|
function normalizeComponentId(componentId) {
|
|
3743
3745
|
const trimmed = componentId.trim();
|
|
3744
3746
|
if (!trimmed) {
|
|
@@ -3753,33 +3755,75 @@ function normalizeManifestFilePath(filePath) {
|
|
|
3753
3755
|
}
|
|
3754
3756
|
return toPosixPath(trimmed).replace(/^\.\/+/, "");
|
|
3755
3757
|
}
|
|
3758
|
+
function uniqueNormalizedManifestFiles(files) {
|
|
3759
|
+
return [...new Set(files.map(normalizeManifestFilePath))];
|
|
3760
|
+
}
|
|
3761
|
+
function getSuccessfulExportableFiles(manifest) {
|
|
3762
|
+
return manifest.export.exportables.flatMap(
|
|
3763
|
+
(exportable) => exportable.isReadyToExport && exportable.manifest.success ? exportable.manifest.files : []
|
|
3764
|
+
);
|
|
3765
|
+
}
|
|
3766
|
+
function getComponentCopyManifestFiles(manifest) {
|
|
3767
|
+
return uniqueNormalizedManifestFiles([
|
|
3768
|
+
...manifest.page.manifest.files,
|
|
3769
|
+
...getSuccessfulExportableFiles(manifest)
|
|
3770
|
+
]);
|
|
3771
|
+
}
|
|
3756
3772
|
function isVirtualRouteFile(relativePath) {
|
|
3757
|
-
|
|
3773
|
+
const segments = relativePath.split("/");
|
|
3774
|
+
return segments[0] === "src" && segments[1] === "app" && segments.includes(VIRTUAL_ROUTE_SEGMENT);
|
|
3775
|
+
}
|
|
3776
|
+
function isComponentEntryFile(relativePath, componentId) {
|
|
3777
|
+
if (!relativePath.startsWith(COMPONENT_PAGES_PREFIX)) {
|
|
3778
|
+
return false;
|
|
3779
|
+
}
|
|
3780
|
+
const extension = path13.extname(relativePath);
|
|
3781
|
+
if (!extension) {
|
|
3782
|
+
return false;
|
|
3783
|
+
}
|
|
3784
|
+
const basename = path13.basename(relativePath, extension);
|
|
3785
|
+
if (basename === componentId) {
|
|
3786
|
+
return true;
|
|
3787
|
+
}
|
|
3788
|
+
return basename === "index" && path13.basename(path13.dirname(relativePath)) === componentId;
|
|
3789
|
+
}
|
|
3790
|
+
function isManifestSupportFile(relativePath) {
|
|
3791
|
+
return relativePath.startsWith(COMPONENT_UI_PREFIX);
|
|
3758
3792
|
}
|
|
3759
|
-
function
|
|
3760
|
-
|
|
3761
|
-
|
|
3793
|
+
function toSkippedFile(targetPath, reason) {
|
|
3794
|
+
return {
|
|
3795
|
+
targetPath,
|
|
3796
|
+
reason
|
|
3797
|
+
};
|
|
3798
|
+
}
|
|
3799
|
+
function splitManifestFiles(input) {
|
|
3800
|
+
const manifestFiles = input.files.map(normalizeManifestFilePath);
|
|
3801
|
+
const copyableFileSet = new Set(input.copyableFiles);
|
|
3802
|
+
const componentEntryFiles = [];
|
|
3762
3803
|
const skippedFiles = [];
|
|
3763
3804
|
for (const relativePath of manifestFiles) {
|
|
3764
3805
|
if (relativePath === PACKAGE_JSON_RELATIVE_PATH2) {
|
|
3765
|
-
skippedFiles.push(
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
});
|
|
3806
|
+
skippedFiles.push(
|
|
3807
|
+
toSkippedFile(relativePath, "package_json_managed_as_dependencies")
|
|
3808
|
+
);
|
|
3769
3809
|
continue;
|
|
3770
3810
|
}
|
|
3771
3811
|
if (isVirtualRouteFile(relativePath)) {
|
|
3772
|
-
skippedFiles.push(
|
|
3773
|
-
targetPath: relativePath,
|
|
3774
|
-
reason: "virtual_component_route"
|
|
3775
|
-
});
|
|
3812
|
+
skippedFiles.push(toSkippedFile(relativePath, "virtual_component_route"));
|
|
3776
3813
|
continue;
|
|
3777
3814
|
}
|
|
3778
|
-
|
|
3815
|
+
if (isComponentEntryFile(relativePath, input.componentId)) {
|
|
3816
|
+
componentEntryFiles.push(relativePath);
|
|
3817
|
+
}
|
|
3818
|
+
if (!copyableFileSet.has(relativePath)) {
|
|
3819
|
+
skippedFiles.push(
|
|
3820
|
+
toSkippedFile(relativePath, "not_component_dependency")
|
|
3821
|
+
);
|
|
3822
|
+
}
|
|
3779
3823
|
}
|
|
3780
3824
|
return {
|
|
3781
3825
|
manifestFiles,
|
|
3782
|
-
|
|
3826
|
+
componentEntryFiles,
|
|
3783
3827
|
skippedFiles
|
|
3784
3828
|
};
|
|
3785
3829
|
}
|
|
@@ -3833,7 +3877,7 @@ function buildMessage(input) {
|
|
|
3833
3877
|
}
|
|
3834
3878
|
if (input.skippedFiles.length > 0) {
|
|
3835
3879
|
parts.push(
|
|
3836
|
-
`${input.skippedFiles.length} manifest file(s) skipped, including virtual route
|
|
3880
|
+
`${input.skippedFiles.length} manifest file(s) skipped, including virtual route, package metadata, or non-component context entries.`
|
|
3837
3881
|
);
|
|
3838
3882
|
}
|
|
3839
3883
|
if (input.missingManifestFiles.length > 0) {
|
|
@@ -3883,13 +3927,16 @@ async function copyRegistryComponentFromExport(input) {
|
|
|
3883
3927
|
`Component export manifest mismatch: expected componentId "${normalizedComponentId}", got "${manifest.component.componentId}".`
|
|
3884
3928
|
);
|
|
3885
3929
|
}
|
|
3886
|
-
const
|
|
3887
|
-
manifest
|
|
3888
|
-
|
|
3889
|
-
|
|
3930
|
+
const initialSelection = splitManifestFiles({
|
|
3931
|
+
files: getComponentCopyManifestFiles(manifest),
|
|
3932
|
+
componentId: normalizedComponentId,
|
|
3933
|
+
copyableFiles: []
|
|
3934
|
+
});
|
|
3935
|
+
const manifestFileSet = new Set(initialSelection.manifestFiles);
|
|
3936
|
+
const componentEntryCandidates = await resolveManifestCandidateFiles({
|
|
3890
3937
|
exportPath,
|
|
3891
3938
|
manifestOwnerLabel: `registry component "${normalizedComponentId}"`,
|
|
3892
|
-
files:
|
|
3939
|
+
files: initialSelection.componentEntryFiles,
|
|
3893
3940
|
requireExisting: false
|
|
3894
3941
|
});
|
|
3895
3942
|
const newFiles = [];
|
|
@@ -3897,7 +3944,44 @@ async function copyRegistryComponentFromExport(input) {
|
|
|
3897
3944
|
const conflictFiles = [];
|
|
3898
3945
|
const conflictReportEntries = [];
|
|
3899
3946
|
const missingManifestFiles = /* @__PURE__ */ new Set();
|
|
3900
|
-
const
|
|
3947
|
+
const existingComponentEntryFiles = [];
|
|
3948
|
+
for (const sourceFilePath of componentEntryCandidates) {
|
|
3949
|
+
const relativeToExport = toProjectRelative(exportPath, sourceFilePath);
|
|
3950
|
+
if (await fileExists2(sourceFilePath)) {
|
|
3951
|
+
existingComponentEntryFiles.push(sourceFilePath);
|
|
3952
|
+
continue;
|
|
3953
|
+
}
|
|
3954
|
+
missingManifestFiles.add(relativeToExport);
|
|
3955
|
+
}
|
|
3956
|
+
const dependencyGraph = existingComponentEntryFiles.length > 0 ? await buildImportGraph({
|
|
3957
|
+
projectRoot: exportPath,
|
|
3958
|
+
entryFiles: existingComponentEntryFiles,
|
|
3959
|
+
followInternalImports: true
|
|
3960
|
+
}) : { internalFiles: [], externalPackages: [] };
|
|
3961
|
+
const graphInternalFiles = new Set(
|
|
3962
|
+
dependencyGraph.internalFiles.map(
|
|
3963
|
+
(filePath) => toProjectRelative(exportPath, filePath)
|
|
3964
|
+
)
|
|
3965
|
+
);
|
|
3966
|
+
const exportableFileSet = new Set(
|
|
3967
|
+
uniqueNormalizedManifestFiles(getSuccessfulExportableFiles(manifest))
|
|
3968
|
+
);
|
|
3969
|
+
const copyableFiles = initialSelection.manifestFiles.filter(
|
|
3970
|
+
(relativePath) => graphInternalFiles.has(relativePath) || isManifestSupportFile(relativePath) || exportableFileSet.has(relativePath)
|
|
3971
|
+
).filter(
|
|
3972
|
+
(relativePath) => relativePath !== PACKAGE_JSON_RELATIVE_PATH2 && !isVirtualRouteFile(relativePath)
|
|
3973
|
+
).sort((a, b) => a.localeCompare(b));
|
|
3974
|
+
const { manifestFiles, skippedFiles } = splitManifestFiles({
|
|
3975
|
+
files: initialSelection.manifestFiles,
|
|
3976
|
+
componentId: normalizedComponentId,
|
|
3977
|
+
copyableFiles
|
|
3978
|
+
});
|
|
3979
|
+
const candidateFiles = await resolveManifestCandidateFiles({
|
|
3980
|
+
exportPath,
|
|
3981
|
+
manifestOwnerLabel: `registry component "${normalizedComponentId}"`,
|
|
3982
|
+
files: copyableFiles,
|
|
3983
|
+
requireExisting: false
|
|
3984
|
+
});
|
|
3901
3985
|
for (const sourceFilePath of candidateFiles) {
|
|
3902
3986
|
const relativeToExport = toProjectRelative(exportPath, sourceFilePath);
|
|
3903
3987
|
const sourceExists = await fileExists2(sourceFilePath);
|
|
@@ -3905,7 +3989,6 @@ async function copyRegistryComponentFromExport(input) {
|
|
|
3905
3989
|
missingManifestFiles.add(relativeToExport);
|
|
3906
3990
|
continue;
|
|
3907
3991
|
}
|
|
3908
|
-
existingCandidateFiles.push(sourceFilePath);
|
|
3909
3992
|
const targetFilePath = path13.join(input.projectRoot, relativeToExport);
|
|
3910
3993
|
ensureSafeTargetPath(input.projectRoot, targetFilePath);
|
|
3911
3994
|
const sourceBuffer = await readFile7(sourceFilePath);
|
|
@@ -3939,11 +4022,6 @@ async function copyRegistryComponentFromExport(input) {
|
|
|
3939
4022
|
});
|
|
3940
4023
|
}
|
|
3941
4024
|
}
|
|
3942
|
-
const dependencyGraph = existingCandidateFiles.length > 0 ? await buildImportGraph({
|
|
3943
|
-
projectRoot: exportPath,
|
|
3944
|
-
entryFiles: existingCandidateFiles,
|
|
3945
|
-
followInternalImports: false
|
|
3946
|
-
}) : { externalPackages: [] };
|
|
3947
4025
|
const { addedDependencies, dependenciesVersionConflicts } = await applyDependencyRequirementsToPackageJson({
|
|
3948
4026
|
exportPackageJsonPath: path13.join(exportPath, PACKAGE_JSON_RELATIVE_PATH2),
|
|
3949
4027
|
userPackageJsonPath: path13.join(
|
|
@@ -4853,8 +4931,12 @@ var skippedCopyFileSchema = z4.object({
|
|
|
4853
4931
|
targetPath: z4.string().describe(
|
|
4854
4932
|
"Relative target path intentionally not copied into user project root."
|
|
4855
4933
|
),
|
|
4856
|
-
reason: z4.enum([
|
|
4857
|
-
"
|
|
4934
|
+
reason: z4.enum([
|
|
4935
|
+
"package_json_managed_as_dependencies",
|
|
4936
|
+
"virtual_component_route",
|
|
4937
|
+
"not_component_dependency"
|
|
4938
|
+
]).describe(
|
|
4939
|
+
"Machine-readable reason for skipping this file. package_json_managed_as_dependencies means package.json was handled as dependency guidance instead of direct file copy. virtual_component_route means the internal component-export route was intentionally not installed into the target app. not_component_dependency means the manifest file belongs to page/template context outside the selected registry component dependency set."
|
|
4858
4940
|
)
|
|
4859
4941
|
});
|
|
4860
4942
|
var runtimeGuidanceArtifactSchema = z4.object({
|