mirror of
https://github.com/certd/certd.git
synced 2026-07-09 06:07:37 +08:00
chore: format
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
export * from './plugin-restart.js';
|
||||
export * from './plugin-script.js';
|
||||
export * from './plugin-db-backup.js';
|
||||
export * from './plugin-deploy-to-certd.js';
|
||||
export * from "./plugin-restart.js";
|
||||
export * from "./plugin-script.js";
|
||||
export * from "./plugin-db-backup.js";
|
||||
export * from "./plugin-deploy-to-certd.js";
|
||||
|
||||
@@ -5,7 +5,7 @@ import dayjs from "dayjs";
|
||||
import { AbstractPlusTaskPlugin } from "@certd/plugin-plus";
|
||||
import JSZip from "jszip";
|
||||
import * as os from "node:os";
|
||||
import { OssClientContext, ossClientFactory, OssClientRemoveByOpts} from "../plugin-lib/oss/index.js";
|
||||
import { OssClientContext, ossClientFactory, OssClientRemoveByOpts } from "../plugin-lib/oss/index.js";
|
||||
import { SshAccess, SshClient } from "../plugin-lib/ssh/index.js";
|
||||
import { pipeline } from "stream/promises";
|
||||
const defaultBackupDir = "certd_backup";
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { httpsServer } from '../../modules/auto/https/server.js';
|
||||
import { RestartCertdPlugin } from './plugin-restart.js';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { CertApplyPluginNames, CertInfo, CertReader } from '@certd/plugin-lib';
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
|
||||
import { httpsServer } from "../../modules/auto/https/server.js";
|
||||
import { RestartCertdPlugin } from "./plugin-restart.js";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import { CertApplyPluginNames, CertInfo, CertReader } from "@certd/plugin-lib";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'DeployToCertd',
|
||||
title: '部署证书到Certd本身',
|
||||
icon: 'mdi:restart',
|
||||
desc: '【仅管理员可用】 部署证书到 certd的https服务,用于更新 Certd 的 ssl 证书,建议将此任务放在流水线的最后一步',
|
||||
name: "DeployToCertd",
|
||||
title: "部署证书到Certd本身",
|
||||
icon: "mdi:restart",
|
||||
desc: "【仅管理员可用】 部署证书到 certd的https服务,用于更新 Certd 的 ssl 证书,建议将此任务放在流水线的最后一步",
|
||||
group: pluginGroups.admin.key,
|
||||
onlyAdmin: true,
|
||||
default: {
|
||||
@@ -19,18 +19,17 @@ import { CertApplyPluginNames, CertInfo, CertReader } from '@certd/plugin-lib';
|
||||
},
|
||||
})
|
||||
export class DeployToCertdPlugin extends AbstractTaskPlugin {
|
||||
|
||||
@TaskInput({
|
||||
title: '域名证书',
|
||||
helper: '请选择前置任务输出的域名证书',
|
||||
title: "域名证书",
|
||||
helper: "请选择前置任务输出的域名证书",
|
||||
component: {
|
||||
name: 'output-selector',
|
||||
name: "output-selector",
|
||||
from: [...CertApplyPluginNames],
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
cert!: CertInfo;
|
||||
async onInstance() { }
|
||||
async onInstance() {}
|
||||
async execute(): Promise<void> {
|
||||
this.checkAdmin();
|
||||
|
||||
@@ -40,15 +39,15 @@ export class DeployToCertdPlugin extends AbstractTaskPlugin {
|
||||
|
||||
const certReader = new CertReader(this.cert);
|
||||
const dataDir = "./data";
|
||||
const handle = async ({ tmpCrtPath, tmpKeyPath, }) => {
|
||||
this.logger.info('复制到目标路径');
|
||||
const handle = async ({ tmpCrtPath, tmpKeyPath }) => {
|
||||
this.logger.info("复制到目标路径");
|
||||
if (crtPath) {
|
||||
crtPath = crtPath.startsWith('/') ? crtPath : path.join(dataDir, crtPath);
|
||||
crtPath = crtPath.startsWith("/") ? crtPath : path.join(dataDir, crtPath);
|
||||
this.copyFile(tmpCrtPath, crtPath);
|
||||
}
|
||||
if (keyPath) {
|
||||
keyPath = keyPath.trim();
|
||||
keyPath = keyPath.startsWith('/') ? keyPath : path.join(dataDir, keyPath);
|
||||
keyPath = keyPath.startsWith("/") ? keyPath : path.join(dataDir, keyPath);
|
||||
this.copyFile(tmpKeyPath, keyPath);
|
||||
}
|
||||
};
|
||||
@@ -56,8 +55,7 @@ export class DeployToCertdPlugin extends AbstractTaskPlugin {
|
||||
await certReader.readCertFile({ logger: this.logger, handle });
|
||||
this.logger.info(`证书已部署到 ${crtPath} 和 ${keyPath}`);
|
||||
|
||||
|
||||
this.logger.info('Certd https server 将在 30 秒后重启');
|
||||
this.logger.info("Certd https server 将在 30 秒后重启");
|
||||
await this.ctx.utils.sleep(30000);
|
||||
await httpsServer.restart();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy } from '@certd/pipeline';
|
||||
import { httpsServer } from '../../modules/auto/https/server.js';
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy } from "@certd/pipeline";
|
||||
import { httpsServer } from "../../modules/auto/https/server.js";
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'RestartCertd',
|
||||
title: '重启 Certd',
|
||||
icon: 'mdi:restart',
|
||||
desc: '【仅管理员可用】 重启 certd的https服务,用于更新 Certd 的 ssl 证书',
|
||||
name: "RestartCertd",
|
||||
title: "重启 Certd",
|
||||
icon: "mdi:restart",
|
||||
desc: "【仅管理员可用】 重启 certd的https服务,用于更新 Certd 的 ssl 证书",
|
||||
group: pluginGroups.admin.key,
|
||||
onlyAdmin:true,
|
||||
onlyAdmin: true,
|
||||
default: {
|
||||
strategy: {
|
||||
runStrategy: RunStrategy.SkipWhenSucceed,
|
||||
@@ -18,7 +18,7 @@ export class RestartCertdPlugin extends AbstractTaskPlugin {
|
||||
async onInstance() {}
|
||||
async execute(): Promise<void> {
|
||||
this.checkAdmin();
|
||||
this.logger.info('Certd https server 将在 3 秒后重启');
|
||||
this.logger.info("Certd https server 将在 3 秒后重启");
|
||||
await this.ctx.utils.sleep(3000);
|
||||
await httpsServer.restart();
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskInstanceContext } from '@certd/pipeline';
|
||||
import { CertInfo, CertReader } from '@certd/plugin-cert';
|
||||
import { CertApplyPluginNames} from '@certd/plugin-cert';
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskInstanceContext } from "@certd/pipeline";
|
||||
import { CertInfo, CertReader } from "@certd/plugin-cert";
|
||||
import { CertApplyPluginNames } from "@certd/plugin-cert";
|
||||
export type CustomScriptContext = {
|
||||
CertReader: typeof CertReader;
|
||||
self: CustomScriptPlugin;
|
||||
} & TaskInstanceContext;
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'CustomScript',
|
||||
title: '自定义js脚本',
|
||||
icon: 'ri:javascript-line',
|
||||
desc: '【仅管理员】运行自定义js脚本执行',
|
||||
name: "CustomScript",
|
||||
title: "自定义js脚本",
|
||||
icon: "ri:javascript-line",
|
||||
desc: "【仅管理员】运行自定义js脚本执行",
|
||||
group: pluginGroups.admin.key,
|
||||
showRunStrategy: true,
|
||||
onlyAdmin: true,
|
||||
@@ -22,23 +22,23 @@ export type CustomScriptContext = {
|
||||
})
|
||||
export class CustomScriptPlugin extends AbstractTaskPlugin {
|
||||
@TaskInput({
|
||||
title: '脚本',
|
||||
helper: '自定义js脚本,[脚本编写帮助文档](https://certd.docmirror.cn/guide/use/custom-script/)',
|
||||
title: "脚本",
|
||||
helper: "自定义js脚本,[脚本编写帮助文档](https://certd.docmirror.cn/guide/use/custom-script/)",
|
||||
component: {
|
||||
name: 'a-textarea',
|
||||
vModel: 'value',
|
||||
name: "a-textarea",
|
||||
vModel: "value",
|
||||
rows: 10,
|
||||
style: 'background-color: #000c17;color: #fafafa;',
|
||||
style: "background-color: #000c17;color: #fafafa;",
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
script!: string;
|
||||
|
||||
@TaskInput({
|
||||
title: '域名证书',
|
||||
helper: '请选择前置任务输出的域名证书',
|
||||
title: "域名证书",
|
||||
helper: "请选择前置任务输出的域名证书",
|
||||
component: {
|
||||
name: 'output-selector',
|
||||
name: "output-selector",
|
||||
from: [...CertApplyPluginNames],
|
||||
},
|
||||
required: false,
|
||||
@@ -48,14 +48,14 @@ export class CustomScriptPlugin extends AbstractTaskPlugin {
|
||||
async onInstance() {}
|
||||
async execute(): Promise<void> {
|
||||
this.checkAdmin();
|
||||
this.logger.info('执行自定义脚本:\n', this.script);
|
||||
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);
|
||||
const func = new AsyncFunction("ctx", this.script);
|
||||
return await func(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user