forked from platanus/angular-restmod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
227 lines (211 loc) · 6.24 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
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('bower.json'),
meta: {
banner: '/**\n' +
' * <%= pkg.description %>\n' +
' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * @link <%= pkg.homepage %>\n' +
' * @author <%= pkg.authors.join(", ") %>\n' +
' * @license MIT License, http://www.opensource.org/licenses/MIT\n' +
' */\n'
},
bower: {
install: {}
},
concat: {
options: {
banner: '<%= meta.banner %>\n(function(angular, undefined) {\n\'use strict\';\n',
footer: '})(angular);',
process: function(src, filepath) {
return src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
}
},
dist: {
files: {
'dist/<%= pkg.name %>.js': [
'src/module.js',
'src/module/**/*.js'
],
'dist/<%= pkg.name %>-bundle.js': [
'bower_components/angular-inflector/dist/angular-inflector.js',
'src/module.js',
'src/module/**/*.js'
],
'dist/plugins/debounced.js': 'src/plugins/debounced.js',
'dist/plugins/dirty.js': 'src/plugins/dirty.js',
'dist/plugins/paged.js': 'src/plugins/paged.js',
'dist/plugins/find-many.js': 'src/plugins/find-many.js',
'dist/plugins/preload.js': 'src/plugins/preload.js',
'dist/plugins/nested-dirty.js': 'src/plugins/nested-dirty.js',
'dist/styles/ams.js': 'src/styles/ams.js'
}
}
},
uglify: {
options: {
banner: '<%= meta.banner %>'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': 'dist/<%= pkg.name %>.js',
'dist/<%= pkg.name %>-bundle.min.js': 'dist/<%= pkg.name %>-bundle.js',
'dist/plugins/debounced.min.js': 'dist/plugins/debounced.js',
'dist/plugins/dirty.min.js': 'dist/plugins/dirty.js',
'dist/plugins/paged.min.js': 'dist/plugins/paged.js',
'dist/plugins/find-many.min.js': 'dist/plugins/find-many.js',
'dist/plugins/preload.min.js': 'dist/plugins/preload.js',
'dist/plugins/nested-dirty.min.js': 'dist/plugins/nested-dirty.js',
'dist/styles/ams.min.js': 'dist/styles/ams.js'
}
}
},
jshint: {
files: ['Gruntfile.js', 'src/*.js'],
options: {
curly: false,
browser: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
expr: true,
node: true,
globals: {
exports: true,
angular: false,
$: false
}
}
},
karma: {
options: {
configFile: 'karma.conf.js'
},
build: {
singleRun: true,
autoWatch: false
},
dev: {
singleRun: false,
autoWatch: true
},
sauce: {
configFile: 'karma-sauce.conf.js',
singleRun: true
}
},
jsdoc : {
dist : {
src: ['src/*.js', 'src/**/*.js', 'docs/index.md'],
options: {
tutorials: 'docs/guides',
destination: '.docs',
configure: 'jsdoc.json'
}
}
},
'gh-pages': {
options: {
base: '.docs'
},
src: ['**']
},
changelog: {
options: {
dest: 'CHANGELOG.md'
}
},
gitcommit: {
bump: {
options: {
message: "<%= pkg.version %>",
noStatus: true
},
files: {
src: [
'bower.json',
'package.json',
'CHANGELOG.md',
'dist/**/*'
]
}
}
},
gittag: {
bump: {
options: {
tag: "v<%= pkg.version %>",
noStatus: true
}
}
},
gitpush: {
bump: {
options: {
branch: 'master',
tags: true
}
}
},
'npm-publish': {
options: {
// list of tasks that are required before publishing
requires: ['build'],
// if the workspace is dirty, abort publishing (to avoid publishing local changes)
abortIfDirty: true,
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-bower-task');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-jsdoc'); // use jsdocs for now, until docular is ready
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-conventional-changelog');
grunt.loadNpmTasks('grunt-git');
grunt.loadNpmTasks('grunt-npm');
// Default task
grunt.registerTask('default', ['build']);
// Build task
grunt.registerTask('build', ['bower', 'karma:build', 'concat', 'uglify']);
// Publish task
grunt.registerTask('pub', ['jsdoc', 'gh-pages']);
// Test task
grunt.registerTask('test', ['karma:build']);
// CI task
grunt.registerTask('ci', ['karma:dev']);
// Release Task
grunt.registerTask('release', ['bump', 'changelog', 'build']);
// Publish Task
grunt.registerTask('publish', ['gitcommit:bump', 'gittag:bump', 'gitpush:bump', 'npm-publish']);
// 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 = grunt.config.data.pkg.version;
version = bumpVersion(version, versionType || 'patch');
grunt.config.data.pkg.version = version;
grunt.file.write('bower.json', JSON.stringify(grunt.config.data.pkg, null, ' '));
var packagejson = grunt.file.readJSON('package.json');
packagejson.version = version;
grunt.file.write('package.json', JSON.stringify(packagejson, null, ' '));
grunt.log.ok('Version bumped to ' + version);
});
};