Replies: 10 comments 11 replies
-
@mshanemc -- Just level setting on terms:
|
Beta Was this translation helpful? Give feedback.
-
I have some PTSD about a "full org retrieve" and how useful this feature will be. Most admins and developers think of Custom Objects, LWCs, Apex Classes and a few other things as being "their work" but the moment you do the full org retrieve, you get a million metadata types and a million records within those metadata types that are part of the happy soup that no one understands. Further, some of those metadata types don't roundtrip well, or at all, (per your point about the known MDAPI bugs) so it will be a heavy lift to filter out the ones that AREN'T relevant or material to the project. As a somewhat relevant example: We try to pull the Settings metadata (using the * wildcard) from orgs at the beginning of each new Release Preview window so that we can apply the Release Updates in our scratch orgs so that developers can test with those Release Updates turned on. The exact same metadata that is retrieved from a I sympathize with the "Why?" on this feature proposal but I don't know how useful the final feature will be for any org of moderate complexity. |
Beta Was this translation helpful? Give feedback.
-
This is already possible today using sfdx diff. 1- connect org A to sfdx project How will this be different? |
Beta Was this translation helpful? Give feedback.
-
Would be great if we could get some 👀 on forcedotcom/salesforcedx-vscode#4162 to mitigate some of the potential false positives that folks would receive because of style-linting, particularly with Prettier. Would love to leverage this but in our case most if not everything that we have Prettier format would likely result in a false positive. |
Beta Was this translation helpful? Give feedback.
-
I'd love to see this become built-in. This process is exactly how we do our production deploys and have so for several years. Some things I'd like to see added though, I don't just want to target an org. If the CLI is going to have the ability to diff metadata I'd like to provide a local copy of metadata (in either format because I do see the benefit of not converting what comes out of the Metadata API). This is because I use cached copies of the org's current metadata to speed up CI evaluation. Imagine executing a deployment to a Sandbox but running that deployment in validation-only, the export could be relied upon to be reusable and would only need to be updated as often as you complete a proper deployment, speeding up CI actions by several minutes or more. XML ordering is interesting. I think we should be able to, at a CLI/MDT Registry level, understand where ordering doesn't matter (default to it does matter to lower risk). CustomLabels are an example of something that can deploy a lot of unnecessary changes if even a single entity changes and the ordering doesn't matter. Custom Objects are something where partial deployments are possible but depending at what layer you perform you diff calculation, you could be causing a LOT of overhead and redeploy. I think Deletes in the target org is something to be taken very carefully, possibly even off by default. There are some Metadata types, or even pattern matching names, that should or should not be deleted, varying by individual. Not all things will be tracked and deleting things you found in the org that are NOT found in source could get you in trouble if you're not confident in the correct choice. In my prod org we have ListViews that we track and some that we don't. Instead of fine-tuning our I know there are several comments all wrapped up here. I have a terrible code base that does a lot of this inefficiently and using some very old ideas but it works well enough that I'm happy to share if that helps. |
Beta Was this translation helpful? Give feedback.
-
It would be also nice to have an option to limit to packageDirectory(s) |
Beta Was this translation helpful? Give feedback.
-
@mshanemc This is an awesome feature and I am really excited about it! Making the org look like the project is super helpful and should be the de-facto deployment mechanism for unpackaged metadata as it will enable auto-destructive changes and support actual rollbacks to a prior commit ( 🥳 ). This is a very necessary step in the direction of source driven development instead of selective delta modifications of a project. We have built a tool like this internally to make the org match the project and there are a lot of nuances/gotchas to watch out for: Any diff is treated as a delta as you mentioned, but this is particularly challenging when your team uses the Apex prettier code plugin. This plugin appends a new line at the end of each class file which won't be there upon retrieval from Salesforce - therefore every Apex class in your org will show up as a false positive of a difference. Can we insert a post retrieve, pre diff-generation hook for performing formatting or other CLI scripting to remediate such false positives? There are some metadata types with "composite" XML representation - where one single file contains multiple pieces of metadata. Custom Labels and Workflow files are the two most notorious offenders of this. In these files, sometimes the ordering can get a little bit out of sync, especially if the XML is modified by hand as it often is on super large projects with many workflow rules/actions. A strict character by character file diff here is extremely likely to produce a false positive of a diff here, so what we do is parse the XML into an object in memory and perform the comparison on the object's properties. This has proved to be a helpful tactic for XML based comparison. There are also some special character things to watch out for. Some metadata files have their values encoded - ex Another thing we have done which is really nice is the definition of a |
Beta Was this translation helpful? Give feedback.
-
@mshanemc Parse the contents and you have all diff files needed to send from your local to an org Proposed solution seems to be the case for using a third party as GitHub CLI, this reduces maintenance as well. |
Beta Was this translation helpful? Give feedback.
-
@VivekMChawla @mshanemc any additional traction on this idea? It's very unfortunate that customers have to do gymnastics just to identify what to deploy - especially for orgs above the 10k metadata component limit. Parsing git diffs and manual assembly of |
Beta Was this translation helpful? Give feedback.
-
I'd like to thank everyone for contributing to this discussion. Due to other priorities, we won't be moving forward with this idea at this time. Rationale:
We'll periodically review this idea to determine if future MDAPI/CLI changes make implementation and support more feasible. |
Beta Was this translation helpful? Give feedback.
-
Align metadata between orgs and/or projects
Use cases
Why (examples)
Relationship with source tracking
Design Proposal
Rationale
.forceignore
is automatically handled consistently. ex: a full retrieve shows includes Profiles in the generated manifest, but the user has Profiles in.forceignore
No profiles are retrieved/deployed/deleted/modified.Limitations
Usage/Examples
Make a newly created project match an org
What’s in the output folder?
sf project retrieve start -x diff-1680528024/package.xml -o username@target.org
(username is always specified for portability, even if the given command uses a default org or an alias)Alternatives/enhancements:
project generate
command for a better experience when starting a project with an existing org. This could also attempt to create the scratch-org-def.json based on the org’s settingsMake an org match a project
imagine the org has some metadata that the project does not
What’s in the output folder?
sf project deploy start -x diff-1680528024/package.xml --post-destructive-changes diff-1680528024/destructiveChanges.xml -o username@target.org
Make a project match an org
imagine the project has some metadata that the org does not
What’s in the output folder?
sf project retrieve start -x diff-1680528024/package.xml -o username@target.org
rm force-app/main/default/classes/foo* force-app/main/default/lwc/cmpYouNeverDeployedButForgot
Make an org match another org
This is a two-step operation conducted “through” the local project.
sf project diff --modify project --target-org orgToCopyFrom
sf project diff --modify org --target-org destinationOrg
Alternatives considered
project diff
command output an entire retrieved project from the “source” org into the output dir in mdapi formatThe proposed design is simpler (re-use of the command) and has the positive side effect
If the user wants to diff 2 orgs without modifying a real project locally, they would create an empty project.
Beta Was this translation helpful? Give feedback.
All reactions