diff --git a/packages/core/certd/.eslintrc b/packages/core/certd/.eslintrc deleted file mode 100644 index c6ce67f2..00000000 --- a/packages/core/certd/.eslintrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "standard", - "env": { - "mocha": true - }, - "overrides": [ - { - "files": ["*.test.js", "*.spec.js"], - "rules": { - "no-unused-expressions": "off" - } - } - ] -} diff --git a/packages/core/certd/.gitignore b/packages/core/certd/.gitignore deleted file mode 100644 index cbb386fa..00000000 --- a/packages/core/certd/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.vscode/ -node_modules/ -npm-debug.log -yarn-error.log -yarn.lock -package-lock.json -/.idea/ diff --git a/packages/core/certd/package.json b/packages/core/certd/package.json deleted file mode 100644 index a63abd35..00000000 --- a/packages/core/certd/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@certd/certd", - "version": "0.3.0", - "description": "a ssl cert keeper", - "main": "src/index.js", - "scripts": { - "test": "echo \\\"Error: no test specified\\\" && exit 1" - }, - "type": "module", - "author": "Greper", - "license": "MIT", - "dependencies": { - "@certd/acme-client": "^0.3.0", - "@certd/api": "^0.3.0", - "dayjs": "^1.9.7", - "lodash-es": "^4.17.20", - "node-forge": "^0.10.0" - }, - "devDependencies": { - "chai": "^4.2.0", - "eslint": "^7.15.0", - "eslint-config-standard": "^16.0.2", - "eslint-plugin-import": "^2.22.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.2.1", - "mocha": "^8.2.1" - }, - "gitHead": "5fbd7742665c0a949333d805153e9b6af91c0a71" -} diff --git a/packages/core/certd/src/acme.js b/packages/core/certd/src/acme.js deleted file mode 100644 index 6ad6a64d..00000000 --- a/packages/core/certd/src/acme.js +++ /dev/null @@ -1,202 +0,0 @@ -import acme from '@certd/acme-client' -import _ from 'lodash-es' -import { util } from '@certd/api' -const logger = util.logger -export class AcmeService { - constructor (store) { - this.store = store - acme.setLogger((text) => { - logger.info(text) - }) - } - - async getAccountConfig (email) { - let conf = this.store.get(this.buildAccountPath(email)) - if (conf == null) { - conf = {} - } else { - conf = JSON.parse(conf) - } - return conf - } - - buildAccountPath (email) { - return this.store.buildKey(email, 'account.json') - } - - saveAccountConfig (email, conf) { - this.store.set(this.buildAccountPath(email), JSON.stringify(conf)) - } - - async getAcmeClient (email, isTest) { - const conf = await this.getAccountConfig(email) - if (conf.key == null) { - conf.key = await this.createNewKey() - this.saveAccountConfig(email, conf) - } - if (isTest == null) { - isTest = process.env.CERTD_MODE === 'test' - } - const client = new acme.Client({ - directoryUrl: isTest ? acme.directory.letsencrypt.staging : acme.directory.letsencrypt.production, - accountKey: conf.key, - accountUrl: conf.accountUrl, - backoffAttempts: 20, - backoffMin: 5000, - backoffMax: 10000 - }) - - if (conf.accountUrl == null) { - const accountPayload = { termsOfServiceAgreed: true, contact: [`mailto:${email}`] } - await client.createAccount(accountPayload) - conf.accountUrl = client.getAccountUrl() - this.saveAccountConfig(email, conf) - } - return client - } - - async createNewKey () { - const key = await acme.forge.createPrivateKey() - return key.toString() - } - - async challengeCreateFn (authz, challenge, keyAuthorization, dnsProvider) { - logger.info('Triggered challengeCreateFn()') - - /* http-01 */ - if (challenge.type === 'http-01') { - const filePath = `/var/www/html/.well-known/acme-challenge/${challenge.token}` - const fileContents = keyAuthorization - - logger.info(`Creating challenge response for ${authz.identifier.value} at path: ${filePath}`) - - /* Replace this */ - logger.info(`Would write "${fileContents}" to path "${filePath}"`) - // await fs.writeFileAsync(filePath, fileContents); - } else if (challenge.type === 'dns-01') { - /* dns-01 */ - const dnsRecord = `_acme-challenge.${authz.identifier.value}` - const recordValue = keyAuthorization - - logger.info(`Creating TXT record for ${authz.identifier.value}: ${dnsRecord}`) - - /* Replace this */ - logger.info(`Would create TXT record "${dnsRecord}" with value "${recordValue}"`) - - return await dnsProvider.createRecord({ - fullRecord: dnsRecord, - type: 'TXT', - value: recordValue - }) - } - } - - /** - * Function used to remove an ACME challenge response - * - * @param {object} authz Authorization object - * @param {object} challenge Selected challenge - * @param {string} keyAuthorization Authorization key - * @param recordItem challengeCreateFn create record item - * @param dnsProvider dnsProvider - * @returns {Promise} - */ - - async challengeRemoveFn (authz, challenge, keyAuthorization, recordItem, dnsProvider) { - logger.info('Triggered challengeRemoveFn()') - - /* http-01 */ - if (challenge.type === 'http-01') { - const filePath = `/var/www/html/.well-known/acme-challenge/${challenge.token}` - - logger.info(`Removing challenge response for ${authz.identifier.value} at path: ${filePath}`) - - /* Replace this */ - logger.info(`Would remove file on path "${filePath}"`) - // await fs.unlinkAsync(filePath); - } else if (challenge.type === 'dns-01') { - const dnsRecord = `_acme-challenge.${authz.identifier.value}` - const recordValue = keyAuthorization - - logger.info(`Removing TXT record for ${authz.identifier.value}: ${dnsRecord}`) - - /* Replace this */ - logger.info(`Would remove TXT record "${dnsRecord}" with value "${recordValue}"`) - await dnsProvider.removeRecord({ - fullRecord: dnsRecord, - type: 'TXT', - value: keyAuthorization, - record: recordItem - }) - } - } - - async order ({ email, domains, dnsProvider, dnsProviderCreator, csrInfo, isTest }) { - const client = await this.getAcmeClient(email, isTest) - - let accountUrl - try { - accountUrl = client.getAccountUrl() - } catch (e) { - } - - /* Create CSR */ - const { commonName, altNames } = this.buildCommonNameByDomains(domains) - - const [key, csr] = await acme.forge.createCsr({ - commonName, - ...csrInfo, - altNames - }) - if (dnsProvider == null && dnsProviderCreator) { - dnsProvider = await dnsProviderCreator() - } - if (dnsProvider == null) { - throw new Error('dnsProvider 不能为空') - } - /* 自动申请证书 */ - const crt = await client.auto({ - csr, - email: email, - termsOfServiceAgreed: true, - challengePriority: ['dns-01'], - challengeCreateFn: async (authz, challenge, keyAuthorization) => { - return await this.challengeCreateFn(authz, challenge, keyAuthorization, dnsProvider) - }, - challengeRemoveFn: async (authz, challenge, keyAuthorization, recordItem) => { - return await this.challengeRemoveFn(authz, challenge, keyAuthorization, recordItem, dnsProvider) - } - }) - - // 保存账号url - if (!accountUrl) { - try { - accountUrl = client.getAccountUrl() - this.setAccountUrl(email, accountUrl) - } catch (e) { - logger.warn('保存accountUrl出错', e) - } - } - /* Done */ - logger.debug(`CSR:\n${csr.toString()}`) - logger.debug(`Certificate:\n${crt.toString()}`) - logger.info('证书申请成功') - return { key, crt, csr } - } - - buildCommonNameByDomains (domains) { - if (typeof domains === 'string') { - domains = domains.split(',') - } - if (domains.length === 0) { - throw new Error('domain can not be empty') - } - const ret = { - commonName: domains[0] - } - if (domains.length > 1) { - ret.altNames = _.slice(domains, 1) - } - return ret - } -} diff --git a/packages/core/certd/src/index.js b/packages/core/certd/src/index.js deleted file mode 100644 index 41dbdcb3..00000000 --- a/packages/core/certd/src/index.js +++ /dev/null @@ -1,131 +0,0 @@ -import { util, Store, dnsProviderRegistry } from '@certd/api' -import { AcmeService } from './acme.js' -import { FileStore } from './store/file-store.js' -import { CertStore } from './store/cert-store.js' -import dayjs from 'dayjs' -import forge from 'node-forge' - -const logger = util.logger -export class Certd { - constructor (options) { - this.options = options - this.email = options.cert.email - this.domains = options.cert.domains - - if (!(options.store instanceof Store)) { - this.store = new FileStore(options.store || {}) - } - this.certStore = new CertStore({ - store: this.store, - email: options.cert.email, - domains: this.domains - }) - this.acme = new AcmeService(this.store) - } - - async certApply () { - let oldCert - try { - oldCert = await this.readCurrentCert() - } catch (e) { - logger.warn('读取cert失败:', e) - } - - if (oldCert == null) { - logger.info('还未申请过,准备申请新证书') - } else { - const ret = this.isWillExpire(oldCert.expires, this.options.cert.renewDays) - if (!ret.isWillExpire) { - logger.info('证书还未过期:', oldCert.expires, ',剩余', ret.leftDays, '天') - if (this.options.args.forceCert) { - logger.info('准备强制更新证书') - } else { - logger.info('暂不更新证书') - - oldCert.isNew = false - return oldCert - } - } else { - logger.info('即将过期,准备更新证书') - } - } - - // 执行证书申请步骤 - return await this.doCertApply() - } - - async doCertApply () { - const options = this.options - const dnsProvider = this.createDnsProvider(options) - const cert = await this.acme.order({ - email: options.cert.email, - domains: options.cert.domains, - dnsProvider, - csrInfo: options.cert.csrInfo, - isTest: options.args.test - }) - - await this.writeCert(cert) - const certRet = await this.readCurrentCert() - certRet.isNew = true - return certRet - } - - createDnsProvider (options) { - return this.createProviderByType(options.cert.dnsProvider, options.accessProviders) - } - - async writeCert (cert) { - const newPath = await this.certStore.writeCert(cert) - return { - realPath: this.certStore.store.getActualKey(newPath), - currentPath: this.certStore.store.getActualKey(this.certStore.currentMarkPath) - } - } - - async readCurrentCert () { - const cert = await this.certStore.readCert() - if (cert == null) { - return null - } - const { detail, expires } = this.getCrtDetail(cert.crt) - const domain = this.certStore.getMainDomain(this.options.cert.domains) - return { - ...cert, detail, expires, domain, domains: this.domains, email: this.email - } - } - - getCrtDetail (crt) { - const pki = forge.pki - const detail = pki.certificateFromPem(crt.toString()) - const expires = detail.validity.notAfter - return { detail, expires } - } - - /** - * 检查是否过期,默认提前20天 - * @param expires - * @param maxDays - * @returns {boolean} - */ - isWillExpire (expires, maxDays = 20) { - if (expires == null) { - throw new Error('过期时间不能为空') - } - // 检查有效期 - const leftDays = dayjs(expires).diff(dayjs(), 'day') - return { - isWillExpire: leftDays < maxDays, - leftDays - } - } - - createProviderByType (props, accessProviders) { - const { type } = props - const Provider = dnsProviderRegistry.get(type) - if (Provider == null) { - throw new Error('暂不支持此dnsProvider,请先注册该provider:' + type) - } - return new Provider({ accessProviders, props }) - } -} diff --git a/packages/core/certd/src/store/cert-store.js b/packages/core/certd/src/store/cert-store.js deleted file mode 100644 index b4ea4ee0..00000000 --- a/packages/core/certd/src/store/cert-store.js +++ /dev/null @@ -1,127 +0,0 @@ -import dayjs from 'dayjs' -import crypto from 'crypto' -// eslint-disable-next-line no-unused-vars -function md5 (content) { - return crypto.createHash('md5').update(content).digest('hex') -} -export class CertStore { - constructor ({ store, email, domains }) { - this.store = store - this.email = email - this.domains = domains - this.domain = this.getMainDomain(this.domains) - this.safetyDomain = this.getSafetyDomain(this.domain) - this.domainDir = this.safetyDomain + '-' + md5(this.getDomainStr(this.domains)) - // this.domainDir = this.safetyDomain - this.certsRootPath = this.store.buildKey(this.email, 'certs') - - this.currentMarkPath = this.store.buildKey(this.certsRootPath, this.domainDir, 'current.json') - } - - getMainDomain (domains) { - if (domains == null) { - return null - } - if (typeof domains === 'string') { - return domains - } - if (domains.length > 0) { - return domains[0] - } - } - - getDomainStr (domains) { - if (domains == null) { - return null - } - if (typeof domains === 'string') { - return domains - } - return domains.join(',') - } - - buildNewCertRootPath (dir) { - if (dir == null) { - dir = dayjs().format('YYYY.MM.DD.HHmmss') - } - return this.store.buildKey(this.certsRootPath, this.domainDir, dir) - } - - formatCert (pem) { - pem = pem.replace(/\r/g, '') - pem = pem.replace(/\n\n/g, '\n') - pem = pem.replace(/\n$/g, '') - return pem - } - - async writeCert (cert) { - const newDir = this.buildNewCertRootPath() - - const crtKey = this.buildKey(newDir, this.safetyDomain + '.crt') - const priKey = this.buildKey(newDir, this.safetyDomain + '.key') - const csrKey = this.buildKey(newDir, this.safetyDomain + '.csr') - await this.store.set(crtKey, this.formatCert(cert.crt.toString())) - await this.store.set(priKey, this.formatCert(cert.key.toString())) - await this.store.set(csrKey, cert.csr.toString()) - - await this.store.set(this.currentMarkPath, JSON.stringify({ latest: newDir })) - - return newDir - } - - async readCert (dir) { - if (dir == null) { - dir = await this.getCurrentDir() - } - if (dir == null) { - return - } - - const crtKey = this.buildKey(dir, this.safetyDomain + '.crt') - const priKey = this.buildKey(dir, this.safetyDomain + '.key') - const csrKey = this.buildKey(dir, this.safetyDomain + '.csr') - const crt = await this.store.get(crtKey) - if (crt == null) { - return null - } - const key = await this.store.get(priKey) - const csr = await this.store.get(csrKey) - - return { - crt: this.formatCert(crt), - key: this.formatCert(key), - csr, - crtPath: this.store.getActualKey(crtKey), - keyPath: this.store.getActualKey(priKey), - certDir: this.store.getActualKey(dir) - } - } - - buildKey (...keyItem) { - return this.store.buildKey(...keyItem) - } - - getSafetyDomain (domain) { - return domain.replace(/\*/g, '_') - } - - async getCurrentDir () { - const current = await this.store.get(this.currentMarkPath) - if (current == null) { - return null - } - return JSON.parse(current).latest - } - - async getCurrentFile (file) { - const currentDir = await this.getCurrentDir() - const key = this.buildKey(currentDir, file) - return this.store.get(key) - } - - async setCurrentFile (file, value) { - const currentDir = await this.getCurrentDir() - const key = this.buildKey(currentDir, file) - return this.store.set(key, value) - } -} diff --git a/packages/core/certd/src/store/file-store.js b/packages/core/certd/src/store/file-store.js deleted file mode 100644 index 3233aeb1..00000000 --- a/packages/core/certd/src/store/file-store.js +++ /dev/null @@ -1,66 +0,0 @@ -import { Store, util } from '@certd/api' -import path from 'path' -import fs from 'fs' -const logger = util.logger -export class FileStore extends Store { - constructor (opts) { - super() - if (opts.rootDir != null) { - this.rootDir = opts.rootDir - } else { - this.rootDir = util.path.getUserBasePath() - } - if (opts.test) { - this.rootDir = path.join(this.rootDir, '/test/') - } - } - - getActualKey (key) { - // return 前缀+key - return this.getPathByKey(key) - } - - buildKey (...keyItem) { - return path.join(...keyItem) - } - - getPathByKey (key) { - return path.join(this.rootDir, key) - } - - set (key, value) { - const filePath = this.getPathByKey(key) - const dir = path.dirname(filePath) - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir, { recursive: true }) - } - fs.writeFileSync(filePath, value) - return filePath - } - - get (key) { - const filePath = this.getPathByKey(key) - if (!fs.existsSync(filePath)) { - return null - } - return fs.readFileSync(filePath).toString() - } - - link (targetPath, linkPath) { - targetPath = this.getPathByKey(targetPath) - linkPath = this.getPathByKey(linkPath) - if (fs.existsSync(linkPath)) { - try { - fs.unlinkSync(linkPath) - } catch (e) { - logger.error('unlink error:', e) - } - } - fs.symlinkSync(targetPath, linkPath, 'dir') - } - - unlink (linkPath) { - linkPath = this.getPathByKey(linkPath) - fs.unlinkSync(linkPath) - } -} diff --git a/packages/core/certd/test/index.test.js b/packages/core/certd/test/index.test.js deleted file mode 100644 index ca5b4bce..00000000 --- a/packages/core/certd/test/index.test.js +++ /dev/null @@ -1,88 +0,0 @@ -import chai from 'chai' -import { Certd } from '../src/index.js' -import { createOptions } from '../../../../test/options.js' -const { expect } = chai -const fakeCrt = `-----BEGIN CERTIFICATE----- -MIIFSTCCBDGgAwIBAgITAPoZZk/LhVIyXoic2NnJyxubezANBgkqhkiG9w0BAQsF -ADAiMSAwHgYDVQQDDBdGYWtlIExFIEludGVybWVkaWF0ZSBYMTAeFw0yMDEyMTQx -NjA1NTFaFw0yMTAzMTQxNjA1NTFaMBsxGTAXBgNVBAMMECouZG9jbWlycm9yLmNs -dWIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC75tGrYjly+RpcZehQ -my1EpaXElT4L60pINKV2YDKnBrcSSo1c6rO7nFh12eC/ju4WwYUep0RVmBDF8xD0 -I1Sd1uuDTQWP0UT1X9yqdXtjvxpUqoCHAzG633f3sJRFul7mDLuC9tRCuae9o7qP -EZ827XOmjBR35dso9I2GEE4828J3YE3tSKtobZlM+30jozLEcsO0PTyM5mq5PPjP -VI3fGLcEaBmLZf5ixz4XkcY9IAhyAMYf03cT2wRoYPBaDdXblgCYL6sFtIMbzl3M -Di94PB8NyoNSsC2nmBdWi54wFOgBvY/4ljsX/q7X3EqlSvcA0/M6/c/J9kJ3eupv -jV8nAgMBAAGjggJ9MIICeTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYB -BQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFAkdTjSCV3KD -x28sf98MrwVfyFYgMB8GA1UdIwQYMBaAFMDMA0a5WCDMXHJw8+EuyyCm9Wg6MHcG -CCsGAQUFBwEBBGswaTAyBggrBgEFBQcwAYYmaHR0cDovL29jc3Auc3RnLWludC14 -MS5sZXRzZW5jcnlwdC5vcmcwMwYIKwYBBQUHMAKGJ2h0dHA6Ly9jZXJ0LnN0Zy1p -bnQteDEubGV0c2VuY3J5cHQub3JnLzArBgNVHREEJDAighAqLmRvY21pcnJvci5j -bHVigg5kb2NtaXJyb3IuY2x1YjBMBgNVHSAERTBDMAgGBmeBDAECATA3BgsrBgEE -AYLfEwEBATAoMCYGCCsGAQUFBwIBFhpodHRwOi8vY3BzLmxldHNlbmNyeXB0Lm9y -ZzCCAQQGCisGAQQB1nkCBAIEgfUEgfIA8AB1ABboacHRlerXw/iXGuPwdgH3jOG2 -nTGoUhi2g38xqBUIAAABdmI3LM4AAAQDAEYwRAIgaiNqXSEq+sxp8eqlJXp/KFdO -so5mT50MoRsLF8Inu0ACIDP46+ekng7I0BlmyIPmbqFcZgnZFVWLLCdLYijhVyOL -AHcA3Zk0/KXnJIDJVmh9gTSZCEmySfe1adjHvKs/XMHzbmQAAAF2YjcuxwAABAMA -SDBGAiEAxpeB8/w4YkHZ62nH20h128VtuTSmYDCnF7EK2fQyeZYCIQDbJlF2wehZ -sF1BeE7qnYYqCTP0dYIrQ9HWtBa/MbGOKTANBgkqhkiG9w0BAQsFAAOCAQEAL2di -HKh6XcZtGk0BFxJa51sCZ3MLu9+Zy90kCRD4ooP5x932WxVM25+LBRd+xSzx+TRL -UVrlKp9GdMYX1JXL4Vf2NwzuFO3snPDe/qizD/3+D6yo8eKJ/LD82t5kLWAD2rto -YfVSTKwfNIBBJwHUnjviBPJmheHHCKmz8Ct6/6QxFAeta9TAMn0sFeVCQnmAq7HL -jrunq0tNHR/EKG0ITPLf+6P7MxbmpYNnq918766l0tKsW8oo8ZSGEwKU2LMaSiAa -hasyl/2gMnYXjtKOjDcnR8oLpbrOg0qpVbynmJin1HP835oHPPAZ1gLsqYTTizNz -AHxTaXliTVvS83dogw== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEqzCCApOgAwIBAgIRAIvhKg5ZRO08VGQx8JdhT+UwDQYJKoZIhvcNAQELBQAw -GjEYMBYGA1UEAwwPRmFrZSBMRSBSb290IFgxMB4XDTE2MDUyMzIyMDc1OVoXDTM2 -MDUyMzIyMDc1OVowIjEgMB4GA1UEAwwXRmFrZSBMRSBJbnRlcm1lZGlhdGUgWDEw -ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDtWKySDn7rWZc5ggjz3ZB0 -8jO4xti3uzINfD5sQ7Lj7hzetUT+wQob+iXSZkhnvx+IvdbXF5/yt8aWPpUKnPym -oLxsYiI5gQBLxNDzIec0OIaflWqAr29m7J8+NNtApEN8nZFnf3bhehZW7AxmS1m0 -ZnSsdHw0Fw+bgixPg2MQ9k9oefFeqa+7Kqdlz5bbrUYV2volxhDFtnI4Mh8BiWCN -xDH1Hizq+GKCcHsinDZWurCqder/afJBnQs+SBSL6MVApHt+d35zjBD92fO2Je56 -dhMfzCgOKXeJ340WhW3TjD1zqLZXeaCyUNRnfOmWZV8nEhtHOFbUCU7r/KkjMZO9 -AgMBAAGjgeMwgeAwDgYDVR0PAQH/BAQDAgGGMBIGA1UdEwEB/wQIMAYBAf8CAQAw -HQYDVR0OBBYEFMDMA0a5WCDMXHJw8+EuyyCm9Wg6MHoGCCsGAQUFBwEBBG4wbDA0 -BggrBgEFBQcwAYYoaHR0cDovL29jc3Auc3RnLXJvb3QteDEubGV0c2VuY3J5cHQu -b3JnLzA0BggrBgEFBQcwAoYoaHR0cDovL2NlcnQuc3RnLXJvb3QteDEubGV0c2Vu -Y3J5cHQub3JnLzAfBgNVHSMEGDAWgBTBJnSkikSg5vogKNhcI5pFiBh54DANBgkq -hkiG9w0BAQsFAAOCAgEABYSu4Il+fI0MYU42OTmEj+1HqQ5DvyAeyCA6sGuZdwjF -UGeVOv3NnLyfofuUOjEbY5irFCDtnv+0ckukUZN9lz4Q2YjWGUpW4TTu3ieTsaC9 -AFvCSgNHJyWSVtWvB5XDxsqawl1KzHzzwr132bF2rtGtazSqVqK9E07sGHMCf+zp -DQVDVVGtqZPHwX3KqUtefE621b8RI6VCl4oD30Olf8pjuzG4JKBFRFclzLRjo/h7 -IkkfjZ8wDa7faOjVXx6n+eUQ29cIMCzr8/rNWHS9pYGGQKJiY2xmVC9h12H99Xyf -zWE9vb5zKP3MVG6neX1hSdo7PEAb9fqRhHkqVsqUvJlIRmvXvVKTwNCP3eCjRCCI -PTAvjV+4ni786iXwwFYNz8l3PmPLCyQXWGohnJ8iBm+5nk7O2ynaPVW0U2W+pt2w -SVuvdDM5zGv2f9ltNWUiYZHJ1mmO97jSY/6YfdOUH66iRtQtDkHBRdkNBsMbD+Em -2TgBldtHNSJBfB3pm9FblgOcJ0FSWcUDWJ7vO0+NTXlgrRofRT6pVywzxVo6dND0 -WzYlTWeUVsO40xJqhgUQRER9YLOLxJ0O6C8i0xFxAMKOtSdodMB3RIwt7RFQ0uyt -n5Z5MqkYhlMI3J1tPRTp1nEt9fyGspBOO05gi148Qasp+3N+svqKomoQglNoAxU= ------END CERTIFICATE-----` -describe('Certd', function () { - it('#buildCertDir', function () { - const options = createOptions() - options.cert.email = 'xiaojunnuo@qq.com' - options.cert.domains = ['*.docmirror.club'] - const certd = new Certd(options) - const currentRootPath = certd.certStore.currentMarkPath - console.log('rootDir', currentRootPath) - expect(currentRootPath).match(/xiaojunnuo@qq.com\\certs\\_.docmirror.club-\w*\\current.json/) - }) - it('#writeAndReadCert', async function () { - const options = createOptions() - options.cert.email = 'xiaojunnuo@qq.com' - options.cert.domains = ['*.domain.cn'] - const certd = new Certd(options) - await certd.writeCert({ csr: 'csr', crt: fakeCrt, key: 'bbb' }) - - const cert = await certd.readCurrentCert() - expect(cert).to.be.ok - expect(cert.crt).ok - expect(cert.key).to.be.ok - expect(cert.detail).to.be.ok - expect(cert.expires).to.be.ok - console.log('cert:', JSON.stringify(cert)) - }) -}) diff --git a/packages/core/executor/.eslintrc b/packages/core/executor/.eslintrc deleted file mode 100644 index c6ce67f2..00000000 --- a/packages/core/executor/.eslintrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "standard", - "env": { - "mocha": true - }, - "overrides": [ - { - "files": ["*.test.js", "*.spec.js"], - "rules": { - "no-unused-expressions": "off" - } - } - ] -} diff --git a/packages/core/executor/.gitignore b/packages/core/executor/.gitignore deleted file mode 100644 index cbb386fa..00000000 --- a/packages/core/executor/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.vscode/ -node_modules/ -npm-debug.log -yarn-error.log -yarn.lock -package-lock.json -/.idea/ diff --git a/packages/core/executor/package.json b/packages/core/executor/package.json deleted file mode 100644 index ca2e0cd0..00000000 --- a/packages/core/executor/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "@certd/executor", - "version": "0.3.0", - "description": "", - "main": "src/index.js", - "scripts": { - "test": "echo \\\"Error: no test specified\\\" && exit 1", - "build": "webpack --config webpack.config.cjs ", - "rollup": "rollup --config rollup.config.js" - }, - "type": "module", - "dependencies": { - "@certd/api": "^0.3.0", - "@certd/certd": "^0.3.0", - "dayjs": "^1.9.7", - "lodash-es": "^4.17.20" - }, - "devDependencies": { - "@certd/plugin-aliyun": "^0.3.0", - "@certd/plugin-host": "^0.3.0", - "@certd/plugin-tencent": "^0.3.0", - "@rollup/plugin-commonjs": "^17.0.0", - "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-node-resolve": "^11.0.1", - "chai": "^4.2.0", - "eslint": "^7.15.0", - "eslint-config-standard": "^16.0.2", - "eslint-plugin-import": "^2.22.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.2.1", - "mocha": "^8.2.1", - "rollup": "^2.35.1", - "rollup-plugin-terser": "^7.0.2" - }, - "author": "Greper", - "license": "MIT", - "sideEffects": false, - "gitHead": "5fbd7742665c0a949333d805153e9b6af91c0a71" -} diff --git a/packages/core/executor/rollup.config.js b/packages/core/executor/rollup.config.js deleted file mode 100644 index 5545a468..00000000 --- a/packages/core/executor/rollup.config.js +++ /dev/null @@ -1,21 +0,0 @@ -import json from '@rollup/plugin-json' -import { terser } from 'rollup-plugin-terser' -import commonjs from '@rollup/plugin-commonjs' -import { nodeResolve } from '@rollup/plugin-node-resolve' - -export default { - input: 'src/index.js', - output: [ - { - file: 'bundle.js', - format: 'es' - }, - { - file: 'bundle.min.js', - format: 'iife', - name: 'version', - plugins: [terser()] - } - ], - plugins: [json(), commonjs(), nodeResolve()] -} diff --git a/packages/core/executor/src/index.js b/packages/core/executor/src/index.js deleted file mode 100644 index a700df17..00000000 --- a/packages/core/executor/src/index.js +++ /dev/null @@ -1,182 +0,0 @@ -import { Certd } from '@certd/certd' -import { pluginRegistry, util } from '@certd/api' -import _ from 'lodash-es' -import dayjs from 'dayjs' -import { Trace } from './trace.js' -const logger = util.logger - -function createDefaultOptions () { - return { - args: { - forceCert: false, - forceDeploy: true, - forceRedeploy: false, - doNotThrowError: false // 部署流程执行有错误时,不抛异常,此时整个任务执行完毕后,可以返回结果,你可以在返回结果中处理 - } - } -} -export class Executor { - constructor () { - this.trace = new Trace() - } - - async run (options) { - logger.info('------------------- Cert-D ---------------------') - try { - this.transfer(options) - options = _.merge(createDefaultOptions(), options) - return await this.doRun(options) - } catch (e) { - logger.error('任务执行出错', e) - throw e - } - } - - transfer (options) { - const providers = options.accessProviders - if (_.isArray(providers)) { - const map = {} - for (const provider of providers) { - if (provider.key) { - map[provider.key] = provider - } - } - options.accessProviders = map - } - } - - async doRun (options) { - // 申请证书 - logger.info('任务开始') - const certd = new Certd(options) - const cert = await this.runCertd(certd) - if (cert == null) { - throw new Error('申请证书失败') - } - logger.info('证书保存路径:', cert.certDir) - - logger.info('----------------------') - if (!cert.isNew) { - // 如果没有更新 - if (options.args.forceRedeploy) { - // 强制重新部署,清空保存的状态 - await certd.certStore.setCurrentFile('context.json', '{}') - } else if (!options.args.forceDeploy) { - // 且不需要强制deploy - logger.info('证书无更新,无需重新部署') - logger.info('任务完成') - return { cert } - } - } - // 读取上次执行进度 - let context = {} - const contextJson = await certd.certStore.getCurrentFile('context.json') - if (contextJson) { - context = JSON.parse(contextJson) - } - - context.certIsNew = !!cert.isNew - - const trace = new Trace(context) - const resultTrace = trace.getInstance({ type: 'result' }) - // 运行部署任务 - try { - await this.runDeploys({ options, cert, context, trace }) - } finally { - await certd.certStore.setCurrentFile('context.json', JSON.stringify(context)) - } - logger.info('任务完成') - trace.print() - const result = resultTrace.get({ }) - if (result) { - if (result.status === 'error' && options.args.doNotThrowError === false) { - throw new Error(result.remark) - } - } - return { - cert, - context, - result - } - } - - async runCertd (certd) { - logger.info(`证书任务 ${JSON.stringify(certd.options.cert.domains)} 开始`) - const cert = await certd.certApply() - logger.info(`证书任务 ${JSON.stringify(certd.options.cert.domains)} 完成`) - return cert - } - - async runDeploys ({ options, cert, context, trace }) { - if (cert == null) { - const certd = new Certd(options) - cert = await certd.readCurrentCert() - } - logger.info('部署任务开始') - for (const deploy of options.deploy) { - const deployName = deploy.deployName - logger.info(`------------【${deployName}】-----------`) - - const deployTrace = trace.getInstance({ type: 'deploy', deployName }) - if (deploy.disabled === true) { - logger.info('此流程已被禁用,跳过') - logger.info('') - deployTrace.set({ value: { current: 'skip', status: 'disabled', remark: '流程禁用' } }) - deployTrace.set({ tasks: null }) - continue - } - try { - for (const task of deploy.tasks) { - if (context[deployName] == null) { - context[deployName] = {} - } - const taskContext = context[deployName] - // 开始执行任务列表 - await this.runTask({ options, cert, task, context: taskContext, deploy, trace }) - } - - deployTrace.set({ value: { status: 'success', remark: '执行成功' } }) - trace.set({ type: 'result', value: { status: 'success', remark: '执行成功' } }) - } catch (e) { - deployTrace.set({ value: { status: 'error', remark: '执行失败:' + e.message } }) - trace.set({ type: 'result', value: { status: 'error', remark: deployName + '执行失败:' + e.message } }) - logger.error('流程执行失败', e) - } - - logger.info('') - } - } - - async runTask ({ options, task, cert, context, deploy, trace }) { - const taskType = task.type - const Plugin = pluginRegistry.get(taskType) - const deployName = deploy.deployName - const taskName = task.taskName - if (Plugin == null) { - throw new Error(`插件:${taskType}还未安装`) - } - - let instance = Plugin - if (Plugin instanceof Function) { - instance = new Plugin({ accessProviders: options.accessProviders }) - } - const taskTrace = trace.getInstance({ type: 'deploy', deployName, taskName }) - const traceStatus = taskTrace.get({}) - if (traceStatus && traceStatus.status === 'success' && !options.args.forceRedeploy) { - logger.info(`----【${taskName}】已经执行完成,跳过此任务`) - taskTrace.set({ value: { current: 'skip', status: 'success', remark: '已执行成功过,本次跳过' } }) - return - } - logger.info(`----【${taskName}】开始执行`) - try { - // 执行任务 - await instance.execute({ cert, props: task.props, context }) - taskTrace.set({ value: { current: 'success', status: 'success', remark: '执行成功', time: dayjs().format() } }) - } catch (e) { - taskTrace.set({ value: { current: 'error', status: 'error', remark: e.message, time: dayjs().format() } }) - throw e - } - logger.info(`----任务【${taskName}】执行完成`) - logger.info('') - } -} diff --git a/packages/core/executor/src/trace.js b/packages/core/executor/src/trace.js deleted file mode 100644 index 209f89d4..00000000 --- a/packages/core/executor/src/trace.js +++ /dev/null @@ -1,96 +0,0 @@ -import { util } from '@certd/api' -import _ from 'lodash-es' -const logger = util.logger -export class Trace { - constructor (context) { - this.context = context - } - - getInstance ({ type, deployName, taskName }) { - return { - get: ({ prop }) => { - return this.get({ type, deployName, taskName, prop }) - }, - set: ({ prop, value }) => { - this.set({ type, deployName, taskName, prop, value }) - } - } - } - - set ({ type, deployName, taskName, prop, value }) { - const key = this.buildTraceKey({ type, deployName, taskName, prop }) - const oldValue = _.get(this.context, key) || {} - _.merge(oldValue, value) - _.set(this.context, key, oldValue) - } - - get ({ type, deployName, taskName, prop }) { - return _.get(this.context, this.buildTraceKey({ type, deployName, taskName, prop })) - } - - buildTraceKey ({ type = 'default', deployName, taskName, prop }) { - let key = '__trace__.' + type - if (deployName) { - key += '.' - key += deployName.replace(/\./g, '_') - } - if (taskName) { - key += '.tasks.' - key += taskName.replace(/\./g, '_') - } - if (prop) { - key += '.' + prop - } - return key - } - - getStringLength (str) { - const enLength = str.replace(/[\u0391-\uFFE5]/g, '').length // 先把中文替换成两个字节的英文,再计算长度 - return Math.floor((str.length - enLength) * 1.5) + enLength - } - - print () { - const context = this.context - logger.info('---------------------------任务结果总览--------------------------') - if (context.certIsNew) { - this.printTraceLine({ current: 'success', remark: '证书更新成功' }, '更新证书') - } else { - this.printTraceLine({ current: 'skip', remark: '还未到过期时间,跳过' }, '更新证书') - } - const trace = this.get({ type: 'deploy' }) - // logger.info('trace', trace) - for (const deployName in trace) { - if (trace[deployName] == null) { - trace[deployName] = {} - } - const traceStatus = this.printTraceLine(trace[deployName], deployName) - - const tasks = traceStatus.tasks - if (tasks) { - for (const taskName in tasks) { - if (tasks[taskName] == null) { - tasks[taskName] = {} - } - this.printTraceLine(tasks[taskName], taskName, ' └') - } - } - } - const result = this.get({ type: 'result' }) - if (result) { - this.printTraceLine(result, 'result', '') - } - const mainContext = {} - _.merge(mainContext, context) - delete mainContext.__trace__ - logger.info('【context】', JSON.stringify(mainContext)) - } - - printTraceLine (traceStatus, name, prefix = '') { - const length = this.getStringLength(name) - const endPad = _.repeat('-', 45 - prefix.length - length) + '\t' - const status = traceStatus.current || traceStatus.status || '' - const remark = traceStatus.remark || '' - logger.info(`${prefix}【${name}】${endPad}[${status}] \t${remark}`) - return traceStatus - } -} diff --git a/packages/core/executor/test/index.test.js b/packages/core/executor/test/index.test.js deleted file mode 100644 index 90cfb228..00000000 --- a/packages/core/executor/test/index.test.js +++ /dev/null @@ -1,42 +0,0 @@ -import pkg from 'chai' -import { Executor } from '../src/index.js' -import { createOptions } from '../../../../test/options.js' -import PluginAliyun from '@certd/plugin-aliyun' -import PluginTencent from '@certd/plugin-tencent' -import PluginHost from '@certd/plugin-host' -const { expect } = pkg - -// 安装默认插件和授权提供者 -PluginAliyun.install() -PluginTencent.install() -PluginHost.install() - -describe('AutoDeploy', function () { - it('#run', async function () { - this.timeout(120000) - const options = createOptions() - const executor = new Executor() - const ret = await executor.run(options) - expect(ret).ok - expect(ret.cert).ok - }) - it('#forceCert', async function () { - this.timeout(120000) - const executor = new Executor() - const options = createOptions() - options.args.forceCert = true - options.args.forceDeploy = true - - const ret = await executor.run(options) - expect(ret).ok - expect(ret.cert).ok - }) - it('#forceDeploy', async function () { - this.timeout(120000) - const executor = new Executor() - const options = createOptions() - const ret = await executor.run(options, { forceCert: false, forceDeploy: true, forceRedeploy: true }) - expect(ret).ok - expect(ret.cert).ok - }) -}) diff --git a/packages/core/executor/webpack.config.cjs b/packages/core/executor/webpack.config.cjs deleted file mode 100644 index a8297e77..00000000 --- a/packages/core/executor/webpack.config.cjs +++ /dev/null @@ -1,23 +0,0 @@ -const path = require('path') -const { CleanWebpackPlugin } = require('clean-webpack-plugin') -console.log(CleanWebpackPlugin) - -module.exports = { - devtool: 'source-map', - target: 'node', - entry: './src/index.js', - output: { - filename: 'executor.js', - path: path.resolve(__dirname, 'dist'), - library: 'certdExecutor', - libraryTarget: 'umd' - }, - plugins: [ - new CleanWebpackPlugin() - ], - mode: 'production' - // mode: 'development', - // optimization: { - // usedExports: true - // } -} diff --git a/packages/core/pipeline/package.json b/packages/core/pipeline/package.json index 08417fc8..1fb81fc1 100644 --- a/packages/core/pipeline/package.json +++ b/packages/core/pipeline/package.json @@ -18,7 +18,6 @@ }, "devDependencies": { "@types/lodash": "^4.14.186", - "@fast-crud/fast-crud": "^1.5.0", "vue-tsc": "^0.38.9", "@alicloud/cs20151215": "^3.0.3", "@alicloud/openapi-client": "^0.4.0", diff --git a/packages/core/pipeline/src/access/api.ts b/packages/core/pipeline/src/access/api.ts index c9be5456..0964ab29 100644 --- a/packages/core/pipeline/src/access/api.ts +++ b/packages/core/pipeline/src/access/api.ts @@ -1,10 +1,14 @@ import { Registrable } from "../registry"; -import { FormItemProps } from "@fast-crud/fast-crud"; import { accessRegistry } from "./registry"; +import { FormItemProps } from "../d.ts"; +export type AccessInput = FormItemProps & { + title: string; + required?: boolean; +}; export type AccessDefine = Registrable & { input: { - [key: string]: FormItemProps; + [key: string]: AccessInput; }; }; export function IsAccess(define: AccessDefine) { diff --git a/packages/core/pipeline/src/access/impl/aliyun-access.ts b/packages/core/pipeline/src/access/impl/aliyun-access.ts index 2fe53505..c770c778 100644 --- a/packages/core/pipeline/src/access/impl/aliyun-access.ts +++ b/packages/core/pipeline/src/access/impl/aliyun-access.ts @@ -7,11 +7,18 @@ import { AbstractAccess } from "../abstract-access"; desc: "", input: { accessKeyId: { + title: "accessKeyId", component: { placeholder: "accessKeyId", }, - //required: true, - //rules: [{ required: true, message: "必填项" }], + required: true, + }, + accessKeySecret: { + title: "accessKeySecret", + component: { + placeholder: "accessKeySecret", + }, + required: true, }, }, }) diff --git a/packages/core/pipeline/src/d.ts/fast-crud.ts b/packages/core/pipeline/src/d.ts/fast-crud.ts new file mode 100644 index 00000000..91515a61 --- /dev/null +++ b/packages/core/pipeline/src/d.ts/fast-crud.ts @@ -0,0 +1,115 @@ +/** + * [x]-col的配置 + */ +export type ColProps = { + span?: number; + [props: string]: any; +}; + +export type FormItemProps = { + /** + * 字段label + */ + title?: string; + /** + * 表单字段组件配置 + */ + component?: ComponentProps; + /** + * 表单字段 [a|el|n]-col的配置 + * 一般用来配置跨列:{span:24} 占满一行 + */ + col?: ColProps; + /** + * 默认值 + */ + value?: any; + /** + * 帮助提示配置 + */ + helper?: string | FormItemHelperProps; + /** + * 排序号 + */ + order?: number; + /** + * 是否显示此字段 + */ + show?: boolean; + /** + * 是否是空白占位栏 + */ + blank?: boolean; + + [key: string]: any; +}; + +/** + * 表单字段帮助说明配置 + */ +export type FormItemHelperProps = { + /** + * 自定义渲染帮助说明 + * @param scope + */ + render?: (scope: any) => any; + /** + * 帮助文本 + */ + text?: string; + /** + * 帮助说明所在的位置,[ undefined | label] + */ + position?: string; + /** + * [a|el|n]-tooltip配置 + */ + tooltip?: object; + + [key: string]: any; +}; + +/** + * 组件配置 + */ +export type ComponentProps = { + /** + * 组件的名称 + */ + name?: string | object; + /** + * vmodel绑定的目标属性名 + */ + vModel?: string; + + /** + * 当原始组件名的参数被以上属性名占用时,可以配置在这里 + * 例如:原始组件有一个叫name的属性,你想要配置它,则可以按如下配置 + * ``` + * component:{ + * name:"组件的名称" + * props:{ + * name:"组件的name属性" <----------- + * } + * } + * ``` + */ + props?: { + [key: string]: any; + }; + + /** + * 组件事件监听 + */ + on?: { + [key: string]: (context?: any) => void; + }; + + /** + * 组件其他参数 + * 事件:onXxx:(event)=>void 组件原始事件监听 + * on.onXxx:(context)=>void 组件事件监听(对原始事件包装) + * 样式:style、class等 + */ + [key: string]: any; +}; diff --git a/packages/core/pipeline/src/d.ts/index.ts b/packages/core/pipeline/src/d.ts/index.ts index 18b29ab6..785c7619 100644 --- a/packages/core/pipeline/src/d.ts/index.ts +++ b/packages/core/pipeline/src/d.ts/index.ts @@ -1 +1,2 @@ export * from "./pipeline"; +export * from "./fast-crud"; diff --git a/packages/core/pipeline/src/plugin/api.ts b/packages/core/pipeline/src/plugin/api.ts index 3b33a9b1..6d9ef563 100644 --- a/packages/core/pipeline/src/plugin/api.ts +++ b/packages/core/pipeline/src/plugin/api.ts @@ -1,6 +1,6 @@ -import { FormItemProps } from "@fast-crud/fast-crud"; import { Registrable } from "../registry"; import { pluginRegistry } from "./registry"; +import { FormItemProps } from "../d.ts"; export type TaskInput = { [key: string]: any; }; diff --git a/packages/core/pipeline/src/plugin/plugins/cert-plugin/index.ts b/packages/core/pipeline/src/plugin/plugins/cert-plugin/index.ts index 24e2e0f2..16d8038a 100644 --- a/packages/core/pipeline/src/plugin/plugins/cert-plugin/index.ts +++ b/packages/core/pipeline/src/plugin/plugins/cert-plugin/index.ts @@ -5,7 +5,7 @@ import dayjs from "dayjs"; import { dnsProviderRegistry } from "../../../dns-provider"; import { AbstractDnsProvider } from "../../../dns-provider/abstract-dns-provider"; import { AcmeService } from "./acme"; - +import _ from "lodash"; export type CertInfo = { crt: string; key: string; @@ -15,6 +15,7 @@ export type CertInfo = { return { name: "CertApply", title: "证书申请", + desc: "免费通配符域名证书申请,支持多个域名打到同一个证书上", input: { domains: { title: "域名", @@ -22,12 +23,17 @@ export type CertInfo = { name: "a-select", vModel: "value", mode: "tags", + open: false, }, required: true, col: { span: 24, }, - helper: "请输入域名", + helper: + "支持通配符域名,例如: *.foo.com 、 *.test.handsfree.work\n" + + "支持多个域名、多个子域名、多个通配符域名打到一个证书上(域名必须是在同一个DNS提供商解析)\n" + + "多级子域名要分成多个域名输入(*.foo.com的证书不能用于xxx.yyy.foo.com)\n" + + "输入一个回车之后,再输入下一个", }, email: { title: "邮箱", @@ -138,7 +144,17 @@ export class CertApplyPlugin extends AbstractPlugin implements TaskPlugin { const domains = input["domains"]; const dnsProviderType = input["dnsProviderType"]; const dnsProviderAccessId = input["dnsProviderAccess"]; - const csrInfo = input["csrInfo"]; + const csrInfo = _.merge( + { + country: "CN", + state: "GuangDong", + locality: "ShengZhen", + organization: "CertD Org.", + organizationUnit: "IT Department", + emailAddress: email, + }, + input["csrInfo"] + ); this.logger.info("开始申请证书,", email, domains); const dnsProviderClass = dnsProviderRegistry.get(dnsProviderType); diff --git a/packages/core/pipeline/src/registry/registry.ts b/packages/core/pipeline/src/registry/registry.ts index 23448ab4..aea7a778 100644 --- a/packages/core/pipeline/src/registry/registry.ts +++ b/packages/core/pipeline/src/registry/registry.ts @@ -59,11 +59,21 @@ export class Registry { getDefineList() { const list = []; for (const key in this.storage) { - const PluginClass = this.storage[key]; - // @ts-ignore - const plugin = new PluginClass(); - list.push({ ...plugin.define, key }); + const define = this.getDefine(key); + if (define) { + list.push({ ...define, key }); + } } return list; } + + getDefine(key: string) { + const PluginClass = this.storage[key]; + if (!PluginClass) { + return; + } + // @ts-ignore + const plugin = new PluginClass(); + return plugin.define; + } } diff --git a/packages/core/pipeline/test/pipeline/pipeline.define.ts b/packages/core/pipeline/test/pipeline/pipeline.define.ts index 649f4229..1369d482 100644 --- a/packages/core/pipeline/test/pipeline/pipeline.define.ts +++ b/packages/core/pipeline/test/pipeline/pipeline.define.ts @@ -9,6 +9,7 @@ export const pipeline: Pipeline = { version: 1, id: generateId(), title: "测试管道", + userId: 1, triggers: [], stages: [ { diff --git a/packages/core/pipeline/vite.config.ts b/packages/core/pipeline/vite.config.ts index 1323c432..c758c7c0 100644 --- a/packages/core/pipeline/vite.config.ts +++ b/packages/core/pipeline/vite.config.ts @@ -7,5 +7,18 @@ export default defineConfig({ entry: "src/index.ts", name: "pipeline", }, + rollupOptions: { + external: ["vue", "lodash-es", "dayjs", "@fast-crud/fast-crud"], + output: { + // Provide global variables to use in the UMD build + // for externalized deps + globals: { + vue: "Vue", + "lodash-es": "_", + dayjs: "dayjs", + "@fast-crud/fast-crud": "FastCrud", + }, + }, + }, }, }); diff --git a/packages/server/certd-client b/packages/server/certd-client index f7d9e45c..70f49940 160000 --- a/packages/server/certd-client +++ b/packages/server/certd-client @@ -1 +1 @@ -Subproject commit f7d9e45c8abb051e8cd8388618e694f8757cb15e +Subproject commit 70f49940d71f5c74087ecd9038881291f250f7d6 diff --git a/packages/server/certd-server b/packages/server/certd-server index 60695c23..a0366be6 160000 --- a/packages/server/certd-server +++ b/packages/server/certd-server @@ -1 +1 @@ -Subproject commit 60695c23553c28a4bb710f55e1a56e623d7fafd3 +Subproject commit a0366be6aeda29aa55d3c5b9f775fa3a27a322a3 diff --git a/packages/ui/certd-server/.eslintrc.cjs b/packages/ui/certd-server/.eslintrc.cjs deleted file mode 100644 index 7186b43a..00000000 --- a/packages/ui/certd-server/.eslintrc.cjs +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = { - root: true, - parserOptions: { - sourceType: 'module', - ecmaVersion: '2020' - }, - parser: 'babel-eslint', - extends: ['standard'], - env: { - node: true - }, - rules: { - 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' - } -} diff --git a/packages/ui/certd-server/.gitignore b/packages/ui/certd-server/.gitignore deleted file mode 100644 index cbb386fa..00000000 --- a/packages/ui/certd-server/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.vscode/ -node_modules/ -npm-debug.log -yarn-error.log -yarn.lock -package-lock.json -/.idea/ diff --git a/packages/ui/certd-server/Dockerfile b/packages/ui/certd-server/Dockerfile deleted file mode 100644 index 4eca4002..00000000 --- a/packages/ui/certd-server/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM registry.cn-shenzhen.aliyuncs.com/greper/node:15.8.0-alpine -ENV TZ=Asia/Shanghai -EXPOSE 3000 -ADD ./ /app/ -RUN cd /app/ && ls -ENTRYPOINT node /app/bin/www.js diff --git a/packages/ui/certd-server/app.js b/packages/ui/certd-server/app.js deleted file mode 100644 index 6fd34a48..00000000 --- a/packages/ui/certd-server/app.js +++ /dev/null @@ -1,59 +0,0 @@ -import Koa from 'koa' -import json from 'koa-json' -import onerror from 'koa-onerror' -import bodyparser from 'koa-bodyparser' -import logger from 'koa-logger' -import Static from 'koa-static' -import fs from 'fs' -import _ from 'lodash-es' -import './install.js' -import pathUtil from './utils/util.path.js' -import compress from 'koa-compress' -const app = new Koa() - -// error handler -onerror(app) - -// middlewares -app.use(bodyparser({ - enableTypes: ['json', 'form', 'text'] -})) -app.use(json()) -app.use(logger()) -// gzip -// app.use(compress({ threshold: 5120 })) - -const staticPlugin = Static(pathUtil.join('public'), { - maxage: 30 * 24 * 60 * 3600, - gzip: true -}) -app.use(staticPlugin) - -// logger -app.use(async (ctx, next) => { - const start = new Date() - await next() - const ms = new Date() - start - console.log(`${ctx.method} ${ctx.url} - ${ms}ms`) -}) - -// routes -const files = fs.readdirSync(new URL('controllers/', import.meta.url)) -// 过滤出.js文件: -const jsFiles = files.filter((f) => { - return f.endsWith('.js') -}) - -_.forEach(jsFiles, async item => { - let mapping = await import(new URL('controllers/' + item, import.meta.url)) - mapping = mapping.default - app.use(mapping.routes(), mapping.allowedMethods()) -}) - -// error-handling -app.on('error', (err, ctx) => { - console.error('server error', err, ctx) -}) - -console.log('http://localhost:3000/') -export default app diff --git a/packages/ui/certd-server/bin/www.js b/packages/ui/certd-server/bin/www.js deleted file mode 100644 index 21950092..00000000 --- a/packages/ui/certd-server/bin/www.js +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env node - -/** - * Module dependencies. - */ - -import app from '../app.js'; -import debuger from 'debug' -const debug = debuger('demo:serer') -// require('debug')('demo:server'); -import http from 'http'; - -/** - * Get port from environment and store in Express. - */ - -var port = normalizePort(process.env.PORT || '3000'); -// app.set('port', port); - -/** - * Create HTTP server. - */ - -var server = http.createServer(app.callback()); - -/** - * Listen on provided port, on all network interfaces. - */ - -server.listen(port); -server.on('error', onError); -server.on('listening', onListening); - -/** - * Normalize a port into a number, string, or false. - */ - -function normalizePort(val) { - var port = parseInt(val, 10); - - if (isNaN(port)) { - // named pipe - return val; - } - - if (port >= 0) { - // port number - return port; - } - - return false; -} - -/** - * Event listener for HTTP server "error" event. - */ - -function onError(error) { - if (error.syscall !== 'listen') { - throw error; - } - - var bind = typeof port === 'string' - ? 'Pipe ' + port - : 'Port ' + port; - - // handle specific listen errors with friendly messages - switch (error.code) { - case 'EACCES': - console.error(bind + ' requires elevated privileges'); - process.exit(1); - break; - case 'EADDRINUSE': - console.error(bind + ' is already in use'); - process.exit(1); - break; - default: - throw error; - } -} - -/** - * Event listener for HTTP server "listening" event. - */ - -function onListening() { - var addr = server.address(); - var bind = typeof addr === 'string' - ? 'pipe ' + addr - : 'port ' + addr.port; - debug('Listening on ' + bind); -} - diff --git a/packages/ui/certd-server/controllers/access-providers.js b/packages/ui/certd-server/controllers/access-providers.js deleted file mode 100644 index 03de8dde..00000000 --- a/packages/ui/certd-server/controllers/access-providers.js +++ /dev/null @@ -1,16 +0,0 @@ -import Router from 'koa-router' -import { accessProviderRegistry } from '@certd/api' -import _ from 'lodash-es' -import { Ret } from '../models/Ret.js' -const router = Router() -router.prefix('/api/access-providers') - -router.get('/list', function (ctx, next) { - const list = [] - _.forEach(accessProviderRegistry.collection, item => { - list.push(item.define()) - }) - ctx.body = Ret.success(list) -}) - -export default router diff --git a/packages/ui/certd-server/controllers/dns-providers.js b/packages/ui/certd-server/controllers/dns-providers.js deleted file mode 100644 index c71807cb..00000000 --- a/packages/ui/certd-server/controllers/dns-providers.js +++ /dev/null @@ -1,16 +0,0 @@ -import Router from 'koa-router' -import { dnsProviderRegistry } from '@certd/api' -import _ from 'lodash-es' -import { Ret } from '../models/Ret.js' -const router = Router() -router.prefix('/api/dns-providers') - -router.get('/list', function (ctx, next) { - const list = [] - _.forEach(dnsProviderRegistry.collection, item => { - list.push(item.define()) - }) - ctx.body = Ret.success(list) -}) - -export default router diff --git a/packages/ui/certd-server/controllers/exports.js b/packages/ui/certd-server/controllers/exports.js deleted file mode 100644 index 79c4b478..00000000 --- a/packages/ui/certd-server/controllers/exports.js +++ /dev/null @@ -1,23 +0,0 @@ -import Router from 'koa-router' -import fs from 'fs' -import exportsService from '../service/exports-service.js' - -const router = Router() -router.prefix('/api/exports') - -router.post('/toZip', async function (ctx, next) { - // const request = ctx.request - // const query = request.query - const body = ctx.request.body - // const req_queryString = request.queryString - const { zipPath, fileName } = await exportsService.exportsToZip(body.options, 'certd-run') - - console.log('zipFile', zipPath) - ctx.set('Content-disposition', 'attachment;filename=' + fileName) - ctx.set('Content-Type', 'application/zip') - ctx.body = fs.createReadStream(zipPath) - // - // // ctx.body = Ret.success(zipPath) -}) - -export default router diff --git a/packages/ui/certd-server/controllers/index.js b/packages/ui/certd-server/controllers/index.js deleted file mode 100644 index 3f87eca9..00000000 --- a/packages/ui/certd-server/controllers/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import Router from 'koa-router' -const router = Router() - -router.get('/api/', async (ctx, next) => { - await ctx.render('index', { - title: 'Hello CertD!' - }) -}) - -export default router diff --git a/packages/ui/certd-server/controllers/plugins.js b/packages/ui/certd-server/controllers/plugins.js deleted file mode 100644 index f6242b32..00000000 --- a/packages/ui/certd-server/controllers/plugins.js +++ /dev/null @@ -1,16 +0,0 @@ -import Router from 'koa-router' -import { pluginRegistry } from '@certd/api' -import _ from 'lodash-es' -import { Ret } from '../models/Ret.js' -const router = Router() -router.prefix('/api/plugins') - -router.get('/list', function (ctx, next) { - const list = [] - _.forEach(pluginRegistry.collection, item => { - list.push(item.define()) - }) - ctx.body = Ret.success(list) -}) - -export default router diff --git a/packages/ui/certd-server/install.js b/packages/ui/certd-server/install.js deleted file mode 100644 index c104766b..00000000 --- a/packages/ui/certd-server/install.js +++ /dev/null @@ -1,8 +0,0 @@ -import PluginAliyun from '@certd/plugin-aliyun' -import PluginTencent from '@certd/plugin-tencent' -import PluginHost from '@certd/plugin-host' - -// 安装默认插件和授权提供者 -PluginAliyun.install() -PluginTencent.install() -PluginHost.install() diff --git a/packages/ui/certd-server/models/Ret.js b/packages/ui/certd-server/models/Ret.js deleted file mode 100644 index 9b40174c..00000000 --- a/packages/ui/certd-server/models/Ret.js +++ /dev/null @@ -1,15 +0,0 @@ -export class Ret { - constructor (code = 0, msg, data) { - this.code = code - this.msg = msg - this.data = data - } - - static success (data) { - return new Ret(0, '', data) - } - - static error (msg) { - return new Ret(1, msg) - } -} diff --git a/packages/ui/certd-server/package.json b/packages/ui/certd-server/package.json deleted file mode 100644 index 4ab36c58..00000000 --- a/packages/ui/certd-server/package.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "@certd/server", - "version": "0.2.2", - "private": false, - "type": "module", - "scripts": { - "start": "node bin/www.js", - "dev": "./node_modules/.bin/nodemon bin/www.js", - "prd": "pm2 start bin/www.js", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { - "@certd/api": "^0.3.0", - "@certd/executor": "^0.3.0", - "@certd/plugin-aliyun": "^0.3.0", - "@certd/plugin-host": "^0.3.0", - "@certd/plugin-tencent": "^0.3.0", - "compressing": "^1.5.1", - "debug": "^4.1.1", - "fs-extra": "^9.1.0", - "koa": "^2.7.0", - "koa-bodyparser": "^4.2.1", - "koa-compress": "^5.0.1", - "koa-convert": "^1.2.0", - "koa-json": "^2.0.2", - "koa-logger": "^3.2.0", - "koa-onerror": "^4.1.0", - "koa-router": "^7.4.0", - "koa-static": "^5.0.0", - "koa-views": "^6.2.0", - "lodash-es": "^4.17.20" - }, - "devDependencies": { - "babel-eslint": "^10.1.0", - "eslint": "^7.19.0", - "eslint-config-standard": "^16.0.2", - "eslint-plugin-import": "^2.22.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.2.1", - "nodemon": "^1.19.1" - }, - "gitHead": "5fbd7742665c0a949333d805153e9b6af91c0a71" -} diff --git a/packages/ui/certd-server/public/favicon.ico b/packages/ui/certd-server/public/favicon.ico deleted file mode 100644 index b34e3e80..00000000 Binary files a/packages/ui/certd-server/public/favicon.ico and /dev/null differ diff --git a/packages/ui/certd-server/public/logo/logo-lang.png b/packages/ui/certd-server/public/logo/logo-lang.png deleted file mode 100644 index df2e39c4..00000000 Binary files a/packages/ui/certd-server/public/logo/logo-lang.png and /dev/null differ diff --git a/packages/ui/certd-server/public/logo/logo-svg.png b/packages/ui/certd-server/public/logo/logo-svg.png deleted file mode 100644 index 5bc5dc18..00000000 Binary files a/packages/ui/certd-server/public/logo/logo-svg.png and /dev/null differ diff --git a/packages/ui/certd-server/public/logo/logo.svg b/packages/ui/certd-server/public/logo/logo.svg deleted file mode 100644 index 227548cc..00000000 --- a/packages/ui/certd-server/public/logo/logo.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/packages/ui/certd-server/service/exports-service.js b/packages/ui/certd-server/service/exports-service.js deleted file mode 100644 index b01fc4b8..00000000 --- a/packages/ui/certd-server/service/exports-service.js +++ /dev/null @@ -1,55 +0,0 @@ -import os from 'os' -import fs from 'fs-extra' -import pathUtil from '../utils/util.path.js' -import cryptoRandomString from 'crypto-random-string' -import zipUtil from '../utils/util.zip.js' -import path from 'path' - -import { createRequire } from 'module' -const require = createRequire(import.meta.url) - -export default { - async exportsToZip (options, dirName) { - const tempDir = os.tmpdir() - const targetDir = path.join(tempDir, 'certd-server', cryptoRandomString(10)) - const projectName = dirName - const targetProjectDir = path.join(targetDir, projectName) - const templateDir = pathUtil.join('templates/' + projectName) - - console.log('targetDir', targetDir) - console.log('projectName', projectName) - console.log('tempalteDir', templateDir) - console.log('targetProjectDir', targetProjectDir) - fs.copySync(templateDir, targetProjectDir) - - // options - const optionsFilePath = path.join(targetProjectDir, 'options.json') - fs.writeJsonSync(optionsFilePath, options) - - // 依赖版本 - const exePkgJson = fs.readFileSync(pathUtil.join('node_modules/@certd/executor/package.json')) - const executorPkg = JSON.parse(exePkgJson) - const currentVersion = executorPkg.version - - const templatePkgJson = fs.readFileSync(pathUtil.join('templates/certd-run/package.json')) - const templatePkg = JSON.parse(templatePkgJson) - templatePkg.dependencies['@certd/executor'] = '^' + currentVersion - templatePkg.dependencies['@certd/plugin-aliyun'] = '^' + currentVersion - templatePkg.dependencies['@certd/plugin-host'] = '^' + currentVersion - templatePkg.dependencies['@certd/plugin-tencent'] = '^' + currentVersion - const pkgFilePath = path.join(targetProjectDir, 'package.json') - fs.writeJsonSync(pkgFilePath, templatePkg) - - const zipName = dirName + '.zip' - const outputFilePath = path.join(targetDir, zipName) - - console.log('outputFilePath', outputFilePath) - await zipUtil.compress({ dir: targetProjectDir, output: outputFilePath }) - return { - dir: targetDir, - fileName: zipName, - zipPath: outputFilePath - } - } - -} diff --git a/packages/ui/certd-server/templates/certd-run/index.js b/packages/ui/certd-server/templates/certd-run/index.js deleted file mode 100644 index 2d5c8500..00000000 --- a/packages/ui/certd-server/templates/certd-run/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import { Executor } from '@certd/executor' -import PluginAliyun from '@certd/plugin-aliyun' -import PluginTencent from '@certd/plugin-tencent' -import PluginHost from '@certd/plugin-host' - -// import options -import { createRequire } from 'module' - -// 安装默认插件和授权提供者 -PluginAliyun.install() -PluginTencent.install() -PluginHost.install() -const require = createRequire(import.meta.url) -const options = require('./options.json') - -// 开始执行 -const executor = new Executor() -await executor.run(options) diff --git a/packages/ui/certd-server/templates/certd-run/options.json b/packages/ui/certd-server/templates/certd-run/options.json deleted file mode 100644 index 9e26dfee..00000000 --- a/packages/ui/certd-server/templates/certd-run/options.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/packages/ui/certd-server/templates/certd-run/package.json b/packages/ui/certd-server/templates/certd-run/package.json deleted file mode 100644 index 9600504c..00000000 --- a/packages/ui/certd-server/templates/certd-run/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "certd-run", - "version": "1.0.0", - "description": "certd run", - "main": "index.js", - "scripts": { - "certd": "node index.js" - }, - "type": "module", - "repository": { - "type": "git", - "url": "https://github.com/certd/certd" - }, - "author": "greper", - "license": "MIT", - "dependencies": { - "@certd/executor": "^0.3.0", - "@certd/plugin-aliyun": "^0.3.0", - "@certd/plugin-host": "^0.3.0", - "@certd/plugin-tencent": "^0.3.0" - } -} diff --git a/packages/ui/certd-server/utils/util.path.js b/packages/ui/certd-server/utils/util.path.js deleted file mode 100644 index 69d5e93c..00000000 --- a/packages/ui/certd-server/utils/util.path.js +++ /dev/null @@ -1,11 +0,0 @@ -import os from 'os' -export default { - join (...dirs) { - const url = new URL('../' + dirs.join('/'), import.meta.url) - let path = url.pathname - if (os.type() === 'Windows_NT') { - path = path.substring(1) - } - return path - } -} diff --git a/packages/ui/certd-server/utils/util.zip.js b/packages/ui/certd-server/utils/util.zip.js deleted file mode 100644 index 9f1fb38c..00000000 --- a/packages/ui/certd-server/utils/util.zip.js +++ /dev/null @@ -1,8 +0,0 @@ -import compressing from 'compressing' -export default { - compress ({ - dir, output - }) { - return compressing.zip.compressDir(dir, output) - } -} diff --git a/packages/ui/certd-ui/.browserslistrc b/packages/ui/certd-ui/.browserslistrc deleted file mode 100644 index 214388fe..00000000 --- a/packages/ui/certd-ui/.browserslistrc +++ /dev/null @@ -1,3 +0,0 @@ -> 1% -last 2 versions -not dead diff --git a/packages/ui/certd-ui/.editorconfig b/packages/ui/certd-ui/.editorconfig deleted file mode 100644 index 7053c49a..00000000 --- a/packages/ui/certd-ui/.editorconfig +++ /dev/null @@ -1,5 +0,0 @@ -[*.{js,jsx,ts,tsx,vue}] -indent_style = space -indent_size = 2 -trim_trailing_whitespace = true -insert_final_newline = true diff --git a/packages/ui/certd-ui/.env b/packages/ui/certd-ui/.env deleted file mode 100644 index 67f85a03..00000000 --- a/packages/ui/certd-ui/.env +++ /dev/null @@ -1 +0,0 @@ -VITE_APP_API=/api diff --git a/packages/ui/certd-ui/.eslintignore b/packages/ui/certd-ui/.eslintignore deleted file mode 100644 index eb79dd5f..00000000 --- a/packages/ui/certd-ui/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -.idea diff --git a/packages/ui/certd-ui/.eslintrc.js b/packages/ui/certd-ui/.eslintrc.js deleted file mode 100644 index a10cc42d..00000000 --- a/packages/ui/certd-ui/.eslintrc.js +++ /dev/null @@ -1,76 +0,0 @@ -module.exports = { - root: true, - env: { - browser: true, - node: true, - es6: true - }, - parser: "vue-eslint-parser", - parserOptions: { - parser: "@typescript-eslint/parser", - ecmaVersion: 2020, - sourceType: "module", - jsxPragma: "React", - ecmaFeatures: { - jsx: true, - tsx: true - } - }, - extends: [ - "plugin:vue/vue3-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended", - "prettier" - ], - rules: { - //"max-len": [0, 200, 2, { ignoreUrls: true }], - "@typescript-eslint/ban-ts-ignore": "off", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-var-requires": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-use-before-define": "off", - "@typescript-eslint/ban-ts-comment": "off", - "@typescript-eslint/ban-types": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/explicit-module-boundary-types": "off" - // "@typescript-eslint/no-unused-vars": [ - // "error", - // { - // argsIgnorePattern: "^h$", - // varsIgnorePattern: "^h$", - // }, - // ], - // "no-unused-vars": [ - // "error", - // { - // argsIgnorePattern: "^h$", - // varsIgnorePattern: "^h$", - // }, - // ], - // "vue/custom-event-name-casing": "off", - // "no-use-before-define": "off", - // "space-before-function-paren": "off", - - // "vue/attributes-order": "off", - // "vue/one-component-per-file": "off", - // "vue/html-closing-bracket-newline": "off", - // "vue/max-attributes-per-line": "off", - // "vue/multiline-html-element-content-newline": "off", - // "vue/singleline-html-element-content-newline": "off", - // "vue/attribute-hyphenation": "off", - // "vue/require-default-prop": "off", - // "vue/html-self-closing": [ - // "error", - // { - // html: { - // void: "always", - // normal: "never", - // component: "always", - // }, - // svg: "always", - // math: "always", - // }, - // ], - } -}; diff --git a/packages/ui/certd-ui/.gitignore b/packages/ui/certd-ui/.gitignore deleted file mode 100644 index 980be95d..00000000 --- a/packages/ui/certd-ui/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -node_modules -.DS_Store -dist -dist-ssr -*.local -/stats.html -yarn.lock -.idea -/.idea/ -yarn-error.log -vite-profile.cpuprofile diff --git a/packages/ui/certd-ui/.npmignore b/packages/ui/certd-ui/.npmignore deleted file mode 100644 index b6c09bbd..00000000 --- a/packages/ui/certd-ui/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -/stats.html diff --git a/packages/ui/certd-ui/.prettierrc b/packages/ui/certd-ui/.prettierrc deleted file mode 100644 index 7944aa9b..00000000 --- a/packages/ui/certd-ui/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - - "trailingComma": "none", - "printWidth": 120 -} diff --git a/packages/ui/certd-ui/README.md b/packages/ui/certd-ui/README.md deleted file mode 100644 index 1f0919a1..00000000 --- a/packages/ui/certd-ui/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# certd-ui - -## Project setup -``` -npm install -``` - -### Compiles and hot-reloads for development -``` -npm run serve -``` - -### Compiles and minifies for production -``` -npm run build -``` - -### Run your unit tests -``` -npm run test:unit -``` - -### Lints and fixes files -``` -npm run lint -``` - -### Customize configuration -See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/packages/ui/certd-ui/babel.config.js b/packages/ui/certd-ui/babel.config.js deleted file mode 100644 index d656ee15..00000000 --- a/packages/ui/certd-ui/babel.config.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - presets: [ - '@vue/cli-plugin-babel/preset' - ] - // plugins: [['import', { - // libraryName: 'ant-design-vue', - // style: true // or 'css' - // }]] -} diff --git a/packages/ui/certd-ui/index.html b/packages/ui/certd-ui/index.html deleted file mode 100644 index e4e27302..00000000 --- a/packages/ui/certd-ui/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - certd - - - -
-
-
-
-
-
- -
- - - diff --git a/packages/ui/certd-ui/package.json b/packages/ui/certd-ui/package.json deleted file mode 100644 index fcc46085..00000000 --- a/packages/ui/certd-ui/package.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "name": "@certd/certd-ui", - "version": "0.2.1", - "private": true, - "scripts": { - "dev": "vite", - "dev:pm": "vite --mode pm", - "dev:force": "vite --force", - "debug": "vite --mode debug", - "debug:pm": "vite --mode debugpm", - "debug:force": "vite --force --mode debug", - "build": "vite build ", - "serve": "vite preview", - "preview": "vite preview", - "pretty-quick": "pretty-quick", - "lint-fix": "eslint --fix --ext .js --ext .jsx --ext .vue src/", - "upgrade": "yarn upgrade-interactive --latest" - }, - "author": "Greper", - "license": "MIT", - "dependencies": { - "@ant-design/colors": "^6.0.0", - "@ant-design/icons-vue": "^6.0.1", - "ant-design-vue": "^3.2.12", - "axios": "^0.27.2", - "core-js": "^3.25.4", - "dayjs": "^1.11.5", - "lodash-es": "^4.17.15", - "mitt": "^3.0.0", - "vue": "^3.2.40", - "vue-i18n": "^9.2.2", - "vue-router": "^4.1.5" - }, - "devDependencies": { - "@rollup/plugin-commonjs": "^22.0.2", - "@rollup/plugin-node-resolve": "^14.1.0", - "@types/chai": "^4.3.3", - "@types/mocha": "^10.0.0", - "@types/node": "^18.8.0", - "@typescript-eslint/eslint-plugin": "^5.38.1", - "@typescript-eslint/parser": "^5.38.1", - "@vitejs/plugin-legacy": "^2.2.0", - "@vitejs/plugin-vue": "^3.1.2", - "@vitejs/plugin-vue-jsx": "^2.0.1", - "@vue/compiler-sfc": "^3.2.40", - "@vue/eslint-config-typescript": "^11.0.2", - "@vue/test-utils": "^2.1.0", - "autoprefixer": "^10.4.12", - "caller-path": "^4.0.0", - "chai": "^4.1.2", - "eslint": "^8.24.0", - "eslint-config-prettier": "^8.1.0", - "eslint-plugin-import": "^2.26.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^4.2.1", - "eslint-plugin-promise": "^6.0.1", - "eslint-plugin-vue": "^9.5.1", - "less": "^4.1.3", - "less-loader": "^11.0.0", - "lint-staged": "^13.0.3", - "postcss": "^8.4.17", - "prettier": "2.7.1", - "rimraf": "^3.0.2", - "rollup": "^2.79.1", - "rollup-plugin-visualizer": "^5.8.2", - "stylelint": "^14.13.0", - "stylelint-config-prettier": "^9.0.3", - "stylelint-order": "^5.0.0", - "vite": "^3.1.4", - "vite-plugin-compression": "^0.5.1", - "vite-plugin-optimize-persist": "^0.1.2", - "vite-plugin-package-config": "^0.1.1", - "vue-eslint-parser": "^9.1.0" - }, - "husky": { - "hooks": { - "pre-commit": "pretty-quick --staged" - } - }, - "gitHead": "9c2162697f3affea22c9a8cbc0ca74f4034ab27e", - "vite": { - "optimizeDeps": { - "include": [ - "@iconify/iconify" - ] - } - } -} diff --git a/packages/ui/certd-ui/public/favicon.ico b/packages/ui/certd-ui/public/favicon.ico deleted file mode 100644 index b34e3e80..00000000 Binary files a/packages/ui/certd-ui/public/favicon.ico and /dev/null differ diff --git a/packages/ui/certd-ui/public/images/plugin.png b/packages/ui/certd-ui/public/images/plugin.png deleted file mode 100644 index 23fa727c..00000000 Binary files a/packages/ui/certd-ui/public/images/plugin.png and /dev/null differ diff --git a/packages/ui/certd-ui/public/images/provider.png b/packages/ui/certd-ui/public/images/provider.png deleted file mode 100644 index c3b95886..00000000 Binary files a/packages/ui/certd-ui/public/images/provider.png and /dev/null differ diff --git a/packages/ui/certd-ui/public/index.html b/packages/ui/certd-ui/public/index.html deleted file mode 100644 index 3e5a1396..00000000 --- a/packages/ui/certd-ui/public/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - <%= htmlWebpackPlugin.options.title %> - - - -
- - - diff --git a/packages/ui/certd-ui/public/public/favicon.ico b/packages/ui/certd-ui/public/public/favicon.ico deleted file mode 100644 index df36fcfb..00000000 Binary files a/packages/ui/certd-ui/public/public/favicon.ico and /dev/null differ diff --git a/packages/ui/certd-ui/public/public/images/logo-certd/logo.svg b/packages/ui/certd-ui/public/public/images/logo-certd/logo.svg deleted file mode 100644 index edcdefbe..00000000 --- a/packages/ui/certd-ui/public/public/images/logo-certd/logo.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/packages/ui/certd-ui/public/public/images/logo-certd/rect-black.svg b/packages/ui/certd-ui/public/public/images/logo-certd/rect-black.svg deleted file mode 100644 index 19bf439f..00000000 --- a/packages/ui/certd-ui/public/public/images/logo-certd/rect-black.svg +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - 让你的证书永不过期 - - - diff --git a/packages/ui/certd-ui/public/public/images/logo-certd/rect.svg b/packages/ui/certd-ui/public/public/images/logo-certd/rect.svg deleted file mode 100644 index acc2f41c..00000000 --- a/packages/ui/certd-ui/public/public/images/logo-certd/rect.svg +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - 让你的证书永不过期 - - - diff --git a/packages/ui/certd-ui/public/public/images/logo-certd/square.svg b/packages/ui/certd-ui/public/public/images/logo-certd/square.svg deleted file mode 100644 index 026dd978..00000000 --- a/packages/ui/certd-ui/public/public/images/logo-certd/square.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/packages/ui/certd-ui/public/public/images/logo/logo.svg b/packages/ui/certd-ui/public/public/images/logo/logo.svg deleted file mode 100644 index edcdefbe..00000000 --- a/packages/ui/certd-ui/public/public/images/logo/logo.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/packages/ui/certd-ui/public/public/images/logo/rect-black.svg b/packages/ui/certd-ui/public/public/images/logo/rect-black.svg deleted file mode 100644 index a57352ec..00000000 --- a/packages/ui/certd-ui/public/public/images/logo/rect-black.svg +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/packages/ui/certd-ui/public/public/images/logo/rect.svg b/packages/ui/certd-ui/public/public/images/logo/rect.svg deleted file mode 100644 index acc2f41c..00000000 --- a/packages/ui/certd-ui/public/public/images/logo/rect.svg +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - 让你的证书永不过期 - - - diff --git a/packages/ui/certd-ui/public/public/images/logo/square.svg b/packages/ui/certd-ui/public/public/images/logo/square.svg deleted file mode 100644 index 1b1395a1..00000000 --- a/packages/ui/certd-ui/public/public/images/logo/square.svg +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/packages/ui/certd-ui/public/public/index.css b/packages/ui/certd-ui/public/public/index.css deleted file mode 100644 index 0950b050..00000000 --- a/packages/ui/certd-ui/public/public/index.css +++ /dev/null @@ -1,12 +0,0 @@ -html, body, #app { height: 100%; margin: 0; padding: 0; width: 100%;} -.fs-bootstrap { background-color: #474949; height: 100%; display: flex; flex-direction: column;position: fixed;width: 100% } -.fs-bootstrap__main {flex:1; user-select: none; width: 100%; flex-grow: 1; display: flex; justify-content: center; align-items: center; flex-direction: column; } -.fs-bootstrap__footer { width: 100%; flex-grow: 0; text-align: center; padding: 10px 0; } -.fs-bootstrap__footer > a { font-size: 12px; color: #ABABAB; text-decoration: none; } -.fs-bootstrap__loading {box-sizing: border-box; height: 50px; width: 50px; margin-bottom: 5px;border:5px solid #333333;border-bottom:#aaa 5px solid; - border-radius:1000px; animation:load 1.1s infinite linear;-webkit-animation:load 1.1s infinite linear;-moz-animation:load 1.1s infinite linear; -o-animation:load 1.1s infinite linear; -} -@keyframes load {from {transform:rotate(0deg);-ms-transform:rotate(0deg);}to { transform:rotate(360deg);-ms-transform:rotate(360deg); } -}@-webkit-keyframes load {from {-webkit-transform:rotate(0deg); }to { -webkit-transform:rotate(360deg);} - }@-moz-keyframes load { from { -moz-transform:rotate(0deg); } to { -moz-transform:rotate(360deg);} - }@-o-keyframes load { from { -o-transform:rotate(0deg);} to { -o-transform:rotate(360deg);}} diff --git a/packages/ui/certd-ui/public/public/index.html b/packages/ui/certd-ui/public/public/index.html deleted file mode 100644 index 3e5a1396..00000000 --- a/packages/ui/certd-ui/public/public/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - <%= htmlWebpackPlugin.options.title %> - - - -
- - - diff --git a/packages/ui/certd-ui/public/public/logo.svg b/packages/ui/certd-ui/public/public/logo.svg deleted file mode 100644 index 1b1395a1..00000000 --- a/packages/ui/certd-ui/public/public/logo.svg +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/packages/ui/certd-ui/src/App.vue b/packages/ui/certd-ui/src/App.vue deleted file mode 100644 index 577d0083..00000000 --- a/packages/ui/certd-ui/src/App.vue +++ /dev/null @@ -1,38 +0,0 @@ - - - diff --git a/packages/ui/certd-ui/src/antdv.js b/packages/ui/certd-ui/src/antdv.js deleted file mode 100644 index 4226d294..00000000 --- a/packages/ui/certd-ui/src/antdv.js +++ /dev/null @@ -1,86 +0,0 @@ -import _ from 'lodash' -import { - AutoComplete, - Alert, - Avatar, - Badge, - Button, - Calendar, - Card, - Cascader, - Checkbox, - Col, - DatePicker, - Divider, - Dropdown, - Form, - Input, - InputNumber, - Layout, - List, - LocaleProvider, - Modal, - Radio, - Row, - Select, - Switch, - Tabs, - Tag, - TimePicker, - Tooltip, - Drawer, - // ColorPicker, - ConfigProvider, - Descriptions, - Space -} from 'ant-design-vue' - -const list = { - AutoComplete, - Alert, - Avatar, - Badge, - Button, - Calendar, - Card, - Cascader, - Checkbox, - Col, - DatePicker, - Divider, - Dropdown, - Form, - Input, - InputNumber, - Layout, - List, - LocaleProvider, - TimePicker, - Modal, - Radio, - Row, - Select, - Switch, - Tabs, - Tag, - Tooltip, - Drawer, - // ColorPicker, - ConfigProvider, - Descriptions, - Space -} -export default function (app) { - _.forEach(list, item => { - app.use(item) - // - // app.config.globalProperties.$message = message - // app.config.globalProperties.$notification = notification - app.config.globalProperties.$info = Modal.info - app.config.globalProperties.$success = Modal.success - app.config.globalProperties.$error = Modal.error - app.config.globalProperties.$warning = Modal.warning - app.config.globalProperties.$confirm = Modal.confirm - app.config.globalProperties.$destroyAll = Modal.destroyAll - }) -} diff --git a/packages/ui/certd-ui/src/api/api.access-providers.js b/packages/ui/certd-ui/src/api/api.access-providers.js deleted file mode 100644 index ab0092ff..00000000 --- a/packages/ui/certd-ui/src/api/api.access-providers.js +++ /dev/null @@ -1,14 +0,0 @@ -import { request } from "./service"; -import inputHandler from "./util.input.handler"; - -export default { - async list() { - const ret = await request({ - url: "/access-providers/list" - }); - - inputHandler.handle(ret); - - return ret; - } -}; diff --git a/packages/ui/certd-ui/src/api/api.dns-providers.js b/packages/ui/certd-ui/src/api/api.dns-providers.js deleted file mode 100644 index c7787f7e..00000000 --- a/packages/ui/certd-ui/src/api/api.dns-providers.js +++ /dev/null @@ -1,14 +0,0 @@ -import { request } from "./service"; -import inputHandler from "./util.input.handler"; - -export default { - async list() { - const ret = await request({ - url: "/dns-providers/list" - }); - - inputHandler.handle(ret); - - return ret; - } -}; diff --git a/packages/ui/certd-ui/src/api/api.exports.js b/packages/ui/certd-ui/src/api/api.exports.js deleted file mode 100644 index 46f969de..00000000 --- a/packages/ui/certd-ui/src/api/api.exports.js +++ /dev/null @@ -1,40 +0,0 @@ -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 }, - method: "post", - responseType: "blob" // 重点在于配置responseType: 'blob' - }).then((res) => { - console.log("res", res); - const filename = decodeURI(res.headers["content-disposition"].replace("attachment;filename=", "")); // 由后端设置下载文件名 - const blob = new Blob([res.data], { type: "application/zip" }); - const a = document.createElement("a"); - const url = window.URL.createObjectURL(blob); - a.href = url; - a.download = filename; - const body = document.getElementsByTagName("body")[0]; - body.appendChild(a); - a.click(); - body.removeChild(a); - window.URL.revokeObjectURL(url); - }); - } -}; diff --git a/packages/ui/certd-ui/src/api/api.plugins.js b/packages/ui/certd-ui/src/api/api.plugins.js deleted file mode 100644 index 202e875d..00000000 --- a/packages/ui/certd-ui/src/api/api.plugins.js +++ /dev/null @@ -1,14 +0,0 @@ -import { request } from "./service"; -import inputHandler from "./util.input.handler"; -export default { - async list() { - const ret = await request({ - url: "/plugins/list" - }); - - inputHandler.handle(ret); - - console.log("plugins", ret); - return ret; - } -}; diff --git a/packages/ui/certd-ui/src/api/index.js b/packages/ui/certd-ui/src/api/index.js deleted file mode 100644 index 21852c05..00000000 --- a/packages/ui/certd-ui/src/api/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import { assign, map } from "lodash"; -import { service, request } from "./service"; - -const files = require.context("./modules", false, /\.js$/); -const generators = files.keys().map((key) => files(key).default); - -export default assign( - {}, - ...map(generators, (generator) => - generator({ - service, - request - }) - ) -); diff --git a/packages/ui/certd-ui/src/api/service.js b/packages/ui/certd-ui/src/api/service.js deleted file mode 100644 index 162ab4bd..00000000 --- a/packages/ui/certd-ui/src/api/service.js +++ /dev/null @@ -1,117 +0,0 @@ -import axios from "axios"; -import { get } from "lodash-es"; -import { errorLog, errorCreate } from "./tools"; -import { env } from "/src/utils/util.env"; -/** - * @description 创建请求实例 - */ -function createService() { - // 创建一个 axios 实例 - const service = axios.create(); - // 请求拦截 - service.interceptors.request.use( - (config) => config, - (error) => { - // 发送失败 - console.log(error); - return Promise.reject(error); - } - ); - // 响应拦截 - service.interceptors.response.use( - (response) => { - console.log("response.config", response.config); - if (response.config.responseType === "blob") { - return response; - } - // dataAxios 是 axios 返回数据中的 data - const dataAxios = response.data; - // 这个状态码是和后端约定的 - const { code } = dataAxios; - // 根据 code 进行判断 - if (code === undefined) { - // 如果没有 code 代表这不是项目后端开发的接口 比如可能是 D2Admin 请求最新版本 - if (response.config.unpack) { - return dataAxios; - } - return dataAxios.data; - } else { - // 有 code 代表这是一个后端接口 可以进行进一步的判断 - switch (code) { - case 0: - // [ 示例 ] code === 0 代表没有错误 - return dataAxios.data; - default: - // 不是正确的 code - errorCreate(`${dataAxios.msg}: ${response.config.url}`); - return dataAxios; - } - } - }, - (error) => { - const status = get(error, "response.status"); - switch (status) { - case 400: - error.message = "请求错误"; - break; - case 401: - error.message = "未授权,请登录"; - break; - case 403: - error.message = "拒绝访问"; - break; - case 404: - error.message = `请求地址出错: ${error.response.config.url}`; - break; - case 408: - error.message = "请求超时"; - break; - case 500: - error.message = "服务器内部错误"; - break; - case 501: - error.message = "服务未实现"; - break; - case 502: - error.message = "网关错误"; - break; - case 503: - error.message = "服务不可用"; - break; - case 504: - error.message = "网关超时"; - break; - case 505: - error.message = "HTTP版本不受支持"; - break; - default: - break; - } - errorLog(error); - return Promise.reject(error); - } - ); - return service; -} - -/** - * @description 创建请求方法 - * @param {Object} service axios 实例 - */ -function createRequestFunction(service) { - return function (config) { - const configDefault = { - headers: { - "Content-Type": get(config, "headers.Content-Type", "application/json") - }, - timeout: 5000, - baseURL: env.API, - data: {} - }; - return service(Object.assign(configDefault, config)); - }; -} - -// 用于真实网络请求的实例和请求方法 -export const service = createService(); -export const request = createRequestFunction(service); diff --git a/packages/ui/certd-ui/src/api/tools.js b/packages/ui/certd-ui/src/api/tools.js deleted file mode 100644 index d35f5064..00000000 --- a/packages/ui/certd-ui/src/api/tools.js +++ /dev/null @@ -1,68 +0,0 @@ -import { notification } from "ant-design-vue"; - -/** - * @description 安全地解析 json 字符串 - * @param {String} jsonString 需要解析的 json 字符串 - * @param {String} defaultValue 默认值 - */ -export function parse(jsonString = "{}", defaultValue = {}) { - let result = defaultValue; - try { - result = JSON.parse(jsonString); - } catch (error) { - console.log(error); - } - return result; -} - -/** - * @description 接口请求返回 - * @param {Any} data 返回值 - * @param {String} msg 状态信息 - * @param {Number} code 状态码 - */ -export function response(data = {}, msg = "", code = 0) { - return [200, { code, msg, data }]; -} - -/** - * @description 接口请求返回 正确返回 - * @param {Any} data 返回值 - * @param {String} msg 状态信息 - */ -export function responseSuccess(data = {}, msg = "成功") { - return response(data, msg); -} - -/** - * @description 接口请求返回 错误返回 - * @param {Any} data 返回值 - * @param {String} msg 状态信息 - * @param {Number} code 状态码 - */ -export function responseError(data = {}, msg = "请求失败", code = 500) { - return response(data, msg, code); -} - -/** - * @description 记录和显示错误 - * @param {Error} error 错误对象 - */ -export function errorLog(error) { - // 打印到控制台 - console.log(error); - // 显示提示 - notification.error({ - message: error.message - }); -} - -/** - * @description 创建一个错误 - * @param {String} msg 错误信息 - */ -export function errorCreate(msg) { - const error = new Error(msg); - errorLog(error); - throw error; -} diff --git a/packages/ui/certd-ui/src/api/util.input.handler.js b/packages/ui/certd-ui/src/api/util.input.handler.js deleted file mode 100644 index fc1b79e7..00000000 --- a/packages/ui/certd-ui/src/api/util.input.handler.js +++ /dev/null @@ -1,35 +0,0 @@ -import _ from "lodash-es"; - -function handleInputs(inputs) { - if (inputs == null) { - return; - } - _.forEach(inputs, (item, key) => { - if (item.required === true) { - if (item.component == null) { - item.component = {}; - } - let rules = item.component.rules; - if (rules == null) { - item.component.rules = rules = []; - } - if (rules.length > 0) { - const hasRequired = rules.filter((rule) => { - return rule.required === true; - }); - if (hasRequired.length > 0) { - return; - } - } - rules.push({ required: true, message: "该项必填" }); - delete item.required; - } - }); -} -export default { - handle(list) { - _.forEach(list, (item) => { - handleInputs(item.input); - }); - } -}; diff --git a/packages/ui/certd-ui/src/assets/favicon.ico b/packages/ui/certd-ui/src/assets/favicon.ico deleted file mode 100644 index b34e3e80..00000000 Binary files a/packages/ui/certd-ui/src/assets/favicon.ico and /dev/null differ diff --git a/packages/ui/certd-ui/src/assets/logo-svg.png b/packages/ui/certd-ui/src/assets/logo-svg.png deleted file mode 100644 index 5bc5dc18..00000000 Binary files a/packages/ui/certd-ui/src/assets/logo-svg.png and /dev/null differ diff --git a/packages/ui/certd-ui/src/assets/logo.svg b/packages/ui/certd-ui/src/assets/logo.svg deleted file mode 100644 index 227548cc..00000000 --- a/packages/ui/certd-ui/src/assets/logo.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/packages/ui/certd-ui/src/components/access-provider-selector/access-provider-manager.vue b/packages/ui/certd-ui/src/components/access-provider-selector/access-provider-manager.vue deleted file mode 100644 index 51c2c56e..00000000 --- a/packages/ui/certd-ui/src/components/access-provider-selector/access-provider-manager.vue +++ /dev/null @@ -1,295 +0,0 @@ - - - - - diff --git a/packages/ui/certd-ui/src/components/access-provider-selector/access-provider-selector.vue b/packages/ui/certd-ui/src/components/access-provider-selector/access-provider-selector.vue deleted file mode 100644 index e0e28b86..00000000 --- a/packages/ui/certd-ui/src/components/access-provider-selector/access-provider-selector.vue +++ /dev/null @@ -1,87 +0,0 @@ - - - diff --git a/packages/ui/certd-ui/src/components/component-render.vue b/packages/ui/certd-ui/src/components/component-render.vue deleted file mode 100644 index 890348bb..00000000 --- a/packages/ui/certd-ui/src/components/component-render.vue +++ /dev/null @@ -1,33 +0,0 @@ - diff --git a/packages/ui/certd-ui/src/components/d-container.vue b/packages/ui/certd-ui/src/components/d-container.vue deleted file mode 100644 index 75fc5056..00000000 --- a/packages/ui/certd-ui/src/components/d-container.vue +++ /dev/null @@ -1,56 +0,0 @@ - - - - - diff --git a/packages/ui/certd-ui/src/components/index.js b/packages/ui/certd-ui/src/components/index.js deleted file mode 100644 index 0b99f8f3..00000000 --- a/packages/ui/certd-ui/src/components/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import DContainer from './d-container.vue' -import ComponentRender from './component-render.vue' -import AccessProviderSelector from './access-provider-selector/access-provider-selector.vue' - -const list = [ - DContainer, - ComponentRender, - AccessProviderSelector -] -export default { - install (app) { - for (const item of list) { - app.component(item.name, item) - } - } -} diff --git a/packages/ui/certd-ui/src/i18n.js b/packages/ui/certd-ui/src/i18n.js deleted file mode 100644 index 593762fb..00000000 --- a/packages/ui/certd-ui/src/i18n.js +++ /dev/null @@ -1,11 +0,0 @@ -import { createI18n } from 'vue-i18n' -import zh from './locales/zh.json' -import en from './locales/en.json' -export const i18n = createI18n({ - // something vue-i18n options here ... - locale: 'zh', // set current locale - messages: { - en, - zh - } -}) diff --git a/packages/ui/certd-ui/src/icons.js b/packages/ui/certd-ui/src/icons.js deleted file mode 100644 index 70b38c39..00000000 --- a/packages/ui/certd-ui/src/icons.js +++ /dev/null @@ -1,26 +0,0 @@ -import _ from 'lodash' -import { - PlusCircleOutlined, - PlusOutlined, - CheckOutlined, EditOutlined, - ArrowRightOutlined, - NodeIndexOutlined, - ThunderboltOutlined, - DeleteOutlined -} from '@ant-design/icons-vue' - -const icons = { - PlusCircleOutlined, - PlusOutlined, - CheckOutlined, - EditOutlined, - ArrowRightOutlined, - NodeIndexOutlined, - ThunderboltOutlined, - DeleteOutlined -} -export default function (app) { - _.forEach(icons, (item, key) => { - app.component(key, item) - }) -} diff --git a/packages/ui/certd-ui/src/locales/en.json b/packages/ui/certd-ui/src/locales/en.json deleted file mode 100644 index 077404aa..00000000 --- a/packages/ui/certd-ui/src/locales/en.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} \ No newline at end of file diff --git a/packages/ui/certd-ui/src/locales/zh.json b/packages/ui/certd-ui/src/locales/zh.json deleted file mode 100644 index 22f15c34..00000000 --- a/packages/ui/certd-ui/src/locales/zh.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "hello": "你好", - "domain": "域名", - "next": "下一步", - "submit": "提交", - "reset": "重置", - "please.input.domain": "请输入域名", - "email": "邮箱" -} diff --git a/packages/ui/certd-ui/src/main.ts b/packages/ui/certd-ui/src/main.ts deleted file mode 100644 index 6696cb1b..00000000 --- a/packages/ui/certd-ui/src/main.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { createApp } from 'vue' -import router from './router' -import App from './App.vue' -import Antd from 'ant-design-vue' -import 'ant-design-vue/dist/antd.css' -import './style/common.less' -import icons from './icons' -import components from './components' -const app = createApp(App) -icons(app) -app.use(Antd) -app.use(components) -app.use(router).mount('#app') diff --git a/packages/ui/certd-ui/src/router/index.js b/packages/ui/certd-ui/src/router/index.js deleted file mode 100644 index ff25ddde..00000000 --- a/packages/ui/certd-ui/src/router/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import { createRouter, createWebHashHistory } from 'vue-router' -import Home from '../views/Home.vue' -import Detail from '../views/detail/index.vue' - -const routes = [ - { - path: '/', - name: 'Home', - component: Home - }, - { - path: '/detail', - name: 'detail', - component: Detail - // component: () => import(/* webpackChunkName: "about" */ '../views/About.vue' - } -] - -const router = createRouter({ - history: createWebHashHistory(), - routes -}) - -export default router diff --git a/packages/ui/certd-ui/src/style/common.less b/packages/ui/certd-ui/src/style/common.less deleted file mode 100644 index 7a004381..00000000 --- a/packages/ui/certd-ui/src/style/common.less +++ /dev/null @@ -1,97 +0,0 @@ -div#app { - height: 100% -} - -h1, h2, h3, h4, h5, h6 { - margin-bottom: 0; -} - -.flex-center { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; -} - -.flex-row { - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; -} - -.ml-10{ - margin-left:10px; -} -.mt-10{ - margin-top:10px; -} -.mr-10{ - margin-right:10px; -} -.mb-10{ - margin-bottom:10px; -} -.ant-layout { - height: 100% -} - -.ant-form{ - .ant-form-item-children { - &>{ - min-height: 40px; - display: flex; - flex-direction: column; - justify-content: center; - } - } - - .ant-form-explain, .ant-form-extra{ - font-size:12px; - line-height: 1.4; - min-height: 20px; - margin:0px; - padding:0px; - } -} - - -.ant-drawer-body{ - padding:0px; -} -.ant-drawer-content { - - .ant-drawer-wrapper-body{ - display: flex; - flex-direction: column; - } - .ant-drawer-body { - position: relative; - flex:1; - } - -} - - -.d-dialog{ - .ant-modal-body{ - max-height: 60vh; - overflow-y: auto; - } - - @media(min-height:600px) and (max-height:700px){ - .ant-modal-body { - max-height: 50vh - } - } - - @media (max-height:600px) { - .ant-modal-body { - max-height: 40vh - } - } - - - - -} diff --git a/packages/ui/certd-ui/src/utils/util.common.js b/packages/ui/certd-ui/src/utils/util.common.js deleted file mode 100644 index 47e6b51a..00000000 --- a/packages/ui/certd-ui/src/utils/util.common.js +++ /dev/null @@ -1,33 +0,0 @@ -import _ from 'lodash-es' -export default { - arrayToMap (array) { - if (!array) { - return {} - } - if (!_.isArray(array)) { - return array - } - const map = {} - for (const item of array) { - if (item.key) { - map[item.key] = item - } - } - return map - }, - mapToArray (map) { - if (!map) { - return [] - } - if (_.isArray(map)) { - return map - } - const array = [] - for (const key in map) { - const item = map[key] - item.key = key - array.push(item) - } - return array - } -} diff --git a/packages/ui/certd-ui/src/utils/util.env.ts b/packages/ui/certd-ui/src/utils/util.env.ts deleted file mode 100644 index d87db909..00000000 --- a/packages/ui/certd-ui/src/utils/util.env.ts +++ /dev/null @@ -1,40 +0,0 @@ -import _ from "lodash-es"; -export function getEnvValue(key) { - // @ts-ignore - return import.meta.env["VITE_APP_" + key]; -} - -export class EnvConfig { - API; - MODE; - STORAGE; - TITLE; - PM_ENABLED; - constructor() { - this.init(); - } - - init() { - // @ts-ignore - _.forEach(import.meta.env, (value, key) => { - if (key.startsWith("VITE_APP")) { - key = key.replace("VITE_APP_", ""); - this[key] = value; - } - }); - // @ts-ignore - this.MODE = import.meta.env.MODE; - } - - get(key, defaultValue) { - return this[key] ?? defaultValue; - } - isDev() { - return this.MODE === "development" || this.MODE === "debug"; - } - isProd() { - return this.MODE === "production"; - } -} - -export const env = new EnvConfig(); diff --git a/packages/ui/certd-ui/src/views/Home.vue b/packages/ui/certd-ui/src/views/Home.vue deleted file mode 100644 index 131fa026..00000000 --- a/packages/ui/certd-ui/src/views/Home.vue +++ /dev/null @@ -1,122 +0,0 @@ - - - diff --git a/packages/ui/certd-ui/src/views/detail/components/cert-form.vue b/packages/ui/certd-ui/src/views/detail/components/cert-form.vue deleted file mode 100644 index a05d8a2f..00000000 --- a/packages/ui/certd-ui/src/views/detail/components/cert-form.vue +++ /dev/null @@ -1,261 +0,0 @@ - - - diff --git a/packages/ui/certd-ui/src/views/detail/components/task-form.vue b/packages/ui/certd-ui/src/views/detail/components/task-form.vue deleted file mode 100644 index dbbb613b..00000000 --- a/packages/ui/certd-ui/src/views/detail/components/task-form.vue +++ /dev/null @@ -1,314 +0,0 @@ - - - - - diff --git a/packages/ui/certd-ui/src/views/detail/index.vue b/packages/ui/certd-ui/src/views/detail/index.vue deleted file mode 100644 index cefce70d..00000000 --- a/packages/ui/certd-ui/src/views/detail/index.vue +++ /dev/null @@ -1,502 +0,0 @@ - - - diff --git a/packages/ui/certd-ui/tests/unit/example.spec.js b/packages/ui/certd-ui/tests/unit/example.spec.js deleted file mode 100644 index bc9939b6..00000000 --- a/packages/ui/certd-ui/tests/unit/example.spec.js +++ /dev/null @@ -1,13 +0,0 @@ -import { expect } from 'chai' -import { shallowMount } from '@vue/test-utils' -import HelloWorld from '@/components/HelloWorld.vue' - -describe('HelloWorld.vue', () => { - it('renders props.msg when passed', () => { - const msg = 'new message' - const wrapper = shallowMount(HelloWorld, { - props: { msg } - }) - expect(wrapper.text()).to.include(msg) - }) -}) diff --git a/packages/ui/certd-ui/tsconfig.json b/packages/ui/certd-ui/tsconfig.json deleted file mode 100644 index bdb44e0f..00000000 --- a/packages/ui/certd-ui/tsconfig.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "compilerOptions": { - // 这样就可以对 `this` 上的数据属性进行更严格的推断` - "noImplicitAny": false, - "target": "esnext", - "module": "esnext", - "strict": true, - "jsx": "preserve", - "importHelpers": true, - "moduleResolution": "node", - "experimentalDecorators": true, - "skipLibCheck": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "sourceMap": true, - "baseUrl": ".", - "outDir": "./dist/ts", - "types": [ - "mocha", - "chai", - "node" - ], - "paths": { - "/@/*": ["src/*"], - "/src/*": ["src/*"], - "/#/*": ["types/*"] - }, - "lib": [ - "esnext", - "dom", - "dom.iterable", - "scripthost" - ] - }, - "include": [ - "src/**/*.ts", - "src/**/*.tsx", - "src/**/*.vue", - "tests/**/*.ts", - "tests/**/*.tsx" - ], - "exclude": [ - "node_modules" - ] -} diff --git a/packages/ui/certd-ui/vite.config.ts b/packages/ui/certd-ui/vite.config.ts deleted file mode 100644 index 4737cca7..00000000 --- a/packages/ui/certd-ui/vite.config.ts +++ /dev/null @@ -1,66 +0,0 @@ -import vue from "@vitejs/plugin-vue"; -import vueJsx from "@vitejs/plugin-vue-jsx"; -import visualizer from "rollup-plugin-visualizer"; -import viteCompression from "vite-plugin-compression"; -import * as path from "path"; -// import { generateModifyVars } from "./build/modify-vars"; -// import { configThemePlugin } from "./build/theme-plugin"; -// import OptimizationPersist from "vite-plugin-optimize-persist"; -// import PkgConfig from "vite-plugin-package-config"; -// https://vitejs.dev/config/ -// 增加环境变量 _ -process.env.VITE_APP_VERSION = require("./package.json").version; -process.env.VITE_APP_BUILD_TIME = require("dayjs")().format("YYYY-M-D HH:mm:ss"); - -export default ({ command, mode }) => { - console.log("args", command, mode); - - const devServerFs: any = {}; - const devAlias: any[] = []; - return { - base: "/", - plugins: [ - vueJsx(), - vue(), - // 压缩build后的代码 - viteCompression() - ], - esbuild: { - // pure: ["console.log", "debugger"], - jsxFactory: "h", - jsxFragment: "Fragment" - }, - resolve: { - alias: [ - ...devAlias, - { find: "/@", replacement: path.resolve("./src") }, - { find: "/#", replacement: path.resolve("./types") } - ], - dedupe: ["vue"] - }, - build: { - rollupOptions: { - plugins: [visualizer()] - } - }, - css: { - preprocessorOptions: { - less: { - // 修改默认主题颜色,配置less变量 - // modifyVars: generateModifyVars(), - javascriptEnabled: true - } - } - }, - server: { - fs: devServerFs, - proxy: { - // with options - "/api": { - //配套后端 https://github.com/fast-crud/fs-server-js - target: "http://127.0.0.1:3000" - } - } - } - }; -};