Skip to content
This repository has been archived by the owner on Mar 18, 2018. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: shipitjs/grunt-shipit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.4.1
Choose a base ref
...
head repository: shipitjs/grunt-shipit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
language: node_js
node_js:
- "0.10"
- "0.10"
before_install:
- npm install -g grunt-cli
24 changes: 24 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = function (grunt) {
grunt.initConfig({
shipit: {
options: {},
staging: {
servers: 'myserver.com'
}
}
});

grunt.loadTasks('tasks');

grunt.registerTask('test', function () {
var done = this.async();
grunt.shipit.local('echo "hello"', function (err, res) {
if (err) return done(err);

if (res.stdout !== 'hello\n')
done(new Error('test not passing'));

done();
});
});
};
250 changes: 58 additions & 192 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
# This repository is no longer maintained, please use [Shipit](https://github.com/shipitjs/shipit) instead
# ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

# grunt-shipit

[![Build Status](https://travis-ci.org/neoziro/grunt-shipit.svg?branch=master)](https://travis-ci.org/neoziro/grunt-shipit)
[![Dependency Status](https://david-dm.org/neoziro/grunt-shipit.svg?theme=shields.io)](https://david-dm.org/neoziro/grunt-shipit)
[![devDependency Status](https://david-dm.org/neoziro/grunt-shipit/dev-status.svg?theme=shields.io)](https://david-dm.org/neoziro/grunt-shipit#info=devDependencies)
[![Build Status](https://travis-ci.org/shipitjs/grunt-shipit.svg?branch=master)](https://travis-ci.org/shipitjs/grunt-shipit)
[![Dependency Status](https://david-dm.org/shipitjs/grunt-shipit.svg?theme=shields.io)](https://david-dm.org/shipitjs/grunt-shipit)
[![devDependency Status](https://david-dm.org/shipitjs/grunt-shipit/dev-status.svg?theme=shields.io)](https://david-dm.org/shipitjs/grunt-shipit#info=devDependencies)

![Shipit logo](https://cloud.githubusercontent.com/assets/266302/3756454/81df9f46-182e-11e4-9da6-b2c7a6b84136.png)

Shipit is a deploy tool written in node.js and based on Grunt. Shipit was built to be a Capistrano alternative for people who want to write tasks in JavaScript and don't have a piece of ruby in their beautiful codebase.
Grunt plugin for Shipit, an automation engine and a deployment tool written for node / iojs.

**If you prefer using Shipit without grunt, please go to [Shipit repository](https://github.com/shipitjs/shipit).**

## Getting Started
This plugin requires Grunt `~0.4.0`
@@ -25,224 +31,84 @@ grunt.loadNpmTasks('grunt-shipit');

## Usage

```
grunt shipit:<stage> <tasks ...>
```

## Dependencies

### Local

- git 1.7.8+
- rsync 3+
- OpenSSH 5+

### Remote

- GNU coreutils 5+

## Shipit task

### Run task

```
grunt shipit:<stage> <tasks ...>
```

### Options

#### workspace

Type: `String`

Define the local working path of the project deployed.

#### deployTo

Type: `String`

Define the remote path where the project will be deployed. A directory `releases` is automatically created. A symlink `current` is linked to the current release.

#### repositoryUrl

Type: `String`

Git URL of the project repository.

#### branch

Type: `String`

Tag, branch or commit to deploy.

#### ignores

Type: `Array<String>`

An array of paths that match ignored files. These paths are used in the rsync command.

#### keepReleases

Type: `String`

Number of release to keep on the remote server.

#### 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".

### Usage example
### Example Gruntfile.js

```js
shipit: {
options: {
workspace: '/tmp/github-monitor',
deployTo: '/tmp/deploy_to',
repositoryUrl: 'https://github.com/user/repo.git',
ignores: ['.git', 'node_modules'],
keepReleases: 2
},
staging: {
servers: 'user@myserver.com'
}
}
```

To deploy on staging, you must use the following command :
module.exports = function (grunt) {
grunt.initConfig({
shipit: {
options: {
workspace: '/tmp/github-monitor',
deployTo: '/tmp/deploy_to',
repositoryUrl: 'https://github.com/user/repo.git',
ignores: ['.git', 'node_modules'],
keepReleases: 2,
key: '/path/to/key',
shallowClone: true
},
staging: {
servers: ['user@myserver.com', 'user2@myserver2.com']
}
}
});

grunt.loadNpmTasks('grunt-shipit');
grunt.loadNpmTasks('shipit-deploy');

grunt.registerTask('pwd', function () {
grunt.shipit.remote('pwd', this.async());
});
};

```
grunt shipit:staging deploy
```

You can rollback to the previous releases with the command :
### Launch command

```
grunt shipit:staging rollback
```bash
grunt shipit:<environment> <tasks ...>
```

### Events

Shipit has several events describe in the workflow, you can add custom event and listen to events.

```js
grunt.registerTask('build', function () {
// ...
grunt.shipit.emit('buit');
});
For more documentation about Shipit commands please refer to [Shipit repository](https://github.com/shipitjs/shipit).

grunt.shipit.on('fetched', function () {
grunt.task.run(['build']);
});
For more documentation about Shipit deploy task, please refer to [Shipit deploy repository](https://github.com/shipitjs/shipit-deploy).

```
## Upgrading from v0.5.x

### Methods

#### shipit.local(command, [options], callback)
Now all methods returns promises, you can still use callback but the result has changed.

Run a command locally and streams the result.
Before:

```js
shipit.local('ls -lah', { cwd: '/tmp/deploy/workspace' }, function (err, stdout) {
// ...
shipit.remote('echo "hello"', function (err, stdout, stderr) {
console.log(stdout, stderr);
});
```

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

Run a command remotely and streams the result.

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

```js
shipit.remote('ls -lah', function (err, stdout) {
// ...
shipit.remote('echo "hello"', function (err, res) {
console.log(res.stdout, res.stderr);
});
```

#### shipit.remoteCopy(src, dest, callback)
### Deployment task

Make a remote copy from a local path to a dest path.
The deployment task is now separated from Shipit. You must install it and load it separately:

```js
shipit.remoteCopy('/tmp/workspace', '/opt/web/myapp', function (err) {
// ...
});
```
npm install shipit-deploy
```

### Variables

Shipit attach several variables during the deploy and the rollback process :

#### shipit.config.*

All options describe in the config sections are avalaible in the `shipit.config` object.

#### shipit.repository

Attached during `deploy:fetch` task.

You can manipulate the repository using git command, the API is describe in [gift](https://github.com/sentientwaffle/gift).

#### shipit.releaseDirname

Attached during `deploy:update` and `rollback:init` task.

The current release dirname of the project, the format used is "YYYYDDMMHHmmss" (moment format).

#### shipit.releasesPath

Attached during `deploy:update` and `rollback:init` task.

The remote releases path.

#### shipit.releasePath

Attached during `deploy:update` and `rollback:init` task.

The complete release path : `path.join(shipit.releasesPath, shipit.releaseDirname)`.

#### shipit.currentPath

Attached during `deploy:publish` and `rollback:init` task.

The current symlink path : `path.join(shipit.config.deployTo, 'current')`.
```js
grunt.loadNpmTasks('shipit-deploy');
```

### Workflow tasks
### API change
The exposed property `grunt.shipit.stage` is now `grunt.shipit.environment`.

- deploy
- 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: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".
- rollback
- rollback:init
- Define release path.
- Emit event "rollback".
- deploy:publish
- Update symlink.
- Emit event "published".
- deploy:clean
- Remove old releases.
- Emit event "cleaned".

## License

1 change: 1 addition & 0 deletions examples/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ module.exports = function (grunt) {
});

grunt.loadNpmTasks('grunt-shipit');
grunt.loadNpmTasks('shipit-deploy');

/**
* Initialize tasks.
Loading