couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject fauxton commit: updated refs/heads/master to cfc664d
Date Mon, 08 Feb 2016 16:44:23 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 378d80e60 -> cfc664da2


transpile with babel

Hello babel!

Additional changes:

 - optimize watch task: run stylecheck before to provide faster
   feedback

PR: #609
PR-URL: https://github.com/apache/couchdb-fauxton/pull/609
Reviewed-By: garren smith <garren.smith@gmail.com>
Reviewed-By: Benjamin Keen <ben.keen@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/cfc664da
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/cfc664da
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/cfc664da

Branch: refs/heads/master
Commit: cfc664da24d9c36e4d44b97ce0d226f0487fb78e
Parents: 378d80e
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Fri Jan 15 15:52:02 2016 +0100
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Mon Feb 8 16:44:10 2016 +0000

----------------------------------------------------------------------
 .babelrc                          |   5 ++
 Gruntfile.js                      | 100 ++++++++++++++++-----------------
 app/addons/activetasks/actions.js |   1 +
 package.json                      |   8 ++-
 tasks/couchserver.js              |  10 +++-
 tasks/fauxton.js                  |   4 ++
 tasks/helper.js                   |   4 +-
 test/test.config.underscore       |   4 +-
 8 files changed, 77 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/cfc664da/.babelrc
----------------------------------------------------------------------
diff --git a/.babelrc b/.babelrc
new file mode 100644
index 0000000..2e9146f
--- /dev/null
+++ b/.babelrc
@@ -0,0 +1,5 @@
+{
+  "presets": [
+    "react"
+  ]
+}

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/cfc664da/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index 7520519..e1e5331 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -145,21 +145,21 @@ module.exports = function (grunt) {
 
     watch: {
       js: {
-        files: initHelper.watchFiles(['.js'], ["./app/**/*.js", '!./app/load_addons.js',
"./assets/**/*.js", "./test/**/*.js"]),
+        files: initHelper.getFileList(['.js'], ["./app/**/*.js", '!./app/load_addons.js',
"./assets/**/*.js", "./test/**/*.js"]),
         tasks: []
       },
       jsx: {
-        files: initHelper.watchFiles(['.jsx'], ["./app/**/*.jsx", '!./app/load_addons.jsx',
"./assets/**/*.jsx", "./test/**/*.jsx"]),
+        files: initHelper.getFileList(['.jsx'], ["./app/**/*.jsx", '!./app/load_addons.jsx',
"./assets/**/*.jsx", "./test/**/*.jsx"]),
         tasks: []
       },
       style: {
-        files: initHelper.watchFiles(['.less', '.css'], ["./app/**/*.css", "./app/**/*.less",
"./assets/**/*.css", "./assets/**/*.less"]),
+        files: initHelper.getFileList(['.less', '.css'], ["./app/**/*.css", "./app/**/*.less",
"./assets/**/*.css", "./assets/**/*.less"]),
         tasks: ['clean:watch', 'dependencies', 'shell:build-less-debug']
       },
       html: {
         // the index.html is added in as a dummy file incase there is no
         // html dependancies this will break. So we need one include pattern
-        files: initHelper.watchFiles(['.html'], ['./index.html']),
+        files: initHelper.getFileList(['.html'], ['./index.html']),
         tasks: ['clean:watch', 'dependencies']
       },
       options: {
@@ -212,6 +212,12 @@ module.exports = function (grunt) {
         ]
       },
 
+      distDepsRequire: {
+        files:[
+          {src: 'assets/**', dest: 'dist/tmp-out/', flatten: false, expand: false},
+        ]
+      },
+
       debug: {
         files:[
           {src: ['assets/js/**/*.swf'], dest: 'dist/debug/dashboard.assets/', flatten: true,
expand: true, filter: 'isFile'},
@@ -221,9 +227,11 @@ module.exports = function (grunt) {
         ]
       },
 
-      // populated dynamically by watch tasks
-      changedFiles: {
-        files: []
+      testfiles: {
+        files:[
+          {src: ['test/**'], dest: 'dist/debug/', flatten: false, expand: true},
+          {src: 'assets/**', dest: 'dist/debug/', flatten: false, expand: false},
+        ]
       }
     },
 
@@ -248,7 +256,11 @@ module.exports = function (grunt) {
     mochaSetup: {
       default: {
         files: {
-          src: initHelper.watchFiles(['[Ss]pec.js'], ['./app/addons/**/*[Ss]pec.js', './app/addons/**/*[Ss]pec.react.js',
'./app/core/**/*[Ss]pec.js'])
+          src: initHelper.getFileList(['[Ss]pec.js'], [
+            './app/addons/**/*[Ss]pec.js',
+            './app/addons/**/*[Ss]pec.react.jsx',
+            './app/core/**/*[Ss]pec.js'
+          ])
         },
         template: 'test/test.config.underscore',
         config: './app/config.js'
@@ -256,12 +268,6 @@ module.exports = function (grunt) {
     },
 
     shell: {
-      'build-jsx': {
-        command: 'node ./node_modules/react-tools/bin/jsx -x jsx app/addons/ app/addons/
--no-cache-dir',
-        stdout: true,
-        failOnError: true
-      },
-
       'build-single-jsx': {
         command: '', // populated dynamically
         stdout: true,
@@ -284,6 +290,14 @@ module.exports = function (grunt) {
         command: 'npm run build:css-compress'
       },
 
+      'build-transpile-js-debug': {
+        command: 'npm run build:transpile:debug'
+      },
+
+      'build-transpile-js-release': {
+        command: 'npm run build:transpile:release'
+      },
+
       uglify: {
         command: 'npm run build:uglify'
       },
@@ -299,7 +313,7 @@ module.exports = function (grunt) {
       phantomjs: {
         command: 'node ./node_modules/phantomjs/bin/phantomjs --debug=false ' +
           '--ssl-protocol=sslv2 --web-security=false --ignore-ssl-errors=true ' +
-          './node_modules/mocha-phantomjs/lib/mocha-phantomjs.coffee test/runner.html'
+          './node_modules/mocha-phantomjs/lib/mocha-phantomjs.coffee ./dist/debug/test/runner.html'
       }
     },
 
@@ -362,39 +376,26 @@ module.exports = function (grunt) {
 
     // compile the single JSX file into the appropriate Fauxton folder
     var targetFilepath = filepath;
-    if (isJSX) {
-      var folder = filepath.replace(/\/[^\/]*$/, '');
-      var targetFolder = folder;
-
-      // if the JSX file ISN'T in Fauxton, generate the .js file there
-      if (!(/^app\/addons/.test(folder))) {
-        targetFolder = folder.replace(/.*\/addons/, 'app/addons');
-      }
-      targetFilepath = filepath.replace(/.*\/addons/, 'app/addons');
-      targetFilepath = targetFilepath.replace(/\.jsx$/, '.js');
 
-      config.shell['build-single-jsx'].command = 'node ./node_modules/react-tools/bin/jsx
-x jsx ' + folder + ' ' + targetFolder + ' --no-cache-dir';
-      grunt.task.run(['shell:build-single-jsx']);
-    }
+    var folder = filepath.replace(/\/[^\/]*$/, '');
+    var targetFolder = folder;
 
-    // if the JS file that just changed was outside of Fauxton, copy it over
-    if (isJS && !(/^app\/addons/.test(filepath))) {
-      config.copy.changedFiles.files = [{
-        src: filepath,
-        dest: filepath.replace(/.*\/addons/, 'app/addons')
-      }];
-      grunt.task.run(['copy:changedFiles']);
-    }
-
-    // lastly, run jshint + stylecheck the file. Note: this run multiple times when you save
a single file because the
-    // jsx command above doesn't allow targeting a specific file, just a folder. So any JSX
file in the changed file
-    // folder or subfolder are copied over, causing every one of the files to be jshinted.
Still far faster than before
+    // stylecheck the file.
     if (targetFilepath.indexOf('test.config.js') === -1) {
-
-      config.shell.stylecheckSingleFile.command = 'node ./node_modules/eslint/bin/eslint.js
' + targetFilepath;
+      config.shell.stylecheckSingleFile.command = 'node ./node_modules/eslint/bin/eslint.js
' + filepath;
 
       grunt.task.run(['shell:stylecheckSingleFile']);
     }
+
+    // transpile
+    if (!(/^app\/addons/.test(folder))) {
+      targetFolder = folder.replace(/.*\/addons/, 'app/addons');
+    }
+    targetFilepath = filepath.replace(/.*\/addons/, 'app/addons');
+    targetFilepath = targetFilepath.replace(/\.jsx$/, '.js');
+
+    config.shell['build-single-jsx'].command = 'node ./node_modules/babel-cli/bin/babel --presets
es2015,react ' + filepath + ' > dist/debug/' + targetFilepath;
+    grunt.task.run(['shell:build-single-jsx']);
   });
 
 
@@ -425,16 +426,15 @@ module.exports = function (grunt) {
    */
   // clean out previous build artifacts and lint
   grunt.registerTask('lint', ['clean', 'shell:stylecheck']);
-  grunt.registerTask('test', ['checkTestExists', 'clean:release', 'dependencies', 'jsx',
'shell:stylecheck', 'gen_initialize:development', 'test_inline']);
+  grunt.registerTask('test', ['checkTestExists', 'clean:release', 'dependencies', 'copy:debug',
'shell:stylecheck', 'shell:build-transpile-js-debug', 'gen_initialize:development', 'test_inline']);
 
   // lighter weight test task for use inside dev/watch
-  grunt.registerTask('test_inline', ['mochaSetup', 'jst', 'concat:test_config_js', 'shell:phantomjs']);
+  grunt.registerTask('test_inline', ['mochaSetup', 'jst', 'concat:test_config_js', 'copy:testfiles',
'shell:phantomjs']);
   // Fetch dependencies (from git or local dir), lint them and make load_addons
   grunt.registerTask('dependencies', ['get_deps', 'gen_load_addons:default']);
 
   // minify code and css, ready for release.
-  grunt.registerTask('jsx', ['shell:build-jsx']);
-  grunt.registerTask('build', ['shell:build-less-release', 'jst', 'shell:requirejs', 'concat:requirejs',
'shell:uglify',
+  grunt.registerTask('build', ['copy:distDepsRequire', 'shell:build-less-release', 'jst',
'shell:build-transpile-js-release', 'shell:requirejs', 'concat:requirejs', 'shell:uglify',
     'shell:css-compress', 'md5:requireJS', 'md5:css', 'template:release']);
 
   /*
@@ -444,17 +444,17 @@ module.exports = function (grunt) {
   grunt.registerTask('dev', ['debugDev', 'couchserver']);
 
   // build a debug release
-  grunt.registerTask('debug', ['lint', 'dependencies', "gen_initialize:development", 'jsx',
'concat:requirejs', 'shell:build-less-debug',
+  grunt.registerTask('debug', ['lint', 'dependencies', "gen_initialize:development", 'shell:build-transpile-js-debug',
'concat:requirejs', 'shell:build-less-debug',
     'template:development', 'copy:debug']);
 
-  grunt.registerTask('debugDev', ['clean', 'dependencies', "gen_initialize:development",
'jsx', 'shell:stylecheck',
-    'shell:build-less-debug', 'template:development', 'copy:debug']);
+  grunt.registerTask('debugDev', ['clean', 'dependencies', "gen_initialize:development",
'shell:stylecheck',
+    'shell:build-less-debug', 'template:development', 'copy:debug', 'shell:build-transpile-js-debug']);
 
   grunt.registerTask('watchRun', ['clean:watch', 'dependencies', 'shell:stylecheck']);
 
   // build a release
   grunt.registerTask('release_commons_prefix', ['clean', 'dependencies']);
-  grunt.registerTask('release_commons_suffix', ['shell:stylecheck', 'shell:build-jsx', 'build',
'copy:dist', 'copy:ace']);
+  grunt.registerTask('release_commons_suffix', ['shell:stylecheck', 'build', 'copy:dist',
'copy:ace']);
 
   grunt.registerTask('release', ['release_commons_prefix', 'gen_initialize:release', 'release_commons_suffix']);
   grunt.registerTask('couchapp_release', ['release_commons_prefix', 'gen_initialize:couchapp',
'release_commons_suffix']);

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/cfc664da/app/addons/activetasks/actions.js
----------------------------------------------------------------------
diff --git a/app/addons/activetasks/actions.js b/app/addons/activetasks/actions.js
index 41498d9..b2e5622 100644
--- a/app/addons/activetasks/actions.js
+++ b/app/addons/activetasks/actions.js
@@ -15,6 +15,7 @@ define([
 ],
 function (FauxtonAPI, ActionTypes) {
   return {
+
     init: function (activeTasks) {
       this.fetchAndSetActiveTasks(activeTasks.table, activeTasks);
       FauxtonAPI.when(activeTasks.fetch()).then(function () {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/cfc664da/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index dd974e6..777300a 100644
--- a/package.json
+++ b/package.json
@@ -17,6 +17,9 @@
   },
   "dependencies": {
     "async": "~0.2.6",
+    "babel-cli": "^6.4.0",
+    "babel-preset-es2015": "^6.3.13",
+    "babel-preset-react": "^6.3.13",
     "clean-css": "^3.4.9",
     "couchapp": "~0.11.0",
     "eslint": "^1.6.0",
@@ -38,7 +41,6 @@
     "mkdirp": "^0.5.1",
     "nano": "~5.12.0",
     "optimist": "^0.6.1",
-    "react-tools": "^0.12.0",
     "request": "^2.54.0",
     "requirejs": "^2.1.22",
     "semver": "^5.1.0",
@@ -54,7 +56,9 @@
     "build:less:release": "mkdirp ./dist/tmp-out && node ./build-helper/less.js dist/tmp-out/index-max.css",
     "build:css-compress": "mkdirp ./dist/release/dashboard.assets/css/ && cleancss
--skip-rebase -o dist/tmp-out/index.css dist/tmp-out/index-max.css",
     "build:uglify": "mkdirp ./dist/release/dashboard.assets/js/ && uglifyjs --mangle
--compress=warnings=false --screw-ie8 -o dist/tmp-out/require.js dist/tmp-out/require-max-concat.js",
-    "build:requirejs:production": "mkdirp ./dist/tmp-out && r.js -o out=dist/tmp-out/require-max.js
baseUrl=app mainConfigFile=app/config.js name=config optimize=none wrap=false findNestedDependencies=true",
+    "build:requirejs:production": "mkdirp ./dist/tmp-out && r.js -o out=dist/tmp-out/require-max.js
baseUrl=dist/tmp-out/app mainConfigFile=dist/tmp-out/app/config.js name=config optimize=none
wrap=false findNestedDependencies=true",
+    "build:transpile:debug": "babel app --out-dir dist/debug/app",
+    "build:transpile:release": "babel app --out-dir dist/tmp-out/app",
     "test": "grunt test",
     "couchdebug": "grunt couchdebug",
     "couchdb": "grunt couchdb",

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/cfc664da/tasks/couchserver.js
----------------------------------------------------------------------
diff --git a/tasks/couchserver.js b/tasks/couchserver.js
index d4e434c..e9fcc3d 100644
--- a/tasks/couchserver.js
+++ b/tasks/couchserver.js
@@ -30,7 +30,7 @@ module.exports = function (grunt) {
 
     // Options
     var dist_dir = './dist/debug/',
-        app_dir = './app',
+        app_dir = './dist/debug/app',
         port = options.port,
         setContentSecurityPolicy = _.isUndefined(options.contentSecurityPolicy) ? true :
options.contentSecurityPolicy;
 
@@ -78,10 +78,14 @@ module.exports = function (grunt) {
       } else if (!!url.match(/\.css|img/)) {
         url = url.replace(/\?.*/, '');
         filePath = path.join(dist_dir, url);
-      } else if (!!url.match(/\.js(\?_.*)?$|\.html(\?_.*)?$/)) {
+      } else if (!!url.match(/\.js(\?_.*)?$/)) {
         // server js from app directory
         url = url.replace(/\?_.*/, '');
-        filePath = path.join(app_dir, url.replace('/_utils/fauxton/', ''));
+        filePath = path.join('./dist/debug/app', url.replace('/_utils/fauxton/', ''));
+      } else if (!!url.match(/\.html(\?_.*)?$/)) {
+        // deprecated route for old backbone template
+        url = url.replace(/\?_.*/, '');
+        filePath = path.join('./app', url.replace('/_utils/fauxton/', ''));
       // handles local references to any addon dependencies (e.g. ZeroClipboard.swf)
       } else if (!!url.match(/addons\/[^\/]+\/dependencies\/.+/)) {
         var urlNoQueryStr = url.replace(/\?.*$/, '');

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/cfc664da/tasks/fauxton.js
----------------------------------------------------------------------
diff --git a/tasks/fauxton.js b/tasks/fauxton.js
index 0ba02d8..71a3024 100644
--- a/tasks/fauxton.js
+++ b/tasks/fauxton.js
@@ -124,6 +124,10 @@ module.exports = function (grunt) {
       return /\/app\//.test(filePath);
     });
 
+    testFiles = testFiles.map(function (file) {
+      return file.replace(/\.jsx$/, '.js');
+    });
+
     var configTemplate = _.template(grunt.file.read(configTemplateSrc));
     // a bit of a nasty hack to read our current config.js and get the info so we can change
it
     // for our testing setup

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/cfc664da/tasks/helper.js
----------------------------------------------------------------------
diff --git a/tasks/helper.js b/tasks/helper.js
index a6551a6..02fd6b4 100644
--- a/tasks/helper.js
+++ b/tasks/helper.js
@@ -46,11 +46,11 @@ exports.init = function (grunt) {
       this.readSettingsFile().deps.forEach(callback);
     },
 
-    watchFiles: function (fileExtensions, defaults) {
+    getFileList: function (fileExtensions, defaults) {
       return _.reduce(this.readSettingsFile().deps, function (files, dep) {
         if (dep.path) {
           _.each(fileExtensions, function (fileExtension) {
-            files.push(path.join(dep.path, '**/*' + fileExtension ));
+            files.push(path.join(dep.path, '**/*' + fileExtension));
           });
         }
         return files;

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/cfc664da/test/test.config.underscore
----------------------------------------------------------------------
diff --git a/test/test.config.underscore b/test/test.config.underscore
index 2a42d68..3b1b90c 100644
--- a/test/test.config.underscore
+++ b/test/test.config.underscore
@@ -14,12 +14,12 @@
 //
 // Set the require.js configuration for your test setup.
 require.config(
-<%= JSON.stringify(configInfo, null, '\t') %>
+<%= JSON.stringify(configInfo, null, '  ') %>
 );
 
 require([
+        'es5-shim',
         'app',
-        "es5-shim",
         <% _.each(testFiles, function (test) {%>
            <% if (test[0] === '.') { %>
            '../<%= test %>',


Mime
View raw message