Skip to content

Commit

Permalink
fix: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Jul 15, 2024
1 parent 683254a commit 327df18
Show file tree
Hide file tree
Showing 9 changed files with 68,022 additions and 7 deletions.
21 changes: 19 additions & 2 deletions src/convert/convertContext/recompositionFinalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,27 @@ type ChildWithXml = {
const recompose =
(cache: XmlCache) =>
async (stateValue: RecompositionStateValueWithParent): Promise<JsonMap> => {
await getXmlFromCache(cache)(stateValue.component);
const childComponents = stateValue.children?.toArray() ?? [];

// RecompositionState combines all labels metadata files into 1 component containing
// all the children. This checks for multiple parent components and gets the xml
// file content from each.
if (stateValue.component.type.name === 'CustomLabels') {
const parentLabelNames: string[] = [];
for (const childComp of childComponents) {
const parentComp = childComp.parent as SourceComponent;
if (parentComp && !parentLabelNames.includes(parentComp.name)) {
parentLabelNames.push(parentComp.name);
// eslint-disable-next-line no-await-in-loop
await getXmlFromCache(cache)(parentComp);
}
}
} else {
await getXmlFromCache(cache)(stateValue.component);
}

const childXmls = await Promise.all(
(stateValue.children?.toArray() ?? []).filter(ensureMetadataComponentWithParent).map(
childComponents.filter(ensureMetadataComponentWithParent).map(
async (child): Promise<ChildWithXml> => ({
cmp: child,
xmlContents: await getXmlFromCache(cache)(child),
Expand Down
10 changes: 5 additions & 5 deletions test/convert/convertContext/recomposition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ describe('Recomposition', () => {
expect(readFileSpy.callCount, JSON.stringify(readFileSpy.getCalls(), undefined, 2)).to.equal(1);
});

describe('should only read unique child xml files once for non-decomposed components', () => {
describe('should only read unique child xml files once per parent for non-decomposed components', () => {
// This test sets up 2 CustomLabels files; 1 in each package directory. The CustomLabels files
// each have 2 labels within them. This should result in only 2 file reads.
// each have 2 labels within them. This should result in only 2 file reads; 1 per parent CustomLabels file.
const customLabelsType = new RegistryAccess().getTypeByName('CustomLabels');
const labelsFileName = 'CustomLabels.labels-meta.xml';
const projectDir = join(process.cwd(), 'my-project');
Expand Down Expand Up @@ -210,7 +210,7 @@ describe('Recomposition', () => {
new VirtualTreeContainer(vDir)
);

it('one item in transaction state covering all the children', async () => {
it('one main component with multiple parents in transaction state covering all the children', async () => {
const context = new ConvertContext();
const compSet = new ComponentSet();
component.getChildren().forEach((child) => compSet.add(child));
Expand All @@ -220,11 +220,11 @@ describe('Recomposition', () => {
children: compSet,
});

const readFileSpy = env.spy(component.tree, 'readFile');
const readFileSpy = env.spy(VirtualTreeContainer.prototype, 'readFile');

await context.recomposition.finalize();

expect(readFileSpy.callCount).to.equal(context.recomposition.transactionState.size);
expect(readFileSpy.callCount, 'readFile() should only be called twice').to.equal(2);
});
});
});
Expand Down
Loading

2 comments on commit 327df18

@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: 327df18 Previous: 13ac7dc Ratio
eda-componentSetCreate-linux 183 ms 177 ms 1.03
eda-sourceToMdapi-linux 2020 ms 2247 ms 0.90
eda-sourceToZip-linux 1815 ms 1793 ms 1.01
eda-mdapiToSource-linux 2959 ms 2774 ms 1.07
lotsOfClasses-componentSetCreate-linux 368 ms 399 ms 0.92
lotsOfClasses-sourceToMdapi-linux 3750 ms 3621 ms 1.04
lotsOfClasses-sourceToZip-linux 3129 ms 3016 ms 1.04
lotsOfClasses-mdapiToSource-linux 3519 ms 3442 ms 1.02
lotsOfClassesOneDir-componentSetCreate-linux 636 ms 608 ms 1.05
lotsOfClassesOneDir-sourceToMdapi-linux 6657 ms 6461 ms 1.03
lotsOfClassesOneDir-sourceToZip-linux 5851 ms 5540 ms 1.06
lotsOfClassesOneDir-mdapiToSource-linux 6435 ms 6211 ms 1.04

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: 327df18 Previous: 13ac7dc Ratio
eda-componentSetCreate-win32 407 ms 407 ms 1
eda-sourceToMdapi-win32 3707 ms 4319 ms 0.86
eda-sourceToZip-win32 2880 ms 2886 ms 1.00
eda-mdapiToSource-win32 6134 ms 6160 ms 1.00
lotsOfClasses-componentSetCreate-win32 972 ms 924 ms 1.05
lotsOfClasses-sourceToMdapi-win32 8085 ms 7978 ms 1.01
lotsOfClasses-sourceToZip-win32 5219 ms 5035 ms 1.04
lotsOfClasses-mdapiToSource-win32 8134 ms 8176 ms 0.99
lotsOfClassesOneDir-componentSetCreate-win32 1485 ms 1617 ms 0.92
lotsOfClassesOneDir-sourceToMdapi-win32 13837 ms 14491 ms 0.95
lotsOfClassesOneDir-sourceToZip-win32 9203 ms 9196 ms 1.00
lotsOfClassesOneDir-mdapiToSource-win32 13520 ms 14530 ms 0.93

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

Please sign in to comment.