-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
240 lines (140 loc) · 4.3 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
//todo purge unused modules and remove from package
var gulp = require('gulp');
var jsdoc = require('gulp-jsdoc3');
var sort = require('gulp-sort');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var es6transpiler = require('gulp-es6-transpiler');
var uglify = require('gulp-uglify');
var fs = require("fs");
var globby = require('globby');
var jshint = require('gulp-jshint');
var jasmine = require('gulp-jasmine');
var ts = require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
var runSequence = require('run-sequence');
var typedoc = require("gulp-typedoc");
var includes_typescript = globby.sync('./src/**/*.ts');
//console.log(includes_typescript);
var deleteFolderRecursive = function(path) {
var files = [];
if( fs.existsSync(path) ) {
files = fs.readdirSync(path);
files.forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};
gulp.task('build', function() {
runSequence('documentation','compile', 'test',
function(){
console.log('Build finished!');
});
});
/*
gulp.task('documentation', function (callback) {
console.log('todo documentation for TypeScript');
callback();
/*var documentation_config = {
"tags": {
"allowUnknownTags": true
},
"source": {
"excludePattern": "(^|\\/|\\\\)_"
},
"opts": {
"destination": "./documentation"
},
"plugins": [
"plugins/markdown"
],
"templates": {
"cleverLinks": false,
"monospaceLinks": false,
"default": {
"outputSourceFiles": true
},
"path": "ink-docstrap",
"theme": "cerulean",
"navType": "vertical",
"linenums": true,
"dateFormat": "MMMM Do YYYY, h:mm:ss a"
}
};
deleteFolderRecursive('./documentation');
gulp.src(includes)
.pipe(sort())
.pipe(jsdoc(documentation_config,callback));
});*/
gulp.task('compile', function () {
var tsProject = ts.createProject('tsconfig.json');
var tsResult = tsProject.src() // instead of gulp.src(...)
.pipe(ts(tsProject));
return tsResult.js.pipe(gulp.dest('./'));
/*
return gulp.src(includes_typescript)
.pipe(sourcemaps.init())
.pipe(ts({
noImplicitAny: false,
out: 'towns-shared.js'
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./build'))
//.pipe(uglify())
//.pipe(rename({suffix: '.min'}))
//.pipe(gulp.dest('./build'))
;
*/
});
gulp.task("documentation", function() {
/*
todo make it work
return gulp
.src(includes_typescript)
.pipe(typedoc(
{
mode: 'file',
module: "commonjs",
target: "es5",
includeDeclarations: true,
excludeExternals: true,
out: 'towns-shared.js',
// TypeDoc options (see typedoc docs)
name: "towns-shared",
//theme: "/home/hejny/www/towns/towns-shared/node_modules/typedoc-default-themes/bin/minimal",
theme: "/home/hejny/www/towns/towns-shared/node_modules/typedoc/lib/output/themes/",
plugins: [],
//plugins: ["my", "plugins"],
ignoreCompilerErrors: false,
version: true,
}))
;
/**/
});
/*todo is this useful task?
gulp.task('develop', function() {
gulp.start("build");
//gulp.watch(includes, ['build']);
gulp.watch(includes_typescript, ['build']);
});
/**/
/*todo is this useful task for TypeScript?
gulp.task("test-code", function() {
gulp.src(includes)
.pipe(jshint({esversion:6,laxcomma:true}))
.pipe(jshint.reporter("default"));
});
/**/
gulp.task("test", function() {
global.TOWNS = require('./build/towns-shared.js');
return gulp.src(['./test/*.js','./test/*/*.js'])
.pipe(jasmine({
includeStackTrace: true
}));
});