Skip to content

Commit

Permalink
feat(md-types): ServiceProcess and ProcessFlowMigration (#1039)
Browse files Browse the repository at this point in the history
* feat: add ServiceProcess

* feat: new mdType ProcessFlowMigration

* refactor: sf, new command styles

* docs: reduce sfdx

* refactor: apply suggestions from code review

Co-authored-by: Willie Ruemmele <willieruemmele@gmail.com>

---------

Co-authored-by: Willie Ruemmele <willieruemmele@gmail.com>
  • Loading branch information
mshanemc and WillieRuemmele authored Jul 14, 2023
1 parent 23ea184 commit 2e3f49d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
30 changes: 15 additions & 15 deletions contributing/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The script will:

1. Look for missing types (similar to the completeness test)
2. For missing types, generate a project and scratch org that includes the Features/Settings
3. Run `force:mdapi:describemetadata` to get the describe
3. Run `sf org list metadata-types` to get the describe
4. Modify the registry to include the newly found types

```shell
Expand All @@ -49,7 +49,7 @@ If that's confusing, it's a great time to reach out to the CLI team.

You can do what the script does yourself. As you work, run `./node_modules/mocha/bin/mocha test/registry/registryValidation.test.ts` to check your entries

Run `sfdx force:mdapi:describemetadata --json` to get the describe. `>` the output to a file or pipe it to [jq](https://stedolan.github.io/jq/) (`| jq`) to find your type.
Run `sf org list metadata-types --json` to get the describe. `>` the output to a file or pipe it to [jq](https://stedolan.github.io/jq/) (`| jq`) to find your type.

Your describe will contain something like this

Expand Down Expand Up @@ -142,16 +142,16 @@ Fixing those problems not only makes it easier to automate your type's support i

Want to make sure your types are working as expected?

1. Create a new project with `sfdx force:project:create -n registryTest`
1. Create a scratch org `sfdx force:org:create`
1. Create a new project with `sf project generate -n registryTest`
1. Create a scratch org `sf org create scratch`
1. Open the org and create your types.
1. Run `sfdx force:source:status` and verify the remote add.
1. Run `sfdx force:source:pull` to pull the metadata and examine what is retrieved
1. Run `sfdx force:source:status` and verify the changes were retrieved and no longer appear.
1. Delete the org `sfdx force:org:delete --noprompt`
1. Create a new scratch org. `sfdx force:org:create`
1. Push the source `sfdx force:source:push`
1. Convert the source to mdapi format `sfdx force:source:convert -d mdapiOut`
1. Run `sf project deploy preview` and verify the remote add.
1. Run `sf project retrieve start` to pull the metadata and examine what is retrieved
1. Run `sf project deploy preview` and verify the changes were retrieved and no longer appear.
1. Delete the org `sf org delete scratch --no-prompt`
1. Create a new scratch org. `sf org create scratch`
1. Push the source `sf project deploy start`
1. Convert the source to mdapi format `sf project convert source -d mdapiOut`
1. Look in the resulting `metadataPackage_` and `package.xml` to see that it looks as expected
1. Deploy it to the org using `sfdx force:mdapi:deploy --deploydir mdapiOut --wait 30` and verify that it succeeds
1. Delete the source directory `rm -rf force-app/main/default/*`
Expand All @@ -161,7 +161,7 @@ Want to make sure your types are working as expected?

### Caveats

Only `source:push` and `source:pull` support source tracking, so the target types must be MDAPI addressable on the server. If they aren’t MDAPI addressable, special code is needed to support source tracking for these components. See the document [Metadata API Types: End to End, Cradle to Grave](https://confluence.internal.salesforce.com/display/PLATFORMDX/Metadata+API+Types%3A+End+to+End%2C+Cradle+to+Grave) (Salesforce internal only) for more details.
Target types must be MDAPI addressable on the server. If they aren’t MDAPI addressable, special code is needed to support source tracking for these components. See the document [Metadata API Types: End to End, Cradle to Grave](https://confluence.internal.salesforce.com/display/PLATFORMDX/Metadata+API+Types%3A+End+to+End%2C+Cradle+to+Grave) (Salesforce internal only) for more details.

## Unit Testing

Expand Down Expand Up @@ -210,12 +210,12 @@ You can use an existing org for the metadata describe portion of the script by
## Prerequisites

1. A sfdx project must exists in local.
`sfdx force:project:create --projectname <projectname> --defaultpackagedir <directory> -x`
`sf project generate --name <projectname> --default-package-dir <directory> -x`
2. An authorized devhub org must exists
`sfdx force:auth:web:login -a <alias> -r <localhost url> -d`
`sf org login web -a <alias> -r <localhost url> -d`
3. A scratch org must exists with alias `registryBuilder`
1. Update `project-scratch-def.json` as per your requirements.
2. `sfdx force:org:create -f config/project-scratch-def.json -a registryBuilder -t scratch -s`
2. `sf org create scratch -f config/project-scratch-def.json -a registryBuilder -d`

## Steps

Expand Down
12 changes: 6 additions & 6 deletions scripts/update-registry/update2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const updateProjectScratchDef = (missingTypes: [string, CoverageObjectType][]) =
};

const getMissingTypesAsDescribeResult = (missingTypes: [string, CoverageObjectType][]): DescribeResult[] => {
const describeResult = shelljs.exec('sfdx force:mdapi:describemetadata -u registryBuilder --json', { silent: true });
const describeResult = shelljs.exec('sf org list metadata-types -o registryBuilder --json', { silent: true });
const metadataObjectsByName = new Map<string, DescribeResult>();
(JSON.parse(describeResult.stdout).result.metadataObjects as DescribeResult[]).map((describeObj) => {
metadataObjectsByName.set(describeObj.xmlName, describeObj);
Expand Down Expand Up @@ -104,24 +104,24 @@ const registryUpdate = (missingTypesAsDescribeResult: DescribeResult[]) => {
);

// create an org we can describe
shelljs.exec('sfdx force:project:create -n registryBuilder', { silent: true });
shelljs.exec('sf project generate -n registryBuilder', { silent: true });
updateProjectScratchDef(missingTypes);
// TODO: sourceApi has to match the coverage report
if (!process.env.RB_EXISTING_ORG) {
const hasDefaultDevHub = Boolean(
JSON.parse(shelljs.exec('sfdx config:get defaultdevhubusername --json', { silent: true }).stdout).result[0].value
JSON.parse(shelljs.exec('sf config get target-dev-hub --json', { silent: true }).stdout).result[0].value
);

if (!hasDefaultDevHub) {
console.log(`
Failed to create scratch org: default Dev Hub not found.
To create the scratch org you need to set a default Dev Hub with \`sfdx\`.
Example: \`sfdx config:set defaultdevhubusername=<devhub-username> --global\`
Example: \`sf config set defaultdevhubusername=<devhub-username> --global\`
`);
exit(1);
}

shelljs.exec('sfdx force:org:create -f registryBuilder/config/project-scratch-def.json -d 1 -a registryBuilder');
shelljs.exec('sf org create scratch -f registryBuilder/config/project-scratch-def.json -y 1 -a registryBuilder');
}
// describe the org
const missingTypesAsDescribeResult = getMissingTypesAsDescribeResult(missingTypes);
Expand All @@ -132,7 +132,7 @@ Example: \`sfdx config:set defaultdevhubusername=<devhub-username> --global\`

// destroy the scratch org and the project
if (!process.env.RB_EXISTING_ORG) {
shelljs.exec('sfdx force:org:delete -u registryBuilder --noprompt');
shelljs.exec('sf org delete scratch -o registryBuilder --no-prompt');
}
shelljs.rm('-rf', 'registryBuilder');
})();
20 changes: 19 additions & 1 deletion src/registry/metadataRegistry.json
Original file line number Diff line number Diff line change
Expand Up @@ -3483,6 +3483,22 @@
"directoryName": "useraccesspolicies",
"inFolder": false,
"strictDirectoryName": false
},
"serviceprocess": {
"id": "serviceprocess",
"name": "ServiceProcess",
"suffix": "serviceprocess",
"directoryName": "serviceprocess",
"inFolder": false,
"strictDirectoryName": false
},
"processflowmigration": {
"id": "processflowmigration",
"name": "ProcessFlowMigration",
"suffix": "processflowmigration",
"directoryName": "processflowmigrations",
"inFolder": false,
"strictDirectoryName": false
}
},
"suffixes": {
Expand Down Expand Up @@ -3864,7 +3880,9 @@
"personAccountOwnerPowerUser": "personaccountownerpoweruser",
"pipelineInspMetricConfig": "pipelineinspmetricconfig",
"productSpecificationTypeDefinition": "productspecificationtypedefinition",
"useraccesspolicy": "useraccesspolicy"
"useraccesspolicy": "useraccesspolicy",
"serviceprocess": "serviceprocess",
"processflowmigration": "processflowmigration"
},
"strictDirectoryNames": {
"experiences": "experiencebundle",
Expand Down
6 changes: 0 additions & 6 deletions src/registry/nonSupportedTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ export const metadataTypes = [
// spun up org with ASSOCIATIONENGINE, not in describe
'RecAlrtDataSrcExpSetDef',
'RecordAlertTemplate',

// B2CLOYALTYMANAGEMENTPLUS, not in describe
'ServiceProcess',

// does not show up in describe, but requires no features
'ProcessFlowMigration',
];

export const hasUnsupportedFeatures = (type: CoverageObjectType): boolean => {
Expand Down

0 comments on commit 2e3f49d

Please sign in to comment.