refactor: dns设置
|
@ -4,5 +4,8 @@
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"lerna": "^3.22.1"
|
"lerna": "^3.22.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"sqlite3": "^5.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1795,7 +1795,6 @@
|
||||||
"thread-loader": "^2.1.3",
|
"thread-loader": "^2.1.3",
|
||||||
"url-loader": "^2.2.0",
|
"url-loader": "^2.2.0",
|
||||||
"vue-loader": "^15.9.2",
|
"vue-loader": "^15.9.2",
|
||||||
"vue-loader-v16": "npm:vue-loader@^16.0.0-beta.7",
|
|
||||||
"vue-style-loader": "^4.1.2",
|
"vue-style-loader": "^4.1.2",
|
||||||
"webpack": "^4.0.0",
|
"webpack": "^4.0.0",
|
||||||
"webpack-bundle-analyzer": "^3.8.0",
|
"webpack-bundle-analyzer": "^3.8.0",
|
||||||
|
@ -12415,63 +12414,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vue-loader-v16": {
|
|
||||||
"version": "npm:vue-loader@16.0.0-beta.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.9.tgz",
|
|
||||||
"integrity": "sha512-mu9pg6554GbXDSO8LlxkQM6qUJzUkb/A0FJc9LgRqnU9MCnhzEXwCt1Zx5NObvFpzs2mH2dH/uUCDwL8Qaz9sA==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"chalk": "^4.1.0",
|
|
||||||
"hash-sum": "^2.0.0",
|
|
||||||
"loader-utils": "^2.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"ansi-styles": {
|
|
||||||
"version": "4.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
|
||||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"color-convert": "^2.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"chalk": {
|
|
||||||
"version": "4.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
|
|
||||||
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"ansi-styles": "^4.1.0",
|
|
||||||
"supports-color": "^7.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-convert": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"color-name": "~1.1.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"loader-utils": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"big.js": "^5.2.2",
|
|
||||||
"emojis-list": "^3.0.0",
|
|
||||||
"json5": "^2.1.2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vue-style-loader": {
|
"vue-style-loader": {
|
||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz",
|
||||||
|
|
|
@ -34,31 +34,29 @@ const configApi = {
|
||||||
resetDefault () {
|
resetDefault () {
|
||||||
configTarget = lodash.cloneDeep(defConfig)
|
configTarget = lodash.cloneDeep(defConfig)
|
||||||
},
|
},
|
||||||
async getMirrorEnv () {
|
async getVariables (type) {
|
||||||
const envMap = await Shell.getEnv()
|
const method = type === 'npm' ? Shell.getNpmEnv : Shell.getSystemEnv
|
||||||
|
const currentMap = await method()
|
||||||
const list = []
|
const list = []
|
||||||
const mirrors = configTarget.mirrors
|
const map = configTarget.variables[type]
|
||||||
console.log('envMap', envMap)
|
for (const key in map) {
|
||||||
for (const key in mirrors) {
|
const exists = currentMap[key] != null
|
||||||
console.log('equale', key, envMap[key])
|
|
||||||
const exists = envMap[key] != null
|
|
||||||
list.push({
|
list.push({
|
||||||
key,
|
key,
|
||||||
value: mirrors[key],
|
value: map[key],
|
||||||
exists
|
exists
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
console.log('mirrors:', list)
|
|
||||||
return list
|
return list
|
||||||
},
|
},
|
||||||
async setupMirrors () {
|
async setVariables (type) {
|
||||||
const list = await configApi.getMirrorEnv()
|
const list = await configApi.getVariables(type)
|
||||||
const noSetList = list.filter(item => {
|
const noSetList = list.filter(item => {
|
||||||
return !item.exists
|
return !item.exists
|
||||||
})
|
})
|
||||||
console.log('mirrors will set:', noSetList)
|
|
||||||
if (list.length > 0) {
|
if (list.length > 0) {
|
||||||
return Shell.setEnv({ list: noSetList })
|
const method = type === 'npm' ? Shell.setNpmEnv : Shell.setSystemEnv
|
||||||
|
return method({ list: noSetList })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,13 @@ module.exports = {
|
||||||
{
|
{
|
||||||
abort: true
|
abort: true
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
// https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.0/napi-v3-win32-x64.tar.gz
|
||||||
|
'*.s3.amazonaws.com': [
|
||||||
|
{
|
||||||
|
regexp: '/sqlite3/.*',
|
||||||
|
redirect: 'http://npm.taobao.org/mirrors'
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
dns: {
|
dns: {
|
||||||
|
@ -104,11 +111,18 @@ module.exports = {
|
||||||
// "avatars*.githubusercontent.com": "usa"
|
// "avatars*.githubusercontent.com": "usa"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mirrors: {
|
variables: {
|
||||||
SASS_BINARY_SITE: 'https://npm.taobao.org/mirrors/node-sass/',
|
npm: {
|
||||||
PHANTOMJS_CDNURL: 'https://npm.taobao.org/mirrors/phantomjs/',
|
SASS_BINARY_SITE: 'https://npm.taobao.org/mirrors/node-sass/',
|
||||||
ELECTRON_MIRROR: 'https://npm.taobao.org/mirrors/electron/',
|
PHANTOMJS_CDNURL: 'https://npm.taobao.org/mirrors/phantomjs/',
|
||||||
CYPRESS_DOWNLOAD_MIRROR: 'https://cdn.cypress.io'
|
ELECTRON_MIRROR: 'https://npm.taobao.org/mirrors/electron/',
|
||||||
|
CYPRESS_DOWNLOAD_MIRROR: 'https://cdn.cypress.io',
|
||||||
|
NVM_NODEJS_ORG_MIRROR: 'http://npm.taobao.org/mirrors/node',
|
||||||
|
CHROMEDRIVER_CDNURL: 'http://npm.taobao.org/mirrors/chromedriver',
|
||||||
|
OPERADRIVER: 'http://npm.taobao.org/mirrors/operadriver',
|
||||||
|
ELECTRON_BUILDER_BINARIES_MIRROR: 'http://npm.taobao.org/mirrors/electron-builder-binaries/',
|
||||||
|
PYTHON_MIRROR: 'http://npm.taobao.org/mirrors/python'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setting: {
|
setting: {
|
||||||
startup: { // 开机启动
|
startup: { // 开机启动
|
||||||
|
@ -118,8 +132,8 @@ module.exports = {
|
||||||
npm: true,
|
npm: true,
|
||||||
yarn: true
|
yarn: true
|
||||||
},
|
},
|
||||||
mirrors: {
|
variables: {
|
||||||
set: true
|
npm: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ module.exports = {
|
||||||
}
|
}
|
||||||
await proxyStartup({ ip: '127.0.0.1', port: config.get().server.port })
|
await proxyStartup({ ip: '127.0.0.1', port: config.get().server.port })
|
||||||
|
|
||||||
if (startup.mirrors.set) {
|
if (startup.variables.npm) {
|
||||||
await config.setupMirrors()
|
await config.setVariables('npm')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
const killByPort = require('./scripts/kill-by-port')
|
const killByPort = require('./scripts/kill-by-port')
|
||||||
const setupCa = require('./scripts/setup-ca')
|
const setupCa = require('./scripts/setup-ca')
|
||||||
const getEnv = require('./scripts/get-env')
|
const getSystemEnv = require('./scripts/get-system-env')
|
||||||
const setEnv = require('./scripts/set-env')
|
const setSystemEnv = require('./scripts/set-system-env')
|
||||||
|
const getNpmEnv = require('./scripts/get-npm-env')
|
||||||
|
const setNpmEnv = require('./scripts/set-npm-env')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
killByPort,
|
killByPort,
|
||||||
setupCa,
|
setupCa,
|
||||||
getEnv,
|
getSystemEnv,
|
||||||
setEnv
|
setSystemEnv,
|
||||||
|
getNpmEnv,
|
||||||
|
setNpmEnv
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/**
|
||||||
|
* 获取环境变量
|
||||||
|
*/
|
||||||
|
const Shell = require('../shell')
|
||||||
|
const execute = Shell.execute
|
||||||
|
const executor = {
|
||||||
|
async windows (exec) {
|
||||||
|
const ret = await exec(['npm config list --json'], { type: 'cmd' })
|
||||||
|
if (ret != null) {
|
||||||
|
const json = ret.substring(ret.indexOf('{'))
|
||||||
|
return JSON.parse(json)
|
||||||
|
}
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
async linux (exec, { port }) {
|
||||||
|
throw Error('暂未实现此功能')
|
||||||
|
},
|
||||||
|
async mac (exec, { port }) {
|
||||||
|
throw Error('暂未实现此功能')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = async function (args) {
|
||||||
|
return execute(executor, args)
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
/**
|
||||||
|
* 设置环境变量
|
||||||
|
*/
|
||||||
|
const Shell = require('../shell')
|
||||||
|
const execute = Shell.execute
|
||||||
|
const executor = {
|
||||||
|
async windows (exec, { list }) {
|
||||||
|
const cmds = []
|
||||||
|
for (const item of list) {
|
||||||
|
cmds.push(`npm config set ${item.key} ${item.value}`)
|
||||||
|
}
|
||||||
|
const ret = await exec(cmds, { type: 'cmd' })
|
||||||
|
return ret
|
||||||
|
},
|
||||||
|
async linux (exec, { port }) {
|
||||||
|
throw Error('暂未实现此功能')
|
||||||
|
},
|
||||||
|
async mac (exec, { port }) {
|
||||||
|
throw Error('暂未实现此功能')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = async function (args) {
|
||||||
|
return execute(executor, args)
|
||||||
|
}
|
|
@ -11,6 +11,14 @@ const executor = {
|
||||||
cmds.push(`[Environment]::SetEnvironmentVariable('${item.key}', '${item.value}', 'Machine')`)
|
cmds.push(`[Environment]::SetEnvironmentVariable('${item.key}', '${item.value}', 'Machine')`)
|
||||||
}
|
}
|
||||||
const ret = await exec(cmds, { type: 'ps' })
|
const ret = await exec(cmds, { type: 'ps' })
|
||||||
|
|
||||||
|
const cmds2 = []
|
||||||
|
for (const item of list) {
|
||||||
|
// [Environment]::SetEnvironmentVariable('FOO', 'bar', 'Machine')
|
||||||
|
cmds2.push(`set ${item.key}=""`)
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const ret2 = await exec(cmds2, { type: 'cmd' })
|
||||||
return ret
|
return ret
|
||||||
},
|
},
|
||||||
async linux (exec, { port }) {
|
async linux (exec, { port }) {
|
|
@ -34,7 +34,8 @@ class DarwinSystemShell extends SystemShell {
|
||||||
}
|
}
|
||||||
|
|
||||||
class WindowsSystemShell extends SystemShell {
|
class WindowsSystemShell extends SystemShell {
|
||||||
static async exec (cmds, { type = 'ps' }) {
|
static async exec (cmds, args = { type: 'ps' }) {
|
||||||
|
const { type } = args
|
||||||
if (cmds instanceof String) {
|
if (cmds instanceof String) {
|
||||||
cmds = [cmds]
|
cmds = [cmds]
|
||||||
}
|
}
|
||||||
|
@ -45,12 +46,11 @@ class WindowsSystemShell extends SystemShell {
|
||||||
})
|
})
|
||||||
|
|
||||||
for (const cmd of cmds) {
|
for (const cmd of cmds) {
|
||||||
console.log('ps:', cmd)
|
|
||||||
ps.addCommand(cmd)
|
ps.addCommand(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
const ret = await ps.invoke()
|
const ret = await ps.invoke()
|
||||||
console.log('ps complete:', ret)
|
console.log('ps complete:', cmds, ret)
|
||||||
return ret
|
return ret
|
||||||
} else {
|
} else {
|
||||||
let compose = 'chcp 65001 '
|
let compose = 'chcp 65001 '
|
||||||
|
|
|
@ -28,7 +28,7 @@ class WindowsSystemProxy extends SystemProxy {
|
||||||
ret = await winExec(`npm config set https-proxy=http://${ip}:${port}`)
|
ret = await winExec(`npm config set https-proxy=http://${ip}:${port}`)
|
||||||
console.log('npm https proxy set success', ret)
|
console.log('npm https proxy set success', ret)
|
||||||
|
|
||||||
ret = await winExec(`npm config set ca ${config.getDefaultCAKeyPath()}`)
|
ret = await winExec(`npm config set ca ${config.getDefaultCACertPath()}`)
|
||||||
console.log('npm cafile set success', ret)
|
console.log('npm cafile set success', ret)
|
||||||
|
|
||||||
// ret = await winExec('npm config set strict-ssl false')
|
// ret = await winExec('npm config set strict-ssl false')
|
||||||
|
|
|
@ -4,7 +4,6 @@ const childProcess = require('child_process')
|
||||||
const _exec = childProcess.exec
|
const _exec = childProcess.exec
|
||||||
const Registry = require('winreg')
|
const Registry = require('winreg')
|
||||||
// const cmd = require('node-cmd')
|
// const cmd = require('node-cmd')
|
||||||
console.log('childProcess', childProcess)
|
|
||||||
const exec = util.promisify(_exec)
|
const exec = util.promisify(_exec)
|
||||||
const refreshInternetPs = require('./refresh-internet')
|
const refreshInternetPs = require('./refresh-internet')
|
||||||
const Shell = require('node-powershell')
|
const Shell = require('node-powershell')
|
||||||
|
|
|
@ -29,7 +29,7 @@ class WindowsSystemProxy extends SystemProxy {
|
||||||
ret = await winExec(`yarn config set https-proxy=http://${ip}:${port}`)
|
ret = await winExec(`yarn config set https-proxy=http://${ip}:${port}`)
|
||||||
console.log('yarn https proxy set success', ret)
|
console.log('yarn https proxy set success', ret)
|
||||||
|
|
||||||
ret = await winExec(`yarn config set ca ${config.getDefaultCAKeyPath()}`)
|
ret = await winExec(`yarn config set ca ${config.getDefaultCACertPath()}`)
|
||||||
console.log('yarn cafile set success', ret)
|
console.log('yarn cafile set success', ret)
|
||||||
|
|
||||||
// ret = await winExec('yarn config set strict-ssl false')
|
// ret = await winExec('yarn config set strict-ssl false')
|
||||||
|
|
Before Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 584 B |
Before Width: | Height: | Size: 941 B |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 353 KiB |
|
@ -2372,6 +2372,16 @@
|
||||||
"integrity": "sha1-/q7SVZc9LndVW4PbwIhRpsY1IPo=",
|
"integrity": "sha1-/q7SVZc9LndVW4PbwIhRpsY1IPo=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"ansi-styles": {
|
||||||
|
"version": "4.3.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-4.3.0.tgz?cache=0&sync_timestamp=1601839122515&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-styles%2Fdownload%2Fansi-styles-4.3.0.tgz",
|
||||||
|
"integrity": "sha1-7dgDYornHATIWuegkG7a00tkiTc=",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"color-convert": "^2.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cacache": {
|
"cacache": {
|
||||||
"version": "13.0.1",
|
"version": "13.0.1",
|
||||||
"resolved": "https://registry.npm.taobao.org/cacache/download/cacache-13.0.1.tgz",
|
"resolved": "https://registry.npm.taobao.org/cacache/download/cacache-13.0.1.tgz",
|
||||||
|
@ -2398,6 +2408,34 @@
|
||||||
"unique-filename": "^1.1.1"
|
"unique-filename": "^1.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"chalk": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/chalk/download/chalk-4.1.0.tgz",
|
||||||
|
"integrity": "sha1-ThSHCmGNni7dl92DRf2dncMVZGo=",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"ansi-styles": "^4.1.0",
|
||||||
|
"supports-color": "^7.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"color-convert": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/color-convert/download/color-convert-2.0.1.tgz",
|
||||||
|
"integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"color-name": "~1.1.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"color-name": {
|
||||||
|
"version": "1.1.4",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/color-name/download/color-name-1.1.4.tgz",
|
||||||
|
"integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"find-cache-dir": {
|
"find-cache-dir": {
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
"resolved": "https://registry.npm.taobao.org/find-cache-dir/download/find-cache-dir-3.3.1.tgz",
|
"resolved": "https://registry.npm.taobao.org/find-cache-dir/download/find-cache-dir-3.3.1.tgz",
|
||||||
|
@ -2419,6 +2457,25 @@
|
||||||
"path-exists": "^4.0.0"
|
"path-exists": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"has-flag": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/has-flag/download/has-flag-4.0.0.tgz",
|
||||||
|
"integrity": "sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s=",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"loader-utils": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/loader-utils/download/loader-utils-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-5MrOW4FtQloWa18JfhDNErNgZLA=",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"big.js": "^5.2.2",
|
||||||
|
"emojis-list": "^3.0.0",
|
||||||
|
"json5": "^2.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"locate-path": {
|
"locate-path": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npm.taobao.org/locate-path/download/locate-path-5.0.0.tgz",
|
"resolved": "https://registry.npm.taobao.org/locate-path/download/locate-path-5.0.0.tgz",
|
||||||
|
@ -2483,6 +2540,16 @@
|
||||||
"minipass": "^3.1.1"
|
"minipass": "^3.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"supports-color": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/supports-color/download/supports-color-7.2.0.tgz?cache=0&sync_timestamp=1598611709087&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsupports-color%2Fdownload%2Fsupports-color-7.2.0.tgz",
|
||||||
|
"integrity": "sha1-G33NyzK4E4gBs+R4umpRyqiWSNo=",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"has-flag": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"terser-webpack-plugin": {
|
"terser-webpack-plugin": {
|
||||||
"version": "2.3.8",
|
"version": "2.3.8",
|
||||||
"resolved": "https://registry.npm.taobao.org/terser-webpack-plugin/download/terser-webpack-plugin-2.3.8.tgz?cache=0&sync_timestamp=1602701885709&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fterser-webpack-plugin%2Fdownload%2Fterser-webpack-plugin-2.3.8.tgz",
|
"resolved": "https://registry.npm.taobao.org/terser-webpack-plugin/download/terser-webpack-plugin-2.3.8.tgz?cache=0&sync_timestamp=1602701885709&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fterser-webpack-plugin%2Fdownload%2Fterser-webpack-plugin-2.3.8.tgz",
|
||||||
|
@ -2499,6 +2566,18 @@
|
||||||
"terser": "^4.6.12",
|
"terser": "^4.6.12",
|
||||||
"webpack-sources": "^1.4.3"
|
"webpack-sources": "^1.4.3"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"vue-loader-v16": {
|
||||||
|
"version": "npm:vue-loader@16.0.0-beta.9",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/vue-loader/download/vue-loader-16.0.0-beta.9.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-loader%2Fdownload%2Fvue-loader-16.0.0-beta.9.tgz",
|
||||||
|
"integrity": "sha1-UlEsthwpaCfJnA1UOYvvhL5ESPw=",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"chalk": "^4.1.0",
|
||||||
|
"hash-sum": "^2.0.0",
|
||||||
|
"loader-utils": "^2.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -16335,87 +16414,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vue-loader-v16": {
|
|
||||||
"version": "npm:vue-loader@16.0.0-beta.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.8.tgz",
|
|
||||||
"integrity": "sha512-oouKUQWWHbSihqSD7mhymGPX1OQ4hedzAHyvm8RdyHh6m3oIvoRF+NM45i/bhNOlo8jCnuJhaSUf/6oDjv978g==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"chalk": "^4.1.0",
|
|
||||||
"hash-sum": "^2.0.0",
|
|
||||||
"loader-utils": "^2.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"ansi-styles": {
|
|
||||||
"version": "4.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
|
||||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"color-convert": "^2.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"chalk": {
|
|
||||||
"version": "4.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
|
|
||||||
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"ansi-styles": "^4.1.0",
|
|
||||||
"supports-color": "^7.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-convert": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"color-name": "~1.1.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color-name": {
|
|
||||||
"version": "1.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
|
||||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"has-flag": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
|
||||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"loader-utils": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"big.js": "^5.2.2",
|
|
||||||
"emojis-list": "^3.0.0",
|
|
||||||
"json5": "^2.1.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"supports-color": {
|
|
||||||
"version": "7.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
|
||||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
|
||||||
"has-flag": "^4.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vue-ref": {
|
"vue-ref": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npm.taobao.org/vue-ref/download/vue-ref-2.0.0.tgz",
|
"resolved": "https://registry.npm.taobao.org/vue-ref/download/vue-ref-2.0.0.tgz",
|
||||||
|
|
|
@ -97,7 +97,6 @@ function _mergeConfig (defObj, newObj) {
|
||||||
delete newObj[key]
|
delete newObj[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('newObj', newObj)
|
|
||||||
return newObj
|
return newObj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
import config from '../../../config/index.json5'
|
|
||||||
export default config
|
|
|
@ -17,19 +17,24 @@
|
||||||
:style="{ height: '100%' }"
|
:style="{ height: '100%' }"
|
||||||
>
|
>
|
||||||
<a-tab-pane tab="拦截设置" key="1" >
|
<a-tab-pane tab="拦截设置" key="1" >
|
||||||
<vue-json-editor style="height:100%;" ref="editor" v-model="targetConfig.intercepts" :show-btns="false" :expandedOnStart="true" @json-change="onJsonChange" ></vue-json-editor>
|
<vue-json-editor style="height:100%;" ref="editor" v-model="targetConfig.intercepts" mode="code" :show-btns="false" :expandedOnStart="true" @json-change="onJsonChange" ></vue-json-editor>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane tab="DNS设置" key="2">
|
<a-tab-pane tab="DNS设置" key="2">
|
||||||
<div>
|
<div>
|
||||||
<div>某些域名有时候需要通过其他DNS服务器获取到的IP才可以访问</div>
|
<div>某些域名有时候需要通过其他DNS服务器获取到的IP才可以访问</div>
|
||||||
|
<a-row style="margin-top:10px">
|
||||||
|
<a-col>
|
||||||
|
<a-button type="primary" icon="plus" @click="addDnsMapping()" />
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
<a-row :gutter="10" style="margin-top: 10px" v-for="(item,index) of dnsMappings" :key = 'index'>
|
<a-row :gutter="10" style="margin-top: 10px" v-for="(item,index) of dnsMappings" :key = 'index'>
|
||||||
<a-col :span="14">
|
<a-col :span="14">
|
||||||
<a-input :disabled="item.value ===false" v-model="item.key"></a-input>
|
<a-input :disabled="item.value ===false" v-model="item.key"></a-input>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="5">
|
<a-col :span="5">
|
||||||
<a-select :disabled="item.value ===false" v-model="item.value">
|
<a-select :disabled="item.value ===false" v-model="item.value">
|
||||||
<a-select-option value="usa">USA</a-select-option>
|
<a-select-option value="usa">USA DNS</a-select-option>
|
||||||
<a-select-option value="aliyun">Aliyun</a-select-option>
|
<a-select-option value="aliyun">Aliyun DNS</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="3">
|
<a-col :span="3">
|
||||||
|
@ -37,28 +42,24 @@
|
||||||
<a-button v-if="item.value===false" style="margin-left:10px" type="primary" icon="checked" @click="restoreDefDnsMapping(item,index)" ></a-button>
|
<a-button v-if="item.value===false" style="margin-left:10px" type="primary" icon="checked" @click="restoreDefDnsMapping(item,index)" ></a-button>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
<a-row style="margin-top:10px">
|
|
||||||
<a-col>
|
|
||||||
<a-button type="primary" icon="plus" @click="addDnsMapping()" />
|
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
</div>
|
</div>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane tab="镜像变量" key="3">
|
<a-tab-pane tab="环境变量" key="3">
|
||||||
<div>
|
<div>
|
||||||
<div>某些库需要自己设置代理环境变量,才能安装,比如:electron</div>
|
<div>某些库需要自己设置镜像变量,才能下载,比如:electron</div>
|
||||||
<div>
|
<div>
|
||||||
<a-form-item label="镜像环境变量" >
|
<a-form-item label="镜像环境变量" >
|
||||||
<a-switch v-model="targetConfig.setting.startup.mirrors.set" default-checked v-on:click="(checked)=>{targetConfig.setting.startup.mirrors.set = checked}">
|
<a-switch v-model="targetConfig.setting.startup.variables.npm" default-checked v-on:click="(checked)=>{targetConfig.setting.startup.variables.npm = checked}">
|
||||||
<a-icon slot="checkedChildren" type="check" />
|
<a-icon slot="checkedChildren" type="check" />
|
||||||
<a-icon slot="unCheckedChildren" type="close" />
|
<a-icon slot="unCheckedChildren" type="close" />
|
||||||
</a-switch>
|
</a-switch>
|
||||||
启动后自动检查设置
|
启动后自动检查设置
|
||||||
|
|
||||||
<a-button style="margin-left:10px" @click="doSetMirrorEnvNow">立即设置</a-button>
|
<a-button style="margin-left:10px" @click="doSetNpmVariablesNow">立即设置</a-button>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</div>
|
</div>
|
||||||
<a-row :gutter="10" style="margin-top: 10px" v-for="(item,index) of mirrorEnvs" :key = 'index'>
|
<a-row :gutter="10" style="margin-top: 10px" v-for="(item,index) of npmVariables" :key = 'index'>
|
||||||
<a-col :span="10">
|
<a-col :span="10">
|
||||||
<a-input :disabled="item.key ===false" v-model="item.key"></a-input>
|
<a-input :disabled="item.key ===false" v-model="item.key"></a-input>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
@ -121,7 +122,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
targetConfig: {},
|
targetConfig: {},
|
||||||
dnsMappings: [],
|
dnsMappings: [],
|
||||||
mirrorEnvs: []
|
npmVariables: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
|
@ -139,8 +140,8 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
api.config.getMirrorEnv().then(ret => {
|
api.config.getVariables('npm').then(ret => {
|
||||||
this.mirrorEnvs = ret
|
this.npmVariables = ret
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onJsonChange (config) {
|
onJsonChange (config) {
|
||||||
|
@ -159,6 +160,8 @@ export default {
|
||||||
this.$confirm({
|
this.$confirm({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '是否需要保存?',
|
content: '是否需要保存?',
|
||||||
|
cancelText: '取消',
|
||||||
|
okText: '确定',
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
this.doSave()
|
this.doSave()
|
||||||
},
|
},
|
||||||
|
@ -175,11 +178,11 @@ export default {
|
||||||
}
|
}
|
||||||
this.targetConfig.dns.mapping = mapping
|
this.targetConfig.dns.mapping = mapping
|
||||||
|
|
||||||
const mirrors = {}
|
const variables = {}
|
||||||
for (const item of this.mirrorEnvs) {
|
for (const item of this.npmVariables) {
|
||||||
mirrors[item.key] = item.value
|
variables[item.key] = item.value
|
||||||
}
|
}
|
||||||
this.targetConfig.mirrors = mirrors
|
this.targetConfig.variables.npm = variables
|
||||||
},
|
},
|
||||||
isChanged () {
|
isChanged () {
|
||||||
this.syncTargetConfig()
|
this.syncTargetConfig()
|
||||||
|
@ -197,22 +200,22 @@ export default {
|
||||||
|
|
||||||
},
|
},
|
||||||
addDnsMapping () {
|
addDnsMapping () {
|
||||||
this.dnsMappings.push({ key: '', value: 'usa' })
|
this.dnsMappings.unshift({ key: '', value: 'usa' })
|
||||||
},
|
},
|
||||||
doSetMirrorEnvNow () {
|
doSetNpmVariablesNow () {
|
||||||
this.syncTargetConfig()
|
this.syncTargetConfig()
|
||||||
this.doSave().then(() => {
|
this.doSave().then(() => {
|
||||||
return api.config.setupMirrors()
|
return api.config.setVariables('npm')
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return api.config.getMirrorEnv().then(ret => {
|
return api.config.getVariables('npm').then(ret => {
|
||||||
this.mirrorEnvs = ret
|
this.npmVariables = ret
|
||||||
})
|
})
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$message.info('设置成功')
|
this.$message.info('设置成功')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addMirrors () {
|
addNpmVariable () {
|
||||||
this.mirrorEnvs.push({ key: '', value: '', exists: false })
|
this.npmVariables.push({ key: '', value: '', exists: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|