forked from Katello/bastion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
207 lines (193 loc) · 6.17 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
/**
* Copyright 2014 Red Hat, Inc.
*
* This software is licensed to you under the GNU General Public
* License as published by the Free Software Foundation; either version
* 2 of the License (GPLv2) or (at your option) any later version.
* There is NO WARRANTY for this software, express or implied,
* including the implied warranties of MERCHANTABILITY,
* NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
* have received a copy of GPLv2 along with this software; if not, see
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*/
/*global module,require*/
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var bastionConfig = {
src: 'app/assets/javascripts/bastion',
dist: 'dist'
};
try {
bastionConfig.src = require('./bower.json').appPath || bastionConfig.src;
} catch (e) {}
grunt.initConfig({
bastion: bastionConfig,
bower: {
update: {
options: {
targetDir: 'vendor/assets',
copy: true,
layout: function (type, component) {
// We provide a bit of customization here by allowing
// explicit path declarations if the component is included
// in the type. This is handy for sub-nesting within folders
// for a component. Fallback is 'byType'.
if (type.indexOf(component) !== -1) {
return require('path').join(type);
} else {
return require('path').join(type, component);
}
},
clearBowerDir: true
}
}
},
clean: {
build: '<%= bastion.dist %>'
},
connect: {
livereload: {
options: {
port: 9000,
hostname: '0.0.0.0',
middleware: function (connect) {
return [
lrSnippet,
mountFolder(connect, bastionConfig.src)
];
}
}
},
test: {
options: {
port: 9000,
middleware: function (connect) {
return [
mountFolder(connect, 'test')
];
}
}
}
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'<%= bastion.src %>/**/*.js',
'!<%= bastion.src %>/i18n/translations.js'
]
},
htmlhint: {
html: {
src: [bastionConfig.src + '/**/*.html'],
options: {
'tagname-lowercase': true,
'attr-lowercase': true,
'attr-value-doublequotes': true,
'tag-pair': true,
'tag-self-close': true,
'id-unique': true,
'src-not-empty': true,
'style-disabled': true,
'img-alt-require': true,
'spec-char-escape': true
},
},
},
karma: {
server: {
configFile: 'karma.conf.js',
autoWatch: true
},
singleRun: {
configFile: 'karma.conf.js',
singleRun: true
},
//continuous integration mode
ci: {
configFile: 'karma.conf.js',
reporters: ['progress', 'coverage'],
preprocessors: {
'app/assets/javascripts/bastion/**/*.html': ['ng-html2js'],
'app/assets/javascripts/bastion/**/*.js': ['coverage']
},
coverageReporter: {
type: 'cobertura',
dir: 'coverage/'
},
singleRun: true
}
},
docular: {
groups: [{
groupTitle: 'Bastion',
groupId: 'bastion',
sections: [{
id: 'bastion_api',
title: 'API Reference',
scripts: [
bastionConfig.src
]
}]
}],
showDocularDocs: false,
showAngularDocs: false
},
'nggettext_extract': {
bastion: {
options: {
markerName: 'translate'
},
src: ['<%= bastion.src %>/**/*.html', '<%= bastion.src %>/**/*.js'],
dest: '<%= bastion.src %>/i18n/katello.pot'
}
},
'nggettext_compile': {
options: {
module: 'Bastion.i18n'
},
bastion: {
src: ['<%= bastion.src %>/i18n/locale/**/*.po'],
dest: '<%= bastion.src %>/i18n/translations.js'
}
}
});
grunt.registerTask('docs', [
'docular'
]);
grunt.registerTask('i18n:extract', [
'nggettext_extract'
]);
grunt.registerTask('i18n:compile', [
'nggettext_compile'
]);
grunt.registerTask('test', [
'connect:test',
'karma:singleRun'
]);
grunt.registerTask('test:server', [
'connect:test',
'karma:server'
]);
grunt.registerTask('ci', [
'connect:test',
'jshint',
'htmlhint',
'karma:ci'
]);
grunt.registerTask('build', [
'clean:build',
'jshint',
'htmlhint',
'test'
]);
grunt.registerTask('default', ['build']);
};