Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

upgrade: 清理和升级依赖 #396

Merged
merged 26 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import antfu from '@antfu/eslint-config'

export default antfu(
{
vue: {
vueVersion: 2,
},
rules: {
'style/brace-style': ['error', '1tbs'],
'style/space-before-function-paren': ['error', 'always'],
'import/newline-after-import': 'off',
'import/first': 'off',
'perfectionist/sort-imports': 'off',
'node/prefer-global/buffer': 'off',
'node/prefer-global/process': 'off',
'no-console': 'off',
},
ignores: [
'**/build/*',
'**/dist_electron',
],
formatters: {
css: true,
html: true,
markdown: 'prettier',
},
},
)
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
{
"name": "dev-sidecar-parent",
"type": "module",
"private": false,
"packageManager": "pnpm@9.13.2",
"author": "Greper",
"license": "MPL-2.0"
"license": "MPL-2.0",
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
"devDependencies": {
"@antfu/eslint-config": "^3.9.1",
"eslint": "^9.15.0",
"eslint-plugin-format": "^0.1.2"
}
}
373 changes: 373 additions & 0 deletions packages/cli/LICENSE

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions packages/cli/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../src')
23 changes: 23 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@docmirror/dev-sidecar-cli",
"version": "1.8.9",
"private": false,
"description": "给开发者的加速代理工具",
"author": "docmirror.cn",
"license": "MPL-2.0",
"keywords": [
"dev-sidecar",
"github加速",
"google加速",
"代理"
],
"main": "src/index.js",
"bin": "./cli.js",
"scripts": {
"start": "node ./src"
},
"dependencies": {
"@docmirror/dev-sidecar": "workspace:*",
"@docmirror/mitmproxy": "workspace:*"
}
}
File renamed without changes.
13 changes: 6 additions & 7 deletions packages/core/start/index.js → packages/cli/src/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
const fs = require('fs')
const fs = require('node:fs')
const DevSidecar = require('@docmirror/dev-sidecar')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const DevSidecar = require('../index')
const log = require('../src/utils/util.log')

// 启动服务
const mitmproxyPath = './start/mitmproxy'
const mitmproxyPath = './src/mitmproxy'
async function startup () {
const banner = fs.readFileSync('./start/banner.txt')
const banner = fs.readFileSync('./src/banner.txt')
console.log(banner.toString())

const configPath = './start/user_config.json5'
const configPath = './src/user_config.json5'
if (fs.existsSync(configPath)) {
const file = fs.readFileSync(configPath)
const userConfig = jsonApi.parse(file.toString())
log.info('读取 user_config.json5 成功:', configPath)
console.info('读取 user_config.json5 成功:', configPath)
DevSidecar.api.config.set(userConfig)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')
const server = require('@docmirror/mitmproxy')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const log = require('../src/utils/util.log')
Expand Down
3 changes: 0 additions & 3 deletions packages/core/.babelrc

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/.eslintignore

This file was deleted.

60 changes: 4 additions & 56 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,71 +13,19 @@
],
"main": "src/index.js",
"scripts": {
"start": "node ./start",
"test": "mocha"
},
"dependencies": {
"@docmirror/mitmproxy": "workspace:*",
"agentkeepalive": "^2.1.1",
"babel-preset-es2020": "^1.0.2",
"charset": "^1.0.0",
"child_process": "^1.0.2",
"colors": "^1.1.2",
"commander": "^2.9.0",
"debug": "^4.1.1",
"dns-over-http": "^0.2.0",
"dns-over-tls": "^0.0.8",
"fix-path": "^3.0.0",
"iconv-lite": "^0.4.13",
"is-browser": "^2.1.0",
"jschardet": "^1.4.1",
"json5": "^2.2.3",
"iconv-lite": "^0.6.3",
"lodash": "^4.17.20",
"log4js": "^6.3.0",
"lru-cache": "^6.0.0",
"mkdirp": "^0.5.1",
"node-cmd": "^3.0.0",
"node-forge": "^0.8.2",
"log4js": "^6.9.1",
"node-powershell": "^4.0.0",
"require-context": "^1.1.0",
"spawn-sync": "^2.0.0",
"through2": "^2.0.1",
"tunnel-agent": "^0.4.3",
"util": "^0.12.3",
"validator": "^13.1.17",
"winreg": "^1.2.4"
"winreg": "^1.2.5"
},
"devDependencies": {
"@vue/cli-plugin-eslint": "^4.5.0",
"@vue/eslint-config-standard": "^5.1.2",
"babel-eslint": "^10.1.0",
"chai": "^4.3.4",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2",
"mocha": "^8.2.1"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"@vue/standard"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
],
"gitHead": "30ecf21cb001fb8d821e575d476ca0ffb4ff086e"
}
}
4 changes: 2 additions & 2 deletions packages/core/src/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const lodash = require('lodash')
const request = require('request')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/config/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const path = require('node:path')

function getUserBasePath () {
const userHome = process.env.USERPROFILE || process.env.HOME || '/'
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ function register (channel, handle, order = 10) {
handles = listener[channel] = []
}
handles.push({ id: index, handle, order })
handles.sort((a, b) => { return a.order - b.order })
handles.sort((a, b) => {
return a.order - b.order
})
return index++
}
function fire (channel, event) {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/modules/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const lodash = require('lodash')
const config = require('../../config')
const event = require('../../event')
const status = require('../../status')
const fork = require('child_process').fork
const fs = require('fs')
const path = require('path')
const fork = require('node:child_process').fork
const fs = require('node:fs')
const path = require('node:path')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const log = require('../../utils/util.log')

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/shell/scripts/extra-path/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const path = require('node:path')
const log = require('../../../utils/util.log')

function getExtraPath () {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/shell/scripts/set-system-proxy/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* 获取环境变量
*/
const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')
const request = require('request')
const Registry = require('winreg')
const log = require('../../../utils/util.log')
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/shell/shell.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const childProcess = require('child_process')
const os = require('os')
const childProcess = require('node:child_process')
const os = require('node:os')
const fixPath = require('fix-path')
const iconv = require('iconv-lite')
const PowerShell = require('node-powershell')
Expand Down Expand Up @@ -78,7 +78,7 @@ class WindowsSystemShell extends SystemShell {

function _childExec (composeCmds, options = {}) {
return new Promise((resolve, reject) => {
const childProcess = require('child_process')
const childProcess = require('node:child_process')
log.info('shell:', composeCmds)
childProcess.exec(composeCmds, options, (error, stdout, stderr) => {
if (error) {
Expand All @@ -101,7 +101,7 @@ function childExec (composeCmds, options = {}) {
const encoding = 'cp936'
const binaryEncoding = 'binary'

const childProcess = require('child_process')
const childProcess = require('node:child_process')
log.info('shell:', composeCmds)
childProcess.exec(composeCmds, { encoding: binaryEncoding }, (error, stdout, stderr) => {
if (error) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/shell/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// console.error(e)
// })

const fs = require('fs')
const fs = require('node:fs')
const request = require('request')

request({
Expand Down
15 changes: 1 addition & 14 deletions packages/core/src/utils/util.log.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
const path = require('path')
const log4js = require('log4js')
const config = require('../config/index')
const log4js = require('./util.logger')

const level = process.env.NODE_ENV === 'development' ? 'debug' : 'info'

function getDefaultConfigBasePath () {
return config.server.setting.userBasePath
}

const filename = path.join(getDefaultConfigBasePath(), '/logs/core.log')
log4js.configure({
appenders: { std: { type: 'stdout' }, file: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename } },
categories: { default: { appenders: ['file', 'std'], level } },
})
const logger = log4js.getLogger('core')
module.exports = logger
30 changes: 30 additions & 0 deletions packages/core/src/utils/util.logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const path = require('node:path')
const log4js = require('log4js')
const config = require('../config/index')

const level = process.env.NODE_ENV === 'development' ? 'debug' : 'info'

function getDefaultConfigBasePath () {
return config.server.setting.userBasePath
}

const coreLogFilename = path.join(getDefaultConfigBasePath(), '/logs/core.log')
const guiLogFilename = path.join(getDefaultConfigBasePath(), '/logs/gui.log')
const serverLogFilename = path.join(getDefaultConfigBasePath(), '/logs/server.log')

log4js.configure({
appenders: {
std: { type: 'stdout' },
core: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename: coreLogFilename },
gui: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename: guiLogFilename },
server: { level: 'debug', type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename: serverLogFilename },
},
categories: {
default: { appenders: ['std'], level },
core: { appenders: ['core', 'std'], level },
gui: { appenders: ['gui', 'std'], level },
server: { appenders: ['server', 'std'], level },
},
})

module.exports = log4js
2 changes: 1 addition & 1 deletion packages/core/test/httpsVerifyTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const https = require('https')
const https = require('node:https')

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '1'

Expand Down
2 changes: 1 addition & 1 deletion packages/gui/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset',
'@vue/babel-preset-jsx',
],
}
Loading
Loading