-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathGruntfile.js
More file actions
143 lines (128 loc) · 4.99 KB
/
Gruntfile.js
File metadata and controls
143 lines (128 loc) · 4.99 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
module.exports = function(grunt) {
// Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jsdoc : {
cmwapi: {
src: ['README.md', 'cmwapi/**/*.js', 'cmwapi-adapter/**/*.js', '!cmwapi-adapter/Vendor/**'],
options: {
destination: 'target/jsdoc/cmwapi',
template: "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template",
configure: "jsdoc.conf.json",
private: true
}
},
widget : {
src: ['owf-map-widget/js/*.js',
'owf-map-widget/js/models/**/*.js',
'image-collection-query-widget/js/app.js',
'image-collection-query-widget/js/util/*.js'],
options: {
destination: 'target/jsdoc/widget',
private: true,
template: "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template",
configure: "jsdoc.conf.json"
}
}
},
karma: {
unit: {
configFile: 'test/test-phantom.conf.js'
},
chrome: {
configFile: 'test/test-chrome.conf.js'
}
},
jshint: {
src: ['Gruntfile.js',
'cmwapi/**/*.js',
'cmwapi-adapter/**/*.js',
'owf-map-widget/js/**/*.js',
'owf-map-widget/dijits/**/*.js',
'image-collection-query-widget/js/**/*.js'],
options: {
jshintrc: true
}
},
uglify: {
options: {
banner: '<%= pkg.license %>'
},
cmwapi: {
files: [{
src: 'cmwapi/**/*.js', // source files mask
dest: 'deployment', // destination folder
expand: true, // allow dynamic building
flatten: false // remove all unnecessary nesting
//ext: '.min.js' // replace .js to .min.js
}]
},
cmwapi_adapter: {
files: [{
src: 'cmwapi-adapter/**/*.js', // source files mask
dest: 'deployment', // destination folder
expand: true, // allow dynamic building
flatten: false // remove all unnecessary nesting
//ext: '.min.js' // replace .js to .min.js
}]
}
},
copy: {
main: {
files: [
// includes files within path and its sub-directories
{expand: true, src: ['cmwapi/**'], dest: 'owf-map-widget/js/lib'},
{expand: true, src: ['cmwapi-adapter/**'], dest: 'owf-map-widget/js/lib'}
]
},
deployment: {
files: [
// includes files within path and its sub-directories
{expand: true, src: ['basic-map-widget/**'], dest: 'deployment'},
{expand: true, src: ['contacts/**'], dest: 'deployment'},
{expand: true, src: ['owf-map-widget/**'], dest: 'deployment'}
]
}
},
clean : {
deployment : {
src : [ "deployment/**" ]
},
coverage: {
src : [ "coverage/*.json" ]
}
}
});
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
// Workaround for allowing tasks that can fail but should not abort the build chains.
// Reference: http://stackoverflow.com/questions/16612495/continue-certain-tasks-in-grunt-even-if-one-fails
grunt.registerTask('usetheforce_on',
'force the force option on if needed',
function() {
if ( !grunt.option( 'force' ) ) {
grunt.config.set('usetheforce_set', true);
grunt.option( 'force', true );
}
}
);
grunt.registerTask('usetheforce_restore',
'turn force option off if we have previously set it',
function() {
if ( grunt.config.get('usetheforce_set') ) {
grunt.option( 'force', false );
}
}
);
// Helpful aliases
grunt.registerTask('test', ['clean:coverage','karma:unit']);
// Default task(s)
grunt.registerTask('default', ['usetheforce_on', 'jshint', 'usetheforce_restore', 'karma:unit', 'jsdoc'/**, 'copy'**/] );
// Deployment task
grunt.registerTask('deploy', ['clean:deployment', 'usetheforce_on', 'jshint', 'usetheforce_restore',
'karma:unit', 'jsdoc', 'uglify', 'copy:deployment']);
};