Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the default network setting outside of built bundles - Closes #491 #538

Merged
merged 17 commits into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dist
node_modules
coverage
app/build
app/build-testnet
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"beforeEach": true,
"afterEach": true,
"ipc": true,
"DEFAULT_NEWTORK": true,
"PRODUCTION": true,
"TEST": true
},
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ e2e-test-screenshots
app/report.html
app/*.map
app/build
app/build-testnet
*.sw[pon]
app/app.js
.vscode
Expand Down
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ node('lisk-hub') {
sh '''
cp ~/.coveralls.yml-hub .coveralls.yml
npm run --silent build
npm run --silent build:testnet
rsync -axl --delete --rsync-path="mkdir -p /var/www/test/${JOB_NAME%/*}/$BRANCH_NAME/ && rsync" $WORKSPACE/app/build/ jenkins@master-01:/var/www/test/${JOB_NAME%/*}/$BRANCH_NAME/
npm run --silent bundlesize
'''
Expand Down
5 changes: 1 addition & 4 deletions config/webpack.config.react.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/no-extraneous-dependencies */
const { resolve } = require('path');
const { ContextReplacementPlugin, DefinePlugin } = require('webpack');
const { ContextReplacementPlugin } = require('webpack');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const reactToolboxVariables = require('./reactToolbox.config');
Expand Down Expand Up @@ -35,9 +35,6 @@ module.exports = {
historyApiFallback: true,
},
plugins: [
new DefinePlugin({
DEFAULT_NEWTORK: JSON.stringify(process.env.TESTNET ? 'testnet' : 'mainnet'),
}),
new StyleLintPlugin({
context: `${resolve(__dirname, '../src')}/`,
files: '**/*.css',
Expand Down
1 change: 1 addition & 0 deletions config/webpack.config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ module.exports = merge(baseConfig, reactConfig, {
],
externals,
});

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"main": "main.js",
"scripts": {
"build": "npm run clean-build && npm run copy-files && npm run build-prod && npm run build-electron",
"build:testnet": "export TESTNET=true && npm run build",
"build:testnet": "npm run build:testnet:pre",
"build:testnet:pre": "cpx \"./app/build/**\" ./app/build-testnet && npm run build:testnet:post",
"build:testnet:post": "replace '\"mainnet\";//defaultNetwork' '\"testnet\";//defaultNetwork' ./app/build-testnet/index.html ",
"dev": "webpack-dev-server --config ./config/webpack.config.dev --env.dev --hot",
"build-prod": "webpack --config ./config/webpack.config.prod --env.prod",
"build-electron": "webpack --config ./config/webpack.config.electron",
Expand Down Expand Up @@ -157,6 +159,7 @@
"react-hot-loader": "=1.3.1",
"react-test-renderer": "=16.0.0",
"redux-mock-store": "1.3.0",
"replace": "0.3.0",
"should": "13.1.0",
"simulant": "0.2.2",
"sinon": "3.3.0",
Expand Down
3 changes: 2 additions & 1 deletion src/components/register/register.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { spy, match } from 'sinon';
import PropTypes from 'prop-types';
import configureMockStore from 'redux-mock-store';

import networks from '../../constants/networks';
import accounts from '../../../test/constants/accounts';
import i18n from '../../i18n';
import Register from './register';
Expand Down Expand Up @@ -61,7 +62,7 @@ describe('Register', () => {
it('should call activePeerSet with network and passphrase', () => {
wrapper.find('MultiStep').props().finalCallback(passphrase);
expect(prop.activePeerSet).to.have.been.calledWith(match({
network: { code: 0, name: 'Mainnet', port: 443, ssl: true },
network: networks.mainnet,
passphrase,
}));
});
Expand Down
3 changes: 1 addition & 2 deletions src/constants/env.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const env = {
production: PRODUCTION,
test: TEST,
development: (!PRODUCTION && !TEST),
defaultNetwork: DEFAULT_NEWTORK,
test: TEST,
};

export default env;
5 changes: 1 addition & 4 deletions src/constants/networks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import env from './env';

const networks = {
mainnet: { // network name translation t('Mainnet');
name: 'Mainnet',
Expand All @@ -22,6 +20,5 @@ const networks = {
},
};

networks.default = networks[env.defaultNetwork];

networks.default = networks[window.localStorage && window.localStorage.getItem('defaultNetwork')] || networks.mainnet;
module.exports = networks;
9 changes: 9 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,15 @@

</style>
<link rel="icon" type="image/png" href="./assets/images/LISK.png" />
<script type="text/javascript">
/* Following comment is a placeholder used by `npm run build:testnet`, do not remove */
var defaultNet = "mainnet";//defaultNetwork
(function(targetNet) {
if (window.localStorage && !window.localStorage.getItem('defaultNetwork')){
window.localStorage.setItem('defaultNetwork', defaultNet);
}
})(defaultNet);
</script>
</head>
<body>
<div id="app"></div>
Expand Down