You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ro...@apache.org on 2016/01/20 09:39:08 UTC
[2/2] fauxton commit: updated refs/heads/master to 16a8143
fix fauxton server for module
- use native node methods instead of custom solutions
PR: #613
PR-URL: https://github.com/apache/couchdb-fauxton/pull/613
Reviewed-By: Benjamin Keen <be...@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/16a81431
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/16a81431
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/16a81431
Branch: refs/heads/master
Commit: 16a81431a89f2dbc5886855013c0b2bcb3acff72
Parents: 1de7efa
Author: Robert Kowalski <ro...@apache.org>
Authored: Mon Jan 18 16:10:17 2016 +0100
Committer: Robert Kowalski <ro...@apache.org>
Committed: Wed Jan 20 09:41:06 2016 +0100
----------------------------------------------------------------------
Gruntfile.js | 6 ++++--
index.js | 14 ++++----------
package.json | 4 ++--
settings.json.default.json | 2 +-
version-check.js | 9 +++++++++
5 files changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/16a81431/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index 4826c72..7520519 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -18,6 +18,8 @@
/*jslint node: true */
"use strict";
+const path = require('path');
+
module.exports = function (grunt) {
var helper = require('./tasks/helper.js'),
initHelper = helper.init(grunt),
@@ -325,7 +327,7 @@ module.exports = function (grunt) {
options: {
afterEach: function (fileChanges) {
// replace the REQUIREJS_FILE placeholder with the actual filename
- var newFilename = fileChanges.newPath.match(/[^\/]+$/)[0];
+ const newFilename = path.basename(fileChanges.newPath);
config.template.release.variables.requirejs = config.template.release.variables.requirejs.replace(/REQUIREJS_FILE/, newFilename);
}
}
@@ -336,7 +338,7 @@ module.exports = function (grunt) {
options: {
afterEach: function (fileChanges) {
// replace the CSS_FILE placeholder with the actual filename
- var newFilename = fileChanges.newPath.match(/[^\/]+$/)[0];
+ const newFilename = path.basename(fileChanges.newPath);
config.template.release.variables.css = config.template.release.variables.css.replace(/CSS_FILE/, newFilename);
}
}
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/16a81431/index.js
----------------------------------------------------------------------
diff --git a/index.js b/index.js
index d7f2dc0..5998697 100644
--- a/index.js
+++ b/index.js
@@ -28,16 +28,10 @@ module.exports = function (options) {
.pipe(res);
}
- var fileTypes = ['js', 'css', 'png', 'swf', 'eot', 'woff', 'svg', 'ttf', 'swf'];
+ var fileTypes = ['.js', '.css', '.png', '.swf', '.eot', '.woff', '.svg', '.ttf', '.swf'];
function isFile (url) {
- var arr = url.split('.');
-
- if (arr.length < 2) {
- return false;
- }
-
- return _.contains(fileTypes, arr[1]);
+ return _.contains(fileTypes, path.extname(url));
}
// create proxy to couch for all couch requests
@@ -46,7 +40,7 @@ module.exports = function (options) {
});
http.createServer(function (req, res) {
- var isDocLink = /_utils\/docs/.test(req.url) ? true : false;
+ var isDocLink = /_utils\/docs/.test(req.url);
var url = req.url.split(/\?v=|\?noCache/)[0].replace('_utils', '');
var accept = req.headers.accept.split(',');
@@ -59,7 +53,7 @@ module.exports = function (options) {
if (url === '/' && accept[0] !== 'application/json') {
// serve main index file from here
return sendFile(req, res, path.join(dist_dir, 'index.html'));
- } else if (isFile(url) && !isDocLink ) {
+ } else if (isFile(url) && !isDocLink) {
return sendFile(req, res, path.join(dist_dir, url));
}
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/16a81431/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 845b4bb..a8b1608 100644
--- a/package.json
+++ b/package.json
@@ -41,13 +41,13 @@
"react-tools": "^0.12.0",
"request": "^2.54.0",
"requirejs": "^2.1.22",
+ "semver": "^5.1.0",
"send": "~0.1.1",
"uglify-js": "^2.6.1",
"underscore": "~1.4.2",
"url": "~0.7.9",
"urls": "~0.0.3"
},
-
"scripts": {
"stylecheck": "eslint --ext=js,jsx .",
"build:less:debug": "mkdirp ./dist/debug/dashboard.assets/css && node ./build-helper/less.js dist/debug/dashboard.assets/css/index.css",
@@ -62,7 +62,7 @@
"dev": "grunt dev",
"nightwatch": "grunt nightwatch",
"start": "node ./bin/fauxton",
- "postinstall": "grunt release"
+ "postinstall": "node version-check.js && grunt release"
},
"repository": {
"type": "git",
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/16a81431/settings.json.default.json
----------------------------------------------------------------------
diff --git a/settings.json.default.json b/settings.json.default.json
index 101a0d5..3fe5a2a 100644
--- a/settings.json.default.json
+++ b/settings.json.default.json
@@ -34,7 +34,7 @@
"src": "assets/index.underscore",
"dest": "dist/debug/index.html",
"variables": {
- "requirejs": "./js/REQUIREJS_FILE",
+ "requirejs": "./dashboard.assets/js/REQUIREJS_FILE",
"css": "./dashboard.assets/css/CSS_FILE",
"base": null
},
http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/16a81431/version-check.js
----------------------------------------------------------------------
diff --git a/version-check.js b/version-check.js
new file mode 100644
index 0000000..c8f6c23
--- /dev/null
+++ b/version-check.js
@@ -0,0 +1,9 @@
+var semver = require('semver');
+
+var version = process.version.replace(/^v/, '');
+
+if (!semver.satisfies(version, '>=4')) {
+ console.error('Error:');
+ console.error('Fauxton needs Node 4 or greater to work');
+ process.exit(1);
+}