How can you delete components from a local project to match what is in SF org?

274 views
Skip to first unread message

gr...@silverlinecrm.com

unread,
Sep 27, 2017, 12:41:08 PM9/27/17
to Illuminated Cloud General Discussion
I feel somewhat silly asking this but how are you supposed to delete components that are in your project locally but have been deleted from Salesforce. Neither refresh nor retrieve metadata seem to delete the components from your local project.

What I'm really looking for is the equivalent of the MavensMate "Clean project" command.

sc...@illuminatedcloud.com

unread,
Sep 27, 2017, 1:02:06 PM9/27/17
to discu...@illuminatedcloud.com
Greg, there's not really a distinct "clean project" action in Illuminated Cloud, but here's how I approach reconciling what's on the server and what's local:
  • Run Retrieve Metadata>Retrieve for Merge with either Module or Project contents.
  • In the resulting directory diff, I look for orphans on both sides. FYI, I use Beyond Compare for this as an external diff tool in IntelliJ, by the way. For me it makes it much easier to visualize directory- and file-level differences. 
  • Orphans on the left represent metadata that's in the org but not local. If it's something that I should have, I just copy it left-to-right in that directory diff. If not, I perform a Delete action once I wrap up the current Retrieve for Merge. I'll get back to that below.
  • Orphans on the right represent metadata that's in the local filesystem but not in the org. If it's something that I should have, I perform a Deploy action once I wrap up the current Retrieve for Merge. Again, I'll include that step below. If it's not, I delete those file(s) from the local filesystem right in Beyond Compare.
  • I also look at non-orphan differences from the server and determine which need to be merged into the local filesystem (and exactly how since it's often not just a full replacement). Again, I personally prefer how Beyond Compare shows these file-level differences.
  • Once that's done, I close the diff window.
  • If there were local orphans that needed to be deployed, I make sure they're in my metadata subscription and deployment them.
  • If there were server orphans that shouldn't be in the org, I start a Delete Metadata action with only Server Only checked so that I can see things that are in the server but not local and may fall outside of my metadata subscription.
It may seem onerous, but it's complete. I've used this recently to clean out some quite important orgs based on a number of far-reaching changes to the metadata. And obviously you don't have to do all of this every time. I'm describing my full process when I know there are items that need to be cleaned up on both sides and I want to be very careful when removing those.

I hope this helps!

Regards,
Scott Wells

sc...@illuminatedcloud.com

unread,
Sep 27, 2017, 1:09:41 PM9/27/17
to Illuminated Cloud General Discussion
Here's an example of Beyond Compare in response to a Retrieve for Merge configured to show orphans only:



In this case I'd probably decide that I want ApexDocExample and UnresolvableReferenceTest locally, should deploy formRenderer.js to the server, can remove ServerOnlyClass from the server, and can remove LocalOnlyClass locally. I'd copy the first two left-to-right and delete LocalOnlyClass.cls* in the right pane from within Beyond Compare, then I'd deploy the form Lightning component and delete ServerOnlyClass from the server.

Hopefully that makes it more concrete.

Regards,
Scott

gr...@silverlinecrm.com

unread,
Sep 27, 2017, 1:39:12 PM9/27/17
to Illuminated Cloud General Discussion
Hi Scott,

Thanks for the quick and thorough response! Based on that workflow it does sound like I would need to go through the merge/diffing process and select all the files I want to delete locally. I actually use GIT through the command line for all this currently and don't really use the built-in diff/merging capabilities of IntelliJ.

Is there any way to disable this such that refreshing the metadata for a selected project/folder will just blow away what is in the local project?


sc...@illuminatedcloud.com

unread,
Sep 27, 2017, 1:46:17 PM9/27/17
to Illuminated Cloud General Discussion
There's not really a notion of "reset to server". I've heard others ask for it, though. If it's something that interests you would you mind logging an enhancement request in the issue tracker with details on how you'd like to see it work?

Regards,
Scott

dougla...@gmail.com

unread,
Oct 12, 2017, 10:37:22 PM10/12/17
to Illuminated Cloud General Discussion
I was used to the "project clean" feature in MavensMate, but what I do with IC is:

1. Ensure I've committed my local changes to git
2. Delete the src folder
3. Do a project retrieve from the org. Now my local has everything exactly from the org and no residue from my local.
4. Use source control to compare what might have been overwritten or deleted, if I care then restore from git
Reply all
Reply to author
Forward
0 new messages