This repository has been archived by the owner on Oct 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Gruntfile.js
278 lines (252 loc) · 6.11 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
'use strict';
module.exports = function(grunt) {
//--------------------------------------------------------------------------
// SETUP CONFIG
//--------------------------------------------------------------------------
// Helpers to make things cleaner
var pkg = grunt.file.readJSON('./package.json');
var dev = (grunt.option('dev')) ? '-dev' : '';
var version = pkg.version + dev;
var testOpts = {execOptions: {maxBuffer: 20 * 1024 * 1024}};
var testCommand = 'node_modules/bats/libexec/bats ${CI:+--tap}';
// Setup task config
var config = {
// Arrays of relevant code classified by type
files: {
js: {
src: [
'*.js',
'lib/*.js',
'scripts/*.js',
'app/scripts/*.js',
'app/plugins/*/*.js',
'app/plugins/*/lib/*.js'
]
}
},
// Clean out the build dirs
clean: {
build: ['build', 'dist'],
},
// Copy relevant things
copy: {
app: {
src: [
'index.js',
'lib/*.js',
'app/**/*',
'app/.gitignore',
'package.json'
],
dest: 'build',
expand: true,
options: {
mode: true,
noProcess: [
'app/*.{png,gif,jpg,ico,psd,ttf,otf,woff,svg}'
],
process: function(content, srcPath) {
// Switch it up
switch (srcPath) {
// Return a dev version
case 'app/package.json':
return content.replace(pkg.version, version);
case 'package.json':
return content.replace(pkg.version, version);
default:
return content;
}
},
}
}
},
// Compress build
compress: {
tar: {
options: {
archive: 'dist/kalabox-app-pantheon.tar.gz'
},
expand: true,
cwd: 'build/',
src: ['**'],
dest: './'
},
zip: {
options: {
archive: 'dist/kalabox-app-pantheon.zip'
},
expand: true,
cwd: 'build/',
src: ['**'],
dest: './'
}
},
// This handles automatic version bumping
bump: {
options: {
files: ['package.json', 'app/package.json'],
updateConfigs: [],
commit: true,
commitMessage: 'Release v%VERSION%',
commitFiles: ['package.json', 'app/package.json'],
createTag: true,
tagName: 'v%VERSION%',
tagMessage: 'Version %VERSION%',
pushTo: 'origin',
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
globalReplace: false,
prereleaseName: 'rc',
metadata: '',
regExp: false
}
},
// Some linting and code standards
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: ['Gruntfile.js', '<%= files.js.src %>', 'index.js']
},
jscs: {
src: ['Gruntfile.js', '<%= files.js.src %>', 'index.js'],
options: {
config: '.jscsrc'
}
},
mdlint: ['docs/**/*.md'],
// Shell things
shell: {
// Tests
images: {
options: testOpts,
command: testCommand + ' ./test/images.bats'
},
drupal7: {
options: testOpts,
command: testCommand + ' ./test/drupal7.bats'
},
drupal8: {
options: testOpts,
command: testCommand + ' ./test/drupal8.bats'
},
backdrop: {
options: testOpts,
command: testCommand + ' ./test/backdrop.bats'
},
wordpress: {
options: testOpts,
command: testCommand + ' ./test/wordpress.bats'
},
drush: {
options: testOpts,
command: testCommand + ' ./test/drush.bats'
},
// Build
build: {
options: {
execOptions: {
maxBuffer: 20 * 1024 * 1024,
cwd: 'build'
}
},
command: 'npm install --production'
}
}
};
//--------------------------------------------------------------------------
// LOAD TASKS
//--------------------------------------------------------------------------
// load task config
grunt.initConfig(config);
// load external tasks
//grunt.loadTasks('tasks');
// load grunt-* tasks from package.json dependencies
require('matchdep').filterAll('grunt-*').forEach(grunt.loadNpmTasks);
//--------------------------------------------------------------------------
// SETUP WORKFLOWS
//--------------------------------------------------------------------------
/*
* Bump Taskz
*/
// Bump our minor version
grunt.registerTask('bigrelease', [
'bump:minor'
]);
// Bump our patch version
grunt.registerTask('release', [
'bump:patch'
]);
// Do a prerelease version
grunt.registerTask('prerelease', [
'bump:prerelease'
]);
/*
* Pkg tasks
*/
// Build out an app
grunt.registerTask('pkg', [
'clean:build',
'copy:app',
'shell:build',
'compress:tar',
'compress:zip'
]);
/*
* Code tests
*/
// Standards and code
grunt.registerTask('test:code', [
'jshint',
'jscs'
// 'mdlint'
]);
/*
* Functional tests
*/
// Build the images
grunt.registerTask('test:images', [
'shell:images'
]);
// Basic Drupal 7 tests
grunt.registerTask('test:drupal7', [
'shell:drupal7'
]);
// Basic Drupal 8 tests
grunt.registerTask('test:drupal8', [
'shell:drupal8'
]);
// Basic Backdrop tests
grunt.registerTask('test:backdrop', [
'shell:backdrop'
]);
// Basic Wordpress tests
grunt.registerTask('test:wordpress', [
'shell:wordpress'
]);
// Basic Drush tests
grunt.registerTask('test:drush', [
'shell:drush'
]);
// All Framework tests
grunt.registerTask('test:frameworks', [
'shell:drupal7',
'shell:drupal8',
'shell:backdrop',
'shell:wordpress'
]);
// All Func tests
grunt.registerTask('test:func', [
'test:images',
'test:frameworks',
'test:drush'
]);
/*
* All tests
*/
// All tests
grunt.registerTask('test', [
'test:code',
'test:func'
]);
};