Merge remote-tracking branch 'origin/v2' into v2

# Conflicts:
#	package.json
#	packages/core/pipeline/package.json
#	packages/libs/k8s/package.json
#	packages/plugins/plugin-cert/package.json
#	packages/ui/certd-server/package.json
#	packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts
#	packages/ui/certd-server/src/plugins/plugin-host/plugin/upload-to-host/index.ts
pull/101/head
xiaojunnuo 2024-07-15 01:33:04 +08:00
commit 2fd14430a2
28 changed files with 313 additions and 86 deletions

View File

@ -3,6 +3,19 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 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) # [1.21.0](https://github.com/certd/certd/compare/v1.20.17...v1.21.0) (2024-07-03)
### Features ### Features

View File

@ -1,13 +1,15 @@
# CertD # CertD
CertD 是一个免费全自动申请和部署SSL证书的工具。 CertD 是一个免费全自动申请和自动部署更新SSL证书的工具。
后缀D取自linux守护进程的命名风格意为证书守护进程。 后缀D取自linux守护进程的命名风格意为证书守护进程。
关键字:证书自动申请、证书自动更新、证书自动续期、证书自动续签
## 一、特性 ## 一、特性
本项目不仅支持证书申请过程自动化,还可以自动化部署证书,让你的证书永不过期。 本项目不仅支持证书申请过程自动化,还可以自动化部署更新证书,让你的证书永不过期。
* 全自动申请证书支持阿里云、腾讯云、华为云、Cloudflare注册的域名 * 全自动申请证书支持阿里云、腾讯云、华为云、Cloudflare注册的域名
* 全自动部署证书(目前支持服务器上传部署、部署到阿里云、腾讯云等) * 全自动部署更新证书(目前支持服务器上传部署、部署到阿里云、腾讯云等)
* 支持通配符域名 * 支持通配符域名
* 支持多个域名打到一个证书上 * 支持多个域名打到一个证书上
* 邮件通知 * 邮件通知
@ -108,8 +110,8 @@ http://your_server_ip:7001
* http-01 在网站根目录下放置一份txt文件 * http-01 在网站根目录下放置一份txt文件
* dns-01 需要给域名添加txt解析记录通配符域名只能用这种方式 * dns-01 需要给域名添加txt解析记录通配符域名只能用这种方式
* 证书续期: * 证书续期:
* 实际上acme并没有续期概念 * 实际上没有办法不改变证书文件本身情况下直接续期或者续签
* 我们所说的续期,其实就是按照全套流程重新申请一份新证书。 * 我们所说的续期,其实就是按照全套流程重新申请一份新证书,然后重新部署上去
* 免费证书过期时间90天以后可能还会缩短所以自动化部署必不可少 * 免费证书过期时间90天以后可能还会缩短所以自动化部署必不可少
* 设置每天自动运行当证书过期前20天会自动重新申请证书并部署 * 设置每天自动运行当证书过期前20天会自动重新申请证书并部署
@ -172,3 +174,7 @@ docker compose up -d
* [袖手GPT](https://ai.handsfree.work/) ChatGPT国内可用无需FQ每日免费额度 * [袖手GPT](https://ai.handsfree.work/) ChatGPT国内可用无需FQ每日免费额度
* [fast-crud](https://gitee.com/fast-crud/fast-crud/) 基于vue3的crud快速开发框架 * [fast-crud](https://gitee.com/fast-crud/fast-crud/) 基于vue3的crud快速开发框架
* [dev-sidecar](https://github.com/docmirror/dev-sidecar/) 直连访问github工具无需FQ解决github无法访问的问题 * [dev-sidecar](https://github.com/docmirror/dev-sidecar/) 直连访问github工具无需FQ解决github无法访问的问题
## 十二、版本更新日志
https://github.com/certd/certd/blob/v2/CHANGELOG.md

View File

@ -1,6 +1,5 @@
import http from 'axios' import http from 'axios'
import fs from 'fs' import fs from 'fs'
//读取 packages/core/pipline/package.json的版本号 //读取 packages/core/pipline/package.json的版本号
import {default as packageJson} from './packages/core/pipeline/package.json' assert { type: "json" }; import {default as packageJson} from './packages/core/pipeline/package.json' assert { type: "json" };

View File

@ -9,5 +9,5 @@
} }
}, },
"npmClient": "pnpm", "npmClient": "pnpm",
"version": "1.21.0" "version": "1.21.2"
} }

View File

@ -14,9 +14,10 @@
"i-all": "lerna link && lerna exec npm install ", "i-all": "lerna link && lerna exec npm install ",
"publish": "npm run prepublishOnly1 && lerna publish --conventional-commits && npm run afterpublishOnly && npm run deploy1", "publish": "npm run prepublishOnly1 && lerna publish --conventional-commits && npm run afterpublishOnly && npm run deploy1",
"afterpublishOnly": "", "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\"", "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 ", "deploy1": "node --experimental-json-modules deploy.js ",
"check": "node --experimental-json-modules publish-check.js"
"init": "lerna run build" "init": "lerna run build"
}, },
"license": "AGPL-3.0", "license": "AGPL-3.0",

View File

@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 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) # [1.21.0](https://github.com/publishlab/node-acme-client/compare/v1.20.17...v1.21.0) (2024-07-03)
### Features ### Features

View File

@ -1 +1 @@
01:14 15:57

View File

@ -3,7 +3,7 @@
"description": "Simple and unopinionated ACME client", "description": "Simple and unopinionated ACME client",
"private": false, "private": false,
"author": "nmorsman", "author": "nmorsman",
"version": "1.21.0", "version": "1.21.2",
"main": "src/index.js", "main": "src/index.js",
"types": "types/index.d.ts", "types": "types/index.d.ts",
"license": "MIT", "license": "MIT",

View File

@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 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) # [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 **Note:** Version bump only for package @certd/pipeline

View File

@ -1,7 +1,7 @@
{ {
"name": "@certd/pipeline", "name": "@certd/pipeline",
"private": false, "private": false,
"version": "1.21.0", "version": "1.21.2",
"type": "module", "type": "module",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -21,7 +21,7 @@
"qs": "^6.11.2" "qs": "^6.11.2"
}, },
"devDependencies": { "devDependencies": {
"@certd/acme-client": "workspace:^1.21.0", "@certd/acme-client": "workspace:^1.21.2",
"@rollup/plugin-commonjs": "^23.0.4", "@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-node-resolve": "^15.0.1",

View File

@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 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) # [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 **Note:** Version bump only for package @certd/plugin-util

View File

@ -1,7 +1,7 @@
{ {
"name": "@certd/lib-k8s", "name": "@certd/lib-k8s",
"private": false, "private": false,
"version": "1.21.0", "version": "1.21.2",
"type": "module", "type": "module",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -17,7 +17,7 @@
"kubernetes-client": "^9.0.0" "kubernetes-client": "^9.0.0"
}, },
"devDependencies": { "devDependencies": {
"@certd/pipeline": "workspace:^1.21.0", "@certd/pipeline": "workspace:^1.21.2",
"@rollup/plugin-commonjs": "^23.0.4", "@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-node-resolve": "^15.0.1",

View File

@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 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) # [1.21.0](https://github.com/certd/certd/compare/v1.20.17...v1.21.0) (2024-07-03)
### Features ### Features

View File

@ -1,7 +1,7 @@
{ {
"name": "@certd/plugin-cert", "name": "@certd/plugin-cert",
"private": false, "private": false,
"version": "1.21.0", "version": "1.21.2",
"type": "module", "type": "module",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -13,8 +13,8 @@
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"@certd/acme-client": "workspace:^1.21.0", "@certd/acme-client": "workspace:^1.21.2",
"@certd/pipeline": "workspace:^1.21.0", "@certd/pipeline": "workspace:^1.21.2",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"node-forge": "^0.10.0", "node-forge": "^0.10.0",
"psl": "^1.9.0" "psl": "^1.9.0"

View File

@ -18,12 +18,20 @@ export class AcmeService {
userContext: IContext; userContext: IContext;
logger: Logger; logger: Logger;
sslProvider: SSLProvider; sslProvider: SSLProvider;
skipLocalVerify = true;
eab?: ClientExternalAccountBindingOptions; 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.userContext = options.userContext;
this.logger = options.logger; this.logger = options.logger;
this.sslProvider = options.sslProvider || "letsencrypt"; this.sslProvider = options.sslProvider || "letsencrypt";
this.eab = options.eab; this.eab = options.eab;
this.skipLocalVerify = options.skipLocalVerify ?? false;
acme.setLogger((text: string) => { acme.setLogger((text: string) => {
this.logger.info(text); this.logger.info(text);
}); });
@ -192,7 +200,7 @@ export class AcmeService {
csr, csr,
email: email, email: email,
termsOfServiceAgreed: true, termsOfServiceAgreed: true,
skipChallengeVerification: false, skipChallengeVerification: this.skipLocalVerify,
challengePriority: ["dns-01"], challengePriority: ["dns-01"],
challengeCreateFn: async (authz: acme.Authorization, challenge: Challenge, keyAuthorization: string): Promise<any> => { challengeCreateFn: async (authz: acme.Authorization, challenge: Challenge, keyAuthorization: string): Promise<any> => {
return await this.challengeCreateFn(authz, challenge, keyAuthorization, dnsProvider); return await this.challengeCreateFn(authz, challenge, keyAuthorization, dnsProvider);

View File

@ -39,10 +39,10 @@ export class CertApplyPlugin extends AbstractTaskPlugin {
span: 24, span: 24,
}, },
helper: helper:
"支持通配符域名,例如: *.foo.com、foo.com、*.test.handsfree.work\n" + "1、支持通配符域名,例如: *.foo.com、foo.com、*.test.handsfree.work\n" +
"支持多个域名、多个子域名、多个通配符域名打到一个证书上域名必须是在同一个DNS提供商解析\n" + "2、支持多个域名、多个子域名、多个通配符域名打到一个证书上域名必须是在同一个DNS提供商解析\n" +
"多级子域名要分成多个域名输入(*.foo.com的证书不能用于xxx.yyy.foo.com、foo.com\n" + "3、多级子域名要分成多个域名输入(*.foo.com的证书不能用于xxx.yyy.foo.com、foo.com\n" +
"输入一个回车之后,再输入下一个", "4、输入一个回车之后,再输入下一个",
}) })
domains!: string; domains!: string;
@ -110,6 +110,17 @@ export class CertApplyPlugin extends AbstractTaskPlugin {
}) })
dnsProviderAccess!: string; dnsProviderAccess!: string;
@TaskInput({
title: "跳过本地校验DNS",
default: false,
component: {
name: "a-switch",
vModel: "checked",
},
helper: "如果重试多次出现Authorization not found TXT record导致无法申请成功请尝试开启此选项",
})
skipLocalVerify = false;
@TaskInput({ @TaskInput({
title: "更新天数", title: "更新天数",
component: { component: {
@ -166,7 +177,13 @@ export class CertApplyPlugin extends AbstractTaskPlugin {
if (this.eabAccessId) { if (this.eabAccessId) {
eab = await this.ctx.accessService.getById(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<void> { async execute(): Promise<void> {

View File

@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 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) # [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 **Note:** Version bump only for package @certd/ui-client

View File

@ -1,6 +1,6 @@
{ {
"name": "@certd/ui-client", "name": "@certd/ui-client",
"version": "1.21.0", "version": "1.21.2",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite --open", "dev": "vite --open",
@ -59,7 +59,7 @@
"vuedraggable": "^2.24.3" "vuedraggable": "^2.24.3"
}, },
"devDependencies": { "devDependencies": {
"@certd/pipeline": "^1.21.0", "@certd/pipeline": "^1.21.2",
"@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-node-resolve": "^15.2.3",
"@types/chai": "^4.3.12", "@types/chai": "^4.3.12",

View File

@ -222,6 +222,10 @@ export default {
); );
} }
} }
//
if (input.default != null && currentStep.value.input[key] == null) {
currentStep.value.input[key] = input.default ?? input.value;
}
} }
} }

View File

@ -1,7 +1,7 @@
import * as api from "./api"; import * as api from "./api";
import { utils, dict, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, UserPageQuery, UserPageRes, EditReq, DelReq, AddReq, ScopeContext } from "@fast-crud/fast-crud"; 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 { FsUploaderFormOptions } from "@fast-crud/fast-extends";
import "./editor.css";
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet { export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => { const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query); return await api.GetList(query);
@ -79,6 +79,11 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
show: false show: false
}, },
type: "editor-wang5", // 富文本图片上传依赖file-uploader请先配置好file-uploader type: "editor-wang5", // 富文本图片上传依赖file-uploader请先配置好file-uploader
viewForm: {
render({ value }) {
return <div class={"editor-content-view"} v-html={value}></div>;
}
},
form: { form: {
helper: "示例已升级到wangEditor5版本原来的editor-wang目前仍然可以使用后续fs升级可能会将其删除请尽快升级到editor-wang5版本", helper: "示例已升级到wangEditor5版本原来的editor-wang目前仍然可以使用后续fs升级可能会将其删除请尽快升级到editor-wang5版本",
col: { span: 24 }, col: { span: 24 },

View File

@ -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;
}

View File

@ -57,7 +57,17 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
multiple: true, //可选择多个 multiple: true, //可选择多个
uploader: { uploader: {
type: "form", 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: "可以同时选择多个文件" helper: "可以同时选择多个文件"

View File

@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 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) # [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 **Note:** Version bump only for package @certd/ui-server

View File

@ -1,7 +1,7 @@
{ {
"name": "my-midway-esm-project", "name": "@certd/ui-server",
"version": "1.0.0", "version": "1.21.2",
"description": "", "description": "fast-server base midway",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
@ -19,12 +19,10 @@
"@alicloud/cs20151215": "^3.0.3", "@alicloud/cs20151215": "^3.0.3",
"@alicloud/openapi-client": "^0.4.0", "@alicloud/openapi-client": "^0.4.0",
"@alicloud/pop-core": "^1.7.10", "@alicloud/pop-core": "^1.7.10",
"@certd/acme-client": "^1.21.0", "@certd/acme-client": "^1.21.2",
"@certd/lib-huawei": "^1.21.0", "@certd/pipeline": "^1.21.2",
"@certd/lib-k8s": "^1.21.0", "@certd/plugin-cert": "^1.21.2",
"@certd/midway-flyway-js": "^1.21.0", "@certd/plugin-util": "^1.21.2",
"@certd/pipeline": "^1.21.0",
"@certd/plugin-cert": "^1.21.0",
"@koa/cors": "^3.4.3", "@koa/cors": "^3.4.3",
"@midwayjs/bootstrap": "^3.16.2", "@midwayjs/bootstrap": "^3.16.2",
"@midwayjs/cache": "^3.14.0", "@midwayjs/cache": "^3.14.0",

View File

@ -96,7 +96,9 @@ export class AsyncSsh2Client {
.stderr.on('data', (ret: Buffer) => { .stderr.on('data', (ret: Buffer) => {
const err = this.convert(ret); const err = this.convert(ret);
data += err; 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 * @param options
*/ */
async uploadFiles(options: { connectConf: SshAccess; transports: any }) { async uploadFiles(options: {
const { connectConf, transports } = options; connectConf: SshAccess;
transports: any;
mkdirs: boolean;
}) {
const { connectConf, transports, mkdirs } = options;
await this._call({ await this._call({
connectConf, connectConf,
callable: async (conn: AsyncSsh2Client) => { callable: async (conn: AsyncSsh2Client) => {
const sftp = await conn.getSftp(); const sftp = await conn.getSftp();
this.logger.info('开始上传'); this.logger.info('开始上传');
for (const transport of transports) { for (const transport of transports) {
const filePath = path.dirname(transport.remotePath); if (mkdirs !== false) {
let mkdirCmd = `mkdir -p ${filePath} `; const filePath = path.dirname(transport.remotePath);
if (conn.windows) { let mkdirCmd = `mkdir -p ${filePath} `;
if (filePath.indexOf('/') > -1) { if (conn.windows) {
this.logger.info('--------------------------'); if (filePath.indexOf('/') > -1) {
this.logger.info('请注意windows下文件目录分隔应该写成\\而不是/'); this.logger.info('--------------------------');
this.logger.info('--------------------------'); this.logger.info(
} '请注意windows下文件目录分隔应该写成\\而不是/'
const spec = await conn.exec('echo %COMSPEC%'); );
if (spec.toString().trim() === '%COMSPEC%') { this.logger.info('--------------------------');
mkdirCmd = `New-Item -ItemType Directory -Path "${filePath}" -Force`; }
} else { const spec = await conn.exec('echo %COMSPEC%');
mkdirCmd = `if not exist "${filePath}" mkdir "${filePath}"`; 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 }); await conn.fastPut({ sftp, ...transport });
} }
this.logger.info('文件全部上传成功'); this.logger.info('文件全部上传成功');

View File

@ -48,6 +48,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
required: true, required: true,
}) })
cert!: CertInfo; cert!: CertInfo;
@TaskInput({ @TaskInput({
title: '主机登录配置', title: '主机登录配置',
helper: 'access授权', helper: 'access授权',
@ -59,13 +60,24 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
}) })
accessId!: string; accessId!: string;
@TaskInput({
title: '自动创建远程目录',
helper: '是否自动创建远程目录,如果关闭则你需要自己确保远程目录存在',
default: true,
component: {
name: 'a-switch',
vModel: 'checked',
},
})
mkdirs = true;
@TaskInput({ @TaskInput({
title: '仅复制到当前主机', title: '仅复制到当前主机',
helper: helper:
'开启后将直接复制到当前主机某个目录不上传到主机由于是docker启动实际上是复制到docker容器内的“证书保存路径”你需要事先在docker-compose.yaml中配置主机目录映射 volumes: /your_target_path:/your_target_path', '开启后将直接复制到当前主机某个目录不上传到主机由于是docker启动实际上是复制到docker容器内的“证书保存路径”你需要事先在docker-compose.yaml中配置主机目录映射 volumes: /your_target_path:/your_target_path',
default: false,
component: { component: {
name: 'a-switch', name: 'a-switch',
default: false,
vModel: 'checked', vModel: 'checked',
}, },
}) })
@ -102,39 +114,58 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
this.logger.info('将证书写入本地缓存文件'); this.logger.info('将证书写入本地缓存文件');
const saveCrtPath = certReader.saveToFile('crt'); const saveCrtPath = certReader.saveToFile('crt');
const saveKeyPath = certReader.saveToFile('key'); const saveKeyPath = certReader.saveToFile('key');
this.logger.info('本地文件写入成功');
if (this.copyToThisHost) { try {
this.logger.info('复制到目标路径'); if (this.copyToThisHost) {
this.copyFile(saveCrtPath, crtPath); this.logger.info('复制到目标路径');
this.copyFile(saveKeyPath, keyPath); this.copyFile(saveCrtPath, crtPath);
this.logger.info('证书复制成功crtPath=', crtPath, ',keyPath=', keyPath); this.copyFile(saveKeyPath, keyPath);
} else { this.logger.info(
if (!accessId) { '证书复制成功crtPath=',
throw new Error('主机登录授权配置不能为空'); 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('准备上传到服务器'); } catch (e) {
const connectConf: SshAccess = await this.accessService.getById(accessId); this.logger.error(`上传失败:${e.message}`);
const sshClient = new SshClient(this.logger); throw e;
await sshClient.uploadFiles({ } finally {
connectConf, //删除临时文件
transports: [ this.logger.info('删除临时文件');
{ fs.unlinkSync(saveCrtPath);
localPath: saveCrtPath, fs.unlinkSync(saveKeyPath);
remotePath: crtPath,
},
{
localPath: saveKeyPath,
remotePath: keyPath,
},
],
});
this.logger.info('证书上传成功crtPath=', crtPath, ',keyPath=', keyPath);
} }
this.logger.info('执行完成');
//删除临时文件
fs.unlinkSync(saveCrtPath);
fs.unlinkSync(saveKeyPath);
//输出 //输出
this.hostCrtPath = crtPath; this.hostCrtPath = crtPath;
this.hostKeyPath = keyPath; this.hostKeyPath = keyPath;

13
publish-check.js Normal file
View File

@ -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()

View File

@ -2,6 +2,8 @@
本示例演示从创建证书申请任务到自动部署证书全流程 本示例演示从创建证书申请任务到自动部署证书全流程
> 申请证书->部署证书->设置定时执行->设置邮件通知
## 准备工作 ## 准备工作
1. 已部署CertD服务可官方Demo自助注册体验 https://certd.handsfree.work/ 1. 已部署CertD服务可官方Demo自助注册体验 https://certd.handsfree.work/
2. 注册一个域名支持阿里云万网、腾讯云DnsPod、华为云 2. 注册一个域名支持阿里云万网、腾讯云DnsPod、华为云