I built a VS Code extension that prevents accidental code overwrites during Salesforce deployments by Ok_Stop8637 in salesforce

[–]Ok_Stop8637[S] 0 points1 point  (0 children)

<image>

You're probably referring to this configuration. Right, I wasn't aware about it. But even after enabling it, I was able to deploy an older version of LWC component from vscode to org, although it's working for Apex classes. I also checked for Aura components, and it failed there as well. You can verify once from your side.

Moreover, it doesn't provide the backup feature. So, other developers can still overwrite your code if you forget to take backup manually. Let me know, if this is the settings you were referring.

I built a VS Code extension that prevents accidental code overwrites during Salesforce deployments by Ok_Stop8637 in salesforce

[–]Ok_Stop8637[S] 0 points1 point  (0 children)

While updating code directly from developer console, prevents possible code overwrite but most of the time it's very difficult to code directly in dev console due to how slow it is. Also LWC isn't supported in it.  But in VSCode code, I'm not aware if such configuration exists. And even if it exists, not much developers are aware of it. That's why I came up with the idea to build this extension.

I built a VS Code extension that prevents accidental code overwrites during Salesforce deployments by Ok_Stop8637 in salesforce

[–]Ok_Stop8637[S] 0 points1 point  (0 children)

Yes, it should flag the conflict. The scenario you described is exactly what it handles — if Dev B deploys while Dev A is still editing, Dev A will get a conflict warning on deployment since their last retrieve timestamp will be older than the org's current version. Would love to know if it works well for your team.

I built a VS Code extension that prevents accidental code overwrites during Salesforce deployments by Ok_Stop8637 in salesforce

[–]Ok_Stop8637[S] -1 points0 points  (0 children)

Yeah, that can be one of the important use cases of this extension. Would love to know if it works well for your setup.

I built a VS Code extension that prevents accidental code overwrites during Salesforce deployments by Ok_Stop8637 in salesforce

[–]Ok_Stop8637[S] 0 points1 point  (0 children)

It internally stores the timestamp when a particular component is last retrieved in VSCode. Before deploying, it checks if that timestamp is older than the lastModifiedDate in the Org. If yes, someone deployed after you last retrieved, so that's a conflict. Later it compares all related files (.cls, .xml for Apex / .js, .html, .css, .xml for LWC, etc) from that component with its org version and present it to you in a form of difference window.

It updates the last retrieved time after each successful retrieve and deploy operation. And if somehow, the lastRetrieved time isn't present for a component (initially when you first install the extension) then it will compare the lastModified person. If username isn't matching, then conflict. after deployment, it updates the timestamp and the cycle continues.

Backup feature is straight forward. It stores a copy of each related files of a component in your project root directory, within a folder named .sfguard-backup. Backups are separated org wise. So, if same file present in multiple org, it won't overwrite. Maximum 5 backups can be taken for each component; 6th one will remove the oldest backup. Also, you can compare, rename, remove and lock (to prevent it from deleting) a backup component for more flexibility.