Skip to content

Commit 2022711

Browse files
author
Zhe Feng
committed
update readme
1 parent 0fe0a06 commit 2022711

File tree

3 files changed

+32
-66
lines changed

3 files changed

+32
-66
lines changed

Gruntfile.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@
3131
// Configuration to be run (and then tested).
3232
deploy: {
3333
liveservers: {
34-
servers: require('servers').servers(),
35-
cmds_before_deploy: [],
36-
cmds_after_deploy: [],
37-
deploy_path: '~/grunt-plugins/grunt-deploy'
34+
options:{
35+
servers: require('servers').servers(),
36+
cmds_before_deploy: [],
37+
cmds_after_deploy: [],
38+
deploy_path: '~/grunt-plugins/grunt-deploy'
39+
}
3840
}
3941
/*default_options: {
4042
options: {

README.md

+18-54
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# grunt-deploy deploy your node app easily
1+
# grunt-deploy: deploy your node app easily
22

3-
> The Grunt plugin to deploy nodejs app into ubuntu
3+
> The Grunt plugin to deploy node app into ubuntu
4+
5+
Find more in [here](http://zhefeng.github.io/grunt-deploy/ "grunt-deploy").
6+
Google group in [here](https://groups.google.com/forum/?fromgroups#!forum/grunt-deploy "grunt-deploy group").
47

58
## Getting Started
69
This plugin requires Grunt `~0.4.1`
@@ -25,62 +28,23 @@ In your project's Gruntfile, add a section named `deploy` to the data object pas
2528
```js
2629
grunt.initConfig({
2730
deploy: {
28-
options: {
29-
// Task-specific options go here.
30-
},
31-
your_target: {
32-
// Target-specific file lists and/or options go here.
33-
},
34-
},
35-
})
36-
```
37-
38-
### Options
39-
40-
#### options.separator
41-
Type: `String`
42-
Default value: `', '`
43-
44-
A string value that is used to do something with whatever.
45-
46-
#### options.punctuation
47-
Type: `String`
48-
Default value: `'.'`
49-
50-
A string value that is used to do something else with whatever else.
51-
52-
### Usage Examples
53-
54-
#### Default Options
55-
In this example, the default options are used to do something with whatever. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result would be `Testing, 1 2 3.`
56-
57-
```js
58-
grunt.initConfig({
59-
deploy: {
60-
options: {},
61-
files: {
62-
'dest/default_options': ['src/testing', 'src/123'],
63-
},
31+
liveservers: {
32+
options:{
33+
servers: [{
34+
host: '123.123.123.12',
35+
port: 22,
36+
username: 'username',
37+
password: 'password'
38+
}],
39+
cmds_before_deploy: ["some cmds you may want to exec before deploy"],
40+
cmds_after_deploy: ["forever restart", "some other cmds you want to exec after deploy"],
41+
deploy_path: 'your deploy path in server'
42+
}
43+
}
6444
},
6545
})
6646
```
6747

68-
#### Custom Options
69-
In this example, custom options are used to do something else with whatever else. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result in this case would be `Testing: 1 2 3 !!!`
70-
71-
```js
72-
grunt.initConfig({
73-
deploy: {
74-
options: {
75-
separator: ': ',
76-
punctuation: ' !!!',
77-
},
78-
files: {
79-
'dest/default_options': ['src/testing', 'src/123'],
80-
},
81-
},
82-
})
83-
```
8448

8549
## Contributing
8650
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

tasks/deploy.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@
5353
}
5454

5555
console.log('executing cmds before deploy');
56-
execCmds(self.data.cmds_before_deploy, 0, function(){
56+
execCmds(options.cmds_before_deploy, 0, function(){
5757
console.log('cmds before deploy executed');
5858

5959

60-
var createFolder = 'cd ' + self.data.deploy_path + '/releases && mkdir ' + timeStamp;
61-
var removeCurrent = 'rm -rf ' + self.data.deploy_path + '/current';
62-
var setCurrent = 'ln -s ' + self.data.deploy_path + '/releases/' + timeStamp + ' ' + self.data.deploy_path + '/current';
60+
var createFolder = 'cd ' + options.deploy_path + '/releases && mkdir ' + timeStamp;
61+
var removeCurrent = 'rm -rf ' + options.deploy_path + '/current';
62+
var setCurrent = 'ln -s ' + options.deploy_path + '/releases/' + timeStamp + ' ' + options.deploy_path + '/current';
6363

6464
console.log('start deploy');
6565
exec(createFolder + ' && ' + removeCurrent + ' && ' + setCurrent,function(){
@@ -68,11 +68,11 @@
6868
var execLocal = require('child_process').exec;
6969
var child;
7070

71-
child = execLocal("scp -r . " + server.username + "@" + server.host + ":" + self.data.deploy_path + "/releases/" + timeStamp, function (error, stdout, stderr) {
71+
child = execLocal("scp -r . " + server.username + "@" + server.host + ":" + options.deploy_path + "/releases/" + timeStamp, function (error, stdout, stderr) {
7272
console.log('end deploy');
7373

7474
console.log('executing cmds after deploy');
75-
execCmds(self.data.cmds_after_deploy, 0, function(){
75+
execCmds(options.cmds_after_deploy, 0, function(){
7676
console.log('cmds after deploy executed');
7777
connection.end();
7878
});
@@ -81,7 +81,7 @@
8181
})
8282
}
8383

84-
var length = self.data.servers.length;
84+
var length = options.servers.length;
8585
var completed = 0;
8686
var checkCompleted = function(){
8787
completed++;
@@ -90,7 +90,7 @@
9090
}
9191
}
9292

93-
self.data.servers.forEach(function(server){
93+
options.servers.forEach(function(server){
9494
var c = new Connection();
9595
c.on('connect', function() {
9696
console.log('Connecting to server: ' + server.host);

0 commit comments

Comments
 (0)