Skip to content

Commit 5b8c97e

Browse files
authored
Merge pull request #14 from simpletut/codeRefactoring_update_dependencies_projectArchitecture_Testing
Code Refactoring - Update dependencies, Project Architecture And Testing
2 parents eeb347e + 0a00b90 commit 5b8c97e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2348
-2828
lines changed

.babelrc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"presets": [
3-
"env",
4-
"react"
5-
],
6-
"plugins": [
7-
"transform-class-properties"
8-
]
2+
"presets": [
3+
"@babel/preset-env",
4+
"@babel/preset-react"
5+
],
6+
"plugins": [
7+
"@babel/plugin-proposal-class-properties"
8+
]
99
}

.eslintrc.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"browser": true,
5+
"es6": true,
6+
"jest": true
7+
},
8+
"extends": [
9+
"eslint:recommended",
10+
"plugin:react/recommended"
11+
],
12+
"globals": {
13+
"Atomics": "readonly",
14+
"SharedArrayBuffer": "readonly"
15+
},
16+
"parser": "babel-eslint",
17+
"parserOptions": {
18+
"ecmaFeatures": {
19+
"jsx": true
20+
},
21+
"ecmaVersion": 2018,
22+
"sourceType": "module"
23+
},
24+
"plugins": [
25+
"react"
26+
],
27+
"rules": {
28+
"indent": [
29+
"error",
30+
2
31+
],
32+
"react/jsx-filename-extension": [
33+
1,
34+
{
35+
"extensions": [
36+
".js",
37+
".jsx"
38+
]
39+
}
40+
],
41+
"react/prop-types": 0
42+
}
43+
}

Utils/testing.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const findByTestAtrr = (wrapper, attr) => {
2+
return wrapper.find(`[data-test='${attr}']`);
3+
};

assetsTransformer.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
const path = require('path');
3+
4+
module.exports = {
5+
process(src, filename, config, options) {
6+
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
7+
},
8+
};

config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const config = require('config');
2+
3+
module.exports = function () {
4+
if (!config.get('dbString')) {
5+
throw new Error('Environment variable \'dbString\' is not defined');
6+
}
7+
8+
if (!config.get('jwtPrivateKey')) {
9+
throw new Error('Environment variable \'jwt_secret_key\' is not defined');
10+
}
11+
12+
if (!config.get('mailServer.auth.user')) {
13+
throw new Error('Environment variable \'mailServer_user\' is not defined');
14+
}
15+
16+
if (!config.get('mailServer.auth.pass')) {
17+
throw new Error('Environment variable \'mailServer_pass\' is not defined');
18+
}
19+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"dbString": "db_connection_string",
3+
"jwtPrivateKey": "jwt_secret_key",
4+
"mailServer": {
5+
"auth": {
6+
"user": "mailServer_user",
7+
"pass": "mailServer_pass"
8+
}
9+
}
10+
}

config/default.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"dbString": "",
3+
"jwtPrivateKey": "",
4+
"mailServer": {
5+
"host": "-HOST-",
6+
"auth": {
7+
"user": "",
8+
"pass": ""
9+
},
10+
"from": "-FROM-EMAIL-",
11+
"subject": "Password Reset"
12+
}
13+
}

config/test.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"dbString": "mongodb://localhost/playground_tests",
3+
"jwtPrivateKey": "1234",
4+
"mailServer": {
5+
"host": "[email protected]",
6+
"auth": {
7+
"user": "test",
8+
"pass": "123"
9+
},
10+
"from": "Test",
11+
"subject": "Password Reset"
12+
}
13+
}

package.json

Lines changed: 75 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,68 +11,92 @@
1111
"dev:build-server": "webpack --config webpack.server.js --watch",
1212
"dev:build-client": "webpack --config webpack.client.js --watch",
1313
"dev:server": "nodemon --watch build --exec node build/bundle.js",
14+
"lint": "eslint src",
1415
"test": "jest",
16+
"test-watch": "jest --watch",
1517
"test-coverage": "jest --coverage"
1618
},
19+
"jest": {
20+
"moduleNameMapper": {
21+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/assetsTransformer.js",
22+
"\\.(css|less|scss)$": "<rootDir>/assetsTransformer.js"
23+
},
24+
"setupFilesAfterEnv": [
25+
"<rootDir>/setupTests.js"
26+
]
27+
},
28+
"husky": {
29+
"hooks": {
30+
"pre-push": "eslint src && jest"
31+
}
32+
},
1733
"dependencies": {
18-
"babel-polyfill": "6.26.0",
19-
"cookie-parser": "1.4.3",
20-
"apollo-boost": "0.1.12",
21-
"express-fileupload": "0.4.0",
22-
"apollo-cache-inmemory": "1.3.0-beta.6",
23-
"apollo-client": "2.3.7",
24-
"apollo-link-http": "1.5.4",
25-
"apollo-server": "2.0.0",
34+
"config": "3.1.0",
35+
"apollo-boost": "0.3.1",
36+
"apollo-cache-inmemory": "1.5.1",
37+
"apollo-client": "2.5.1",
38+
"apollo-link-http": "1.5.14",
39+
"apollo-server": "2.4.8",
2640
"apollo-server-express": "1.3.6",
27-
"copy-webpack-plugin": "4.5.2",
28-
"express-graphql": "0.6.12",
29-
"graphql": "14.0.2",
30-
"graphql-tools": "4.0.0",
31-
"isomorphic-unfetch": "2.1.1",
32-
"jsonwebtoken": "8.3.0",
33-
"mongoose": "5.2.6",
34-
"nodemailer": "4.6.7",
35-
"nodemailer-express-handlebars": "3.0.0",
36-
"react": "16.4.2",
37-
"react-apollo": "2.1.9",
38-
"react-dom": "16.4.2",
39-
"react-helmet": "5.2.0",
40-
"react-router-config": "1.0.0-beta.4",
41-
"react-router-dom": "4.3.1",
42-
"webpack-node-externals": "1.7.2",
43-
"webpack": "4.17.2",
44-
"webpack-cli": "3.1.0",
45-
"toastr": "2.1.4",
4641
"axios": "0.18.0",
42+
"babel-polyfill": "7.0.0-beta.3",
4743
"bcrypt": "2.0.1",
4844
"classnames": "2.2.6",
49-
"concurrently": "3.6.1",
50-
"cors": "2.8.4",
51-
"css-loader": "1.0.0",
52-
"dotenv": "6.0.0",
45+
"concurrently": "4.1.0",
46+
"cookie-parser": "1.4.4",
47+
"copy-webpack-plugin": "5.0.2",
48+
"cors": "2.8.5",
49+
"css-loader": "2.1.1",
50+
"dotenv": "7.0.0",
5351
"es-cookie": "1.2.0",
54-
"express": "4.16.3",
55-
"extract-loader": "2.0.1",
56-
"file-loader": "1.1.11",
57-
"generate-password": "1.4.0",
58-
"node-sass": "4.9.2",
59-
"sass-loader": "7.1.0",
60-
"nodemon": "1.18.3",
61-
"npm-run-all": "4.1.3",
52+
"express": "4.16.4",
53+
"express-fileupload": "1.1.4",
54+
"express-graphql": "0.8.0",
55+
"extract-loader": "3.1.0",
56+
"file-loader": "3.0.1",
57+
"generate-password": "1.4.1",
58+
"graphql": "14.2.1",
59+
"graphql-tools": "4.0.4",
60+
"isomorphic-unfetch": "3.0.0",
61+
"jsonwebtoken": "8.5.1",
62+
"mongoose": "5.5.2",
63+
"node-sass": "4.11.0",
64+
"nodemailer": "6.1.1",
65+
"nodemailer-express-handlebars": "3.0.0",
66+
"nodemon": "1.18.11",
67+
"npm-run-all": "4.1.5",
68+
"qs-middleware": "^1.0.3",
6269
"randomstring": "1.1.5",
63-
"react-ckeditor-wrapper": "1.1.2"
70+
"react": "16.8.6",
71+
"react-apollo": "2.5.4",
72+
"react-ckeditor-wrapper": "1.1.2",
73+
"react-dom": "16.8.6",
74+
"react-helmet": "5.2.0",
75+
"react-router-config": "5.0.0",
76+
"react-router-dom": "5.0.0",
77+
"sass-loader": "7.1.0",
78+
"toastr": "2.1.4",
79+
"webpack": "4.30.0",
80+
"webpack-cli": "3.3.0",
81+
"webpack-node-externals": "1.7.2"
6482
},
6583
"devDependencies": {
66-
"babel-cli": "6.26.0",
67-
"babel-core": "6.26.3",
68-
"babel-loader": "7.1.5",
69-
"babel-preset-env": "1.7.0",
70-
"babel-preset-es2015": "6.24.1",
71-
"babel-preset-es2017": "6.24.1",
72-
"babel-preset-react": "6.24.1",
73-
"babel-preset-stage-0": "6.24.1",
74-
"enzyme": "3.4.1",
75-
"enzyme-adapter-react-16": "1.2.0",
76-
"jest": "23.5.0"
84+
"@babel/core": "7.4.3",
85+
"@babel/plugin-proposal-class-properties": "7.4.0",
86+
"@babel/preset-env": "7.4.3",
87+
"@babel/preset-react": "7.0.0",
88+
"babel-core": "7.0.0-bridge.0",
89+
"babel-eslint": "10.0.1",
90+
"babel-jest": "24.7.1",
91+
"babel-loader": "8.0.5",
92+
"eslint": "5.16.0",
93+
"eslint-config-airbnb": "17.1.0",
94+
"eslint-plugin-import": "2.17.1",
95+
"eslint-plugin-jsx-a11y": "6.2.1",
96+
"eslint-plugin-react": "7.12.4",
97+
"husky": "1.3.1",
98+
"enzyme": "3.9.0",
99+
"enzyme-adapter-react-16": "1.12.1",
100+
"jest": "24.7.1"
77101
}
78102
}

0 commit comments

Comments
 (0)