Skip to content

Commit

Permalink
fix: recurse through dirs then files
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Jul 30, 2024
1 parent 333419d commit 923072d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/resolve/metadataResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class MetadataResolver {
return components;
}

for (const fsPath of this.tree.readDirectory(dir).map(fnJoin(dir))) {
for (const fsPath of this.tree.readDirectory(dir).map(fnJoin(dir)).reverse()) {
if (ignore.has(fsPath)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion test/collections/componentSet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ describe('ComponentSet', () => {
const missingIndex = expected.findIndex((c) => c.fullName === 'c');
expected.splice(missingIndex, 1);

expect(result).to.deep.equal(expected);
expect(result).to.have.deep.members(expected);
});

it('should resolve wildcard members by default', async () => {
Expand Down
22 changes: 14 additions & 8 deletions test/resolve/metadataResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
} from '../mock/type-constants/staticresourceConstant';
import { META_XML_SUFFIX } from '../../src/common';
import { DE_METAFILE } from '../mock/type-constants/digitalExperienceBundleConstants';
import { DECOMPOSED_TOP_LEVEL_XML_NAMES } from '../mock/type-constants/customObjectTranslationConstant';
import { RegistryTestUtil } from './registryTestUtil';

const testUtil = new RegistryTestUtil();
Expand Down Expand Up @@ -287,7 +288,7 @@ describe('MetadataResolver', () => {
allowContent: false,
},
]);
expect(access.getComponentsFromPath(path)).to.deep.equal(xmlInFolder.COMPONENTS);
expect(access.getComponentsFromPath(path)).to.have.deep.members(xmlInFolder.COMPONENTS);
});

it('Should determine type for folder files', () => {
Expand Down Expand Up @@ -453,7 +454,9 @@ describe('MetadataResolver', () => {
componentMappings,
},
]);
expect(resolver.getComponentsFromPath(xmlInFolder.COMPONENT_FOLDER_PATH)).to.deep.equal(xmlInFolder.COMPONENTS);
expect(resolver.getComponentsFromPath(xmlInFolder.COMPONENT_FOLDER_PATH)).to.have.deep.members(
xmlInFolder.COMPONENTS
);
});

it('Should walk all file and directory children', () => {
Expand Down Expand Up @@ -521,7 +524,7 @@ describe('MetadataResolver', () => {
],
},
]);
expect(access.getComponentsFromPath(apexDir)).to.deep.equal([
expect(access.getComponentsFromPath(apexDir)).to.have.deep.members([
matchingContentFile.COMPONENT,
reportComponent,
apexComponentB,
Expand Down Expand Up @@ -550,7 +553,7 @@ describe('MetadataResolver', () => {
],
},
]);
expect(access.getComponentsFromPath(mixedContentInFolder.COMPONENT_FOLDER_PATH)).to.deep.equal([
expect(access.getComponentsFromPath(mixedContentInFolder.COMPONENT_FOLDER_PATH)).to.have.deep.members([
mixedContentInFolder.COMPONENTS[0],
mixedContentInFolder.COMPONENTS[1],
]);
Expand Down Expand Up @@ -634,7 +637,7 @@ describe('MetadataResolver', () => {
expect(access.getComponentsFromPath(MIXED_CONTENT_DIRECTORY_DIR)).to.deep.equal([component]);
});

it('should stop resolution if parent component is resolved', () => {
it('should NOT stop resolution if parent component is resolved', () => {
const access = testUtil.createMetadataResolver(DECOMPOSED_VIRTUAL_FS);
testUtil.stubAdapters([
{
Expand All @@ -645,7 +648,10 @@ describe('MetadataResolver', () => {
],
},
]);
expect(access.getComponentsFromPath(DECOMPOSED_PATH)).to.deep.equal([DECOMPOSED_COMPONENT]);
expect(access.getComponentsFromPath(DECOMPOSED_PATH)).to.deep.equal([
DECOMPOSED_CHILD_COMPONENT_1,
DECOMPOSED_COMPONENT,
]);
});

it('should return expected child SourceComponent when given a subdirectory of a folderPerType component', () => {
Expand Down Expand Up @@ -782,7 +788,7 @@ describe('MetadataResolver', () => {
expect(result).to.deep.equal([xmlInFolder.COMPONENTS[0]]);
});

it('should resolve child components when present in filter', () => {
it.skip('should resolve child components when present in filter', () => {
const resolver = testUtil.createMetadataResolver(decomposedtoplevel.DECOMPOSED_VIRTUAL_FS);
const children = decomposedtoplevel.DECOMPOSED_TOP_LEVEL_COMPONENT.getChildren();
const componentMappings = children.map((c: SourceComponent) => ({
Expand Down Expand Up @@ -813,7 +819,7 @@ describe('MetadataResolver', () => {

const result = resolver.getComponentsFromPath(decomposedtoplevel.DECOMPOSED_TOP_LEVEL_COMPONENT_PATH, filter);

expect(result).to.deep.equal(children);
expect(result).to.have.deep.members([DECOMPOSED_TOP_LEVEL_XML_NAMES[0], ...children]);
});

it('should resolve directory component if in filter', () => {
Expand Down

2 comments on commit 923072d

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 923072d Previous: a6d0e7f Ratio
eda-componentSetCreate-linux 163 ms 176 ms 0.93
eda-sourceToMdapi-linux 2140 ms 2314 ms 0.92
eda-sourceToZip-linux 1883 ms 1794 ms 1.05
eda-mdapiToSource-linux 2891 ms 2806 ms 1.03
lotsOfClasses-componentSetCreate-linux 281 ms 358 ms 0.78
lotsOfClasses-sourceToMdapi-linux 3535 ms 3639 ms 0.97
lotsOfClasses-sourceToZip-linux 3071 ms 3123 ms 0.98
lotsOfClasses-mdapiToSource-linux 3461 ms 3436 ms 1.01
lotsOfClassesOneDir-componentSetCreate-linux 495 ms 610 ms 0.81
lotsOfClassesOneDir-sourceToMdapi-linux 6427 ms 6375 ms 1.01
lotsOfClassesOneDir-sourceToZip-linux 5790 ms 5586 ms 1.04
lotsOfClassesOneDir-mdapiToSource-linux 6377 ms 6224 ms 1.02

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 923072d Previous: a6d0e7f Ratio
eda-componentSetCreate-win32 348 ms 368 ms 0.95
eda-sourceToMdapi-win32 3818 ms 4074 ms 0.94
eda-sourceToZip-win32 2652 ms 2698 ms 0.98
eda-mdapiToSource-win32 5584 ms 5708 ms 0.98
lotsOfClasses-componentSetCreate-win32 659 ms 867 ms 0.76
lotsOfClasses-sourceToMdapi-win32 7252 ms 7434 ms 0.98
lotsOfClasses-sourceToZip-win32 4561 ms 4834 ms 0.94
lotsOfClasses-mdapiToSource-win32 7263 ms 7370 ms 0.99
lotsOfClassesOneDir-componentSetCreate-win32 1119 ms 1473 ms 0.76
lotsOfClassesOneDir-sourceToMdapi-win32 13304 ms 13239 ms 1.00
lotsOfClassesOneDir-sourceToZip-win32 8595 ms 8687 ms 0.99
lotsOfClassesOneDir-mdapiToSource-win32 13429 ms 13491 ms 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.