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

# Conflicts:
#	packages/ui/certd-server/src/plugins/plugin-other/plugins/index.ts
pull/189/head
xiaojunnuo 2024-09-16 15:52:35 +08:00
commit 4c37ec3222
59 changed files with 618 additions and 179 deletions

View File

@ -64,10 +64,10 @@ jobs:
username: ${{ secrets.dockerhub_username }} username: ${{ secrets.dockerhub_username }}
password: ${{ secrets.dockerhub_password }} password: ${{ secrets.dockerhub_password }}
- name: Build and push - name: Build default platforms
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
platforms: linux/amd64,linux/arm64,linux/arm/v7 platforms: linux/amd64,linux/arm64
push: true push: true
context: ./packages/ui/ context: ./packages/ui/
tags: | tags: |
@ -75,3 +75,15 @@ jobs:
registry.cn-shenzhen.aliyuncs.com/handsfree/certd:${{steps.get_certd_version.outputs.result}} registry.cn-shenzhen.aliyuncs.com/handsfree/certd:${{steps.get_certd_version.outputs.result}}
greper/certd:latest greper/certd:latest
greper/certd:${{steps.get_certd_version.outputs.result}} greper/certd:${{steps.get_certd_version.outputs.result}}
- name: Build armv7
uses: docker/build-push-action@v6
with:
platforms: linux/arm/v7
push: true
context: ./packages/ui/
tags: |
registry.cn-shenzhen.aliyuncs.com/handsfree/certd:armv7
registry.cn-shenzhen.aliyuncs.com/handsfree/certd:${{steps.get_certd_version.outputs.result}}-armv7
greper/certd:armv7
greper/certd:${{steps.get_certd_version.outputs.result}}-armv7

View File

@ -3,6 +3,20 @@
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.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
### Bug Fixes
* 修复腾讯云cdn证书部署后会自动关闭hstshttp2.0等配置的bug ([7908ab7](https://github.com/certd/certd/commit/7908ab79da624c94fa05849925b15e480e3317c4))
* 修复腾讯云tke证书部署报错的bug ([653f409](https://github.com/certd/certd/commit/653f409d91a441850d6381f89a8dd390831f0d5e))
### Performance Improvements
* 插件选择支持搜索 ([d1498a7](https://github.com/certd/certd/commit/d1498a71601b74d38343b1d070eadd03705dd9d5))
* 前置任务步骤增加错误提示 ([ae3daa9](https://github.com/certd/certd/commit/ae3daa9bcf4fc363825aad9b77f5d3879aeeff70))
* 群晖部署教程 ([0f0af2f](https://github.com/certd/certd/commit/0f0af2f309390f388e7a272cea3a1dd30c01977d))
* 支持群晖 ([5c270b6](https://github.com/certd/certd/commit/5c270b6b9d45a2152f9fdb3c07bd98b7c803cb8e))
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06) ## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
### Performance Improvements ### Performance Improvements

View File

@ -13,7 +13,7 @@ https://afdian.com/a/greper
1. 可加入发电专属群,可以获得作者一对一技术支持 1. 可加入发电专属群,可以获得作者一对一技术支持
2. 您的需求我们将优先实现,并且将作为专业版功能提供 2. 您的需求我们将优先实现,并且将作为专业版功能提供
3. 一年期专业版激活码 3. 一年期专业版激活码
4. 赠送国外免费服务器部署方案0成本使用Certd不过该服务器需要翻墙 4. 赠送国外免费服务器部署方案0成本使用Certd可能需要翻墙,不过现在性能越来越差了
专业版特权 专业版特权
1. 证书流水线条数无限制免费版限制10条 1. 证书流水线条数无限制免费版限制10条
@ -101,9 +101,11 @@ docker compose up -d
#### 镜像说明: #### 镜像说明:
* 国内镜像地址: * 国内镜像地址:
* `registry.cn-shenzhen.aliyuncs.com/handsfree/certd:latest` * `registry.cn-shenzhen.aliyuncs.com/handsfree/certd:latest`
* `registry.cn-shenzhen.aliyuncs.com/handsfree/certd:armv7`、`[version]-armv7`
* DockerHub地址 * DockerHub地址
* `https://hub.docker.com/r/greper/certd` * `https://hub.docker.com/r/greper/certd`
* `docker pull greper/certd:latest` * `greper/certd:latest`
* `greper/certd:armv7`、`greper/certd:[version]-armv7`
* 镜像构建通过`Actions`自动执行,过程公开透明,请放心使用 * 镜像构建通过`Actions`自动执行,过程公开透明,请放心使用
* [点我查看镜像构建日志](https://github.com/certd/certd/actions/workflows/build-image.yml) * [点我查看镜像构建日志](https://github.com/certd/certd/actions/workflows/build-image.yml)
@ -157,6 +159,7 @@ docker compose up -d
* [腾讯云](./doc/tencent/tencent.md) * [腾讯云](./doc/tencent/tencent.md)
* [windows主机](./doc/host/host.md) * [windows主机](./doc/host/host.md)
* [google证书](./doc/google/google.md) * [google证书](./doc/google/google.md)
* [群晖部署certd及证书更新教程](./doc/synology/index.md)
## 八、问题处理 ## 八、问题处理

View File

@ -1 +1 @@
7 1

0
doc/deploy/koyeb.md Normal file
View File

BIN
doc/synology/images/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

BIN
doc/synology/images/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
doc/synology/images/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
doc/synology/images/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

BIN
doc/synology/images/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

BIN
doc/synology/images/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

41
doc/synology/index.md Normal file
View File

@ -0,0 +1,41 @@
# 群晖部署和证书更新
## 一、群晖系统上部署Certd教程
### 1. 打开Container Manager
![](./images/1.png)
### 2. 新增项目
![](./images/2.png)
### 3. 配置Certd项目
![](./images/3.png)
### 4. 外网访问设置
![](./images/4.png)
### 5. 确认项目信息
![](./images/5.png)
点击完成安装等待certd启动完成即可
### 6. 门户配置向导【可选】
![](./images/6.png)
## 二、更新群晖证书
## 1. 前提条件
* 已经部署了certd
* 群晖上已经设置好了证书(证书建议设置好描述,插件需要根据描述查找证书)
## 2. 在certd上配置自动更新群晖证书插件
![](./images/deploy.png)

View File

@ -1,38 +1,40 @@
version: '3.3' #version: '3.3'
services: services:
certd: certd:
# 镜像 # ↓↓↓↓↓ --- 镜像版本号,建议改成固定版本号【可选】 # 镜像 # ↓↓↓↓↓ --- 镜像版本号,建议改成固定版本号
image: registry.cn-shenzhen.aliyuncs.com/handsfree/certd:latest image: registry.cn-shenzhen.aliyuncs.com/handsfree/certd:latest
container_name: certd # 容器名 container_name: certd # 容器名
restart: unless-stopped # 自动重启 restart: unless-stopped # 自动重启
volumes: volumes:
# ↓↓↓↓↓ -------------------------------------------------------- 数据库以及证书存储路径,默认存在宿主机的/data/certd/目录下【可选 # ↓↓↓↓↓ -------------------------------------------------------- 数据库以及证书存储路径,默认存在宿主机的/data/certd/目录下,【您需要定时备份此目录,以保障数据容灾
- /data/certd:/app/data - /data/certd:/app/data
ports: # 端口映射 ports: # 端口映射
# ↓↓↓↓ ---------------------------------------------------------- 如果端口有冲突可以修改第一个7001为其他不冲突的端口号【可选】 # ↓↓↓↓ ---------------------------------------------------------- 如果端口有冲突可以修改第一个7001为其他不冲突的端口号
- "7001:7001" - "7001:7001"
dns: dns:
# 如果出现getaddrinfo ENOTFOUND等错误可以尝试修改或注释dns配置 # ↓↓↓↓ ---------------------------------------------------------- 如果出现getaddrinfo ENOTFOUND等错误可以尝试修改或注释dns配置
- 223.5.5.5 - 223.5.5.5
- 223.6.6.6 - 223.6.6.6
# ↓↓↓↓ ---------------------------------------------------------- 如果你服务器部署在国外可以用8.8.8.8替换上面的dns【可选】 # ↓↓↓↓ ---------------------------------------------------------- 如果你服务器部署在国外可以用8.8.8.8替换上面的dns
# - 8.8.8.8 # - 8.8.8.8
# - 8.8.4.4 # - 8.8.4.4
# extra_hosts:
# ↓↓↓↓ ---------------------------------------------------------- 这里可以配置自定义hosts外网域名可以指向本地局域网ip地址
# - "localdomain.comm:192.168.1.3"
environment: # 环境变量 environment: # 环境变量
- TZ=Asia/Shanghai - TZ=Asia/Shanghai
#- HTTPS_PROXY=http://xxxxxx:xx #- HTTPS_PROXY=http://xxxxxx:xx
#- HTTP_PROXY=http://xxxxxx:xx #- HTTP_PROXY=http://xxxxxx:xx
# ↑↑↑↑↑ ------------------------------------- 这里可以设置http代理【可选】 # ↑↑↑↑↑ ------------------------------------- 这里可以设置http代理
- certd_system_resetAdminPasswd=false - certd_system_resetAdminPasswd=false
# ↑↑↑↑↑--------------------------- 如果忘记管理员密码可以设置为true重启之后管理员密码将改成123456然后请及时修改回false【可选】 # ↑↑↑↑↑--------------------------- 如果忘记管理员密码可以设置为true重启之后管理员密码将改成123456然后请及时修改回false
- certd_cron_immediateTriggerOnce=false - certd_cron_immediateTriggerOnce=false
# ↑↑↑↑↑--------------------------- 如果设置为true启动后所有配置了cron的流水线任务都将被立即触发一次【可选】 # ↑↑↑↑↑--------------------------- 如果设置为true启动后所有配置了cron的流水线任务都将被立即触发一次
- VITE_APP_ICP_NO= - VITE_APP_ICP_NO=
# ↑↑↑↑↑ ----------------------------------------- 这里可以设置备案号【可选】 # ↑↑↑↑↑ ----------------------------------------- 这里可以设置备案号
#- certd_koa_key=./data/ssl/cert.key #- certd_koa_key=./data/ssl/cert.key
#- certd_koa_cert=./data/ssl/cert.crt #- certd_koa_cert=./data/ssl/cert.crt
# ↑↑↑↑↑ ----------------------------------------- 配置证书和key则表示https方式启动访问网址要使用 https://your.domain:7001【可选】 # ↑↑↑↑↑ ----------------------------------------- 配置证书和key则表示https方式启动使用https协议访问https://your.domain:7001
# 设置环境变量即可自定义certd配置 # 设置环境变量即可自定义certd配置
# 服务端配置项见: packages/ui/certd-server/src/config/config.default.ts # 服务端配置项见: packages/ui/certd-server/src/config/config.default.ts
# 服务端配置规则: certd_ + 配置项, 点号用_代替 # 服务端配置规则: certd_ + 配置项, 点号用_代替

View File

@ -9,5 +9,5 @@
} }
}, },
"npmClient": "pnpm", "npmClient": "pnpm",
"version": "1.24.3" "version": "1.24.4"
} }

View File

@ -3,6 +3,10 @@
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.24.4](https://github.com/publishlab/node-acme-client/compare/v1.24.3...v1.24.4) (2024-09-09)
**Note:** Version bump only for package @certd/acme-client
## [1.24.3](https://github.com/publishlab/node-acme-client/compare/v1.24.2...v1.24.3) (2024-09-06) ## [1.24.3](https://github.com/publishlab/node-acme-client/compare/v1.24.2...v1.24.3) (2024-09-06)
**Note:** Version bump only for package @certd/acme-client **Note:** Version bump only for package @certd/acme-client

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.24.3", "version": "1.24.4",
"main": "src/index.js", "main": "src/index.js",
"types": "types/index.d.ts", "types": "types/index.d.ts",
"license": "MIT", "license": "MIT",
@ -59,5 +59,5 @@
"bugs": { "bugs": {
"url": "https://github.com/publishlab/node-acme-client/issues" "url": "https://github.com/publishlab/node-acme-client/issues"
}, },
"gitHead": "c49ccbde93dbad7062ac39d4f18eca7d561f573f" "gitHead": "6fe2d2c3288b698e9cbdc91725abcbb072278fab"
} }

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.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
### Performance Improvements
* 前置任务步骤增加错误提示 ([ae3daa9](https://github.com/certd/certd/commit/ae3daa9bcf4fc363825aad9b77f5d3879aeeff70))
* 群晖部署教程 ([0f0af2f](https://github.com/certd/certd/commit/0f0af2f309390f388e7a272cea3a1dd30c01977d))
* 支持群晖 ([5c270b6](https://github.com/certd/certd/commit/5c270b6b9d45a2152f9fdb3c07bd98b7c803cb8e))
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06) ## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
### Performance Improvements ### Performance Improvements

View File

@ -1 +1 @@
23:19 17:29

View File

@ -1,7 +1,7 @@
{ {
"name": "@certd/pipeline", "name": "@certd/pipeline",
"private": false, "private": false,
"version": "1.24.3", "version": "1.24.4",
"type": "module", "type": "module",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -20,6 +20,7 @@
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"node-forge": "^1.3.1", "node-forge": "^1.3.1",
"nodemailer": "^6.9.3", "nodemailer": "^6.9.3",
"proxy-agent": "^6.4.0",
"qs": "^6.11.2" "qs": "^6.11.2"
}, },
"devDependencies": { "devDependencies": {
@ -57,5 +58,5 @@
"vite": "^4.3.8", "vite": "^4.3.8",
"vue-tsc": "^1.6.5" "vue-tsc": "^1.6.5"
}, },
"gitHead": "c49ccbde93dbad7062ac39d4f18eca7d561f573f" "gitHead": "6fe2d2c3288b698e9cbdc91725abcbb072278fab"
} }

View File

@ -1,6 +1,4 @@
import { AxiosInstance } from "axios";
import { IContext } from "../core/index.js"; import { IContext } from "../core/index.js";
export type HttpClient = AxiosInstance;
export type UserContext = IContext; export type UserContext = IContext;
export type PipelineContext = IContext; export type PipelineContext = IContext;

View File

@ -12,7 +12,7 @@ import { RegistryItem } from "../registry/index.js";
import { Decorator } from "../decorator/index.js"; import { Decorator } from "../decorator/index.js";
import { IEmailService } from "../service/index.js"; import { IEmailService } from "../service/index.js";
import { FileStore } from "./file-store.js"; import { FileStore } from "./file-store.js";
import { hashUtils } from "../utils/index.js"; import { hashUtils, utils } from "../utils/index.js";
// import { TimeoutPromise } from "../utils/util.promise.js"; // import { TimeoutPromise } from "../utils/util.promise.js";
export type ExecutorOptions = { export type ExecutorOptions = {
@ -93,7 +93,7 @@ export class Executor {
await this.notification("success"); await this.notification("success");
} catch (e: any) { } catch (e: any) {
await this.notification("error", e); await this.notification("error", e);
this.logger.error("pipeline 执行失败", e.stack); this.logger.error("pipeline 执行失败", e);
} finally { } finally {
clearInterval(intervalFlushLogId); clearInterval(intervalFlushLogId);
await this.onChanged(this.runtime); await this.onChanged(this.runtime);
@ -104,11 +104,18 @@ export class Executor {
async runWithHistory(runnable: Runnable, runnableType: string, run: () => Promise<ResultType | void>) { async runWithHistory(runnable: Runnable, runnableType: string, run: () => Promise<ResultType | void>) {
runnable.runnableType = runnableType; runnable.runnableType = runnableType;
this.runtime.start(runnable); this.runtime.start(runnable);
// const timeout = runnable.timeout ?? 20 * 60 * 1000;
await this.onChanged(this.runtime);
try { try {
if (runnable.disabled) {
//该任务被禁用
this.runtime.disabled(runnable);
return ResultType.disabled;
}
await this.onChanged(this.runtime);
if (this.abort.signal.aborted) { if (this.abort.signal.aborted) {
this.runtime.cancel(runnable); this.runtime.cancel(runnable);
return ResultType.canceled; return ResultType.canceled;
@ -217,11 +224,17 @@ export class Executor {
if (item.component?.name === "pi-output-selector") { if (item.component?.name === "pi-output-selector") {
const contextKey = input[key]; const contextKey = input[key];
if (contextKey != null) { if (contextKey != null) {
if (typeof contextKey !== "string") {
throw new Error(`步骤${step.title}${item.title}属性必须为String类型请重新配置该属性`);
}
// "cert": "step.-BNFVPMKPu2O-i9NiOQxP.cert", // "cert": "step.-BNFVPMKPu2O-i9NiOQxP.cert",
const arr = contextKey.split("."); const arr = contextKey.split(".");
const id = arr[1]; const id = arr[1];
const outputKey = arr[2]; const outputKey = arr[2];
input[key] = this.currentStatusMap.get(id)?.status?.output[outputKey] ?? this.lastStatusMap.get(id)?.status?.output[outputKey]; input[key] = this.currentStatusMap.get(id)?.status?.output[outputKey] ?? this.lastStatusMap.get(id)?.status?.output[outputKey];
if (input[key] == null) {
this.logger.warn(`${item.title}的配置未找到对应的输出值,请确认对应的前置任务是否存在或者是否执行正确`);
}
} }
} }
}); });
@ -231,14 +244,13 @@ export class Executor {
//判断是否需要跳过 //判断是否需要跳过
const lastNode = this.lastStatusMap.get(step.id); const lastNode = this.lastStatusMap.get(step.id);
const lastResult = lastNode?.status?.status; const lastResult = lastNode?.status?.status;
if (step.strategy?.runStrategy === RunStrategy.SkipWhenSucceed) {
//如果是成功后跳过策略
let inputChanged = true; let inputChanged = true;
const lastInputHash = lastNode?.status?.inputHash; const lastInputHash = lastNode?.status?.inputHash;
if (lastInputHash && newInputHash && lastInputHash === newInputHash) { if (lastInputHash && newInputHash && lastInputHash === newInputHash) {
//参数有变化 //参数有变化
inputChanged = false; inputChanged = false;
} }
if (step.strategy?.runStrategy === RunStrategy.SkipWhenSucceed) {
if (lastResult != null && lastResult === ResultType.success && !inputChanged) { if (lastResult != null && lastResult === ResultType.success && !inputChanged) {
step.status!.output = lastNode?.status?.output; step.status!.output = lastNode?.status?.output;
step.status!.files = lastNode?.status?.files; step.status!.files = lastNode?.status?.files;
@ -253,6 +265,7 @@ export class Executor {
lastStatus, lastStatus,
http, http,
logger: currentLogger, logger: currentLogger,
inputChanged,
accessService: this.options.accessService, accessService: this.options.accessService,
emailService: this.options.emailService, emailService: this.options.emailService,
pipelineContext: this.pipelineContext, pipelineContext: this.pipelineContext,
@ -263,6 +276,7 @@ export class Executor {
rootDir: this.options.fileRootDir, rootDir: this.options.fileRootDir,
}), }),
signal: this.abort.signal, signal: this.abort.signal,
utils,
}; };
instance.setCtx(taskCtx); instance.setCtx(taskCtx);

View File

@ -74,6 +74,17 @@ export class RunHistory {
this.log(runnable, `跳过`); this.log(runnable, `跳过`);
} }
disabled(runnable: Runnable) {
const now = new Date().getTime();
const status = runnable.status;
_.merge(status, {
status: "canceled",
endTime: now,
result: "disabled",
});
this.log(runnable, `禁用`);
}
error(runnable: Runnable, e: Error) { error(runnable: Runnable, e: Error) {
const now = new Date().getTime(); const now = new Date().getTime();
const status = runnable.status; const status = runnable.status;
@ -107,8 +118,8 @@ export class RunHistory {
logError(runnable: Runnable, e: Error) { logError(runnable: Runnable, e: Error) {
// @ts-ignore // @ts-ignore
const errorInfo = runnable.runnableType == "step" ? e.stack : e.message; const errorInfo = runnable.runnableType === "step" ? e : e.message;
this._loggers[runnable.id].error(`[${runnable.runnableType}] [${runnable.title}]<id:${runnable.id}> ${errorInfo}`); this._loggers[runnable.id].error(`[${runnable.runnableType}] [${runnable.title}]<id:${runnable.id}> `, errorInfo);
} }
finally(runnable: Runnable) { finally(runnable: Runnable) {

View File

@ -70,6 +70,7 @@ export type Runnable = {
default?: { default?: {
[key: string]: any; [key: string]: any;
}; };
disabled?: boolean;
}; };
export type EmailOptions = { export type EmailOptions = {
@ -108,6 +109,7 @@ export enum ResultType {
error = "error", error = "error",
canceled = "canceled", canceled = "canceled",
skip = "skip", skip = "skip",
disabled = "disabled",
none = "none", none = "none",
} }

View File

@ -5,9 +5,9 @@ import { Logger } from "log4js";
import { IAccessService } from "../access/index.js"; import { IAccessService } from "../access/index.js";
import { IEmailService } from "../service/index.js"; import { IEmailService } from "../service/index.js";
import { IContext } from "../core/index.js"; import { IContext } from "../core/index.js";
import { AxiosInstance } from "axios";
import { ILogger, logger } from "../utils/index.js"; import { ILogger, logger } from "../utils/index.js";
import { HttpClient } from "../utils/util.request";
import { utils } from "../utils/index.js";
export enum ContextScope { export enum ContextScope {
global, global,
pipeline, pipeline,
@ -57,17 +57,32 @@ export type TaskResult = {
pipelineVars: Record<string, any>; pipelineVars: Record<string, any>;
}; };
export type TaskInstanceContext = { export type TaskInstanceContext = {
//流水线定义
pipeline: Pipeline; pipeline: Pipeline;
//步骤定义
step: Step; step: Step;
//日志
logger: Logger; logger: Logger;
//当前步骤输入参数跟上一次执行比较是否有变化
inputChanged: boolean;
//授权获取服务
accessService: IAccessService; accessService: IAccessService;
//邮件服务
emailService: IEmailService; emailService: IEmailService;
//流水线上下文
pipelineContext: IContext; pipelineContext: IContext;
//用户上下文
userContext: IContext; userContext: IContext;
http: AxiosInstance; //http请求客户端
http: HttpClient;
//文件存储
fileStore: FileStore; fileStore: FileStore;
//上一次执行结果状态
lastStatus?: Runnable; lastStatus?: Runnable;
//用户取消信号
signal: AbortSignal; signal: AbortSignal;
//工具类
utils: typeof utils;
}; };
export abstract class AbstractTaskPlugin implements ITaskPlugin { export abstract class AbstractTaskPlugin implements ITaskPlugin {

View File

@ -1,11 +1,22 @@
import sleep from "./util.sleep.js"; import sleep from "./util.sleep.js";
import { request } from "./util.request.js"; import { http } from "./util.request.js";
export * from "./util.request.js";
export * from "./util.log.js"; export * from "./util.log.js";
export * from "./util.file.js"; export * from "./util.file.js";
export * from "./util.sp.js"; export * from "./util.sp.js";
export * as promises from "./util.promise.js"; export * from "./util.promise.js";
export * from "./util.hash.js"; export * from "./util.hash.js";
import { sp } from "./util.sp.js";
import { hashUtils } from "./util.hash.js";
import { promises } from "./util.promise.js";
import { fileUtils } from "./util.file.js";
import _ from "lodash-es";
export const utils = { export const utils = {
sleep, sleep,
http: request, http,
sp,
hash: hashUtils,
promises,
file: fileUtils,
_,
}; };

View File

@ -24,3 +24,8 @@ export function safePromise<T>(callback: (resolve: (ret: T) => void, reject: (re
} }
}); });
} }
export const promises = {
TimeoutPromise,
safePromise,
};

View File

@ -1,29 +1,39 @@
import axios from "axios"; import axios, { AxiosRequestConfig } from "axios";
import { logger } from "./util.log.js"; import { logger } from "./util.log.js";
import { Logger } from "log4js"; import { Logger } from "log4js";
import { ProxyAgent, ProxyAgentOptions } from "proxy-agent";
export class HttpError extends Error { export class HttpError extends Error {
request?: { url: string; method: string; data?: any };
response?: { data: any };
status?: number; status?: number;
statusText?: string; statusText?: string;
code?: string;
request?: { url: string; method: string; params?: any; data?: any };
response?: { data: any };
cause?: any;
constructor(error: any) { constructor(error: any) {
if (!error) { if (!error) {
return; return;
} }
super(error.message); super(error.message);
this.name = error.name; this.name = error.name;
this.stack = error.stack; this.code = error.code;
this.status = error?.response?.status; this.cause = error.cause;
this.statusText = error?.response?.statusText;
this.status = error.response?.status;
this.statusText = error.response?.statusText;
this.request = { this.request = {
url: error?.response?.config?.url, url: error.config?.url,
method: error?.response?.config?.method, method: error.config?.method,
data: error?.response?.config?.data, params: error.config?.params,
data: error.config?.data,
}; };
this.response = { this.response = {
data: error?.response?.data, data: error.response?.data,
}; };
delete error.response;
delete error.config;
delete error.request;
logger.error(error);
} }
} }
/** /**
@ -32,10 +42,23 @@ export class HttpError extends Error {
export function createAxiosService({ logger }: { logger: Logger }) { export function createAxiosService({ logger }: { logger: Logger }) {
// 创建一个 axios 实例 // 创建一个 axios 实例
const service = axios.create(); const service = axios.create();
const defaultAgents = createAgent();
// 请求拦截 // 请求拦截
service.interceptors.request.use( service.interceptors.request.use(
(config: any) => { (config: any) => {
logger.info(`http request:${config.url}method:${config.method}`); logger.info(`http request:${config.url}method:${config.method}params:${JSON.stringify(config.params)}`);
if (config.timeout == null) {
config.timeout = 15000;
}
let agents = defaultAgents;
if (config.skipSslVerify) {
agents = createAgent({ rejectUnauthorized: config.rejectUnauthorized });
}
config.httpsAgent = agents.httpsAgent;
config.httpAgent = agents.httpAgent;
return config; return config;
}, },
(error: Error) => { (error: Error) => {
@ -51,25 +74,52 @@ export function createAxiosService({ logger }: { logger: Logger }) {
return response.data; return response.data;
}, },
(error: any) => { (error: any) => {
// const status = _.get(error, 'response.status') const status = error.response?.status;
// switch (status) { switch (status) {
// case 400: error.message = '请求错误'; break case 400:
// case 401: error.message = '未授权,请登录'; break error.message = "请求错误";
// case 403: error.message = '拒绝访问'; break break;
// case 404: error.message = `请求地址出错: ${error.response.config.url}`; break case 401:
// case 408: error.message = '请求超时'; break error.message = "未授权,请登录";
// case 500: error.message = '服务器内部错误'; break break;
// case 501: error.message = '服务未实现'; break case 403:
// case 502: error.message = '网关错误'; break error.message = "拒绝访问";
// case 503: error.message = '服务不可用'; break break;
// case 504: error.message = '网关超时'; break case 404:
// case 505: error.message = 'HTTP版本不受支持'; break error.message = `请求地址出错: ${error.response.config.url}`;
// default: break 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;
}
logger.error( logger.error(
`请求出错status:${error?.response?.status},statusText:${error?.response?.statusText},url:${error?.config?.url},method:${error?.config?.method}` `请求出错status:${error.response?.status},statusText:${error.response?.statusText},url:${error.config?.url},method:${error.config?.method}`
); );
logger.error("返回数据:", JSON.stringify(error?.response?.data)); logger.error("返回数据:", JSON.stringify(error.response?.data));
if (error instanceof AggregateError) {
logger.error(error);
}
const err = new HttpError(error); const err = new HttpError(error);
return Promise.reject(err); return Promise.reject(err);
} }
@ -77,4 +127,19 @@ export function createAxiosService({ logger }: { logger: Logger }) {
return service; return service;
} }
export const request = createAxiosService({ logger }); export const http = createAxiosService({ logger }) as HttpClient;
export type HttpClientResponse<R> = any;
export type HttpRequestConfig<D> = {
skipSslVerify?: boolean;
} & AxiosRequestConfig<D>;
export type HttpClient = {
request<D = any, R = any>(config: HttpRequestConfig<D>): Promise<HttpClientResponse<R>>;
};
export function createAgent(opts: ProxyAgentOptions = {}) {
const httpAgent = new ProxyAgent(opts);
return {
httpAgent,
httpsAgent: httpAgent,
};
}

View File

@ -3,6 +3,10 @@
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.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
**Note:** Version bump only for package @certd/lib-k8s
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06) ## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
**Note:** Version bump only for package @certd/lib-k8s **Note:** Version bump only for package @certd/lib-k8s

View File

@ -1,7 +1,7 @@
{ {
"name": "@certd/lib-k8s", "name": "@certd/lib-k8s",
"private": false, "private": false,
"version": "1.24.3", "version": "1.24.4",
"type": "module", "type": "module",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -16,7 +16,7 @@
"@kubernetes/client-node": "0.21.0" "@kubernetes/client-node": "0.21.0"
}, },
"devDependencies": { "devDependencies": {
"@certd/pipeline": "^1.24.3", "@certd/pipeline": "^1.24.4",
"@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",
@ -37,5 +37,5 @@
"tslib": "^2.5.2", "tslib": "^2.5.2",
"typescript": "^4.8.4" "typescript": "^4.8.4"
}, },
"gitHead": "c49ccbde93dbad7062ac39d4f18eca7d561f573f" "gitHead": "6fe2d2c3288b698e9cbdc91725abcbb072278fab"
} }

View File

@ -3,6 +3,10 @@
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.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
**Note:** Version bump only for package @certd/midway-flyway-js
## [1.22.6](https://github.com/certd/certd/compare/v1.22.5...v1.22.6) (2024-08-03) ## [1.22.6](https://github.com/certd/certd/compare/v1.22.5...v1.22.6) (2024-08-03)
**Note:** Version bump only for package @certd/midway-flyway-js **Note:** Version bump only for package @certd/midway-flyway-js

View File

@ -1,6 +1,6 @@
{ {
"name": "@certd/midway-flyway-js", "name": "@certd/midway-flyway-js",
"version": "1.22.6", "version": "1.24.4",
"description": "midway with flyway, sql upgrade way ", "description": "midway with flyway, sql upgrade way ",
"private": false, "private": false,
"type": "module", "type": "module",
@ -53,5 +53,5 @@
"typeorm": "^0.3.11", "typeorm": "^0.3.11",
"typescript": "~5.1.0" "typescript": "~5.1.0"
}, },
"gitHead": "e5da46cfc31b2e30a4903bcb2251b1851265ef41" "gitHead": "6fe2d2c3288b698e9cbdc91725abcbb072278fab"
} }

View File

@ -3,6 +3,12 @@
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.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
### Performance Improvements
* 支持群晖 ([5c270b6](https://github.com/certd/certd/commit/5c270b6b9d45a2152f9fdb3c07bd98b7c803cb8e))
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06) ## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
**Note:** Version bump only for package @certd/plugin-cert **Note:** Version bump only for package @certd/plugin-cert

View File

@ -1,7 +1,7 @@
{ {
"name": "@certd/plugin-cert", "name": "@certd/plugin-cert",
"private": false, "private": false,
"version": "1.24.3", "version": "1.24.4",
"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": "^1.24.3", "@certd/acme-client": "^1.24.4",
"@certd/pipeline": "^1.24.3", "@certd/pipeline": "^1.24.4",
"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"
@ -53,5 +53,5 @@
"vite": "^3.1.0", "vite": "^3.1.0",
"vue-tsc": "^0.38.9" "vue-tsc": "^0.38.9"
}, },
"gitHead": "c49ccbde93dbad7062ac39d4f18eca7d561f573f" "gitHead": "6fe2d2c3288b698e9cbdc91725abcbb072278fab"
} }

View File

@ -311,7 +311,7 @@ export class AcmeService {
private async testDirectory(directoryUrl: string) { private async testDirectory(directoryUrl: string) {
try { try {
await utils.http({ await utils.http.request({
url: directoryUrl, url: directoryUrl,
method: "GET", method: "GET",
timeout: 10000, timeout: 10000,

View File

@ -45,7 +45,7 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
email!: string; email!: string;
@TaskInput({ @TaskInput({
title: "PFX密码", title: "PFX证书密码",
component: { component: {
name: "a-input-password", name: "a-input-password",
vModel: "value", vModel: "value",
@ -191,14 +191,14 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
*/ */
async condition() { async condition() {
if (this.forceUpdate) { if (this.forceUpdate) {
this.logger.info("强制更新证书选项已勾选,准备申请新证书");
return null; return null;
} }
let inputChanged = false; const inputChanged = this.ctx.inputChanged;
const oldInput = JSON.stringify(this.lastStatus?.input?.domains); if (inputChanged) {
const thisInput = JSON.stringify(this.domains); this.logger.info("输入参数变更,准备申请新证书");
if (oldInput !== thisInput) { return null;
inputChanged = true;
} }
let oldCert: CertReader | undefined = undefined; let oldCert: CertReader | undefined = undefined;
@ -212,11 +212,6 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
return null; return null;
} }
if (inputChanged) {
this.logger.info("输入参数变更,申请新证书");
return null;
}
const ret = this.isWillExpire(oldCert.expires, this.renewDays); const ret = this.isWillExpire(oldCert.expires, this.renewDays);
if (!ret.isWillExpire) { if (!ret.isWillExpire) {
this.logger.info(`证书还未过期:过期时间${dayjs(oldCert.expires).format("YYYY-MM-DD HH:mm:ss")},剩余${ret.leftDays}`); this.logger.info(`证书还未过期:过期时间${dayjs(oldCert.expires).format("YYYY-MM-DD HH:mm:ss")},剩余${ret.leftDays}`);

View File

@ -69,13 +69,15 @@ export class CertReader {
const tmpDerPath = this.saveToFile("der"); const tmpDerPath = this.saveToFile("der");
logger.info("本地文件写入成功"); logger.info("本地文件写入成功");
try { try {
await opts.handle({ return await opts.handle({
reader: this, reader: this,
tmpCrtPath: tmpCrtPath, tmpCrtPath: tmpCrtPath,
tmpKeyPath: tmpKeyPath, tmpKeyPath: tmpKeyPath,
tmpPfxPath: tmpPfxPath, tmpPfxPath: tmpPfxPath,
tmpDerPath: tmpDerPath, tmpDerPath: tmpDerPath,
}); });
} catch (err) {
throw err;
} finally { } finally {
//删除临时文件 //删除临时文件
logger.info("删除临时文件"); logger.info("删除临时文件");

View File

@ -8,7 +8,7 @@ RUN npm install -g pnpm@8.15.7
#RUN cd /workspace/certd-client && pnpm install && npm run build #RUN cd /workspace/certd-client && pnpm install && npm run build
RUN cp /workspace/certd-client/dist/* /workspace/certd-server/public/ -rf RUN cp /workspace/certd-client/dist/* /workspace/certd-server/public/ -rf
RUN cd /workspace/certd-server && yarn install && npm run build-on-docker RUN cd /workspace/certd-server && pnpm install && npm run build-on-docker
FROM node:18-alpine FROM node:18-alpine

View File

@ -3,6 +3,12 @@
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.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
### Performance Improvements
* 插件选择支持搜索 ([d1498a7](https://github.com/certd/certd/commit/d1498a71601b74d38343b1d070eadd03705dd9d5))
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06) ## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
**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.24.3", "version": "1.24.4",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite --open", "dev": "vite --open",
@ -58,7 +58,7 @@
"vuedraggable": "^4.1.0" "vuedraggable": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@certd/pipeline": "^1.24.3", "@certd/pipeline": "^1.24.4",
"@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

@ -143,6 +143,7 @@ function openUpgrade() {
<div class="flex-o w-100"> <div class="flex-o w-100">
<span>站点ID</span> <span>站点ID</span>
<fs-copyable class="flex-1" v-model={computedSiteId.value}></fs-copyable> <fs-copyable class="flex-1" v-model={computedSiteId.value}></fs-copyable>
<div>注意保存好数据库暂不支持换绑默认数据库路径/data/certd/db.sqlite</div>
</div> </div>
<a-input class="mt-10" v-model:value={formState.code} placeholder={placeholder} /> <a-input class="mt-10" v-model:value={formState.code} placeholder={placeholder} />
</div> </div>

View File

@ -68,6 +68,17 @@ h1, h2, h3, h4, h5, h6 {
flex: 1; flex: 1;
} }
.flex-col{
display: flex;
flex-direction: column;
}
.scroll-y{
overflow-y: auto;
}
.mb-2 { .mb-2 {
margin-bottom: 2px; margin-bottom: 2px;
} }
@ -137,6 +148,13 @@ h1, h2, h3, h4, h5, h6 {
.w-100 { .w-100 {
width: 100%; width: 100%;
} }
.h-100 {
height: 100%;
}
.overflow-hidden {
overflow: hidden;
}
.block-header { .block-header {
margin: 3px; margin: 3px;
@ -166,3 +184,17 @@ h1, h2, h3, h4, h5, h6 {
.need-plus { .need-plus {
color: #c5913f !important; color: #c5913f !important;
} }
.deleted{
color: #c7c7c7;
//删除线
text-decoration: line-through;
}
.cursor-move{
cursor: move !important;
}
.cursor-pointer{
cursor: pointer;
}

View File

@ -8,9 +8,22 @@
</template> </template>
<template v-if="currentStep"> <template v-if="currentStep">
<pi-container v-if="currentStep._isAdd" class="pi-step-form"> <pi-container v-if="currentStep._isAdd" class="pi-step-form">
<a-tabs tab-position="left"> <template #header>
<a-tab-pane v-for="group of pluginGroups.groups" :key="group.key" :tab="group.title"> <a-row :gutter="10" class="mb-10">
<a-row :gutter="10"> <a-col :span="24" style="padding-left: 20px">
<a-input-search v-model:value="pluginSearch.keyword" placeholder="搜索插件" :allow-clear="true" :show-search="true"></a-input-search>
</a-col>
</a-row>
</template>
<div class="flex-col h-100 w-100 overflow-hidden">
<a-tabs v-model:active-key="pluginGroupActive" tab-position="left" class="flex-1 overflow-hidden">
<a-tab-pane v-for="group of computedPluginGroups" :key="group.key" :tab="group.title" class="scroll-y">
<a-row v-if="!group.plugins || group.plugins.length === 0" :gutter="10">
<a-col class="flex-o">
<div class="flex-o m-10">没有找到插件</div>
</a-col>
</a-row>
<a-row v-else :gutter="10">
<a-col v-for="item of group.plugins" :key="item.key" class="step-plugin" :span="12"> <a-col v-for="item of group.plugins" :key="item.key" class="step-plugin" :span="12">
<a-card <a-card
hoverable hoverable
@ -36,15 +49,20 @@
</a-row> </a-row>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</div>
<template #footer>
<div style="padding: 20px; margin-left: 100px"> <div style="padding: 20px; margin-left: 100px">
<a-button v-if="editMode" type="primary" @click="stepTypeSave"> </a-button> <a-button v-if="editMode" type="primary" @click="stepTypeSave"> </a-button>
</div> </div>
</template>
</pi-container> </pi-container>
<pi-container v-else class="pi-step-form"> <pi-container v-else class="pi-step-form">
<a-form ref="stepFormRef" class="step-form" :model="currentStep" :label-col="labelCol" :wrapper-col="wrapperCol"> <template #header>
<div class="mb-10"> <div class="mb-10">
<a-alert type="info" :message="currentPlugin.title" :description="currentPlugin.desc"> </a-alert> <a-alert type="info" :message="currentPlugin.title" :description="currentPlugin.desc"> </a-alert>
</div> </div>
</template>
<a-form ref="stepFormRef" class="step-form" :model="currentStep" :label-col="labelCol" :wrapper-col="wrapperCol">
<fs-form-item <fs-form-item
v-model="currentStep.title" v-model="currentStep.title"
:item="{ :item="{
@ -66,9 +84,9 @@
</a-form> </a-form>
<template #footer> <template #footer>
<a-form-item v-if="editMode" :wrapper-col="{ span: 14, offset: 4 }"> <div v-if="editMode" class="bottom-button">
<a-button type="primary" @click="stepSave"> </a-button> <a-button type="primary" @click="stepSave"> </a-button>
</a-form-item> </div>
</template> </template>
</pi-container> </pi-container>
</template> </template>
@ -77,7 +95,7 @@
<script lang="tsx"> <script lang="tsx">
import { message, Modal } from "ant-design-vue"; import { message, Modal } from "ant-design-vue";
import { computed, inject, Ref, ref } from "vue"; import { computed, inject, Ref, ref, watch } from "vue";
import _ from "lodash-es"; import _ from "lodash-es";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { CopyOutlined } from "@ant-design/icons-vue"; import { CopyOutlined } from "@ant-design/icons-vue";
@ -263,7 +281,45 @@ export default {
const blankFn = () => { const blankFn = () => {
return {}; return {};
}; };
const pluginSearch = ref({
keyword: "",
result: []
});
const pluginGroupActive = ref("all");
const computedPluginGroups: any = computed(() => {
const groups = pluginGroups.groups;
if (pluginSearch.value.keyword) {
const keyword = pluginSearch.value.keyword.toLowerCase();
const list = groups.all.plugins.filter((plugin) => {
return (
plugin.title?.toLowerCase().includes(keyword) || plugin.desc?.toLowerCase().includes(keyword) || plugin.name?.toLowerCase().includes(keyword)
);
});
return { return {
search: { key: "search", title: "搜索结果", plugins: list }
};
} else {
return groups;
}
});
watch(
() => {
return pluginSearch.value.keyword;
},
(val: any) => {
if (val) {
pluginGroupActive.value = "search";
} else {
pluginGroupActive.value = "all";
}
}
);
return {
pluginGroupActive,
computedPluginGroups,
pluginSearch,
stepTypeSelected, stepTypeSelected,
stepTypeSave, stepTypeSave,
pluginGroups, pluginGroups,
@ -321,8 +377,23 @@ export default {
<style lang="less"> <style lang="less">
.pi-step-form { .pi-step-form {
.bottom-button {
padding: 20px;
padding-bottom: 5px;
margin-left: 100px;
}
.body { .body {
padding: 10px; padding: 0px;
.ant-tabs-content {
height: 100%;
}
.ant-tabs-tabpane {
padding-right: 10px;
overflow-y: auto;
overflow-x: hidden;
}
.ant-card { .ant-card {
margin-bottom: 10px; margin-bottom: 10px;

View File

@ -48,13 +48,14 @@
<div class="step-row"> <div class="step-row">
<div class="text"> <div class="text">
<fs-icon icon="ion:flash"></fs-icon> <fs-icon icon="ion:flash"></fs-icon>
<h4 class="title">{{ element.title }}</h4> <h4 class="title" :class="{ disabled: element.disabled, deleted: element.disabled }">{{ element.title }}</h4>
</div> </div>
<div class="action"> <div class="action">
<a key="edit" @click="stepEdit(currentTask, element, index)">编辑</a> <a key="edit" @click="stepEdit(currentTask, element, index)">编辑</a>
<a key="edit" @click="stepCopy(currentTask, element, index)">复制</a> <a key="edit" @click="stepCopy(currentTask, element, index)">复制</a>
<a key="remove" @click="stepDelete(currentTask, index)">删除</a> <a key="remove" @click="stepDelete(currentTask, index)">删除</a>
<fs-icon v-plus class="icon-button handle" title="拖动排序" icon="ion:move-outline"></fs-icon> <a key="disabled" @click="element.disabled = !!!element.disabled">{{ element.disabled ? "启用" : "禁用" }}</a>
<fs-icon v-plus class="icon-button handle cursor-move" title="拖动排序" icon="ion:move-outline"></fs-icon>
</div> </div>
</div> </div>
</template> </template>

View File

@ -94,7 +94,9 @@
<!-- :open="true"--> <!-- :open="true"-->
<template #content> <template #content>
<div v-for="(item, index) of task.steps" class="flex-o w-100"> <div v-for="(item, index) of task.steps" class="flex-o w-100">
<span class="ellipsis flex-1">{{ index + 1 }}. {{ item.title }} </span> <span class="ellipsis flex-1 step-title" :class="{ disabled: item.disabled, deleted: item.disabled }">
{{ index + 1 }}. {{ item.title }}
</span>
<pi-status-show v-if="!editMode" :status="item.status?.result"></pi-status-show> <pi-status-show v-if="!editMode" :status="item.status?.result"></pi-status-show>
<fs-icon <fs-icon
v-if="!editMode" v-if="!editMode"
@ -346,14 +348,23 @@ export default defineComponent({
} }
const intervalLoadHistoryRef = ref(); const intervalLoadHistoryRef = ref();
function watchNewHistoryList() { function watchNewHistoryList() {
intervalLoadHistoryRef.value = setInterval(async () => { intervalLoadHistoryRef.value = setTimeout(async () => {
try {
if (currentHistory.value == null) { if (currentHistory.value == null) {
await loadHistoryList(); await loadHistoryList();
} else if (currentHistory.value.pipeline?.status?.status === "start") { }
if (currentHistory.value != null) {
if (currentHistory.value.pipeline?.status?.status === "start") {
await loadCurrentHistoryDetail(); await loadCurrentHistoryDetail();
} else { } else {
clearInterval(intervalLoadHistoryRef.value); return;
} }
}
} catch (e) {
console.error(e);
}
watchNewHistoryList();
}, 3000); }, 3000);
} }
@ -603,6 +614,9 @@ export default defineComponent({
saveLoading.value = true; saveLoading.value = true;
try { try {
if (props.options.doSave) { if (props.options.doSave) {
if (pipeline.value.version == null) {
pipeline.value.version = 0;
}
pipeline.value.version++; pipeline.value.version++;
currentPipeline.value = pipeline.value; currentPipeline.value = pipeline.value;
await props.options.doSave(pipeline.value); await props.options.doSave(pipeline.value);

View File

@ -48,6 +48,12 @@ const StatusEnum: StatusEnumType = {
label: "未运行", label: "未运行",
color: "blue", color: "blue",
icon: "ant-design:minus-circle-twotone" icon: "ant-design:minus-circle-twotone"
},
disabled: {
value: "disabled",
label: "禁用",
color: "gray",
icon: "ant-design:stop-outlined"
} }
}; };
export const statusUtil = { export const statusUtil = {

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.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
### Bug Fixes
* 修复腾讯云cdn证书部署后会自动关闭hstshttp2.0等配置的bug ([7908ab7](https://github.com/certd/certd/commit/7908ab79da624c94fa05849925b15e480e3317c4))
* 修复腾讯云tke证书部署报错的bug ([653f409](https://github.com/certd/certd/commit/653f409d91a441850d6381f89a8dd390831f0d5e))
### Performance Improvements
* 支持群晖 ([5c270b6](https://github.com/certd/certd/commit/5c270b6b9d45a2152f9fdb3c07bd98b7c803cb8e))
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06) ## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
### Performance Improvements ### Performance Improvements

View File

@ -1,6 +1,6 @@
{ {
"name": "@certd/ui-server", "name": "@certd/ui-server",
"version": "1.24.3", "version": "1.24.4",
"description": "fast-server base midway", "description": "fast-server base midway",
"private": true, "private": true,
"type": "module", "type": "module",
@ -16,18 +16,20 @@
"build": "mwtsc --cleanOutDir --skipLibCheck", "build": "mwtsc --cleanOutDir --skipLibCheck",
"build-on-docker": "node ./before-build.js && npm run build", "build-on-docker": "node ./before-build.js && npm run build",
"up-mw-deps": "npx midway-version -u -w", "up-mw-deps": "npx midway-version -u -w",
"clinic": "clinic heapprofiler -- node ./bootstrap.js" "heap": "clinic heapprofiler -- node ./bootstrap.js",
"flame": "clinic flame -- node ./bootstrap.js"
}, },
"dependencies": { "dependencies": {
"@alicloud/cs20151215": "^3.0.3", "@alicloud/cs20151215": "^3.0.3",
"@alicloud/pop-core": "^1.7.10", "@alicloud/pop-core": "^1.7.10",
"@certd/acme-client": "^1.24.3", "@certd/acme-client": "^1.24.4",
"@certd/lib-huawei": "^1.24.3", "@certd/lib-huawei": "^1.24.3",
"@certd/lib-k8s": "^1.24.3", "@certd/lib-k8s": "^1.24.4",
"@certd/midway-flyway-js": "^1.22.6", "@certd/midway-flyway-js": "^1.24.4",
"@certd/pipeline": "^1.24.3", "@certd/pipeline": "^1.24.4",
"@certd/plugin-cert": "^1.24.3", "@certd/plugin-cert": "^1.24.4",
"@certd/plugin-plus": "^1.24.3", "@certd/plugin-plus": "^1.24.4",
"@koa/cors": "^5.0.0", "@koa/cors": "^5.0.0",
"@midwayjs/bootstrap": "^3.16.2", "@midwayjs/bootstrap": "^3.16.2",
"@midwayjs/cache": "^3.14.0", "@midwayjs/cache": "^3.14.0",
@ -47,6 +49,7 @@
"cache-manager": "^3.6.3", "cache-manager": "^3.6.3",
"cron-parser": "^4.9.0", "cron-parser": "^4.9.0",
"dayjs": "^1.11.7", "dayjs": "^1.11.7",
"form-data": "^4.0.0",
"glob": "^10.4.5", "glob": "^10.4.5",
"https-proxy-agent": "^7.0.5", "https-proxy-agent": "^7.0.5",
"iconv-lite": "^0.6.3", "iconv-lite": "^0.6.3",
@ -67,6 +70,7 @@
"ssh2": "^1.15.0", "ssh2": "^1.15.0",
"strip-ansi": "^7.1.0", "strip-ansi": "^7.1.0",
"svg-captcha": "^1.4.0", "svg-captcha": "^1.4.0",
"syno": "^2.2.0",
"tencentcloud-sdk-nodejs": "^4.0.44", "tencentcloud-sdk-nodejs": "^4.0.44",
"typeorm": "^0.3.20" "typeorm": "^0.3.20"
}, },

View File

@ -1,19 +1,19 @@
import crypto from 'crypto'; import crypto from 'crypto';
import querystring from 'querystring'; import querystring from 'querystring';
import { DogeCloudAccess } from '../access.js'; import { DogeCloudAccess } from '../access.js';
import { AxiosInstance } from 'axios'; import { HttpClient } from '@certd/pipeline';
export class DogeClient { export class DogeClient {
accessKey: string; accessKey: string;
secretKey: string; secretKey: string;
http: AxiosInstance; http: HttpClient;
constructor(access: DogeCloudAccess, http: AxiosInstance) { constructor(access: DogeCloudAccess, http: HttpClient) {
this.accessKey = access.accessKey; this.accessKey = access.accessKey;
this.secretKey = access.secretKey; this.secretKey = access.secretKey;
this.http = http; this.http = http;
} }
async request(apiPath: string, data: any = {}, jsonMode = false) { async request(apiPath: string, data: any = {}, jsonMode = false, ignoreResNullCode = false) {
// 这里替换为你的多吉云永久 AccessKey 和 SecretKey可在用户中心 - 密钥管理中查看 // 这里替换为你的多吉云永久 AccessKey 和 SecretKey可在用户中心 - 密钥管理中查看
// 请勿在客户端暴露 AccessKey 和 SecretKey那样恶意用户将获得账号完全控制权 // 请勿在客户端暴露 AccessKey 和 SecretKey那样恶意用户将获得账号完全控制权
@ -34,7 +34,9 @@ export class DogeClient {
}, },
}); });
if (res.code !== 200) { if (res.code == null && ignoreResNullCode) {
//ignore
} else if (res.code !== 200) {
throw new Error('API Error: ' + res.msg); throw new Error('API Error: ' + res.msg);
} }
return res.data; return res.data;

View File

@ -44,6 +44,17 @@ export class DogeCloudDeployToCDNPlugin extends AbstractTaskPlugin {
}) })
accessId!: string; accessId!: string;
@TaskInput({
title: '忽略部署接口报错',
helper: '当该域名部署后报错,但是实际上已经部署成功时,可以勾选',
value: false,
component: {
name: 'a-switch',
type: 'checked',
},
})
ignoreDeployNullCode = false;
dogeClient!: DogeClient; dogeClient!: DogeClient;
async onInstance() { async onInstance() {
@ -66,10 +77,14 @@ export class DogeCloudDeployToCDNPlugin extends AbstractTaskPlugin {
} }
async bindCert(certId: number) { async bindCert(certId: number) {
await this.dogeClient.request('/cdn/cert/bind.json', { await this.dogeClient.request(
'/cdn/cert/bind.json',
{
id: certId, id: certId,
domain: this.domain, domain: this.domain,
}); },
this.ignoreDeployNullCode
);
} }
} }
new DogeCloudDeployToCDNPlugin(); new DogeCloudDeployToCDNPlugin();

View File

@ -1,2 +1,3 @@
export * from './plugin-k8s.js'; export * from './plugin-k8s.js';
export * from './plugin-restart.js'; export * from './plugin-restart.js';
export * from './plugin-script.js';

View File

@ -6,6 +6,7 @@ import { appendTimeSuffix } from '../../plugin-aliyun/utils/index.js';
@IsTaskPlugin({ @IsTaskPlugin({
name: 'DeployToK8SIngress', name: 'DeployToK8SIngress',
title: 'K8S Ingress证书部署', title: 'K8S Ingress证书部署',
desc: '暂不可用',
group: pluginGroups.other.key, group: pluginGroups.other.key,
default: { default: {
strategy: { strategy: {

View File

@ -0,0 +1,58 @@
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskInstanceContext } from '@certd/pipeline';
import { CertInfo, CertReader } from '@certd/plugin-cert';
export type CustomScriptContext = {
CertReader: typeof CertReader;
self: CustomScriptPlugin;
} & TaskInstanceContext;
@IsTaskPlugin({
name: 'CustomScript',
title: '自定义js脚本',
desc: '测试',
group: pluginGroups.other.key,
default: {
strategy: {
runStrategy: RunStrategy.SkipWhenSucceed,
},
},
})
export class CustomScriptPlugin extends AbstractTaskPlugin {
@TaskInput({
title: '脚本',
helper: '自定义js脚本',
component: {
name: 'a-textarea',
vModel: 'value',
rows: 10,
style: 'background-color: #000c17;color: #fafafa;',
},
required: true,
})
script!: string;
@TaskInput({
title: '域名证书',
helper: '请选择前置任务输出的域名证书',
component: {
name: 'pi-output-selector',
from: 'CertApply',
},
required: true,
})
cert!: CertInfo;
async onInstance() {}
async execute(): Promise<void> {
this.logger.info('执行自定义脚本:\n', this.script);
const ctx: CustomScriptContext = {
CertReader,
self: this,
...this.ctx,
};
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
const func = new AsyncFunction('ctx', this.script);
return await func(ctx);
}
}
new CustomScriptPlugin();

View File

@ -93,20 +93,20 @@ export class DeployToCdnPlugin extends AbstractTaskPlugin {
buildParams() { buildParams() {
return { return {
Https: { Domain: this.domainName,
Switch: 'on', Route: 'Https.CertInfo',
CertInfo: { Value: JSON.stringify({
update: {
Certificate: this.cert.crt, Certificate: this.cert.crt,
PrivateKey: this.cert.key, PrivateKey: this.cert.key,
}, },
}, }),
Domain: this.domainName,
}; };
} }
async doRequest(params: any) { async doRequest(params: any) {
const client = await this.getClient(); const client = await this.getClient();
const ret = await client.UpdateDomainConfig(params); const ret = await client.ModifyDomainConfig(params);
this.checkRet(ret); this.checkRet(ret);
this.logger.info('设置腾讯云CDN证书成功:', ret.RequestId); this.logger.info('设置腾讯云CDN证书成功:', ret.RequestId);
return ret.RequestId; return ret.RequestId;

View File

@ -6,7 +6,7 @@ import dayjs from 'dayjs';
name: 'DeployCertToTencentCLB', name: 'DeployCertToTencentCLB',
title: '部署到腾讯云CLB', title: '部署到腾讯云CLB',
group: pluginGroups.tencent.key, group: pluginGroups.tencent.key,
desc: '暂时只支持单向认证证书,暂时只支持通用负载均衡', desc: '暂时只支持单向认证证书,暂时只支持通用负载均衡必须开启sni',
default: { default: {
strategy: { strategy: {
runStrategy: RunStrategy.SkipWhenSucceed, runStrategy: RunStrategy.SkipWhenSucceed,
@ -93,14 +93,13 @@ export class DeployToClbPlugin extends AbstractTaskPlugin {
accessId!: string; accessId!: string;
client: any; client: any;
ClbClient: any;
async onInstance() { async onInstance() {
this.client = await this.getClient(); this.client = await this.getClient();
} }
async getClient() { async getClient() {
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/clb/v20180317/index.js'); const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/clb/v20180317/index.js');
this.ClbClient = sdk.v20180317.Client; const ClbClient = sdk.v20180317.Client;
const accessProvider = (await this.accessService.getById(this.accessId)) as TencentAccess; const accessProvider = (await this.accessService.getById(this.accessId)) as TencentAccess;
@ -118,7 +117,7 @@ export class DeployToClbPlugin extends AbstractTaskPlugin {
}, },
}; };
return new this.ClbClient(clientConfig); return new ClbClient(clientConfig);
} }
async execute(): Promise<void> { async execute(): Promise<void> {

View File

@ -38,6 +38,7 @@ export class DeployToEOPlugin extends AbstractTaskPlugin {
@TaskInput({ @TaskInput({
title: '站点ID', title: '站点ID',
helper: '类似于zone-xxxx的字符串在站点概览页面左上角或者站点列表页面站点名称下方', helper: '类似于zone-xxxx的字符串在站点概览页面左上角或者站点列表页面站点名称下方',
required: true,
}) })
zoneId!: string; zoneId!: string;

View File

@ -89,19 +89,16 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
}) })
cert!: any; cert!: any;
TkeClient: any;
K8sClient: any; K8sClient: any;
async onInstance() { async onInstance() {
// const TkeClient = this.tencentcloud.tke.v20180525.Client; // const TkeClient = this.tencentcloud.tke.v20180525.Client;
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/tke/v20220501/index.js');
this.TkeClient = sdk.v20220501.Client;
const k8sSdk = await import('@certd/lib-k8s'); const k8sSdk = await import('@certd/lib-k8s');
this.K8sClient = k8sSdk.K8sClient; this.K8sClient = k8sSdk.K8sClient;
} }
async execute(): Promise<void> { async execute(): Promise<void> {
const accessProvider = await this.accessService.getById(this.accessId); const accessProvider = await this.accessService.getById(this.accessId);
const tkeClient = this.getTkeClient(accessProvider, this.region); const tkeClient = await this.getTkeClient(accessProvider, this.region);
const kubeConfigStr = await this.getTkeKubeConfig(tkeClient, this.clusterId); const kubeConfigStr = await this.getTkeKubeConfig(tkeClient, this.clusterId);
this.logger.info('kubeconfig已成功获取'); this.logger.info('kubeconfig已成功获取');
@ -127,7 +124,9 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
await this.restartIngress({ k8sClient }); await this.restartIngress({ k8sClient });
} }
getTkeClient(accessProvider: any, region = 'ap-guangzhou') { async getTkeClient(accessProvider: any, region = 'ap-guangzhou') {
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/tke/v20180525/index.js');
const TkeClient = sdk.v20180525.Client;
const clientConfig = { const clientConfig = {
credential: { credential: {
secretId: accessProvider.secretId, secretId: accessProvider.secretId,
@ -141,7 +140,7 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
}, },
}; };
return new this.TkeClient(clientConfig); return new TkeClient(clientConfig);
} }
async getTkeKubeConfig(client: any, clusterId: string) { async getTkeKubeConfig(client: any, clusterId: string) {

View File

@ -2,7 +2,7 @@ import { utils } from '@certd/pipeline';
export async function request(config: any): Promise<any> { export async function request(config: any): Promise<any> {
try { try {
return await utils.http(config); return await utils.http.request(config);
} catch (e) { } catch (e) {
const data = e.data || e.response?.data; const data = e.data || e.response?.data;
if (data) { if (data) {

View File

@ -9,4 +9,4 @@ log4js.configure({
}, },
categories: { default: { appenders: ['std'], level } }, categories: { default: { appenders: ['std'], level } },
}); });
export const logger = log4js.getLogger('fast'); export const logger = log4js.getLogger('server');