forked from STS-Rosario/carpoolear_backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·115 lines (95 loc) · 3.31 KB
/
gulpfile.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
/*******************************************************************************
* Description:
*
* Gulp file to push changes to remote servers (eg: staging/production)
*
* Usage:
*
* gulp deploy --target --user=usuario
*
* --testing -> only view changes not apply
*
* Examples:
*
* gulp deploy --production --user=usuario // push to production
* gulp deploy --develop --user=usuario // push to staging
*
* Install:
* npm intall gulp -g
* npm install
*
******************************************************************************/
var gulp = require('gulp');
var gutil = require('gulp-util');
var argv = require('minimist')(process.argv);
var rsync = require('gulp-rsync');
var prompt = require('gulp-prompt');
var gulpif = require('gulp-if');
var path = require('path');
var exec = require('gulp-exec');
var isWin = /^win/.test(process.platform);
var reportOptions = {
err: true, // default = true, false means don't write err
stderr: true, // default = true, false means don't write stderr
stdout: true // default = true, false means don't write stdout
};
gulp.task('deploy', ['deploy-file'] ,function() {
gulp.src(['.env.example'])
.pipe(exec("ssh [email protected] -p 2200 'cd /home/movilizame/sites/carpoolear_dev && ./after_deploy.sh'"))
.pipe(exec.reporter(reportOptions));
});
gulp.task('deploy-file', function() {
// Dirs and Files to sync
rsyncPaths = ['artisan', 'after_deploy.sh', 'composer.json', 'composer.lock', 'app' , 'config' , 'database' , 'public' , 'resources' , 'bootstrap' , 'cert', 'tests', 'routes', 'storage/banks', 'storage/cc', 'storage/geojson' ];
// Default options for rsync
rsyncConf = {
progress: true,
incremental: true,
relative: true,
emptyDirectories: true,
recursive: true,
clean: false,
exclude: [],
dryrun: argv.testing
};
if (isWin) {
rsyncConf.chmod = "ugo=rwX";
}
// develop
if (argv.develop) {
rsyncConf.port = 2200;
rsyncConf.hostname = '104.131.15.228'; // hostname
rsyncConf.username = argv.user || 'movilizame' ; // ssh username
rsyncConf.destination = '/home/movilizame/sites/carpoolear_dev/'; // path where uploaded files go
// Production
} else if (argv.production) {
rsyncConf.port = 2200;
rsyncConf.hostname = '104.131.15.228'; // hostname
rsyncConf.username = argv.user || 'movilizame'; // ssh username
rsyncConf.destination = '/home/movilizame/sites/carpoolear_dev/'; // path where uploaded files go
} else if (argv.apalancar) {
rsyncConf.port = 2200;
rsyncConf.hostname = '45.55.196.14'; // hostname
rsyncConf.username = argv.user || 'movilizame'; // ssh username
rsyncConf.destination = '/home/movilizame/sites/apalancar/'; // path where uploaded files go
// Missing/Invalid Target
} else {
throwError('deploy', gutil.colors.red('Missing or invalid target'));
}
// Use gulp-rsync to sync the files
return gulp.src(rsyncPaths)
.pipe(gulpif(
argv.production,
prompt.confirm({
message: 'Heads Up! Are you SURE you want to push to PRODUCTION?',
default: false
})
))
.pipe(rsync(rsyncConf));
});
function throwError(taskName, msg) {
throw new gutil.PluginError({
plugin: taskName,
message: msg
});
}