mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
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
This commit is contained in:
@@ -3,6 +3,16 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.21.2](https://github.com/certd/certd/compare/v1.21.1...v1.21.2) (2024-07-08)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-client
|
||||
|
||||
## [1.21.1](https://github.com/certd/certd/compare/v1.21.0...v1.21.1) (2024-07-08)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 说明优化,默认值优化 ([970c7fd](https://github.com/certd/certd/commit/970c7fd8a0f557770e973d8462ee5684ef742810))
|
||||
|
||||
# [1.21.0](https://github.com/certd/certd/compare/v1.20.17...v1.21.0) (2024-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-client
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/ui-client",
|
||||
"version": "1.21.0",
|
||||
"version": "1.21.2",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite --open",
|
||||
@@ -59,7 +59,7 @@
|
||||
"vuedraggable": "^2.24.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/pipeline": "^1.21.0",
|
||||
"@certd/pipeline": "^1.21.2",
|
||||
"@rollup/plugin-commonjs": "^25.0.7",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@types/chai": "^4.3.12",
|
||||
|
||||
+4
@@ -222,6 +222,10 @@ export default {
|
||||
);
|
||||
}
|
||||
}
|
||||
//设置初始值
|
||||
if (input.default != null && currentStep.value.input[key] == null) {
|
||||
currentStep.value.input[key] = input.default ?? input.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as api from "./api";
|
||||
import { utils, dict, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, UserPageQuery, UserPageRes, EditReq, DelReq, AddReq, ScopeContext } from "@fast-crud/fast-crud";
|
||||
import { FsUploaderFormOptions } from "@fast-crud/fast-extends";
|
||||
|
||||
import "./editor.css";
|
||||
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
||||
return await api.GetList(query);
|
||||
@@ -79,6 +79,11 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
||||
show: false
|
||||
},
|
||||
type: "editor-wang5", // 富文本图片上传依赖file-uploader,请先配置好file-uploader
|
||||
viewForm: {
|
||||
render({ value }) {
|
||||
return <div class={"editor-content-view"} v-html={value}></div>;
|
||||
}
|
||||
},
|
||||
form: {
|
||||
helper: "示例已升级到wangEditor5版本,原来的editor-wang目前仍然可以使用,后续fs升级可能会将其删除,请尽快升级到editor-wang5版本",
|
||||
col: { span: 24 },
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -57,7 +57,17 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
||||
multiple: true, //可选择多个
|
||||
uploader: {
|
||||
type: "form",
|
||||
keepName: true
|
||||
keepName: true,
|
||||
successHandle(res: any) {
|
||||
//这里我的后台返回res是一个key 字符串
|
||||
//此方法需要返回的数据结构为 {key:"string",url:"string"...}
|
||||
// 如果 有返回url,那么buildUrl将不会被执行
|
||||
return { key: res };
|
||||
}
|
||||
},
|
||||
valueType: "key",
|
||||
async buildUrl(value: string) {
|
||||
return "http://www.docmirror.cn:7070/api/upload/form/download?key=" + value;
|
||||
}
|
||||
},
|
||||
helper: "可以同时选择多个文件"
|
||||
|
||||
@@ -3,6 +3,17 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.21.2](https://github.com/fast-crud/fast-server-js/compare/v1.21.1...v1.21.2) (2024-07-08)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-server
|
||||
|
||||
## [1.21.1](https://github.com/fast-crud/fast-server-js/compare/v1.21.0...v1.21.1) (2024-07-08)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 上传到主机,支持设置不mkdirs ([5ba9831](https://github.com/fast-crud/fast-server-js/commit/5ba9831ed1aa6ec6057df246f1035b36b9c41d2e))
|
||||
* 说明优化,默认值优化 ([970c7fd](https://github.com/fast-crud/fast-server-js/commit/970c7fd8a0f557770e973d8462ee5684ef742810))
|
||||
|
||||
# [1.21.0](https://github.com/fast-crud/fast-server-js/compare/v1.20.17...v1.21.0) (2024-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-server
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "my-midway-esm-project",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"name": "@certd/ui-server",
|
||||
"version": "1.21.2",
|
||||
"description": "fast-server base midway",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
@@ -19,12 +19,10 @@
|
||||
"@alicloud/cs20151215": "^3.0.3",
|
||||
"@alicloud/openapi-client": "^0.4.0",
|
||||
"@alicloud/pop-core": "^1.7.10",
|
||||
"@certd/acme-client": "^1.21.0",
|
||||
"@certd/lib-huawei": "^1.21.0",
|
||||
"@certd/lib-k8s": "^1.21.0",
|
||||
"@certd/midway-flyway-js": "^1.21.0",
|
||||
"@certd/pipeline": "^1.21.0",
|
||||
"@certd/plugin-cert": "^1.21.0",
|
||||
"@certd/acme-client": "^1.21.2",
|
||||
"@certd/pipeline": "^1.21.2",
|
||||
"@certd/plugin-cert": "^1.21.2",
|
||||
"@certd/plugin-util": "^1.21.2",
|
||||
"@koa/cors": "^3.4.3",
|
||||
"@midwayjs/bootstrap": "^3.16.2",
|
||||
"@midwayjs/cache": "^3.14.0",
|
||||
|
||||
@@ -96,7 +96,9 @@ export class AsyncSsh2Client {
|
||||
.stderr.on('data', (ret: Buffer) => {
|
||||
const err = this.convert(ret);
|
||||
data += err;
|
||||
this.logger.info(`[${this.connConf.host}][error]: ` + err.trimEnd());
|
||||
this.logger.info(
|
||||
`[${this.connConf.host}][error]: ` + err.trimEnd()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -152,30 +154,39 @@ export class SshClient {
|
||||
}
|
||||
* @param options
|
||||
*/
|
||||
async uploadFiles(options: { connectConf: SshAccess; transports: any }) {
|
||||
const { connectConf, transports } = options;
|
||||
async uploadFiles(options: {
|
||||
connectConf: SshAccess;
|
||||
transports: any;
|
||||
mkdirs: boolean;
|
||||
}) {
|
||||
const { connectConf, transports, mkdirs } = options;
|
||||
await this._call({
|
||||
connectConf,
|
||||
callable: async (conn: AsyncSsh2Client) => {
|
||||
const sftp = await conn.getSftp();
|
||||
this.logger.info('开始上传');
|
||||
for (const transport of transports) {
|
||||
const filePath = path.dirname(transport.remotePath);
|
||||
let mkdirCmd = `mkdir -p ${filePath} `;
|
||||
if (conn.windows) {
|
||||
if (filePath.indexOf('/') > -1) {
|
||||
this.logger.info('--------------------------');
|
||||
this.logger.info('请注意:windows下,文件目录分隔应该写成\\而不是/');
|
||||
this.logger.info('--------------------------');
|
||||
}
|
||||
const spec = await conn.exec('echo %COMSPEC%');
|
||||
if (spec.toString().trim() === '%COMSPEC%') {
|
||||
mkdirCmd = `New-Item -ItemType Directory -Path "${filePath}" -Force`;
|
||||
} else {
|
||||
mkdirCmd = `if not exist "${filePath}" mkdir "${filePath}"`;
|
||||
if (mkdirs !== false) {
|
||||
const filePath = path.dirname(transport.remotePath);
|
||||
let mkdirCmd = `mkdir -p ${filePath} `;
|
||||
if (conn.windows) {
|
||||
if (filePath.indexOf('/') > -1) {
|
||||
this.logger.info('--------------------------');
|
||||
this.logger.info(
|
||||
'请注意:windows下,文件目录分隔应该写成\\而不是/'
|
||||
);
|
||||
this.logger.info('--------------------------');
|
||||
}
|
||||
const spec = await conn.exec('echo %COMSPEC%');
|
||||
if (spec.toString().trim() === '%COMSPEC%') {
|
||||
mkdirCmd = `New-Item -ItemType Directory -Path "${filePath}" -Force`;
|
||||
} else {
|
||||
mkdirCmd = `if not exist "${filePath}" mkdir "${filePath}"`;
|
||||
}
|
||||
}
|
||||
await conn.exec(mkdirCmd);
|
||||
}
|
||||
await conn.exec(mkdirCmd);
|
||||
|
||||
await conn.fastPut({ sftp, ...transport });
|
||||
}
|
||||
this.logger.info('文件全部上传成功');
|
||||
|
||||
@@ -48,6 +48,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
required: true,
|
||||
})
|
||||
cert!: CertInfo;
|
||||
|
||||
@TaskInput({
|
||||
title: '主机登录配置',
|
||||
helper: 'access授权',
|
||||
@@ -59,13 +60,24 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
})
|
||||
accessId!: string;
|
||||
|
||||
@TaskInput({
|
||||
title: '自动创建远程目录',
|
||||
helper: '是否自动创建远程目录,如果关闭则你需要自己确保远程目录存在',
|
||||
default: true,
|
||||
component: {
|
||||
name: 'a-switch',
|
||||
vModel: 'checked',
|
||||
},
|
||||
})
|
||||
mkdirs = true;
|
||||
|
||||
@TaskInput({
|
||||
title: '仅复制到当前主机',
|
||||
helper:
|
||||
'开启后,将直接复制到当前主机某个目录,不上传到主机,由于是docker启动,实际上是复制到docker容器内的“证书保存路径”,你需要事先在docker-compose.yaml中配置主机目录映射: volumes: /your_target_path:/your_target_path',
|
||||
default: false,
|
||||
component: {
|
||||
name: 'a-switch',
|
||||
default: false,
|
||||
vModel: 'checked',
|
||||
},
|
||||
})
|
||||
@@ -102,39 +114,58 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
this.logger.info('将证书写入本地缓存文件');
|
||||
const saveCrtPath = certReader.saveToFile('crt');
|
||||
const saveKeyPath = certReader.saveToFile('key');
|
||||
|
||||
if (this.copyToThisHost) {
|
||||
this.logger.info('复制到目标路径');
|
||||
this.copyFile(saveCrtPath, crtPath);
|
||||
this.copyFile(saveKeyPath, keyPath);
|
||||
this.logger.info('证书复制成功:crtPath=', crtPath, ',keyPath=', keyPath);
|
||||
} else {
|
||||
if (!accessId) {
|
||||
throw new Error('主机登录授权配置不能为空');
|
||||
this.logger.info('本地文件写入成功');
|
||||
try {
|
||||
if (this.copyToThisHost) {
|
||||
this.logger.info('复制到目标路径');
|
||||
this.copyFile(saveCrtPath, crtPath);
|
||||
this.copyFile(saveKeyPath, keyPath);
|
||||
this.logger.info(
|
||||
'证书复制成功:crtPath=',
|
||||
crtPath,
|
||||
',keyPath=',
|
||||
keyPath
|
||||
);
|
||||
} else {
|
||||
if (!accessId) {
|
||||
throw new Error('主机登录授权配置不能为空');
|
||||
}
|
||||
this.logger.info('准备上传文件到服务器');
|
||||
const connectConf: SshAccess = await this.accessService.getById(
|
||||
accessId
|
||||
);
|
||||
const sshClient = new SshClient(this.logger);
|
||||
await sshClient.uploadFiles({
|
||||
connectConf,
|
||||
transports: [
|
||||
{
|
||||
localPath: saveCrtPath,
|
||||
remotePath: crtPath,
|
||||
},
|
||||
{
|
||||
localPath: saveKeyPath,
|
||||
remotePath: keyPath,
|
||||
},
|
||||
],
|
||||
mkdirs: this.mkdirs,
|
||||
});
|
||||
this.logger.info(
|
||||
'证书上传成功:crtPath=',
|
||||
crtPath,
|
||||
',keyPath=',
|
||||
keyPath
|
||||
);
|
||||
}
|
||||
this.logger.info('准备上传到服务器');
|
||||
const connectConf: SshAccess = await this.accessService.getById(accessId);
|
||||
const sshClient = new SshClient(this.logger);
|
||||
await sshClient.uploadFiles({
|
||||
connectConf,
|
||||
transports: [
|
||||
{
|
||||
localPath: saveCrtPath,
|
||||
remotePath: crtPath,
|
||||
},
|
||||
{
|
||||
localPath: saveKeyPath,
|
||||
remotePath: keyPath,
|
||||
},
|
||||
],
|
||||
});
|
||||
this.logger.info('证书上传成功:crtPath=', crtPath, ',keyPath=', keyPath);
|
||||
} catch (e) {
|
||||
this.logger.error(`上传失败:${e.message}`);
|
||||
throw e;
|
||||
} finally {
|
||||
//删除临时文件
|
||||
this.logger.info('删除临时文件');
|
||||
fs.unlinkSync(saveCrtPath);
|
||||
fs.unlinkSync(saveKeyPath);
|
||||
}
|
||||
|
||||
//删除临时文件
|
||||
fs.unlinkSync(saveCrtPath);
|
||||
fs.unlinkSync(saveKeyPath);
|
||||
|
||||
this.logger.info('执行完成');
|
||||
//输出
|
||||
this.hostCrtPath = crtPath;
|
||||
this.hostKeyPath = keyPath;
|
||||
|
||||
Reference in New Issue
Block a user