From fc4610911a74538a344ad419ac867da9aa6b2956 Mon Sep 17 00:00:00 2001 From: Dean Malmgren Date: Thu, 2 Jul 2015 06:06:39 -0500 Subject: [PATCH 1/7] added grunt and a few contributed packages to package.json --- package.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8245717..05cae30 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,12 @@ "crossfilter": "~1.3.2" }, "devDependencies": { + "grunt": "^0.4.5", + "grunt-contrib-compass": "^1.0.3", + "grunt-contrib-concat": "^0.5.1", + "grunt-contrib-jshint": "^0.11.2", + "grunt-contrib-uglify": "^0.9.1", + "grunt-contrib-watch": "^0.6.1", "vows": "0.7.x" }, "scripts": { @@ -18,7 +24,7 @@ }, "repository": { "type": "git", - "url": "git://github.com/freemarmoset/catcorrjs.git" + "url": "git://github.com/ideo/catcorrjs.git" }, "keywords": [ "visualization" @@ -26,6 +32,6 @@ "author": "Dean Malmgren", "license": "MIT", "bugs": { - "url": "https://github.com/freemarmoset/catcorrjs/issues" + "url": "https://github.com/ideo/catcorrjs/issues" } } From 73d21251808b89ac442d2538daeaab01c714b671 Mon Sep 17 00:00:00 2001 From: Dean Malmgren Date: Thu, 2 Jul 2015 06:18:44 -0500 Subject: [PATCH 2/7] initial gruntfile works using the uglify task --- Gruntfile.js | 32 ++++++++++++++++++++++++++ catcorr.min.js => build/catcorr.min.js | 0 package.json | 2 +- catcorr.js => src/catcorr.js | 0 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 Gruntfile.js rename catcorr.min.js => build/catcorr.min.js (100%) rename catcorr.js => src/catcorr.js (100%) diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..8dd2c96 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,32 @@ +module.exports = function(grunt) { + + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + uglify: { + options: { + banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' + }, + build: { + src: 'src/<%= pkg.name %>.js', + dest: 'build/<%= pkg.name %>.min.js' + } + } + }); + + // Load the plugins + grunt.loadNpmTasks('grunt-contrib-compass'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-watch'); + + // Default task(s). + grunt.registerTask('default', [ + // 'jshint', + // 'compass', + // 'concat', + 'uglify' + ]); + +}; diff --git a/catcorr.min.js b/build/catcorr.min.js similarity index 100% rename from catcorr.min.js rename to build/catcorr.min.js diff --git a/package.json b/package.json index 05cae30..25ead3d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "catcorrjs", + "name": "catcorr", "version": "0.3.1", "description": "Visualize correlations across many dimensions of categorical data (e.g., from a survey)", "main": "catcorr.js", diff --git a/catcorr.js b/src/catcorr.js similarity index 100% rename from catcorr.js rename to src/catcorr.js From 4f16cfeeb757dba2e018a029d10e64a94df47dcf Mon Sep 17 00:00:00 2001 From: Dean Malmgren Date: Thu, 2 Jul 2015 07:59:39 -0500 Subject: [PATCH 3/7] added jshint to Gruntfile.js --- .jshintrc | 10 ++++++++++ Gruntfile.js | 15 +++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..8350de1 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,10 @@ +{ + "curly": true, + "eqeqeq": true, + "eqnull": true, + "noarg": true, + "undef": true, + "unused": true, + "maxstatements": 40, + "nobsp": true +} diff --git a/Gruntfile.js b/Gruntfile.js index 8dd2c96..2bb8dfb 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,6 +3,10 @@ module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), + jshint: { + files: ['Gruntfile.js'], + jshintrc: '.jshintrc' + }, uglify: { options: { banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' @@ -11,9 +15,16 @@ module.exports = function(grunt) { src: 'src/<%= pkg.name %>.js', dest: 'build/<%= pkg.name %>.min.js' } - } + }, + watch: { + files: ['<%= jshint.files %>'], + tasks: ['jshint'] + }, }); + if (grunt === null) + var x = true; + // Load the plugins grunt.loadNpmTasks('grunt-contrib-compass'); grunt.loadNpmTasks('grunt-contrib-concat'); @@ -23,7 +34,7 @@ module.exports = function(grunt) { // Default task(s). grunt.registerTask('default', [ - // 'jshint', + 'jshint', // 'compass', // 'concat', 'uglify' From 58375142571e21048c2b1286f2904cdc27c8f6ca Mon Sep 17 00:00:00 2001 From: Dean Malmgren Date: Thu, 2 Jul 2015 08:26:42 -0500 Subject: [PATCH 4/7] added jscs to the grunt watch command --- .jscsrc | 23 +++++++++++++++++++++++ Gruntfile.js | 21 +++++++++++++++------ package.json | 1 + 3 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 .jscsrc diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..db51281 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,23 @@ +{ + "disallowEmptyBlocks": true, + "disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"], + "disallowMixedSpacesAndTabs": true, + "disallowMultipleVarDecl": true, + "disallowNewlineBeforeBlockStatements": true, + "disallowQuotedKeysInObjects": "allButReserved", + "disallowSpaceAfterObjectKeys": true, + "disallowTrailingComma": true, + "maximumLineLength": 80, + "requireBlocksOnNewline": true, + "requireCommaBeforeLineBreak": true, + "requireCurlyBraces": true, + "requireDotNotation": true, + "requireLineBreakAfterVariableAssignment": true, + "requireLineFeedAtFileEnd": true, + "requireSemicolons": true, + "requireSpaceAfterBinaryOperators": true, + "requireSpaceAfterLineComment": true, + "requireSpaceBeforeBinaryOperators": true, + "requireSpaceBeforeObjectValues": true, + "validateQuoteMarks": { "mark": "'", "escape": true } +} diff --git a/Gruntfile.js b/Gruntfile.js index 2bb8dfb..142f13a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,9 +7,19 @@ module.exports = function(grunt) { files: ['Gruntfile.js'], jshintrc: '.jshintrc' }, + jscs: { + // src: ['Gruntfile.js'], 'src/**.js'], + src: ['Gruntfile.js'], + options: { + config: '.jscsrc' + } + }, uglify: { options: { - banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' + banner: ( + '/*! <%= pkg.name %> ' + + '<%= grunt.template.today("yyyy-mm-dd") %> */\n' + ) }, build: { src: 'src/<%= pkg.name %>.js', @@ -18,23 +28,22 @@ module.exports = function(grunt) { }, watch: { files: ['<%= jshint.files %>'], - tasks: ['jshint'] - }, + tasks: ['jshint', 'jscs'] + } }); - if (grunt === null) - var x = true; - // Load the plugins grunt.loadNpmTasks('grunt-contrib-compass'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-jscs'); // Default task(s). grunt.registerTask('default', [ 'jshint', + 'jscs', // 'compass', // 'concat', 'uglify' diff --git a/package.json b/package.json index 25ead3d..501034a 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "grunt-contrib-jshint": "^0.11.2", "grunt-contrib-uglify": "^0.9.1", "grunt-contrib-watch": "^0.6.1", + "grunt-jscs": "^1.8.0", "vows": "0.7.x" }, "scripts": { From 462214a652d10aa9efd955b0341bee14b21e739a Mon Sep 17 00:00:00 2001 From: Dean Malmgren Date: Thu, 2 Jul 2015 08:50:14 -0500 Subject: [PATCH 5/7] checking same source files in jshint and jscs for more DRY implementation --- Gruntfile.js | 6 ++++-- package.json | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 142f13a..517caca 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,11 +5,13 @@ module.exports = function(grunt) { pkg: grunt.file.readJSON('package.json'), jshint: { files: ['Gruntfile.js'], + options: { + reporter: require('jshint-stylish') + }, jshintrc: '.jshintrc' }, jscs: { - // src: ['Gruntfile.js'], 'src/**.js'], - src: ['Gruntfile.js'], + src: ['<%= jshint.files %>'], options: { config: '.jscsrc' } diff --git a/package.json b/package.json index 501034a..b96318d 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "grunt-contrib-uglify": "^0.9.1", "grunt-contrib-watch": "^0.6.1", "grunt-jscs": "^1.8.0", + "jshint-stylish": "^2.0.1", "vows": "0.7.x" }, "scripts": { From 28bd216aa8762cb2c7cb817e6ef48adf43418a78 Mon Sep 17 00:00:00 2001 From: Dean Malmgren Date: Thu, 2 Jul 2015 13:52:09 -0500 Subject: [PATCH 6/7] using grunt to concatenate files into one source file --- Gruntfile.js | 22 ++++++++++++++++++++-- src/analysis.js | 1 + src/render.js | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/analysis.js create mode 100644 src/render.js diff --git a/Gruntfile.js b/Gruntfile.js index 517caca..4c0e646 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -16,6 +16,24 @@ module.exports = function(grunt) { config: '.jscsrc' } }, + concat: { + build: { + nonull: true, + options: { + banner: ('(function (exports){\n' + + 'var catcorr = {\n' + + ' version: \'<%= pkg.version %>\'\n' + + '};\n' + ), + footer: '}();', + }, + src: [ + 'src/analysis.js', + 'src/render.js' + ], + dest: 'build/kk.js' + } + }, uglify: { options: { banner: ( @@ -30,7 +48,7 @@ module.exports = function(grunt) { }, watch: { files: ['<%= jshint.files %>'], - tasks: ['jshint', 'jscs'] + tasks: ['jshint', 'jscs', 'concat'] } }); @@ -47,7 +65,7 @@ module.exports = function(grunt) { 'jshint', 'jscs', // 'compass', - // 'concat', + 'concat', 'uglify' ]); diff --git a/src/analysis.js b/src/analysis.js new file mode 100644 index 0000000..b364a34 --- /dev/null +++ b/src/analysis.js @@ -0,0 +1 @@ +catcorr.analyze = {}; diff --git a/src/render.js b/src/render.js new file mode 100644 index 0000000..1ceb92b --- /dev/null +++ b/src/render.js @@ -0,0 +1 @@ +catcorr.render = {}; From b68acc1f6efecdc21a7d7d22ac7b1253a73cc692 Mon Sep 17 00:00:00 2001 From: Dean Malmgren Date: Thu, 2 Jul 2015 14:24:55 -0500 Subject: [PATCH 7/7] properly concatinating things from files in src/ --- Gruntfile.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 4c0e646..010e4c8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,7 +4,7 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), jshint: { - files: ['Gruntfile.js'], + files: ['Gruntfile.js', 'src/analysis.js', 'src/render.js'], options: { reporter: require('jshint-stylish') }, @@ -20,12 +20,13 @@ module.exports = function(grunt) { build: { nonull: true, options: { - banner: ('(function (exports){\n' + + banner: ( + '(function (exports){\n' + 'var catcorr = {\n' + ' version: \'<%= pkg.version %>\'\n' + '};\n' ), - footer: '}();', + footer: '}();' }, src: [ 'src/analysis.js',