You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Clone forked repo in local and checkout a new branch
16
+
1. Setup Yarn
17
+
1. Go to the repo directory
18
+
1. Run `yarn install && yarn build`
18
19
19
20
## Adding new types to the registry via a script
20
21
21
22
> NOTE: If you have a “Settings” metadata type, you do not need to follow these instructions. Support for your type is already built into SDR.
22
23
23
-
To simplify modifying the registry, there's a script.
24
+
### Path 1: Using Core Metadata
25
+
26
+
There exists a test in Core `GenerateCLITypeRegistryInfoTest` that generates a file `cli-type-registry-info.json`.
27
+
28
+
The test is manually run, the file is committed to `patch`, and the output is manually copied to `../scripts/update-registry/describe.json` in SDR.
24
29
25
-
> Note: The script depends on being able to create an org that will have your type. If you have a working org, but your type isn't compatible with scratch org, you can [use an existing org](#use-an-existing-org)
30
+
If your metadata type is simple and already in the file, run `yarn update-registry-org <MetadataEntity1> <MetadataEntity2>` (you'll see warnings if your type is missing or too complex for the script to handle)
26
31
27
-
> Note: The script will use your default dev hub. If you don't have one, set one up. If you want to use a different hub, update your default.
32
+
### Path 2: Using Describe from an Org
33
+
34
+
> Note: The script asks your org for describe information about your type. Make sure that `sf org list metadata-types` returns the correct information for your type.
28
35
29
36
The script will:
30
37
31
-
1. Look for missing types (similar to the completeness test)
32
-
2. For missing types, generate a project and scratch org that includes the Features/Settings
33
-
3. Run `sf org list metadata-types` to get the describe
34
-
4. Modify the registry to include the newly found types
38
+
1. Look for missing types (similar to the completeness test) OR the types you specify
39
+
1. Run `sf org list metadata-types` to get the describe
40
+
1. Modify the registry to include the newly found types
You can set the environment variable `SF_ORG_API_VERSION` if you want to specify an API version.
41
48
49
+
### Results
50
+
51
+
You should see updates to `src/registry/metadataRegistry.json` (check `git status`)
52
+
42
53
### What the script can't do
43
54
44
55
inFolderTypes and types with childXml in their describe are not supported. You **want** to explore the various strategies forthose (see the [SDR Handbook](../HANDBOOK.md)in this repo) and [create tests](#integration-testing) to validate that your types are being handled correctly.
@@ -51,6 +62,8 @@ If that's confusing, it's a great time to reach out to the CLI team.
51
62
52
63
## Manual Edits
53
64
65
+
> only do this if the script can't handle our type OR your type isn't in the CoverageReport yet and the script won't see it
66
+
54
67
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
55
68
56
69
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.
@@ -135,23 +148,31 @@ The completeness is checked by comparing the registry to the metadata coverage r
135
148
136
149
If you find your types (or the features they require) excluded by `nonSupportedTypes.ts` but think they're ready to go, feel free to remove them from the list.
137
150
138
-
There are 2 main ways this happens (or ways to make this work if it currently isn't)
151
+
## Manual Testing
139
152
140
-
1. A feature is available to scratch orgs when it previously wasn't
141
-
1. The metadata coverage report's "settings" were not sufficient to enable your type to appear in the `describe` call.
153
+
Want to make sure your types are working as expected?
142
154
143
-
Fixing those problems not only makes it easier to automate your type's support in the library, but also makes your type usable by customers (features) and fixes your documentation (coverageReport).
155
+
### Path 1 (replace the registry in your CLI)
144
156
145
-
## Manual Testing
157
+
1. find where your CLI has `metadataRegistry.json`. This varies based on how you installed the CLI and your machine. For example, using the installers on a mac, the registry is in ~/.local/share/sf/client/current/node_modules/@salesforce/source-deploy-retrieve/lib/src/registry/metadataRegistry.json
158
+
1. copy your modified registry from SDR over the existing file in your CLI
146
159
147
-
Want to make sure your types are working as expected?
160
+
### Path 2 (patch the registry via registryCustomizations)
148
161
149
162
1. Create a new project with `sf project generate -n registryTest`
150
-
1. Create a scratch org `sf org create scratch`
163
+
1. Open the generated `sfdx-project.json` and add a property `registryCustomizations`. Its shape is the same as the Metadata Registry, and it is treated as a "patch" for the default registry. If you generated registry changes above, you can add just those changes to `registryCustomizations`.
164
+
1. suffixes
165
+
1. strictDirectoryNames (could be empty if your new type doesn't use this)
166
+
1. childTypes (could be empty if your new type doesn't use this)
167
+
1. types
168
+
169
+
### Sample validation
170
+
171
+
1. Create a scratch org `sf org create scratch` (edit the scratch org definition file if your types needs features/settings)
151
172
1. Open the org and create your types.
152
-
1. Run `sf project deploy preview` and verify the remote add.
173
+
1. Run `sf project retrieve preview` and verify the remote add.
153
174
1. Run `sf project retrieve start` to pull the metadata and examine what is retrieved
154
-
1. Run `sf project deploy preview` and verify the changes were retrieved and no longer appear.
175
+
1. Run `sf project retrieve preview` and verify the changes were retrieved and no longer appear.
155
176
1. Delete the org `sf org delete scratch --no-prompt`
156
177
1. Create a new scratch org. `sf org create scratch`
157
178
1. Push the source `sf project deploy start`
@@ -169,10 +190,10 @@ Target types must be MDAPI addressable on the server. If they aren’t MDAPI add
169
190
170
191
## Unit Testing
171
192
172
-
Reach out to the CLI team for help with unit tests.
173
-
174
193
[metadataResolver.ts](../test/resolve/metadataResolver.test.ts) is an example of unit testing one behavior (resolving from source files) of a real metadata type.
175
194
195
+
We don't recommend additional UT for anything the script generated. But if you had a complex type, reach out to the CLI team forhelp with unit tests.
196
+
176
197
## Integration Testing
177
198
178
199
If you're doing anything complex (you've used any of the following properties `strategies`, `folderType`, `inFolder=true`, `ignoreParsedFullName`, `folderContentType`, `ignoreParentName`), you'll want to add some NUTs (not-unit-tests) that verify the behavior or your types using real orgs and to prevent SDR changes from causing regressions on your types.
@@ -183,61 +204,9 @@ NUTs live in [plugin-deploy-retrieve](https://github.com/salesforcecli/plugin-de
183
204
184
205
See [testkit](https://github.com/salesforcecli/cli-plugins-testkit) for examples and usage.
185
206
186
-
# Tips and Tricks
187
-
188
-
### Work in stages
207
+
## Got questions?
189
208
190
-
If you see a whole bunch of new unsupported types, you can "ignore" all the features and work through them in chunks (uncomment a feature at a time) using nonSupportedTypes.ts
191
-
192
-
If you want to update the registry for only a subset of the currently missing metadata types, add your types as arguments to the script.
Some metadata types require features which require modifications to the DevHub (licenses, etc) and some may have to stay ignored (ex: a pilot feature you can't enable)
204
-
205
-
### Use an existing org
206
-
207
-
You can use an existing org for the metadata describe portion of the script by
208
-
209
-
1. setting its alias to `registryBuilder`
210
-
2. setting the env `RB_EXISTING_ORG` ex: `RB_EXISTING_ORG=true yarn update-registry`
211
-
212
-
### Steps to add your metadata in registry
213
-
214
-
## Prerequisites
215
-
216
-
1. A sfdx project must exist in local `sf project generate --name <projectname> --default-package-dir <directory> -x`
217
-
1. An authorized devhub org must exists `sf org login web -a <alias> -r <localhost url> -d`
218
-
1. A scratch org must exists with alias `registryBuilder`
219
-
1. Update `project-scratch-def.json` as per your requirements
220
-
1. Run `sf org create scratch -f config/project-scratch-def.json -a registryBuilder -d`
0 commit comments