This repository has been archived by the owner on Dec 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
158 lines (131 loc) · 3.77 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
var gulp = require('gulp');
var argv = require('yargs').argv;
var tsc = require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
var path = require('path');
var tslint = require("gulp-tslint");
var nodeInspector = require('gulp-node-inspector');
var runSequence = require('run-sequence');
var nodemon = require('gulp-nodemon');
var mocha = require('gulp-mocha');
var del = require('del');
var apidoc = require('gulp-apidoc');
var istanbul = require('gulp-istanbul');
var tsProject = tsc.createProject('tsconfig.json');
nodemonConfiguration = {
script: './dist/app.js',
ext: 'ts', // js reload when any of these file extensions changes -> watch will trigger compileing of ts to js,
watch: ['dist'], //
exec: 'node',
env: {
'NODE_ENV': 'development'
}
};
gulp.task("clean", function(callback) {
return del(['dist/**'], callback);
});
gulp.task("lint", function() {
return gulp.src([
"src/**/**.ts"
])
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tslint.report());
});
gulp.task('ts-compile', function() {
var tsProject = tsc.createProject('tsconfig.json');
return gulp.src([
"src/**/**.ts",
"typings/index.d.ts",
"node_modules/inversify-dts/inversify-binding-decorators/inversify-binding-decorators.d.ts",
"node_modules/inversify-dts/inversify-express-utils/inversify-express-utils.d.ts",
"node_modules/inversify-dts/inversify-logger-middleware/inversify-logger-middleware.d.ts",
"node_modules/inversify-dts/inversify/inversify.d.ts"
])
.pipe(sourcemaps.init())
.pipe(tsProject())
.js.pipe(sourcemaps.write('../../code/ts'))
.pipe(gulp.dest('dist'));
});
gulp.task('node-inspector', function() {
gulp.src([])
.pipe(nodeInspector({
debugPort: 5858,
webHost: '0.0.0.0',
webPort: 8080,
saveLiveEdit: false,
preload: true,
inject: true,
hidden: [],
stackTraceLimit: 50,
sslKey: '',
sslCert: ''
}));
});
gulp.task('serve', function () {
var cfg = JSON.parse(JSON.stringify(nodemonConfiguration));
cfg.exec = 'node';
nodemon(cfg).on('restart', function () {
console.log('restarted!')
});
});
gulp.task('serve-debug', function () {
var cfg = JSON.parse(JSON.stringify(nodemonConfiguration));
cfg.exec = 'node --debug';
nodemon(cfg).on('restart', function () {
console.log('restarted!')
});
});
gulp.task('watch', false,
function () {
gulp.watch('src/**/**.ts', ['lint', 'compile']);
}
);
gulp.task('pre-test', function () {
if(!argv.brief) {
return gulp.src(['dist/**/*.js'])
// Covering files
.pipe(istanbul())
.pipe(istanbul.hookRequire());
}
});
gulp.task('test', ['pre-test'], function() {
var test = gulp.src(['dist/**/spec/**/*.js'], {read: false})
.pipe(mocha({}));
if(!argv.brief) {
return test.pipe(istanbul.writeReports());
} else {
return test;
}
});
gulp.task('copyConfigurations', function() {
gulp.src('src/**/*.json')
.pipe(gulp.dest('dist'));
gulp.src('src/**/*.hbs')
.pipe(gulp.dest('dist'));
gulp.src('src/public/**/*.*')
.pipe(gulp.dest('dist/public'));
});
gulp.task('compile', function(callback) {
runSequence('clean', 'copyConfigurations', 'ts-compile', callback);
});
gulp.task('default', function() {
runSequence(
'compile',
'serve-debug',
'node-inspector'
);
});
gulp.task('prod', function() {
runSequence(
'compile',
'serve'
);
});
gulp.task('apidoc', function(done) {
apidoc({
src: "src/",
dest: "src/public/documentation/api"
},done);
});