Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve strict dirs before suffixes for potential metadata files #1480

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/resolve/metadataResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,8 @@ const parseAsContentMetadataXml =
const matchesSuffixType = fsPath.split(sep).includes(suffixType.directoryName);
if (matchesSuffixType) return matchesSuffixType;

// it might be a type that requires strict parent folder name.
const strictFolderSuffixType = registry
.getStrictFolderTypes()
.find((l) => l.suffix === suffixType.suffix && l.directoryName && l.name !== suffixType.name);
if (!strictFolderSuffixType) return false;

return fsPath.split(sep).includes(strictFolderSuffixType.directoryName);
// at this point, the suffixType is not a match, so check for strict folder types
return !!resolveTypeFromStrictFolder(registry)(fsPath);
};

/**
Expand Down
23 changes: 23 additions & 0 deletions test/resolve/metadataResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,29 @@ describe('MetadataResolver', () => {
expect(mdResolver.getComponentsFromPath(nonMetadataDirPath, filter)).to.deep.equal([]);
});

it('Should resolve RestrictionRules metadata in mdapi format', () => {
const unpackagedPath = 'unpackaged';
const packageXmlPath = join(unpackagedPath, 'package.xml');
const restrictionRulesPath = join('unpackaged', 'restrictionRules');
const restrictionRulePath = join(restrictionRulesPath, 'Foo.rule');
const treeContainer = VirtualTreeContainer.fromFilePaths([
unpackagedPath,
packageXmlPath,
restrictionRulesPath,
restrictionRulePath,
]);
const restrictionRuleComponent = new SourceComponent(
{
name: 'Foo',
type: registry.types.restrictionrule,
xml: restrictionRulePath,
},
treeContainer
);
const mdResolver = new MetadataResolver(undefined, treeContainer, false);
expect(mdResolver.getComponentsFromPath(unpackagedPath)).to.deep.equal([restrictionRuleComponent]);
});

it('Should not return a component if path to folder metadata xml is forceignored', () => {
const path = xmlInFolder.FOLDER_XML_PATH;
const access = testUtil.createMetadataResolver([
Expand Down
Loading