-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
183 lines (163 loc) · 3.87 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
module.exports = function (grunt) {
var configuration = {
gitRemote : 'origin'
};
// -----------------------------------------------------------------------------------------------
// Plugin tasks
/**
* Transpile the AngularJS arithmetic component using Babel
*/
configuration.babel = {
options : {
sourceMap : true,
presets : ['es2015']
},
components : {
files : {
'build/angular-arithmetic.es5.js' : 'components/arithmetic/arithmetic.js'
}
}
};
/**
* Bump the package.json version property and commit the built artifacts
* @see "release-major", "release-minor", "release-patch" registered tasks below
*/
configuration.bump = {
options : {
commitFiles : [
'build/angular-arithmetic.es5.js',
'build/angular-arithmetic.es5.js.map',
'build/angular-arithmetic.js',
'CHANGELOG.md',
'package.json'
],
commitMessage : 'chore: release v%VERSION%',
pushTo : '<%= gitRemote %>'
}
};
/**
* Clean the build directory
*/
configuration.clean = ['build'];
/**
* Generate a CHANGELOG.md file based on the Angular commit message conventions
*/
configuration.conventionalChangelog = {
options : {
changelogOpts : {
preset : 'angular'
}
},
release : {
src : 'CHANGELOG.md'
}
};
/**
* Copy the Angular arithmetic component for external use
*/
configuration.copy = {
components : {
files : {
'build/angular-arithmetic.js' : 'components/arithmetic/arithmetic.js'
}
},
};
/**
* Lint the ES6 components
*/
configuration.eslint = {
components : [
'components/**/*.js'
]
};
/**
* Run a karma instance to unit test the AngularJS components
*/
configuration.karma = {
components : {
options : {
preprocessors : {
'components/**/*.js' : ['babel'],
},
files : [
'node_modules/angular/angular.js',
'node_modules/angular-mocks/angular-mocks.js',
'components/**/*.js'
],
browsers : ['PhantomJS'],
frameworks : ['jasmine'],
singleRun : true,
babelPreprocessor : {
options : {
presets : ['es2015']
}
}
}
}
};
/**
* Watch for components changes
*/
configuration.watch = {
components : {
files : 'components/**/*.js',
tasks : 'test'
}
};
// -----------------------------------------------------------------------------------------------
// Registered tasks
/**
* Build the AngularJS arithmetic component for external use
*/
grunt.registerTask('build', [
'clean',
'test',
'babel',
'copy'
]);
/**
* Release a SemVer Major version (X.x.x)
*/
grunt.registerTask('release-major', [
'build',
'bump-only:major',
'conventionalChangelog',
'bump-commit'
]);
/**
* Release a SemVer Minor version (x.X.x)
*/
grunt.registerTask('release-minor', [
'build',
'bump-only:minor',
'conventionalChangelog',
'bump-commit'
]);
/**
* Release a SemVer Patch version (x.x.X)
*/
grunt.registerTask('release-patch', [
'build',
'bump-only:patch',
'conventionalChangelog',
'bump-commit'
]);
/**
* Test the AngularJS components
*/
grunt.registerTask('test', [
'eslint',
'karma'
]);
// -----------------------------------------------------------------------------------------------
// Dependencies
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-conventional-changelog');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-karma');
grunt.initConfig(configuration);
};