Skip to content

Commit

Permalink
chore: remove clean up writeInfos
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Sep 11, 2024
1 parent 61f7de4 commit f06c070
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
35 changes: 11 additions & 24 deletions src/convert/transformers/decomposedPermissionSetTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ export class DecomposedPermissionSetTransformer extends BaseMetadataTransformer

[
...children,
// TODO: this feels wrong, I'm not sure why the parent (.permissionset) isn't here child.getChildren() returns children
new SourceComponent({
// because the children have the same name as the parent
name: children[0]?.name,
xml: children[0]?.xml!.replace(/(\w+\.\w+-meta\.xml)/gm, `${children[0].name}.permissionset-meta.xml`),
type: this.context.decomposedPermissionSet.permissionSetType,
}),
// component is the first (alphabetically) file in the PS dir, if it happens to be the parent (.permissionset) use it,
// otherwise, build our own
component.xml?.endsWith('.permissionset-meta.xml')
? component
: new SourceComponent({
// because the children have the same name as the parent
name: children[0]?.name,
xml: children[0]?.xml!.replace(/(\w+\.\w+-meta\.xml)/gm, `${children[0].name}.permissionset-meta.xml`),
type: this.context.decomposedPermissionSet.permissionSetType,
}),
].map((c) => {
this.context.decomposedPermissionSet.transactionState.permissionSetChildByPath.set(
`${c.xml!}:${c.fullName}`,
Expand Down Expand Up @@ -122,25 +125,9 @@ export class DecomposedPermissionSetTransformer extends BaseMetadataTransformer
? getWriteInfosFromMerge(mergeWith)(stateSetter)(parentXmlObject)(component)
: getWriteInfosWithoutMerge(this.defaultDirectory)(parentXmlObject)(component);

const childDestinations = new Set(writeInfosForChildren.map((w) => w.output));

// files that exist in FS (therefore, in mergeWith) but aren't in the component should be deleted by returning a writeInfo
// only do this if all the children have isAddressable marked false
const writeInfosForMissingChildrenToDelete: WriteInfo[] = mergeWith
? childrenOfMergeComponent
.getSourceComponents()
.toArray()
.filter(hasXml)
.filter((c) => !childDestinations.has(c.xml))
.map((c) => ({ shouldDelete: true, output: c.xml, fullName: c.fullName, type: c.type.name }))
: [];

return [...writeInfosForChildren, ...writeInfoForParent, ...writeInfosForMissingChildrenToDelete];
return [...writeInfosForChildren, ...writeInfoForParent];
}
}

const hasXml = (c: SourceComponent): c is SourceComponent & { xml: string } => typeof c.xml === 'string';

/** for a component, parse the xml and create an json object with contents, child typeId, etc */
const getComposedMetadataEntries = async (component: SourceComponent): Promise<ComposedMetadata[]> =>
// composedMetadata might be undefined if you call toSourceFormat() from a non-source-backed Component
Expand Down
4 changes: 0 additions & 4 deletions src/registry/presets/decomposePermissionSetBeta2.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
"id": "fieldpermission",
"isAddressable": false,
"name": "FieldPermission",
"sharedDirectory": true,
"suffix": "objectSettings",
"uniqueIdElement": "field"
},
Expand All @@ -142,7 +141,6 @@
"directoryName": "objectSettings",
"id": "objectpermission",
"isAddressable": false,
"sharedDirectory": true,
"name": "ObjectPermission",
"suffix": "objectSettings",
"uniqueIdElement": "object"
Expand All @@ -158,15 +156,13 @@
"recordtypevisibility": {
"directoryName": "objectSettings",
"id": "recordtypevisibility",
"sharedDirectory": true,
"isAddressable": false,
"name": "RecordTypeVisibility",
"suffix": "objectSettings",
"uniqueIdElement": "recordType"
},
"tabsetting": {
"directoryName": "objectSettings",
"sharedDirectory": true,
"id": "tabsetting",
"isAddressable": false,
"name": "TabSetting",
Expand Down

2 comments on commit f06c070

@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: f06c070 Previous: 61f7de4 Ratio
eda-componentSetCreate-linux 234 ms 236 ms 0.99
eda-sourceToMdapi-linux 2387 ms 2352 ms 1.01
eda-sourceToZip-linux 1869 ms 1860 ms 1.00
eda-mdapiToSource-linux 3017 ms 2855 ms 1.06
lotsOfClasses-componentSetCreate-linux 418 ms 470 ms 0.89
lotsOfClasses-sourceToMdapi-linux 3749 ms 3645 ms 1.03
lotsOfClasses-sourceToZip-linux 3124 ms 3095 ms 1.01
lotsOfClasses-mdapiToSource-linux 3572 ms 3561 ms 1.00
lotsOfClassesOneDir-componentSetCreate-linux 726 ms 747 ms 0.97
lotsOfClassesOneDir-sourceToMdapi-linux 6534 ms 6478 ms 1.01
lotsOfClassesOneDir-sourceToZip-linux 5620 ms 5677 ms 0.99
lotsOfClassesOneDir-mdapiToSource-linux 6506 ms 6504 ms 1.00

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: f06c070 Previous: 61f7de4 Ratio
eda-componentSetCreate-win32 717 ms 710 ms 1.01
eda-sourceToMdapi-win32 4848 ms 4665 ms 1.04
eda-sourceToZip-win32 3198 ms 3229 ms 0.99
eda-mdapiToSource-win32 6499 ms 6304 ms 1.03
lotsOfClasses-componentSetCreate-win32 1371 ms 1303 ms 1.05
lotsOfClasses-sourceToMdapi-win32 8606 ms 8413 ms 1.02
lotsOfClasses-sourceToZip-win32 5581 ms 5405 ms 1.03
lotsOfClasses-mdapiToSource-win32 8637 ms 8501 ms 1.02
lotsOfClassesOneDir-componentSetCreate-win32 2462 ms 2322 ms 1.06
lotsOfClassesOneDir-sourceToMdapi-win32 15103 ms 14595 ms 1.03
lotsOfClassesOneDir-sourceToZip-win32 9539 ms 9117 ms 1.05
lotsOfClassesOneDir-mdapiToSource-win32 14482 ms 14034 ms 1.03

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

Please sign in to comment.