GithubHelp home page GithubHelp logo

deployer's Introduction

Deployer

NPM

It mainly used by myself to deploy express.js servers or Angular 2+ projects (Angular Universal as well), but you can use it for a lot of things. This repo allows you to deploy files on server, remove old files (e.g. old angular hashed bundles, which you don't need after deploying new ones), restart a server (e.g. Angular Universal server) by running command line commands and other cool stuff.

Install

Just install this module globally:

npm install -g @edkhrian/deployer

Setup

To make a config process easier, there is a command to initialize an environment on first setup:

cd /home/myproject # first navigate to your project folder
deployer init # then run the initialization

What it makes:

  1. Creates empty config files in the root directory (deploy.tasks.js and deploy.credentials.js);
  2. Adds the credential config file name to .gitignore (because it's bad to push username/password to a repository);

Right after the initialization your config files will be located in the root directory. You should change their content to your own purposes.

Example of deploy.config.js

module.exports = [
    // list of tasks, they will be running in the presented order one after another
    // there are 3 types of tasks available: upload, delete, run
    {
        name: 'upload',
        src: [
            './dist/**/*',
            '!./dist/templates/**',
        ],
        dest: '/home/public'
    },
    {
        name: 'delete', // remove files on the server
        src: [
            '/home/public/*.js', // in the remote folder
        ],
        // optional, check which files to delete
        test: (file) => {
            return Date.now() - file.modifyTime > 24 * 3600 * 1000;
        }
    },
    {
        name: 'run', // run commands
        commands: [
            'cd /home/public',
            'pm2 restart server'
        ],
    }
];

Example of deploy.credentials.js

module.exports = {
    host: 'XXX.XXX.XXX.XXX', // host ip or domain
    username: 'root',
    password: 'root_password',
}

Usage

To execute tasks from a config file run the command:

deployer deploy

deployer's People

Contributors

edkhrian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.