chore: format

This commit is contained in:
xiaojunnuo
2026-05-31 01:41:33 +08:00
parent acd440106b
commit 4b57a0d729
557 changed files with 12530 additions and 14039 deletions
@@ -335,7 +335,7 @@ export class AcmeService {
try {
const recordRes = await dnsProvider.createRecord(recordReq);
this.logger.info("添加 TXT 解析记录成功", JSON.stringify(recordRes));
return {
return {
recordReq,
recordRes,
dnsProvider,
@@ -345,9 +345,8 @@ export class AcmeService {
} catch (e: any) {
//@ts-ignore
e.message = `[${dnsProvider?.constructor?.name}错误] ${e.message}`;
throw e
throw e;
}
};
const doDnsPersistVerify = async (challenge: any, plan: DnsPersistVerifyPlan) => {
@@ -1,10 +1,9 @@
import { AbstractTaskPlugin, FileItem, IContext, Step, TaskInput, TaskOutput } from "@certd/pipeline";
import dayjs from "dayjs";
import type { CertInfo } from "./acme.js";
import { CertReader,CertConverter, EVENT_CERT_APPLY_SUCCESS } from "@certd/plugin-lib";
import { CertReader, CertConverter, EVENT_CERT_APPLY_SUCCESS } from "@certd/plugin-lib";
import JSZip from "jszip";
export abstract class CertApplyBaseConvertPlugin extends AbstractTaskPlugin {
@TaskInput({
title: "证书域名",
@@ -16,7 +15,7 @@ export abstract class CertApplyBaseConvertPlugin extends AbstractTaskPlugin {
placeholder: "请输入证书域名/IP,比如:foo.com , *.foo.com , *.sub.foo.com , *.bar.com , 123.123.123.123",
tokenSeparators: [",", " ", "", "、", "|"],
search: true,
pager:true,
pager: true,
},
rules: [{ type: "domains" }],
required: true,
@@ -20,7 +20,7 @@ export abstract class CertApplyBasePlugin extends CertApplyBaseConvertPlugin {
@TaskInput({
title: "更新天数",
value:20,
value: 20,
component: {
name: "a-input-number",
vModel: "value",
@@ -140,25 +140,25 @@ export abstract class CertApplyBasePlugin extends CertApplyBaseConvertPlugin {
*/
isWillExpire(cert: CertReader, maxDays = 15) {
const expires = cert.expires;
if (expires == null) {
if (expires == null) {
throw new Error("过期时间不能为空");
}
const begin = dayjs(cert.detail?.notBefore )
const begin = dayjs(cert.detail?.notBefore);
//证书总天数
const totalDays = Math.floor((expires - begin.valueOf()) / (1000 * 60 * 60 * 24));
// 检查有效期
// 检查有效期
const leftDays = Math.floor((expires - dayjs().valueOf()) / (1000 * 60 * 60 * 24));
this.logger.info(`证书有效期剩余天数:${leftDays}`);
if(totalDays < maxDays){
this.logger.info(`证书有效期剩余天数:${leftDays}`);
if (totalDays < maxDays) {
this.logger.warn(`当前更新天数为${maxDays},证书总天数${totalDays},总天数小于更新天数(更新天数是指到期前多少天更新证书,您可以在任务配置中调整该值)`);
maxDays = Math.floor(totalDays/2);
if(maxDays < 2){
maxDays = Math.floor(totalDays / 2);
if (maxDays < 2) {
maxDays = 2;
}
this.logger.warn(`为避免每次运行都更新证书,更新天数自动减半(即证书最大时长${totalDays}天减半),调整为${maxDays}`);
}
return {
isWillExpire: leftDays <= maxDays,
leftDays,
@@ -28,27 +28,25 @@ export class CertApplyGetFormAliyunPlugin extends CertApplyBasePlugin {
})
accessId!: string;
@TaskInput(
{
title: "证书API 版本",
value: "v1",
component: {
name: "a-select",
vModel: "value",
options: [
{
label: "API 1.0 (旧版)",
value: "v1",
},
{
label: "API 2.0 (新版)",
value: "v2",
},
],
},
helper: "选择阿里云证书 API 版本",
}
)
@TaskInput({
title: "证书API 版本",
value: "v1",
component: {
name: "a-select",
vModel: "value",
options: [
{
label: "API 1.0 (旧版)",
value: "v1",
},
{
label: "API 2.0 (新版)",
value: "v2",
},
],
},
helper: "选择阿里云证书 API 版本",
})
apiVersion!: string;
@TaskInput(
@@ -67,7 +65,7 @@ export class CertApplyGetFormAliyunPlugin extends CertApplyBasePlugin {
)
orderId!: string;
async onInit(): Promise<void> { }
async onInit(): Promise<void> {}
async doCertApply(): Promise<CertReader> {
const access = await this.getAccess<AliyunAccess>(this.accessId);
@@ -102,7 +100,7 @@ export class CertApplyGetFormAliyunPlugin extends CertApplyBasePlugin {
throw new Error("请先输入证书实例 ID");
}
if (Array.isArray(this.orderId) && this.orderId.length > 0) {
this.orderId = this.orderId[0]
this.orderId = this.orderId[0];
}
const certificateId = await this.getOrderDetailV2(client, this.orderId);
this.logger.info(`获取到证书 ID:${certificateId}`);
@@ -1,3 +1,2 @@
export * from "./base.js";
export * from "./apply.js";
@@ -7,7 +7,6 @@ import path from "path";
import JSZip from "jszip";
import { PrivateKeyType } from "./dns.js";
@IsTaskPlugin({
name: "CertApplyLego",
icon: "ph:certificate",