Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shipit-cli

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shipit-cli

Universal automation and deployment tool written in JavaScript.

  • 1.5.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.9K
decreased by-28.35%
Maintainers
2
Weekly downloads
 
Created
Source

Shipit

![Gitter](https://badges.gitter.im/Join Chat.svg)

Build Status Dependency Status devDependency Status Inline docs

Shipit logo

Shipit is an automation engine and a deployment tool written for node / iojs.

Shipit was built to be a Capistrano alternative for people who don't know ruby, or who experienced some issues with it. If you want to write tasks in JavaScript and enjoy the node ecosystem, Shipit is also for you.

You can automate anything with Shipit but most of the time you will want to deploy your project using the Shipit deploy task.

Features:

  • Full JavaScript (all npm package availables)
  • Task flow based on orchestrator (gulp core)
  • Official deploy task
  • Login and interactive SSH commands
  • Easily extendable

Install

Globally

npm install --global shipit-cli

Locally

npm install --save-dev shipit-cli

Getting Started

Once shipit is installed, you must create a shipitfile.js.

If you are familiar with grunt or gulp, you will feel at home.

Create a shipitfile.js

module.exports = function (shipit) {
  shipit.initConfig({
    staging: {
      servers: 'myproject.com'
    }
  });

  shipit.task('pwd', function () {
    return shipit.remote('pwd');
  });
};

Launch command

shipit staging pwd

Deploy using Shipit

You can easily deploy a project using Shipit and its plugin shipit-deploy.

Example shipitfile.js

module.exports = function (shipit) {
  require('shipit-deploy')(shipit);

  shipit.initConfig({
    default: {
      workspace: '/tmp/github-monitor',
      deployTo: '/tmp/deploy_to',
      repositoryUrl: 'https://github.com/user/repo.git',
      ignores: ['.git', 'node_modules'],
      rsync: ['--del'],
      keepReleases: 2,
      key: '/path/to/key',
      shallowClone: true
    },
    staging: {
      servers: 'user@myserver.com'
    }
  });
};

To deploy on staging, you must use the following command :

shipit staging deploy

You can rollback to the previous releases with the command :

shipit staging rollback

Usage

shipit <environment> <tasks ...>

Options

servers

Type: String or Array<String>

Servers on which the project will be deployed. Pattern must be user@myserver.com if user is not specified (myserver.com) the default user will be "deploy".

key

Type: String

Path to SSH key

Events

You can add custom event and listen to events.

shipit.task('build', function () {
  // ...
  shipit.emit('built');
});

shipit.on('built', function () {
  shipit.start('start-server');
});

Shipit emits the init event once initialized, before any tasks are run.

Methods

shipit.task(name, [deps], fn)

Create a new Shipit task, if you are familiar with gulp, this is the same API. You can use a callback or a promise in your task.

For more documentation, please refer to orchestrator documentation.

shipit.task('pwd', function () {
  return shipit.remote('pwd');
});
shipit.blTask(name, [deps], fn)

Create a new Shipit task that will block other tasks during its execution (synchronous).

If you use these type of task, the flow will be exactly the same as if you use grunt.

shipit.blTask('pwd', function () {
  return shipit.remote('pwd');
});
shipit.start(tasks)

Run Shipit tasks.

For more documentation, please refer to orchestrator documentation.

shipit.start('task');
shipit.start('task1', 'task2');
shipit.start(['task1', 'task2']);
shipit.local(command, [options], [callback])

Run a command locally and streams the result. This command take a callback or return a promise. It returns a result object containing stdout, stderr and the child process object.

shipit.local('ls -lah', {cwd: '/tmp/deploy/workspace'}).then(function (res) {
  console.log(res.stdout);
  console.log(res.stderr);
  res.child.stdout.pipe(...);
});
shipit.remote(command, [options], [callback])

Run a command remotely and streams the result. This command take a callback or return a promise.

If you want to run a sudo command, the ssh connection will use the TTY mode automatically.

It returns an array of result objects containing stdout, stderr and the child process object. The list of results matchs the list of servers specified in configuration.

shipit.remote('ls -lah').then(function (res) {
  console.log(res[0].stdout); // stdout for first server
  console.log(res[0].stderr); // stderr for first server
  res[0].child.stdout.pipe(...); // child of first server

  console.log(res[1].stdout); // stdout for second server
  console.log(res[1].stderr); // stderr for second server
  res[0].child.stdout.pipe(...); // child of second server
});
shipit.remoteCopy(src, dest, [options], [callback])

Make a remote copy from a local path to a dest path.

shipit.remoteCopy('/tmp/workspace', '/opt/web/myapp').then(...);
shipit.log()

Log using Shipit, same API as console.log.

shipit.log('hello %s', 'world');

Dependencies

Customising environments

You can overwrite all default variables defined as part of the default object.

module.exports = function (shipit) {
  shipit.initConfig({
    staging: {
      servers: 'staging.myproject.com',
      workspace: '/home/vagrant/website'
      branch: 'dev'
    },
    production: {
      servers: [{
        host: 'app1.myproject.com',
        user: 'john',
      }, {
        host: 'app2.myproject.com',
        user: 'rob',
      }],
      branch: 'production',
      workspace: '/var/www/website'
    }
  });

  ...
  shipit.task('pwd', function () {
    return shipit.remote('pwd');
  });
  ...
};

Async Config

If you can't call shipit.initConfig(...) right away because you need to get data asynchronously to do so, you can return a promise from the module:

module.exports = function (shipit) {
  return getServersAsync().then( function( servers ) {
    shipit.initConfig({
      production: {
        servers: servers,
        // ...
      }
    })
  } )
}

If you need to use a function that works with callbacks instead of promises, you can wrap it manually:

module.exports = function (shipit) {
  return new Promise( function( resolve ) {
    getServersAsync( function( servers ) {
      shipit.initConfig({
        production: {
          servers: servers,
          // ...
        }
      })
      resolve()
    } )
  } )
}

Known Plugins

Official

Third Party

Who use Shipit?

License

MIT

Keywords

FAQs

Package last updated on 22 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc