gorillamoe / AutoRemoteSync.nvim

A Vim/Neovim plugin to automatically upload files via rsync or sftp to a remote server when you write the contents of a buffer to disk.
MIT License
3 stars 0 forks source link

Upload files, that was changed but withour saving buffer? #1

Open seriiserii825 opened 3 months ago

seriiserii825 commented 3 months ago

Hi, i has a project. that works with vite. And when i changed scss, and save file, that it's ok, file uploaded to server. But i need to call yarn build, than another compiled files, like my.css will change, but without saving buffer manualy, and this file will not uploaded.

May be to add an watcher?

Thansk for you plugin

gorillamoe commented 3 months ago

Ye, totally can implement that, if you're using neovim 0.10.0+

seriiserii825 commented 3 months ago

What you mean?

seriiserii825 commented 3 months ago

I wrote a script and run afte build

sftp_config_file_json=".AutoRemoteSync.json"
if [ -f $sftp_config_file_json ]; then
  echo "File $sftp_config_file_json exists."
  host=$(jq -r '.remote.host' $sftp_config_file_json)
  user=$(jq -r '.remote.user' $sftp_config_file_json)
  remote_path=$(jq -r '.remote.path' $sftp_config_file_json)
  modified_files=$(git ls-files --modified)
  for file in $modified_files; do
    echo "${tblue}file: $file${treset}"
    full_path=$remote_path/$file
    echo "${tgreen}full_path: $full_path${treset}"
    rsync -avz -e ssh $file $user@$host:$full_path
  done
else
  echo "${tmagenta}File $sftp_config_file_json does not exist.${treset}"
  echo "${tyellow}Please create a file $sftp_config_file_json with the following content:${treset}"
  exit 1
fi
num8er commented 2 days ago

@gorillamoe I think I would be nice to have ability to run shell script on save. Something like "runAfterUpload": "relative/path/to/script.sh" which will execute shell script on remote machine.

P.S. it's not related to main question to upload without saving, I also would disagree to have such feature. It's unsafe to do that for different security related reasons.

I wrote a script and run afte build

sftp_config_file_json=".AutoRemoteSync.json"
if [ -f $sftp_config_file_json ]; then
  echo "File $sftp_config_file_json exists."
  host=$(jq -r '.remote.host' $sftp_config_file_json)
  user=$(jq -r '.remote.user' $sftp_config_file_json)
  remote_path=$(jq -r '.remote.path' $sftp_config_file_json)
  modified_files=$(git ls-files --modified)
  for file in $modified_files; do
    echo "${tblue}file: $file${treset}"
    full_path=$remote_path/$file
    echo "${tgreen}full_path: $full_path${treset}"
    rsync -avz -e ssh $file $user@$host:$full_path
  done
else
  echo "${tmagenta}File $sftp_config_file_json does not exist.${treset}"
  echo "${tyellow}Please create a file $sftp_config_file_json with the following content:${treset}"
  exit 1
fi