sftp-live-update
This tool allows you to work on a local copy, listen to change in order to instantly send them to a remote
SFTP server. Also you can run a command via SSH on the server & configure proxy.
Use case & Genesis
When I work hard on a project with database inside docker, backend and multiple front end,
my laptop said something like "I don't get paid enough for this bullshit" and it starts to grumble.
Lucky as I am, I have an unused linux server at my home. With sftp-live-update
I will show you
how I use this server to run my backend project while I'm still working on my local copy.
It allows me to save my precious memory on my computer.
Feature
- 🚀 Automatically send update on an SFTP server
- 👻 Setup a proxy from localhost to your server
- ✈️ Run a command directly after upload by SSH
Requirements
- Obviously an SFTP / SSH server
- A folder to watch : in my case a nodejs project
Installation
yarn global add sftp-live-update
Usage
Create a config file (json):
{
"sftp": {
"host": "your sftp host",
"port": 22,
"username": "your sftp user",
"privateKey": "/Users/gtaja/.ssh/id_rsa",
"passphrase": "your passphrase",
"password": "your password",
},
"watchDir": "directory to watch in your laptop",
"targetDir": "directory to target in your Watcher server",
"ignore": [
"/node_modules",
"/dist",
"/.git",
"/.idea"
],
"proxy": {
"targetPort": 3000,
"localPort": 3000
},
"commands": [
"yarn install",
"yarn start:dev"
]
}
Run sftp-live-update <config>
(make sure you have add yarn binary to PATH export PATH="$(yarn global bin):$PATH"
)
WARNING: This will update every files in your Watcher server under the targetDir, make sure this dir doesn't
contains important things.
Tricks: running sftp-live-update
without config file will look in the file .sftp-live-update.json
For my use case, with the configured proxy & commands, I just run sftp-live-update
and my app is
running on my server with the same confort as on my device (it's so good to use localhost
to target the
remote server) !
Enjoy ;)