-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgruntfile.js
More file actions
268 lines (245 loc) · 7.97 KB
/
Copy pathgruntfile.js
File metadata and controls
268 lines (245 loc) · 7.97 KB
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
module.exports = function (grunt) {
console.log(grunt.cli.tasks);
console.log("##### Build starting ###### ");
var pkg = grunt.file.readJSON('package.json');
// these will get overwritten ...
var versionNumber = pkg.version + "." + pkg.build;
var outputDirectory = "dist/" + versionNumber + "/";
// grunt.log.writeln( "outputDirectory: " + outputDirectory );
grunt.initConfig({
/**
* Invoke typescript complier ...
*/
ts: {
options: {
compile: true, // perform compilation. [true (default) | false]
comments: true, // same as !removeComments. [true | false (default)]
target: 'es5', // target javascript language. [es3 | es5 (grunt-ts default) | es6]
"lib": [
"es6",
"dom"
],
module: 'commonjs', // target javascript module style. [amd (default) | commonjs]
sourceMap: true, // generate a source map for every output js file. [true (default) | false] // Both html templates accept the ext and filename parameters.
noImplicitAny: false, // set to true to pass --noImplicitAny to the compiler. [true | false (default)]
fast: "watch", // see https://github.com/TypeStrong/grunt-ts/blob/master/docs/fast.md ["watch" (default) | "always" | "never"]
rootDir: "build/src/",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
declaration: true,
},
default: {
src: ["build/src/**/*.ts"],
outDir: "build/output/",
}
},
tslint: {
options: {
// can be a configuration object or a filepath to tslint.json
configuration: "tslint.json"
},
files: {
src: ['src/**/*.ts', 'specs/**/*.ts'],
}
},
/**
* Generate documentation
*/
jsdoc: {
dist: {
src: [
'build/output/*.js',
],
options: {
destination: 'JSdoc',
template: "node_modules/ink-docstrap/template",
// configure: "node_modules/ink-docstrap/template/jsdoc.conf.json"
configure: "jsdoc.conf.json"
}
}
},
/**
* Increment the build number
*/
buildnumber: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
/**
* Copy everything out of the build folder
*/
copy: {
specs: {
expand: true, cwd: 'specs/', src: ['**/*.ts'], dest: "build/specs",
},
src: {
expand: true, cwd: 'src/', src: ['**'], dest: "build/src",
},
build: {
expand: true, cwd: 'build/', src: ['**'], dest: outputDirectory,
},
docs: {
expand: true, cwd: 'JSDoc/', src: ['**'], dest: outputDirectory + "/JSDoc",
},
},
/**
* create outputDirectory based on version number
*/
buildfolder: {
default: {
options: {}
},
},
/**
* Lint all javascript files - running this on tsc output is presumably redundant but if there is a mix of files it will be useful
*/
jshint: {
files: [
'build/src/*.js'
],
// configure JSHint (documented at http://www.jshint.com/docs/)
options: {
// more options here if you want to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true
}
}
},
express: {
dev: {
options: {
background: true,
script: 'specs/server.js'
}
},
ws: {
options: {
background: true,
script: 'specs/webSocket.js'
}
},
},
uglify: {
dist: {
files: {
'build/bundle/comapi-foundation.min.js': ['build/bundle/comapi-foundation.js']
}
}
},
/**
*
*/
clean: {
tempfolders: {
src: ["build", "JSDoc", "tests", "coverage"]
},
},
replace: {
src: {
src: ['build/**/*.*'], // source files array (supports minimatch)
overwrite: true, // destination directory or file
replacements: [{
from: '_SDK_VERSION_', // string replacement
to: versionNumber
}]
},
},
webpack: {
build: {
entry: [
'./node_modules/reflect-metadata/Reflect.js',
'./build/output/foundation.js'
],
output: {
path: './build/bundle',
filename: "comapi-foundation.js",
library: ["COMAPI"],
libraryTarget: "var",
},
},
},
run: {
karma_typescript: {
cmd: 'npm',
args: [
'test'
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks("grunt-ts");
grunt.loadNpmTasks('grunt-build-number');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks("grunt-tslint");
grunt.loadNpmTasks('grunt-webpack');
grunt.loadNpmTasks('grunt-run');
grunt.task.registerMultiTask('buildfolder', 'creates output folder', function () {
var pkg = grunt.file.readJSON('package.json');
grunt.log.writeln(pkg.version + "." + pkg.build);
versionNumber = pkg.version + "." + pkg.build;
outputDirectory = "dist/" + versionNumber + "/";
});
// the default task can be run just by typing "grunt" on the command line - this does everything
grunt.registerTask('default', [
// 'clean',
'tslint',
'buildnumber',
'buildfolder',
'copy:specs',
'copy:src',
// 'typescript',
'ts',
'webpack',
'replace',
'jsdoc',
'copy:build',
'copy:docs',
]);
// Just create the docs ...
grunt.registerTask('docs', [
'jsdoc',
]);
// Just create the docs ...
grunt.registerTask('compile', [
// 'clean',
'tslint',
'buildnumber',
'buildfolder',
'copy:specs',
'copy:src',
// 'typescript',
'ts',
'webpack',
'replace',
'uglify',
'jsdoc',
]);
// Just create the docs ...
grunt.registerTask('lint', [
'jshint',
]);
// Just create the docs ...
grunt.registerTask('test', [
'clean',
'express:dev',
'express:ws',
'run:karma_typescript',
'express:dev:stop',
'express:ws:stop',
]);
// Just create the docs ...
grunt.registerTask('tidy', [
'clean',
]);
};