express-browserify-deployer

1.4.0 • Public • Published

Express + Browserify deployer

(yeah, I know, an awfull name)

Small script to:

  • Transpile your client JS code (with JSX by default)
  • Handle version number (taken from package.json)
  • Select target server to deploy to
  • Upload files via SSH
  • Install NPM dependencies in target server
  • Restart service hosting the deployed service

Installation

npm install -g express-browserify-deployer

Pay special attention to:

If you are working with NVM, you may have some problems with global NPM modules (as I had)
To fix it you should set the environment variable NODE_PATH to the exact location where your node modules are being installed to.
Mine was in /home/<me>/.nvm/versions/node/v0.12.7/lib/node_modules

Usage

Sitting in your app dir, having there the code you want to deploy type:

deploy

That easy? YES, that's the idea.

Configuration

Well, actually it's not so so simple, first you need to have some configuration in place.
The script will look for the file deploy.json, in your app root directory (usually, there you have the package.json file. If such file is not present, the script will ask you for the values it was expecting to find there, and afterwards will write the deploy.json file for you.
The deploy.json file should look something like:

{
    "servers": ["svrname1", "svrname2"],
    "appDirInServer": "/opt/yourawesomeapp",
    "restartCommand": "systemctl restart yourawesomeapp_service",
    "entryFile": "./app/browserapp.js",
    "outputFile": "./public/js/bundle.js",
  "buildCommand": "npm run build-prod",
    "filesToUpload": [
        "app/routes",
        "app/models",
        "public",
        "config.js",
        "package.json",
        "server.js"
    ]
}

OK, what are we looking at here? Lets see:

  • servers: this is an array containing the names of the servers you may deploy to (ie: staging and production servers)
  • appDirInServer: this is the directory where your app will be located in the previously defined servers (by now it must be the same in all the servers defined)
  • restartCommand: here you have to type the linux command to restart your app service.
  • entryFile (optional): the root file of your client JS app (this was built with React, ES2015 and browserify in mind)
  • outputFile (optional): the browserify output file.
  • buildCommand (optional): If you provide this command, it will ignore entryFile and outputFile and will use this command to build the JS bundle to deploy.
  • fileToUpload: which files and folders, of the directory you're standing at, you want to upload to the defined servers.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Credits

@luispablo

Readme

Keywords

Package Sidebar

Install

npm i express-browserify-deployer

Weekly Downloads

4

Version

1.4.0

License

GPL-2.0

Last publish

Collaborators

  • luispablo