Skip to content

Commit

Permalink
Grunt tidyup: move to load-grunt-config, grunt-newer, add unit --core
Browse files Browse the repository at this point in the history
Config for load-grunt-config, which splits Gruntfile into separate files
in the grunt/ directory.

Added in grunt-newer, and configured it for jscs, jshint.  Probably
it could be used for more stuff, but I haven't worked out what yet.

Also added config for --core option that runs only the core unit
tests (ignores all features).

Most settings and information found in http://www.html5rocks.com/en/tutorials/tooling/supercharging-your-gruntfile/
  • Loading branch information
PaulL1 committed Mar 1, 2015
1 parent 0b29072 commit 7e006bb
Show file tree
Hide file tree
Showing 25 changed files with 591 additions and 648 deletions.
688 changes: 42 additions & 646 deletions Gruntfile.js

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions grunt/aliases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

module.exports = function (grunt, options) {
var baseTasks = {
'install': ['shell:bower-install', 'shell:protractor-install'],

// register before and after test tasks so we don't have to change cli
// options on the CI server
'before-test': ['clean', 'newer:jshint', 'newer:jscs', 'ngtemplates', 'less'], // Have to run less so CSS files are present
'after-test': ['build'],
'default': ['before-test', 'test:single', 'after-test'],

// Build with no testing
'build': ['ngtemplates', 'concat', 'uglify', 'newer:fontello', 'less', 'newer:ngdocs', 'copy'],

// Auto-test tasks for development
'autotest:unit': ['karmangular:start'],
'autotest:e2e': ['shell:protractor-start'],

// Testing tasks
'test': ['before-test', 'test:single'],
'test:ci': ['before-test', 'serialsauce'], // NOTE(c0bra): Removed this task for now, as Selenium is timing out while connecting to the Chromium browser... : 'test:ci-e2e'
'test:docs': ['connect:testserver', 'protractor:docs'],
'test:e2e': ['connect:testserver', 'protractor:singlerun'],
'test:ci-e2e': ['clean', 'build', 'connect:testserver', 'protractor:ci']
};

var e2e = grunt.option('e2e');

if (e2e === false){
grunt.log.writeln("Skipping e2e testing...");
baseTasks['dev'] = ['before-test', 'after-test', 'connect', 'autotest:unit', 'watch'];
} else {
baseTasks['protractor-watch'] = [ 'protractor' ];
baseTasks['dev'] = ['before-test', 'after-test', 'connect', 'autotest:unit', 'autotest:e2e', 'watch'];
}

if (process.env.TRAVIS){
baseTasks['test:single'] = ['karma:travis'];
} else {
baseTasks['test:single'] = ['karmangular'];
}

var util = require('../lib/grunt/utils.js');
var semver = require('semver');
var currentTag = semver.clean( util.getCurrentTag() );

if (currentTag){
baseTasks['release'] = ['clean', 'ngtemplates', 'build', 'cut-release', 'gh-pages:ui-grid-site', 'update-bower-json', 'gh-pages:bower'];
} else {
baseTasks['release'] = ['clean', 'ngtemplates', 'build', 'cut-release', 'gh-pages:ui-grid-site'];
}

return baseTasks;
};
7 changes: 7 additions & 0 deletions grunt/bump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
options: {
files: ['package.json', 'bower.json'],
commitFiles: ['package.json', 'bower.json', 'CHANGELOG.md'],
push: false
}
};
6 changes: 6 additions & 0 deletions grunt/changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
options: {
dest: 'CHANGELOG.md',
github: 'angular-ui/ng-grid'
}
};
4 changes: 4 additions & 0 deletions grunt/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports =
// Clean the temp directory
['.tmp', '<%= dist %>', 'docs', 'coverage']
;
22 changes: 22 additions & 0 deletions grunt/concat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['src/js/core/bootstrap.js', 'src/js/**/*.js', 'src/features/*/js/**/*.js', '.tmp/template.js'],
dest: '<%= dist %>/release/<%= pkg.name %>.js'
},

// Concat all the less files together for the customizer
customizer_less: {
options: {
process: function(src, filepath) {
// Strip import statements since we're concatting
return src.replace(/\@import\s*.+?;/g, '');
}
},
src: 'src/less/**/*.less',
dest: '<%= dist %>/less/<%= pkg.name %>.less'
}
};
23 changes: 23 additions & 0 deletions grunt/connect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
dev: {
options: {
port: process.env.DEV_PORT || 9002,
base: '.',
livereload: true
}
},
docs: {
options: {
hostname: '*',
port: process.env.DOCS_PORT || 9003,
base: '<%= dist %>',
livereload: true
}
},
testserver: {
options: {
port: process.env.TEST_PORT || 9999,
base: '<%= dist %>'
}
}
};
19 changes: 19 additions & 0 deletions grunt/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = function ( grunt ) {
return {
site: {
options: {
process: function (content, srcpath) {
return grunt.template.process(content);
}
},
files: [
{
expand: true,
cwd: 'misc/site/',
src: '**',
dest: '<%= dist %>'
}
]
}
};
};
10 changes: 10 additions & 0 deletions grunt/cut-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
options: {
cleanup: true,
keepUnstable: false
},
dist: {
src: '<%= dist %>/release/*.{js,css,svg,woff,ttf,eot}',
dest: '<%= dist %>/release/'
}
};
14 changes: 14 additions & 0 deletions grunt/fontello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
options: {
sass: false
},
dist: {
options: {
config : 'src/font/config.json',
fonts : 'dist/release',
styles : '.tmp/font',
scss : false
// force : true
}
}
};
29 changes: 29 additions & 0 deletions grunt/gh-pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var util = require('../lib/grunt/utils.js');
var semver = require('semver');

// Get the tag on this commit, if there is one
var currentTag = semver.clean( util.getCurrentTag() );

module.exports = {
'ui-grid-site': {
options: {
base: '<%= dist %>',
tag: (currentTag) ? 'v' + currentTag : null,
repo: 'https://github.com/angular-ui/ui-grid.info.git',
message: 'gh-pages v<%= version %>',
add: true
},
src: ['**/*']
},
'bower': {
options: {
base: '<%= dist %>/release/' + currentTag,
tag: (currentTag) ? 'v' + currentTag : null,
repo: 'https://github.com/angular-ui/bower-ui-grid.git',
message: 'v' + currentTag,
branch: 'master',
add: true
},
src: ['**/*']
}
};
8 changes: 8 additions & 0 deletions grunt/jscs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
files: {
src: ['src/**/*.js', 'src/features/*/js/**/*.js', 'src/features/*/test/**/*.spec.js', 'test/**/*.spec.js'],
},
options: {
config: '.jscs.json'
}
};
67 changes: 67 additions & 0 deletions grunt/jshint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module.exports = {
options: {
reporter: require('jshint-stylish'),

curly: true,
eqeqeq: true,
immed: true,
latedef: false,
newcap: true,
noarg: true,
sub: true,
undef: true,
unused: false,
boss: true,
eqnull: true,
browser: true,
debug: true, // debugger statements allowed
globals: {
angular: false,

/* Protractor */
browser: false,

/* Lodash */
_: false,

/* jquery (testing only) */
$: false,
jQuery: false,


/* grunt */
process: false,
require: false,

/* Jasmine */
jasmine: false,
after: false,
afterEach: false,
before: false,
beforeEach: false,
console: false,
dump: false,
describe: false,
ddescribe: false,
expect: false,
inject: false,
it: false,
iit: false,
module: false,
debugger: false,
DocumentTouch: false,
runs: false,
waits: false,
waitsFor: false,
xit: false,
xdescribe: false,
spyOn: false
}
},
gruntfile: {
src: 'Gruntfile.js'
},
src_test: {
src: ['src/**/*.js', 'src/features/*/js/**/*.js', 'src/features/*/test/**/*.spec.js', 'test/**/*.spec.js']
}
};
40 changes: 40 additions & 0 deletions grunt/karma.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var util = require('../lib/grunt/utils.js');

module.exports = function( grunt ){
var baseConfig = {
options: {
configFile: 'test/karma.conf.js',
background: true,
},
// dev: {
// singleRun: false,
// background: true
// },
single: {
background: false,
singleRun: true,
reporters: ['progress'],
reportSlowerThan: 200
},

travis: {
background: false,
singleRun: true,
reporters: ['dots'],
}
};

var core = grunt.option('core');

if (core){
baseConfig.options.files = util.testDependencies.unit
.concat(util.angularFiles(util.latestAngular()))
.concat(util.testFiles.core_unit);
} else {
baseConfig.options.files = util.testDependencies.unit
.concat(util.angularFiles(util.latestAngular()))
.concat(util.testFiles.unit);
}

return baseConfig;
};
20 changes: 20 additions & 0 deletions grunt/less.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
dist: {
// paths: ['/bower_components/bootstrap'],
options: {
banner: '<%= banner %>'
},
files: {
'dist/release/<%= pkg.name %>.css': ['src/less/main.less', 'src/features/*/less/**/*.less', '.tmp/font/ui-grid-codes.css']
}
},
min: {
options: {
banner: '<%= banner %>',
compress: true
},
files: {
'dist/release/<%= pkg.name %>.min.css': ['src/less/main.less', 'src/features/*/less/**/*.less', '.tmp/font/ui-grid-codes.css']
}
}
};
61 changes: 61 additions & 0 deletions grunt/ngdocs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module.exports = {
options: {
dest: '<%= dist %>/docs',
testingUrlPrefix: '<%= protractor.options.args.baseUrl %>/docs/#/',
versionedFiles: {
default: process.env.TRAVIS ? 'unstable' : 'stable',
waitEval: "(function() { var ret = true; try { angular.module('ui.grid'); } catch (e) { ret = false; } return ret; })()",
versions: {
stable: [
{ src: '/release/<%= pkg.name %>.js', type: 'script' },
{ src: '/release/<%= pkg.name %>.css', type: 'css' }
],
unstable: [
{ src: '/release/<%= pkg.name %>-unstable.js', type: 'script' },
{ src: '/release/<%= pkg.name %>-unstable.css', type: 'css' }
]
}
},
scripts: [
// no jquery automatically loaded for tutorial!!!
'//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.js',
'//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-touch.js',
'//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-animate.js',
'bower_components/csv-js/csv.js',
'bower_components/pdfmake/build/pdfmake.js',
'bower_components/pdfmake/build/vfs_fonts.js'
],
hiddenScripts: [
'//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-animate.js',
'bower_components/google-code-prettify/src/prettify.js',
'node_modules/marked/lib/marked.js'
],
httpScripts: [
// process.env.TRAVIS ? '/release/<%= pkg.name %>.unstable.js' : '/release/<%= pkg.name %>.js'
// '/release/<%= pkg.name %>.js'
],
styles: [
'misc/doc/css/prettify.css',
//'misc/doc/css/bootstrap-flatly.min.css',
//'misc/doc/css/docs.css',
// process.env.TRAVIS ? '<%= dist %>/release/<%= pkg.name %>.unstable.css' : '<%= dist %>/release/<%= pkg.name %>.css'
// '<%= dist %>/release/<%= pkg.name %>.css'
],
title: 'UI Grid',
titleLink: 'http://<%= site %>',
html5Mode: false,
analytics: {
account: 'UA-46391685-1',
domainName: 'ui-grid.info'
},
navTemplate: 'misc/doc/templates/nav.html'
},
api: {
src: ['src/**/*.js', 'misc/api/**/*.ngdoc', 'test/e2e/**/*.js'],
title: 'API'
},
tutorial: {
src: ['misc/tutorial/**/*.ngdoc'],
title: 'Tutorial'
}
};
Loading

0 comments on commit 7e006bb

Please sign in to comment.