Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 76CB195C7 for ; Mon, 8 Dec 2014 19:49:17 +0000 (UTC) Received: (qmail 84361 invoked by uid 500); 8 Dec 2014 19:49:17 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 84317 invoked by uid 500); 8 Dec 2014 19:49:17 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 84308 invoked by uid 99); 8 Dec 2014 19:49:17 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Dec 2014 19:49:17 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 0EAADA1E174; Mon, 8 Dec 2014 19:49:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: benkeen@apache.org To: commits@couchdb.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: fauxton commit: updated refs/heads/master to ef5264d Date: Mon, 8 Dec 2014 19:49:17 +0000 (UTC) Repository: couchdb-fauxton Updated Branches: refs/heads/master 310e8135b -> ef5264d3d Rename index.css and require.js with md5 hash - removes obsolete "cache buster" setting - replaces hardcoded require.js and index.cs filenames in settings files with for non-dev build processes with variables. - release and couchapp_deploy tasks now rename those two files to include their hashes, and reference them in the generated index.html file Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/ef5264d3 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/ef5264d3 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/ef5264d3 Branch: refs/heads/master Commit: ef5264d3da1c7f16e2db7f46e4f23353968dc9e4 Parents: 310e813 Author: Benjamin Keen Authored: Fri Dec 5 11:33:22 2014 -0800 Committer: Benjamin Keen Committed: Mon Dec 8 11:47:49 2014 -0800 ---------------------------------------------------------------------- Gruntfile.js | 90 ++++++++++++++++++++++++++++---------------- assets/index.underscore | 4 +- package.json | 3 +- settings.json.default | 17 ++++----- 4 files changed, 68 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/ef5264d3/Gruntfile.js ---------------------------------------------------------------------- diff --git a/Gruntfile.js b/Gruntfile.js index aa5bbb4..1828425 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -113,8 +113,8 @@ module.exports = function(grunt) { "src": "assets/index.underscore", "dest": "dist/debug/index.html", "variables": { - "requirejs": "./js/require.js", - "css": "./css/index.css", + "requirejs": "./js/{REQUIREJS_FILE}", + "css": "./css/{CSS_FILE}", "base": null } } @@ -139,7 +139,7 @@ module.exports = function(grunt) { return helper.readSettingsFile().couchserver || defaults; }(); - grunt.initConfig({ + var config = { // The clean task ensures all files are removed from the dist/ directory so // that no files linger from previous builds. @@ -159,7 +159,7 @@ module.exports = function(grunt) { // The jshint option for scripturl is set to lax, because the anchor // override inside main.js needs to test for them so as to not accidentally - // route. Settings expr true so we can do `migtBeNullObject && mightBeNullObject.coolFunction()` + // route. Settings expr true so we can do `mightBeNullObject && mightBeNullObject.coolFunction()` jshint: { all: ['app/**/*.js', 'Gruntfile.js', "!app/**/assets/js/*.js"], options: { @@ -244,14 +244,15 @@ module.exports = function(grunt) { test_config_js: { src: ["dist/debug/templates.js", "test/test.config.js"], dest: 'test/test.config.js' - }, + } }, cssmin: { compress: { files: { "dist/release/css/index.css": [ - "dist/debug/css/index.css", 'assets/css/*.css', + 'dist/debug/css/index.css', + 'assets/css/*.css', "app/addons/**/assets/css/*.css" ] }, @@ -403,12 +404,12 @@ module.exports = function(grunt) { check_selenium: helper.check_selenium, check_chrome_driver : helper.check_chrome_driver, start_nightWatch: { - command: __dirname + '/node_modules/nightwatch/bin/nightwatch' + - ' -e chrome -c ' + __dirname + '/test/nightwatch_tests/' + 'nightwatch.json' + command: __dirname + '/node_modules/nightwatch/bin/nightwatch' + + ' -e chrome -c ' + __dirname + '/test/nightwatch_tests/nightwatch.json' }, start_nightWatch_saucelabs: { - command: 'sleep 10s; '+ __dirname + '/node_modules/nightwatch/bin/nightwatch' + - ' -e saucelabs -c ' + __dirname + '/test/nightwatch_tests/' + 'nightwatch.json' + command: 'sleep 10s; '+ __dirname + '/node_modules/nightwatch/bin/nightwatch' + + ' -e saucelabs -c ' + __dirname + '/test/nightwatch_tests/nightwatch.json' } }, @@ -423,8 +424,41 @@ module.exports = function(grunt) { template: 'test/nightwatch_tests/nightwatch.json.underscore', dest: 'test/nightwatch_tests/nightwatch.json' } + }, + + // these rename the already-bundled, minified requireJS and CSS files to include their hash + md5: { + requireJS: { + files: { "dist/release/js/" : "dist/release/js/require.js" }, + options: { + afterEach: function (fileChanges) { + // replace the REQUIREJS_FILE placeholder with the actual filename + var newFilename = fileChanges.newPath.match(/[^\/]+$/)[0]; + config.template.release.variables.requirejs = config.template.release.variables.requirejs.replace(/REQUIREJS_FILE/, newFilename); + + // remove the original requireJS file, we don't need it anymore + fs.unlinkSync(fileChanges.oldPath); + } + } + }, + + css: { + files: { "dist/release/css/": 'dist/release/css/index.css' }, + options: { + afterEach: function (fileChanges) { + // replace the CSS_FILE placeholder with the actual filename + var newFilename = fileChanges.newPath.match(/[^\/]+$/)[0]; + config.template.release.variables.css = config.template.release.variables.css.replace(/CSS_FILE/, newFilename); + + // remove the original CSS file + fs.unlinkSync(fileChanges.oldPath); + } + } + } } - }); + }; + + grunt.initConfig(config); // on watch events configure jshint:all to only run on changed file grunt.event.on('watch', function(action, filepath) { @@ -443,34 +477,22 @@ module.exports = function(grunt) { */ // Load fauxton specific tasks grunt.loadTasks('tasks'); - // Load the couchapp task + grunt.loadNpmTasks('grunt-couchapp'); - // Load the copy task grunt.loadNpmTasks('grunt-contrib-watch'); - // Load the exec task grunt.loadNpmTasks('grunt-exec'); - // Load Require.js task grunt.loadNpmTasks('grunt-contrib-requirejs'); - // Load Copy task grunt.loadNpmTasks('grunt-contrib-copy'); - // Load Clean task grunt.loadNpmTasks('grunt-contrib-clean'); - // Load jshint task grunt.loadNpmTasks('grunt-contrib-jshint'); - // Load jst task grunt.loadNpmTasks('grunt-contrib-jst'); - // Load less task grunt.loadNpmTasks('grunt-contrib-less'); - // Load concat task grunt.loadNpmTasks('grunt-contrib-concat'); - // Load UglifyJS task grunt.loadNpmTasks('grunt-contrib-uglify'); - // Load CSSMin task grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-mocha-phantomjs'); - - //Selenium Server grunt.loadNpmTasks('grunt-selenium-webdriver'); + grunt.loadNpmTasks('grunt-md5'); /* * Default task @@ -481,31 +503,33 @@ module.exports = function(grunt) { /* * Transformation tasks */ - // clean out previous build artefactsa and lint + // clean out previous build artifacts and lint grunt.registerTask('lint', ['clean', 'jshint']); grunt.registerTask('test', ['lint', 'dependencies', 'gen_initialize:development', 'test_inline']); // lighter weight test task for use inside dev/watch grunt.registerTask('test_inline', ['mochaSetup','jst', 'concat:test_config_js','mocha_phantomjs']); // Fetch dependencies (from git or local dir), lint them and make load_addons grunt.registerTask('dependencies', ['get_deps', 'gen_load_addons:default']); + // build templates, js and css - grunt.registerTask('build', ['less', 'concat:index_css', 'jst', 'requirejs', 'concat:requirejs', 'template:release']); - // minify code and css, ready for release. - grunt.registerTask('minify', ['uglify', 'cssmin:compress']); + grunt.registerTask('build', ['less', 'concat:index_css', 'jst', 'requirejs', 'concat:requirejs', 'uglify', + 'cssmin:compress', 'md5:requireJS', 'md5:css', 'template:release']); /* * Build the app in either dev, debug, or release mode */ // dev server grunt.registerTask('dev', ['debugDev', 'couchserver']); + // build a debug release - grunt.registerTask('debug', ['lint', 'dependencies', "gen_initialize:development", 'concat:requirejs','less', 'concat:index_css', 'template:development', 'copy:debug']); - grunt.registerTask('debugDev', ['clean', 'dependencies', "gen_initialize:development",'jshint','less', 'concat:index_css', 'template:development', 'copy:debug']); + grunt.registerTask('debug', ['lint', 'dependencies', "gen_initialize:development", 'concat:requirejs','less', 'concat:index_css', 'template:development', 'copy:debug']); + grunt.registerTask('debugDev', ['clean', 'dependencies', "gen_initialize:development", 'jshint', 'less', 'concat:index_css', 'template:development', 'copy:debug']); grunt.registerTask('watchRun', ['clean:watch', 'dependencies', 'jshint']); + // build a release - grunt.registerTask('release', ['clean' ,'dependencies', "gen_initialize:release", 'jshint', 'build', 'minify', 'copy:dist', 'copy:ace', 'copy:zeroclip']); - grunt.registerTask('couchapp_release', ['clean' ,'dependencies', "gen_initialize:couchapp", 'jshint', 'build', 'minify', 'copy:dist', 'copy:ace', 'copy:zeroclip']); + grunt.registerTask('release', ['clean' ,'dependencies', "gen_initialize:release", 'jshint', 'build', 'copy:dist', 'copy:ace', 'copy:zeroclip']); + grunt.registerTask('couchapp_release', ['clean' ,'dependencies', "gen_initialize:couchapp", 'jshint', 'build', 'copy:dist', 'copy:ace', 'copy:zeroclip']); /* * Install into CouchDB in either debug, release, or couchapp mode http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/ef5264d3/assets/index.underscore ---------------------------------------------------------------------- diff --git a/assets/index.underscore b/assets/index.underscore index 6a887b5..1b07bcd 100644 --- a/assets/index.underscore +++ b/assets/index.underscore @@ -24,7 +24,7 @@ Project Fauxton - + <% if (base) { %> <% } %> @@ -38,6 +38,6 @@ - + http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/ef5264d3/package.json ---------------------------------------------------------------------- diff --git a/package.json b/package.json index 410fef5..f92010e 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "nightwatch": "~0.5.33", "nano": "~5.12.0", "grunt-chmod": "^1.0.3", - "grunt-selenium-webdriver": "^0.2.431" + "grunt-selenium-webdriver": "^0.2.431", + "grunt-md5": "^0.1.11" } } http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/ef5264d3/settings.json.default ---------------------------------------------------------------------- diff --git a/settings.json.default b/settings.json.default index 2eede08..fcb3767 100644 --- a/settings.json.default +++ b/settings.json.default @@ -21,8 +21,7 @@ "variables": { "requirejs": "/assets/js/libs/require.js", "css": "./css/index.css", - "base": null, - "cachebuster": "" + "base": null }, "app": { "root": "/", @@ -34,10 +33,9 @@ "src": "assets/index.underscore", "dest": "dist/debug/index.html", "variables": { - "requirejs": "./js/require.js", - "css": "./css/index.css", - "base": null, - "cachebuster": "?v1.0" + "requirejs": "./js/REQUIREJS_FILE", + "css": "./css/CSS_FILE", + "base": null }, "app": { "root": "/_utils/fauxton/", @@ -49,10 +47,9 @@ "src": "assets/index.underscore", "dest": "dist/debug/index.html", "variables": { - "requirejs": "./js/require.js", - "css": "./css/index.css", - "base": null, - "cachebuster": "?v1.0" + "requirejs": "./js/REQUIREJS_FILE", + "css": "./css/CSS_FILE", + "base": null }, "app": { "root": "/",