rploy

Minimal rsync deployment

Usage no npm install needed!

<script type="module">
  import rploy from 'https://cdn.skypack.dev/rploy';
</script>

README

rploy đźšš

Minimal rsync deployment

Usage

npm i rploy -D

Add source and destination options to your package.json:

{
  "rploy": {
    "source": "public/",
    "destination": "user@ip:/var/www/public/"
  }
}

Deploy:

npx rploy

Config

rploy wraps node-rsync, so you can pass any relevant options to configure flags, progress, excludes, etc. Here is an example:

{
  "rploy": {
    "source": "public/",
    "destination": "user@ip:/var/www/public/",
    "exclude": [
      ".DS_Store",
      "Icon",
      "node_modules",
      ".git"
    ],
    "progress": true
  }
}

Branches

When deploying git repositories, rploy offers a branches option, which provides a way to be explicit about a destination for each branch:

{
  "rploy": {
    "source": "public/",
    "branches": {
      "master": "user@ip:/var/www/prod/public/",
      "dev": "user@ip:/var/www/dev/public/"
    }
  }
}

You will now be notified of your current working branch and the destination:


This provides an easy way to prevent issues like accidentally deploying your staging branch to production. It will always check your working branch and look for a deploy context. You can even pass node-rsync options into each branch, to get even more granular:

{
  "rploy": {
    "source": "public/",
    "branches": {
      "master": {
        "destination": "user@ip:/var/www/prod/public/",
        "exclude": [
          "readme.md"
        ]
      },
      "dev": {
        "destination": "user@ip:/var/www/dev/public/",
        "delete": false
      }
    }
  }
}

Tips

  • I recommend adding your ssh key to the server you are deploying to, for easy passwordless auth.
  • Use a lifecycle script to build assets before a deploy:
{
  "scripts": {
    "build": "parcel src/index.js",
    "deploy": "npx rploy",
    "predeploy": "npm run build"
  },
  "rploy": {
    "source": "public/",
    "destination": "user@ip:/var/www/public/"
  }
}

Why?

I’ve been using a similar little bash script to deploy things with rsync for a while. Figured should finally package this up since there somehow still seems to be a lack of simple deployment tools for “websites.” This brings some of the ease of deploying to platforms like netlify or vercel, but without any ecosystem. Works great with traditional php projects, like kirby. git-based deployment is also cool, but sometimes it’s nice to have them decoupled, to quickly deploy to staging during dev, for example.

Provided as-is, but hopefully you find it useful! 🥂