@gradealabs/git-deploy

A simple module that makes Git deployment easier.


Keywords
git, deploy
License
MIT
Install
npm install @gradealabs/git-deploy@3.1.0

Documentation

Git Deploy

A simple module that makes Git deployment easier. If the remote being deployed to has not been added to the local Git repo it will be added automatically and given the name as specified in the remote settings.

Quick Start

npm install @gradealabs/git-deploy -D

To Use the API:

import gitDeploy from '@gradealabs/git-deploy'

gitDeploy({
  staging: {
    // The name of the remote repo (can be anything)
    name: 'heroku-staging',
    // The branch on the remote repo
    branch: 'master',
    // The URL of the remote repo
    url: 'https://git.heroku.com/myapp-staging.git'
  },
  production: {
    name: 'heroku-production',
    branch: 'master',
    url: 'https://git.heroku.com/myapp-production.git'
  }
}, 'staging', { verbose: true })

To Use the CLI:

git-deploy --remotes .remotes.json --env staging --verbose

CLI

Usage: git-deploy [options]

Options:
--env, -E      The environment to deploy to. Defaults to NODE_ENV or first
                environemnt in remotes JSON.                           [string]
--dryrun       Determines if any git commands will be executed (enables
                verbose)                             [boolean] [default: false]
--remotes, -R  Path to JSON file containing remotes for each supported env
                                                            [string] [required]
--verbose      Determines if log messages will be written to the console
                                                    [boolean] [default: false]
--help         Show help                                             [boolean]

API

gitDeploy(remotes, env, { dryRun, verbose })

Attempts to synchronously deploy the current branch to a remote repo.

Example:

import gitDeploy from '@gradealabs/git-deploy'
// OR import { gitDeploy } from '@gradealabs/git-deploy`

gitDeploy({
  staging: {
    // The name of the remote repo (can be anything)
    name: 'heroku-staging',
    // The branch on the remote repo
    branch: 'master',
    // The URL of the remote repo
    url: 'https://git.heroku.com/myapp-staging.git'
  },
  production: {
    name: 'heroku-production',
    branch: 'master',
    url: 'https://git.heroku.com/myapp-production.git'
  }
}, 'staging', { verbose: true })

Building

To build the source

npm run build
npm run build:node

To clean all generated folders

npm run clean

Testing

Unit tests are expected to be colocated next to the module/file they are testing and have the following suffix .test.js.

To run unit tests through istanbul and mocha

npm test

Maintainence

To check what modules in node_modules is outdated

npm run audit

To update outdated modules while respecting the semver rules in the package.json

npm update

To update a module to the latest major version (replacing what you have)

npm install themodule@latest -S (if to save in dependencies)
npm install themodule@latest -D (if to save in devDependencies)