-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshipit.js
154 lines (134 loc) · 3.62 KB
/
shipit.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
var fs = require('fs');
var shipitConfig = null;
try {
shipitConfig = JSON.parse(fs.readFileSync('./deploy.json', 'utf8'));
} catch(e) {
console.log('No deploy.json file, shipit will not be configured');
console.log(e);
}
module.exports.shipitConfig = shipitConfig;
module.exports.shipitInit = function (shipit) {
var fs = require('fs');
require('shipit-deploy')(shipit);
require('shipit-shared')(shipit);
require('shipit-composer')(shipit);
require('shipit-npm')(shipit);
require('shipit-bower')(shipit);
/*-----------------------------------------------------------------------------------------------
| EVENTS
*/
/*
| After Bower is installed, do our local things to do
*/
shipit.on('bower_installed', function () {
shipit.start([
'compile-assets'
]);
});
/*
| Before updating the symlink, we go into maintainance mode
*/
shipit.on('updated', function () {
shipit.start([
'artisan-down'
]);
});
/*
| After the deployment is done, do our remote things to do
*/
shipit.on('deployed', function () {
shipit.start([
'artisan-migrate',
'artisan-clear',
'artisan-optimize',
'artisan-import-translations',
'artisan-up'
]);
});
/*
| After the deployment is done, do our remote things to do
*/
shipit.on('rollbacked', function () {
shipit.start([
'artisan-rollback',
'artisan-up'
]);
});
/*-----------------------------------------------------------------------------------------------
| TASKS
*/
/*
| Compile the assets locally
*/
shipit.blTask('compile-assets', function () {
return shipit.local('gulp --production', {"cwd": shipit.config.workspace});
});
/*
| Run laravel commands on the remote
*/
shipit.blTask('artisan-migrate', function () {
var artisanCommand = 'php artisan migrate';
if (shipit.config.laravel.resetDb) {
artisanCommand += ':refresh';
}
if (shipit.config.laravel.seedDb) {
artisanCommand += ' --seed';
}
return shipit.remote('cd ' + shipit.releasePath
+ ' && ' + artisanCommand
).then(function(res) {
shipit.log(res);
});
});
shipit.blTask('artisan-rollback', function () {
return shipit.remote('cd ' + shipit.releasePath
+ ' && php artisan rollback'
).then(function(res) {
shipit.log(res);
});
});
shipit.blTask('artisan-down', function () {
return shipit.remote('cd ' + shipit.releasePath
+ ' && php artisan down'
).then(function(res) {
shipit.log(res);
});
});
shipit.blTask('artisan-clear', function () {
return shipit.remote('cd ' + shipit.releasePath
+ ' && php artisan clear-compiled '
+ ' && php artisan view:clear '
+ ' && php artisan route:clear '
+ ' && php artisan cache:clear '
+ ' && php artisan config:clear'
).then(function(res) {
shipit.log(res);
});
});
shipit.blTask('artisan-optimize', function () {
return shipit.remote('cd ' + shipit.releasePath
+ ' && php artisan config:cache ' // Seems to be causing trouble with reading .env in code, CAREFUL
+ ' && php artisan route:cache '
).then(function(res) {
shipit.log(res);
});
});
shipit.blTask('artisan-import-translations', function () {
return shipit.remote('cd ' + shipit.releasePath
+ ' && php artisan translations:import'
).then(function(res) {
shipit.log(res);
});
});
shipit.blTask('artisan-up', function () {
return shipit.remote('cd ' + shipit.releasePath
+ ' && php artisan up'
).then(function(res) {
shipit.log(res);
});
});
/*-----------------------------------------------------------------------------------------------
| EVENTS
*/
shipit.initConfig(shipitConfig);
};