diff --git a/CHANGELOG.md b/CHANGELOG.md index 511ee819..43793098 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.21.2](https://github.com/certd/certd/compare/v1.21.1...v1.21.2) (2024-07-08) + +### Performance Improvements + +* 申请证书时可以选择跳过本地dns校验 ([fe91d94](https://github.com/certd/certd/commit/fe91d94090d22ed0a3ea753ba74dfaa1bf057c17)) + +## [1.21.1](https://github.com/certd/certd/compare/v1.21.0...v1.21.1) (2024-07-08) + +### Performance Improvements + +* 上传到主机,支持设置不mkdirs ([5ba9831](https://github.com/certd/certd/commit/5ba9831ed1aa6ec6057df246f1035b36b9c41d2e)) +* 说明优化,默认值优化 ([970c7fd](https://github.com/certd/certd/commit/970c7fd8a0f557770e973d8462ee5684ef742810)) + # [1.21.0](https://github.com/certd/certd/compare/v1.20.17...v1.21.0) (2024-07-03) ### Features diff --git a/README.md b/README.md index 6acd168f..5d2df760 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@ # CertD -CertD 是一个免费全自动申请和部署SSL证书的工具。 +CertD 是一个免费全自动申请和自动部署更新SSL证书的工具。 后缀D取自linux守护进程的命名风格,意为证书守护进程。 +关键字:证书自动申请、证书自动更新、证书自动续期、证书自动续签 + ## 一、特性 -本项目不仅支持证书申请过程自动化,还可以自动化部署证书,让你的证书永不过期。 +本项目不仅支持证书申请过程自动化,还可以自动化部署更新证书,让你的证书永不过期。 * 全自动申请证书(支持阿里云、腾讯云、华为云、Cloudflare注册的域名) -* 全自动部署证书(目前支持服务器上传部署、部署到阿里云、腾讯云等) +* 全自动部署更新证书(目前支持服务器上传部署、部署到阿里云、腾讯云等) * 支持通配符域名 * 支持多个域名打到一个证书上 * 邮件通知 @@ -108,8 +110,8 @@ http://your_server_ip:7001 * http-01: 在网站根目录下放置一份txt文件 * dns-01: 需要给域名添加txt解析记录,通配符域名只能用这种方式 * 证书续期: - * 实际上acme并没有续期概念。 - * 我们所说的续期,其实就是按照全套流程重新申请一份新证书。 + * 实际上没有办法不改变证书文件本身情况下直接续期或者续签。 + * 我们所说的续期,其实就是按照全套流程重新申请一份新证书,然后重新部署上去。 * 免费证书过期时间90天,以后可能还会缩短,所以自动化部署必不可少 * 设置每天自动运行,当证书过期前20天,会自动重新申请证书并部署 @@ -172,3 +174,7 @@ docker compose up -d * [袖手GPT](https://ai.handsfree.work/) ChatGPT,国内可用,无需FQ,每日免费额度 * [fast-crud](https://gitee.com/fast-crud/fast-crud/) 基于vue3的crud快速开发框架 * [dev-sidecar](https://github.com/docmirror/dev-sidecar/) 直连访问github工具,无需FQ,解决github无法访问的问题 + + +## 十二、版本更新日志 +https://github.com/certd/certd/blob/v2/CHANGELOG.md \ No newline at end of file diff --git a/deploy.js b/deploy.js index 8e581acf..a2bdf8f5 100644 --- a/deploy.js +++ b/deploy.js @@ -1,6 +1,5 @@ import http from 'axios' import fs from 'fs' - //读取 packages/core/pipline/package.json的版本号 import {default as packageJson} from './packages/core/pipeline/package.json' assert { type: "json" }; diff --git a/lerna.json b/lerna.json index 0c209522..5f69b329 100644 --- a/lerna.json +++ b/lerna.json @@ -9,5 +9,5 @@ } }, "npmClient": "pnpm", - "version": "1.21.0" + "version": "1.21.2" } diff --git a/package.json b/package.json index 7c9ed52d..fc9dc70b 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,10 @@ "i-all": "lerna link && lerna exec npm install ", "publish": "npm run prepublishOnly1 && lerna publish --conventional-commits && npm run afterpublishOnly && npm run deploy1", "afterpublishOnly": "", - "prepublishOnly1": "npm run before-build && lerna run build ", + "prepublishOnly1": "npm run check && npm run before-build && lerna run build ", "before-build": "cd ./packages/core/acme-client && time /t >build.md && git add ./build.md && git commit -m \"build: prepare to build\"", "deploy1": "node --experimental-json-modules deploy.js ", + "check": "node --experimental-json-modules publish-check.js" "init": "lerna run build" }, "license": "AGPL-3.0", diff --git a/packages/core/acme-client/CHANGELOG.md b/packages/core/acme-client/CHANGELOG.md index 4379790a..febb2f08 100644 --- a/packages/core/acme-client/CHANGELOG.md +++ b/packages/core/acme-client/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.21.2](https://github.com/publishlab/node-acme-client/compare/v1.21.1...v1.21.2) (2024-07-08) + +**Note:** Version bump only for package @certd/acme-client + +## [1.21.1](https://github.com/publishlab/node-acme-client/compare/v1.21.0...v1.21.1) (2024-07-08) + +**Note:** Version bump only for package @certd/acme-client + # [1.21.0](https://github.com/publishlab/node-acme-client/compare/v1.20.17...v1.21.0) (2024-07-03) ### Features diff --git a/packages/core/acme-client/build.md b/packages/core/acme-client/build.md index 1d3b516a..21e5320c 100644 --- a/packages/core/acme-client/build.md +++ b/packages/core/acme-client/build.md @@ -1 +1 @@ -01:14 +15:57 diff --git a/packages/core/acme-client/package.json b/packages/core/acme-client/package.json index a7c6121f..9945f485 100644 --- a/packages/core/acme-client/package.json +++ b/packages/core/acme-client/package.json @@ -3,7 +3,7 @@ "description": "Simple and unopinionated ACME client", "private": false, "author": "nmorsman", - "version": "1.21.0", + "version": "1.21.2", "main": "src/index.js", "types": "types/index.d.ts", "license": "MIT", diff --git a/packages/core/pipeline/CHANGELOG.md b/packages/core/pipeline/CHANGELOG.md index ef6b1667..be971a3b 100644 --- a/packages/core/pipeline/CHANGELOG.md +++ b/packages/core/pipeline/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.21.2](https://github.com/certd/certd/compare/v1.21.1...v1.21.2) (2024-07-08) + +**Note:** Version bump only for package @certd/pipeline + +## [1.21.1](https://github.com/certd/certd/compare/v1.21.0...v1.21.1) (2024-07-08) + +**Note:** Version bump only for package @certd/pipeline + # [1.21.0](https://github.com/certd/certd/compare/v1.20.17...v1.21.0) (2024-07-03) **Note:** Version bump only for package @certd/pipeline diff --git a/packages/core/pipeline/package.json b/packages/core/pipeline/package.json index eb2f7da3..3eebe082 100644 --- a/packages/core/pipeline/package.json +++ b/packages/core/pipeline/package.json @@ -1,7 +1,7 @@ { "name": "@certd/pipeline", "private": false, - "version": "1.21.0", + "version": "1.21.2", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -21,7 +21,7 @@ "qs": "^6.11.2" }, "devDependencies": { - "@certd/acme-client": "workspace:^1.21.0", + "@certd/acme-client": "workspace:^1.21.2", "@rollup/plugin-commonjs": "^23.0.4", "@rollup/plugin-json": "^6.0.0", "@rollup/plugin-node-resolve": "^15.0.1", diff --git a/packages/libs/huawei/CHANGELOG.md b/packages/libs/huawei/CHANGELOG.md index 55e6df7f..1bf3aa01 100644 --- a/packages/libs/huawei/CHANGELOG.md +++ b/packages/libs/huawei/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.21.2](https://github.com/certd/certd/compare/v1.21.1...v1.21.2) (2024-07-08) + +**Note:** Version bump only for package @certd/plugin-util + +## [1.21.1](https://github.com/certd/certd/compare/v1.21.0...v1.21.1) (2024-07-08) + +**Note:** Version bump only for package @certd/plugin-util + # [1.21.0](https://github.com/certd/certd/compare/v1.20.17...v1.21.0) (2024-07-03) **Note:** Version bump only for package @certd/plugin-util diff --git a/packages/libs/k8s/package.json b/packages/libs/k8s/package.json index 9490f03d..2842eb43 100644 --- a/packages/libs/k8s/package.json +++ b/packages/libs/k8s/package.json @@ -1,7 +1,7 @@ { "name": "@certd/lib-k8s", "private": false, - "version": "1.21.0", + "version": "1.21.2", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -17,7 +17,7 @@ "kubernetes-client": "^9.0.0" }, "devDependencies": { - "@certd/pipeline": "workspace:^1.21.0", + "@certd/pipeline": "workspace:^1.21.2", "@rollup/plugin-commonjs": "^23.0.4", "@rollup/plugin-json": "^6.0.0", "@rollup/plugin-node-resolve": "^15.0.1", diff --git a/packages/plugins/plugin-cert/CHANGELOG.md b/packages/plugins/plugin-cert/CHANGELOG.md index a7ce43a6..65187ba7 100644 --- a/packages/plugins/plugin-cert/CHANGELOG.md +++ b/packages/plugins/plugin-cert/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.21.2](https://github.com/certd/certd/compare/v1.21.1...v1.21.2) (2024-07-08) + +### Performance Improvements + +* 申请证书时可以选择跳过本地dns校验 ([fe91d94](https://github.com/certd/certd/commit/fe91d94090d22ed0a3ea753ba74dfaa1bf057c17)) + +## [1.21.1](https://github.com/certd/certd/compare/v1.21.0...v1.21.1) (2024-07-08) + +### Performance Improvements + +* 说明优化,默认值优化 ([970c7fd](https://github.com/certd/certd/commit/970c7fd8a0f557770e973d8462ee5684ef742810)) + # [1.21.0](https://github.com/certd/certd/compare/v1.20.17...v1.21.0) (2024-07-03) ### Features diff --git a/packages/plugins/plugin-cert/package.json b/packages/plugins/plugin-cert/package.json index 68a7dd86..ed880d1e 100644 --- a/packages/plugins/plugin-cert/package.json +++ b/packages/plugins/plugin-cert/package.json @@ -1,7 +1,7 @@ { "name": "@certd/plugin-cert", "private": false, - "version": "1.21.0", + "version": "1.21.2", "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", @@ -13,8 +13,8 @@ "preview": "vite preview" }, "dependencies": { - "@certd/acme-client": "workspace:^1.21.0", - "@certd/pipeline": "workspace:^1.21.0", + "@certd/acme-client": "workspace:^1.21.2", + "@certd/pipeline": "workspace:^1.21.2", "jszip": "^3.10.1", "node-forge": "^0.10.0", "psl": "^1.9.0" diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts index 4b9cd8a0..7187652f 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts @@ -18,12 +18,20 @@ export class AcmeService { userContext: IContext; logger: Logger; sslProvider: SSLProvider; + skipLocalVerify = true; eab?: ClientExternalAccountBindingOptions; - constructor(options: { userContext: IContext; logger: Logger; sslProvider: SSLProvider; eab?: ClientExternalAccountBindingOptions }) { + constructor(options: { + userContext: IContext; + logger: Logger; + sslProvider: SSLProvider; + eab?: ClientExternalAccountBindingOptions; + skipLocalVerify?: boolean; + }) { this.userContext = options.userContext; this.logger = options.logger; this.sslProvider = options.sslProvider || "letsencrypt"; this.eab = options.eab; + this.skipLocalVerify = options.skipLocalVerify ?? false; acme.setLogger((text: string) => { this.logger.info(text); }); @@ -192,7 +200,7 @@ export class AcmeService { csr, email: email, termsOfServiceAgreed: true, - skipChallengeVerification: false, + skipChallengeVerification: this.skipLocalVerify, challengePriority: ["dns-01"], challengeCreateFn: async (authz: acme.Authorization, challenge: Challenge, keyAuthorization: string): Promise => { return await this.challengeCreateFn(authz, challenge, keyAuthorization, dnsProvider); diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts index 6d438d14..854d1ce6 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts @@ -39,10 +39,10 @@ export class CertApplyPlugin extends AbstractTaskPlugin { span: 24, }, helper: - "支持通配符域名,例如: *.foo.com、foo.com、*.test.handsfree.work\n" + - "支持多个域名、多个子域名、多个通配符域名打到一个证书上(域名必须是在同一个DNS提供商解析)\n" + - "多级子域名要分成多个域名输入(*.foo.com的证书不能用于xxx.yyy.foo.com、foo.com)\n" + - "输入一个回车之后,再输入下一个", + "1、支持通配符域名,例如: *.foo.com、foo.com、*.test.handsfree.work\n" + + "2、支持多个域名、多个子域名、多个通配符域名打到一个证书上(域名必须是在同一个DNS提供商解析)\n" + + "3、多级子域名要分成多个域名输入(*.foo.com的证书不能用于xxx.yyy.foo.com、foo.com)\n" + + "4、输入一个回车之后,再输入下一个", }) domains!: string; @@ -110,6 +110,17 @@ export class CertApplyPlugin extends AbstractTaskPlugin { }) dnsProviderAccess!: string; + @TaskInput({ + title: "跳过本地校验DNS", + default: false, + component: { + name: "a-switch", + vModel: "checked", + }, + helper: "如果重试多次出现Authorization not found TXT record,导致无法申请成功,请尝试开启此选项", + }) + skipLocalVerify = false; + @TaskInput({ title: "更新天数", component: { @@ -166,7 +177,13 @@ export class CertApplyPlugin extends AbstractTaskPlugin { if (this.eabAccessId) { eab = await this.ctx.accessService.getById(this.eabAccessId); } - this.acme = new AcmeService({ userContext: this.userContext, logger: this.logger, sslProvider: this.sslProvider, eab }); + this.acme = new AcmeService({ + userContext: this.userContext, + logger: this.logger, + sslProvider: this.sslProvider, + eab, + skipLocalVerify: this.skipLocalVerify, + }); } async execute(): Promise { diff --git a/packages/ui/certd-client/CHANGELOG.md b/packages/ui/certd-client/CHANGELOG.md index d8143be3..4e5ee148 100644 --- a/packages/ui/certd-client/CHANGELOG.md +++ b/packages/ui/certd-client/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.21.2](https://github.com/certd/certd/compare/v1.21.1...v1.21.2) (2024-07-08) + +**Note:** Version bump only for package @certd/ui-client + +## [1.21.1](https://github.com/certd/certd/compare/v1.21.0...v1.21.1) (2024-07-08) + +### Performance Improvements + +* 说明优化,默认值优化 ([970c7fd](https://github.com/certd/certd/commit/970c7fd8a0f557770e973d8462ee5684ef742810)) + # [1.21.0](https://github.com/certd/certd/compare/v1.20.17...v1.21.0) (2024-07-03) **Note:** Version bump only for package @certd/ui-client diff --git a/packages/ui/certd-client/package.json b/packages/ui/certd-client/package.json index c777e578..8e6af5e5 100644 --- a/packages/ui/certd-client/package.json +++ b/packages/ui/certd-client/package.json @@ -1,6 +1,6 @@ { "name": "@certd/ui-client", - "version": "1.21.0", + "version": "1.21.2", "private": true, "scripts": { "dev": "vite --open", @@ -59,7 +59,7 @@ "vuedraggable": "^2.24.3" }, "devDependencies": { - "@certd/pipeline": "^1.21.0", + "@certd/pipeline": "^1.21.2", "@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-node-resolve": "^15.2.3", "@types/chai": "^4.3.12", diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue index aef3938a..30598ba5 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/step-form/index.vue @@ -222,6 +222,10 @@ export default { ); } } + //设置初始值 + if (input.default != null && currentStep.value.input[key] == null) { + currentStep.value.input[key] = input.default ?? input.value; + } } } diff --git a/packages/ui/certd-client/src/views/crud/component/editor/crud.tsx b/packages/ui/certd-client/src/views/crud/component/editor/crud.tsx index 716e3a48..5b0b7d22 100644 --- a/packages/ui/certd-client/src/views/crud/component/editor/crud.tsx +++ b/packages/ui/certd-client/src/views/crud/component/editor/crud.tsx @@ -1,7 +1,7 @@ import * as api from "./api"; import { utils, dict, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, UserPageQuery, UserPageRes, EditReq, DelReq, AddReq, ScopeContext } from "@fast-crud/fast-crud"; import { FsUploaderFormOptions } from "@fast-crud/fast-extends"; - +import "./editor.css"; export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet { const pageRequest = async (query: UserPageQuery): Promise => { return await api.GetList(query); @@ -79,6 +79,11 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti show: false }, type: "editor-wang5", // 富文本图片上传依赖file-uploader,请先配置好file-uploader + viewForm: { + render({ value }) { + return
; + } + }, form: { helper: "示例已升级到wangEditor5版本,原来的editor-wang目前仍然可以使用,后续fs升级可能会将其删除,请尽快升级到editor-wang5版本", col: { span: 24 }, diff --git a/packages/ui/certd-client/src/views/crud/component/editor/editor.css b/packages/ui/certd-client/src/views/crud/component/editor/editor.css new file mode 100644 index 00000000..5666c316 --- /dev/null +++ b/packages/ui/certd-client/src/views/crud/component/editor/editor.css @@ -0,0 +1,52 @@ +.editor-content-view { + /*border: 1px solid #ccc;*/ + /*border-radius: 5px;*/ + padding: 0 10px; + margin-top: 20px; + overflow-x: auto; +} + +.editor-content-view p, +.editor-content-view li { + white-space: pre-wrap; /* 保留空格 */ +} + +.editor-content-view blockquote { + border-left: 8px solid #d0e5f2; + padding: 10px 10px; + margin: 10px 0; + background-color: #f1f1f1; +} + +.editor-content-view code { + font-family: monospace; + background-color: #eee; + padding: 3px; + border-radius: 3px; +} +.editor-content-view pre>code { + display: block; + padding: 10px; +} + +.editor-content-view table { + border-collapse: collapse; +} +.editor-content-view td, +.editor-content-view th { + border: 1px solid #ccc; + min-width: 50px; + height: 20px; +} +.editor-content-view th { + background-color: #f1f1f1; +} + +.editor-content-view ul, +.editor-content-view ol { + padding-left: 20px; +} + +.editor-content-view input[type="checkbox"] { + margin-right: 5px; +} \ No newline at end of file diff --git a/packages/ui/certd-client/src/views/crud/component/uploader/form/crud.tsx b/packages/ui/certd-client/src/views/crud/component/uploader/form/crud.tsx index 16c4f4a2..b592dc02 100644 --- a/packages/ui/certd-client/src/views/crud/component/uploader/form/crud.tsx +++ b/packages/ui/certd-client/src/views/crud/component/uploader/form/crud.tsx @@ -57,7 +57,17 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti multiple: true, //可选择多个 uploader: { type: "form", - keepName: true + keepName: true, + successHandle(res: any) { + //这里我的后台返回res是一个key 字符串 + //此方法需要返回的数据结构为 {key:"string",url:"string"...} + // 如果 有返回url,那么buildUrl将不会被执行 + return { key: res }; + } + }, + valueType: "key", + async buildUrl(value: string) { + return "http://www.docmirror.cn:7070/api/upload/form/download?key=" + value; } }, helper: "可以同时选择多个文件" diff --git a/packages/ui/certd-server/CHANGELOG.md b/packages/ui/certd-server/CHANGELOG.md index 559a749b..1ec2b4dd 100644 --- a/packages/ui/certd-server/CHANGELOG.md +++ b/packages/ui/certd-server/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.21.2](https://github.com/fast-crud/fast-server-js/compare/v1.21.1...v1.21.2) (2024-07-08) + +**Note:** Version bump only for package @certd/ui-server + +## [1.21.1](https://github.com/fast-crud/fast-server-js/compare/v1.21.0...v1.21.1) (2024-07-08) + +### Performance Improvements + +* 上传到主机,支持设置不mkdirs ([5ba9831](https://github.com/fast-crud/fast-server-js/commit/5ba9831ed1aa6ec6057df246f1035b36b9c41d2e)) +* 说明优化,默认值优化 ([970c7fd](https://github.com/fast-crud/fast-server-js/commit/970c7fd8a0f557770e973d8462ee5684ef742810)) + # [1.21.0](https://github.com/fast-crud/fast-server-js/compare/v1.20.17...v1.21.0) (2024-07-03) **Note:** Version bump only for package @certd/ui-server diff --git a/packages/ui/certd-server/package.json b/packages/ui/certd-server/package.json index e1a07e55..4c0f1e75 100644 --- a/packages/ui/certd-server/package.json +++ b/packages/ui/certd-server/package.json @@ -1,7 +1,7 @@ { - "name": "my-midway-esm-project", - "version": "1.0.0", - "description": "", + "name": "@certd/ui-server", + "version": "1.21.2", + "description": "fast-server base midway", "private": true, "type": "module", "scripts": { @@ -19,12 +19,10 @@ "@alicloud/cs20151215": "^3.0.3", "@alicloud/openapi-client": "^0.4.0", "@alicloud/pop-core": "^1.7.10", - "@certd/acme-client": "^1.21.0", - "@certd/lib-huawei": "^1.21.0", - "@certd/lib-k8s": "^1.21.0", - "@certd/midway-flyway-js": "^1.21.0", - "@certd/pipeline": "^1.21.0", - "@certd/plugin-cert": "^1.21.0", + "@certd/acme-client": "^1.21.2", + "@certd/pipeline": "^1.21.2", + "@certd/plugin-cert": "^1.21.2", + "@certd/plugin-util": "^1.21.2", "@koa/cors": "^3.4.3", "@midwayjs/bootstrap": "^3.16.2", "@midwayjs/cache": "^3.14.0", diff --git a/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts b/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts index 899cdb59..39496322 100644 --- a/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts +++ b/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts @@ -96,7 +96,9 @@ export class AsyncSsh2Client { .stderr.on('data', (ret: Buffer) => { const err = this.convert(ret); data += err; - this.logger.info(`[${this.connConf.host}][error]: ` + err.trimEnd()); + this.logger.info( + `[${this.connConf.host}][error]: ` + err.trimEnd() + ); }); }); }); @@ -152,30 +154,39 @@ export class SshClient { } * @param options */ - async uploadFiles(options: { connectConf: SshAccess; transports: any }) { - const { connectConf, transports } = options; + async uploadFiles(options: { + connectConf: SshAccess; + transports: any; + mkdirs: boolean; + }) { + const { connectConf, transports, mkdirs } = options; await this._call({ connectConf, callable: async (conn: AsyncSsh2Client) => { const sftp = await conn.getSftp(); this.logger.info('开始上传'); for (const transport of transports) { - const filePath = path.dirname(transport.remotePath); - let mkdirCmd = `mkdir -p ${filePath} `; - if (conn.windows) { - if (filePath.indexOf('/') > -1) { - this.logger.info('--------------------------'); - this.logger.info('请注意:windows下,文件目录分隔应该写成\\而不是/'); - this.logger.info('--------------------------'); - } - const spec = await conn.exec('echo %COMSPEC%'); - if (spec.toString().trim() === '%COMSPEC%') { - mkdirCmd = `New-Item -ItemType Directory -Path "${filePath}" -Force`; - } else { - mkdirCmd = `if not exist "${filePath}" mkdir "${filePath}"`; + if (mkdirs !== false) { + const filePath = path.dirname(transport.remotePath); + let mkdirCmd = `mkdir -p ${filePath} `; + if (conn.windows) { + if (filePath.indexOf('/') > -1) { + this.logger.info('--------------------------'); + this.logger.info( + '请注意:windows下,文件目录分隔应该写成\\而不是/' + ); + this.logger.info('--------------------------'); + } + const spec = await conn.exec('echo %COMSPEC%'); + if (spec.toString().trim() === '%COMSPEC%') { + mkdirCmd = `New-Item -ItemType Directory -Path "${filePath}" -Force`; + } else { + mkdirCmd = `if not exist "${filePath}" mkdir "${filePath}"`; + } } + await conn.exec(mkdirCmd); } - await conn.exec(mkdirCmd); + await conn.fastPut({ sftp, ...transport }); } this.logger.info('文件全部上传成功'); diff --git a/packages/ui/certd-server/src/plugins/plugin-host/plugin/upload-to-host/index.ts b/packages/ui/certd-server/src/plugins/plugin-host/plugin/upload-to-host/index.ts index a4e8196a..fd98ddd8 100644 --- a/packages/ui/certd-server/src/plugins/plugin-host/plugin/upload-to-host/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-host/plugin/upload-to-host/index.ts @@ -48,6 +48,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin { required: true, }) cert!: CertInfo; + @TaskInput({ title: '主机登录配置', helper: 'access授权', @@ -59,13 +60,24 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin { }) accessId!: string; + @TaskInput({ + title: '自动创建远程目录', + helper: '是否自动创建远程目录,如果关闭则你需要自己确保远程目录存在', + default: true, + component: { + name: 'a-switch', + vModel: 'checked', + }, + }) + mkdirs = true; + @TaskInput({ title: '仅复制到当前主机', helper: '开启后,将直接复制到当前主机某个目录,不上传到主机,由于是docker启动,实际上是复制到docker容器内的“证书保存路径”,你需要事先在docker-compose.yaml中配置主机目录映射: volumes: /your_target_path:/your_target_path', + default: false, component: { name: 'a-switch', - default: false, vModel: 'checked', }, }) @@ -102,39 +114,58 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin { this.logger.info('将证书写入本地缓存文件'); const saveCrtPath = certReader.saveToFile('crt'); const saveKeyPath = certReader.saveToFile('key'); - - if (this.copyToThisHost) { - this.logger.info('复制到目标路径'); - this.copyFile(saveCrtPath, crtPath); - this.copyFile(saveKeyPath, keyPath); - this.logger.info('证书复制成功:crtPath=', crtPath, ',keyPath=', keyPath); - } else { - if (!accessId) { - throw new Error('主机登录授权配置不能为空'); + this.logger.info('本地文件写入成功'); + try { + if (this.copyToThisHost) { + this.logger.info('复制到目标路径'); + this.copyFile(saveCrtPath, crtPath); + this.copyFile(saveKeyPath, keyPath); + this.logger.info( + '证书复制成功:crtPath=', + crtPath, + ',keyPath=', + keyPath + ); + } else { + if (!accessId) { + throw new Error('主机登录授权配置不能为空'); + } + this.logger.info('准备上传文件到服务器'); + const connectConf: SshAccess = await this.accessService.getById( + accessId + ); + const sshClient = new SshClient(this.logger); + await sshClient.uploadFiles({ + connectConf, + transports: [ + { + localPath: saveCrtPath, + remotePath: crtPath, + }, + { + localPath: saveKeyPath, + remotePath: keyPath, + }, + ], + mkdirs: this.mkdirs, + }); + this.logger.info( + '证书上传成功:crtPath=', + crtPath, + ',keyPath=', + keyPath + ); } - this.logger.info('准备上传到服务器'); - const connectConf: SshAccess = await this.accessService.getById(accessId); - const sshClient = new SshClient(this.logger); - await sshClient.uploadFiles({ - connectConf, - transports: [ - { - localPath: saveCrtPath, - remotePath: crtPath, - }, - { - localPath: saveKeyPath, - remotePath: keyPath, - }, - ], - }); - this.logger.info('证书上传成功:crtPath=', crtPath, ',keyPath=', keyPath); + } catch (e) { + this.logger.error(`上传失败:${e.message}`); + throw e; + } finally { + //删除临时文件 + this.logger.info('删除临时文件'); + fs.unlinkSync(saveCrtPath); + fs.unlinkSync(saveKeyPath); } - - //删除临时文件 - fs.unlinkSync(saveCrtPath); - fs.unlinkSync(saveKeyPath); - + this.logger.info('执行完成'); //输出 this.hostCrtPath = crtPath; this.hostKeyPath = keyPath; diff --git a/publish-check.js b/publish-check.js new file mode 100644 index 00000000..1beb67d5 --- /dev/null +++ b/publish-check.js @@ -0,0 +1,13 @@ + +import fs from 'fs' +function check(){ + const gitAdd = fs.readFileSync("./node_modules/@lerna-lite/version/dist/lib/git-add.js","utf-8") + if(gitAdd.indexOf("('git', ['add', '.']") > -1){ + console.log("git-add 已经修改过了") + }else{ + console.error("git-add 没有修改过") + throw new Error("git-add 还没修改过") + } +} + +check() \ No newline at end of file diff --git a/step.md b/step.md index 9f3b6d71..e1d00371 100644 --- a/step.md +++ b/step.md @@ -2,6 +2,8 @@ 本示例演示从创建证书申请任务到自动部署证书全流程 +> 申请证书->部署证书->设置定时执行->设置邮件通知 + ## 准备工作 1. 已部署CertD服务(可官方Demo自助注册体验 https://certd.handsfree.work/ ) 2. 注册一个域名(支持阿里云万网、腾讯云DnsPod、华为云)