Repository: couchdb-fauxton Updated Branches: refs/heads/master fad972a56 -> d71ea8b16
revert: "Open up require's config.js file to be extended" This reverts fad972a56ec7b2d799921cc5756baa7aace900ed The commit caused problems for the bundled script. Two things need to be fixed: - md5 encoding of the two new files: config.js + any overridden files included by a wrapper - grunt updated to copy those files over during the dist build step i Please enter the commit message for your changes. Lines starting Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/d71ea8b1 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/d71ea8b1 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/d71ea8b1 Branch: refs/heads/master Commit: d71ea8b163411521ef1e4f9310d4bebc53a072ed Parents: fad972a Author: Ben Keen <[email protected]> Authored: Wed Jun 17 14:19:59 2015 -0700 Committer: Ben Keen <[email protected]> Committed: Wed Jun 17 14:19:59 2015 -0700 ---------------------------------------------------------------------- Gruntfile.js | 3 +- app/config-source.js | 68 -------------------------------------------- app/config.js | 63 ++++++++++++++++++++++++++++++++++++++-- assets/index.underscore | 2 -- tasks/fauxton.js | 38 +++++++++++-------------- 5 files changed, 78 insertions(+), 96 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d71ea8b1/Gruntfile.js ---------------------------------------------------------------------- diff --git a/Gruntfile.js b/Gruntfile.js index 836df39..e7c408a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -370,8 +370,7 @@ module.exports = function (grunt) { src: initHelper.watchFiles(['[Ss]pec.js'], ['./app/addons/**/*[Ss]pec.js', './app/addons/**/*[Ss]pec.react.js', './app/core/**/*[Ss]pec.js', './app/**/*[Ss]pec.js']) }, template: 'test/test.config.underscore', - config: './app/config-source.js', - templateSettings: templateSettings + config: './app/config.js' } }, http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d71ea8b1/app/config-source.js ---------------------------------------------------------------------- diff --git a/app/config-source.js b/app/config-source.js deleted file mode 100644 index ac7d99b..0000000 --- a/app/config-source.js +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); you may not -// use this file except in compliance with the License. You may obtain a copy of -// the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations under -// the License. - -var requireConfig = { - - // initialize the application with the main application file - deps: ['main'], - - paths: { - - // JavaScript folders - libs: '../assets/js/libs', - plugins: '../assets/js/plugins', - - // Libraries - jquery: '../assets/js/libs/jquery', - lodash: '../assets/js/libs/lodash', - backbone: '../assets/js/libs/backbone', - 'backbone.layoutmanager': '../assets/js/plugins/backbone.layoutmanager', - bootstrap: '../assets/js/libs/bootstrap', - spin: '../assets/js/libs/spin.min', - d3: '../assets/js/libs/d3', - ace: '../assets/js/libs/ace', - 'cloudant.pagingcollection': '../assets/js/plugins/cloudant.pagingcollection', - velocity: '../assets/js/plugins/velocity', - 'velocity.ui': '../assets/js/plugins/velocity.ui', - react: '../assets/js/libs/react', - flux: '../assets/js/libs/flux', - 'es5-shim': '../assets/js/libs/es5-shim', - 'css.escape': '../assets/js/libs/css.escape', - moment: '../assets/js/libs/moment' - }, - - baseUrl: '/', - - map: { - '*': { - 'underscore': 'lodash', - 'api': 'core/api' - } - }, - - shim: { - backbone: { - deps: ['lodash', 'jquery'], - exports: 'Backbone' - }, - bootstrap: { - deps: ['jquery'], - exports: 'Bootstrap' - }, - 'plugins/prettify': [], - 'plugins/beautify': [], - 'plugins/jquery.form': ['jquery'], - velocity: ['jquery'], - 'velocity.ui': ['velocity'] - } -}; - http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d71ea8b1/app/config.js ---------------------------------------------------------------------- diff --git a/app/config.js b/app/config.js index b560b7c..da2b606 100644 --- a/app/config.js +++ b/app/config.js @@ -10,6 +10,65 @@ // License for the specific language governing permissions and limitations under // the License. -/* global requireConfig */ -require.config(requireConfig); +// Set the require.js configuration for your application. +require.config({ + + // Initialize the application with the main application file. + deps: ["main"], + + paths: { + // JavaScript folders. + libs: "../assets/js/libs", + plugins: "../assets/js/plugins", + + // Libraries. + jquery: "../assets/js/libs/jquery", + lodash: "../assets/js/libs/lodash", + backbone: "../assets/js/libs/backbone", + "backbone.layoutmanager": "../assets/js/plugins/backbone.layoutmanager", + bootstrap: "../assets/js/libs/bootstrap", + spin: "../assets/js/libs/spin.min", + d3: "../assets/js/libs/d3", + "ace":"../assets/js/libs/ace", + "cloudant.pagingcollection": "../assets/js/plugins/cloudant.pagingcollection", + "velocity": "../assets/js/plugins/velocity", + "velocity.ui": "../assets/js/plugins/velocity.ui", + react: "../assets/js/libs/react", + flux: "../assets/js/libs/flux", + "es5-shim": "../assets/js/libs/es5-shim", + "css.escape": "../assets/js/libs/css.escape", + moment: '../assets/js/libs/moment' + }, + + baseUrl: '/', + + map: { + "*": { + 'underscore': 'lodash', + 'api':'core/api' + } + }, + + shim: { + // Backbone library depends on lodash and jQuery. + backbone: { + deps: ["lodash", "jquery"], + exports: "Backbone" + }, + + bootstrap: { + deps: ["jquery"], + exports: "Bootstrap" + }, + + "plugins/prettify": [], + "plugins/beautify": [], + + "plugins/jquery.form": ["jquery"], + + "velocity": ["jquery"], + + "velocity.ui": ["velocity"] + } +}); http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d71ea8b1/assets/index.underscore ---------------------------------------------------------------------- diff --git a/assets/index.underscore b/assets/index.underscore index 2043e9a..fc669ec 100644 --- a/assets/index.underscore +++ b/assets/index.underscore @@ -42,8 +42,6 @@ </div> <!-- Application source. --> - <script src="/app/config-source.js"></script> <script data-main="/config" src="<%= requirejs %>"></script> - </body> </html> http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/d71ea8b1/tasks/fauxton.js ---------------------------------------------------------------------- diff --git a/tasks/fauxton.js b/tasks/fauxton.js index 36ec5b1..ed5c021 100644 --- a/tasks/fauxton.js +++ b/tasks/fauxton.js @@ -12,13 +12,7 @@ module.exports = function (grunt) { var _ = grunt.util._, - fs = require('fs'), - vm = require('vm'); - - var includeInScope = function (path) { - var code = fs.readFileSync(path); - vm.runInThisContext(code, path); - }.bind(this); + fs = require('fs'); grunt.registerMultiTask('template', 'generates an html file from a specified template', function () { var data = this.data, @@ -115,6 +109,7 @@ module.exports = function (grunt) { grunt.registerMultiTask('mochaSetup', 'Generate a config.js and runner.html for tests', function () { var data = this.data, + configInfo, _ = grunt.util._, configTemplateSrc = data.template; @@ -128,23 +123,22 @@ module.exports = function (grunt) { }); 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 + var require = { + config: function (args) { + configInfo = args; + configInfo.paths['chai'] = '../test/mocha/chai'; + configInfo.paths['sinon-chai'] = '../test/mocha/sinon-chai'; + configInfo.paths['testUtils'] = '../test/mocha/testUtils'; + configInfo.baseUrl = '../app'; + delete configInfo.deps; + } + }; - // include the config file source. That contains a requireConfig var that's included in this scope - includeInScope(data.config); - - // if the settings file specifies a file that extends Require's config.js file, include it as well - if (data.templateSettings.development.variables && data.templateSettings.development.variables.config_extend_file) { - includeInScope(data.templateSettings.development.variables.config_extend_file); - } - - // now apply whatever additional requireJS config changes we need - requireConfig.paths['chai'] = '../test/mocha/chai'; - requireConfig.paths['sinon-chai'] = '../test/mocha/sinon-chai'; - requireConfig.paths['testUtils'] = '../test/mocha/testUtils'; - requireConfig.baseUrl = '../app'; - delete requireConfig.deps; + eval(grunt.file.read(data.config) + ''); - grunt.file.write('./test/test.config.js', configTemplate({ configInfo: requireConfig, testFiles: testFiles })); + grunt.file.write('./test/test.config.js', configTemplate({configInfo: configInfo, testFiles: testFiles})); });
