diff --git a/README.md b/README.md index 98c1ee1..8e01354 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ 下载安装包: 阿里云直接下载 -[windows版](http://dev-sidecar.docmirror.cn/update/DevSidecar-1.5.0.exe) -[Mac版](http://dev-sidecar.docmirror.cn/update/DevSidecar-1.5.0.dmg) +[windows版](https://dev-sidecar.docmirror.cn/update/DevSidecar-1.5.0.exe) +[Mac版](https://dev-sidecar.docmirror.cn/update/DevSidecar-1.5.0.dmg) 注意:mac版安装需要在“系统偏好设置->安全性与隐私->通用”中解锁并允许应用安装 从Release下载 diff --git a/packages/core/.eslintignore b/packages/core/.eslintignore new file mode 100644 index 0000000..3d9ba84 --- /dev/null +++ b/packages/core/.eslintignore @@ -0,0 +1 @@ +./src/test diff --git a/packages/core/package.json b/packages/core/package.json index 4164e23..f4ea935 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -13,7 +13,8 @@ "license": "MPL-2.0", "private": false, "scripts": { - "start": "node ./start" + "start": "node ./start", + "test": "mocha" }, "dependencies": { "@docmirror/mitmproxy": "^1.5.0", @@ -49,6 +50,7 @@ "@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", diff --git a/packages/core/src/config/index.js b/packages/core/src/config/index.js index c6d00c0..2cc5805 100644 --- a/packages/core/src/config/index.js +++ b/packages/core/src/config/index.js @@ -47,7 +47,7 @@ module.exports = { '/.*/.*/blame/': { redirect: 'hub.fastgit.org' }, - '^/[^/]+/[^/]+$': { + '^/[^/]+/[^/]+(/releases(/.*)?)?$': { script: [ 'jquery', 'github' diff --git a/packages/core/test/configTest.js b/packages/core/test/configTest.js index d5525c5..8f2c0af 100644 --- a/packages/core/test/configTest.js +++ b/packages/core/test/configTest.js @@ -1,20 +1,20 @@ -const config = require('../src/config') - -config.set({ - server: { - intercepts: { - 'github1.githubassets.com': { - '.*': { - redirect: 'assets.fastgit.org', - test: 'https://github.githubassets.com/favicons/favicon.svg', - desc: '静态资源加速' - } - }, - 'github.githubassets.com': null - } - } -}) - -console.log(config.get()) - -config.reload() +// const config = require('../src/config') +// +// config.set({ +// server: { +// intercepts: { +// 'github1.githubassets.com': { +// '.*': { +// redirect: 'assets.fastgit.org', +// test: 'https://github.githubassets.com/favicons/favicon.svg', +// desc: '静态资源加速' +// } +// }, +// 'github.githubassets.com': null +// } +// } +// }) +// +// console.log(config.get()) +// +// config.reload() diff --git a/packages/core/test/macProxy.js b/packages/core/test/macProxy.js index db759d2..2ce5a6d 100644 --- a/packages/core/test/macProxy.js +++ b/packages/core/test/macProxy.js @@ -1,13 +1,13 @@ -const childProcess = require('child_process') -const util = require('util') -const exec = util.promisify(childProcess.exec) - -async function test () { - const wifiAdaptor = (await exec('sh -c "networksetup -listnetworkserviceorder | grep `route -n get 0.0.0.0 | grep \'interface\' | cut -d \':\' -f2` -B 1 | head -n 1 | cut -d \' \' -f2"')).stdout.trim() - - await exec(`networksetup -setwebproxystate '${wifiAdaptor}' off`) - return await exec(`networksetup -setsecurewebproxystate '${wifiAdaptor}' off`) -} -test().then((ret) => { - console.log('haha', ret) -}) +// const childProcess = require('child_process') +// const util = require('util') +// const exec = util.promisify(childProcess.exec) +// +// async function test () { +// const wifiAdaptor = (await exec('sh -c "networksetup -listnetworkserviceorder | grep `route -n get 0.0.0.0 | grep \'interface\' | cut -d \':\' -f2` -B 1 | head -n 1 | cut -d \' \' -f2"')).stdout.trim() +// +// await exec(`networksetup -setwebproxystate '${wifiAdaptor}' off`) +// return await exec(`networksetup -setsecurewebproxystate '${wifiAdaptor}' off`) +// } +// test().then((ret) => { +// console.log('haha', ret) +// }) diff --git a/packages/core/test/regex.test.js b/packages/core/test/regex.test.js new file mode 100644 index 0000000..93a7cac --- /dev/null +++ b/packages/core/test/regex.test.js @@ -0,0 +1,13 @@ +var expect = require('chai').expect +// eslint-disable-next-line no-undef +describe('test', function () { + // eslint-disable-next-line no-undef + it('regexp', function () { + const test = '^/[^/]+/[^/]+(/releases(/.*)?)?$' + const reg = new RegExp(test) + + const ret = reg.test('/docmirror/dev-sidecar/releases/tag') + // eslint-disable-next-line no-unused-expressions + expect(ret).be.ok + }) +}) diff --git a/packages/core/yarn.lock b/packages/core/yarn.lock index 0273ba5..ea6eb7c 100644 --- a/packages/core/yarn.lock +++ b/packages/core/yarn.lock @@ -610,6 +610,11 @@ assert@^1.1.1: object-assign "^4.1.1" util "0.10.3" +assertion-error@^1.1.0: + version "1.1.0" + resolved "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" + integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== + assign-symbols@^1.0.0: version "1.0.0" resolved "https://registry.npm.taobao.org/assign-symbols/download/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" @@ -1039,6 +1044,18 @@ caseless@~0.12.0: resolved "https://registry.npm.taobao.org/caseless/download/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= +chai@^4.3.4: + version "4.3.4" + resolved "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz#b55e655b31e1eac7099be4c08c21964fce2e6c49" + integrity sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA== + dependencies: + assertion-error "^1.1.0" + check-error "^1.0.2" + deep-eql "^3.0.1" + get-func-name "^2.0.0" + pathval "^1.1.1" + type-detect "^4.0.5" + chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" @@ -1077,6 +1094,11 @@ charset@^1.0.0: resolved "https://registry.npmjs.org/charset/-/charset-1.0.1.tgz#8d59546c355be61049a8fa9164747793319852bd" integrity sha512-6dVyOOYjpfFcL1Y4qChrAoQLRHvj2ziyhcm0QJlhOcAhykL/k1kTUPbeo+87MNRTRdk2OIIsIXbuF3x2wi5EXg== +check-error@^1.0.2: + version "1.0.2" + resolved "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" + integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= + child_process@^1.0.2: version "1.0.2" resolved "https://registry.npm.taobao.org/child_process/download/child_process-1.0.2.tgz#b1f7e7fc73d25e7fd1d455adc94e143830182b5a" @@ -1452,6 +1474,13 @@ decode-uri-component@^0.2.0: resolved "https://registry.npm.taobao.org/decode-uri-component/download/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= +deep-eql@^3.0.1: + version "3.0.1" + resolved "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" + integrity sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw== + dependencies: + type-detect "^4.0.0" + deep-is@~0.1.3: version "0.1.3" resolved "https://registry.npm.taobao.org/deep-is/download/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -2358,6 +2387,11 @@ get-caller-file@^2.0.1: resolved "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== +get-func-name@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" + integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= + get-stream@^2.2.0: version "2.3.1" resolved "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz#5f38f93f346009666ee0150a054167f91bdd95de" @@ -3869,6 +3903,11 @@ path-type@^3.0.0: dependencies: pify "^3.0.0" +pathval@^1.1.1: + version "1.1.1" + resolved "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" + integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== + pbkdf2@^3.0.3: version "3.1.1" resolved "https://registry.npm.taobao.org/pbkdf2/download/pbkdf2-3.1.1.tgz#cb8724b0fada984596856d1a6ebafd3584654b94" @@ -4931,6 +4970,11 @@ type-check@~0.3.2: dependencies: prelude-ls "~1.1.2" +type-detect@^4.0.0, type-detect@^4.0.5: + version "4.0.8" + resolved "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== + type-fest@^0.11.0: version "0.11.0" resolved "https://registry.npm.taobao.org/type-fest/download/type-fest-0.11.0.tgz?cache=0&sync_timestamp=1602623859603&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftype-fest%2Fdownload%2Ftype-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1"