diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 522738b9d59f106c870408fe754311b04917e5e3..0087d44e79d114cef3e2e3ebb0f62c36e22fd3b7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,6 +50,8 @@ test: push:qa: image: docker:latest stage: push + variables: + NODE_ENV: test only: - develop script: @@ -72,6 +74,8 @@ push:demo: image: docker:latest stage: push when: manual + variables: + NODE_ENV: production script: # Setup - export AWS_REGION="eu-west-1" @@ -93,6 +97,8 @@ push:staging: stage: push only: - master + variables: + NODE_ENV: production script: # Setup - export AWS_REGION="eu-west-1" @@ -133,6 +139,7 @@ deploy:qa: only: - develop variables: + NODE_ENV: test PACKAGE_NAME: xpub-faraday IMAGE_TAG: latest environment: @@ -151,6 +158,7 @@ deploy:staging: variables: PACKAGE_NAME: xpub-faraday IMAGE_TAG: staging + NODE_ENV: production environment: name: staging url: http://faraday.hindawi.com diff --git a/Dockerfile b/Dockerfile index d00693285f68ab5f0c4f5e4d97d59e0d9fd7ae09..c87eba2f96e95954571a418f79050335311a813a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,7 @@ RUN [ "yarn", "cache", "clean"] RUN [ "rm", "-rf", "/npm-packages-offline-cache"] ENV NODE_ENV "production" + WORKDIR ${HOME}/packages/xpub-faraday RUN [ "npx", "pubsweet", "build"] diff --git a/packages/component-faraday-ui/src/Textarea.js b/packages/component-faraday-ui/src/Textarea.js index 2d0a372f55f58e466abd92efd0b9c9e2d3eb2907..bd385619a2ba0f5c56ec6cd321427f0c11d8cf34 100644 --- a/packages/component-faraday-ui/src/Textarea.js +++ b/packages/component-faraday-ui/src/Textarea.js @@ -16,6 +16,7 @@ const Textarea = styled.textarea` font-family: ${th('fontWriting')}; padding: ${th('gridUnit')}; width: 100%; + resize: vertical; ${minHeight}; ${marginHelper}; diff --git a/packages/xpub-faraday/app/index-production.html b/packages/xpub-faraday/app/index-production.html index e76102f559bc3625df0428c4c1ce6014bd2e5554..c8251fcc6cf40c4ef36c18af0144f75ba3461799 100644 --- a/packages/xpub-faraday/app/index-production.html +++ b/packages/xpub-faraday/app/index-production.html @@ -5,6 +5,7 @@ <!-- Build time: <%= htmlWebpackPlugin.options.buildTime %> --> + <%= htmlWebpackPlugin.options.gaHead %> <meta charset=utf-8> <title> <%= htmlWebpackPlugin.options.title %> @@ -13,6 +14,7 @@ </head> <body> + <%= htmlWebpackPlugin.options.gaBody %> <div id="root"></div> </body> diff --git a/packages/xpub-faraday/app/index.html b/packages/xpub-faraday/app/index.html index 95cf2616b10504c8878f03681e40c99e410c3a0f..66d18d09d7310ff4375c267d99344e9b2e365547 100644 --- a/packages/xpub-faraday/app/index.html +++ b/packages/xpub-faraday/app/index.html @@ -2,7 +2,7 @@ <html> <head> <meta charset="utf-8"> - <title> Faraday </title> + <title> Hindawi Review </title> <link xmlns="http://www.w3.org/1999/xhtml" rel="shortcut icon" href="/assets/favicon.ico" type="image/x-icon" /> </head> <body style="margin: 0;"> diff --git a/packages/xpub-faraday/config/default.js b/packages/xpub-faraday/config/default.js index 66a21abd7bac73846624ccc7f898e6a1500574ec..768e933842c849abb6cbe6812a2591fe402afbf3 100644 --- a/packages/xpub-faraday/config/default.js +++ b/packages/xpub-faraday/config/default.js @@ -46,7 +46,7 @@ module.exports = { API_ENDPOINT: '/api', baseUrl: process.env.CLIENT_BASE_URL || 'http://localhost:3000', 'login-redirect': '/', - 'redux-log': true, // process.env.NODE_ENV !== 'production', + 'redux-log': process.env.NODE_ENV !== 'production', theme: process.env.PUBSWEET_THEME, }, orcid: { diff --git a/packages/xpub-faraday/config/upload-validations.js b/packages/xpub-faraday/config/upload-validations.js index 79f682e7416efb192c78574e39b13600fd4d473d..b96273bb102149b4e48d223a601698447e2b9b4d 100644 --- a/packages/xpub-faraday/config/upload-validations.js +++ b/packages/xpub-faraday/config/upload-validations.js @@ -6,22 +6,26 @@ module.exports = { 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/pdf', 'application/msword', + 'application/vnd.oasis.opendocument.tex', + 'application/rdf+xml', ]) - .error(new Error('Only Word documents and PDFs are allowed')), + .error(new Error('Document type is not allowed.')), supplementary: Joi.any(), coverLetter: Joi.any() .valid([ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/pdf', 'application/msword', + 'application/vnd.oasis.opendocument.tex', + 'application/rdf+xml', ]) - .error(new Error('Only Word documents and PDFs are allowed')), + .error(new Error('Document type is not allowed.')), responseToReviewers: Joi.any() .valid([ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/pdf', 'application/msword', ]) - .error(new Error('Only Word documents and PDFs are allowed')), + .error(new Error('Document type is not allowed.')), review: Joi.any(), } diff --git a/packages/xpub-faraday/package.json b/packages/xpub-faraday/package.json index b0117338f1b0e3fa0f97cedc84dd99688b07a8c1..62a5b6e75d408ff3e8e47b45b3e80f4aebb5c2c5 100644 --- a/packages/xpub-faraday/package.json +++ b/packages/xpub-faraday/package.json @@ -8,11 +8,11 @@ "url": "https://gitlab.coko.foundation/xpub/xpub-faraday" }, "dependencies": { - "@pubsweet/ui": "^8.6.0", - "@pubsweet/styleguide": "3.1.4", - "@pubsweet/ui-toolkit": "latest", "@pubsweet/component-aws-s3": "^1.2.0", "@pubsweet/component-send-email": "0.2.4", + "@pubsweet/styleguide": "3.1.4", + "@pubsweet/ui": "^8.6.0", + "@pubsweet/ui-toolkit": "latest", "aws-sdk": "^2.197.0", "babel-core": "^6.26.0", "config": "^1.26.2", @@ -28,9 +28,9 @@ "prop-types": "^15.5.10", "pubsweet": "^2.2.1", "pubsweet-client": "^4.0.4", - "pubsweet-server": "2.0.3", "pubsweet-component-login": "^1.1.0", "pubsweet-component-signup": "^1.0.0", + "pubsweet-server": "2.0.3", "react": "^16.4.2", "react-dnd": "^2.5.4", "react-dnd-html5-backend": "^2.5.4", @@ -62,8 +62,8 @@ "extract-text-webpack-plugin": "^3.0.0", "file-loader": "^1.1.5", "html-webpack-plugin": "^2.24.0", - "joi-browser": "^10.0.6", "jest": "^22.1.1", + "joi-browser": "^10.0.6", "react-hot-loader": "^3.1.1", "string-replace-loader": "^1.3.0", "style-loader": "^0.19.0", diff --git a/packages/xpub-faraday/webpack/rules.test.js b/packages/xpub-faraday/webpack/rules.test.js new file mode 100644 index 0000000000000000000000000000000000000000..0fe8d5b7e26111759ee1c581d90bfa22dd195de7 --- /dev/null +++ b/packages/xpub-faraday/webpack/rules.test.js @@ -0,0 +1,60 @@ +const ExtractTextPlugin = require('extract-text-webpack-plugin') +const include = require('./babel-includes') +const stringReplaceRule = require('./string-replace') + +module.exports = [ + stringReplaceRule, + { + oneOf: [ + // ES6 JS + { + test: /\.jsx?$/, + include, + loader: 'babel-loader', + options: { + presets: [ + [require('babel-preset-env'), { modules: false }], + require('babel-preset-react'), + require('babel-preset-stage-2'), + ], + }, + }, + + // CSS Modules + { + test: /\.local\.css$/, + include, + use: ExtractTextPlugin.extract({ + fallback: 'style-loader', + use: [ + { + loader: 'css-loader', + options: { + modules: true, + localIdentName: '[name]_[local]-[hash:base64:8]', + }, + }, + ], + }), + }, + + // global CSS + { + test: /\.css$/, + use: ExtractTextPlugin.extract({ + fallback: 'style-loader', + use: ['css-loader'], + }), + }, + + // files + { + exclude: [/\.jsx?$/, /\.html$/, /\.json$/], + loader: 'file-loader', + options: { + name: 'static/media/[name].[hash:8].[ext]', + }, + }, + ], + }, +] diff --git a/packages/xpub-faraday/webpack/webpack.production.config.js b/packages/xpub-faraday/webpack/webpack.production.config.js index 60437cd2dc41e3dd5266ac592e484366fc42cf6c..0d39669864461e3188c03bf231076559a84d6ab4 100644 --- a/packages/xpub-faraday/webpack/webpack.production.config.js +++ b/packages/xpub-faraday/webpack/webpack.production.config.js @@ -36,10 +36,27 @@ module.exports = [ root: path.join(__dirname, '..', '_build'), }), new HtmlWebpackPlugin({ - title: 'Faraday', + title: 'Hindawi Review', buildTime: new Date().toString(), template: '../app/index-production.html', inject: 'body', + gaHead: `<!-- Google Tag Manager --> + <script>(function (w, d, s, l, i) { + w[l] = w[l] || []; w[l].push({ + 'gtm.start': + new Date().getTime(), event: 'gtm.js' + }); var f = d.getElementsByTagName(s)[0], + j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src = + 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f); + })(window, document, 'script', 'dataLayer', '${ + process.env.GA_KEY + }');</script> + <!-- End Google Tag Manager -->`, + gaBody: ` <!-- Google Tag Manager (noscript) --> + <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=${ + process.env.GA_KEY + }" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> + <!-- End Google Tag Manager (noscript) -->`, }), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), diff --git a/packages/xpub-faraday/webpack/webpack.test.config.js b/packages/xpub-faraday/webpack/webpack.test.config.js index 21f67e92541322d368112f1cf962ca835fc2b2fa..6153720114f39d34bccf2ec92bd511d307b478d7 100644 --- a/packages/xpub-faraday/webpack/webpack.test.config.js +++ b/packages/xpub-faraday/webpack/webpack.test.config.js @@ -4,7 +4,11 @@ process.env.BABEL_ENV = 'test' const config = require('config') const path = require('path') const webpack = require('webpack') +const CleanWebpackPlugin = require('clean-webpack-plugin') +const ExtractTextPlugin = require('extract-text-webpack-plugin') +const HtmlWebpackPlugin = require('html-webpack-plugin') const CopyWebpackPlugin = require('copy-webpack-plugin') +const UglifyJSPlugin = require('uglifyjs-webpack-plugin') const rules = require('./rules.production') const resolve = require('./common-resolve') @@ -15,20 +19,28 @@ module.exports = [ target: 'web', context: path.join(__dirname, '..', 'app'), entry: { - app: ['react-hot-loader/patch', 'webpack-hot-middleware/client', './app'], + app: ['./app'], }, output: { path: path.join(__dirname, '..', '_build', 'assets'), - filename: '[name].js', + filename: '[name].[hash].js', publicPath: '/assets/', }, module: { rules, }, resolve, + devtool: 'eval', plugins: [ - new webpack.HotModuleReplacementPlugin(), - new webpack.NoEmitOnErrorsPlugin(), + new CleanWebpackPlugin(['assets'], { + root: path.join(__dirname, '..', '_build'), + }), + new HtmlWebpackPlugin({ + title: 'Hindawi Review', + buildTime: new Date().toString(), + template: '../app/index-production.html', + inject: 'body', + }), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), }), @@ -36,9 +48,13 @@ module.exports = [ [config.authsome.mode]: config.authsome.mode, [config.validations]: config.validations, }), + new ExtractTextPlugin('styles/main.css'), new CopyWebpackPlugin([{ from: '../static' }]), new webpack.optimize.AggressiveMergingPlugin(), new webpack.optimize.OccurrenceOrderPlugin(), + new UglifyJSPlugin({ + sourceMap: true, + }), ], node: { fs: 'empty',