-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
120 lines (104 loc) · 2.91 KB
/
Copy pathgulpfile.js
File metadata and controls
120 lines (104 loc) · 2.91 KB
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
var gulp = require("gulp");
var ts = require("gulp-typescript");
var clean = require("gulp-clean");
var sourcemaps = require('gulp-sourcemaps');
var tsProject = ts.createProject("tsconfig.json");
var cache = require('gulp-cached');
const GulpSSH = require('gulp-ssh');
const JSON_FILES = ['src/*.json', 'src/**/*.json', 'package.json'];
const gulpConfig = require('./gulpconfig.json');
var fs = require('fs');
var privateKey = '';
try {
privateKey = fs.readFileSync(gulpConfig.private_key_path);
} catch (e) {
console.log("Not found privateKey");
}
const config = {
test: {
host: 'private.contractium.io',
port: 22,
username: 'ubuntu',
privateKey: privateKey
}
};
gulp.task("scripts-n-src", function () {
var tsResult = tsProject.src()
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(tsProject());
console.log("Build script success!!");
return tsResult.js
.pipe(sourcemaps.write("./")) // Now the sourcemaps are added to the .js file
.pipe(gulp.dest("dist"));
});
gulp.task("scripts", function () {
var tsResult = tsProject.src()
.pipe(cache("typescript"))
.pipe(tsProject())
.js
.pipe(gulp.dest("dist"));
});
gulp.task('views', function() {
return gulp.src('./src/views/**')
.pipe(gulp.dest('./dist/views/'));
});
gulp.task('email-template', function() {
return gulp.src('./src/email-template/**')
.pipe(gulp.dest('./dist/email-template/'));
});
gulp.task('json', function() {
return gulp.src(JSON_FILES)
.pipe(gulp.dest('dist'));
});
gulp.task('watch-ts', () => {
gulp.watch(['src/**/*.ts'], ['scripts']);
});
gulp.task('watch-json', () => {
gulp.watch(['src/**/*.json'], ['json']);
});
gulp.task('watch-views', () => {
gulp.watch(['src/views/*'], ['views']);
});
gulp.task('watch-email-template', () => {
gulp.watch(['src/email-template/*'], ['email-template']);
});
gulp.task('clean', () => {
return gulp.src('dist', {read: false})
.pipe(clean());
});
gulp.task('default', ['watch-ts', 'watch-json', 'watch-views', 'views', 'watch-email-template', 'email-template', 'json', 'scripts']);
gulp.task('build', ['views', 'email-template', 'json', 'scripts-n-src']);
gulp.task('migrate-test',
() => {
var gulpSSH = new GulpSSH({
ignoreErrors: false,
sshConfig: config.test
});
return gulpSSH
.shell([
'cd ~/bdlnetwork/bdlnetwork-server/dist',
'rm -rf ../dump/*',
'node run backup',
'cd ~/bdlnetwork/bdlnetwork-server',
'git pull origin master',
'npm install',
'gulp build',
'cd ./dist/',
'node run restore',
'NODE_ENV=development pm2 restart network'
])}
);
gulp.task('deploy-test', () => {
var gulpSSH = new GulpSSH({
ignoreErrors: false,
sshConfig: config.test
});
return gulpSSH
.shell([
'cd ~/ctu/ctu',
'git pull origin master',
'sudo npm install',
'gulp build',
'docker exec -it ctu_app sh -c "pm2 restart all"'
]);
})