mirror of
https://github.com/certd/certd.git
synced 2026-04-06 07:50:54 +08:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f47f86b669 | ||
|
|
95eeb93822 | ||
|
|
367f807313 | ||
|
|
a954629ff9 | ||
|
|
3bbbc41062 | ||
|
|
bf63b0d73f | ||
|
|
5362df55f4 | ||
|
|
59897c4cea | ||
|
|
a9717b9a0d | ||
|
|
680941af11 | ||
|
|
1cf8d4e5e7 | ||
|
|
70ce6be0bf | ||
|
|
9187e87419 | ||
|
|
6ed1e18c7d | ||
|
|
8d27f07213 | ||
|
|
e4f4570b29 | ||
|
|
d86fc9569a | ||
|
|
fa7a983bcb | ||
|
|
9ac908ebee | ||
|
|
6e594ee66e | ||
|
|
c26d3e9c38 | ||
|
|
5db5607faa | ||
|
|
728f27e0a0 |
55
.github/workflows/deploy-demo.yml
vendored
Normal file
55
.github/workflows/deploy-demo.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
name: deploy-demo
|
||||
on:
|
||||
push:
|
||||
branches: ['v2']
|
||||
paths:
|
||||
- "deploy.trigger"
|
||||
workflow_run:
|
||||
workflows: [ "build-image" ]
|
||||
types:
|
||||
- completed
|
||||
|
||||
# schedule:
|
||||
# - # 国际时间 19:17 执行,北京时间3:17 ↙↙↙ 改成你想要每天自动执行的时间
|
||||
# - cron: '17 19 * * *'
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
deploy-certd-demo:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
- name: get_certd_version
|
||||
id: get_certd_version
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
result-encoding: string
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const jsonFilePath = "./packages/ui/certd-server/package.json";
|
||||
const jsonContent = fs.readFileSync(jsonFilePath, 'utf-8');
|
||||
const pkg = JSON.parse(jsonContent)
|
||||
console.log("certd_version:",pkg.version);
|
||||
return pkg.version
|
||||
- uses: GuillaumeFalourd/wait-sleep-action@v1
|
||||
with:
|
||||
time: '10' # for 60 seconds
|
||||
- name: Send HTTP request
|
||||
id: request
|
||||
uses: tyrrrz/action-http-request@master
|
||||
with:
|
||||
url: http://flow-openapi.aliyun.com/pipeline/webhook/lzCzlGrLCOHQaTMMt0mG
|
||||
method: POST
|
||||
headers: |
|
||||
Content-Type: application/json
|
||||
body: |
|
||||
{
|
||||
"CERTD_VERSION": "${{steps.get_certd_version.outputs.result}}"
|
||||
}
|
||||
retry-count: 3
|
||||
retry-delay: 5000
|
||||
|
||||
|
||||
19
CHANGELOG.md
19
CHANGELOG.md
@@ -3,6 +3,25 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.22.7](https://github.com/certd/certd/compare/v1.22.6...v1.22.7) (2024-08-04)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复保存配置报id不能为空的bug ([367f807](https://github.com/certd/certd/commit/367f80731396003416665c22853dfbc09c2c03a0))
|
||||
|
||||
## [1.22.6](https://github.com/certd/certd/compare/v1.22.5...v1.22.6) (2024-08-03)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复在相同的cron时偶尔无法触发定时任务的bug ([680941a](https://github.com/certd/certd/commit/680941af119619006b592e3ab6fb112cb5556a8b))
|
||||
* 修复pg下pipeline title 类型问题 ([a9717b9](https://github.com/certd/certd/commit/a9717b9a0df7b5a64d4fe03314fecad4f59774cc))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 流水线支持名称模糊查询 ([59897c4](https://github.com/certd/certd/commit/59897c4ceae992ebe2972ca9e8f9196616ffdfd7))
|
||||
* 腾讯云clb支持更多大区选择 ([e4f4570](https://github.com/certd/certd/commit/e4f4570b29f26c60f1ee9660a4c507cbeaba3d7e))
|
||||
* 优化前置任务输出为空的提示 ([6ed1e18](https://github.com/certd/certd/commit/6ed1e18c7d9c46d964ecc6abc90f3908297b7632))
|
||||
|
||||
## [1.22.5](https://github.com/certd/certd/compare/v1.22.4...v1.22.5) (2024-07-26)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -1 +1 @@
|
||||
6
|
||||
02:55
|
||||
|
||||
1
deploy.trigger
Normal file
1
deploy.trigger
Normal file
@@ -0,0 +1 @@
|
||||
5
|
||||
@@ -11,6 +11,12 @@ services:
|
||||
ports: # 端口映射
|
||||
# ↓↓↓↓ ----------------------------------------------------------3、如果端口有冲突,可以修改第一个7001为其他不冲突的端口号【可选】
|
||||
- "7001:7001"
|
||||
dns:
|
||||
# 如果出现getaddrinfo ENOTFOUND等错误,可以尝试修改或注释dns配置
|
||||
- 223.5.5.5
|
||||
- 223.6.6.6
|
||||
- 8.8.8.8
|
||||
- 8.8.4.4
|
||||
environment: # 环境变量
|
||||
- TZ=Asia/Shanghai
|
||||
- certd_system_resetAdminPassword=false
|
||||
|
||||
@@ -9,5 +9,5 @@
|
||||
}
|
||||
},
|
||||
"npmClient": "pnpm",
|
||||
"version": "1.22.5"
|
||||
"version": "1.22.7"
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"start": "lerna bootstrap --hoist",
|
||||
"i-all": "lerna link && lerna exec npm install ",
|
||||
"publish": "npm run prepublishOnly1 && lerna publish --conventional-commits --create-release github && npm run afterpublishOnly",
|
||||
"afterpublishOnly": "time /t >build.trigger && git add ./build.md && git commit -m \"build: trigger build image\" && TIMEOUT /T 10 && git push",
|
||||
"afterpublishOnly": "time /t >build.trigger && git add ./build.trigger && git commit -m \"build: trigger build image\" && TIMEOUT /T 10 && git push",
|
||||
"prepublishOnly1": "npm run check && npm run before-build && lerna run build ",
|
||||
"before-build": "cd ./packages/core/pipeline && time /t >build.md && git add ./build.md && git commit -m \"build: prepare to build\"",
|
||||
"deploy1": "node --experimental-json-modules deploy.js ",
|
||||
|
||||
@@ -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.22.6](https://github.com/publishlab/node-acme-client/compare/v1.22.5...v1.22.6) (2024-08-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.22.4](https://github.com/publishlab/node-acme-client/compare/v1.22.3...v1.22.4) (2024-07-26)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"description": "Simple and unopinionated ACME client",
|
||||
"private": false,
|
||||
"author": "nmorsman",
|
||||
"version": "1.22.4",
|
||||
"version": "1.22.6",
|
||||
"main": "src/index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"license": "MIT",
|
||||
|
||||
2
packages/core/pipeline/.gitignore
vendored
2
packages/core/pipeline/.gitignore
vendored
@@ -24,3 +24,5 @@ dist-ssr
|
||||
*.sw?
|
||||
|
||||
test/user.secret.*
|
||||
test/**/*.js
|
||||
src/**/*.spec.ts
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"extension": ["ts"],
|
||||
"spec": "test/**/*.test.ts",
|
||||
"require": "ts-node/register"
|
||||
}
|
||||
"spec": "src/**/*.spec.ts"
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
node_modules
|
||||
src
|
||||
src
|
||||
dist/**/*.spec.*
|
||||
@@ -3,6 +3,21 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.22.7](https://github.com/certd/certd/compare/v1.22.6...v1.22.7) (2024-08-04)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
## [1.22.6](https://github.com/certd/certd/compare/v1.22.5...v1.22.6) (2024-08-03)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复在相同的cron时偶尔无法触发定时任务的bug ([680941a](https://github.com/certd/certd/commit/680941af119619006b592e3ab6fb112cb5556a8b))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 流水线支持名称模糊查询 ([59897c4](https://github.com/certd/certd/commit/59897c4ceae992ebe2972ca9e8f9196616ffdfd7))
|
||||
* 优化前置任务输出为空的提示 ([6ed1e18](https://github.com/certd/certd/commit/6ed1e18c7d9c46d964ecc6abc90f3908297b7632))
|
||||
|
||||
## [1.22.5](https://github.com/certd/certd/compare/v1.22.4...v1.22.5) (2024-07-26)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
@@ -1 +1 @@
|
||||
23:14
|
||||
22:30
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@certd/pipeline",
|
||||
"private": false,
|
||||
"version": "1.22.5",
|
||||
"version": "1.22.7",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -10,10 +10,10 @@
|
||||
"build": "tsc --skipLibCheck",
|
||||
"build3": "rollup -c",
|
||||
"build2": "vue-tsc --noEmit && vite build",
|
||||
"preview": "vite preview"
|
||||
"preview": "vite preview",
|
||||
"test": "mocha --loader=ts-node/esm"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"axios": "^1.7.2",
|
||||
"fix-path": "^4.0.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
@@ -28,6 +28,7 @@
|
||||
"@rollup/plugin-terser": "^0.4.3",
|
||||
"@rollup/plugin-typescript": "^11.0.0",
|
||||
"@types/chai": "^4.3.10",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@types/node-forge": "^1.3.2",
|
||||
"@types/uuid": "^9.0.2",
|
||||
|
||||
@@ -213,7 +213,12 @@ export class Executor {
|
||||
if (contextKey != null) {
|
||||
const value = this.runtime.context[contextKey];
|
||||
if (value == null) {
|
||||
currentLogger.warn(`[step init] input ${define.title} is null`);
|
||||
currentLogger.warn(`[step init] input ${define.title} is null,前置任务步骤输出值为空,请按如下步骤排查:`);
|
||||
currentLogger.log(`1、检查前置任务(证书申请任务)是否是配置了成功后跳过,如果是,请改为正常执行`);
|
||||
currentLogger.log(
|
||||
`2、是否曾经删除过前置任务(证书申请任务),然后又重新添加了,如果是,请重新编辑当前任务,重新选择一下前置任务输出的参数(域名证书那一栏)`
|
||||
);
|
||||
currentLogger.log(`3、以上都不是,联系作者吧`);
|
||||
}
|
||||
step.input[key] = value;
|
||||
}
|
||||
@@ -241,18 +246,26 @@ export class Executor {
|
||||
|
||||
await instance.onInstance();
|
||||
await instance.execute();
|
||||
|
||||
//执行结果处理
|
||||
if (instance._result.clearLastStatus) {
|
||||
//是否需要清除所有状态
|
||||
this.lastStatusMap.clear();
|
||||
}
|
||||
//输出到output context
|
||||
//输出上下文变量到output context
|
||||
_.forEach(define.output, (item: any, key: any) => {
|
||||
step.status!.output[key] = instance[key];
|
||||
const stepOutputKey = `step.${step.id}.${key}`;
|
||||
this.runtime.context[stepOutputKey] = instance[key];
|
||||
});
|
||||
|
||||
step.status!.files = instance.getFiles();
|
||||
|
||||
//更新pipeline vars
|
||||
if (Object.keys(instance._result.pipelineVars).length > 0) {
|
||||
// 判断 pipelineVars 有值时更新
|
||||
const vars = this.pipelineContext.getObj("vars");
|
||||
_.merge(vars, instance._result.pipelineVars);
|
||||
await this.pipelineContext.setObj("vars", vars);
|
||||
}
|
||||
}
|
||||
|
||||
async notification(when: NotificationWhen, error?: any) {
|
||||
|
||||
@@ -3,3 +3,4 @@ export * from "./run-history.js";
|
||||
export * from "./context.js";
|
||||
export * from "./storage.js";
|
||||
export * from "./file-store.js";
|
||||
export * from "./license.js";
|
||||
|
||||
15
packages/core/pipeline/src/core/license.spec.ts
Normal file
15
packages/core/pipeline/src/core/license.spec.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { isPlus, verify } from "./license.js";
|
||||
import { equal } from "assert";
|
||||
describe("license", function () {
|
||||
it("#license", async function () {
|
||||
const req = {
|
||||
appKey: "z4nXOeTeSnnpUpnmsV",
|
||||
subjectId: "999",
|
||||
license: "",
|
||||
};
|
||||
const plus = isPlus();
|
||||
equal(plus, false);
|
||||
const res = await verify(req);
|
||||
equal(res, true);
|
||||
});
|
||||
});
|
||||
85
packages/core/pipeline/src/core/license.ts
Normal file
85
packages/core/pipeline/src/core/license.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import { createVerify } from "node:crypto";
|
||||
import { logger } from "../utils/index.js";
|
||||
|
||||
const SecreteKey =
|
||||
"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1JSUJDZ0tDQVFFQXY3TGtMaUp1dGM0NzhTU3RaTExjajVGZXh1YjJwR2NLMGxwa0hwVnlZWjhMY29rRFhuUlAKUGQ5UlJSTVRTaGJsbFl2Mzd4QUhOV1ZIQ0ZsWHkrQklVU001bUlBU1NDQTV0azlJNmpZZ2F4bEFDQm1BY0lGMwozKzBjeGZIYVkrVW9YdVluMkZ6YUt2Ym5GdFZIZ0lkMDg4a3d4clZTZzlCT3BDRVZIR1pxR2I5TWN5MXVHVXhUClFTVENCbmpoTWZlZ0p6cXVPYWVOY0ZPSE5tbmtWRWpLTythbTBPeEhNS1lyS3ZnQnVEbzdoVnFENlBFMUd6V3AKZHdwZUV4QXZDSVJxL2pWTkdRK3FtMkRWOVNJZ3U5bmF4MktmSUtFeU50dUFFS1VpekdqL0VmRFhDM1cxMExhegpKaGNYNGw1SUFZU1o3L3JWVmpGbExWSVl0WDU1T054L1Z3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0K";
|
||||
const appKey = "z4nXOeTeSnnpUpnmsV";
|
||||
export type LicenseVerifyReq = {
|
||||
subjectId: string;
|
||||
license: string;
|
||||
};
|
||||
|
||||
type License = {
|
||||
appKey: string;
|
||||
code: string;
|
||||
subjectId: string;
|
||||
expireTime: number;
|
||||
activeTime: number;
|
||||
duration: number;
|
||||
version: number;
|
||||
secret: string;
|
||||
signature: string;
|
||||
};
|
||||
|
||||
class LicenseHolder {
|
||||
isPlus = false;
|
||||
}
|
||||
const holder = new LicenseHolder();
|
||||
holder.isPlus = false;
|
||||
|
||||
class LicenseVerifier {
|
||||
checked = false;
|
||||
licenseReq?: LicenseVerifyReq = undefined;
|
||||
async reVerify(req: LicenseVerifyReq) {
|
||||
this.checked = false;
|
||||
return await this.verify(req);
|
||||
}
|
||||
|
||||
setPlus(value: boolean) {
|
||||
holder.isPlus = value;
|
||||
return value;
|
||||
}
|
||||
async verify(req: LicenseVerifyReq) {
|
||||
this.licenseReq = req;
|
||||
if (this.checked) {
|
||||
return this.setPlus(false);
|
||||
}
|
||||
const license = req?.license;
|
||||
if (!license) {
|
||||
this.checked = true;
|
||||
return this.setPlus(false);
|
||||
}
|
||||
|
||||
const licenseJson = Buffer.from(Buffer.from(license, "hex").toString(), "base64").toString();
|
||||
const json: License = JSON.parse(licenseJson);
|
||||
if (json.expireTime < Date.now()) {
|
||||
logger.warn("授权已过期");
|
||||
return this.setPlus(false);
|
||||
}
|
||||
const content = `${appKey},${this.licenseReq.subjectId},${json.code},${json.secret},${json.activeTime},${json.duration},${json.expireTime},${json.version}`;
|
||||
const publicKey = Buffer.from(SecreteKey, "base64").toString();
|
||||
const res = this.verifySignature(content, json.signature, publicKey);
|
||||
this.checked = true;
|
||||
if (!res) {
|
||||
logger.warn("授权校验失败");
|
||||
return this.setPlus(false);
|
||||
}
|
||||
return this.setPlus(true);
|
||||
}
|
||||
|
||||
verifySignature(content: string, signature: any, publicKey: string) {
|
||||
const verify = createVerify("RSA-SHA256");
|
||||
verify.update(content);
|
||||
return verify.verify(publicKey, signature, "base64");
|
||||
}
|
||||
}
|
||||
|
||||
const verifier = new LicenseVerifier();
|
||||
|
||||
export function isPlus() {
|
||||
return holder.isPlus;
|
||||
}
|
||||
|
||||
export async function verify(req: LicenseVerifyReq) {
|
||||
return await verifier.reVerify(req);
|
||||
}
|
||||
@@ -51,6 +51,7 @@ export type ITaskPlugin = {
|
||||
export type TaskResult = {
|
||||
clearLastStatus?: boolean;
|
||||
files?: FileItem[];
|
||||
pipelineVars: Record<string, any>;
|
||||
};
|
||||
export type TaskInstanceContext = {
|
||||
pipeline: Pipeline;
|
||||
@@ -66,7 +67,7 @@ export type TaskInstanceContext = {
|
||||
};
|
||||
|
||||
export abstract class AbstractTaskPlugin implements ITaskPlugin {
|
||||
_result: TaskResult = { clearLastStatus: false, files: [] };
|
||||
_result: TaskResult = { clearLastStatus: false, files: [], pipelineVars: {} };
|
||||
ctx!: TaskInstanceContext;
|
||||
clearLastStatus() {
|
||||
this._result.clearLastStatus = true;
|
||||
@@ -83,12 +84,6 @@ export abstract class AbstractTaskPlugin implements ITaskPlugin {
|
||||
randomFileId() {
|
||||
return Math.random().toString(36).substring(2, 9);
|
||||
}
|
||||
linkFile(file: FileItem) {
|
||||
this._result.files?.push({
|
||||
...file,
|
||||
id: this.randomFileId(),
|
||||
});
|
||||
}
|
||||
saveFile(filename: string, file: Buffer) {
|
||||
const filePath = this.ctx.fileStore.writeFile(filename, file);
|
||||
logger.info(`saveFile:${filePath}`);
|
||||
|
||||
@@ -5,4 +5,3 @@ export default function (timeout: number) {
|
||||
}, timeout);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { expect } from "chai";
|
||||
import "mocha";
|
||||
import { EchoPlugin } from "./echo-plugin";
|
||||
import { EchoPlugin } from "./echo-plugin.js";
|
||||
describe("task_plugin", function () {
|
||||
it("#taskplugin", function () {
|
||||
console.log("before new plugin");
|
||||
|
||||
1
packages/core/pipeline/test/pipeline/.gitignore
vendored
Normal file
1
packages/core/pipeline/test/pipeline/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
license.*
|
||||
@@ -34,6 +34,7 @@
|
||||
"exclude": [
|
||||
"*.js",
|
||||
"*.ts",
|
||||
"*.spec.ts",
|
||||
"dist",
|
||||
"node_modules",
|
||||
"test"
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.22.7](https://github.com/certd/certd/compare/v1.22.6...v1.22.7) (2024-08-04)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
## [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/lib-k8s
|
||||
|
||||
## [1.22.5](https://github.com/certd/certd/compare/v1.22.4...v1.22.5) (2024-07-26)
|
||||
|
||||
**Note:** Version bump only for package @certd/lib-k8s
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@certd/lib-k8s",
|
||||
"private": false,
|
||||
"version": "1.22.5",
|
||||
"version": "1.22.7",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -17,7 +17,7 @@
|
||||
"shelljs": "^0.8.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/pipeline": "^1.22.5",
|
||||
"@certd/pipeline": "^1.22.7",
|
||||
"@rollup/plugin-commonjs": "^23.0.4",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
|
||||
@@ -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.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
|
||||
|
||||
## [1.22.3](https://github.com/certd/certd/compare/v1.22.2...v1.22.3) (2024-07-25)
|
||||
|
||||
**Note:** Version bump only for package @certd/midway-flyway-js
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/midway-flyway-js",
|
||||
"version": "1.22.3",
|
||||
"version": "1.22.6",
|
||||
"description": "midway with flyway, sql upgrade way ",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
|
||||
@@ -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.22.7](https://github.com/certd/certd/compare/v1.22.6...v1.22.7) (2024-08-04)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-cert
|
||||
|
||||
## [1.22.6](https://github.com/certd/certd/compare/v1.22.5...v1.22.6) (2024-08-03)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 流水线支持名称模糊查询 ([59897c4](https://github.com/certd/certd/commit/59897c4ceae992ebe2972ca9e8f9196616ffdfd7))
|
||||
|
||||
## [1.22.5](https://github.com/certd/certd/compare/v1.22.4...v1.22.5) (2024-07-26)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-cert
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@certd/plugin-cert",
|
||||
"private": false,
|
||||
"version": "1.22.5",
|
||||
"version": "1.22.7",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -13,8 +13,8 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/acme-client": "^1.22.4",
|
||||
"@certd/pipeline": "^1.22.5",
|
||||
"@certd/acme-client": "^1.22.6",
|
||||
"@certd/pipeline": "^1.22.7",
|
||||
"jszip": "^3.10.1",
|
||||
"node-forge": "^0.10.0",
|
||||
"psl": "^1.9.0"
|
||||
|
||||
@@ -138,6 +138,8 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
|
||||
const cert: CertInfo = certReader.toCertInfo();
|
||||
this.cert = cert;
|
||||
|
||||
this._result.pipelineVars.certExpiresTime = dayjs(certReader.detail.validity.notAfter).valueOf();
|
||||
|
||||
if (isNew) {
|
||||
const applyTime = dayjs(certReader.detail.validity.notBefore).format("YYYYMMDD_HHmmss");
|
||||
await this.zipCert(cert, applyTime);
|
||||
|
||||
@@ -3,6 +3,20 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.22.7](https://github.com/certd/certd/compare/v1.22.6...v1.22.7) (2024-08-04)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-client
|
||||
|
||||
## [1.22.6](https://github.com/certd/certd/compare/v1.22.5...v1.22.6) (2024-08-03)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复在相同的cron时偶尔无法触发定时任务的bug ([680941a](https://github.com/certd/certd/commit/680941af119619006b592e3ab6fb112cb5556a8b))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 流水线支持名称模糊查询 ([59897c4](https://github.com/certd/certd/commit/59897c4ceae992ebe2972ca9e8f9196616ffdfd7))
|
||||
|
||||
## [1.22.5](https://github.com/certd/certd/compare/v1.22.4...v1.22.5) (2024-07-26)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-client
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/ui-client",
|
||||
"version": "1.22.5",
|
||||
"version": "1.22.7",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite --open",
|
||||
@@ -57,7 +57,7 @@
|
||||
"vuedraggable": "^2.24.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/pipeline": "^1.22.5",
|
||||
"@certd/pipeline": "^1.22.7",
|
||||
"@rollup/plugin-commonjs": "^25.0.7",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@types/chai": "^4.3.12",
|
||||
|
||||
@@ -61,7 +61,7 @@ function install(app: App, options: any = {}) {
|
||||
},
|
||||
size: "small",
|
||||
pagination: false,
|
||||
onResizeColumn: (w: number, col: any) => {
|
||||
onResizeColumn: (w: number | string, col: any) => {
|
||||
if (crudBinding.value?.table?.columnsMap && crudBinding.value?.table?.columnsMap[col.key]) {
|
||||
crudBinding.value.table.columnsMap[col.key].width = w;
|
||||
}
|
||||
@@ -336,6 +336,23 @@ function install(app: App, options: any = {}) {
|
||||
return columnProps;
|
||||
}
|
||||
});
|
||||
|
||||
registerMergeColumnPlugin({
|
||||
name: "resize-column-plugin",
|
||||
order: 2,
|
||||
handle: (columnProps: ColumnCompositionProps) => {
|
||||
if (!columnProps.column) {
|
||||
columnProps.column = {};
|
||||
}
|
||||
columnProps.column.resizable = true;
|
||||
if (!columnProps.column.width) {
|
||||
columnProps.column.width = 100;
|
||||
} else if (typeof columnProps.column?.width === "string" && columnProps.column.width.indexOf("px") > -1) {
|
||||
columnProps.column.width = parseInt(columnProps.column.width.replace("px", ""));
|
||||
}
|
||||
return columnProps;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
@@ -6,12 +6,10 @@ export function useReference(form: any) {
|
||||
return;
|
||||
}
|
||||
for (const reference of form.reference) {
|
||||
debugger;
|
||||
_.set(
|
||||
form,
|
||||
reference.dest,
|
||||
compute<any>((scope) => {
|
||||
debugger;
|
||||
return _.get(scope, reference.src);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -8,6 +8,7 @@ import { nanoid } from "nanoid";
|
||||
import { message, Modal } from "ant-design-vue";
|
||||
import { env } from "/@/utils/util.env";
|
||||
import { useUserStore } from "/@/store/modules/user";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const router = useRouter();
|
||||
@@ -125,6 +126,8 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp
|
||||
}
|
||||
},
|
||||
rowHandle: {
|
||||
minWidth: 200,
|
||||
fixed: "right",
|
||||
buttons: {
|
||||
view: {
|
||||
click({ row }) {
|
||||
@@ -200,6 +203,7 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp
|
||||
},
|
||||
column: {
|
||||
width: 300,
|
||||
sorter: true,
|
||||
component: {
|
||||
on: {
|
||||
// 注意:必须要on前缀
|
||||
@@ -210,11 +214,35 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp
|
||||
}
|
||||
}
|
||||
},
|
||||
lastVars: {
|
||||
title: "到期剩余",
|
||||
type: "number",
|
||||
form: {
|
||||
show: false
|
||||
},
|
||||
column: {
|
||||
cellRender({ row }) {
|
||||
if (!row.lastVars?.certExpiresTime) {
|
||||
return "-";
|
||||
}
|
||||
const leftDays = dayjs(row.lastVars.certExpiresTime).diff(dayjs(), "day");
|
||||
const color = leftDays < 20 ? "red" : "#389e0d";
|
||||
const percent = (leftDays / 90) * 100;
|
||||
return <a-progress percent={percent} strokeColor={color} format={(percent: number) => `${leftDays} 天`} />;
|
||||
},
|
||||
width: 110
|
||||
}
|
||||
},
|
||||
lastHistoryTime: {
|
||||
title: "最后运行",
|
||||
type: "datetime",
|
||||
form: {
|
||||
show: false
|
||||
},
|
||||
column: {
|
||||
sorter: true,
|
||||
width: 120,
|
||||
align: "center"
|
||||
}
|
||||
},
|
||||
status: {
|
||||
@@ -225,6 +253,11 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp
|
||||
}),
|
||||
form: {
|
||||
show: false
|
||||
},
|
||||
column: {
|
||||
sorter: true,
|
||||
width: 80,
|
||||
align: "center"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -242,6 +275,9 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp
|
||||
show: false
|
||||
},
|
||||
column: {
|
||||
sorter: true,
|
||||
width: 80,
|
||||
align: "center",
|
||||
component: {
|
||||
name: "fs-dict-switch",
|
||||
vModel: "checked"
|
||||
@@ -254,12 +290,25 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
keepHistoryCount: {
|
||||
title: "历史记录保持数",
|
||||
type: "number",
|
||||
form: {
|
||||
value: 30,
|
||||
helper: "历史记录保持条数,多余的会被删除"
|
||||
},
|
||||
column: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
order: {
|
||||
title: "排序号",
|
||||
type: "number",
|
||||
column: {
|
||||
sorter: true,
|
||||
align: "center",
|
||||
width: 80
|
||||
}
|
||||
},
|
||||
createTime: {
|
||||
@@ -267,6 +316,11 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp
|
||||
type: "datetime",
|
||||
form: {
|
||||
show: false
|
||||
},
|
||||
column: {
|
||||
sorter: true,
|
||||
width: 125,
|
||||
align: "center"
|
||||
}
|
||||
},
|
||||
updateTime: {
|
||||
@@ -274,6 +328,9 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp
|
||||
type: "datetime",
|
||||
form: {
|
||||
show: false
|
||||
},
|
||||
column: {
|
||||
show: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,24 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.22.7](https://github.com/certd/certd/compare/v1.22.6...v1.22.7) (2024-08-04)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复保存配置报id不能为空的bug ([367f807](https://github.com/certd/certd/commit/367f80731396003416665c22853dfbc09c2c03a0))
|
||||
|
||||
## [1.22.6](https://github.com/certd/certd/compare/v1.22.5...v1.22.6) (2024-08-03)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复在相同的cron时偶尔无法触发定时任务的bug ([680941a](https://github.com/certd/certd/commit/680941af119619006b592e3ab6fb112cb5556a8b))
|
||||
* 修复pg下pipeline title 类型问题 ([a9717b9](https://github.com/certd/certd/commit/a9717b9a0df7b5a64d4fe03314fecad4f59774cc))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* 流水线支持名称模糊查询 ([59897c4](https://github.com/certd/certd/commit/59897c4ceae992ebe2972ca9e8f9196616ffdfd7))
|
||||
* 腾讯云clb支持更多大区选择 ([e4f4570](https://github.com/certd/certd/commit/e4f4570b29f26c60f1ee9660a4c507cbeaba3d7e))
|
||||
|
||||
## [1.22.5](https://github.com/certd/certd/compare/v1.22.4...v1.22.5) (2024-07-26)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -2,4 +2,4 @@ INSERT INTO sys_settings (key, title, setting,access) VALUES ('sys.install','安
|
||||
|
||||
ALTER TABLE sys_user ADD COLUMN password_version integer DEFAULT 1;
|
||||
ALTER TABLE sys_user ADD COLUMN password_salt varchar(36);
|
||||
ALTER TABLE sys_user ALTER COLUMN password varchar(100);
|
||||
alter table sys_user alter column password type varchar(100) using password::varchar(100);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
alter table pi_pipeline alter column title type varchar(100) using title::varchar(100);
|
||||
alter table pi_pipeline alter column content type text using content::text;
|
||||
alter table pi_storage alter column value type text using value::text;
|
||||
|
||||
alter table pi_pipeline add "order" integer default 0;
|
||||
@@ -0,0 +1,3 @@
|
||||
alter table pi_pipeline add COLUMN "order" integer default 0;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/ui-server",
|
||||
"version": "1.22.5",
|
||||
"version": "1.22.7",
|
||||
"description": "fast-server base midway",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
@@ -21,12 +21,12 @@
|
||||
"@alicloud/cs20151215": "^3.0.3",
|
||||
"@alicloud/openapi-client": "^0.4.0",
|
||||
"@alicloud/pop-core": "^1.7.10",
|
||||
"@certd/acme-client": "^1.22.4",
|
||||
"@certd/acme-client": "^1.22.6",
|
||||
"@certd/lib-huawei": "^1.22.1",
|
||||
"@certd/lib-k8s": "^1.22.5",
|
||||
"@certd/midway-flyway-js": "^1.22.3",
|
||||
"@certd/pipeline": "^1.22.5",
|
||||
"@certd/plugin-cert": "^1.22.5",
|
||||
"@certd/lib-k8s": "^1.22.7",
|
||||
"@certd/midway-flyway-js": "^1.22.6",
|
||||
"@certd/pipeline": "^1.22.7",
|
||||
"@certd/plugin-cert": "^1.22.7",
|
||||
"@koa/cors": "^3.4.3",
|
||||
"@midwayjs/bootstrap": "^3.16.2",
|
||||
"@midwayjs/cache": "^3.14.0",
|
||||
@@ -42,6 +42,7 @@
|
||||
"bcryptjs": "^2.4.3",
|
||||
"better-sqlite3": "^11.1.2",
|
||||
"cache-manager": "^3.6.3",
|
||||
"cron-parser": "^4.9.0",
|
||||
"dayjs": "^1.11.7",
|
||||
"glob": "^10.4.5",
|
||||
"https-proxy-agent": "^7.0.4",
|
||||
@@ -56,7 +57,6 @@
|
||||
"md5": "^2.3.0",
|
||||
"mwtsc": "^1.4.0",
|
||||
"nanoid": "^4.0.0",
|
||||
"node-cron": "^3.0.2",
|
||||
"nodemailer": "^6.9.3",
|
||||
"pg": "^8.12.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
|
||||
@@ -118,10 +118,9 @@ export abstract class BaseService<T> {
|
||||
}
|
||||
const qb = this.getRepository().createQueryBuilder('main');
|
||||
if (order && order.prop) {
|
||||
qb.orderBy('main.' + order.prop, order.asc ? 'ASC' : 'DESC');
|
||||
} else {
|
||||
qb.orderBy('id', 'DESC');
|
||||
qb.addOrderBy('main.' + order.prop, order.asc ? 'ASC' : 'DESC');
|
||||
}
|
||||
qb.addOrderBy('id', 'DESC');
|
||||
qb.offset(page.offset).limit(page.limit);
|
||||
//根据bean query
|
||||
if (query) {
|
||||
|
||||
@@ -9,12 +9,7 @@ export abstract class CrudController<T> extends BaseController {
|
||||
@Body(ALL)
|
||||
body
|
||||
) {
|
||||
const pageRet = await this.getService().page(
|
||||
body?.query,
|
||||
body?.page,
|
||||
body?.sort,
|
||||
null
|
||||
);
|
||||
const pageRet = await this.getService().page(body?.query, body?.page, body?.sort, null);
|
||||
return this.ok(pageRet);
|
||||
}
|
||||
|
||||
@@ -54,6 +49,7 @@ export abstract class CrudController<T> extends BaseController {
|
||||
await this.getService().update(bean);
|
||||
return this.ok(null);
|
||||
}
|
||||
|
||||
@Post('/delete')
|
||||
async delete(
|
||||
@Query('id')
|
||||
|
||||
@@ -3,7 +3,8 @@ import { logger } from '../../utils/logger.js';
|
||||
import { UserService } from '../authority/service/user-service.js';
|
||||
import { SysSettingsService } from '../system/service/sys-settings-service.js';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { SysInstallInfo } from '../system/service/models.js';
|
||||
import { SysInstallInfo, SysLicenseInfo } from '../system/service/models.js';
|
||||
import { verify } from '@certd/pipeline';
|
||||
|
||||
export type InstallInfo = {
|
||||
installTime: number;
|
||||
@@ -32,6 +33,14 @@ export class AutoInitSite {
|
||||
await this.sysSettingsService.saveSetting(installInfo);
|
||||
}
|
||||
|
||||
// 授权许可
|
||||
const licenseInfo: SysLicenseInfo = await this.sysSettingsService.getSetting(SysLicenseInfo);
|
||||
const req = {
|
||||
subjectId: installInfo.siteId,
|
||||
license: licenseInfo.license,
|
||||
};
|
||||
await verify(req);
|
||||
|
||||
logger.info('初始化站点完成');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,7 @@ export class BasicSettingsController extends BaseController {
|
||||
|
||||
@Get('/public', { summary: Constants.per.guest })
|
||||
public async getSysPublic() {
|
||||
const settings = await this.sysSettingsService.getSetting(
|
||||
SysPublicSettings
|
||||
);
|
||||
const settings = await this.sysSettingsService.getSetting(SysPublicSettings);
|
||||
return this.ok(settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,19 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
@Post('/page', { summary: Constants.per.authOnly })
|
||||
async page(@Body(ALL) body) {
|
||||
body.query.userId = this.ctx.user.id;
|
||||
|
||||
const title = body.query.title;
|
||||
delete body.query.title;
|
||||
|
||||
const buildQuery = qb => {
|
||||
qb.where({});
|
||||
if (title) {
|
||||
qb.where('title like :title', { title: `%${title}%` });
|
||||
}
|
||||
};
|
||||
if (!body.sort || !body.sort?.prop) {
|
||||
body.sort = { prop: 'order', asc: false };
|
||||
}
|
||||
|
||||
return super.page({ ...body, buildQuery });
|
||||
}
|
||||
|
||||
@@ -48,7 +58,6 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
await this.service.checkUserId(bean.id, this.ctx.user.id);
|
||||
}
|
||||
await this.service.save(bean);
|
||||
await this.service.registerTriggerById(bean.id);
|
||||
return this.ok(bean.id);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ export class PipelineEntity {
|
||||
userId: number;
|
||||
|
||||
@Column({ name: 'title', comment: '标题' })
|
||||
title: number;
|
||||
title: string;
|
||||
|
||||
@Column({ comment: '配置', length: 40960 })
|
||||
content: string;
|
||||
@@ -37,6 +37,16 @@ export class PipelineEntity {
|
||||
})
|
||||
lastHistoryTime: number;
|
||||
|
||||
// 变量
|
||||
lastVars: any;
|
||||
|
||||
@Column({
|
||||
name: 'order',
|
||||
comment: '排序',
|
||||
nullable: true,
|
||||
})
|
||||
order: number;
|
||||
|
||||
@Column({
|
||||
name: 'create_time',
|
||||
comment: '创建时间',
|
||||
|
||||
@@ -12,7 +12,7 @@ export class DbStorage implements IStorage {
|
||||
this.storageService = storageService;
|
||||
}
|
||||
|
||||
remove(scope: string, namespace: string, version: string, key: string): Promise<void> {
|
||||
async remove(scope: string, namespace: string, version: string, key: string): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,23 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
return this.repository;
|
||||
}
|
||||
|
||||
async update(entity) {
|
||||
await super.update(entity);
|
||||
async page(query: any, page: { offset: number; limit: number }, order: any, buildQuery: any) {
|
||||
const result = await super.page(query, page, order, buildQuery);
|
||||
const pipelineIds: number[] = [];
|
||||
const recordMap = {};
|
||||
for (const record of result.records) {
|
||||
pipelineIds.push(record.id);
|
||||
recordMap[record.id] = record;
|
||||
}
|
||||
const vars = await this.storageService.findPipelineVars(pipelineIds);
|
||||
for (const varEntity of vars) {
|
||||
const record = recordMap[varEntity.namespace];
|
||||
if (record) {
|
||||
const value = JSON.parse(varEntity.value);
|
||||
record.lastVars = value.value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public async registerTriggerById(pipelineId) {
|
||||
@@ -71,10 +86,18 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
return new PipelineDetail(pipeline);
|
||||
}
|
||||
|
||||
async update(bean: PipelineEntity) {
|
||||
await this.clearTriggers(bean.id);
|
||||
await super.update(bean);
|
||||
await this.registerTriggerById(bean.id);
|
||||
}
|
||||
|
||||
async save(bean: PipelineEntity) {
|
||||
await this.clearTriggers(bean.id);
|
||||
const pipeline = JSON.parse(bean.content);
|
||||
bean.title = pipeline.title;
|
||||
await this.addOrUpdate(bean);
|
||||
await this.registerTriggerById(bean.id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +143,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info('定时器数量:', this.cron.getListSize());
|
||||
logger.info('定时器数量:', this.cron.getTaskSize());
|
||||
}
|
||||
|
||||
async registerTriggers(pipeline?: Pipeline, immediateTriggerOnce = false) {
|
||||
@@ -153,6 +176,17 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
}
|
||||
|
||||
async delete(id: number) {
|
||||
await this.clearTriggers(id);
|
||||
//TODO 删除storage
|
||||
// const storage = new DbStorage(pipeline.userId, this.storageService);
|
||||
// await storage.remove(pipeline.id);
|
||||
await super.delete([id]);
|
||||
}
|
||||
|
||||
async clearTriggers(id: number) {
|
||||
if (id == null) {
|
||||
return;
|
||||
}
|
||||
const pipeline = await this.info(id);
|
||||
if (!pipeline) {
|
||||
return;
|
||||
@@ -163,7 +197,6 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
this.removeCron(id, trigger);
|
||||
}
|
||||
}
|
||||
await super.delete([id]);
|
||||
}
|
||||
|
||||
removeCron(pipelineId, trigger) {
|
||||
@@ -176,6 +209,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
if (cron == null) {
|
||||
return;
|
||||
}
|
||||
cron = cron.trim();
|
||||
if (cron.startsWith('*')) {
|
||||
cron = '0' + cron.substring(1, cron.length);
|
||||
}
|
||||
@@ -183,7 +217,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
this.cron.remove(name);
|
||||
this.cron.register({
|
||||
name,
|
||||
cron: cron,
|
||||
cron,
|
||||
job: async () => {
|
||||
logger.info('定时任务触发:', pipelineId, trigger.id);
|
||||
try {
|
||||
@@ -193,11 +227,12 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
}
|
||||
},
|
||||
});
|
||||
logger.info('当前定时器数量:', this.cron.getListSize());
|
||||
logger.info('当前定时器数量:', this.cron.getTaskSize());
|
||||
}
|
||||
|
||||
async run(id: number, triggerId: string) {
|
||||
const entity: PipelineEntity = await this.info(id);
|
||||
|
||||
const pipeline = JSON.parse(entity.content);
|
||||
|
||||
if (!pipeline.stages || pipeline.stages.length === 0) {
|
||||
@@ -209,9 +244,16 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (triggerType === 'timer') {
|
||||
if (entity.disabled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const onChanged = async (history: RunHistory) => {
|
||||
//保存执行历史
|
||||
try {
|
||||
logger.info('保存执行历史:', history.id);
|
||||
await this.saveHistory(history);
|
||||
} catch (e) {
|
||||
const pipelineEntity = new PipelineEntity();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { In, Repository } from 'typeorm';
|
||||
import { BaseService } from '../../../basic/base-service.js';
|
||||
import { StorageEntity } from '../entity/storage.js';
|
||||
|
||||
@@ -41,4 +41,14 @@ export class StorageService extends BaseService<StorageEntity> {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
async findPipelineVars(pipelineIds: number[]) {
|
||||
return await this.repository.find({
|
||||
where: {
|
||||
scope: 'pipeline',
|
||||
namespace: In(pipelineIds),
|
||||
key: 'vars',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import cron from 'node-cron';
|
||||
export type CronTask = {
|
||||
import parser from 'cron-parser';
|
||||
import { ILogger } from '@certd/pipeline';
|
||||
|
||||
export type CronTaskReq = {
|
||||
/**
|
||||
* 为空则为单次执行
|
||||
*/
|
||||
@@ -7,39 +9,90 @@ export type CronTask = {
|
||||
job: () => Promise<void>;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export class CronTask {
|
||||
logger: ILogger;
|
||||
cron: string;
|
||||
job: () => Promise<void>;
|
||||
name: string;
|
||||
stoped = false;
|
||||
|
||||
timeoutId: any;
|
||||
|
||||
constructor(req: CronTaskReq, logger: ILogger) {
|
||||
this.cron = req.cron;
|
||||
this.job = req.job;
|
||||
this.name = req.name;
|
||||
this.logger = logger;
|
||||
this.start();
|
||||
}
|
||||
|
||||
start() {
|
||||
if (!this.cron) {
|
||||
return;
|
||||
}
|
||||
if (this.stoped) {
|
||||
return;
|
||||
}
|
||||
const interval = parser.parseExpression(this.cron);
|
||||
const next = interval.next().getTime();
|
||||
const now = Date.now();
|
||||
const delay = next - now;
|
||||
this.timeoutId = setTimeout(async () => {
|
||||
try {
|
||||
if (this.stoped) {
|
||||
return;
|
||||
}
|
||||
await this.job();
|
||||
} catch (e) {
|
||||
this.logger.error(`[cron] job error : [${this.name}]`, e);
|
||||
}
|
||||
this.start();
|
||||
}, delay);
|
||||
}
|
||||
|
||||
stop() {
|
||||
this.stoped = true;
|
||||
clearTimeout(this.timeoutId);
|
||||
}
|
||||
}
|
||||
export class Cron {
|
||||
logger;
|
||||
logger: ILogger;
|
||||
immediateTriggerOnce: boolean;
|
||||
constructor(opts) {
|
||||
|
||||
bucket: Record<string, CronTask> = {};
|
||||
|
||||
constructor(opts: any) {
|
||||
this.logger = opts.logger;
|
||||
this.immediateTriggerOnce = opts.immediateTriggerOnce;
|
||||
}
|
||||
|
||||
register(task: CronTask) {
|
||||
if (!task.cron) {
|
||||
this.logger.info(`[cron] register once : [${task.name}]`);
|
||||
task.job();
|
||||
register(req: CronTaskReq) {
|
||||
if (!req.cron) {
|
||||
this.logger.info(`[cron] register once : [${req.name}]`);
|
||||
req.job().catch(e => {
|
||||
this.logger.error(`job execute error : [${req.name}]`, e);
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.logger.info(`[cron] register cron : [${task.name}] ,${task.cron}`);
|
||||
cron.schedule(task.cron, task.job, {
|
||||
name: task.name,
|
||||
});
|
||||
this.logger.info('当前定时任务数量:', this.getListSize());
|
||||
this.logger.info(`[cron] register cron : [${req.name}] ,${req.cron}`);
|
||||
|
||||
const task = new CronTask(req, this.logger);
|
||||
this.bucket[task.name] = task;
|
||||
this.logger.info('当前定时任务数量:', this.getTaskSize());
|
||||
}
|
||||
|
||||
remove(taskName: string) {
|
||||
this.logger.info(`[cron] remove : [${taskName}]`);
|
||||
const tasks = cron.getTasks() as Map<any, any>;
|
||||
const node = tasks.get(taskName);
|
||||
if (node) {
|
||||
node.stop();
|
||||
tasks.delete(taskName);
|
||||
const task = this.bucket[taskName];
|
||||
if (task) {
|
||||
task.stop();
|
||||
delete this.bucket[taskName];
|
||||
}
|
||||
}
|
||||
|
||||
getListSize() {
|
||||
const tasks = cron.getTasks();
|
||||
return tasks.size;
|
||||
getTaskSize() {
|
||||
const tasks = Object.keys(this.bucket);
|
||||
return tasks.length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,3 +27,10 @@ export class SysInstallInfo extends BaseSettings {
|
||||
installTime: number;
|
||||
siteId?: string;
|
||||
}
|
||||
|
||||
export class SysLicenseInfo extends BaseSettings {
|
||||
static __title__ = '授权许可信息';
|
||||
static __key__ = 'sys.license';
|
||||
static __access__ = 'private';
|
||||
license?: string;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ export class UploadCertToAliyun extends AbstractTaskPlugin {
|
||||
default: 'cn-hangzhou',
|
||||
component: {
|
||||
name: 'a-select',
|
||||
mode: 'tags',
|
||||
vModel: 'value',
|
||||
options: ZoneOptions,
|
||||
},
|
||||
|
||||
@@ -29,6 +29,7 @@ export class CloudflareDeployToCDNPlugin extends AbstractTaskPlugin {
|
||||
component: {
|
||||
//前端组件配置,具体配置见组件文档 https://www.antdv.com/components/select-cn
|
||||
name: 'a-select',
|
||||
mode: 'tags',
|
||||
options: [
|
||||
{ value: '1', label: '选项1' },
|
||||
{ value: '2', label: '选项2' },
|
||||
|
||||
@@ -29,6 +29,7 @@ export class DemoTestPlugin extends AbstractTaskPlugin {
|
||||
component: {
|
||||
//前端组件配置,具体配置见组件文档 https://www.antdv.com/components/select-cn
|
||||
name: 'a-select',
|
||||
mode: 'tags',
|
||||
options: [
|
||||
{ value: '1', label: '选项1' },
|
||||
{ value: '2', label: '选项2' },
|
||||
|
||||
@@ -11,6 +11,7 @@ export class DnspodAccess {
|
||||
component: {
|
||||
placeholder: 'endpoint',
|
||||
name: 'a-select',
|
||||
mode: 'tags',
|
||||
vModel: 'value',
|
||||
options: [
|
||||
{ value: 'https://dnsapi.cn', label: '中国站' },
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { Autowire, HttpClient, ILogger } from '@certd/pipeline';
|
||||
import {
|
||||
AbstractDnsProvider,
|
||||
CreateRecordOptions,
|
||||
IsDnsProvider,
|
||||
RemoveRecordOptions,
|
||||
} from '@certd/plugin-cert';
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import * as _ from 'lodash-es';
|
||||
import { DnspodAccess } from '../access/index.js';
|
||||
|
||||
@@ -50,9 +45,7 @@ export class DnspodDnsProvider extends AbstractDnsProvider {
|
||||
if (!ret || !ret.status) {
|
||||
const code = ret.status.code;
|
||||
if (code !== '1' || !successCodes.includes(code)) {
|
||||
throw new Error(
|
||||
'请求失败:' + ret.status.message + ',api=' + config.url
|
||||
);
|
||||
throw new Error('请求失败:' + ret.status.message + ',api=' + config.url);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -87,12 +80,7 @@ export class DnspodDnsProvider extends AbstractDnsProvider {
|
||||
},
|
||||
['104']
|
||||
); // 104错误码为记录已存在,无需再次添加
|
||||
this.logger.info(
|
||||
'添加域名解析成功:',
|
||||
fullRecord,
|
||||
value,
|
||||
JSON.stringify(ret.record)
|
||||
);
|
||||
this.logger.info('添加域名解析成功:', fullRecord, value, JSON.stringify(ret.record));
|
||||
return ret.record;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,28 @@ export class DeployToClbPlugin extends AbstractTaskPlugin {
|
||||
default: 'ap-guangzhou',
|
||||
component: {
|
||||
name: 'a-select',
|
||||
options: [{ value: 'ap-guangzhou' }],
|
||||
mode: 'tags',
|
||||
options: [
|
||||
{ value: 'ap-guangzhou' },
|
||||
{ value: 'ap-beijing' },
|
||||
{ value: 'ap-chengdu' },
|
||||
{ value: 'ap-chongqing' },
|
||||
{ value: 'ap-hongkong' },
|
||||
{ value: 'ap-jakarta' },
|
||||
{ value: 'ap-mumbai' },
|
||||
{ value: 'ap-nanjing' },
|
||||
{ value: 'ap-seoul' },
|
||||
{ value: 'ap-shanghai' },
|
||||
{ value: 'ap-shanghai-fsi' },
|
||||
{ value: 'ap-shenzhen-fsi' },
|
||||
{ value: 'ap-singapore' },
|
||||
{ value: 'ap-tokyo' },
|
||||
{ value: 'eu-frankfurt' },
|
||||
{ value: 'na-ashburn' },
|
||||
{ value: 'na-siliconvalley' },
|
||||
{ value: 'na-toronto' },
|
||||
{ value: 'sa-saopaulo' },
|
||||
],
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user