Skip to content

Commit

Permalink
[Refactor] 核心重构 (#116)
Browse files Browse the repository at this point in the history
* fix: remove config controller and service

* fix: use class implement proxy middleware

* fix: 插件中间件热更新功能完成

* fix: use routing-controllers to replace old controller regist

* fix: move socket logic to a single controller

* fix: rename plugin-manager to plugin-service

* fix: 删除无用 interface,证书移到 service 目录下

* fix: core/App 下的目录结构修改,上提一级

* fix: 证书信息相关类属性移动到 https server 中

* fix: 修复重构bug,移动部分文件路径

* fix: move middleware dir

* fix: optimize cert storage and service

* fix: remove ip and user middleware

* fix: http-traffic 去除 userId 依赖

* fix: delete some webui monitor unused file

* fix: move webui to src directory

* fix: add vuex-class lib, fix tsconfig

* fix: 监控页重构——记录列表显示

* fix: move webui outer again

* fix: open strictNullCheck, change some client type

* fix: repair response headers error

* fix: make body-collapse a vue component

* fix: button icon

* fix: move intro page and left-menu to ts

* fix: api to ts

* fix: plugins 页面 ts 化

* fix: webui mock-data 部分重构

* fix: mock 数据 service 层删除 userId 依赖

* fix: profile controller 修改

* fix: change some table align and width

* fix: host 部分重构

* fix: 转发规则 node 部分删除 userId 参数

* fix: 规则转发部分重构

* fix: remove plugin-example, test files and cli publish script

* fix: host 规则添加重复检测

* fix: 添加插件升级功能

* fix: plugin service 抽取公共方法

* fix: disable remote rule edit

* fix: service 方法整理,plugin 功能测试

* fix: remove console

* fix: remove some dependencies

* fix: create rule no response

* fix: 修复 gui 中 service 方法的错误使用

* fix: 异步加载 GUI Application,避免 profile 初始化错误

* fix: 修改开发打包配置,

* fix: 升级 devDependencies

* fix: update tray icon image

* v5.0.0-beta.1

* fix: update build script

* fix: revert mobx-react version

* fix: update npm version

* fix: 添加清理证书功能

* fix: 添加证书初始化的平台判断

* fix: 调整菜单项

* fix: 添加旧版数据备份

* fix: add LAN ip to ignore pattern
  • Loading branch information
kainstar authored Nov 11, 2019
1 parent 101cd98 commit 030b68b
Show file tree
Hide file tree
Showing 266 changed files with 11,500 additions and 36,302 deletions.
7 changes: 0 additions & 7 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"comments": false,
"env": {
"main": {
"presets": [
["@babel/env", {
"targets": { "node": 8 }
}]
]
},
"renderer": {
"presets": [
[
Expand Down
61 changes: 29 additions & 32 deletions .build/cli/dev-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,44 @@ const webpack = require('webpack');
const nodemon = require('nodemon');
const webpackConfig = require('./webpack.cli.config');

process.on('SIGINT', function(){
process.on('SIGINT', function() {
process.exit(0);
});

const startNodemon = (function() {
let started = false;

function startNodemon() {
if (started) {
return;
}

nodemon({
verbose: true,
delay: '500',
env: {
NODE_ENV: 'development',
},
watch: ['dist'],
exec: `node dist/main.js ${process.argv.slice(2).join(' ')}`,
}).on('start', () => {
console.log('nodemon started.');
started = true;
});
}

return startNodemon;
})();
const startNodemon = () => {
nodemon({
verbose: true,
delay: '500',
env: {
NODE_ENV: 'development',
},
watch: ['dist'],
exec: `node dist/main.js ${process.argv.slice(2).join(' ')}`,
}).on('start', () => {
console.log('nodemon started.');
started = true;
});
};

function watch() {
webpackConfig.mode = 'development';
const compiler = webpack(webpackConfig);

compiler.watch({}, (err, stats) => {
if (err) {
console.log(err);
return;
}
return new Promise((resolve, reject) => {
compiler.watch({}, (err, stats) => {
if (err) {
return reject(err);
}

startNodemon();
resolve(stats);
});
});
}

watch();
watch()
.then(() => {
startNodemon();
})
.catch(err => {
console.error(err);
});
71 changes: 5 additions & 66 deletions .build/cli/webpack.cli.config.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,14 @@
'use strict';

process.env.BABEL_ENV = 'main';
const merge = require('webpack-merge');
const webpackNodeBaseConfig = require('../webpack.config.node-base');
const { rootResolve } = require('../utils');

const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const { rootResolve, runtimePathDefine, webpackAlias } = require('../utils');

const isDev = process.env.NODE_ENV !== 'production';

const mainConfig = {
mode: process.env.NODE_ENV,
const mainConfig = merge(webpackNodeBaseConfig, {
target: 'node',
entry: {
main: rootResolve('src/cli/index.ts'),
},
externals: [nodeExternals()],
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'awesome-typescript-loader',
options: {},
},
],
exclude: /node_modules/,
},
{
test: /\.node$/,
use: 'node-loader',
},
],
},
node: {
__dirname: isDev,
__filename: isDev,
},
output: {
filename: '[name].js',
libraryTarget: 'commonjs2',
path: rootResolve('dist'),
},
plugins: [new webpack.NoEmitOnErrorsPlugin()],
resolve: {
alias: webpackAlias,
extensions: ['.js', '.ts', '.json', '.node'],
},
};

if (isDev) {
/**
* Adjust mainConfig for development settings
*/
mainConfig.plugins.push(
new webpack.DefinePlugin({
...runtimePathDefine,
}),
new FriendlyErrorsWebpackPlugin(),
);
} else {
/**
* Adjust mainConfig for production settings
*/
mainConfig.plugins.push(
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
);

}
});

module.exports = mainConfig;
50 changes: 16 additions & 34 deletions .build/gui/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

process.env.NODE_ENV = 'production';

const { say } = require('cfonts');
const chalk = require('chalk');
const del = require('del');
const webpack = require('webpack');
Expand All @@ -11,14 +10,12 @@ const Multispinner = require('multispinner');
const mainConfig = require('./webpack.main.config');
const rendererConfig = require('./webpack.renderer.config');

const doneLog = chalk.bgGreen.white(' DONE ') + ' ';
const errorLog = chalk.bgRed.white(' ERROR ') + ' ';
const okayLog = chalk.bgBlue.white(' OKAY ') + ' ';
const doneLog = chalk.bgGreen.white(' DONE ');
const errorLog = chalk.bgRed.white(' ERROR ');
const okayLog = chalk.bgBlue.white(' OKAY ');

function build() {
greeting();

del.sync(['build/*', 'dist/*', '!.gitkeep']);
del.sync(['build/*', 'dist/*']);

const tasks = ['main', 'renderer'];
const m = new Multispinner(tasks, {
Expand All @@ -31,7 +28,7 @@ function build() {
m.on('success', () => {
process.stdout.write('\x1B[2J\x1B[0f');
console.log(`\n\n${results}`);
console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`);
console.log(`${okayLog} take it away ${chalk.yellow('`electron-builder`')}\n`);
process.exit();
});

Expand All @@ -42,7 +39,7 @@ function build() {
})
.catch(err => {
m.error('main');
console.log(`\n ${errorLog}failed to build main process`);
console.log(`\n ${errorLog} failed to build main process`);
console.error(`\n${err}\n`);
process.exit(1);
});
Expand All @@ -54,19 +51,22 @@ function build() {
})
.catch(err => {
m.error('renderer');
console.log(`\n ${errorLog}failed to build renderer process`);
console.log(`\n ${errorLog} failed to build renderer process`);
console.error(`\n${err}\n`);
process.exit(1);
});
}

/**
* webpack 打包
*/
function pack(config) {
return new Promise((resolve, reject) => {
config.mode = 'production';
webpack(config, (err, stats) => {
if (err) reject(err.stack || err);
else if (stats.hasErrors()) {
let err = '';
if (err) {
reject(err.stack || err);
} else if (stats.hasErrors()) {
let errMsg = '';

stats
.toString({
Expand All @@ -75,10 +75,10 @@ function pack(config) {
})
.split(/\r?\n/)
.forEach(line => {
err += ` ${line}\n`;
errMsg += ` ${line}\n`;
});

reject(err);
reject(errMsg);
} else {
resolve(
stats.toString({
Expand All @@ -91,22 +91,4 @@ function pack(config) {
});
}

function greeting() {
const cols = process.stdout.columns;
let text = '';

if (cols > 85) text = 'lets-build';
else if (cols > 60) text = 'lets-|build';
else text = false;

if (text) {
say(text, {
colors: ['yellow'],
font: 'simple3d',
space: false,
});
} else console.log(chalk.yellow.bold('\n lets-build'));
console.log();
}

build();
2 changes: 1 addition & 1 deletion .build/gui/dev-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ hotClient.subscribe(event => {
* giving notice for an expected reload of the `electron` process
*/
if (event.action === 'compiling') {
document.body.innerHTML += `
document.body.innerHTML = `
<style>
#dev-client {
background: #4fc08d;
Expand Down
Loading

0 comments on commit 030b68b

Please sign in to comment.