Skip to content

Commit

Permalink
chore: simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Oct 30, 2023
1 parent 3036227 commit 45aece8
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions src/convert/transformers/decomposedMetadataTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { join } from 'path';
import * as path from 'path';
import { dirname, join } from 'path';
import { JsonMap } from '@salesforce/ts-types';
import { ensureArray } from '@salesforce/kit';
import { Messages } from '@salesforce/core';
Expand Down Expand Up @@ -109,7 +108,7 @@ export class DecomposedMetadataTransformer extends BaseMetadataTransformer {
}

// if there's nothing to merge with, push write operation now to default location
if (!mergeWith && !childType.unaddressableWithoutParent) {
if (!mergeWith) {
writeInfos.push({
source,
output: getDefaultOutput(childComponent),
Expand All @@ -128,29 +127,24 @@ export class DecomposedMetadataTransformer extends BaseMetadataTransformer {
});
this.setDecomposedState(childComponent, { foundMerge: true });
}
// if no child component is found to merge with yet, mark it as so in the state
// If we have a parent and the child is unaddressable without the parent, keep them
// together on the file system, meaning a new child will not be written to the default dir.
else if (childType.unaddressableWithoutParent) {
// get output path from parent
const childFileName = `${entryName}.${childComponent.type.suffix}${META_XML_SUFFIX}`;
const output = join(dirname(mergeWith.xml as string), childFileName);
writeInfos.push({ source, output });
}
// if no child component is found to merge with yet, mark it as so in
// the state
else if (!this.getDecomposedState(childComponent)?.foundMerge) {
if (mergeWith?.content && childComponent.type.unaddressableWithoutParent && childComponent.type.suffix) {
// if the child can't exist without the parent, and we found a parent (mergeWith) redirect the output to the parents output, rather than the default output
writeInfos.push({
source,
output: path.join(mergeWith.content, `${entryName}.${childComponent.type.suffix}${META_XML_SUFFIX}`),
});
} else if (!mergeWith) {
// if the child can't exist without a parent, and there's no parent found, redirect to the default pkg dir
writeInfos.push({
this.setDecomposedState(childComponent, {
foundMerge: false,
writeInfo: {
source,
output: getDefaultOutput(childComponent),
});
} else {
this.setDecomposedState(childComponent, {
foundMerge: false,
writeInfo: {
source,
output: getDefaultOutput(childComponent),
},
});
}
},
});
}
}
}
Expand Down

2 comments on commit 45aece8

@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: 45aece8 Previous: 396f7e6 Ratio
eda-componentSetCreate-linux 276 ms 290 ms 0.95
eda-sourceToMdapi-linux 8091 ms 8268 ms 0.98
eda-sourceToZip-linux 6308 ms 5274 ms 1.20
eda-mdapiToSource-linux 4351 ms 3592 ms 1.21
lotsOfClasses-componentSetCreate-linux 579 ms 557 ms 1.04
lotsOfClasses-sourceToMdapi-linux 10528 ms 9472 ms 1.11
lotsOfClasses-sourceToZip-linux 8098 ms 6564 ms 1.23
lotsOfClasses-mdapiToSource-linux 4682 ms 3692 ms 1.27
lotsOfClassesOneDir-componentSetCreate-linux 961 ms 864 ms 1.11
lotsOfClassesOneDir-sourceToMdapi-linux 13516 ms 10255 ms 1.32
lotsOfClassesOneDir-sourceToZip-linux 12635 ms 9925 ms 1.27
lotsOfClassesOneDir-mdapiToSource-linux 8314 ms 5294 ms 1.57

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: 45aece8 Previous: 396f7e6 Ratio
eda-componentSetCreate-win32 583 ms 747 ms 0.78
eda-sourceToMdapi-win32 9928 ms 11107 ms 0.89
eda-sourceToZip-win32 7974 ms 7816 ms 1.02
eda-mdapiToSource-win32 9084 ms 10663 ms 0.85
lotsOfClasses-componentSetCreate-win32 1203 ms 1723 ms 0.70
lotsOfClasses-sourceToMdapi-win32 17143 ms 18685 ms 0.92
lotsOfClasses-sourceToZip-win32 9723 ms 11247 ms 0.86
lotsOfClasses-mdapiToSource-win32 11162 ms 13642 ms 0.82
lotsOfClassesOneDir-componentSetCreate-win32 2134 ms 3001 ms 0.71
lotsOfClassesOneDir-sourceToMdapi-win32 25496 ms 31790 ms 0.80
lotsOfClassesOneDir-sourceToZip-win32 15975 ms 16789 ms 0.95
lotsOfClassesOneDir-mdapiToSource-win32 20009 ms 25099 ms 0.80

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

Please sign in to comment.