# shipit-cli

> Universal automation and deployment tool written in JavaScript.

Latest version **5.3.0** (published 2020-03-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install shipit-cli
pnpm add shipit-cli
yarn add shipit-cli
bun add shipit-cli
```

Provides the command `shipit`.

## Health

**Score 18/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.3.0 |
| Published | 2020-03-18 |
| First published | 2015-01-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/shipit-cli) |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 9 |
| Unpacked size | 22.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5293 |
| Author | Greg Bergé |
| Maintainers | neoziro, timkelty |
| Keywords | shipit, automation, deployment, deploy, ssh |

## Links

- npm: https://www.npmjs.com/package/shipit-cli
- Repository: https://github.com/shipitjs/shipit/tree/master/packages/shipit-deploy
- npm.io page: https://npm.io/package/shipit-cli

## Dependencies (9)

- [chalk](https://npm.io/package/chalk.md) ^2.4.1
- [liftoff](https://npm.io/package/liftoff.md) ^3.1.0
- [v8flags](https://npm.io/package/v8flags.md) ^3.1.0
- [ssh-pool](https://npm.io/package/ssh-pool.md) ^5.3.0
- [commander](https://npm.io/package/commander.md) ^3.0.0
- [interpret](https://npm.io/package/interpret.md) ^1.1.0
- [orchestrator](https://npm.io/package/orchestrator.md) ^0.3.7
- [pretty-hrtime](https://npm.io/package/pretty-hrtime.md) ^1.0.0
- [stream-line-wrapper](https://npm.io/package/stream-line-wrapper.md) ^0.1.1

## Recent versions

- 5.3.0 (latest) — 2020-03-18
- 5.2.0 — 2020-03-07
- 5.1.0 — 2019-08-28
- 5.0.0 — 2019-07-15
- 4.2.0 — 2019-03-01
- 4.1.2 — 2018-11-04
- 4.1.1 — 2018-05-30
- 4.1.0 — 2018-04-27
- 4.0.2 — 2018-03-25
- 4.0.1 — 2018-03-18
- 4.0.0 — 2018-03-17
- 3.0.0 — 2017-02-28
- 2.0.0 — 2016-11-22
- 1.5.2 — 2016-11-22
- 1.5.1 — 2016-11-13
- … 10 more at https://npm.io/package/shipit-cli/versions

## README

# shipit-cli

[![Build Status][build-badge]][build]
[![version][version-badge]][package]
[![MIT License][license-badge]][license]

Shipit command line interface.

```
npm install --save-dev shipit-cli
```

## Usage

```
Usage: shipit <environment> <tasks...>

Options:

  -V, --version         output the version number
  --shipitfile <file>   Specify a custom shipitfile to use
  --require <files...>  Script required before launching Shipit
  --tasks               List available tasks
  --environments        List available environments
  -h, --help            output usage information
```

## `shipitfile.js`

```js
module.exports = shipit => {
  shipit.initConfig({
    staging: {
      servers: 'myproject.com',
    },
  })

  shipit.task('pwd', async () => {
    await shipit.remote('pwd')
  })
}
```

## API

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

Create a new Shipit task. If a promise is returned task will wait for completion.

```js
shipit.task('hello', async () => {
  await shipit.remote('echo "hello on remote"')
  await shipit.local('echo "hello from local"')
})
```

#### shipit.blTask(name, [deps], fn)

Create a new Shipit task that will block other tasks during its execution. If a promise is returned other task will wait before start.

```js
shipit.blTask('hello', async () => {
  await shipit.remote('echo "hello on remote"')
  await shipit.local('echo "hello from local"')
})
```

#### shipit.start(tasks)

Run Shipit tasks.

```js
shipit.start('task')
shipit.start('task1', 'task2')
shipit.start(['task1', 'task2'])
```

#### shipit.local(command, [options])

Run a command locally and streams the result. See [ssh-pool#exec](https://github.com/shipitjs/shipit/tree/master/packages/ssh-pool#exec).

```js
shipit
  .local('ls -lah', {
    cwd: '/tmp/deploy/workspace',
  })
  .then(({ stdout }) => console.log(stdout))
  .catch(({ stderr }) => console.error(stderr))
```

#### shipit.remote(command, [options])

Run a command remotely and streams the result. Run a command locally and streams the result. See [ssh-pool#connection.run](https://github.com/shipitjs/shipit/tree/master/packages/ssh-pool#connectionruncommand-options).

```js
shipit
  .remote('ls -lah')
  .then(([server1Result, server2Result]) => {
    console.log(server1Result.stdout)
    console.log(server2Result.stdout)
  })
  .catch(error => {
    console.error(error.stderr)
  })
```

#### shipit.copyToRemote(src, dest, [options])

Make a remote copy from a local path to a remote path. See [ssh-pool#connection.copyToRemote](https://github.com/shipitjs/shipit/tree/master/packages/ssh-pool#connectioncopytoremotesrc-dest-options).

```js
shipit.copyToRemote('/tmp/workspace', '/opt/web/myapp')
```

#### shipit.copyFromRemote(src, dest, [options])

Make a remote copy from a remote path to a local path. See [ssh-pool#connection.copyFromRemote](https://github.com/shipitjs/shipit/tree/master/packages/ssh-pool#connectioncopyfromremotesrc-dest-options).

```js
shipit.copyFromRemote('/opt/web/myapp', '/tmp/workspace')
```

#### shipit.log(...args)

Log using Shipit, same API as `console.log`.

```js
shipit.log('hello %s', 'world')
```

## Workflow tasks

When the system initializes it automatically emits events:

- Emit event "init"
- Emit event "init:after_ssh_pool"

Each shipit task also generates events:

- Emit event "task_start"
- Emit event "task_stop"
- Emit event "task_err"
- Emit event "task_not_found"

Inside the task events, you can test for the task name.

```js
shipit.on('task_start', event => {
  if (event.task == 'first_task') {
    shipit.log("I'm the first task")
  }
})
```

## License

MIT

[build-badge]: https://img.shields.io/travis/shipitjs/shipit.svg?style=flat-square
[build]: https://travis-ci.org/shipitjs/shipit
[version-badge]: https://img.shields.io/npm/v/shipit-cli.svg?style=flat-square
[package]: https://www.npmjs.com/package/shipit-cli
[license-badge]: https://img.shields.io/npm/l/shipit-cli.svg?style=flat-square
[license]: https://github.com/shipitjs/shipit/blob/master/LICENSE

---
_Source: https://npm.io/package/shipit-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
