I am using Visual Studio Code on MacOS with sfdx (Salesforce Extension Pack) to develop Lightning Web Components on MacOS. I find that the normal command-shift-P SFDX: Deploy This Source to Org randomly fails when run for a single file in the LWC. Instead you need to right-click on the LWC's folder and then select the picklist item SFDX: Deploy Source to Org. Then it succeeds.
This picklist item is immediatly below SFDX: Delete from Project and Org which is stupid and causes endless nerves whenever I need to upload a delta (frequent since this is UI code).
I would like to create a new keyboard shortcut (and maybe toolbar icon) that runs SFDX: Deploy Source to Org, only for the folder enclosing the open file. Not for the entire project, which might include downloaded objects or libraries that I don't really want to update and would also take more time to upload. How can I create a new shortcut? Do I have to research how to create a new extension of my own?
FYI I did try adding a keyboard shortcut in the Preferences > Keyboard Shortcuts screen for SFDX: Deploy Source to Org. But I get these errors, same as I was getting on single file upload:
- Cannot find Lightning Component Bundle xxx. (where xxx is the folder name)
- duplicate value found: duplicates value on record with id: I get 2 of the first error. The second error (duplicate value found) is a famous one for deployment errors, and it shows up for a file that actually has only comments in it. Ugh. Also when I try the new shortcut after clicking on the lwc's folder name, I get this nasty error:
- Error deploying or retrieving source: The file or directory that you tried to deploy or retrieve isn't in a package directory that's specified in your sfdx-project.json file. Add this location to your "packageDirectories" value, or deploy or retrieve a different file or directory. For details about sfdx-project.json, see: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm
Of course adding the lwc's path does not fix the error..
A keyboard shortcut would be best. Ultimately having also a new icon in VSCode would be nice, and for fun one day, hooking up an external button device or custom keypad would be the cherry on top! ;)
The VSCode extensions installed are: Salesforce CLI Integration, Salesforce Diff, Salesforce Extension Pack, Salesforce Package.xml Generator, SLDS Validator.