xixiaofinland / sf.nvim

22 stars 6 forks source link

Feat: Adds Push/Pull Delta Commands #54

Closed waltonzt closed 2 months ago

waltonzt commented 2 months ago

Addresses #53

Adds commands push_delta and retrieve_delta.

push_delta: Runs the sf command sf project deploy start without specifying a specific file to deploy.

retrieve_delta: Runs the sf command sf project retrieve start without specifying a specific file to retrieve.

If source tracking is enabled in the org then these command will only deploy/retrieve the delta. If source tracking is not enabled then calling this command will deploy/retrieve all files.

Updates documentation with new commands.

I did not add any default keybindings to this pull request. If you want to add them I was thinking something like this.

 vim.keymap.set('n', '<leader>sR', sf.retrieve_delta, { desc = '[R]etrieve Remote Changes from target_org' })
 vim.keymap.set('n', '<leader>sP', sf.push_delta, { desc = '[P]Push Local Changes to target_org' })

Let me know your thoughts!

xixiaofinland commented 2 months ago

I just tested with SF v2.41.8:

  1. sf project retrieve start throws an error when source tracking is not enabled.
  2. sf project deploy start deploys all local metadata (I have 1400+ items locally) into the target org.

Point 2 is odd. I don't think it's a good fallback action for an org with no source tracking enabled. An error should be expected. I'm not sure why the SF CLI team implemented this way.

Your keybinding suggestions (sR, sP) make perfect sense, though I won't add them for now due to the above-mentioned concern.

Another point as an FYI: The help.txt is auto-generated from the init.lua file by the mini.doc plugin. Comments with --- above each function are automatically pulled into help.txt.

I will reword the new function doc and include them. Thanks again for the PR!

xixiaofinland commented 2 months ago

question: do you use the main branch of this repo or your own forked version in your setup? @waltonzt

waltonzt commented 2 months ago

@xixiaofinland Interesting. I can add some error handling for point 1. I definitely agree with your assessment about SFs design choice. I read an interesting issue about that choice. It seems like some users don't agree with the choice to combine.

Thanks for the info about the help.txt file! I didn't know that.

I forked the repo and am using that forked repo in my neovim config while I am working on development towards the plugin

xixiaofinland commented 2 months ago

@waltonzt thanks for the info!

I attempt to learn how to build this repo general enough that ppl are happy to use/trust it as the baseline rather than forking away (not that forking is bad, I simply wish to learn and practice the skill of creating a lib).

How far are you with your fork and what's your main reasons if I may ask?

xixiaofinland commented 2 months ago

@xixiaofinland Interesting. I can add some error handling for point 1

It's ok and it's SF's design. We invoke the exact sf command and mention precisely in the doc, that's good enough.

Also, not sure if you know the integrated terminal can run any commands, so users are free to invoke whatever cmds including sf ones. https://github.com/xixiaofinland/sf.nvim?tab=readme-ov-file#%EF%B8%8F-integrated-terminal

For example, users can define vim.keymap.set('n', '<leader>sR', require'sf'.run('sf project deploy start'), { desc = '[R]etrieve Remote Changes from target_org' }) to achieve the same