diff --git a/.gitignore b/.gitignore index e034b4100b..4c2c6ce8a0 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,6 @@ target # Closed source libraries closed-lib +# Node dependencies +node_modules + diff --git a/app.js b/app.js new file mode 100644 index 0000000000..4ebc9c3e94 --- /dev/null +++ b/app.js @@ -0,0 +1,62 @@ +/*global require,process,console*/ + +/** + * Usage: + * + * npm install minimist express + * node app.js [options] + */ + +(function () { + "use strict"; + + var BUNDLE_FILE = 'bundles.json', + options = require('minimist')(process.argv.slice(2)), + express = require('express'), + app = express(), + fs = require('fs'), + bundles = JSON.parse(fs.readFileSync(BUNDLE_FILE, 'utf8')); + + // Defaults + options.port = options.port || options.p || 8080; + ['include', 'exclude', 'i', 'x'].forEach(function (opt) { + options[opt] = options[opt] || []; + // Make sure includes/excludes always end up as arrays + options[opt] = Array.isArray(options[opt]) ? + options[opt] : [options[opt]]; + }); + options.include = options.include.concat(options.i); + options.exclude = options.exclude.concat(options.x); + + // Show command line options + if (options.help || options.h) { + console.log("\nUsage: node app.js [options]\n"); + console.log("Options:"); + console.log(" --help, -h Show this message."); + console.log(" --port, -p Specify port."); + console.log(" --include, -i Include the specified bundle."); + console.log(" --exclude, -x Exclude the specified bundle."); + console.log(""); + process.exit(0); + } + + // Handle command line inclusions/exclusions + bundles = bundles.concat(options.include); + bundles = bundles.filter(function (bundle) { + return options.exclude.indexOf(bundle) === -1; + }); + bundles = bundles.filter(function (bundle, index) { // Uniquify + return bundles.indexOf(bundle) === index; + }); + + // Override bundles.json for HTTP requests + app.use('/' + BUNDLE_FILE, function (req, res) { + res.send(JSON.stringify(bundles)); + }); + + // Expose everything else as static files + app.use(express['static']('.')); + + // Finally, open the HTTP server + app.listen(options.port); +}()); \ No newline at end of file diff --git a/bundles.json b/bundles.json index 04515b1897..666e520854 100644 --- a/bundles.json +++ b/bundles.json @@ -15,8 +15,8 @@ "platform/features/scrolling", "platform/forms", "platform/persistence/queue", - "platform/persistence/elastic", "platform/policy", + "example/persistence", "example/generator" ] diff --git a/platform/persistence/elastic/bundle.json b/platform/persistence/elastic/bundle.json index 53f8571e1a..371b8aa17a 100644 --- a/platform/persistence/elastic/bundle.json +++ b/platform/persistence/elastic/bundle.json @@ -17,15 +17,18 @@ }, { "key": "ELASTIC_ROOT", - "value": "/elastic" + "value": "/elastic", + "priority": "fallback" }, { "key": "ELASTIC_PATH", - "value": "mct/domain_object" + "value": "mct/domain_object", + "priority": "fallback" }, { "key": "ELASTIC_INDICATOR_INTERVAL", - "value": 15000 + "value": 15000, + "priority": "fallback" } ], "indicators": [ diff --git a/pom.xml b/pom.xml index 783cc8ce45..b8cc32ca06 100644 --- a/pom.xml +++ b/pom.xml @@ -160,6 +160,8 @@ ${basedir} **/lib/** + app.js + node_modules/**/*