Upgrade npm packages and make required modifications

This commit is contained in:
Itay Mizeretz 2018-08-16 17:08:03 +03:00
parent f98a121c51
commit 2a393d6ed5
13 changed files with 11241 additions and 6030 deletions

View File

@ -1,7 +1,4 @@
{ {
"presets": [ "presets": ["es2015", "stage-0", "react"]
"es2015",
"stage-0",
"react"
]
} }

View File

@ -1,43 +0,0 @@
'use strict';
let path = require('path');
let defaultSettings = require('./defaults');
// Additional npm or bower modules to include in builds
// Add all foreign plugins you may need into this array
// @example:
// let npmBase = path.join(__dirname, '../node_modules');
// let additionalPaths = [ path.join(npmBase, 'react-bootstrap') ];
let additionalPaths = [];
module.exports = {
additionalPaths: additionalPaths,
port: defaultSettings.port,
debug: true,
devtool: 'eval',
output: {
path: path.join(__dirname, '/../dist/assets'),
filename: 'app.js',
publicPath: defaultSettings.publicPath
},
devServer: {
contentBase: './src/',
historyApiFallback: true,
hot: true,
port: defaultSettings.port,
publicPath: defaultSettings.publicPath,
noInfo: false
},
resolve: {
extensions: ['', '.js', '.jsx'],
alias: {
actions: `${defaultSettings.srcPath}/actions/`,
components: `${defaultSettings.srcPath}/components/`,
sources: `${defaultSettings.srcPath}/sources/`,
stores: `${defaultSettings.srcPath}/stores/`,
styles: `${defaultSettings.srcPath}/styles/`,
config: `${defaultSettings.srcPath}/config/` + process.env.REACT_WEBPACK_ENV,
'react/lib/ReactMount': 'react-dom/lib/ReactMount'
}
},
module: {}
};

View File

@ -1,68 +0,0 @@
/**
* Function that returns default values.
* Used because Object.assign does a shallow instead of a deep copy.
* Using [].push will add to the base array, so a require will alter
* the base array output.
*/
'use strict';
const path = require('path');
const srcPath = path.join(__dirname, '/../src');
const dfltPort = 8000;
/**
* Get the default modules object for webpack
* @return {Object}
*/
function getDefaultModules() {
return {
preLoaders: [
{
test: /\.(js|jsx)$/,
include: srcPath,
loader: 'eslint-loader'
}
],
loaders: [
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.sass/,
loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded&indentedSyntax'
},
{
test: /\.scss/,
loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded'
},
{
test: /\.less/,
loader: 'style-loader!css-loader!less-loader'
},
{
test: /\.styl/,
loader: 'style-loader!css-loader!stylus-loader'
},
{
test: /\.(png|jpg|gif)$/,
loader: 'url-loader?limit=8192'
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
}
]
};
}
module.exports = {
srcPath: srcPath,
publicPath: '/assets/',
port: dfltPort,
getDefaultModules: getDefaultModules
};

View File

@ -1,47 +0,0 @@
'use strict';
let path = require('path');
let webpack = require('webpack');
let baseConfig = require('./base');
let defaultSettings = require('./defaults');
// Add needed plugins here
let BowerWebpackPlugin = require('bower-webpack-plugin');
let config = Object.assign({}, baseConfig, {
entry: [
'webpack-dev-server/client?http://127.0.0.1:' + defaultSettings.port,
'webpack/hot/only-dev-server',
'./src/index'
],
cache: true,
devtool: 'eval-source-map',
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new BowerWebpackPlugin({
searchResolveModulesDirectories: false
})
],
module: defaultSettings.getDefaultModules()
});
// Add needed loaders to the defaults here
config.module.loaders.push({
test: /\.(js|jsx)$/,
loader: 'react-hot!babel-loader',
include: [].concat(
config.additionalPaths,
[ path.join(__dirname, '/../src') ]
)
});
// proxy to backend server
config.devServer.proxy = {
'/api': {
target: 'https://localhost:5000',
secure: false
}
};
module.exports = config;

View File

@ -1,42 +0,0 @@
'use strict';
let path = require('path');
let webpack = require('webpack');
let baseConfig = require('./base');
let defaultSettings = require('./defaults');
// Add needed plugins here
let BowerWebpackPlugin = require('bower-webpack-plugin');
let config = Object.assign({}, baseConfig, {
entry: path.join(__dirname, '../src/index'),
cache: false,
devtool: 'sourcemap',
plugins: [
new webpack.optimize.DedupePlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new BowerWebpackPlugin({
searchResolveModulesDirectories: false
}),
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.NoErrorsPlugin()
],
module: defaultSettings.getDefaultModules()
});
// Add needed loaders to the defaults here
config.module.loaders.push({
test: /\.(js|jsx)$/,
loader: 'babel',
include: [].concat(
config.additionalPaths,
[ path.join(__dirname, '/../src') ]
)
});
module.exports = config;

View File

@ -1,51 +0,0 @@
'use strict';
let path = require('path');
let srcPath = path.join(__dirname, '/../src/');
let baseConfig = require('./base');
// Add needed plugins here
let BowerWebpackPlugin = require('bower-webpack-plugin');
module.exports = {
devtool: 'eval',
module: {
preLoaders: [
],
loaders: [
{
test: /\.(png|jpg|gif|woff|woff2|css|sass|scss|less|styl)$/,
loader: 'null-loader'
},
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
include: [].concat(
baseConfig.additionalPaths,
[
path.join(__dirname, '/../src'),
path.join(__dirname, '/../test')
]
)
}
]
},
resolve: {
extensions: [ '', '.js', '.jsx' ],
alias: {
actions: srcPath + 'actions/',
helpers: path.join(__dirname, '/../test/helpers'),
components: srcPath + 'components/',
sources: srcPath + 'sources/',
stores: srcPath + 'stores/',
styles: srcPath + 'styles/',
config: srcPath + 'config/' + process.env.REACT_WEBPACK_ENV
}
},
plugins: [
new BowerWebpackPlugin({
searchResolveModulesDirectories: false
})
]
};

File diff suppressed because it is too large Load Diff

View File

@ -2,11 +2,10 @@
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.0",
"description": "Infection Monkey C&C UI", "description": "Infection Monkey C&C UI",
"main": "",
"scripts": { "scripts": {
"clean": "rimraf dist/*", "clean": "rimraf dist/*",
"copy": "copyfiles -f ./src/index.html ./src/favicon.ico ./dist", "copy": "copyfiles -f ./src/index.html ./src/favicon.ico ./dist",
"dist": "npm run copy & webpack --env=dist", "dist": "webpack --mode production",
"lint": "eslint ./src", "lint": "eslint ./src",
"posttest": "npm run lint", "posttest": "npm run lint",
"release:major": "npm version major && npm publish && git push --follow-tags", "release:major": "npm version major && npm publish && git push --follow-tags",
@ -14,7 +13,7 @@
"release:patch": "npm version patch && npm publish && git push --follow-tags", "release:patch": "npm version patch && npm publish && git push --follow-tags",
"serve": "node server.js --env=dev", "serve": "node server.js --env=dev",
"serve:dist": "node server.js --env=dist", "serve:dist": "node server.js --env=dist",
"start": "node server.js --env=dev", "start": "webpack-dev-server --mode development --open --history-api-fallback --port 8000",
"test": "karma start", "test": "karma start",
"test:watch": "karma start --autoWatch=true --singleRun=false" "test:watch": "karma start --autoWatch=true --singleRun=false"
}, },
@ -22,71 +21,76 @@
"keywords": [], "keywords": [],
"author": "Guardicore", "author": "Guardicore",
"devDependencies": { "devDependencies": {
"babel-core": "^6.26.0", "babel-cli": "^6.26.0",
"babel-eslint": "^6.0.0", "babel-core": "^6.26.3",
"babel-loader": "^6.4.1", "babel-eslint": "^8.2.6",
"babel-loader": "^7.1.5",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1", "babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1", "babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.5.0", "babel-preset-stage-0": "^6.5.0",
"bower-webpack-plugin": "^0.1.9", "bower-webpack-plugin": "^0.1.9",
"chai": "^3.2.0", "chai": "^4.1.2",
"copyfiles": "^1.0.0", "copyfiles": "^2.0.0",
"css-loader": "^0.23.1", "css-loader": "^1.0.0",
"eslint": "^3.0.0", "eslint": "^5.3.0",
"eslint-loader": "^1.0.0", "eslint-loader": "^2.1.0",
"eslint-plugin-react": "^6.0.0", "eslint-plugin-react": "^7.11.1",
"file-loader": "^0.9.0", "file-loader": "^1.1.11",
"glob": "^7.0.0", "glob": "^7.0.0",
"karma": "^1.7.1", "html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"karma": "^3.0.0",
"karma-chai": "^0.1.0", "karma-chai": "^0.1.0",
"karma-coverage": "^1.0.0", "karma-coverage": "^1.1.2",
"karma-mocha": "^1.0.0", "karma-mocha": "^1.0.0",
"karma-mocha-reporter": "^2.2.5", "karma-mocha-reporter": "^2.2.5",
"karma-phantomjs-launcher": "^1.0.0", "karma-phantomjs-launcher": "^1.0.0",
"karma-sourcemap-loader": "^0.3.5", "karma-sourcemap-loader": "^0.3.5",
"karma-webpack": "^1.7.0", "karma-webpack": "^3.0.0",
"minimist": "^1.2.0", "minimist": "^1.2.0",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"null-loader": "^0.1.1", "null-loader": "^0.1.1",
"open": "0.0.5", "open": "0.0.5",
"phantomjs-prebuilt": "^2.1.16", "phantomjs-prebuilt": "^2.1.16",
"react-addons-test-utils": "^15.6.2", "react-addons-test-utils": "^15.6.2",
"react-hot-loader": "^1.2.9", "react-hot-loader": "^4.3.4",
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"style-loader": "^0.13.2", "style-loader": "^0.22.1",
"url-loader": "^0.5.9", "url-loader": "^1.1.0",
"webpack": "^1.15.0", "webpack": "^4.16.5",
"webpack-dev-server": "^1.12.0" "webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5"
}, },
"dependencies": { "dependencies": {
"bootstrap": "^3.3.7", "bootstrap": "3.3.7",
"core-js": "^2.5.5", "core-js": "^2.5.7",
"downloadjs": "^1.4.7", "downloadjs": "^1.4.7",
"fetch": "^1.1.0", "fetch": "^1.1.0",
"js-file-download": "^0.4.1", "js-file-download": "^0.4.1",
"json-loader": "^0.5.7", "json-loader": "^0.5.7",
"jwt-decode": "^2.2.0", "jwt-decode": "^2.2.0",
"moment": "^2.22.1", "moment": "^2.22.2",
"normalize.css": "^4.0.0", "normalize.css": "^8.0.0",
"npm": "^5.8.0", "npm": "^6.3.0",
"prop-types": "^15.6.1", "prop-types": "^15.6.2",
"rc-progress": "^2.2.5", "rc-progress": "^2.2.5",
"react": "^15.6.2", "react": "^16.4.2",
"react-bootstrap": "^0.31.5", "react-bootstrap": "^0.32.1",
"react-copy-to-clipboard": "^5.0.1", "react-copy-to-clipboard": "^5.0.1",
"react-data-components": "^1.2.0", "react-data-components": "^1.2.0",
"react-dimensions": "^1.3.0", "react-dimensions": "^1.3.0",
"react-dom": "^15.6.2", "react-dom": "^16.4.2",
"react-fa": "^4.2.0", "react-fa": "^5.0.0",
"react-graph-vis": "^0.1.4", "react-graph-vis": "^1.0.2",
"react-json-tree": "^0.10.9", "react-json-tree": "^0.11.0",
"react-jsonschema-form": "^0.50.1", "react-jsonschema-form": "^1.0.4",
"react-modal-dialog": "^4.0.7", "react-modal-dialog": "^4.0.7",
"react-redux": "^5.0.7", "react-redux": "^5.0.7",
"react-router-dom": "^4.2.2", "react-router-dom": "^4.3.1",
"react-table": "^6.7.4", "react-table": "^6.8.6",
"react-toggle": "^4.0.1", "react-toggle": "^4.0.1",
"redux": "^3.7.2" "redux": "^4.0.0"
} }
} }

View File

@ -14,11 +14,11 @@ import LicensePage from 'components/pages/LicensePage';
import AuthComponent from 'components/AuthComponent'; import AuthComponent from 'components/AuthComponent';
import LoginPageComponent from 'components/pages/LoginPage'; import LoginPageComponent from 'components/pages/LoginPage';
require('normalize.css/normalize.css'); import 'normalize.css/normalize.css';
require('react-data-components/css/table-twbs.css'); import 'react-data-components/css/table-twbs.css';
require('styles/App.css'); import 'styles/App.css';
require('react-toggle/style.css'); import 'react-toggle/style.css';
require('react-table/react-table.css'); import 'react-table/react-table.css';
let logoImage = require('../images/monkey-icon.svg'); let logoImage = require('../images/monkey-icon.svg');
let infectionMonkeyImage = require('../images/infection-monkey.svg'); let infectionMonkeyImage = require('../images/infection-monkey.svg');

View File

@ -10,9 +10,10 @@ let getGroupsOptions = () => {
{ {
shape: 'image', shape: 'image',
size: 50, size: 50,
image: require('../../images/nodes/' + groupName + '.png') image: '../' + require('../../images/nodes/' + groupName + '.png')
}; };
} }
return groupOptions; return groupOptions;
}; };

View File

@ -8,9 +8,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
</head> </head>
<body> <body>
<div id="app">Loading...</div> <div id="app"></div>
<script>__REACT_DEVTOOLS_GLOBAL_HOOK__ = parent.__REACT_DEVTOOLS_GLOBAL_HOOK__</script>
<script type="text/javascript" src="/assets/app.js"></script>
</body> </body>
</html> </html>

View File

@ -1,7 +1,7 @@
import StandardConfig from './StandardConfig'; import StandardConfig from './StandardConfig';
import AwsConfig from './AwsConfig'; import AwsConfig from './AwsConfig';
const SERVER_CONFIG_JSON = require('json-loader!../../../server_config.json'); const SERVER_CONFIG_JSON = require('../../../server_config.json');
const CONFIG_DICT = const CONFIG_DICT =
{ {

View File

@ -1,32 +1,70 @@
'use strict';
const path = require('path'); const path = require('path');
const args = require('minimist')(process.argv.slice(2)); const HtmlWebPackPlugin = require("html-webpack-plugin");
// List of allowed environments module.exports = {
const allowedEnvs = ['dev', 'dist', 'test']; module: {
rules: [
// Set the correct environment {
let env; test: /\.js$/,
if (args._.length > 0 && args._.indexOf('start') !== -1) { exclude: /node_modules/,
env = 'test'; use: {
} else if (args.env) { loader: "babel-loader"
env = args.env; }
} else { },
env = 'dev'; {
} test: /\.css$/,
process.env.REACT_WEBPACK_ENV = env; use: [
'style-loader',
/** 'css-loader'
* Build the webpack configuration ]
* @param {String} wantedEnv The wanted environment },
* @return {Object} Webpack config {
*/ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
function buildConfig(wantedEnv) { use: {
let isValid = wantedEnv && wantedEnv.length > 0 && allowedEnvs.indexOf(wantedEnv) !== -1; loader: 'file-loader'
let validEnv = isValid ? wantedEnv : 'dev'; }
let config = require(path.join(__dirname, 'cfg/' + validEnv)); },
return config; {
} test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: {
module.exports = buildConfig(env); loader: 'url-loader?limit=10000&mimetype=application/font-woff'
}
},
{
test: /\.(png|jpg|gif)$/,
use: {
loader: 'url-loader?limit=8192'
}
},
{
test: /\.html$/,
use: [
{
loader: "html-loader"
}
]
}
]
},
plugins: [
new HtmlWebPackPlugin({
template: "./src/index.html",
filename: "./index.html"
})
],
resolve: {
extensions: ['.js', '.jsx', '.css'],
modules: [
'node_modules',
path.resolve(__dirname, 'src/')
]
},
devServer: {
proxy: {
'/api': {
target: 'https://localhost:5000',
secure: false
}
}
}
};