mirror of https://github.com/certd/certd
refactor: fix
parent
b9d5d33aaa
commit
6eb9817296
|
@ -1,6 +1,6 @@
|
|||
export class Registry {
|
||||
constructor () {
|
||||
this.collection = {}
|
||||
this.collection = new Map()
|
||||
}
|
||||
|
||||
install (target) {
|
||||
|
@ -8,7 +8,7 @@ export class Registry {
|
|||
return
|
||||
}
|
||||
if (this.collection == null) {
|
||||
this.collection = {}
|
||||
this.collection = new Map()
|
||||
}
|
||||
let defineName = target.define ? target.define().name : null
|
||||
if (defineName == null) {
|
||||
|
@ -22,14 +22,18 @@ export class Registry {
|
|||
if (!key || value == null) {
|
||||
return
|
||||
}
|
||||
this.collection[key] = value
|
||||
this.collection.set(key, value)
|
||||
}
|
||||
|
||||
get (name) {
|
||||
if (name) {
|
||||
return this.collection[name]
|
||||
return this.collection.get(name)
|
||||
}
|
||||
|
||||
throw new Error(`${name} not found`)
|
||||
}
|
||||
|
||||
getCollection () {
|
||||
return this.collection
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import { CertStore } from './store/cert-store.js'
|
|||
import dayjs from 'dayjs'
|
||||
import forge from 'node-forge'
|
||||
import DefaultDnsProviders from '@certd/dns-providers'
|
||||
|
||||
const logger = util.logger
|
||||
|
||||
DefaultDnsProviders.install()
|
||||
|
@ -125,11 +126,10 @@ export class Certd {
|
|||
|
||||
createProviderByType (props, accessProviders) {
|
||||
const { type } = props
|
||||
try {
|
||||
const Provider = dnsProviderRegistry.get(type)
|
||||
return new Provider({ accessProviders, props })
|
||||
} catch (e) {
|
||||
throw new Error('暂不支持此dnsProvider,请先注册该provider:' + type, e)
|
||||
const Provider = dnsProviderRegistry.get(type)
|
||||
if (Provider == null) {
|
||||
throw new Error('暂不支持此dnsProvider,请先注册该provider:' + type)
|
||||
}
|
||||
return new Provider({ accessProviders, props })
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,6 +28,7 @@ export class Executor {
|
|||
async run (options) {
|
||||
logger.info('------------------- Cert-D ---------------------')
|
||||
try {
|
||||
this.transferToSafetyOptions(options)
|
||||
options = _.merge(createDefaultOptions(), options)
|
||||
return await this.doRun(options)
|
||||
} catch (e) {
|
||||
|
|
|
@ -1,7 +1,22 @@
|
|||
import { request } from './service'
|
||||
import _ from 'lodash-es'
|
||||
function arrayToMap (arr) {
|
||||
if (arr && arr instanceof Array) {
|
||||
const map = {}
|
||||
_.forEach(arr, item => {
|
||||
map[item.key] = item
|
||||
})
|
||||
return map
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
function transfer (options) {
|
||||
options.accessProviders = arrayToMap(options.accessProviders)
|
||||
}
|
||||
export default {
|
||||
exportsToZip (options) {
|
||||
transfer(options)
|
||||
return request({
|
||||
url: '/exports/toZip',
|
||||
data: { options },
|
||||
|
|
Loading…
Reference in New Issue