Browse Source

try a simpler process

try to get thigns running. basically we need to run an express app inside of electorn in order to get all of the files to be served correctly. currently this is broken although the piecesa re in place. I dont know if the express app is being correctly launched so I need a way to be able to launch it manually and see the console output

small updates

gitignore

fix dist path

need to specify globals to load correctly

add stubs for express data static serving

clean the main index file

add donwlaod script...

register the command neccessary to build electron

build instructions for electron

use script to ensure the data is downloaded

add electron specific config that specifies local data use. also add script to clean the release folder and update the dist npm script

add iconset

update package.json scripts and documentaitonon how to use

use asar to compress files now that things are working

remove some unused configs
master
zach charlop-powers 4 years ago
parent
commit
34d96c4cad
  1. 7
      README.md
  2. BIN
      build/background.png
  3. BIN
      build/icon.icns
  4. BIN
      build/icon.ico
  5. 3
      index.html
  6. 43
      index.js
  7. 6302
      package-lock.json
  8. 44
      package.json
  9. 22
      scripts/get_data.sh
  10. 65
      webpack.config.electron.js
  11. 1
      webpack.config.prod.js

7
README.md

@ -25,6 +25,13 @@ Auspice is the web app that gives an interactive display of inferences produced
`$ npm install `
`$ npm start `
## Build Electron App
```
npm install
npm install -g electron-builder
npm run dist:electron
```
## License and copyright
Copyright 2014-2016 Trevor Bedford, Richard Neher and Colin Megill.

BIN
build/background.png

After

Width: 64  |  Height: 64  |  Size: 8.2 KiB

BIN
build/icon.icns

BIN
build/icon.ico

After

Width: 64  |  Height: 64  |  Size: 8.2 KiB

3
index.html

@ -250,7 +250,6 @@
return component;
}
</script>
<script src="/dist/bundle.js"></script>
<script src="./dist/bundle.js"></script>
</body>
</html>

43
index.js

@ -0,0 +1,43 @@
const {app, BrowserWindow } = require('electron');
const path = require('path');
const url = require('url');
const http = require('http');
const express = require("express");
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
app.on('ready', function() {
// port this code from server.js
// from https://gist.github.com/maximilian-ruppert/a446a7ee87838a62099d
var expressApp = express();
//register stati directories
expressApp.use("/dist", express.static(path.join(__dirname, 'dist')));
expressApp.use("/data", express.static(path.join(__dirname, 'data')));
expressApp.get("*", function(req, res) {
res.sendFile(path.join(__dirname, "index.html"));
});
// Start the Express App
http.createServer(expressApp).listen(5000);
//setup the main window
mainWindow = new BrowserWindow({
width: 800,
height: 600,
useContentSize: true,
resizable: true
});
// run the Nextstrain express app in that window
mainWindow.loadURL('http://localhost:5000/');
mainWindow.focus();
});

6302
package-lock.json
File diff suppressed because it is too large
View File

44
package.json

@ -5,15 +5,53 @@
"scripts": {
"clean": "rimraf dist",
"build:webpack": "NODE_ENV=production webpack --config webpack.config.prod.js",
"build:electron": "NODE_ENV=production webpack --config webpack.config.electron.js",
"build": "npm run clean && npm run build:webpack",
"start": "node dev-server.js",
"start:local": "node dev-server.js local",
"server": "node server.js",
"lint": "eslint src",
"postinstall": "npm run build"
"postinstall": "npm run build",
"getdata": "sh scripts/get_data.sh",
"run:electron": "npm run clean && npm run build:electron && npm run getdata && ./node_modules/.bin/electron . ",
"dist:electron": "npm run clean && npm run build:electron && npm run getdata && electron-builder"
},
"author": "Trevor Bedford and Richard Neher",
"license": "AGPL",
"homepage": "./",
"build": {
"appId": "nextstrain",
"directories": {
"output": "releases"
},
"files": [
"data/*",
"dist/*",
"index.html",
"index.js",
"package.json"
],
"dmg": {
"contents": [
{
"x": 110,
"y": 150
},
{
"x": 240,
"y": 150,
"type": "link",
"path": "/Applications"
}
]
},
"linux": {
"target": [
"AppImage",
"deb"
]
}
},
"devDependencies": {
"babel-core": "^5.8.25",
"babel-eslint": "^4.1.3",
@ -21,6 +59,8 @@
"babel-plugin-react-transform": "^1.1.1",
"compression-webpack-plugin": "^0.3.2",
"css-loader": "^0.26.1",
"electron-builder": "next",
"electron-prebuilt": "^1.4.13",
"es6-promise": "~1.0.0",
"eslint": "3.5.0",
"eslint-config-defaults": "^7.0.1",
@ -43,6 +83,7 @@
},
"dependencies": {
"binomial": "^0.2.0",
"asar": "^0.13.0",
"color": "^0.7.3",
"d3": "^3.5.17",
"d3-axis": "^1.0.6",
@ -50,6 +91,7 @@
"d3-scale": "^1.0.5",
"d3-selection": "^1.0.5",
"d3-zoom": "^1.1.3",
"express": "^4.13.3",
"express-static-gzip": "^0.2.2",
"history": "^4.6.0",
"linspace": "^1.0.0",

22
scripts/get_data.sh

@ -0,0 +1,22 @@
rm -rf data/
mkdir -p data/
curl http://data.nextstrain.org/ebola_tree.json --compressed -o data/ebola_tree.json
curl http://data.nextstrain.org/ebola_sequences.json --compressed -o data/ebola_sequences.json
curl http://data.nextstrain.org/ebola_meta.json --compressed -o data/ebola_meta.json
curl http://data.nextstrain.org/ebola_entropy.json --compressed -o data/ebola_entropy.json
curl http://data.nextstrain.org/zika_tree.json --compressed -o data/zika_tree.json
curl http://data.nextstrain.org/zika_sequences.json --compressed -o data/zika_sequences.json
curl http://data.nextstrain.org/zika_meta.json --compressed -o data/zika_meta.json
curl http://data.nextstrain.org/zika_entropy.json --compressed -o data/zika_entropy.json
curl http://data.nextstrain.org/flu_tree.json --compressed -o data/flu_tree.json
curl http://data.nextstrain.org/flu_sequences.json --compressed -o data/flu_sequences.json
curl http://data.nextstrain.org/flu_meta.json --compressed -o data/flu_meta.json
curl http://data.nextstrain.org/flu_entropy.json --compressed -o data/flu_entropy.json
curl http://data.nextstrain.org/dengue_tree.json --compressed -o data/dengue_tree.json
curl http://data.nextstrain.org/dengue_sequences.json --compressed -o data/dengue_sequences.json
curl http://data.nextstrain.org/dengue_meta.json --compressed -o data/dengue_meta.json
curl http://data.nextstrain.org/dengue_entropy.json --compressed -o data/dengue_entropy.json

65
webpack.config.electron.js

@ -0,0 +1,65 @@
var path = require("path");
var webpack = require("webpack");
var CompressionPlugin = require('compression-webpack-plugin');
// let commitHash = require('child_process')
// .execSync('git rev-parse --short HEAD')
// .toString();
module.exports = {
// devtool: "source-map",
entry: [
"./src/index"
],
output: {
path: path.join(__dirname, "dist"),
filename: "bundle.js",
publicPath: "/dist/"
},
target: "electron-renderer",
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
"process.env": {
"NODE_ENV": JSON.stringify("production"),
"DATA_LOCAL": JSON.stringify(true)
},
'global': {}
}),
new webpack.optimize.UglifyJsPlugin({ // minify everything
compressor: {
warnings: false
}
}),
new webpack.optimize.DedupePlugin(), // dedupe similar code
new webpack.optimize.AggressiveMergingPlugin(), // merge chunks
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), // ignore all locale files of moment.js
new CompressionPlugin({ // gzip everything
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8
})
],
module: {
preLoaders: [
{ test: /\.json$/, loader: "json"}
],
loaders: [{
test: /\.js$/,
loaders: ["babel"],
include: path.join(__dirname, "src")
},
{
test: /\.css$/,
loaders: [ "style-loader", "css-loader" ]
},
{
test: /\.(gif|png|jpe?g|svg)$/i, loader: "file-loader",
include: path.join(__dirname, "src")
}]
}
};

1
webpack.config.prod.js

@ -24,6 +24,7 @@ module.exports = {
"DATA_LOCAL": JSON.stringify(false)
}
}),
new webpack.optimize.UglifyJsPlugin({ // minify everything
compressor: {
warnings: false

Loading…
Cancel
Save