Что такое, кто такой?

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.


Выкладка без боли с Capistrano

Под капотом


Gulp для сборки статики

## API * Tasks * Commands * Events * Utils

Tasks

shipit.task(name, [deps], fn)     // create async task
shipit.blTask(name, [deps], fn)   // create sync task
shipit.start(tasks)               // start task(s)

Commands

shipit.local(command, [options], [callback])
// run command locally

shipit.remote(command, [options], [callback])
// run command remotely

Events

shipit.emit(name)     // emit custom event
shipit.on(name, fn)   // listen to event

Utils

shipit.remoteCopy(src, dest, [options], [callback])
// copy from a local path to a remote dest path

shipit.log('hello %s', 'world')
// the same as `console.log`

Configuration

shipitfile.js

Default

shipit.initConfig
  default:
    workspace: '/tmp/slides.kugaevsky.ru'
    deployTo: '/var/www/slides.kugaevsky.ru'
    repositoryUrl: 'git@github.com:kugaevsky/slides.kugaevsky.ru.git'
    ignores: ['.git', 'node_modules']
    dirToCopy: 'public'
    branch: 'master'
    shallowClone: false
    rsync: ['--del']
    keepReleases: 5
    deleteOnRollback: false
    key: '/path/to/key'

Environments

shipit.initConfig
  default: #...
  staging:
    branch: 'staging'
    deployTo: '/var/www/beta.slides.kugaevsky.ru'
  production:
    servers: 'nick@kugaevsky.ru'

All together

module.exports = (shipit) ->
  require('shipit-deploy') shipit
  shipit.initConfig
      default:
        workspace: '/tmp/slides.kugaevsky.ru'
        deployTo: '/var/www/slides.kugaevsky.ru'
        repositoryUrl: 'git@github.com:kugaevsky/slides.kugaevsky.ru.git'
        dirToCopy: 'public'
        branch: 'master'
        keepReleases: 5
      production:
        servers: 'nick@kugaevsky.ru'
        nginx:
          server: 'slides.kugaevsky.ru'
          port: 80
## Deploy flow (1/2) * **deploy:init** * Emit event "deploy". * **deploy:fetch** * Create workspace. * Initialize repository. * Add remote. * Fetch repository. * Checkout commit-ish. * Merge remote branch in local branch. * Emit event "fetched".
## Deploy flow (2/2) * **deploy:update** * Create and define release path. * Remote copy project. * Emit event "updated". * **deploy:publish** * Update symlink. * Emit event "published". * **deploy:clean** * Remove old releases. * Emit event "cleaned". * **deploy:finish** * Emit event "deployed".
## Rollback flow * **rollback:init** * Define release path. * Emit event "rollback". * **deploy:publish** * Update symlink. * Emit event "published". * **deploy:clean** * Remove old releases. * Emit event "cleaned". * **rollback:finish** * Emit event "rollbacked".
## Pending * **pending:log** * Log pending commits (diff between HEAD and currently deployed revision) to console.
## Variables – Events * **shipit.config.*** – `deploy:init` * **shipit.repository** – `deploy:fetch` * **shipit.releaseDirname** – `deploy:update`, `rollback:init` * **shipit.releasesPath** – `deploy:init`, `rollback:init`, `pending:log` * **shipit.releasePath** – `deploy:update`, `rollback:init` * **shipit.currentPath** – `deploy:init`, `rollback:init`, `pending:log`