forked from patternfly/angular-patternfly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
297 lines (283 loc) · 9.08 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
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: 'lib/patternfly/dist',
src: ['fonts/*', 'img/*'],
dest: 'docs',
expand: true
},
fa: {
cwd: 'lib/patternfly/',
src: ['components/font-awesome/**'],
dest: 'docs',
expand: true
},
styles: {
cwd: 'styles/',
src: ['*.css', '!*.min.css'],
dest: 'dist/styles',
expand: true
},
img: {
cwd: 'misc/',
src: 'patternfly-orb.svg',
dest: 'docs/img',
expand: true
},
publish: {
cwd: 'docs',
src: ['**'],
dest: 'dist/docs',
expand: true
}
},
cssmin: {
target: {
files: [{
expand: true,
cwd: 'styles',
src: ['*.css', '!*.min.css'],
dest: 'dist/styles',
ext: '.min.css'
}]
}
},
htmlhint: {
html: {
src: ['src/**/*.html'],
options: {
htmlhintrc: '.htmlhintrc'
}
}
},
eslint: {
options: {
configFile: 'eslint.yaml'
},
target: [
'Gruntfile.js',
'src/**/*.js'
]
},
karma: {
unit: {
configFile: 'test/karma.conf.js',
singleRun: true,
browsers: ['PhantomJS']
}
},
ngdocs: {
options: {
title: 'Angular Patternfly Documentation',
dest: 'docs',
image: 'misc/logo-alt.svg',
scripts: ['lib/jquery/dist/jquery.js',
'lib/bootstrap/dist/js/bootstrap.js',
'lib/bootstrap-combobox/js/bootstrap-combobox.js',
'lib/bootstrap-datepicker/dist/js/bootstrap-datepicker.js',
'lib/bootstrap-select/js/bootstrap-select.js',
'lib/patternfly-bootstrap-treeview/src/js/bootstrap-treeview.js',
'lib/c3/c3.js',
'lib/d3/d3.js',
'lib/patternfly/dist/js/patternfly.js',
'lib/angular/angular.js',
'lib/angular-sanitize/angular-sanitize.js',
'lib/angular-animate/angular-animate.js',
'lib/angular-bootstrap/ui-bootstrap-tpls.js',
'misc/angular-bootstrap-prettify.js',
'lib/lodash/lodash.min.js',
'dist/angular-patternfly.js'],
html5Mode: false,
template: 'grunt-ngdocs-index.tmpl',
styles: ['lib/patternfly/dist/css/patternfly.css', 'lib/patternfly/dist/css/patternfly-additions.css',
'dist/styles/angular-patternfly.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.sort': {
cwd: 'src/',
src: ['sort/**/*.html'],
dest: 'templates/sort.js'
},
'patternfly.toolbars': {
cwd: 'src/',
src: ['toolbars/**/*.html'],
dest: 'templates/toolbars.js'
},
'patternfly.views': {
cwd: 'src/',
src: ['views/**/*.html'],
dest: 'templates/views.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']
},
all: {
files: ['Gruntfile.js', 'src/**/*.js', 'src/**/*.html', 'styles/**/*.css'],
tasks: ['build'],
options: {
livereload: 35722
}
}
}
});
grunt.registerTask('copymain', ['copy:docdata', 'copy:fa', 'copy:styles', 'copy:img']);
// 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', 'cssmin', 'copymain', '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', 'cssmin', 'copymain', 'ngdocs', 'clean:templates']);
});
grunt.registerTask('default', ['build']);
grunt.registerTask('ngdocs:view', ['build', 'connect:docs', 'watch']);
grunt.registerTask('lint', ['eslint', 'htmlhint']);
grunt.registerTask('test', ['karma']);
grunt.registerTask('check', ['lint', 'test']);
grunt.registerTask('help', ['availabletasks']);
grunt.registerTask('server', ['ngdocs:view']);
grunt.registerTask('ngdocs:publish', ['remove:published', 'copy:publish']);
}
init({});
};