-
Notifications
You must be signed in to change notification settings - Fork 840
/
Gruntfile.js
188 lines (168 loc) · 4.91 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
module.exports = function(grunt) {
'use strict';
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: [
'/**',
' * <%= pkg.description %>',
' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>' +
' * @link <%= pkg.homepage %>',
' * @author <%= pkg.author %>',
' * @license MIT License, http://www.opensource.org/licenses/MIT',
' */'
].join('\n')
},
dirs: {
dest: 'dist'
},
concat: {
options: {
banner: '<%= meta.banner %>'
},
dist: {
src: ['src/*.js'],
dest: '<%= dirs.dest %>/<%= pkg.name %>.js'
}
},
zip: {
'<%= dirs.dest %>/restangular.zip': [
'<%= dirs.dest %>/<%= pkg.name %>.js',
'<%= dirs.dest %>/<%= pkg.name %>.min.js'
]
},
bowerInstall: {
install: {
}
},
uglify: {
options: {
banner: '<%= meta.banner %>'
},
dist: {
src: ['<%= concat.dist.dest %>'],
dest: '<%= dirs.dest %>/<%= pkg.name %>.min.js'
}
},
jshint: {
files: ['Gruntfile.js', 'src/*.js'],
options: {
jshintrc: true
}
},
karma: {
options: {
configFile: 'karma.conf.js'
},
build: {
singleRun: true,
autoWatch: false
},
debug: {
singleRun: false,
autoWatch: true,
browsers: ['Chrome']
},
travis: {
singleRun: true,
autoWatch: false,
browsers: ['Firefox']
},
travisUnderscore: {
singleRun: true,
autoWatch: false,
browsers: ['Firefox'],
configFile: 'karma.underscore.conf.js',
},
buildUnderscore: {
configFile: 'karma.underscore.conf.js',
singleRun: true,
autoWatch: false
},
dev: {
autoWatch: true
}
},
coveralls: {
// Options relevant to all targets
options: {
// When true, grunt-coveralls will only print a warning rather than
// an error, to prevent CI builds from failing unnecessarily (e.g. if
// coveralls.io is down). Optional, defaults to false.
force: false
},
restangular: {
// LCOV coverage file (can be string, glob or array)
src: 'coverage/**/lcov.info',
options: {
// Any options for just this target
}
},
},
conventionalChangelog: {
options: {
changelogOpts: {
// conventional-changelog options go here
outputUnreleased: true,
// preset: 'angular'
},
context: {
// context goes here
},
gitRawCommitsOpts: {
// git-raw-commits options go here
},
parserOpts: {
// conventional-commits-parser options go here
},
writerOpts: {
// conventional-changelog-writer options go here
}
},
release: {
src: 'CHANGELOG.md'
}
}
});
// Load the plugin that provides the "jshint" task.
grunt.loadNpmTasks('grunt-contrib-jshint');
// Load the plugin that provides the "concat" task.
grunt.loadNpmTasks('grunt-contrib-concat');
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-bower-task');
grunt.renameTask('bower', 'bowerInstall');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-conventional-changelog');
grunt.loadNpmTasks('grunt-zip');
grunt.loadNpmTasks('grunt-coveralls');
// Default task.
grunt.registerTask('default', ['build']);
// Build task.
grunt.registerTask('build', ['bowerInstall', 'karma:build', 'karma:buildUnderscore', 'concat', 'uglify', 'zip']);
grunt.registerTask('test', ['karma:build', 'karma:buildUnderscore']);
grunt.registerTask('test-debug', ['karma:debug']);
grunt.registerTask('travis', ['karma:travis', 'karma:travisUnderscore', 'coveralls']);
grunt.registerTask('changelog', ['conventionalChangelog']);
// Provides the "bump" task.
grunt.registerTask('bump', 'Increment version number', function() {
var versionType = grunt.option('type');
function bumpVersion(version, versionType) {
var type = {patch: 2, minor: 1, major: 0},
parts = version.split('.'),
idx = type[versionType || 'patch'];
parts[idx] = parseInt(parts[idx], 10) + 1;
while(++idx < parts.length) { parts[idx] = 0; }
return parts.join('.');
}
var version;
function updateFile(file) {
var json = grunt.file.readJSON(file);
version = json.version = bumpVersion(json.version, versionType || 'patch');
grunt.file.write(file, JSON.stringify(json, null, ' '));
}
updateFile('package.json');
grunt.log.ok('Version bumped to ' + version);
});
};