-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
137 lines (114 loc) · 4.58 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
// default to development environment
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var gulp = require('gulp');
var fs = require('fs');
var browserify = require('browserify');
var ClosureCompiler = require('google-closure-compiler').compiler;
var envify = require('envify/custom');
var child_process = require('child_process');
var config = require('config')
var markdown = require('./lib/markdown');
gulp.task('markdown-help', function(done) {
var html = JSON.stringify(markdown.Converter.makeHtml(fs.readFileSync('./public/MarkdownHelp.md','ascii')));
var output = "module.exports=" + html + ';';
fs.writeFileSync('./public/javascripts/editorHelpHtml.js', output);
done();
});
gulp.task('markdown-browserify', gulp.series('markdown-help', function(done) {
var b = browserify('./public/javascripts/loadMarkdown.js');
var bStream = b.transform('uglifyify').bundle();
bStream.on('end', function() {
done();
});
bStream.pipe(fs.createWriteStream('./public/javascripts/markdownBundle.js'));
}));
gulp.task('markdown-closurecompiler', gulp.series('markdown-browserify', function(done) {
const closureCompiler = new ClosureCompiler({
'js': './public/javascripts/markdownBundle.js',
'js_output_file': './public/javascripts/markdownBundle-min.js',
'language_in': 'ECMASCRIPT5',
'language_out': 'ECMASCRIPT5',
'compilation_level': 'SIMPLE_OPTIMIZATIONS',
});
closureCompiler.run(function(exitCode, stdOut, stdErr) { done(); });
}));
gulp.task('markdown', gulp.series('markdown-closurecompiler'));
gulp.task('encryptPassword-browserify', function(done) {
var b = browserify('./public/javascripts/encryptPassword.js');
var bStream = b.transform(envify({RSA_PUBLIC_KEY: config.rsaPublicKey}))
.transform('uglifyify')
.bundle();
bStream.on('end', function() {
done();
});
bStream.pipe(fs.createWriteStream('./public/javascripts/encryptPasswordBundle.js'));
});
gulp.task('encryptPassword-closurecompiler', gulp.series('encryptPassword-browserify', function(done) {
const closureCompiler = new ClosureCompiler({
'js': './public/javascripts/encryptPasswordBundle.js',
'js_output_file': './public/javascripts/encryptPasswordBundle-min.js',
'language_in': 'ECMASCRIPT5',
'language_out': 'ECMASCRIPT5',
'compilation_level': 'SIMPLE_OPTIMIZATIONS',
});
closureCompiler.run(function(exitCode, stdOut, stdErr) {
console.error(stdErr);
done();
});
}));
gulp.task('encryptPassword', gulp.series('encryptPassword-closurecompiler'));
gulp.task('javascripts', gulp.series('encryptPassword'));
// sequelize migrations
// testing
gulp.task('selenium', function() {
// on my system selenium is an alias for:
// java -jar /Users/phil/selenium/selenium-server-standalone-2.47.1.jar -Dwebdriver.chrome.driver=/Users/phil/selenium/chromedriver
var selenium = child_process.spawn('java', ['-jar', '/Users/phil/selenium/selenium-server-standalone-2.47.1.jar',
'-Dwebdriver.chrome.driver=/Users/phil/selenium/chromedriver']);
selenium.stdout.pipe(process.stdout);
selenium.stderr.pipe(process.stderr);
});
// running dbs for the app
gulp.task('db:start', function() {
var pg = child_process.spawn('postgres', ['-D', '/usr/local/var/postgres/']);
pg.stdout.pipe(process.stdout);
pg.stderr.pipe(process.stdout);
var redis = child_process.spawn('redis-server', ['/usr/local/etc/redis.conf'])
redis.stdout.pipe(process.stdout);
redis.stderr.pipe(process.stdout);
});
gulp.task('db:migrate', function(done) {
const sequelize = child_process.spawn('sequelize', ['db:migrate']);
sequelize.stdout.pipe(process.stdout);
sequelize.stderr.pipe(process.stderr);
sequelize.on('exit', function() {
done();
});
});
// testing
gulp.task('test:unit', function(done) {
var mocha = child_process.spawn('mocha', ['test']);
mocha.stdout.pipe(process.stdout);
mocha.stderr.pipe(process.stdout);
mocha.on('exit', function() {
done();
});
});
gulp.task('test:integration', function(done) {
var mocha = child_process.spawn('mocha', ['test/integration', '-t', '10000']);
mocha.stdout.pipe(process.stdout);
mocha.stderr.pipe(process.stdout);
mocha.on('exit', function() {
done();
});
});
gulp.task('test:functional', function(done) {
var mocha = child_process.spawn('mocha', ['test/functional', '-t', '120000']);
mocha.stdout.pipe(process.stdout);
mocha.stderr.pipe(process.stdout);
mocha.on('exit', function() {
done();
});
});
// necessary tasks to start the app
gulp.task('default', gulp.series('javascripts', 'db:migrate'));