Skip to content

Commit

Permalink
fix: resolve strict dirs before suffixes for potential metadata files (
Browse files Browse the repository at this point in the history
…#1480)

* fix: resolve strict dirs before suffixes for potential metadata files

* fix: do not reuse suffixType if no match
  • Loading branch information
shetzel authored Jan 9, 2025
1 parent fa58e77 commit 50cb744
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
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

0 comments on commit 50cb744

Please sign in to comment.