Skip to content

Commit

Permalink
代码格式调整:packages/core/**/*.js
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Nov 15, 2024
1 parent 6c22713 commit 48132c3
Show file tree
Hide file tree
Showing 40 changed files with 327 additions and 311 deletions.
2 changes: 1 addition & 1 deletion packages/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module.exports = require('./src')
// TODO 这是一个解谜游戏 ↓ ↓ ↓ ↓ ↓ ↓ ,如果你破解了它,请不要公开,好好用它来学习和查资料吧(特别注意:为了你的人身安全,请不要用它来查看和发表不当言论,你懂得)。
/**
\u0061\u0048\u0052\u0030\u0063\u0044\u006f\u0076\u004c\u0032\u0052\u006c\u0064\u0069\u0031\u007a\u0061\u0057\u0052\u006c\u0059\u0032\u0046\u0079\u004c\u006d\u0052\u0076\u0059\u0032\u0031\u0070\u0063\u006e\u004a\u0076\u0063\u0069\u0035\u006a\u0062\u0069\u0039\u0035\u0062\u0033\u0056\u006d\u0061\u0057\u0035\u006b\u0061\u0058\u0051\u0076\u0061\u0057\u0035\u006b\u005a\u0058\u0067\u0075\u0061\u0048\u0052\u0074\u0062\u0041\u003d\u003d
**/
*/
// 这个项目里有一点点解谜提示: https://github.com/fast-crud/fast-crud (打开拉到最下面)
30 changes: 15 additions & 15 deletions packages/core/src/config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const fs = require('fs')
const Shell = require('./shell')
const lodash = require('lodash')
const defConfig = require('./config/index.js')
const path = require('path')
const jsonApi = require('@docmirror/mitmproxy/src/json')
const lodash = require('lodash')
const request = require('request')
const path = require('path')
const log = require('./utils/util.log')
const defConfig = require('./config/index.js')
const mergeApi = require('./merge.js')
const Shell = require('./shell')
const log = require('./utils/util.log')

let configTarget = lodash.cloneDeep(defConfig)

Expand Down Expand Up @@ -80,13 +80,13 @@ const configApi = {
configApi.deleteRemoteConfigFile(suffix)
return
}
// eslint-disable-next-line handle-callback-err

return new Promise((resolve, reject) => {
log.info('开始下载远程配置:', remoteConfigUrl)

const headers = {
'Cache-Control': 'no-cache', // 禁止使用缓存
Pragma: 'no-cache' // 禁止使用缓存
'Pragma': 'no-cache', // 禁止使用缓存
}
if (remoteConfigUrl.startsWith('https://raw.githubusercontent.com/')) {
headers['Server-Name'] = 'baidu.com'
Expand Down Expand Up @@ -131,7 +131,7 @@ const configApi = {
if (response) {
message = `下载远程配置失败: ${remoteConfigUrl}, message: ${response.message}, code: ${response.statusCode}`
} else {
message = '下载远程配置失败: response: ' + response
message = `下载远程配置失败: response: ${response}`
}
reject(new Error(message))
}
Expand Down Expand Up @@ -205,7 +205,7 @@ const configApi = {

return {
diffConfig,
allConfig
allConfig,
}
},
doMerge: mergeApi.doMerge,
Expand Down Expand Up @@ -330,31 +330,31 @@ const configApi = {
list.push({
key,
value: map[key],
exists
exists,
})
}
return list
},
async setVariables (type) {
const list = await configApi.getVariables(type)
const noSetList = list.filter(item => {
const noSetList = list.filter((item) => {
return !item.exists
})
if (list.length > 0) {
const context = {
root_ca_cert_path: configApi.get().server.setting.rootCaFile.certPath
root_ca_cert_path: configApi.get().server.setting.rootCaFile.certPath,
}
for (const item of noSetList) {
if (item.value.indexOf('${') >= 0) {
if (item.value.includes('${')) {
for (const key in context) {
item.value = item.value.replcace(new RegExp('${' + key + '}', 'g'), context[key])
item.value = item.value.replcace(new RegExp(`\${${key}}`, 'g'), context[key])
}
}
}
const method = type === 'npm' ? Shell.setNpmEnv : Shell.setSystemEnv
return method({ list: noSetList })
}
}
},
}

module.exports = configApi
Loading

0 comments on commit 48132c3

Please sign in to comment.