Skip to content

Commit

Permalink
Implement machinery for allowing extensions
Browse files Browse the repository at this point in the history
This commit (and the PR to which it belongs)
moves auspice from a component of nextstrain
to a stand alone tool which can be extended
(e.g. with aesthetic or functional changes).
The auspice seen on nextstrain.org will
eventually be one such extension.
  • Loading branch information
jameshadfield committed Dec 31, 2018
1 parent 82f7d5e commit 27ef50d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const expressStaticGzip = require("express-static-gzip");
const charon = require("./src/server/charon");
const globals = require("./src/server/globals");
const compression = require('compression');
const fs = require('fs');
const argparse = require('argparse');
const version = require('./src/version').version;

Expand All @@ -25,6 +26,7 @@ if (!globals.isNpmGlobalInstall()) {
parser.addArgument('--dev', {action: "storeTrue", help: "Run (client) in development mode (hot reloading etc)"});
}
parser.addArgument('--data', {help: "Directory where local datasets are sourced"});
parser.addArgument('--extend', {help: "tmp / wip"});
parser.addArgument('--narratives', {help: "Directory where local narratives are sourced"});
const args = parser.parseArgs();

Expand All @@ -38,6 +40,9 @@ app.use(compression());
if (args.dev) {
/* if we are in dev-mode, we need to import specific libraries & set up hot reloading */
const webpack = require("webpack"); // eslint-disable-line
if (args.extend) {
process.env.EXTEND_AUSPICE_JSON = JSON.stringify(JSON.parse(fs.readFileSync(args.extend, {encoding: 'utf8'})));
}
const webpackConfig = require(process.env.WEBPACK_CONFIG ? process.env.WEBPACK_CONFIG : './webpack.config.dev'); // eslint-disable-line
const compiler = webpack(webpackConfig);
app.use(require("webpack-dev-middleware")( // eslint-disable-line
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import "./css/boxed.css";
import "./css/select.css";
import "./css/narrative.css";

import "./util/extensions"

const store = configureStore();

/* set up non-redux state storage for the animation - use this conservitavely! */
Expand Down
20 changes: 20 additions & 0 deletions src/util/extensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@


/* set up time -- only runs once no matter how many components import this */

const registry = (() => {
console.log("EXTENSTIONS.jS");
if (!process.env.EXTENSION_DATA) {
console.log("no EXTENSION_DATA found")
return {};
}
const extensionJson = JSON.parse(process.env.EXTENSION_DATA);
console.log("extensionJson", extensionJson);
return extensionJson;
})();


export const getExtension = (what) => {
console.log("trying to get:", what)
return "something";
}
3 changes: 2 additions & 1 deletion webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module.exports = {
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("dev")
NODE_ENV: JSON.stringify("dev"),
EXTENSION_DATA: JSON.stringify(process.env.EXTEND_AUSPICE_JSON)
}
}),
new webpack.NoEmitOnErrorsPlugin()
Expand Down

0 comments on commit 27ef50d

Please sign in to comment.