Skip to content

Commit

Permalink
feat: rename presets property (#1312)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc authored May 21, 2024
1 parent 5839d5d commit df722e3
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"]
}

0 comments on commit df722e3

Please sign in to comment.