forked from TryGhost/gscan
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
97 lines (83 loc) · 3.17 KB
/
Gruntfile.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// ### grunt-mocha-istanbul
// Configuration for the mocha test coverage generator
// `grunt coverage`.
mocha_istanbul: {
coverage: {
src: ['test'],
options: {
mask: '*test.js',
coverageFolder: 'test/coverage',
excludes: ['app', 'uploads', 'tmp']
}
}
},
shipit: {
options: {
workspace: '.',
deployTo: '/opt/gscan',
ignores: ['.git', '.gitkeep', '.gitignore', '.jshintrc', 'node_modules'],
keepReleases: 5
},
prd: {
servers: ['[email protected]']
}
},
release: {
github: {
repo: 'TryGhost/gscan',
accessTokenVar: 'GITHUB_ACCESS_TOKEN'
}
}
});
grunt.loadNpmTasks('grunt-mocha-istanbul');
grunt.loadNpmTasks('grunt-shipit');
grunt.loadNpmTasks('shipit-deploy');
grunt.loadNpmTasks('grunt-release');
grunt.shipit.on('published', function () {
grunt.task.run(['link-node-modules', 'link-uploads', 'create-tmp', 'npm-install', 'start']);
});
grunt.registerTask('link-node-modules', function () {
var done = this.async(),
deployDir = grunt.config('shipit.options.deployTo'),
current = deployDir + '/current';
grunt.shipit.remote('mkdir -p ' + deployDir + '/shared/node_modules', function () {
grunt.shipit.remote('ln -nfs ' + deployDir + '/shared/node_modules ' + current + '/node_modules', done);
});
});
grunt.registerTask('link-uploads', function () {
var done = this.async(),
deployDir = grunt.config('shipit.options.deployTo'),
current = deployDir + '/current';
grunt.shipit.remote('mkdir -p ' + deployDir + '/shared/uploads', function () {
grunt.shipit.remote('ln -nfs ' + deployDir + '/shared/uploads ' + current + '/uploads', done);
});
});
grunt.registerTask('create-tmp', function () {
var done = this.async(),
current = grunt.config('shipit.options.deployTo') + '/current';
grunt.shipit.remote('mkdir -p ' + current + '/tmp', done);
});
grunt.registerTask('npm-install', function () {
var done = this.async(),
current = grunt.config('shipit.options.deployTo') + '/current';
grunt.shipit.remote('cd ' + current + ' && npm install', done);
});
grunt.registerTask('start', function () {
var done = this.async(),
deployDir = grunt.config('shipit.options.deployTo'),
current = deployDir + '/current';
grunt.shipit.remote('cd ' + current + ' && touch tmp/restart.txt', done);
});
grunt.registerTask('deploy', [
'deploy:init',
'deploy:update',
'deploy:publish',
'deploy:clean'
]);
grunt.registerTask('coverage', 'Generate unit and integration (mocha) tests coverage report',
['mocha_istanbul:coverage']
);
};