-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
253 lines (239 loc) · 8.02 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
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.webcomponents.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
},
fonts: {
cwd: 'node_modules/patternfly-webcomponents/dist/',
src: ['fonts/*'],
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.min.js',
'lib/angular/angular.js',
'misc/angular-bootstrap-prettify.js',
'node_modules/webcomponentsjs/full.js',
'node_modules/patternfly-webcomponents/dist/js/patternfly.js',
'dist/angular-patternfly.webcomponents.js'],
html5Mode: false,
template: 'grunt-ngdocs-index.tmpl',
//styles: ['lib/patternfly/dist/css/patternfly.css', 'lib/patternfly/dist/css/patternfly-additions.css',
styles: ['lib/patternfly/dist/css/patternfly-additions.css',
'node_modules/patternfly-webcomponents/dist/css/patternfly.css',
'dist/styles/patternfly-webcomponents.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
}
}
},
// 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.webcomponents.js',
dest: 'dist/angular-patternfly.webcomponents.js'
}]
}
},
remove: {
published: {
dirList: ['dist/docs']
}
},
uglify: {
options: {
mangle: false
},
build: {
files: {},
src: 'dist/angular-patternfly.webcomponents.js',
dest: 'dist/angular-patternfly.webcomponents.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:fonts', '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', '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({});
};