Update build to pull from external repos

This commit is contained in:
Jaco Greeff 2017-08-01 14:41:13 +02:00
parent c509733a30
commit f8bf4a1522
10 changed files with 607 additions and 828 deletions

711
js/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,16 +27,16 @@
],
"scripts": {
"build": "npm run build:lib && npm run build:app",
"build:app": "parallel-webpack -p=2 --config webpack/app",
"build:lib": "parallel-webpack -p=2 --config webpack/libraries",
"build:app": "webpack --progress --config webpack/app",
"build:lib": "webpack --progress --config webpack/libraries",
"build:markdown": "babel-node ./scripts/build-rpc-markdown.js",
"build:json": "babel-node ./scripts/build-rpc-json.js",
"build:embed": "EMBED=1 node webpack/embed",
"build:i18n": "npm run clean && npm run build && babel-node ./scripts/build-i18n.js",
"ci:build": "npm run ci:build:lib && npm run ci:build:app && npm run ci:build:embed",
"ci:build:app": "NODE_ENV=production parallel-webpack -p=2 --config webpack/app",
"ci:build:lib": "NODE_ENV=production parallel-webpack -p=2 --config webpack/libraries",
"ci:build:npm": "NODE_ENV=production parallel-webpack -p=2 --config webpack/npm",
"ci:build:app": "NODE_ENV=production webpack --progress --config webpack/app",
"ci:build:lib": "NODE_ENV=production webpack --progress --config webpack/libraries",
"ci:build:npm": "NODE_ENV=production webpack --progress --config webpack/npm",
"ci:build:jsonrpc": "babel-node ./scripts/build-rpc-json.js --output .npmjs/jsonrpc",
"ci:build:embed": "NODE_ENV=production EMBED=1 node webpack/embed",
"clean": "rm -rf ./.build ./.coverage ./.happypack ./build ./node_modules/.cache",
@ -50,7 +50,7 @@
"lint:js:cached": "eslint --cache --ignore-path .gitignore ./src/",
"lint:js:fix": "eslint --fix --ignore-path .gitignore ./src/",
"start": "npm run clean && npm install && npm run build:lib && npm run start:app",
"start:app": "webpack-dev-server --progress --config webpack/app",
"start:app": "node webpack/dev.server",
"test": "NODE_ENV=test mocha --compilers ejs:ejsify 'src/**/*.spec.js' 'packages/**/*.spec.js'",
"test:coverage": "NODE_ENV=test istanbul cover _mocha -- --compilers ejs:ejsify 'src/**/*.spec.js' 'packages/**/*.spec.js'",
"test:e2e": "NODE_ENV=test mocha 'src/**/*.e2e.js' 'packages/**/*.e2e.js'",
@ -122,7 +122,6 @@
"mock-local-storage": "1.0.2",
"mock-socket": "6.0.4",
"nock": "9.0.7",
"parallel-webpack": "2.1.0",
"postcss-import": "10.0.0",
"postcss-loader": "2.0.6",
"postcss-nested": "2.1.0",
@ -144,7 +143,7 @@
"to-source": "2.0.3",
"uglify-js": "2.8.22",
"url-loader": "0.5.7",
"webpack": "2.4.1",
"webpack": "3.3.0",
"webpack-bundle-size-analyzer": "2.5.0",
"webpack-dev-middleware": "1.10.1",
"webpack-dev-server": "2.6.1",
@ -155,13 +154,9 @@
},
"dependencies": {
"@parity/api": "paritytech/js-api#ade4a6750292a2918676039ea53eea20c4c728bc",
"@parity/dapps": "file:packages/dapps",
"@parity/etherscan": "paritytech/js-etherscan#efe859ac7d2a8a3cc05e01c689b7fa58f47f8b87",
"@parity/ledger": "file:packages/ledger",
"@parity/shapeshift": "file:packages/shapeshift",
"@parity/shared": "paritytech/js-shared#a83c71946d30d5b3bf976860a676add29c48ee24",
"@parity/dapp-accounts": "paritytech/dapp-accounts#b4b7113ba8ea25d11dfc0ed6d6c93b85c8a7fac8",
"@parity/shared": "paritytech/js-shared#438912f286ca09209e53fda5808205fca2c62940",
"@parity/ui": "paritytech/js-ui#037782bd16e8abf1c169143aa61749a44b94489b",
"@parity/wordlist": "1.0.1",
"es6-error": "4.0.0",
"es6-promise": "4.0.5",
"flat": "2.0.1",
@ -170,14 +165,13 @@
"format-number": "2.0.1",
"isomorphic-fetch": "2.2.1",
"lodash": "4.17.2",
"loglevel": "1.4.1",
"moment": "2.17.0",
"promise-worker": "1.1.1",
"prop-types": "15.5.10",
"react": "15.6.1",
"react-dom": "15.6.1",
"react-inspector": "paritytech/react-inspector",
"react-intl": "2.1.5",
"react-markdown": "2.5.0",
"react-router": "3.0.0",
"react-router-redux": "4.0.7",
"react-tap-event-plugin": "2.0.1",
@ -188,12 +182,9 @@
"redux-thunk": "2.1.0",
"store": "1.3.20",
"sw-toolbox": "^3.6.0",
"u2f-api": "0.0.9",
"u2f-api-polyfill": "0.4.3",
"useragent.js": "0.5.6",
"utf8": "2.1.2",
"web3": "0.17.0-beta",
"whatwg-fetch": "2.0.1",
"worker-loader": "^0.8.0"
"whatwg-fetch": "2.0.1"
}
}

View File

@ -20,6 +20,7 @@ import { FormattedMessage } from 'react-intl';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import UpgradeStore from '@parity/shared/mobx/upgradeParity';
import { Errors } from '@parity/ui';
import Connection from '../Connection';
@ -31,7 +32,6 @@ import Requests from '../Requests';
import Snackbar from '../Snackbar';
import Status from '../Status';
import UpgradeParity from '../UpgradeParity';
import UpgradeStore from '../UpgradeParity/store';
import SyncWarning, { showSyncWarning } from '../SyncWarning';
import Store from './store';

View File

@ -102,12 +102,14 @@ export default class Dapp extends Component {
case 'local':
src = `${dappsUrl}/${app.id}/`;
break;
case 'network':
src = `${dappsUrl}/${app.contentHash}/`;
break;
default:
let dapphost = process.env.DAPPS_URL || (
process.env.NODE_ENV === 'production' && !app.secure
process.env.NODE_ENV === 'production'
? `${dappsUrl}/ui`
: ''
);
@ -116,7 +118,11 @@ export default class Dapp extends Component {
dapphost = '';
}
src = `${dapphost}/${app.url}.html`;
const appId = this.context.api.util.isHex(app.id)
? app.id
: this.context.api.sha3(app.url);
src = `${dapphost}/dapps/${appId}/index.html`;
break;
}

View File

@ -27,11 +27,9 @@ import web3extensions from './web3.extensions';
function initProvider () {
let [, appId] = window.location.pathname.split('/');
if (appId.indexOf('.html') !== -1) {
appId = appId.replace('.html', '');
}
console.log('window.location.pathname', window.location.pathname, appId);
if (appId.substr(0, 2) !== '0x') {
if (!Api.util.isHex(appId)) {
appId = Api.util.sha3(appId);
}

View File

@ -15,7 +15,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
const Api = require('@parity/api');
const path = require('path');
const flatten = require('lodash.flatten');
// const ReactIntlAggregatePlugin = require('react-intl-aggregate-webpack-plugin');
const WebpackErrorNotificationPlugin = require('webpack-error-notification');
const CopyWebpackPlugin = require('copy-webpack-plugin');
@ -27,10 +29,11 @@ const rulesParity = require('./rules/parity');
const Shared = require('./shared');
const DAPPS_BUILTIN = require('@parity/shared/config/dappsBuiltin.json');
const DAPPS_VIEWS = require('@parity/shared/config/dappsViews.json').map((dapp) => {
dapp.commons = true;
return dapp;
});
const DAPPS_VIEWS = require('@parity/shared/config/dappsViews.json');
const DAPPS_ALL = []
.concat(DAPPS_BUILTIN, DAPPS_VIEWS)
.filter((dapp) => !dapp.skipBuild)
.filter((dapp) => dapp.package);
const FAVICON = path.resolve(__dirname, '../node_modules/@parity/shared/assets/images/parity-logo-black-no-text.png');
@ -42,24 +45,15 @@ const isProd = ENV === 'production';
const isEmbed = EMBED === '1' || EMBED === 'true';
const entry = isEmbed
? {
embed: './embed.js'
}
: Object.assign({}, Shared.dappsEntry, {
index: './index.js'
});
? { embed: './embed.js' }
: { index: './index.js' };
module.exports = Object.keys(entry).map((entryName) => {
const entrySrc = entry[entryName];
return {
module.exports = {
cache: !isProd,
devtool: isProd ? '#hidden-source-map' : '#source-map',
context: path.join(__dirname, '../src'),
entry: {
[entryName]: entrySrc
},
entry,
output: {
path: path.join(__dirname, '../', DEST),
filename: '[name].js'
@ -176,16 +170,7 @@ module.exports = Object.keys(entry).map((entryName) => {
resolve: {
alias: {
'~': path.resolve(__dirname, '..'),
'@parity/abi': path.resolve(__dirname, '../node_modules/@parity/abi'),
'@parity/api': path.resolve(__dirname, '../node_modules/@parity/api'),
'@parity/etherscan': path.resolve(__dirname, '../node_modules/@parity/etherscan'),
'@parity/jsonrpc': path.resolve(__dirname, '../node_modules/@parity/jsonrpc'),
'@parity/parity.js': path.resolve(__dirname, '../node_modules/@parity/parity.js'),
'@parity/shared': path.resolve(__dirname, '../node_modules/@parity/shared'),
'@parity/ui': path.resolve(__dirname, '../node_modules/@parity/ui'),
'@parity/wordlist': path.resolve(__dirname, '../node_modules/@parity/wordlist'),
'@parity': path.resolve(__dirname, '../packages')
'~': path.resolve(__dirname, '..')
},
modules: [
path.join(__dirname, '../node_modules')
@ -199,20 +184,6 @@ module.exports = Object.keys(entry).map((entryName) => {
},
plugins: (function () {
const DappsHTMLInjection = []
.concat(DAPPS_BUILTIN, DAPPS_VIEWS)
.filter((dapp) => !dapp.skipBuild)
.map((dapp) => {
return new HtmlWebpackPlugin({
title: dapp.name,
filename: dapp.url + '.html',
template: '../packages/dapps/index.ejs',
favicon: FAVICON,
secure: dapp.secure,
chunks: [ dapp.url ]
});
});
let plugins = Shared.getPlugins().concat(
new WebpackErrorNotificationPlugin()
);
@ -233,12 +204,33 @@ module.exports = Object.keys(entry).map((entryName) => {
entry: path.join(__dirname, '../src/serviceWorker.js')
}),
DappsHTMLInjection,
new CopyWebpackPlugin(
flatten([
{
from: './error_pages.css',
to: 'styles.css'
},
flatten(
DAPPS_ALL.map((dapp) => {
const destination = Api.util.isHex(dapp.id)
? dapp.id
: Api.util.sha3(dapp.url);
new CopyWebpackPlugin([
{ from: './error_pages.css', to: 'styles.css' },
{ from: '../packages/dapps/static' }
], {})
return [
{
from: `../node_modules/${dapp.package}/dist`,
to: `dapps/${destination}/dist/`
},
{
from: `../node_modules/${dapp.package}/index.html`,
to: `dapps/${destination}/`
}
];
})
)
]),
{}
)
);
}
@ -254,19 +246,6 @@ module.exports = Object.keys(entry).map((entryName) => {
);
}
// if (!isAnalize && !isProd) {
// const DEST_I18N = path.join(__dirname, '..', DEST, 'i18n');
//
// plugins.push(
// new ReactIntlAggregatePlugin({
// messagesPattern: DEST_I18N + '/i18n/**/*.json',
// aggregateOutputDir: DEST_I18N + '/i18n/',
// aggregateFilename: 'en'
// })
// );
// }
return plugins;
}())
};
});

View File

@ -0,0 +1,35 @@
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
// test only
/**
* Run `DAPPS_URL="/" PARITY_URL="127.0.0.1:8546" NODE_ENV="production" npm run build`
* to build the project ; use this server to test that the minifed
* version is working (this is a simple proxy server)
*/
var express = require('express');
var Shared = require('./shared');
var app = express();
Shared.addProxies(app);
app.use(express.static('.build'));
var server = app.listen(process.env.PORT || 3000, function () {
console.log('Listening on port', server.address().port);
});

97
js/webpack/dev.server.js Normal file
View File

@ -0,0 +1,97 @@
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
const webpack = require('webpack');
const WebpackStats = require('webpack/lib/Stats');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const http = require('http');
const express = require('express');
const ProgressBar = require('progress');
const webpackConfig = require('./app');
const Shared = require('./shared');
let progressBar = { update: () => {} };
/**
* Add webpack hot middleware to each entry in the config
* and HMR to the plugins
*/
(function updateWebpackConfig () {
webpackConfig.performance = { hints: false };
Object.keys(webpackConfig.entry).forEach((key) => {
const entry = webpackConfig.entry[key];
webpackConfig.entry[key] = [].concat(
'react-hot-loader/patch',
'webpack-hot-middleware/client?reload=true',
entry
);
});
webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
webpackConfig.plugins.push(new webpack.NamedModulesPlugin());
webpackConfig.plugins.push(new webpack.NoEmitOnErrorsPlugin());
webpackConfig.plugins.push(new webpack.ProgressPlugin(
(percentage) => progressBar.update(percentage)
));
})();
const app = express();
const compiler = webpack(webpackConfig);
app.use(webpackHotMiddleware(compiler, {
log: console.log
}));
app.use(webpackDevMiddleware(compiler, {
noInfo: true,
quiet: false,
progress: true,
publicPath: webpackConfig.output.publicPath,
stats: {
colors: true
},
reporter: function (data) {
// @see https://github.com/webpack/webpack/blob/324d309107f00cfc38ec727521563d309339b2ec/lib/Stats.js#L790
// Accepted values: none, errors-only, minimal, normal, verbose
const options = WebpackStats.presetToOptions('minimal');
options.timings = true;
const output = data.stats.toString(options);
process.stdout.write('\n');
process.stdout.write(output);
process.stdout.write('\n\n');
}
}));
// Add the dev proxies in the express App
Shared.addProxies(app);
app.use(express.static(webpackConfig.output.path));
const server = http.createServer(app);
server.listen(process.env.PORT || 3000, function () {
console.log('Listening on port', server.address().port);
progressBar = new ProgressBar('[:bar] :percent :etas', { total: 50 });
});

View File

@ -24,11 +24,12 @@ const Shared = require('./shared');
const DEST = process.env.BUILD_DEST || '.build';
module.exports = ['inject', 'parity', 'web3'].map((entryName) => {
return {
module.exports = {
context: path.join(__dirname, '../src'),
entry: {
[entryName]: ['./inject.js']
inject: ['./inject.js'],
parity: ['./inject.js'],
web3: ['./inject.js']
},
output: {
path: path.join(__dirname, '../', DEST),
@ -39,15 +40,7 @@ module.exports = ['inject', 'parity', 'web3'].map((entryName) => {
resolve: {
alias: {
'~': path.resolve(__dirname, '..'),
'@parity/abi': path.resolve(__dirname, '../node_modules/@parity/abi'),
'@parity/api': path.resolve(__dirname, '../node_modules/@parity/api'),
'@parity/etherscan': path.resolve(__dirname, '../node_modules/@parity/etherscan'),
'@parity/jsonrpc': path.resolve(__dirname, '../node_modules/@parity/jsonrpc'),
'@parity/shared': path.resolve(__dirname, '../node_modules/@parity/shared'),
'@parity/ui': path.resolve(__dirname, '../node_modules/@parity/ui'),
'@parity/wordlist': path.resolve(__dirname, '../node_modules/@parity/wordlist'),
'@parity': path.resolve(__dirname, '../packages')
'~': path.resolve(__dirname, '..')
}
},
@ -81,4 +74,3 @@ module.exports = ['inject', 'parity', 'web3'].map((entryName) => {
},
plugins: Shared.getPlugins()
};
});

View File

@ -115,23 +115,6 @@ function getPlugins (_isProd = isProd) {
return plugins;
}
function getDappsEntry () {
const builtins = require('@parity/shared/config/dappsBuiltin.json');
const views = require('@parity/shared/config/dappsViews.json');
return Object.assign(
[]
.concat(
builtins.filter((dapp) => !dapp.skipBuild),
views
)
.reduce((_entry, dapp) => {
_entry[dapp.url] = '../packages/dapp-' + dapp.url + '/index.js';
return _entry;
}, {})
);
}
function addProxies (app) {
const proxy = require('http-proxy-middleware');
@ -166,6 +149,5 @@ function addProxies (app) {
module.exports = {
getBabelrc: getBabelrc,
getPlugins: getPlugins,
dappsEntry: getDappsEntry(),
addProxies: addProxies
};