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

This commit is contained in:
xiaojunnuo
2026-07-26 20:37:28 +08:00
42 changed files with 423 additions and 112 deletions
+10
View File
@@ -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.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
### Bug Fixes
* 修复正常批量删除流水线报权限不足的bug ([5b50083](https://github.com/certd/certd/commit/5b500830a122c6c42dab054e57fed509050f94da))
### Performance Improvements
* 优化动态加载依赖镜像地址,多次重试 ([5f53b81](https://github.com/certd/certd/commit/5f53b81c75dd242b4260ac08cae14c6d1a08a883))
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
### Bug Fixes
+10
View File
@@ -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.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
### Bug Fixes
* 修复正常批量删除流水线报权限不足的bug ([5b50083](https://github.com/certd/certd/commit/5b500830a122c6c42dab054e57fed509050f94da))
### Performance Improvements
* 优化动态加载依赖镜像地址,多次重试 ([5f53b81](https://github.com/certd/certd/commit/5f53b81c75dd242b4260ac08cae14c6d1a08a883))
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
### Bug Fixes
+1 -1
View File
@@ -9,5 +9,5 @@
}
},
"npmClient": "pnpm",
"version": "1.42.5"
"version": "1.42.6"
}
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/publishlab/node-acme-client/compare/v1.42.5...v1.42.6) (2026-07-18)
**Note:** Version bump only for package @certd/acme-client
## [1.42.5](https://github.com/publishlab/node-acme-client/compare/v1.42.4...v1.42.5) (2026-07-15)
**Note:** Version bump only for package @certd/acme-client
+3 -3
View File
@@ -3,7 +3,7 @@
"description": "Simple and unopinionated ACME client",
"private": false,
"author": "nmorsman",
"version": "1.42.5",
"version": "1.42.6",
"type": "module",
"module": "./dist/index.js",
"main": "./dist/index.js",
@@ -18,7 +18,7 @@
"types"
],
"dependencies": {
"@certd/basic": "^1.42.5",
"@certd/basic": "^1.42.6",
"@peculiar/x509": "^1.11.0",
"asn1js": "^3.0.5",
"axios": "^1.9.0",
@@ -75,5 +75,5 @@
"bugs": {
"url": "https://github.com/publishlab/node-acme-client/issues"
},
"gitHead": "83495b32138cf831b4ea02054d12981d9787ebf0"
"gitHead": "246ee83015bf5589adc2a5fa3d1388c8d9a2a252"
}
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
**Note:** Version bump only for package @certd/basic
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
**Note:** Version bump only for package @certd/basic
+1 -1
View File
@@ -1 +1 @@
23:31
01:12
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "@certd/basic",
"private": false,
"version": "1.42.5",
"version": "1.42.6",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
@@ -54,5 +54,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "83495b32138cf831b4ea02054d12981d9787ebf0"
"gitHead": "246ee83015bf5589adc2a5fa3d1388c8d9a2a252"
}
+6
View File
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
### Performance Improvements
* 优化动态加载依赖镜像地址,多次重试 ([5f53b81](https://github.com/certd/certd/commit/5f53b81c75dd242b4260ac08cae14c6d1a08a883))
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
### Bug Fixes
+4 -4
View File
@@ -1,7 +1,7 @@
{
"name": "@certd/pipeline",
"private": false,
"version": "1.42.5",
"version": "1.42.6",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
@@ -21,8 +21,8 @@
"lint": "eslint --fix"
},
"dependencies": {
"@certd/basic": "^1.42.5",
"@certd/plus-core": "^1.42.5",
"@certd/basic": "^1.42.6",
"@certd/plus-core": "^1.42.6",
"dayjs": "^1.11.7",
"lodash-es": "^4.17.21",
"reflect-metadata": "^0.2.2"
@@ -51,5 +51,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "83495b32138cf831b4ea02054d12981d9787ebf0"
"gitHead": "246ee83015bf5589adc2a5fa3d1388c8d9a2a252"
}
@@ -571,8 +571,14 @@ export class RuntimeDepsService {
log.info("第三方依赖安装完成");
return { registryUrl: tryUrl, packageJsonPath };
}
lastError = result.stderr || result.stdout || "unknown error";
log.warn?.(`镜像 ${tryUrl || "默认"} 安装失败${urlsToTry.length > 1 ? ",尝试下一个镜像..." : ""}`);
const errOutput = (result.stderr || "").trim();
const outOutput = (result.stdout || "").trim();
lastError = errOutput || outOutput || "unknown error";
log.info(`镜像 ${tryUrl || "默认"} 安装失败,退出码: ${result.code}${urlsToTry.length > 1 ? ",尝试下一个镜像..." : ""}`);
log.info(` pnpm stderr: ${(errOutput || "(空)").slice(0, 2000)}`);
if (outOutput) {
log.info(` pnpm stdout: ${outOutput.slice(0, 2000)}`);
}
}
this.writeInstallState(statePath, {
...currentState,
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
**Note:** Version bump only for package @certd/lib-huawei
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
**Note:** Version bump only for package @certd/lib-huawei
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "@certd/lib-huawei",
"private": false,
"version": "1.42.5",
"version": "1.42.6",
"main": "./dist/bundle.js",
"module": "./dist/bundle.js",
"types": "./dist/d/index.d.ts",
@@ -31,5 +31,5 @@
"prettier": "3.3.3",
"tslib": "^2.8.1"
},
"gitHead": "83495b32138cf831b4ea02054d12981d9787ebf0"
"gitHead": "246ee83015bf5589adc2a5fa3d1388c8d9a2a252"
}
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
**Note:** Version bump only for package @certd/lib-iframe
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
**Note:** Version bump only for package @certd/lib-iframe
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "@certd/lib-iframe",
"private": false,
"version": "1.42.5",
"version": "1.42.6",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
@@ -37,5 +37,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "83495b32138cf831b4ea02054d12981d9787ebf0"
"gitHead": "246ee83015bf5589adc2a5fa3d1388c8d9a2a252"
}
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
**Note:** Version bump only for package @certd/jdcloud
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
**Note:** Version bump only for package @certd/jdcloud
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@certd/jdcloud",
"version": "1.42.5",
"version": "1.42.6",
"description": "jdcloud openApi sdk",
"main": "./dist/bundle.js",
"module": "./dist/bundle.js",
@@ -63,5 +63,5 @@
"fetch"
]
},
"gitHead": "83495b32138cf831b4ea02054d12981d9787ebf0"
"gitHead": "246ee83015bf5589adc2a5fa3d1388c8d9a2a252"
}
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
**Note:** Version bump only for package @certd/lib-k8s
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
**Note:** Version bump only for package @certd/lib-k8s
+3 -3
View File
@@ -1,7 +1,7 @@
{
"name": "@certd/lib-k8s",
"private": false,
"version": "1.42.5",
"version": "1.42.6",
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
@@ -21,7 +21,7 @@
"lint": "eslint --fix"
},
"dependencies": {
"@certd/basic": "^1.42.5",
"@certd/basic": "^1.42.6",
"@kubernetes/client-node": "0.21.0"
},
"devDependencies": {
@@ -38,5 +38,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "83495b32138cf831b4ea02054d12981d9787ebf0"
"gitHead": "246ee83015bf5589adc2a5fa3d1388c8d9a2a252"
}
+6
View File
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
### Bug Fixes
* 修复正常批量删除流水线报权限不足的bug ([5b50083](https://github.com/certd/certd/commit/5b500830a122c6c42dab054e57fed509050f94da))
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
### Bug Fixes
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@certd/lib-server",
"version": "1.42.5",
"version": "1.42.6",
"description": "midway with flyway, sql upgrade way ",
"private": false,
"type": "module",
@@ -29,11 +29,11 @@
],
"license": "AGPL",
"dependencies": {
"@certd/acme-client": "^1.42.5",
"@certd/basic": "^1.42.5",
"@certd/pipeline": "^1.42.5",
"@certd/plugin-lib": "^1.42.5",
"@certd/plus-core": "^1.42.5",
"@certd/acme-client": "^1.42.6",
"@certd/basic": "^1.42.6",
"@certd/pipeline": "^1.42.6",
"@certd/plugin-lib": "^1.42.6",
"@certd/plus-core": "^1.42.6",
"@midwayjs/cache": "3.14.0",
"@midwayjs/core": "3.20.11",
"@midwayjs/i18n": "3.20.13",
@@ -69,5 +69,5 @@
"typeorm": "^0.3.20",
"typescript": "^5.4.2"
},
"gitHead": "83495b32138cf831b4ea02054d12981d9787ebf0"
"gitHead": "246ee83015bf5589adc2a5fa3d1388c8d9a2a252"
}
@@ -253,7 +253,6 @@ export abstract class BaseService<T> {
if (!Array.isArray(ids)) {
ids = [ids];
}
ids = this.filterIds(ids);
const res = await this.getRepository().find({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
@@ -266,7 +265,7 @@ export abstract class BaseService<T> {
},
});
if (!res || res.length === ids.length) {
return;
return ids;
}
throw new PermissionException("权限不足");
}
@@ -280,6 +279,12 @@ export abstract class BaseService<T> {
});
}
async batchDelete(ids: number[], userId: number, projectId?: number): Promise<number> {
if (!ids || ids.length === 0) {
throw new ValidateException("ids不能为空");
}
if (!Array.isArray(ids)) {
ids = [ids];
}
ids = this.filterIds(ids);
if (userId != null) {
const userProjectQuery = this.buildUserProjectQuery(userId, projectId);
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
**Note:** Version bump only for package @certd/midway-flyway-js
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
### Performance Improvements
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@certd/midway-flyway-js",
"version": "1.42.5",
"version": "1.42.6",
"description": "midway with flyway, sql upgrade way ",
"private": false,
"type": "module",
@@ -52,5 +52,5 @@
"typeorm": "^0.3.20",
"typescript": "^5.4.2"
},
"gitHead": "83495b32138cf831b4ea02054d12981d9787ebf0"
"gitHead": "246ee83015bf5589adc2a5fa3d1388c8d9a2a252"
}
+8 -5
View File
@@ -93,19 +93,21 @@ export class Flyway {
await queryRunner.commitTransaction();
} catch (err) {
this.logger.error(err);
this.errorTip(err);
await this.storeSqlExecLog(file.script, filepath, false, queryRunner);
await queryRunner.rollbackTransaction();
if (err.code === "SQLITE_IOERR_WRITE") {
this.logger.warn("SQLite数据库写入失败,可能您的操作系统版本太低,请将「certd:latest」镜像改为「certd:slim」即可。(如需指定版本可以修改成「certd:[version]-slim」)", file.script);
}
throw err;
}
}
this.logger.info("[ midfly ] end-------------");
}
private errorTip(err: any) {
if (err.code === "SQLITE_IOERR_WRITE") {
this.logger.warn("SQLite数据库写入失败,可能您的操作系统版本太低,请将「certd:latest」镜像改为「certd:slim」即可。(如需指定版本可以修改成「certd:[version]-slim」)");
}
}
private async storeSqlExecLog(filename: string, filepath: string, success: boolean, queryRunner: QueryRunner) {
const hash = await this.getFileHash(filepath);
//先删除
@@ -265,6 +267,7 @@ export class Flyway {
await queryRunner.query(sql);
} catch (err: any) {
this.logger.error("exec sql error ", err.message, err);
this.errorTip(err);
throw err;
}
}
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
**Note:** Version bump only for package @certd/plugin-cert
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
**Note:** Version bump only for package @certd/plugin-cert
+3 -3
View File
@@ -1,7 +1,7 @@
{
"name": "@certd/plugin-cert",
"private": false,
"version": "1.42.5",
"version": "1.42.6",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -20,7 +20,7 @@
"lint": "eslint --fix"
},
"dependencies": {
"@certd/plugin-lib": "^1.42.5"
"@certd/plugin-lib": "^1.42.6"
},
"devDependencies": {
"@types/chai": "^4.3.12",
@@ -38,5 +38,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "83495b32138cf831b4ea02054d12981d9787ebf0"
"gitHead": "246ee83015bf5589adc2a5fa3d1388c8d9a2a252"
}
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
**Note:** Version bump only for package @certd/plugin-lib
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
### Bug Fixes
+5 -5
View File
@@ -1,7 +1,7 @@
{
"name": "@certd/plugin-lib",
"private": false,
"version": "1.42.5",
"version": "1.42.6",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
@@ -17,9 +17,9 @@
"lint": "eslint --fix"
},
"dependencies": {
"@certd/acme-client": "^1.42.5",
"@certd/basic": "^1.42.5",
"@certd/pipeline": "^1.42.5",
"@certd/acme-client": "^1.42.6",
"@certd/basic": "^1.42.6",
"@certd/pipeline": "^1.42.6",
"dayjs": "^1.11.7",
"jszip": "^3.10.1",
"lodash-es": "^4.17.21",
@@ -45,5 +45,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "83495b32138cf831b4ea02054d12981d9787ebf0"
"gitHead": "246ee83015bf5589adc2a5fa3d1388c8d9a2a252"
}
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
**Note:** Version bump only for package @certd/ui-client
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
### Bug Fixes
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@certd/ui-client",
"version": "1.42.5",
"version": "1.42.6",
"private": true,
"scripts": {
"dev": "vite --open",
@@ -104,8 +104,8 @@
"zod-defaults": "^0.1.3"
},
"devDependencies": {
"@certd/lib-iframe": "^1.42.5",
"@certd/pipeline": "^1.42.5",
"@certd/lib-iframe": "^1.42.6",
"@certd/pipeline": "^1.42.6",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/chai": "^4.3.12",
+6
View File
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.42.6](https://github.com/certd/certd/compare/v1.42.5...v1.42.6) (2026-07-18)
### Bug Fixes
* 修复正常批量删除流水线报权限不足的bug ([5b50083](https://github.com/certd/certd/commit/5b500830a122c6c42dab054e57fed509050f94da))
## [1.42.5](https://github.com/certd/certd/compare/v1.42.4...v1.42.5) (2026-07-15)
### Bug Fixes
+14 -14
View File
@@ -1,6 +1,6 @@
{
"name": "@certd/ui-server",
"version": "1.42.5",
"version": "1.42.6",
"description": "fast-server base midway",
"private": true,
"type": "module",
@@ -42,20 +42,20 @@
"lint1": "eslint --fix"
},
"dependencies": {
"@certd/acme-client": "^1.42.5",
"@certd/basic": "^1.42.5",
"@certd/commercial-core": "^1.42.5",
"@certd/acme-client": "^1.42.6",
"@certd/basic": "^1.42.6",
"@certd/commercial-core": "^1.42.6",
"@certd/cv4pve-api-javascript": "^8.4.2",
"@certd/jdcloud": "^1.42.5",
"@certd/lib-huawei": "^1.42.5",
"@certd/lib-k8s": "^1.42.5",
"@certd/lib-server": "^1.42.5",
"@certd/midway-flyway-js": "^1.42.5",
"@certd/pipeline": "^1.42.5",
"@certd/plugin-cert": "^1.42.5",
"@certd/plugin-lib": "^1.42.5",
"@certd/plugin-plus": "^1.42.5",
"@certd/plus-core": "^1.42.5",
"@certd/jdcloud": "^1.42.6",
"@certd/lib-huawei": "^1.42.6",
"@certd/lib-k8s": "^1.42.6",
"@certd/lib-server": "^1.42.6",
"@certd/midway-flyway-js": "^1.42.6",
"@certd/pipeline": "^1.42.6",
"@certd/plugin-cert": "^1.42.6",
"@certd/plugin-lib": "^1.42.6",
"@certd/plugin-plus": "^1.42.6",
"@certd/plus-core": "^1.42.6",
"@koa/cors": "^5.0.0",
"@midwayjs/bootstrap": "3.20.11",
"@midwayjs/cache": "3.14.0",
@@ -806,6 +806,8 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
}
async batchDelete(ids: number[], userId: number, projectId?: number): Promise<number> {
ids = this.filterIds(ids);
const userProjectQuery = this.buildUserProjectQuery(userId, projectId);
const result = await this.repository.delete({
id: In(ids),
@@ -1,7 +1,7 @@
import { Config, Inject, Provide, Scope, ScopeEnum, sleep } from "@midwayjs/core";
import { InjectEntityModel } from "@midwayjs/typeorm";
import { In, MoreThan, Repository } from "typeorm";
import { AccessService, BaseService, isEnterprise, NeedSuiteException, NeedVIPException, PageReq, SysPublicSettings, SysSettingsService, SysSiteInfo } from "@certd/lib-server";
import { AccessService, BaseService, isEnterprise, NeedSuiteException, NeedVIPException, PageReq, SysPublicSettings, SysSettingsService, SysSiteInfo, ValidateException } from "@certd/lib-server";
import { PipelineEntity } from "../entity/pipeline.js";
import { PipelineDetail } from "../entity/vo/pipeline-detail.js";
import { Executor, IAccessService, ICnameProxyService, INotificationService, Notification, Pipeline, pluginRegistry, ResultType, RunHistory, RunnableCollection, SysInfo, UserInfo } from "@certd/pipeline";
@@ -966,15 +966,19 @@ export class PipelineService extends BaseService<PipelineEntity> {
if (!isPlus()) {
throw new NeedVIPException("此功能需要升级Certd专业版");
}
if (!ids || ids.length === 0) {
throw new ValidateException("ids不能为空");
}
ids = this.filterIds(ids);
if (userId && userId > 0) {
await this.checkUserId(ids, userId);
}
if (projectId) {
await this.checkUserId(ids, projectId, "projectId");
}
for (const id of ids) {
if (userId && userId > 0) {
await this.checkUserId(id, userId);
}
if (projectId) {
await this.checkUserId(id, projectId, "projectId");
}
await this.delete(id);
ids.push(id);
}
return ids.length;
}
@@ -88,6 +88,7 @@ export class TemplateService extends BaseService<TemplateEntity> {
}
async batchDelete(ids: number[], userId: number, projectId?: number): Promise<number> {
ids = this.filterIds(ids);
const where: any = {
id: In(ids),
};
@@ -1,15 +1,17 @@
import crypto from "node:crypto";
import { BaotaAccess } from "../access.js";
import { HttpClient, HttpRequestConfig } from "@certd/basic";
import { HttpClient, HttpRequestConfig, ILogger } from "@certd/basic";
import * as querystring from "node:querystring";
export class BaotaClient {
access: BaotaAccess;
http: HttpClient;
logger: ILogger
constructor(access: BaotaAccess, http: HttpClient) {
this.access = access;
this.http = http;
this.logger = access.ctx.logger;
}
//将以上 java代码 翻译成nodejs 代码
@@ -88,7 +88,7 @@ export class BaotaDeployWebSiteCert extends AbstractTaskPlugin {
})
siteName!: string | string[];
async onInstance() {}
async onInstance() { }
async execute(): Promise<void> {
const { cert, accessId } = this;
const access = await this.getAccess(accessId);
@@ -104,26 +104,37 @@ export class BaotaDeployWebSiteCert extends AbstractTaskPlugin {
}
const lockKey = `baota-lock-${accessId}`;
if (this.isDockerSite) {
this.logger.info(`当前已勾选docker站点(如果部署失败,请确认站点:${siteNames} 是否全部为docker站点)`);
}
for (const site of siteNames) {
// 加锁,防止并发部署证书, 宝塔并发部署会导致nginx的conf错乱
await this.ctx.utils.locker.execute(lockKey, async () => {
this.logger.info(`为站点:${site}设置证书,目前支持宝塔网站站点、docker站点`);
if (this.isDockerSite) {
const res = await client.doRequest("/mod/docker/com/set_ssl", "", {
site_name: site,
key: cert.key,
csr: cert.crt,
});
this.logger.info(res?.msg);
} else {
const res = await client.doRequest("/site", "SetSSL", {
type: 0,
siteName: site,
key: cert.key,
csr: cert.crt,
});
this.logger.info(res?.msg);
try {
if (this.isDockerSite) {
this.logger.info(`为Docker站点:${site} 设置证书`);
const res = await client.doRequest("/mod/docker/com/set_ssl", "", {
site_name: site,
key: cert.key,
csr: cert.crt,
});
this.logger.info(res?.msg);
} else {
this.logger.info(`为非Docker站点:${site} 设置证书`);
const res = await client.doRequest("/site", "SetSSL", {
type: 0,
siteName: site,
key: cert.key,
csr: cert.crt,
});
this.logger.info(res?.msg);
}
} catch (e: any) {
if (e?.message?.includes("没有服务器配置文件")) {
this.logger.error(e.message);
this.logger.warn(`首先请确认站点 ${site} 是否存在,如果存在,请到宝塔上手动保存一下该站点证书试试`);
}
throw e
}
});
}
@@ -0,0 +1,111 @@
/// <reference types="mocha" />
import assert from "node:assert/strict";
import { DeployCertToTencentCLB } from "./index.js";
describe("DeployCertToTencentCLB", () => {
it("uses remote single-select inputs for CLB and HTTPS listener", () => {
const input = (DeployCertToTencentCLB as any).define.input;
assert.equal(input.loadBalancerId.component.name, "remote-select");
assert.equal(input.loadBalancerId.component.single, true);
assert.equal(input.loadBalancerId.component.action, "onGetCLBList");
assert.equal(input.loadBalancerId.required, true);
assert.equal(input.listenerId.component.name, "remote-select");
assert.equal(input.listenerId.component.single, true);
assert.equal(input.listenerId.component.action, "onGetListenerList");
assert.deepEqual(input.listenerId.component.watches, ["certDomains", "accessId", "region", "loadBalancerId"]);
assert.equal(input.listenerId.required, true);
assert.equal(input.domain.component.name, "remote-select");
assert.equal(input.domain.component.single, false);
assert.equal(input.domain.component.action, "onGetDomainList");
assert.deepEqual(input.domain.component.watches, ["certDomains", "accessId", "region", "loadBalancerId", "listenerId"]);
assert.equal(input.domain.required, false);
});
it("maps CLB API results to remote-select options", async () => {
const plugin = new DeployCertToTencentCLB();
plugin.accessId = "access-1";
plugin.logger = { info: () => undefined } as any;
(plugin as any).getClient = async () => ({});
(plugin as any).getCLBList = async () => [
{
LoadBalancerId: "lb-1",
LoadBalancerName: "业务负载均衡",
},
];
const options = await plugin.onGetCLBList({});
assert.deepEqual(options, [
{
value: "lb-1",
label: "业务负载均衡<lb-1>",
},
]);
});
it("maps HTTPS listener API results after selecting a CLB", async () => {
const plugin = new DeployCertToTencentCLB();
plugin.accessId = "access-1";
plugin.loadBalancerId = "lb-1";
plugin.logger = { info: () => undefined } as any;
(plugin as any).getClient = async () => ({});
(plugin as any).getListenerList = async (_client: any, loadBalancerId: string, listenerIds: any) => {
assert.equal(loadBalancerId, "lb-1");
assert.equal(listenerIds, null);
return [
{
ListenerId: "listener-1",
ListenerName: "HTTPS监听器",
Port: 443,
},
];
};
const options = await plugin.onGetListenerList({});
assert.deepEqual(options, [
{
value: "listener-1",
label: "HTTPS监听器:443<listener-1>",
},
]);
});
it("maps SNI domains from the selected listener rules", async () => {
const plugin = new DeployCertToTencentCLB();
plugin.accessId = "access-1";
plugin.loadBalancerId = "lb-1";
plugin.listenerId = "listener-1";
plugin.logger = { info: () => undefined } as any;
(plugin as any).getClient = async () => ({});
(plugin as any).getListenerList = async (_client: any, loadBalancerId: string, listenerIds: string[]) => {
assert.equal(loadBalancerId, "lb-1");
assert.deepEqual(listenerIds, ["listener-1"]);
return [
{
ListenerId: "listener-1",
Rules: [{ Domain: "www.example.com" }, { Domain: "api.example.com" }],
},
];
};
const options = await plugin.onGetDomainList({});
assert.deepEqual(options, [
{
value: "www.example.com",
label: "www.example.com",
domain: "www.example.com",
},
{
value: "api.example.com",
label: "api.example.com",
domain: "api.example.com",
},
]);
});
});
@@ -1,7 +1,8 @@
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
import { AbstractTaskPlugin, IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
import dayjs from "dayjs";
import { TencentAccess } from "../../../plugin-lib/tencent/index.js";
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
import { createRemoteSelectInputDefine } from "@certd/plugin-lib";
@IsTaskPlugin({
name: "DeployCertToTencentCLB",
title: "腾讯云-部署到CLB",
@@ -73,29 +74,44 @@ export class DeployCertToTencentCLB extends AbstractTaskPlugin {
})
region!: string;
@TaskInput({
title: "负载均衡ID",
required: true,
})
@TaskInput(
createRemoteSelectInputDefine({
title: "负载均衡ID",
helper: "请选择要部署证书的负载均衡",
action: DeployCertToTencentCLB.prototype.onGetCLBList.name,
watches: ["region"],
single: true,
pager: false,
search: false,
})
)
loadBalancerId!: string;
@TaskInput({
title: "监听器ID",
required: true,
})
@TaskInput(
createRemoteSelectInputDefine({
title: "监听器ID",
helper: "请选择要部署证书的HTTPS监听器",
action: DeployCertToTencentCLB.prototype.onGetListenerList.name,
watches: ["region", "loadBalancerId"],
single: true,
pager: false,
search: false,
})
)
listenerId!: string;
@TaskInput({
title: "域名",
required: false,
component: {
name: "a-select",
vModel: "value",
open: false,
mode: "tags",
},
helper: "如果开启了sni,则此项必须填写,未开启,则不要填写",
})
@TaskInput(
createRemoteSelectInputDefine({
title: "域名",
helper: "如果开启了SNI,请选择要部署证书的域名;未开启SNI时可以留空",
action: DeployCertToTencentCLB.prototype.onGetDomainList.name,
watches: ["region", "loadBalancerId", "listenerId"],
required: false,
single: false,
pager: false,
search: false,
})
)
domain!: string | string[];
@TaskInput({
@@ -272,6 +288,27 @@ export class DeployCertToTencentCLB extends AbstractTaskPlugin {
return ret.LoadBalancerSet;
}
async onGetCLBList(data: PageSearch) {
if (!this.accessId) {
throw new Error("请选择Access提供者");
}
const client = await this.getClient();
const list = await this.getCLBList(client);
if (!list || list.length === 0) {
return [];
}
return list.map((item: any) => {
const loadBalancerId = item.LoadBalancerId;
const loadBalancerName = item.LoadBalancerName || loadBalancerId;
return {
value: loadBalancerId,
label: `${loadBalancerName}<${loadBalancerId}>`,
};
});
}
async getListenerList(client: any, balancerId: any, listenerIds: any) {
// HTTPS
const params = {
@@ -284,6 +321,57 @@ export class DeployCertToTencentCLB extends AbstractTaskPlugin {
return ret.Listeners;
}
async onGetListenerList(data: PageSearch) {
if (!this.accessId) {
throw new Error("请选择Access提供者");
}
if (!this.loadBalancerId) {
throw new Error("请先选择负载均衡");
}
const client = await this.getClient();
const list = await this.getListenerList(client, this.loadBalancerId, null);
if (!list || list.length === 0) {
return [];
}
return list.map((item: any) => {
const listenerId = item.ListenerId;
const listenerName = item.ListenerName || "HTTPS监听器";
const port = item.Port ? `:${item.Port}` : "";
return {
value: listenerId,
label: `${listenerName}${port}<${listenerId}>`,
};
});
}
async onGetDomainList(data: PageSearch) {
if (!this.accessId) {
throw new Error("请选择Access提供者");
}
if (!this.loadBalancerId) {
throw new Error("请先选择负载均衡");
}
if (!this.listenerId) {
throw new Error("请先选择监听器");
}
const client = await this.getClient();
const listeners = await this.getListenerList(client, this.loadBalancerId, [this.listenerId]);
const listener = listeners?.[0];
const domains = listener?.Rules?.map((rule: any) => rule.Domain).filter(Boolean) || [];
const uniqueDomains = [...new Set(domains)];
return uniqueDomains.map(domain => {
return {
value: domain,
label: domain,
domain,
};
});
}
checkRet(ret: any) {
if (!ret || ret.Error) {
throw new Error("执行失败:" + ret.Error.Code + "," + ret.Error.Message);
+1 -1
View File
@@ -1 +1 @@
23:35
01:14
+1 -1
View File
@@ -1 +1 @@
23:54
01:28