-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
141 lines (117 loc) · 4.18 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
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
const { series, parallel } = require('gulp');
const exec = require('child_process').exec;
const execSync = require('child_process').execSync;
const glob = require('glob');
const run = require('gulp-run-command').default;
const path = require('path');
function runCommand(cb, cmd) {
exec(cmd, function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
}
function runCommand2(done, cmd, workDir) {
run(cmd, {
cwd: workDir
})().then(done);
}
function buildBackend(cb) {
runCommand(cb, 'npm run build');
}
function buildFrontend(cb) {
runCommand(cb, 'cd frontend && npm run build');
}
function testBackend(cb) {
runCommand(cb, 'npm run test');
}
function testFrontend(cb) {
runCommand(cb, 'cd frontend && npm run test');
}
function lintBackend(cb) {
runCommand(cb, 'npm run lint');
}
function lintFrontend(cb) {
runCommand(cb, 'cd frontend && npm run lint');
}
function e2eBackend(cb) {
runCommand(cb, 'npm run test:e2e');
}
function e2eFrontend(cb) {
runCommand2(cb, 'npm run test:e2e', 'frontend');
}
function installBackend(cb) {
runCommand(cb, 'npm install');
}
function preInstallBackend(cb) {
runCommand(cb, 'npm install gulp-run-command')
}
function installFrontend(cb) {
runCommand2(cb, 'npm install', 'frontend');
}
function installFrontendWebdriver(cb) {
runCommand2(cb, 'npm install webdriver-manager@latest', 'frontend/node_modules/protractor');
}
function updateFrontendWebdriver(cb) {
// Set the CHROMEDRIVER_VERSION environment variable to the chromedriver version that
// fits the installed chrome version. Not setting the variable will use the latest
// chromedriver. Note: you'll have to specify the full version number, e.g. 77.0.3865.40
// which can be found on https://chromedriver.storage.googleapis.com/.
var installedVersion;
if (process.env.OS === 'Windows_NT') {
console.log('Building on Windows');
glob.sync('C:\\Program Files (x86)\\Google\\Chrome\\Application\\[0-9]*').forEach(function (file) {
installedVersion = path.basename(file);
});
} else if (process.env.DESKTOP_SESSION === 'ubuntu') {
console.log('Building on Ubuntu');
installedVersion = execSync('grep "readonly UPSTREAM_VERSION" /usr/bin/chromium-browser | cut -d "=" -f 2');
} else {
console.log('Building on Mac');
glob.sync('/Applications/Google Chrome.app/Contents/Frameworks/Google Chrome Framework.framework/Versions/[0-9]*').sort().forEach(function (file) {
installedVersion = path.basename(file);
});
}
if (installedVersion == null) {
installedVersion = 'latest';
}
console.log('Detected installed Chrome version as ' + installedVersion);
const driverVersion = process.env.CHROMEDRIVER_VERSION ? process.env.CHROMEDRIVER_VERSION : installedVersion;
console.log('Updating Chromedriver to ' + driverVersion);
runCommand2(cb, `node_modules/.bin/webdriver-manager update --versions.chrome ${driverVersion}`,
'frontend/node_modules/protractor');
}
function installBackendCi(cb) {
runCommand(cb, 'npm ci');
}
function installFrontendCi(cb) {
runCommand2(cb, 'npm ci', 'frontend');
}
function deployBackend(cb) {
runCommand(cb, 'npm run prestart:prod')
}
function deployFrontend(cb) {
runCommand2(cb, 'npm run build:prod', 'frontend')
}
exports.default = series(
parallel(installBackend,
series(installFrontend, installFrontendWebdriver, updateFrontendWebdriver)),
parallel(lintBackend, lintFrontend),
parallel(testBackend, testFrontend),
parallel(e2eBackend, e2eFrontend))
exports.build = series(buildBackend, buildFrontend)
exports.test = series(testBackend, testFrontend)
exports.lint = series(lintBackend, lintFrontend)
exports.e2e = series(e2eBackend, e2eFrontend)
exports.e2eBackend = series(e2eBackend)
exports.install = series(installBackend, installFrontend)
exports.installCi = series(installBackendCi, installFrontendCi)
exports.cibuild = series(
preInstallBackend,
parallel(installBackendCi,
series(installFrontendCi, installFrontendWebdriver, updateFrontendWebdriver)),
parallel(lintBackend, lintFrontend))
exports.citest = series(
parallel(testBackend, testFrontend),
parallel(e2eBackend, e2eFrontend))
exports.deploy = series(deployFrontend, deployBackend)