Skip to content

Commit 091e3eb

Browse files
Merge pull request #2182 from RedisInsight/build/feature/RI-4567_Refactoring_main_dev
2 parents 49cb3f4 + dba3ecf commit 091e3eb

Some content is hidden

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

56 files changed

+1089
-881
lines changed

.eslintrc.js

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,63 @@
11
module.exports = {
22
root: true,
3+
env: {
4+
node: true,
5+
},
36
extends: ['airbnb-typescript'],
47
plugins: ['@typescript-eslint'],
58
parser: '@typescript-eslint/parser',
69
rules: {
7-
'max-len': ['warn', 120],
10+
semi: ['error', 'never'],
11+
quotes: [2, 'single', { avoidEscape: true }],
12+
'max-len': ['error', { ignoreComments: true, ignoreStrings: true, ignoreRegExpLiterals: true, code: 120 }],
813
'class-methods-use-this': 'off',
914
'import/no-extraneous-dependencies': 'off', // temporary disabled
15+
'@typescript-eslint/semi': ['error', 'never'],
16+
'object-curly-newline': 'off',
17+
'import/prefer-default-export': 'off',
18+
'@typescript-eslint/comma-dangle': 'off',
19+
'implicit-arrow-linebreak': 'off',
20+
'import/order': [
21+
1,
22+
{
23+
groups: [
24+
'external',
25+
'builtin',
26+
'internal',
27+
'sibling',
28+
'parent',
29+
'index',
30+
],
31+
pathGroups: [
32+
{
33+
pattern: 'desktopSrc/**',
34+
group: 'internal',
35+
position: 'after'
36+
},
37+
{
38+
pattern: 'uiSrc/**',
39+
group: 'internal',
40+
position: 'after'
41+
},
42+
{
43+
pattern: 'apiSrc/**',
44+
group: 'internal',
45+
position: 'after'
46+
},
47+
],
48+
warnOnUnassignedImports: true,
49+
pathGroupsExcludedImportTypes: ['builtin']
50+
},
51+
],
1052
},
1153
parserOptions: {
1254
project: './tsconfig.json',
55+
ecmaVersion: 2020,
56+
sourceType: 'module',
57+
createDefaultProgram: true,
1358
},
1459
ignorePatterns: [
1560
'redisinsight/ui',
61+
'redisinsight/api',
1662
],
17-
};
63+
}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ lerna-debug.log*
3636
.vscode
3737

3838
# App packaged
39-
redisinsight/electron/preload.js
4039
release
4140
main.prod.js
4241
main.prod.js.map

configs/webpack.config.base.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ const configuration: webpack.Configuration = {
3535
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx', '.scss'],
3636
modules: [webpackPaths.apiPath, 'node_modules'],
3737
plugins: [new TsconfigPathsPlugins()],
38-
alias: {
39-
src: webpackPaths.apiSrcPath,
40-
apiSrc: webpackPaths.apiSrcPath,
41-
uiSrc: webpackPaths.uiSrcPath,
42-
},
4338
},
4439

4540
plugins: [

configs/webpack.config.main.prod.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from 'path';
22
import webpack from 'webpack';
33
import { merge } from 'webpack-merge';
4+
import { toString } from 'lodash';
45
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
56
import baseConfig from './webpack.config.base';
67
import DeleteSourceMaps from '../scripts/DeleteSourceMaps';
@@ -24,16 +25,8 @@ export default merge(baseConfig, {
2425
target: 'electron-main',
2526

2627
entry: {
27-
main: path.join(webpackPaths.electronPath, 'main.dev.ts'),
28-
preload: path.join(webpackPaths.electronPath, 'preload.ts'),
29-
},
30-
31-
resolve: {
32-
alias: {
33-
['apiSrc']: webpackPaths.apiSrcPath,
34-
['src']: webpackPaths.apiSrcPath,
35-
},
36-
extensions: ['.tsx', '.ts', '.js', '.jsx'],
28+
main: path.join(webpackPaths.desktopPath, 'index.ts'),
29+
preload: path.join(webpackPaths.desktopPath, 'preload.ts'),
3730
},
3831

3932
output: {
@@ -73,6 +66,9 @@ export default merge(baseConfig, {
7366
APP_VERSION: version,
7467
AWS_BUCKET_NAME: 'AWS_BUCKET_NAME' in process.env ? process.env.AWS_BUCKET_NAME : '',
7568
SEGMENT_WRITE_KEY: 'SEGMENT_WRITE_KEY' in process.env ? process.env.SEGMENT_WRITE_KEY : 'SOURCE_WRITE_KEY',
69+
CONNECTIONS_TIMEOUT_DEFAULT: 'CONNECTIONS_TIMEOUT_DEFAULT' in process.env
70+
? process.env.CONNECTIONS_TIMEOUT_DEFAULT
71+
: toString(30 * 1000), // 30 sec
7672
}),
7773

7874
new webpack.DefinePlugin({

configs/webpack.config.main.stage.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import webpack from 'webpack';
22
import { merge } from 'webpack-merge';
3+
import { toString } from 'lodash';
34
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
45
import mainProdConfig from './webpack.config.main.prod';
56
import DeleteSourceMaps from '../scripts/DeleteSourceMaps';
@@ -30,6 +31,9 @@ export default merge(mainProdConfig, {
3031
APP_VERSION: version,
3132
AWS_BUCKET_NAME: 'AWS_BUCKET_NAME' in process.env ? process.env.AWS_BUCKET_NAME : '',
3233
SEGMENT_WRITE_KEY: 'SEGMENT_WRITE_KEY' in process.env ? process.env.SEGMENT_WRITE_KEY : 'SOURCE_WRITE_KEY',
34+
CONNECTIONS_TIMEOUT_DEFAULT: 'CONNECTIONS_TIMEOUT_DEFAULT' in process.env
35+
? process.env.CONNECTIONS_TIMEOUT_DEFAULT
36+
: toString(30 * 1000), // 30 sec
3337
}),
3438
],
3539
});

configs/webpack.config.preload.dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const configuration: webpack.Configuration = {
1212

1313
target: 'electron-preload',
1414

15-
entry: path.join(webpackPaths.electronPath, 'preload.ts'),
15+
entry: path.join(webpackPaths.desktopPath, 'preload.ts'),
1616

1717
output: {
1818
path: webpackPaths.dllPath,

configs/webpack.config.renderer.dev.dll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default merge(baseConfig, {
5454
new webpack.LoaderOptionsPlugin({
5555
debug: true,
5656
options: {
57-
context: webpackPaths.electronPath,
57+
context: webpackPaths.desktopPath,
5858
output: {
5959
path: webpackPaths.dllPath,
6060
},

configs/webpack.config.renderer.dev.ts

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const skipDLLs =
1818
module.parent?.filename.includes('webpack.config.renderer.dev.dll') ||
1919
module.parent?.filename.includes('webpack.config.eslint');
2020

21+
const htmlPagesNames = ['splash.ejs', 'index.ejs']
2122
/**
2223
* Warn if the DLL is not built
2324
*/
@@ -51,22 +52,14 @@ const configuration: webpack.Configuration = {
5152
],
5253

5354
output: {
54-
path: webpackPaths.electronPath,
55+
path: webpackPaths.desktopPath,
5556
publicPath: '/',
5657
filename: 'renderer.dev.js',
5758
library: {
5859
type: 'umd',
5960
},
6061
},
6162

62-
resolve: {
63-
alias: {
64-
src: webpackPaths.apiSrcPath,
65-
apiSrc: webpackPaths.apiSrcPath,
66-
uiSrc: webpackPaths.uiSrcPath,
67-
},
68-
},
69-
7063
module: {
7164
rules: [
7265
{
@@ -241,19 +234,21 @@ const configuration: webpack.Configuration = {
241234

242235
new MonacoWebpackPlugin({ languages: ['json'], features: ['!rename'] }),
243236

244-
new HtmlWebpackPlugin({
245-
filename: path.join('index.html'),
246-
template: path.join(webpackPaths.electronPath, 'index.ejs'),
247-
minify: {
248-
collapseWhitespace: true,
249-
removeAttributeQuotes: true,
250-
removeComments: true,
251-
},
252-
isBrowser: false,
253-
env: process.env.NODE_ENV,
254-
isDevelopment: process.env.NODE_ENV !== 'production',
255-
nodeModules: webpackPaths.appNodeModulesPath,
256-
}),
237+
...htmlPagesNames.map((htmlPageName) => (
238+
new HtmlWebpackPlugin({
239+
filename: path.join(`${htmlPageName.split('.')?.[0]}.html`),
240+
template: path.join(webpackPaths.desktopPath, htmlPageName),
241+
minify: {
242+
collapseWhitespace: true,
243+
removeAttributeQuotes: true,
244+
removeComments: true,
245+
},
246+
isBrowser: false,
247+
env: process.env.NODE_ENV,
248+
isDevelopment: process.env.NODE_ENV !== 'production',
249+
nodeModules: webpackPaths.appNodeModulesPath,
250+
})
251+
)),
257252

258253
new webpack.DefinePlugin({
259254
'process.env.NODE_ENV': JSON.stringify('development'),

configs/webpack.config.renderer.prod.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { version } from '../redisinsight/package.json';
1111

1212
DeleteSourceMaps();
1313

14+
const htmlPagesNames = ['splash.ejs', 'index.ejs']
15+
1416
const devtoolsConfig =
1517
process.env.DEBUG_PROD === 'true'
1618
? {
@@ -187,12 +189,14 @@ const configuration: webpack.Configuration = {
187189
filename: 'style.css',
188190
}),
189191

190-
new HtmlWebpackPlugin({
191-
filename: 'index.html',
192-
template: path.join(webpackPaths.electronPath, 'index.ejs'),
193-
isBrowser: false,
194-
isDevelopment: false,
195-
}),
192+
...htmlPagesNames.map((htmlPageName) => (
193+
new HtmlWebpackPlugin({
194+
filename: path.join(`${htmlPageName.split('.')?.[0]}.html`),
195+
template: path.join(webpackPaths.desktopPath, htmlPageName),
196+
isBrowser: false,
197+
isDevelopment: false,
198+
})
199+
)),
196200

197201
new webpack.DefinePlugin({
198202
'process.type': '"renderer"',

configs/webpack.config.web.common.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import webpack from 'webpack';
66
import HtmlWebpackPlugin from 'html-webpack-plugin';
77
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
88
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
9+
import webpackPaths from './webpack.paths';
910
import { dependencies as externals } from '../redisinsight/package.json';
1011
import { dependencies as externalsApi } from '../redisinsight/api/package.json';
1112

@@ -18,12 +19,11 @@ export default {
1819
rules: [
1920
{
2021
test: /\.(js|jsx|ts|tsx)?$/,
21-
// exclude: /node_modules/,
22-
include: [path.resolve(__dirname, '../redisinsight/ui')],
22+
include: [webpackPaths.uiPath],
2323
exclude: [
2424
/node_modules/,
25-
path.resolve(__dirname, '../redisinsight/api'),
26-
path.resolve(__dirname, '../redisinsight/electron'),
25+
webpackPaths.apiPath,
26+
webpackPaths.desktopPath,
2727
],
2828
use: {
2929
loader: 'babel-loader',
@@ -44,8 +44,7 @@ export default {
4444
],
4545
},
4646

47-
// context: path.resolve(__dirname, '../redisinsight/api/src'),
48-
context: path.resolve(__dirname, '../redisinsight/ui'),
47+
context: webpackPaths.uiPath,
4948

5049
/**
5150
* Determine the array of extensions that should be used to resolve modules.
@@ -66,7 +65,7 @@ export default {
6665

6766
plugins: [
6867
new webpack.DefinePlugin({
69-
'window.ENV_VARS.API_PORT': JSON.stringify('5000'),
68+
'window.app.config.apiPort': JSON.stringify('5000'),
7069
}),
7170

7271
new HtmlWebpackPlugin({ template: 'index.html.ejs' }),

0 commit comments

Comments
 (0)