Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding in enhanced grunt config and release process
- Added JSHint and updated syntax to pass - Added in Karma Runner using Jasmine, Browserify, and PhantomJS - Fixed examples to work under HTTPS - Added in Grunt Prompt release process that uses grunt-bump - Added in watch task to quickly run tests when a file is updated
- Loading branch information
Cody Lundquist
committed
Jul 16, 2014
1 parent
2b7588b
commit 977e5d8
Showing
17 changed files
with
294 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,6 @@ | ||
module.exports = function(grunt) { | ||
// Project configuration. | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
browserify: { | ||
options: { | ||
bundleOptions: { | ||
standalone: '<%= pkg.name %>' | ||
} | ||
}, | ||
build: { | ||
src: 'src/main.js', | ||
dest: 'dist/band.js' | ||
} | ||
}, | ||
uglify: { | ||
options: { | ||
compress: true, | ||
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n' | ||
}, | ||
build: { | ||
src: 'dist/band.js', | ||
dest: 'dist/band.min.js' | ||
} | ||
} | ||
require('time-grunt')(grunt); | ||
require('load-grunt-config')(grunt, { | ||
jitGrunt: true | ||
}); | ||
|
||
// Load the plugin that provides the "uglify" task. | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks('grunt-browserify'); | ||
|
||
// Default task(s). | ||
grunt.registerTask('default', ['browserify', 'uglify']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"browser": true, | ||
"curly": true, | ||
"eqnull": true, | ||
"immed": true, | ||
"jquery": false, | ||
"newcap": true, | ||
"noarg": true, | ||
"smarttabs": true, | ||
"sub": true, | ||
"undef": true, | ||
"unused": true, | ||
"globals": { | ||
"require": true, | ||
"it": true, | ||
"iit": true, | ||
"xit": true, | ||
"describe": true, | ||
"ddescribe": true, | ||
"xdescribe": true, | ||
"expect": true, | ||
"beforeEach": true, | ||
"module": true, | ||
"spyOn": true, | ||
"afterEach": true, | ||
"console": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
default: | ||
- "deploy" | ||
|
||
deploy: | ||
- "test" | ||
- "clean:dist" | ||
- "browserify:deploy" | ||
- "uglify:deploy" | ||
|
||
release: | ||
- "checkbranch:master" | ||
- "prompt:deploy" | ||
|
||
test: | ||
- "jshint" | ||
- "karma:once" | ||
|
||
run: | ||
- "test" | ||
- "karma:watch" | ||
- "watch" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
"options": { | ||
"bundleOptions": { | ||
"standalone": '<%= package.name %>' | ||
} | ||
}, | ||
"deploy": { | ||
"src": 'src/main.js', | ||
"dest": 'dist/band.js' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
options: { | ||
files: ['bower.json', 'package.json'], | ||
commit: false, | ||
commitMessage: 'Releasing: %VERSION%', | ||
commitFiles: ['dist/', 'bower.json', 'package.json'], | ||
createTag: false, | ||
tagName: '%VERSION%', | ||
tagMessage: 'Version %VERSION%', | ||
push: false, | ||
pushTo: 'origin master:master' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Clean generated asset files | ||
module.exports = { | ||
"dist": ["dist"], | ||
"build": ["build"] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
options: { | ||
jshintrc: 'grunt/.jshintrc' | ||
}, | ||
all: ['src/**/*.js'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module.exports = { | ||
// Run Unit Tests Once | ||
"once": { | ||
"options": { | ||
"port": 9018, | ||
"runnerPort": 9100, | ||
"singleRun": true, | ||
"background": false | ||
} | ||
}, | ||
// Used during watch. It just sets up the server and then watch calls 'karma:watch:run' to fire off tests. | ||
"watch": { | ||
"options": { | ||
"port": 9118, | ||
"runnerPort": 9200, | ||
"singleRun": false, | ||
"background": true | ||
} | ||
}, | ||
"options": { | ||
"files": [ | ||
"test/*.js" | ||
], | ||
"frameworks": [ | ||
"jasmine", | ||
"browserify" | ||
], | ||
"plugins": [ | ||
"karma-jasmine", | ||
"karma-phantomjs-launcher", | ||
"karma-browserify" | ||
], | ||
"browserify": { | ||
"watch": true | ||
}, | ||
preprocessors: { | ||
"test/*.js": ["browserify"] | ||
}, | ||
"reporters": "dots", | ||
"urlRoot": "/", | ||
"autoWatch": false, | ||
"logLevel": "ERROR", | ||
"browsers": [ | ||
"PhantomJS" | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
module.exports = function(grunt) { | ||
var semver = require('semver'), | ||
currentVersion = require('../package.json').version; | ||
return { | ||
deploy: { | ||
options: { | ||
questions: [ | ||
{ | ||
config: 'bump.version-type', | ||
type: 'list', | ||
message: 'Bump version from ' + '<%= package.version %>'.cyan + ' to:', | ||
choices: [ | ||
{ | ||
value: 'patch', | ||
name: 'Patch: '.yellow + semver.inc(currentVersion, 'patch').yellow + | ||
' Backwards-compatible bug fixes.' | ||
}, | ||
{ | ||
value: 'minor', | ||
name: 'Minor: '.yellow + semver.inc(currentVersion, 'minor').yellow + | ||
' Adding new features but still backwards-compatible.' | ||
}, | ||
{ | ||
value: 'major', | ||
name: 'Major: '.yellow + semver.inc(currentVersion, 'major').yellow + | ||
' Incompatible API changes.' | ||
}, | ||
{ | ||
value: 'custom', | ||
name: 'Custom: ?.?.?'.yellow + | ||
' Specify version...' | ||
} | ||
] | ||
}, | ||
{ | ||
config: 'bump.custom-version', | ||
type: 'input', | ||
message: 'What specific version would you like', | ||
when: function(answers) { | ||
return answers['bump.version-type'] === 'custom'; | ||
}, | ||
validate: function(value) { | ||
var valid = semver.valid(value) && true; | ||
return valid || 'Must be a valid semver, such as 1.2.3'; | ||
} | ||
}, | ||
{ | ||
config: 'bump.options.commit', | ||
type: 'confirm', | ||
message: 'Do you want to commit the ./dist, bower.json, and package.json files?' | ||
}, | ||
{ | ||
config: 'bump.options.createTag', | ||
type: 'confirm', | ||
message: 'Do you want to tag this release?', | ||
when: function(answers) { | ||
return answers['bump.options.commit'] | ||
} | ||
}, | ||
{ | ||
config: 'bump.options.push', | ||
type: 'confirm', | ||
message: 'Do you want to push the new release?', | ||
when: function(answers) { | ||
return answers['bump.options.commit'] && answers['bump.options.createTag'] | ||
} | ||
}, | ||
{ | ||
config: 'bump.options.pushTo', | ||
type: 'input', | ||
message: 'Where would you like to push to?', | ||
default: 'origin master:master', | ||
when: function(answers) { | ||
return answers['bump.options.push'] | ||
} | ||
} | ||
], | ||
then: function(results) { | ||
var versionType = results['bump.version-type'], | ||
bumpTask = 'bump'; | ||
|
||
if ('custom' === versionType) { | ||
grunt.option('setversion', results['bump.custom-version']); | ||
} else { | ||
bumpTask += ':' + versionType; | ||
} | ||
|
||
grunt.task.run(['deploy', bumpTask]); | ||
} | ||
} | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
"options": { | ||
"compress": true, | ||
"banner": '/*! <%= package.name %> - v<%= package.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n' | ||
}, | ||
"deploy": { | ||
"src": 'dist/band.js', | ||
"dest": 'dist/band.min.js' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
"build": { | ||
"files": ["src/**/*.js", "test/*.js"], | ||
"tasks": [ | ||
"karma:watch:run" | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.