lp-deployer

1.1.0 • Public • Published

lp-deployer

Run pre, post, local and remote scripts; and upload files (creating directories if necessary) if you need to. All through SSH

Installation

yarn global add lp-deployer

Usage

lpd configfile.json

where configfile.json is the configuration file. Or

lpd

and it will look for a file called lp-deployer.json in the current directory with the configuration.

Configuration

The configuration file should be like this:

{
  "server": "svrstaging",
  "commands": {
    "pre": [
      { "location": "local", "script": "yarn run build-prod" },
      { "location": "remote", "script": "systemctl stop yourawesomeapp_service", "continueOnError": true }
    ],
    "post": [
      { "location": "remote", "script": "yarn --prod" },
      { "location": "remote", "script": "systemctl start yourawesomeapp_service" },
      { "location": "local", "script": "knex migrate:latest --env={{{knexEnvironment}}}" }
    ]
  },
  "upload": {
    "directory": "/opt/yourapp",
    "items": [
      "app/routes",
      "app/models",
      "public",
      "config.js",
      "package.json",
      "server.js"
    ]
  }
}
 

this means:

server

The target server to upload files and / or run remote commands.

commands

Here you have two groups: pre and post. The pre group will be run before uploading files to the target, and the post group after. In each command you can specify if it has to be run locally in the computer from where you're deploying, or remotely in the target server.

continueOnError

By default this is false, and will halt the whole process if this command fails. When you set it to true you're saying that you want to continue with the other commands even if this one fails.

upload

directory

Where you want to copy the files and directories to.

items

A list of files and directories that you want to upload. If you specify a file it will be uploaded, if it's a directory it'll upload all files in it. The deployer will create all missing remote directories needed to complete this task.

But... What if I have more than one environment to deploy to?

Easy! Have many configuration files, one for each environment.

You could use the lpd-deployer.json file as your default one, and for example lpd-deployer-staging.json for staging, lpd-deployer-prod.json for production and so on.

Credits

@luispablo

Readme

Keywords

none

Package Sidebar

Install

npm i lp-deployer

Weekly Downloads

1

Version

1.1.0

License

GPL-3.0

Last publish

Collaborators

  • luispablo