-
Notifications
You must be signed in to change notification settings - Fork 12
/
shipitfile.js
79 lines (69 loc) · 2.79 KB
/
shipitfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
module.exports = function (shipit) {
require('shipit-deploy')(shipit)
var chalk = require('chalk')
function merge (a, b, z) {
for (var prop in b) {
try {
if (b[prop].constructor === Object) {
a[prop] = merge(a[prop], b[prop], z + ' ')
} else {
a[prop] = b[prop]
}
} catch (e) {
a[prop] = b[prop]
}
}
return a
}
// Recursively merge configuration files
var config = [
'./auto-deploy-config.js'
,'./auto-deploy-config.custom.js'
// ,'./dummy.js'
]
.map(function (cfg) {
try {
return require(cfg)
} catch (e) {
shipit.log(chalk.red('!! Could not find configuration file: ' + cfg))
return {}
}
})
.reduce(function (prevConfig, cfg) {
return merge(prevConfig, cfg)
}, {})
/*
### Options
| Option | Type | Description |
|:------------------|:----------------|:------------|
| workspace | String | Empty directory path to use as local side of transfer |
| dirToCopy | String | Defaults to `workspace` |
| deployTo | String | Remote directory to deploy to. Contains `releases` and symlink to `current` |
| repositoryUrl | String | Git URL of repo |
| branch | String | Tag, commit, or branch to deploy |
| ignores | Array<String> | Array of paths to ignore |
| deleteOnRollback | Boolean | Delete old releases on rollback to previous release |
| keepReleases | Number | Number of releases to keep |
| shallowClone | Boolean | Perform a shallow clone. Default: false |
| gitLogFormat | String | Git log format for `pending` task. Default: %h: %s - %an |
| servers | String or Array<String> | The server(s) to deploy to. Format as user@server.com. Default user is `deploy` |
| key | String | Path to the SSH key required for the server(s) |
For more information, see [shipit-deploy](https://github.com/shipitjs/shipit-deploy) and [shipit](https://github.com/shipitjs/shipit).
*/
shipit.initConfig(config)
shipit.task('config', function () {
return shipit.log(JSON.stringify(config, null, '\t'))
})
shipit.task('buildAndDeploy', function () {
shipit.local('node red5pro-frontendfile.js', {cwd: process.cwd()})
.then(function() {
return shipit.local('rm -rf ' + config.default.workspace, {cwd: process.cwd()});
})
.then(function() {
return shipit.local('cp -r ' + process.cwd() + ' ' + config.default.workspace, {cwd: process.cwd()});
})
.then(function() {
shipit.start('deploy:init', 'deploy:update', 'deploy:publish', 'deploy:clean', 'deploy:finish')
});
})
}