Skip to content

Commit

Permalink
feat: rename presets property
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed May 17, 2024
1 parent 2190932 commit 57a798d
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 23 deletions.
6 changes: 3 additions & 3 deletions HANDBOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ It's possible that the registry isn't what a user wants
There are two options available if you're in an sfdx project.

- `registryCustomizations`: add your own partial of the the registry that'll be merged into the registry. It's a json object just like the registry itself.
- `registryPresets`: SDR defines "preset" registryCustomizations and you say which ones you want applied. Each one is a partial, and you can have any or all of them by listing them. Names correspond to something in src/registry/presets, so your project file could use
- `sourceBehaviorOptions`: SDR defines "preset" registryCustomizations and you say which ones you want applied. Each one is a partial, and you can have any or all of them by listing them. Names correspond to something in src/registry/presets, so your project file could use

```json
"registryPresets": ["decomposePermissionSetBeta", "decomposeSharingRulesBeta"]
"sourceBehaviorOptions": ["decomposePermissionSetBeta", "decomposeSharingRulesBeta"]
```

if you want only those 2 presets.
if you want only those 2 sourceBehaviorOptions.

The naming convention is `decomposeFoo` where `Foo` is the top-level metadata type, and refers to `/presets/Foo.json`.

Expand Down
2 changes: 1 addition & 1 deletion src/Presets.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Available Registry Presets
# Available sourceBehaviorOptions

## `decomposePermissionSetBeta`

Expand Down
22 changes: 14 additions & 8 deletions src/registry/variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type RegistryLoadInput = {
export const getEffectiveRegistry = (input?: RegistryLoadInput): MetadataRegistry =>
deepFreeze(firstLevelMerge(registryData as MetadataRegistry, loadVariants(input)));

/** read the project to get additional registry customizations and presets */
/** read the project to get additional registry customizations and sourceBehaviorOptions */
const loadVariants = ({ projectDir }: RegistryLoadInput = {}): MetadataRegistry => {
const logger = Logger.childFromRoot('variants');
const projJson = maybeGetProject(projectDir);
Expand All @@ -35,25 +35,31 @@ const loadVariants = ({ projectDir }: RegistryLoadInput = {}): MetadataRegistry

// there might not be any customizations in a project, so we default to the emptyRegistry
const customizations = projJson.get<MetadataRegistry>('registryCustomizations') ?? emptyRegistry;
const presets = projJson.get<string[]>('registryPresets') ?? [];
const sourceBehaviorOptions = [
...new Set([
// TODO: deprecated, remove this
...(projJson.get<string[]>('registryPresets') ?? []),
...(projJson.get<string[]>('sourceBehaviorOptions') ?? []),
]),
];
if (Object.keys(customizations.types).length > 0) {
logger.debug(
`found registryCustomizations for types [${Object.keys(customizations.types).join(',')}] in ${projJson.getPath()}`
);
}
if (presets.length > 0) {
logger.debug(`using registryPresets [${presets.join(',')}] in ${projJson.getPath()}`);
if (sourceBehaviorOptions.length > 0) {
logger.debug(`using sourceBehaviorOptions [${sourceBehaviorOptions.join(',')}] in ${projJson.getPath()}`);
}
const registryFromPresets = presets.reduce<MetadataRegistry>(
const registryFromPresets = sourceBehaviorOptions.reduce<MetadataRegistry>(
(prev, curr) => firstLevelMerge(prev, loadPreset(curr)),
emptyRegistry
);
if (presets.length > 0 || Object.keys(customizations.types).length > 0) {
if (sourceBehaviorOptions.length > 0 || Object.keys(customizations.types).length > 0) {
void Lifecycle.getInstance().emitTelemetry({
library: 'SDR',
eventName: 'RegistryVariants',
presetCount: presets.length,
presets: presets.join(','),
presetCount: sourceBehaviorOptions.length,
presets: sourceBehaviorOptions.join(','),
customizationsCount: Object.keys(customizations.types).length,
customizationsTypes: Object.keys(customizations.types).join(','),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"path": "force-app"
}
],
"registryPresets": ["decomposePermissionSetBeta"],
"sourceBehaviorOptions": ["decomposePermissionSetBeta"],
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "60.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"path": "force-app"
}
],
"registryPresets": ["decomposeCustomLabelsBeta"],
"sourceBehaviorOptions": ["decomposeCustomLabelsBeta"],
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "60.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"path": "force-app"
}
],
"registryPresets": ["decomposeSharingRulesBeta"],
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "52.0"
"sourceApiVersion": "52.0",
"sourceBehaviorOptions": ["decomposeSharingRulesBeta"]
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"namespace": "",
"packageDirectories": [
{
"path": "force-app",
"default": true
"default": true,
"path": "force-app"
},
{
"path": "another-package"
}
],
"registryPresets": ["decomposeWorkflowBeta"],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "60.0"
"sourceApiVersion": "60.0",
"sourceBehaviorOptions": ["decomposeWorkflowBeta"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"path": "force-app"
}
],
"registryPresets": ["decomposeWorkflowBeta"],
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "60.0"
"sourceApiVersion": "60.0",
"sourceBehaviorOptions": ["decomposeWorkflowBeta"]
}

2 comments on commit 57a798d

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 57a798d Previous: aac1d3d Ratio
eda-componentSetCreate-linux 183 ms 181 ms 1.01
eda-sourceToMdapi-linux 1958 ms 1972 ms 0.99
eda-sourceToZip-linux 1411 ms 1446 ms 0.98
eda-mdapiToSource-linux 2735 ms 2890 ms 0.95
lotsOfClasses-componentSetCreate-linux 388 ms 422 ms 0.92
lotsOfClasses-sourceToMdapi-linux 3806 ms 3758 ms 1.01
lotsOfClasses-sourceToZip-linux 3008 ms 3117 ms 0.97
lotsOfClasses-mdapiToSource-linux 3480 ms 3502 ms 0.99
lotsOfClassesOneDir-componentSetCreate-linux 622 ms 625 ms 1.00
lotsOfClassesOneDir-sourceToMdapi-linux 6454 ms 6565 ms 0.98
lotsOfClassesOneDir-sourceToZip-linux 5589 ms 5613 ms 1.00
lotsOfClassesOneDir-mdapiToSource-linux 6310 ms 6343 ms 0.99

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

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 57a798d Previous: aac1d3d Ratio
eda-componentSetCreate-win32 405 ms 410 ms 0.99
eda-sourceToMdapi-win32 3836 ms 3582 ms 1.07
eda-sourceToZip-win32 2329 ms 2159 ms 1.08
eda-mdapiToSource-win32 6186 ms 5970 ms 1.04
lotsOfClasses-componentSetCreate-win32 925 ms 843 ms 1.10
lotsOfClasses-sourceToMdapi-win32 7710 ms 7672 ms 1.00
lotsOfClasses-sourceToZip-win32 4697 ms 5349 ms 0.88
lotsOfClasses-mdapiToSource-win32 7450 ms 7529 ms 0.99
lotsOfClassesOneDir-componentSetCreate-win32 1454 ms 1487 ms 0.98
lotsOfClassesOneDir-sourceToMdapi-win32 13560 ms 13976 ms 0.97
lotsOfClassesOneDir-sourceToZip-win32 8418 ms 8580 ms 0.98
lotsOfClassesOneDir-mdapiToSource-win32 13360 ms 13692 ms 0.98

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

Please sign in to comment.