forked from patternfly/angular-patternfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
400 lines (386 loc) · 12.4 KB
/
Gruntfile.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
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
module.exports = function (grunt) {
'use strict';
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
function init () {
grunt.initConfig({
availabletasks: {
tasks: {
options: {
descriptions: {
'help': 'Task list helper for your Grunt enabled projects.',
'clean': 'Deletes the content of the dist directory.',
'build': 'Builds the project (including documentation) into the dist directory. You can specify modules to be built as arguments (' +
'grunt build:buttons:notification) otherwise all available modules are built.',
'test': 'Executes the karma testsuite.',
'watch': 'Whenever js source files (from the src directory) change, the tasks executes jslint and documentation build.',
'ngdocs': 'Builds documentation into docs.',
'ngdocs:view': 'Builds documentation into docs and runs a web server. The docs can be accessed on http://localhost:8000/',
'ngdocs:publish': 'Publishes the ngdocs to the dist area. This should only be done when bumping the release version.'
},
groups: {
'Basic project tasks': ['help', 'clean', 'build', 'test'],
'Documentation tasks': ['ngdocs', 'ngdocs:view', 'ngdocs:publish']
}
}
}
},
clean: {
docs: ['docs'],
templates: ['templates/'],
all: ['dist/*', '!dist/docs']
},
concat: {
options: {
separator: ';'
},
dist: {
src: ['src/**/*.module.js', 'src/**/*.js', 'templates/*.js'],
dest: 'dist/angular-patternfly.js'
}
},
connect: {
docs: {
options: {
hostname: '0.0.0.0',
port: grunt.option("port") || 8000,
base: 'docs',
livereload: 35722,
open: true
}
}
},
copy: {
docdata: {
cwd: 'node_modules/patternfly/dist',
src: ['fonts/*', 'img/*'],
dest: 'docs',
expand: true
},
fa: {
cwd: 'node_modules/patternfly/',
src: ['components/font-awesome/**'],
dest: 'docs',
expand: true
},
img: {
cwd: 'misc/',
src: ['patternfly-orb.svg','patternfly-logo.svg', 'grid-sidebar.png', '*.png'],
dest: 'docs/img',
expand: true
},
publish: {
cwd: 'docs',
src: ['**'],
dest: 'dist/docs',
expand: true
},
distimg: {
cwd: 'misc',
src: ['canvas-dot-grid.png'],
dest: 'dist/imgs',
expand: true
},
distless: {
src: ['styles/**/*.less', 'src/**/*.less'],
dest: 'dist/less',
expand: true,
flatten: true
},
distlessDependencies: {
src: ['node_modules/patternfly/dist/less/color-variables.less'],
dest: 'dist/less/dependencies/patternfly',
expand: true,
flatten: true
}
},
'string-replace': {
dist: {
files: [{
cwd: 'dist/less/',
src: ['angular-patternfly.less'],
dest: 'dist/less',
expand: true
}],
options: {
replacements: [{
pattern: /\.\.\/src\/(.*?)+\//g,
replacement: ''
},{
pattern: '../node_modules/patternfly/dist/less',
replacement: 'dependencies/patternfly'
}]
}
}
},
less: {
patternfly: {
files: {
'dist/styles/angular-patternfly.css': 'styles/angular-patternfly.less'
},
options: {
paths: ['src/less/'],
strictMath: true
}
}
},
cssmin: {
target: {
files: [{
expand: true,
cwd: 'dist/styles',
src: ['*.css', '!*.min.css'],
dest: 'dist/styles',
ext: '.min.css'
}]
}
},
htmlhint: {
html: {
src: ['src/**/*.html'],
options: {
htmlhintrc: '.htmlhintrc'
}
}
},
eslint: {
standard: {
options: {
configFile: 'eslint.yaml'
},
src : [
'Gruntfile.js',
'src/**/*.js'
]
},
tests: {
options: {
configFile: 'test/eslint.yaml'
},
src : [
'test/**/*.js'
]
}
},
karma: {
unit: {
configFile: 'test/karma.conf.js',
singleRun: true,
browsers: ['PhantomJS']
}
},
coveralls: {
options: {
debug: true,
coverageDir: 'coverage',
dryRun: false,
force: true
}
},
ngdocs: {
options: {
title: 'ANGULAR PATTERNFLY',
dest: 'docs',
image: 'misc/logo-alt.svg',
scripts: [
'node_modules/jquery/dist/jquery.js',
'node_modules/bootstrap/dist/js/bootstrap.min.js',
'node_modules/bootstrap-select/js/bootstrap-select.js',
'node_modules/components-jqueryui/jquery-ui.min.js',
'node_modules/datatables.net/js/jquery.dataTables.js',
'node_modules/datatables.net-select/js/dataTables.select.js',
'node_modules/moment/moment.js',
'node_modules/d3/d3.js',
'node_modules/c3/c3.js',
'node_modules/patternfly/dist/js/patternfly-settings.js',
'node_modules/patternfly/dist/js/patternfly-settings-colors.js',
'node_modules/patternfly/dist/js/patternfly-settings-charts.js',
'node_modules/angular/angular.js',
'node_modules/angular-dragdrop/src/angular-dragdrop.js',
'node_modules/angularjs-datatables/dist/angular-datatables.js',
'node_modules/angularjs-datatables/dist/plugins/select/angular-datatables.select.min.js',
'node_modules/angular-sanitize/angular-sanitize.js',
'node_modules/angular-animate/angular-animate.js',
'node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js',
'misc/angular-bootstrap-prettify.js',
'node_modules/lodash/lodash.min.js',
'dist/angular-patternfly.js',
'node_modules/angular-ui-router/release/angular-ui-router.min.js',
'node_modules/angular-drag-and-drop-lists/angular-drag-and-drop-lists.js'],
html5Mode: false,
template: 'grunt-ngdocs-index.tmpl',
styles: ['node_modules/datatables.net-dt/css/jquery.dataTables.css',
'node_modules/patternfly/dist/css/patternfly.css',
'node_modules/patternfly/dist/css/patternfly-additions.css',
'dist/styles/angular-patternfly.css',
'misc/patternfly-showcase.css',
'misc/ng-docs.css',
'misc/examples.css']
},
all: ['src/**/*.js']
},
ngtemplates: {
options: {
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: false,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
}
},
'patternfly.form': {
cwd: 'src/',
src: ['form/**/*.html'],
dest: 'templates/form.js'
},
'patternfly.navigation': {
cwd: 'src/',
src: ['navigation/**/*.html'],
dest: 'templates/navigation.js'
},
'patternfly.notification': {
cwd: 'src/',
src: ['notification/**/*.html'],
dest: 'templates/notification.js'
},
'patternfly.card': {
cwd: 'src/',
src: ['card/**/*.html'],
dest: 'templates/card.js'
},
'patternfly.charts': {
cwd: 'src/',
src: ['charts/**/*.html'],
dest: 'templates/charts.js'
},
'patternfly.filters': {
cwd: 'src/',
src: ['filters/**/*.html'],
dest: 'templates/filters.js'
},
'patternfly.modals': {
cwd: 'src/',
src: ['modals/**/*.html'],
dest: 'templates/modals.js'
},
'patternfly.select': {
cwd: 'src/',
src: ['select/**/*.html'],
dest: 'templates/select.js'
},
'patternfly.sort': {
cwd: 'src/',
src: ['sort/**/*.html'],
dest: 'templates/sort.js'
},
'patternfly.table': {
cwd: 'src/',
src: ['table/**/*.html'],
dest: 'templates/table.js'
},
'patternfly.toolbars': {
cwd: 'src/',
src: ['toolbars/**/*.html'],
dest: 'templates/toolbars.js'
},
'patternfly.views': {
cwd: 'src/',
src: ['views/**/*.html'],
dest: 'templates/views.js'
},
'patternfly.wizard': {
cwd: 'src/',
src: ['wizard/**/*.html'],
dest: 'templates/wizard.js'
},
'patternfly.canvas': {
cwd: 'src/',
src: ['canvas-view/**/*.html'],
dest: 'templates/canvas.js'
},
'patternfly.pagination': {
cwd: 'src/',
src: ['pagination/**/*.html'],
dest: 'templates/pagination.js'
}
},
// ng-annotate tries to make the code safe for minification automatically
// by using the Angular long form for dependency injection.
ngAnnotate: {
dist: {
files: [{
src: 'dist/angular-patternfly.js',
dest: 'dist/angular-patternfly.js'
}]
}
},
remove: {
published: {
dirList: ['dist/docs']
}
},
uglify: {
options: {
mangle: false
},
build: {
files: {},
src: 'dist/angular-patternfly.js',
dest: 'dist/angular-patternfly.min.js'
}
},
watch: {
main: {
files: ['Gruntfile.js'],
tasks: ['eslint']
},
test: {
files: ['test/**/*.js'],
tasks: ['test']
},
all: {
files: ['Gruntfile.js', 'src/**/*.js', 'src/**/*.html', 'styles/**/*.css', '**/*.less'],
tasks: ['build'],
options: {
livereload: 35722
}
}
}
});
grunt.registerTask('copymain', ['copy:docdata', 'copy:fa', 'copy:img', 'copy:distimg', 'copy:distless', 'copy:distlessDependencies']);
// You can specify which modules to build as arguments of the build task.
grunt.registerTask('build', 'Create bootstrap build files', function () {
var concatSrc = [];
if (this.args.length) {
this.args.forEach(function (file) {
if (grunt.file.exists('./src/' + file)) {
grunt.log.ok('Adding ' + file + ' to the build queue.');
concatSrc.push('src/' + file + '/*.js');
} else {
grunt.fail.warn('Unable to build module \'' + file + '\'. The module doesn\'t exist.');
}
});
} else {
concatSrc = 'src/**/*.js';
}
grunt.task.run(['clean', 'lint', 'test', 'ngtemplates', 'concat', 'ngAnnotate', 'uglify:build', 'less', 'cssmin', 'copymain', 'string-replace', 'ngdocs', 'clean:templates']);
});
// Runs all the tasks of build with the exception of tests
grunt.registerTask('deploy', 'Prepares the project for deployment. Does not run unit tests', function () {
var concatSrc = 'src/**/*.js';
grunt.task.run(['clean', 'lint', 'ngtemplates', 'concat', 'ngAnnotate', 'uglify:build', 'less', 'cssmin', 'copymain', 'string-replace', 'ngdocs', 'clean:templates']);
});
grunt.registerTask('default', ['build']);
grunt.registerTask('ngdocs:view', ['build', 'connect:docs', 'watch']);
grunt.registerTask('lint', ['eslint', 'htmlhint']);
grunt.registerTask('test', ['karma', 'coveralls']);
grunt.registerTask('check', ['lint', 'test']);
grunt.registerTask('help', ['availabletasks']);
grunt.registerTask('serve', ['ngdocs:view']);
grunt.registerTask('ngdocs:publish', ['remove:published', 'copy:publish']);
}
init({});
};