-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
108 lines (95 loc) · 3.17 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
var gulp = require('gulp');
var uglify = require('gulp-uglify-es').default;
var stripdebug = require('gulp-strip-debug');
var del = require('del');
var fs = require('fs');
var Readable = require('stream').Readable;
var exec = require('child_process').exec;
var server_sources = [
'./server.js',
'./file_tools.js',
'./api_tools.js',
'./prox_tools.js',
'./google_tools.js',
'./netgear_tools.js'
];
//['./*.js'];
var device_modules = './Devices/*.js';
var certSources = ['./https*'];
var confSources = ['./config/*'];
var outDir = './compiled';
var confOutDir = './compiled/config';
gulp.task('copy-config', function() {
return gulp.src(confSources)
.pipe(gulp.dest(confOutDir));
});
gulp.task('copy-certs', function() {
return gulp.src(certSources)
.pipe(gulp.dest(outDir));
})
gulp.task('minify-server', function() {
return gulp.src(server_sources)
.pipe(stripdebug())
.pipe(uglify())
.pipe(gulp.dest(outDir));
});
gulp.task('minify-device-modules', function() {
return gulp.src(device_modules)
.pipe(stripdebug())
.pipe(uglify())
.pipe(gulp.dest(outDir + '/Devices'));
})
gulp.task('clean', function() {
return del(['./compiled/*', './intermediate']);
});
gulp.task('clean-intermediate', function() {
return del(['./intermediate/']);
})
gulp.task('remove-jsdoc-comments', function() {
var jsdocs = new RegExp(/\/\*\*\s*\n([^\*]|(\*(?!\/)))*(\@\bfunction\b)([^\*]|(\*(?!\/)))*\*\//, 'gms');
var serverjs = fs.readFileSync('./server.js', 'utf8');
var s = new Readable;
serverjs = serverjs.replace(jsdocs, '')
s.push(serverjs);
s.push(null);
fs.mkdirSync('./intermediate/', {recursive: true});
fs.writeFile('./intermediate/server.nojsdocs.js', serverjs, function(err) {if (err) console.log(err)});
return s;
});
// build the docs for the server and main program files
gulp.task('build-server-docs', function(cb) {
exec('jsdoc -d ' + outDir + '/docs/server -c jsdoc.conf.json', function(err, stdout, stderr) {
console.log(stderr);
cb(err);
})
});
// build the docs for the device modules
gulp.task('build-device-module-docs', function(cb) {
exec('jsdoc -d ' + outDir + '/docs/server/ ./Devices', function(err, stdout, stderr) {
console.log(stderr);
cb(err);
})
});
gulp.task('build-docs',
gulp.series('build-server-docs')
// exec('npm run build-docs', function (err, stdout, stderr) {
// //console.log(stdout);
// console.log(stderr);
// cb(err);
// });
);
gulp.task('build-ng', function(cb) {
exec('cd angular && ng build --prod --output-path ../compiled/ng', function (err, stdout, stderr) {
//console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('build',
gulp.series('clean',
// build
gulp.parallel('minify-server', 'minify-device-modules', 'build-ng'),
gulp.parallel('remove-jsdoc-comments', 'build-docs', 'copy-config', 'copy-certs'),
'clean-intermediate'
)
);