Closed pranaymistry closed 5 years ago
@lcampos I assume this is because we are using the context of current file as the file that is being right clicked on rather than the file that is actually open. This isn't strictly a bug, but rather a new use of the command. Is there a better way to identify the current file that would make this command work in both our current situation and this one (which i am assuming to mean the currently open file).
@ntotten @lcampos thanks a lot for the quick response, I am basically looking to replicate Mavensmate behavior of "Save and Compile" in one action. So, when I save my file, it gets compiled and gets deployed to my Sandbox.
Yeah, we actually have that feature planned very soon as well. ;)
Thanks for reporting this @pranaymistry, the issue lies in that this command (as well as a few others) takes an argument to be able to run. In this case that argument is the file path of the opened file or folder you want to deploy.
There are a couple of ways we can address it but will discuss it with the team first and update this thread right after.
Thanks a lot @lcampos and @ntotten for following up on this issue. Will eagerly wait for your next update.
One of my colleagues found a good way to do this:
Output: hit "cmd+shift+b" (in MacOS), it will do 1) save 2)sfdx deploy current file
Steps
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "ssave",
"type": "shell",
"command": "sfdx force:source:deploy -p ${file}",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
}
]
}
@ntotten @lcampos Dug around a bit and saw the error was caused by line 49 in https://github.com/forcedotcom/salesforcedx-vscode/blob/develop/packages/salesforcedx-vscode-core/src/commands/forceSourceRetrieve.ts
Changing the constructor from this,
public constructor(explorerPath: any) {
this.explorerPath = explorerPath.fsPath;
}
to,
public constructor(explorerPath: any) {
this.explorerPath = typeof explorerPath !== "undefined" ? explorerPath.fsPath : vscode.window.activeTextEditor.document.uri.fsPath;
}
seems to do the trick.
Would like to know any possible downsides to this fix. Thanks.
@ntotten @lcampos Dug around a bit and saw the error was caused by line 49 in https://github.com/forcedotcom/salesforcedx-vscode/blob/develop/packages/salesforcedx-vscode-core/src/commands/forceSourceRetrieve.ts
Changing the constructor from this,
public constructor(explorerPath: any) { this.explorerPath = explorerPath.fsPath; }
to,
public constructor(explorerPath: any) { this.explorerPath = typeof explorerPath !== "undefined" ? explorerPath.fsPath : vscode.window.activeTextEditor.document.uri.fsPath; }
seems to do the trick.
Would like to know any possible downsides to this fix. Thanks.
open source shows the power in SF world :)
Hi @sivabalan that is a great starting point. We've started to talk internally on how to address this for a number of commands and situations since the commands can be used from different places (right-click a folder/file in File Explorer, right click on open file, keyboard shortcut) and with different attributes (the same piece of code is used for a single file or a collection of files).
For the scenario where the path is undefined, we are thinking of the following flow:
SFDX: Create Apex Class
).If you feel like opening a Pull Request for this, given you've already made progress on your side, we'd be happy to collaborate with you in getting it merged.
cc @ntotten
+1 on fixing this
+1 here too. I am trying to get into using VS Code, but these minor annoyances keep me away for now.
I commented this text at issue Deploy on Save #577. Just want to duplicate here for you to pay attention.(no offence) if you want you can delete them)
Please , could you do deploy on save. (I should press ctrl+save then with mouse choose file from left sidebar and right click and choose to deploy source to org. and repeat it every time I want to deploy) - that's a nightmare.)
Note: I am dealing with not scratch org. I develop against any org(simple). Thats my case for now. VSCode version is latest and salesforcePack version is latest.
Now I made a shortcut(ctrl+d) to deploy current open file . BUT it also doesnt work. it writes to me Cannot read property 'fsPath' of undefined.
Please look at these two bugs (which prevent me and many others not to use vsCode and this SF plugin).
Thanks for your project and work.
Hi @NikitaChizhik, no offense taken. As an update, we currently have a change under review that will auto deploy/push code when a change is saved. We found some issues while testing it in Windows OS which we're currently sorting out. Once that's addressed and the review is approved it'll go out and be available for everyone. We'll keep this thread updated.
Save on deploy is going out in our next release.
Do you have an idea of when this will be available? Thanks ahead of time!
Hi @ntotten,
Thanks for the update, just want to clarify, is it save on deploy or deploy on save. So when you save the file by using Cmd + S, the file will be deployed to Salesforce first and then saved on your local, correct?
Regards, Pranay
@pranaymistry it should be deploy on save, it's a combination of saving it locally and deploying it to server at the same time. I am pretty excited with this fix..
Thanks @jfaderanga, I too am very excited with this fix. This was the only hurdle for us rolling out VS Code as the preferred Salesforce Development IDE to our clients. Does anyone have a date for this fix going live?
@dujsu, @pranaymistry we released some fixes to deploy on save based on the feedback we received, the latest changes are part of version 44.18.0 of the extensions.
To enable it, set the salesforcedx-vscode-core.push-or-deploy-on-save.enabled
setting to true
in either your user or workspace settings. More info can be found on Develop Against Any Org in Visual Studio Code (Beta).
Hiya folks, I stumbled onto this when I was having the same problem. One point and one question.
The 'Push-or-deploy-on-save' shows Enabled even though I had not yet enabled it. In the JSON, it was false.
Also, I'm curious as to why saving via the Tooling API isn't an option. In the ol' Mavensmate days, or HaoIDE, which was my preferred Salesforce IDE that no one seems to know about... when you Save to Server rather than Deploy, you'd be warned if you weren't the last one to save said file... and it was also a bazillion times faster. What was the rational behind going with deploy vs save?
Thanks very much. Keep up the great work! cc @lcampos
@lcampos thanks for the fix bro!..how can we adjust the auto deploy time delay after we save it using the shortcut? the default at the moment is like 5 seconds before the auto deploy kicks in....can it be real-time after save?
I've updated my CLI and Plugins, and I thought I setup shortcut key correctly but unfortunately still getting the same error.
Cannot read property 'fsPath' of undefined
What is strange is if I right-click and select the same command it works as expected:
@Xtremefaith you don't need to set binding key once you set the salesforcedx-vscode-core.push-or-deploy-on-save.enabled settings to true, it's automatic..
I don't want it to be automatic, I want the ability to save and deploy when I feel it is appropriate. Also does this then deploy just the file or does it deploy the directory?
@jfaderanga regarding the deploy on save time delay. That's currently not configurable but we've been discussing how useful it would be to allow it to be. If you're interested in that functionality/feature I'd suggest you open a separate issue so we can have a thread specific for that.
cc @ntotten
hi @dc7380 , regarding the push or deploy on save showing enabled, this is because of a convention that the new vscode settings UI follows. It takes the name of the setting definition and "breaks" it in a way that for our setting might look like it's enabled. Our setting is named salesforcedx-vscode-core.push-or-deploy-on-save.enabled
, which the UI then takes the push-or-deploy-on-save
part to be the first, grayed out text at the begining and then takes the last part of the string, enabled
and sets is to white bold. If this is confusing I'd suggest opening a separate issue and we'll take a look at updating the name but that could break people's existing settings.
Regarding alerting the user of existing potential conflicts before deploying. That functionality is already available if you are using source:push
which is exclusive for scratch orgs. If you are using source:deploy
, which would mean working with non-scratch orgs, then we are currently working on a feature for it and can follow the specs/updates or post suggestions on the #971 open issue.
Last thing, the lack of tooling api usage. This is mainly because of current limitations in that api. It has limited metadata coverage, meaning you can only use it for a subset of the metadata that we support. Having said that, we are actively working on making things faster and do not discard it's usage in the future if it provides the performance and coverage we're looking for.
@lcampos Thank you for your very complete answer!
hi @Xtremefaith, using a keybinding for existing deploy commands won't work because of limitations on how to define it and the commands depending on a filepath to be provided. We explored the possibility of changing the commands to show a quick-pick option, when no filepath was provided, and then choose the file/folder you wanted to deploy. We discarded that because of how unmanageable it became when working on medium-to-large projects and decided to invest time in releasing the current deploy on save functionality. If this is something you really want I'd suggest opening a feature request (a new issue) for it.
As to how deploy on save works, it deploys only the file that you save. E.g. if you are modifying an apex class and save it, it will wait for a few seconds to see if you're done editing it and will then deploy the file.
Passed 4 months and the "bug" exist yet, @Xixiao007 gave the perfect solution for this problem: https://github.com/forcedotcom/salesforcedx-vscode/issues/662#issuecomment-439354751
Why SF don't update it yet :(?
The issue has been closed. At this time, we don’t plan on addressing this. Save on deploy should solve this use case.
If you want your product to be useful for sf developers, listen to them. Otherwise, we will not use it. I, for example, is almost ready to switch to another IDE from VSCode because of such bugs. Sorry but true.
@NikitaChizhik Does deploy on save not resolve this for you? My understanding is people were using this as a workaround for another missing feature. As many people requested the feature, we added it and it has been available for some time.
You can find instructions here: https://forcedotcom.github.io/salesforcedx-vscode/articles/user-guide/org-development-model#deploy-source
To deploy files each time you save them, set the user or workspace setting
salesforcedx-vscode-core.push-or-deploy-on-save.enabled
to true.
push/deploy on save is not a viable alternative for many, including myself. Many plugins can cause the file to save (such as editorconfig), plus many people have a habit of frequently saving their code, way before its compilable and ready to push to an org.
Deploy on save is a good feature for those that want it, but it is not really a reliable alternative to having a shortcut that ONLY deploys, when the developer is ready.
Just my opinion of course!
@JamieBriersSageCom Makes sense, thanks for the explanation. I will reopen for us to implement or to accept a PR.
Yes, this would be a great add as an alternative to deploy on save. Thanks so much for reopening this issue.
@lcampos Hiya, just a quick follow up re the tooling API. While I get that it doesn't support all metadata types, you should definitely consider enabling it just for those types that it does. Though I'm sure you have.. You guys know what you're doing. (I'm kind of an idiot..)
Anyhoo.. I have recently installed the SalesforceDX Code Companion extension. It uses an sfdx plugin he built which provides new commands to save/retrieve using the Tooling API, and I've gotta say... it's now all I use (for Apex anyway).
1) It's super-quick 2) He returns a diff with the option to overwrite
Ctrl-shift-c for the win. Now, I'm happy. I was honestly having a hard time being productive with the deploy to save.
Just my experience...
Anyways, keep up the great work guys!
I agree here .I got so frustrated with speed I got that I built one using the tooling API version .Salesforce should definitely consider the approach I took or give us a time line when speed by which we save to server should be improved .
The speed is not related to the Tooling API vs Metadata API. We are working to improve the perf and will have updates coming over the next few months, but both APIs are exactly the same on the backend. It is more about how they get called (Sync vs Async) and a few other factors.
@ntotten I agree that both might look same on backend but having experimented with both APIs we do see when it comes to push simple changes to apex , aura , vf or lwc via tooling rest api they somehow take almost 0.5x less time than the other. The fact that we have to wait so much to push a simple change of apex class to server makes me inefficient as a developer . We never had this performance issues when we used Mavensmate , eclipse or even other vscode extensions for salesforce (like forcecode, mavensmate). I can understand that fixing the root cause will be permanent solution but for now i was almost blocked without building something like this .
Agree with above - I have use cases where I want to save (to track to git or get past linter) but not compile to server just yet. I am using "right click deploy" workflow for now and this would solve for my use case.
Well I think its how it was built if you want a real rapid development I think you may want to consider offline development..
On Tue, 5 Mar 2019 at 2:29 PM, James notifications@github.com wrote:
Agree with above - I have use cases where I want to save (to track to git or get past linter) but not compile to server just yet. I am using "right click deploy" workflow for now and this would solve for my use case.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/forcedotcom/salesforcedx-vscode/issues/662#issuecomment-469497445, or mute the thread https://github.com/notifications/unsubscribe-auth/AOqbILRY51T3j1j94XW0oUvDmaz2p0ulks5vTciNgaJpZM4XKVU_ .
+1 on this issue. I can see a pull request waiting to be approved, hopefully it will be released soon so we can optimise our workflows. Huge thanks to the devs who are working on the fix.
This is fixed and has been released. Please reopen if you have any issues.
it works! thanks a lot! now the dev process will be much more faster)!
oh my! thanks for the hardwork mates!
On Sun, Apr 7, 2019 at 1:01 AM Nikita Chizhik notifications@github.com wrote:
it works! thanks a lot! now the dev process will be much more faster)!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/forcedotcom/salesforcedx-vscode/issues/662#issuecomment-480498535, or mute the thread https://github.com/notifications/unsubscribe-auth/AOqbII32CnR47wc0hDYH-OxZs5ch2PQ1ks5veIyBgaJpZM4XKVU_ .
This issue appears to be broken again. I updated VSCode today and it now gives me the same error. Was working previously.
This issue appears to be broken again. I updated VSCode today and it now gives me the same error. Was working previously.
You are not alone, same thing happening here. Right-clicking the file and selecting the deploy option still works though.
Same here.
Same
I started getting this error today too. Yesterday it worked fine. I had to disable deploy on save and right click on a file to deploy.
I added a custom keyboard shortcut to deploy current file using "sfdx.force.source.deploy.current.file" command
One of our business requirements is to figure out a keyboard shortcut that can do Save and compile of Apex classes from VSCode while doing ORG based development. This is very important for us to roll out VSCode and drive adoption of its use for Salesforce development. This feature is currently not available in VSCode and hence I tried adding a keyboard shortcut for the sfdx command but I am running into an issue.
Steps To Reproduce:
[ { "key": "shift+cmd+r", "command": "sfdx.force.source.deploy.current.file" } ]
Expected result
The file should have been deployed
Actual result
VS Code Version:
SFDX CLI Version:
OS and version:
Other Commands just work perfectly fine, for e.g.
[ { "key": "shift+cmd+r", "command": "sfdx.force.org.open" } ]