Skip to content

Commit ab19558

Browse files
Merge pull request ExactTarget#1103 from cormacmccarthy/GH1094---update-dist-and-qunit-process
fixes #1094 makes dist compile and test prior to release. Also prompts f...
2 parents 28b5e0e + 0d1d41a commit ab19558

File tree

3 files changed

+145
-19
lines changed

3 files changed

+145
-19
lines changed

Gruntfile.js

Lines changed: 107 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ module.exports = function(grunt) {
66
// use --no-livereload to disable livereload. Helpful to 'serve' multiple projects
77
var isLivereloadEnabled = (typeof grunt.option('livereload') !== 'undefined') ? grunt.option('livereload') : true;
88

9-
// release minor or patch version. Do major releases manually
10-
var versionReleaseType = (typeof grunt.option('minor') !== 'undefined') ? 'minor':'patch';
9+
var semver = require('semver');
10+
var currentVersion = require('./package.json').version;
1111

1212
// Project configuration.
1313
grunt.initConfig({
@@ -47,14 +47,15 @@ module.exports = function(grunt) {
4747
if (ver === 'browserGlobals') {
4848
return 'http://localhost:<%= connect.testServer.options.port %>/test/fuelux-browser-globals.html';
4949
}
50-
return 'http://localhost:<%= connect.testServer.options.port %>/test/fuelux.html?jquery=' + ver;
50+
return 'http://localhost:<%= connect.testServer.options.port %>/test/fuelux.html?jquery=' + ver + '&testdist=true';
5151
}),
52-
testUrl: ['http://localhost:<%= connect.testServer.options.port %>/test/fuelux.html?jquery=' + '1.9.1'],
52+
testUrl: ['http://localhost:<%= connect.testServer.options.port %>/test/fuelux.html?jquery=' + '1.9.1&testdist=true'],
5353

5454
//Tasks configuration
5555
clean: {
5656
dist: ['dist'],
57-
zipsrc: ['dist/fuelux'] // temp folder
57+
zipsrc: ['dist/fuelux'], // temp folder
58+
screenshots: ['page-at-timeout-*.jpg']
5859
},
5960
compress: {
6061
zip: {
@@ -207,6 +208,7 @@ module.exports = function(grunt) {
207208
}
208209
},
209210
qunit: {
211+
//run with `grunt releasetest` or `grunt travisci`. Requires connect server to be running.
210212
full: {
211213
options: {
212214
urls: '<%= allTestUrls %>',
@@ -219,7 +221,13 @@ module.exports = function(grunt) {
219221
}
220222
}
221223
},
222-
simple: ['test/*.html']
224+
//can be run with `grunt qunit:simple`
225+
simple: ['test/*.html'],
226+
dist: {
227+
options: {
228+
urls: ['http://localhost:<%= connect.server.options.port %>/test/fuelux.html?testdist=true']
229+
}
230+
}
223231
},
224232
less: {
225233
dist: {
@@ -247,6 +255,75 @@ module.exports = function(grunt) {
247255
},
248256

249257
},
258+
prompt: {
259+
bump: {
260+
options: {
261+
questions: [
262+
{
263+
config: 'bump.increment',
264+
type: 'list',
265+
message: 'Bump version from ' + '<%= pkg.version %>' + ' to:',
266+
choices: [
267+
// {
268+
// value: 'build',
269+
// name: 'Build: '+ (currentVersion + '-?') + ' Unstable, betas, and release candidates.'
270+
// },
271+
{
272+
value: 'patch',
273+
name: 'Patch: ' + semver.inc(currentVersion, 'patch') + ' Backwards-compatible bug fixes.'
274+
},
275+
{
276+
value: 'minor',
277+
name: 'Minor: ' + semver.inc(currentVersion, 'minor') + ' Add functionality in a backwards-compatible manner.'
278+
},
279+
{
280+
value: 'major',
281+
name: 'Major: ' + semver.inc(currentVersion, 'major') + ' Incompatible API changes.'
282+
},
283+
{
284+
value: 'custom',
285+
name: 'Custom: ?.?.? Specify version...'
286+
}
287+
]
288+
},
289+
{
290+
config: 'bump.version',
291+
type: 'input',
292+
message: 'What specific version would you like',
293+
when: function (answers) {
294+
return answers['bump.increment'] === 'custom';
295+
},
296+
validate: function (value) {
297+
var valid = semver.valid(value);
298+
return valid || 'Must be a valid semver, such as 1.2.3-rc1. See http://semver.org/ for more details.';
299+
}
300+
}//,
301+
// {
302+
// config: 'bump.files',
303+
// type: 'checkbox',
304+
// message: 'What should get the new version:',
305+
// choices: [
306+
// {
307+
// value: 'package',
308+
// name: 'package.json' + (!grunt.file.isFile('package.json') ? ' not found, will create one' : ''),
309+
// checked: grunt.file.isFile('package.json')
310+
// },
311+
// {
312+
// value: 'bower',
313+
// name: 'bower.json' + (!grunt.file.isFile('bower.json') ? ' not found, will create one' : ''),
314+
// checked: grunt.file.isFile('bower.json')
315+
// },
316+
// {
317+
// value: 'git',
318+
// name: 'git tag',
319+
// checked: grunt.file.isDir('.git')
320+
// }
321+
// ]
322+
// }
323+
]
324+
}
325+
}
326+
},
250327
replace: {
251328
readme: {
252329
src: ['DETAILS.md', 'README.md'],
@@ -378,7 +455,7 @@ module.exports = function(grunt) {
378455
BUILD
379456
------------- */
380457
// JS distribution task
381-
grunt.registerTask('distjs', 'concat, uglify, and beautifying JS', ['concat', 'uglify', 'jsbeautifier']);
458+
grunt.registerTask('distjs', 'concat, uglify', ['concat', 'uglify', 'jsbeautifier']);
382459

383460
// CSS distribution task
384461
grunt.registerTask('distcss', 'Compile LESS into CSS', ['less', 'usebanner', 'delete-temp-less-file']);
@@ -405,13 +482,16 @@ module.exports = function(grunt) {
405482
TESTS
406483
------------- */
407484
// The default build task
408-
grunt.registerTask('default', 'Run simple tests. Does not build "dist."', ['test']);
485+
grunt.registerTask('default', 'Run simple tests.', ['test', 'clean:screenshots']);
409486

410-
// minimal tests for developmeent
487+
// to be run prior to submitting a PR
411488
grunt.registerTask('test', 'run jshint, qunit:simple, and validate HTML', ['jshint', 'qunit:simple', 'validation']);
412489

490+
//If qunit:simple is working but qunit:full is breaking, check to see if the dist broke the code. This would be especially useful if we start mangling our code, but, is 99.99% unlikely right now
491+
grunt.registerTask('validate-dist', 'run qunit:simple, dist, and then qunit:full', ['connect:testServer', 'qunit:simple', 'dist', 'qunit:full']);
492+
413493
// multiple jquery versions, then run SauceLabs VMs
414-
grunt.registerTask('releasetest', 'run jshint, qunit:full, and saucelabs', ['connect:testServer', 'jshint', 'qunit:full', 'saucelabs']);
494+
grunt.registerTask('releasetest', 'run jshint, dist, qunit:full, validation, and qunit on saucelabs', ['connect:testServer', 'jshint', 'qunit:simple', 'dist', 'qunit:full', 'validation', 'saucelabs-qunit:defaultBrowsers']);
415495

416496
// can be run locally instead of through TravisCI, but requires the Fuel UX Saucelabs API key file which is not public at this time.
417497
grunt.registerTask('saucelabs', 'run jshint, and qunit on saucelabs', ['connect:testServer', 'jshint', 'saucelabs-qunit:defaultBrowsers']);
@@ -420,18 +500,30 @@ module.exports = function(grunt) {
420500
grunt.registerTask('trickysauce', 'run tests, jshint, and qunit for "tricky browsers" (IE8-11)', ['connect:testServer', 'jshint', 'saucelabs-qunit:trickyBrowsers']);
421501

422502
// Travis CI task. This task no longer uses SauceLabs. Please run 'grunt saucelabs' manually.
423-
grunt.registerTask('travisci', 'Tests to run when in Travis CI environment', ['connect:testServer', 'jshint', 'qunit:full']);
503+
grunt.registerTask('travisci', 'Tests to run when in Travis CI environment', ['connect:testServer', 'jshint', 'qunit:simple', 'dist', 'qunit:full']);
424504

425505

426506
/* -------------
427507
RELEASE
428508
------------- */
429509
// Maintainers: Run prior to a release. Includes SauceLabs VM tests.
430-
// --minor will create a semver minor release, otherwise a patch release will be created
431-
grunt.registerTask('release', 'Release a new version, push it and publish it', function() {
432-
if (! grunt.option('no-tests') ) { grunt.task.run(['releasetest']); }
510+
grunt.registerTask('release', 'Release a new version, push it and publish it', ['prompt:bump', 'dorelease']);
511+
grunt.registerTask('dorelease', '', function() {
512+
if(typeof grunt.config('bump.increment') === 'undefined'){
513+
grunt.fail.fatal('you must choose a version to bump to');
514+
}
515+
grunt.log.writeln('');
516+
grunt.log.oklns('releasing: ', grunt.config('bump.increment'));
517+
518+
if (! grunt.option('no-tests') ) {
519+
grunt.task.run(['releasetest']);
520+
//delete any screenshots that may have happened if it got this far. This isn't foolproof because it relies on the phantomjs server/page timeout, which can take longer than this grunt task depending on how long saucelabs takes to run...
521+
grunt.task.run('clean:screenshots');
522+
}
523+
433524
grunt.config('banner', '<%= bannerRelease %>');
434-
grunt.task.run(['bump-only:' + versionReleaseType, 'dist', 'replace:readme']);
525+
//make sure we run dist again to grab the latest version numbers. Yeah, we're running it twice... ¯\_(ツ)_/¯
526+
grunt.task.run(['bump-only:' + grunt.config('bump.increment'), 'replace:readme', 'dist']);
435527
});
436528

437529

@@ -452,5 +544,4 @@ module.exports = function(grunt) {
452544
grunt.registerTask('serve', 'serve files without "dist" build', ['test', 'connect:server', 'watch:contrib']);
453545
grunt.registerTask('servedist', 'test, build "dist", serve files w/ watch', ['test', 'dist', 'connect:server', 'watch:full']);
454546

455-
456547
};

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@
3333
"grunt-contrib-watch": "0.x",
3434
"grunt-html-validation": "0.x",
3535
"grunt-jsbeautifier": "0.x",
36+
"grunt-prompt": "1.x",
3637
"grunt-saucelabs": "8.x",
3738
"grunt-text-replace": "0.x",
3839
"grunt-zip": "0.x",
3940
"load-grunt-tasks": "2.x",
41+
"semver": "4.x",
4042
"serve-static": "1.x"
4143
},
4244
"engines": {
@@ -83,4 +85,4 @@
8385
"type": "directory",
8486
"url": "https://raw.github.com/ExactTarget/fuelux/{version}/dist/fuelux.zip"
8587
}
86-
}
88+
}

test/fuelux.html

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
jQueryPath = 'bower_components/jquery-' + jqver + '/jquery';
4444
}
4545

46-
require.config({
46+
var requireConfig = {
4747
baseUrl: '../',
4848
paths: {
4949
jquery: jQueryPath,
@@ -58,7 +58,40 @@
5858
exports: 'bootstrap'
5959
}
6060
}
61-
});
61+
};
62+
63+
//default to non-dist for dev
64+
var testdistParam = location.search.match(/[?&]testdist=(true|false?)(?=&|$)/);
65+
var testdist = (testdistParam && testdistParam[1] === 'true') ? true : false;
66+
if(testdist){
67+
var fueluxLocation;
68+
69+
//map all calls for individual fuelux modules to merged fuelux library
70+
requireConfig.map = {
71+
'*': {
72+
'fuelux/checkbox': 'dist/js/fuelux',
73+
'fuelux/combobox': 'dist/js/fuelux',
74+
'fuelux/datepicker': 'dist/js/fuelux',
75+
'fuelux/dropdown-autoflip': 'dist/js/fuelux',
76+
'fuelux/infinite-scroll': 'dist/js/fuelux',
77+
'fuelux/loader': 'dist/js/fuelux',
78+
'fuelux/pillbox': 'dist/js/fuelux',
79+
'fuelux/placard': 'dist/js/fuelux',
80+
'fuelux/radio': 'dist/js/fuelux',
81+
'fuelux/repeater-list': 'dist/js/fuelux',
82+
'fuelux/repeater-thumbnail': 'dist/js/fuelux',
83+
'fuelux/repeater': 'dist/js/fuelux',
84+
'fuelux/scheduler': 'dist/js/fuelux',
85+
'fuelux/search': 'dist/js/fuelux',
86+
'fuelux/selectlist': 'dist/js/fuelux',
87+
'fuelux/spinbox': 'dist/js/fuelux',
88+
'fuelux/tree': 'dist/js/fuelux',
89+
'fuelux/wizard': 'dist/js/fuelux'
90+
}
91+
}
92+
}
93+
94+
require.config(requireConfig);
6295

6396
require(['jquery', 'test/fuelux-test'], function() {});
6497
})();

0 commit comments

Comments
 (0)