Compare commits

...

96 Commits

Author SHA1 Message Date
xiaojunnuo
d8b3d7a6e0 v1.22.1 2024-07-21 03:11:54 +08:00
xiaojunnuo
b8f072909b build: prepare to build 2024-07-21 03:10:14 +08:00
xiaojunnuo
fa48f2b2f0 build: prepare to build 2024-07-21 03:07:32 +08:00
xiaojunnuo
019a1fe24e chore: 2024-07-21 03:02:13 +08:00
xiaojunnuo
427620d34f perf: 创建证书任务增加定时任务和邮件通知输入 2024-07-21 02:59:02 +08:00
xiaojunnuo
a5a0c1f6e7 perf: 支持配置启动后自动触发一次任务 2024-07-21 02:32:03 +08:00
xiaojunnuo
affef13037 perf: 创建证书任务可以选择lege插件 2024-07-21 02:26:03 +08:00
xiaojunnuo
4afbf20c1a chore: 重构image build 2024-07-20 19:38:15 +08:00
xiaojunnuo
0ef7b036dd chore: 1 2024-07-20 19:27:07 +08:00
xiaojunnuo
17ef7b8b9e chore: 1 2024-07-20 19:25:54 +08:00
xiaojunnuo
15eba52fad chore: 1 2024-07-20 19:25:45 +08:00
xiaojunnuo
f2d894b036 chore: 1 2024-07-20 18:39:51 +08:00
xiaojunnuo
d9da27710e chore: 1 2024-07-20 18:33:11 +08:00
xiaojunnuo
981bff70c3 chore: 1 2024-07-20 18:28:19 +08:00
xiaojunnuo
bb30d6e02f chore: 1 2024-07-20 18:18:34 +08:00
xiaojunnuo
b09ccda54d chore: 1 2024-07-20 18:17:48 +08:00
xiaojunnuo
a5de8d79ec chore: 1 2024-07-20 18:11:56 +08:00
xiaojunnuo
a092a1e843 chore: 1 2024-07-20 18:11:38 +08:00
xiaojunnuo
1c6740feff chore: sqlite换成better-sqlite 2024-07-20 18:07:32 +08:00
xiaojunnuo
79c6e05e02 chore: sqlite换成better-sqlite 2024-07-20 18:04:07 +08:00
xiaojunnuo
31e2085c16 chore: 1 2024-07-20 17:53:19 +08:00
xiaojunnuo
64fda2f1a0 chore: 1 2024-07-20 17:35:07 +08:00
xiaojunnuo
a674719a8b chore: 1 2024-07-20 17:27:12 +08:00
xiaojunnuo
2f7ef0620b chore: 1 2024-07-20 14:27:41 +08:00
xiaojunnuo
153e98b593 chore: 1 2024-07-20 14:26:01 +08:00
xiaojunnuo
d62ea41671 chore: 1 2024-07-20 10:17:38 +08:00
xiaojunnuo
8fcd9813d3 chore: 1 2024-07-20 10:11:05 +08:00
xiaojunnuo
dcbf8c85dd chore: 1 2024-07-20 10:09:18 +08:00
xiaojunnuo
ea0eafdb16 chore: 1 2024-07-20 10:05:39 +08:00
xiaojunnuo
eda89a057a chore: 1 2024-07-20 09:22:20 +08:00
xiaojunnuo
21e6eef1d3 chore: mv libs 2024-07-19 18:08:51 +08:00
xiaojunnuo
54a27c1840 chore: mv libs 2024-07-19 17:22:54 +08:00
xiaojunnuo
a3be0a1618 chore: 1 2024-07-19 16:01:55 +08:00
xiaojunnuo
8e19e44f4c chore: 1 2024-07-19 15:44:10 +08:00
xiaojunnuo
e5d93bd114 chore: 1 2024-07-19 15:41:36 +08:00
xiaojunnuo
47fe3d5826 v1.22.0 2024-07-19 15:28:41 +08:00
xiaojunnuo
8409f5fd4a build: prepare to build 2024-07-19 15:27:50 +08:00
xiaojunnuo
634a468ec4 build: prepare to build 2024-07-19 15:26:29 +08:00
xiaojunnuo
7ed0544664 build: prepare to build 2024-07-19 15:23:59 +08:00
xiaojunnuo
3d4a046634 build: prepare to build 2024-07-19 15:20:13 +08:00
xiaojunnuo
96954b4aaa chore: 1 2024-07-19 15:15:35 +08:00
xiaojunnuo
d77fc11552 chore: 1 2024-07-19 15:14:03 +08:00
xiaojunnuo
5bad0bbde8 build: prepare to build 2024-07-19 15:13:46 +08:00
xiaojunnuo
cd85ac611b build: prepare to build 2024-07-19 15:03:40 +08:00
xiaojunnuo
0bc6d0a211 feat: 支持lego,海量DNS提供商 2024-07-18 21:10:13 +08:00
xiaojunnuo
b1cd055342 chore: lfs 2024-07-18 21:09:22 +08:00
xiaojunnuo
303097b835 chore: 1 2024-07-18 11:17:13 +08:00
xiaojunnuo
a438028002 chore: 1 2024-07-17 13:14:49 +08:00
xiaojunnuo
4813872bcc chore: 1 2024-07-17 01:33:55 +08:00
xiaojunnuo
3b19bfb429 feat: 支持postgresql 2024-07-17 01:30:00 +08:00
Greper
a917a7bca6 Merge pull request #93 from certd/acme_sync
[acme] sync upgrade [trident-sync]
2024-07-16 03:24:25 +08:00
GitHub Actions Bot
86e64af35c 🔱: [acme] sync upgrade with 5 commits [trident-sync]
Temp remove Node v22 from matrix, broke CNAME tests
Invalidate ACME directory cache after 24 hours
Directory URLs for Google ACME provider
Bump Pebble v2.6.0
2024-07-15 19:24:17 +00:00
xiaojunnuo
bf6f1d8137 chore: 2024-07-15 02:13:53 +08:00
xiaojunnuo
b1688525db perf: 优化一些小细节 2024-07-15 02:05:26 +08:00
xiaojunnuo
2fd14430a2 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
2024-07-15 01:33:04 +08:00
xiaojunnuo
bd3d959944 perf: 增加备案号设置 2024-07-15 01:29:35 +08:00
xiaojunnuo
390e4853a5 perf: 自动生成jwtkey,无需手动配置 2024-07-15 01:29:19 +08:00
xiaojunnuo
485e603b51 feat: 升级midway,支持esm 2024-07-15 00:30:33 +08:00
Greper
3ccd7ad95d Merge pull request #89 from certd/client_sync
[client] sync upgrade [trident-sync]
2024-07-13 03:23:54 +08:00
GitHub Actions Bot
54d9050483 🔱: [client] sync upgrade with 2 commits [trident-sync]
perf: 优化editorwang示例
2024-07-12 19:23:47 +00:00
Greper
6d58c68e9b Merge pull request #87 from certd/client_sync
[client] sync upgrade [trident-sync]
2024-07-12 03:23:58 +08:00
GitHub Actions Bot
80019d4dc1 🔱: [client] sync upgrade with 3 commits [trident-sync]
docs: 1
docs: 1
2024-07-11 19:23:48 +00:00
xiaojunnuo
031df8fc35 v1.21.2 2024-07-08 15:58:51 +08:00
xiaojunnuo
62419a8212 build: prepare to build 2024-07-08 15:57:13 +08:00
xiaojunnuo
09d93af853 build: prepare to build 2024-07-08 15:47:51 +08:00
xiaojunnuo
b6ab178de9 chore: 1 2024-07-08 15:47:36 +08:00
xiaojunnuo
5a08f27d2c build: prepare to build 2024-07-08 15:36:18 +08:00
xiaojunnuo
fe91d94090 perf: 申请证书时可以选择跳过本地dns校验 2024-07-08 15:35:58 +08:00
xiaojunnuo
56ab3269d2 chore: 1 2024-07-08 12:05:56 +08:00
xiaojunnuo
c8243c573f chore: 1 2024-07-08 12:04:59 +08:00
xiaojunnuo
0b769a1c86 v1.21.1 2024-07-08 11:58:09 +08:00
xiaojunnuo
a8189a974d build: prepare to build 2024-07-08 11:46:13 +08:00
xiaojunnuo
322875d241 chore: 1 2024-07-08 11:45:31 +08:00
xiaojunnuo
ed8a54a2bc chore: 1 2024-07-08 11:29:11 +08:00
xiaojunnuo
5ba9831ed1 perf: 上传到主机,支持设置不mkdirs 2024-07-08 11:19:02 +08:00
xiaojunnuo
f9c9fce581 docs: 1 2024-07-08 11:10:08 +08:00
xiaojunnuo
bc650a32cd docs: 1 2024-07-08 10:59:19 +08:00
xiaojunnuo
c6d3e3fe5b docs: 1 2024-07-08 10:57:42 +08:00
xiaojunnuo
73acc62af1 docs: 1 2024-07-08 10:56:19 +08:00
xiaojunnuo
0d4491f3a0 docs: 1 2024-07-08 10:55:55 +08:00
xiaojunnuo
85248044ab docs: 1 2024-07-08 10:53:55 +08:00
xiaojunnuo
c532449102 docs: 1 2024-07-05 10:56:29 +08:00
xiaojunnuo
970c7fd8a0 perf: 说明优化,默认值优化 2024-07-04 02:22:52 +08:00
xiaojunnuo
4656019898 v1.21.0 2024-07-04 01:15:51 +08:00
xiaojunnuo
7eceabb2d8 build: prepare to build 2024-07-04 01:14:33 +08:00
xiaojunnuo
eade2c2b68 feat: 支持zero ssl 2024-07-04 01:14:09 +08:00
xiaojunnuo
6ec950818c v1.20.17 2024-07-03 23:45:57 +08:00
xiaojunnuo
7058b20df4 build: prepare to build 2024-07-03 23:43:55 +08:00
xiaojunnuo
a09b0e48c1 perf: 文件上传提示由cert.crt改为cert.pem 2024-07-03 23:39:12 +08:00
xiaojunnuo
664bb66a91 Merge branch 'client_sync' into v2
# Conflicts:
#	packages/ui/certd-client/CHANGELOG.md
#	packages/ui/certd-client/package.json
2024-07-03 23:37:08 +08:00
xiaojunnuo
eba333de7a perf: 优化cname verify 2024-07-03 23:36:06 +08:00
xiaojunnuo
f47b35f6d5 perf: 创建dns解析后,强制等待60s 2024-07-03 23:27:35 +08:00
Greper
c04707c0f7 fix: 修复对Windows powershell 的支持
修复对Windows powershell 的支持 #73
2024-07-03 23:22:29 +08:00
ltxhhz
22ebcd4dd1 fixed #73 2024-07-03 18:30:38 +08:00
GitHub Actions Bot
692e2b5b96 🔱: [client] sync upgrade with 2 commits [trident-sync]
perf: 增加示例,FsInDrawer
2024-06-26 19:24:03 +00:00
GitHub Actions Bot
586d23fc55 🔱: [client] sync upgrade with 6 commits [trident-sync]
build: publish success
fix: 修复多级表头时列设置的问题

https://github.com/fast-crud/fast-crud/issues/175
chore: 1
fix: 修复element示例中远程搜索下拉框label不显示的bug

https://github.com/fast-crud/fast-crud/issues/422
fix: 修复独立使用对话框 openDialog方法await无返回值的bug
2024-06-23 19:23:47 +00:00
344 changed files with 6295 additions and 2634 deletions

5
.gitignore vendored
View File

@@ -34,3 +34,8 @@ gen
docker/image/workspace
/packages/core/lego
tsconfig.tsbuildinfo
test/**/*.js
/packages/ui/certd-server/data/db.sqlite
/packages/ui/certd-server/data/keys.yaml

3
.npmrc
View File

@@ -1 +1,2 @@
link-workspace-packages=deep
link-workspace-packages=true
prefer-workspace-packages=true

7
.prettierrc Normal file
View File

@@ -0,0 +1,7 @@
{
"printWidth": 160,
"bracketSpacing": true,
"singleQuote": true,
"trailingComma": "es5",
"arrowParens": "avoid"
}

View File

@@ -3,6 +3,55 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.1](https://github.com/certd/certd/compare/v1.22.0...v1.22.1) (2024-07-20)
### Performance Improvements
* 创建证书任务可以选择lege插件 ([affef13](https://github.com/certd/certd/commit/affef130378030c517250c58a4e787b0fc85d7d1))
* 创建证书任务增加定时任务和邮件通知输入 ([427620d](https://github.com/certd/certd/commit/427620d34f3b8ad6933005faf1878908441a2453))
* 支持配置启动后自动触发一次任务 ([a5a0c1f](https://github.com/certd/certd/commit/a5a0c1f6e7a3f05e581005e491d5b102ee854412))
# [1.22.0](https://github.com/certd/certd/compare/v1.21.2...v1.22.0) (2024-07-19)
### Features
* 升级midway支持esm ([485e603](https://github.com/certd/certd/commit/485e603b5165c28bc08694997726eaf2a585ebe7))
* 支持lego海量DNS提供商 ([0bc6d0a](https://github.com/certd/certd/commit/0bc6d0a211920fb0084d705e1db67ee1e7262c44))
* 支持postgresql ([3b19bfb](https://github.com/certd/certd/commit/3b19bfb4291e89064b3b407a80dae092d54747d5))
### Performance Improvements
* 优化一些小细节 ([b168852](https://github.com/certd/certd/commit/b1688525dbbbfd67e0ab1cf5b4ddfbe9d394f370))
* 增加备案号设置 ([bd3d959](https://github.com/certd/certd/commit/bd3d959944db63a5690b55ee150e1007133868b9))
* 自动生成jwtkey无需手动配置 ([390e485](https://github.com/certd/certd/commit/390e4853a570390a97df6a3b3882579f9547eeb4))
## [1.21.2](https://github.com/certd/certd/compare/v1.21.1...v1.21.2) (2024-07-08)
### Performance Improvements
* 申请证书时可以选择跳过本地dns校验 ([fe91d94](https://github.com/certd/certd/commit/fe91d94090d22ed0a3ea753ba74dfaa1bf057c17))
## [1.21.1](https://github.com/certd/certd/compare/v1.21.0...v1.21.1) (2024-07-08)
### Performance Improvements
* 上传到主机支持设置不mkdirs ([5ba9831](https://github.com/certd/certd/commit/5ba9831ed1aa6ec6057df246f1035b36b9c41d2e))
* 说明优化,默认值优化 ([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)
### Features
* 支持zero ssl ([eade2c2](https://github.com/certd/certd/commit/eade2c2b681569f03e9cd466e7d5bcd6703ed492))
## [1.20.17](https://github.com/certd/certd/compare/v1.20.16...v1.20.17) (2024-07-03)
### Performance Improvements
* 创建dns解析后强制等待60s ([f47b35f](https://github.com/certd/certd/commit/f47b35f6d5bd7d675005c3e286b7e9a029201f8b))
* 文件上传提示由cert.crt改为cert.pem ([a09b0e4](https://github.com/certd/certd/commit/a09b0e48c176f3ed763791bd50322c29729f7c1c))
* 优化cname verify ([eba333d](https://github.com/certd/certd/commit/eba333de7a5b5ef4b0b7eaa904f578720102fa61))
## [1.20.16](https://github.com/certd/certd/compare/v1.20.15...v1.20.16) (2024-07-01)
### Bug Fixes

View File

@@ -1,13 +1,15 @@
# CertD
CertD 是一个免费全自动申请和部署SSL证书的工具。
CertD 是一个免费全自动申请和自动部署更新SSL证书的工具。
后缀D取自linux守护进程的命名风格意为证书守护进程。
关键字:证书自动申请、证书自动更新、证书自动续期、证书自动续签
## 一、特性
本项目不仅支持证书申请过程自动化,还可以自动化部署证书,让你的证书永不过期。
本项目不仅支持证书申请过程自动化,还可以自动化部署更新证书,让你的证书永不过期。
* 全自动申请证书支持阿里云、腾讯云、华为云、Cloudflare注册的域名
* 全自动部署证书(目前支持服务器上传部署、部署到阿里云、腾讯云等)
* 全自动部署更新证书(目前支持服务器上传部署、部署到阿里云、腾讯云等)
* 支持通配符域名
* 支持多个域名打到一个证书上
* 邮件通知
@@ -64,22 +66,23 @@ wget https://raw.githubusercontent.com/certd/certd/v2/docker/run/docker-compose.
# 或者使用gitee地址
wget https://gitee.com/certd/certd/raw/v2/docker/run/docker-compose.yaml
# 根据需要修改里面的配置
# 可以根据需要修改里面的配置
# 1.修改镜像版本号【可选】
# 2.配置数据保存路径【可选】
# 3.配置certd_auth_jwt_secret【必须
# 3.修改端口号【可选
vi docker-compose.yaml
```
> 镜像版本号与release版本号同步
https://github.com/certd/certd/releases
### 3. 运行
当前版本号: ![](https://img.shields.io/npm/v/%40certd%2Fpipeline)
```bash
# 如果docker compose是插件化安装
export CERTD_VERSION=latest
# 设置镜像版本号环境变量,如果docker-compose.yaml中已经修改请忽略这条命令
export CERTD_VERSION=latest # <---建议设置成固定版本号
# 启动certd
docker compose up -d
```
如果提示 没有compose命令,请安装docker-compose
@@ -89,9 +92,9 @@ https://docs.docker.com/compose/install/linux/
### 4. 访问
http://your_server_ip:7001
默认账号密码admin/123456
记得修改密码
http://your_server_ip:7001
默认账号密码admin/123456
记得修改密码
### 5. 升级
@@ -100,7 +103,6 @@ http://your_server_ip:7001
* 数据存在`/data/certd`目录下,不用担心数据丢失
## 五、一些说明
* 本项目ssl证书提供商为letencrypt
* 申请过程遵循acme协议
@@ -108,8 +110,8 @@ http://your_server_ip:7001
* http-01 在网站根目录下放置一份txt文件
* dns-01 需要给域名添加txt解析记录通配符域名只能用这种方式
* 证书续期:
* 实际上acme并没有续期概念
* 我们所说的续期,其实就是按照全套流程重新申请一份新证书。
* 实际上没有办法不改变证书文件本身情况下直接续期或者续签
* 我们所说的续期,其实就是按照全套流程重新申请一份新证书,然后重新部署上去
* 免费证书过期时间90天以后可能还会缩短所以自动化部署必不可少
* 设置每天自动运行当证书过期前20天会自动重新申请证书并部署
@@ -168,7 +170,11 @@ docker compose up -d
[贡献插件教程](./plugin.md)
## 十一、我的其他项目
## 十一、我的其他项目求Star
* [袖手GPT](https://ai.handsfree.work/) ChatGPT国内可用无需FQ每日免费额度
* [fast-crud](https://gitee.com/fast-crud/fast-crud/) 基于vue3的crud快速开发框架
* [dev-sidecar](https://github.com/docmirror/dev-sidecar/) 直连访问github工具无需FQ解决github无法访问的问题
## 十二、版本更新日志
https://github.com/certd/certd/blob/v2/CHANGELOG.md

View File

@@ -1,6 +1,5 @@
import http from 'axios'
import fs from 'fs'
//读取 packages/core/pipline/package.json的版本号
import {default as packageJson} from './packages/core/pipeline/package.json' assert { type: "json" };
@@ -33,8 +32,9 @@ async function getPackages(directoryPath) {
async function getAllPackages() {
const base = await getPackages("./packages/core")
const plugins = await getPackages("./packages/plugins")
const libs = await getPackages("./packages/libs")
return base.concat(plugins)
return base.concat(plugins).concat(libs)
}
async function sync() {
@@ -49,7 +49,7 @@ async function sync() {
data: {}
})
console.log(`sync success:${pkg}`)
await sleep(100*1000)
await sleep(30*1000)
}
}
@@ -79,7 +79,7 @@ async function triggerBuild() {
}
})
console.log(`webhook success:${webhook}`)
await sleep(10*60*1000)
await sleep(30*60*1000)
}
}
@@ -87,9 +87,9 @@ async function triggerBuild() {
async function start() {
// await build()
console.log("等待60秒")
await sleep(200 * 1000)
await sleep(100* 1000)
await sync()
await sleep(60 * 1000)
await sleep(100 * 1000)
await triggerBuild()
}

View File

@@ -1,17 +1,22 @@
FROM registry.cn-shenzhen.aliyuncs.com/handsfree/node:18-alpine
EXPOSE 7001
ENV NODE_ENV production
ENV MIDWAY_SERVER_ENV production
WORKDIR /app/
#RUN npm install -g pnpm
ENV node_sqlite3_binary_host_mirror https://registry.npmmirror.com/-/binary/sqlite3
RUN npm install -g pnpm@8.15.7 --registry=https://registry.npmmirror.com
RUN pnpm config set registry https://registry.npmmirror.com/
#RUN npm install cross-env -g --registry=https://registry.npmmirror.com
#RUN npm install pm2 -g --registry=https://registry.npmmirror.com
#RUN pm2 install pm2-logrotate
ADD ./workspace/certd-server/ /app/
RUN sed -i "s/workspace://g" "/app/package.json"
RUN yarn install --production --registry=https://registry.npmmirror.com
#RUN yarn install --registry=https://registry.npmmirror.com
#RUN yarn install --production
RUN pnpm install
RUN node ./before-build.js
RUN npm run build
ENV NODE_ENV production
ENV MIDWAY_SERVER_ENV production
#CMD ["pm2-runtime", "start", "./bootstrap.js","--name", "certd","-i","1"]
CMD ["npm", "run","start"]

View File

@@ -14,10 +14,11 @@ echo "安装依赖"
#pnpm install --registry=https://registry.npmmirror.com
pnpm install
echo "client build"
cd $root/packages/ui/certd-client
pnpm run build
echo "client build success"
echo "packages build"
lerna run build
echo "packages build success"
echo "server build"
cd $root/packages/ui/certd-server

View File

@@ -1,26 +1,27 @@
version: '3.3'
services:
certd:
# 镜像 # ↓↓↓↓↓ --- 1、 修改镜像版本号或者干脆写成latest 如果设置了环境变量 export CERTD_VERSION=latest,这里可以不修改
# 镜像 # ↓↓↓↓↓ --- 1、 修改镜像版本号或者干脆写成latest(不推荐) 如果设置了环境变量 export CERTD_VERSION=xxx,这里可以不修改
image: registry.cn-shenzhen.aliyuncs.com/handsfree/certd:${CERTD_VERSION}
container_name: certd # 容器名
restart: unless-stopped # 自动重启
volumes:
# ↓↓↓↓↓ ------------------------------------------------------- 2、 修改数据库以及证书存储路径【可选】
# ↓↓↓↓↓ ------------------------------------------------------- 2、 数据库以及证书存储路径,默认存在宿主机的/data/certd/目录下【可选】
- /data/certd:/app/data
ports: # 端口映射
# ↓↓↓↓ 如果端口有冲突可以修改第一个7001为其他不冲突的端口号
# ↓↓↓↓ ----------------------------------------------------------3、如果端口有冲突可以修改第一个7001为其他不冲突的端口号【可选】
- "7001:7001"
environment: # 环境变量
- TZ=Asia/Shanghai
- certd_auth_jwt_secret=changeme
# ↑↑↑↑↑ ---------------------------------- 3、 修改成你的自定义密钥【必须,安全需要】
- certd_system_resetAdminPassword=false
# ↑↑↑↑↑ 如果忘记管理员密码可以设置为true重启之后管理员密码将改成123456然后请及时修改回false
# ↑↑↑↑↑---------------------------4、如果忘记管理员密码可以设置为true重启之后管理员密码将改成123456然后请及时修改回false【可选】
- certd_cron_immediateTriggerOnce=false
# ↑↑↑↑↑---------------------------5、如果设置为true启动后所有配置了cron的流水线任务都将被立即触发一次【可选】
- VITE_APP_ICP_NO=
# ↑↑↑↑↑ -----------------------------------------6、这里可以设置备案号【可选】
# 设置环境变量即可自定义certd配置
# 服务端配置项见: packages/ui/certd-server/src/config/config.default.ts
# 服务端配置规则: certd_ + 配置项, 点号用_代替
# 如jwt密钥配置为 auth.jwt.secret则设置环境变量 certd_auth_jwt_secret=changeme
# 客户端配置项见: packages/ui/certd-client/.env
# 按实际名称配置环境变量即可,如: VITE_APP_API=http://localhost:7001

View File

@@ -9,5 +9,5 @@
}
},
"npmClient": "pnpm",
"version": "1.20.16"
"version": "1.22.1"
}

View File

@@ -14,13 +14,15 @@
"i-all": "lerna link && lerna exec npm install ",
"publish": "npm run prepublishOnly1 && lerna publish --conventional-commits && npm run afterpublishOnly && npm run deploy1",
"afterpublishOnly": "",
"prepublishOnly1": "npm run before-build && lerna run build ",
"prepublishOnly1": "npm run check && npm run before-build && lerna run build ",
"before-build": "cd ./packages/core/acme-client && time /t >build.md && git add ./build.md && git commit -m \"build: prepare to build\"",
"deploy1": "node --experimental-json-modules deploy.js "
"deploy1": "node --experimental-json-modules deploy.js ",
"check": "node --experimental-json-modules publish-check.js",
"init": "lerna run build"
},
"license": "AGPL-3.0",
"dependencies": {
"axios": "^1.4.0",
"axios": "^1.7.2",
"lodash": "^4.17.21"
},
"workspaces": [

View File

@@ -5,8 +5,10 @@
set -euo pipefail
# Download and install
wget -nv "https://github.com/letsencrypt/pebble/releases/download/v${PEBBLECTS_VERSION}/pebble-challtestsrv_linux-amd64" -O /usr/local/bin/pebble-challtestsrv
wget -nv "https://github.com/letsencrypt/pebble/releases/download/v${PEBBLECTS_VERSION}/pebble-challtestsrv-linux-amd64.tar.gz" -O /tmp/pebble-challtestsrv.tar.gz
tar zxvf /tmp/pebble-challtestsrv.tar.gz -C /tmp
mv /tmp/pebble-challtestsrv-linux-amd64/linux/amd64/pebble-challtestsrv /usr/local/bin/pebble-challtestsrv
chown root:root /usr/local/bin/pebble-challtestsrv
chmod 0755 /usr/local/bin/pebble-challtestsrv

View File

@@ -22,8 +22,10 @@ wget -nv "https://raw.githubusercontent.com/letsencrypt/pebble/v${PEBBLE_VERSION
wget -nv "https://raw.githubusercontent.com/letsencrypt/pebble/v${PEBBLE_VERSION}/test/config/${CONFIG_NAME}" -O /etc/pebble/pebble.json
# Download and install Pebble
wget -nv "https://github.com/letsencrypt/pebble/releases/download/v${PEBBLE_VERSION}/pebble_linux-amd64" -O /usr/local/bin/pebble
wget -nv "https://github.com/letsencrypt/pebble/releases/download/v${PEBBLE_VERSION}/pebble-linux-amd64.tar.gz" -O /tmp/pebble.tar.gz
tar zxvf /tmp/pebble.tar.gz -C /tmp
mv /tmp/pebble-linux-amd64/linux/amd64/pebble /usr/local/bin/pebble
chown root:root /usr/local/bin/pebble
chmod 0755 /usr/local/bin/pebble

View File

@@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
node: [16, 18, 20, 22]
node: [16, 18, 20]
eab: [0, 1]
#
@@ -19,9 +19,9 @@ jobs:
FORCE_COLOR: 1
NPM_CONFIG_COLOR: always
PEBBLE_VERSION: 2.3.1
PEBBLE_VERSION: 2.6.0
PEBBLE_ALTERNATE_ROOTS: 2
PEBBLECTS_VERSION: 2.3.1
PEBBLECTS_VERSION: 2.6.0
PEBBLECTS_DNS_PORT: 8053
COREDNS_VERSION: 1.11.1

View File

@@ -3,6 +3,37 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.1](https://github.com/publishlab/node-acme-client/compare/v1.22.0...v1.22.1) (2024-07-20)
**Note:** Version bump only for package @certd/acme-client
# [1.22.0](https://github.com/publishlab/node-acme-client/compare/v1.21.2...v1.22.0) (2024-07-19)
### Features
* 升级midway支持esm ([485e603](https://github.com/publishlab/node-acme-client/commit/485e603b5165c28bc08694997726eaf2a585ebe7))
## [1.21.2](https://github.com/publishlab/node-acme-client/compare/v1.21.1...v1.21.2) (2024-07-08)
**Note:** Version bump only for package @certd/acme-client
## [1.21.1](https://github.com/publishlab/node-acme-client/compare/v1.21.0...v1.21.1) (2024-07-08)
**Note:** Version bump only for package @certd/acme-client
# [1.21.0](https://github.com/publishlab/node-acme-client/compare/v1.20.17...v1.21.0) (2024-07-03)
### Features
* 支持zero ssl ([eade2c2](https://github.com/publishlab/node-acme-client/commit/eade2c2b681569f03e9cd466e7d5bcd6703ed492))
## [1.20.17](https://github.com/publishlab/node-acme-client/compare/v1.20.16...v1.20.17) (2024-07-03)
### Performance Improvements
* 创建dns解析后强制等待60s ([f47b35f](https://github.com/publishlab/node-acme-client/commit/f47b35f6d5bd7d675005c3e286b7e9a029201f8b))
* 优化cname verify ([eba333d](https://github.com/publishlab/node-acme-client/commit/eba333de7a5b5ef4b0b7eaa904f578720102fa61))
## [1.20.16](https://github.com/publishlab/node-acme-client/compare/v1.20.15...v1.20.16) (2024-07-01)
### Bug Fixes
@@ -61,6 +92,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
# Changelog
## v5.4.0
* `added` Directory URLs for [Google](https://cloud.google.com/certificate-manager/docs/overview) ACME provider
* `fixed` Invalidate ACME directory cache after 24 hours
## v5.3.1 (2024-05-22)
* `fixed` Allow `client.auto()` being called with an empty CSR common name

View File

@@ -59,6 +59,9 @@ const client = new acme.Client({
acme.directory.buypass.staging;
acme.directory.buypass.production;
acme.directory.google.staging;
acme.directory.google.production;
acme.directory.letsencrypt.staging;
acme.directory.letsencrypt.production;

View File

@@ -1 +1 @@
00:35
03:10

View File

@@ -3,7 +3,7 @@
"description": "Simple and unopinionated ACME client",
"private": false,
"author": "nmorsman",
"version": "1.20.16",
"version": "1.22.1",
"main": "src/index.js",
"types": "types/index.d.ts",
"license": "MIT",
@@ -59,5 +59,5 @@
"bugs": {
"url": "https://github.com/publishlab/node-acme-client/issues"
},
"gitHead": "a31f1c7f5e71fa946de9bf0283e11d6ce049b3e9"
"gitHead": "47fe3d5826661f678d081ab53e67c847a3239d88"
}

View File

@@ -36,6 +36,9 @@ module.exports = async (client, userOpts) => {
if (opts.email) {
accountPayload.contact = [`mailto:${opts.email}`];
}
if (opts.externalAccountBinding) {
accountPayload.externalAccountBinding = opts.externalAccountBinding;
}
/**
* Register account
@@ -129,7 +132,8 @@ module.exports = async (client, userOpts) => {
// throw new Error('测试异常');
/* Challenge verification */
if (opts.skipChallengeVerification === true) {
log(`[auto] [${d}] Skipping challenge verification since skipChallengeVerification=true`);
log(`[auto] [${d}] Skipping challenge verification since skipChallengeVerification=truewait 60s`);
await wait(60 * 1000);
}
else {
log(`[auto] [${d}] Running challenge verification`);

View File

@@ -36,8 +36,11 @@ class HttpClient {
this.externalAccountBinding = externalAccountBinding;
this.maxBadNonceRetries = 5;
this.directory = null;
this.jwk = null;
this.directoryCache = null;
this.directoryMaxAge = 86400;
this.directoryTimestamp = 0;
}
/**
@@ -70,15 +73,17 @@ class HttpClient {
}
/**
* Ensure provider directory exists
* Get ACME provider directory
*
* https://datatracker.ietf.org/doc/html/rfc8555#section-7.1.1
*
* @returns {Promise}
* @returns {Promise<object>} ACME directory contents
*/
async getDirectory() {
if (!this.directory) {
const age = (Math.floor(Date.now() / 1000) - this.directoryTimestamp);
if (!this.directoryCache || (age > this.directoryMaxAge)) {
const resp = await this.request(this.directoryUrl, 'get');
if (resp.status >= 400) {
@@ -89,8 +94,10 @@ class HttpClient {
throw new Error('Attempting to read ACME directory returned no data');
}
this.directory = resp.data;
this.directoryCache = resp.data;
}
return this.directoryCache;
}
/**
@@ -134,13 +141,13 @@ class HttpClient {
*/
async getResourceUrl(resource) {
await this.getDirectory();
const dir = await this.getDirectory();
if (!this.directory[resource]) {
if (!dir[resource]) {
throw new Error(`Unable to locate API resource URL in ACME directory: "${resource}"`);
}
return this.directory[resource];
return dir[resource];
}
/**
@@ -151,10 +158,10 @@ class HttpClient {
*/
async getMetaField(field) {
await this.getDirectory();
const dir = await this.getDirectory();
if (('meta' in this.directory) && (field in this.directory.meta)) {
return this.directory.meta[field];
if (('meta' in dir) && (field in dir.meta)) {
return dir.meta[field];
}
return null;

View File

@@ -13,11 +13,16 @@ exports.directory = {
staging: 'https://api.test4.buypass.no/acme/directory',
production: 'https://api.buypass.com/acme/directory',
},
google: {
staging: 'https://dv.acme-v02.test-api.pki.goog/directory',
production: 'https://dv.acme-v02.api.pki.goog/directory',
},
letsencrypt: {
staging: 'https://acme-staging-v02.api.letsencrypt.org/directory',
production: 'https://acme-v02.api.letsencrypt.org/directory',
},
zerossl: {
staging: 'https://acme.zerossl.com/v2/DV90',
production: 'https://acme.zerossl.com/v2/DV90',
},
};

View File

@@ -48,18 +48,18 @@ async function verifyHttpChallenge(authz, challenge, keyAuthorization, suffix =
async function walkDnsChallengeRecord(recordName, resolver = dns) {
/* Resolve CNAME record first */
try {
log(`Checking name for CNAME records: ${recordName}`);
const cnameRecords = await resolver.resolveCname(recordName);
if (cnameRecords.length) {
log(`CNAME record found at ${recordName}, new challenge record name: ${cnameRecords[0]}`);
return walkDnsChallengeRecord(cnameRecords[0]);
}
}
catch (e) {
log(`No CNAME records found for name: ${recordName}`);
}
// try {
// log(`Checking name for CNAME records: ${recordName}`);
// const cnameRecords = await resolver.resolveCname(recordName);
//
// if (cnameRecords.length) {
// log(`CNAME record found at ${recordName}, new challenge record name: ${cnameRecords[0]}`);
// return walkDnsChallengeRecord(cnameRecords[0]);
// }
// }
// catch (e) {
// log(`No CNAME records found for name: ${recordName}`);
// }
/* Resolve TXT records */
try {

View File

@@ -414,7 +414,7 @@ describe('client.auto', () => {
const info = acme.crypto.readCertificateInfo(testCertificate);
spec.crypto.certificateInfo(info);
assert.strictEqual(info.domains.commonName, testDomain);
assert.isNull(info.domains.commonName);
assert.deepStrictEqual(info.domains.altNames, [testDomain]);
});
@@ -422,7 +422,7 @@ describe('client.auto', () => {
const info = acme.crypto.readCertificateInfo(testSanCertificate);
spec.crypto.certificateInfo(info);
assert.strictEqual(info.domains.commonName, testSanDomains[0]);
assert.isNull(info.domains.commonName);
assert.deepStrictEqual(info.domains.altNames, testSanDomains);
});
@@ -430,7 +430,7 @@ describe('client.auto', () => {
const info = acme.crypto.readCertificateInfo(testWildcardCertificate);
spec.crypto.certificateInfo(info);
assert.strictEqual(info.domains.commonName, testWildcardDomain);
assert.isNull(info.domains.commonName);
assert.deepStrictEqual(info.domains.altNames, [testWildcardDomain, `*.${testWildcardDomain}`]);
});
});

View File

@@ -3,9 +3,10 @@
"module": "commonjs",
"lib": ["es6"],
"strict": true,
"noEmit": true,
"noEmit": false,
"esModuleInterop": true,
"baseUrl": ".",
"composite": true,
"paths": { "acme-client": ["."] }
}
}

View File

@@ -87,11 +87,16 @@ export const directory: {
staging: string,
production: string
},
google: {
staging: string,
production: string
},
letsencrypt: {
staging: string,
production: string
},
zerossl: {
staging: string,
production: string
}
};

View File

@@ -23,4 +23,4 @@ dist-ssr
*.sln
*.sw?
test/user.secret.ts
test/user.secret.*

View File

@@ -0,0 +1,2 @@
link-workspace-packages=true
prefer-workspace-packages=true

View File

@@ -3,6 +3,36 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.1](https://github.com/certd/certd/compare/v1.22.0...v1.22.1) (2024-07-20)
### Performance Improvements
* 创建证书任务可以选择lege插件 ([affef13](https://github.com/certd/certd/commit/affef130378030c517250c58a4e787b0fc85d7d1))
# [1.22.0](https://github.com/certd/certd/compare/v1.21.2...v1.22.0) (2024-07-19)
### Features
* 升级midway支持esm ([485e603](https://github.com/certd/certd/commit/485e603b5165c28bc08694997726eaf2a585ebe7))
* 支持lego海量DNS提供商 ([0bc6d0a](https://github.com/certd/certd/commit/0bc6d0a211920fb0084d705e1db67ee1e7262c44))
* 支持postgresql ([3b19bfb](https://github.com/certd/certd/commit/3b19bfb4291e89064b3b407a80dae092d54747d5))
## [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/pipeline
## [1.21.1](https://github.com/certd/certd/compare/v1.21.0...v1.21.1) (2024-07-08)
**Note:** Version bump only for package @certd/pipeline
# [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/pipeline
## [1.20.17](https://github.com/certd/certd/compare/v1.20.16...v1.20.17) (2024-07-03)
**Note:** Version bump only for package @certd/pipeline
## [1.20.16](https://github.com/certd/certd/compare/v1.20.15...v1.20.16) (2024-07-01)
**Note:** Version bump only for package @certd/pipeline

View File

@@ -0,0 +1,96 @@
import * as fs from "fs";
import * as path from "path";
// https://gist.github.com/lovasoa/8691344
async function* walk(dir) {
for await (const d of await fs.promises.opendir(dir)) {
const entry = path.join(dir, d.name);
if (d.isDirectory()) {
yield* walk(entry);
} else if (d.isFile()) {
yield entry;
}
}
}
function resolveImportPath(sourceFile, importPath, options) {
const sourceFileAbs = path.resolve(process.cwd(), sourceFile);
const root = path.dirname(sourceFileAbs);
const { moduleFilter = defaultModuleFilter } = options;
if (moduleFilter(importPath)) {
const importPathAbs = path.resolve(root, importPath);
let possiblePath = [path.resolve(importPathAbs, "./index.ts"), path.resolve(importPathAbs, "./index.js"), importPathAbs + ".ts", importPathAbs + ".js"];
if (possiblePath.length) {
for (let i = 0; i < possiblePath.length; i++) {
let entry = possiblePath[i];
if (fs.existsSync(entry)) {
const resolved = path.relative(root, entry.replace(/\.ts$/, ".js"));
if (!resolved.startsWith(".")) {
return "./" + resolved;
}
return resolved;
}
}
}
}
return null;
}
function replace(filePath, outFilePath, options) {
const code = fs.readFileSync(filePath).toString();
const newCode = code.replace(/(import|export) (.+?) from ('[^\n']+'|"[^\n"]+");/gs, function (found, action, imported, from) {
const importPath = from.slice(1, -1);
let resolvedPath = resolveImportPath(filePath, importPath, options);
if (resolvedPath) {
resolvedPath = resolvedPath.replaceAll("\\", "/");
console.log("\t", importPath, resolvedPath);
return `${action} ${imported} from "${resolvedPath}";`;
}
return found;
});
if (code !== newCode) {
fs.writeFileSync(outFilePath, newCode);
}
}
// Then, use it with a simple async for loop
async function run(srcDir, options = defaultOptions) {
const { sourceFileFilter = defaultSourceFileFilter } = options;
for await (const entry of walk(srcDir)) {
if (sourceFileFilter(entry)) {
console.log(entry);
replace(entry, entry, options);
}
}
}
const defaultSourceFileFilter = function (sourceFilePath) {
return /\.(js|ts)$/.test(sourceFilePath) && !/node_modules/.test(sourceFilePath);
};
const defaultModuleFilter = function (importedModule) {
return !path.isAbsolute(importedModule) && !importedModule.startsWith("@") && !importedModule.endsWith(".js");
};
const defaultOptions = {
sourceFileFilter: defaultSourceFileFilter,
moduleFilter: defaultModuleFilter,
};
// Switch this to test on one file or directly run on a directory.
const DEBUG = false;
if (DEBUG) {
replace("./src/index.ts", "./out.ts", defaultOptions);
} else {
await run("./src/", defaultOptions);
}

View File

@@ -1,49 +1,46 @@
{
"name": "@certd/pipeline",
"private": false,
"version": "1.20.16",
"main": "./src/index.ts",
"module": "./src/index.ts",
"types": "./src/index.ts",
"publishConfig": {
"main": "./dist/bundle.js",
"module": "./dist/bundle.mjs",
"types": "./dist/d/index.d.ts"
},
"version": "1.22.1",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"dev": "vite",
"build": "rollup -c",
"build": "tsc --skipLibCheck",
"build3": "rollup -c",
"build2": "vue-tsc --noEmit && vite build",
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.4.0",
"@types/lodash-es": "^4.17.12",
"axios": "^1.7.2",
"fix-path": "^4.0.0",
"lodash-es": "^4.17.21",
"node-forge": "^1.3.1",
"nodemailer": "^6.9.3",
"qs": "^6.11.2"
},
"devDependencies": {
"@certd/acme-client": "workspace:^1.20.16",
"@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.0.0",
"@types/chai": "^4.3.5",
"@types/lodash": "^4.14.194",
"@types/chai": "^4.3.10",
"@types/mocha": "^10.0.1",
"@types/node-forge": "^1.3.2",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"chai": "^4.3.7",
"chai": "4.3.10",
"dayjs": "^1.11.7",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"lodash": "^4.17.21",
"iconv-lite": "^0.6.3",
"log4js": "^6.9.1",
"mocha": "^10.2.0",
"prettier": "^2.8.8",
@@ -52,10 +49,11 @@
"rollup-plugin-typescript2": "^0.34.1",
"rollup-plugin-visualizer": "^5.8.2",
"ts-node": "^10.9.1",
"tsc-esm-fix": "^3.0.0",
"tslib": "^2.5.2",
"typescript": "^5.0.4",
"vite": "^4.3.8",
"vue-tsc": "^1.6.5"
},
"gitHead": "a31f1c7f5e71fa946de9bf0283e11d6ce049b3e9"
"gitHead": "47fe3d5826661f678d081ab53e67c847a3239d88"
}

View File

@@ -1,43 +0,0 @@
const resolve = require("@rollup/plugin-node-resolve");
const commonjs = require("@rollup/plugin-commonjs");
//const Typescript = require("rollup-plugin-typescript2");
const Typescript = require("@rollup/plugin-typescript");
const json = require("@rollup/plugin-json");
const terser = require("@rollup/plugin-terser");
module.exports = {
input: "src/index.ts",
output: {
file: "dist/bundle.js",
format: "cjs",
},
plugins: [
// 解析第三方依赖
resolve(),
// 识别 commonjs 模式第三方依赖
commonjs(),
Typescript({
target: "esnext",
rootDir: "src",
declaration: true,
declarationDir: "dist/d",
exclude: ["./node_modules/**", "./src/**/*.vue"],
allowSyntheticDefaultImports: true,
}),
json(),
terser(),
],
external: [
"vue",
"lodash",
"dayjs",
"@certd/acme-client",
"@certd/pipeline",
"@certd/plugin-cert",
"@certd/plugin-aliyun",
"@certd/plugin-tencent",
"@certd/plugin-huawei",
"@certd/plugin-host",
"@certd/plugin-tencent",
"@certd/plugin-util",
],
};

View File

@@ -1,5 +1,5 @@
import { Registrable } from "../registry";
import { FormItemProps } from "../d.ts";
import { Registrable } from "../registry/index.js";
import { FormItemProps } from "../dt/index.js";
export type AccessInputDefine = FormItemProps & {
title: string;

View File

@@ -1,8 +1,8 @@
// src/decorator/memoryCache.decorator.ts
import { AccessDefine, AccessInputDefine } from "./api";
import { Decorator } from "../decorator";
import _ from "lodash";
import { accessRegistry } from "./registry";
import { AccessDefine, AccessInputDefine } from "./api.js";
import { Decorator } from "../decorator/index.js";
import _ from "lodash-es";
import { accessRegistry } from "./registry.js";
// 提供一个唯一 key
export const ACCESS_CLASS_KEY = "pipeline:access";

View File

@@ -1,3 +1,3 @@
export * from "./api";
export * from "./registry";
export * from "./decorator";
export * from "./api.js";
export * from "./registry.js";
export * from "./decorator.js";

View File

@@ -1,4 +1,4 @@
import { Registry } from "../registry";
import { Registry } from "../registry/index.js";
// @ts-ignore
export const accessRegistry = new Registry("access");

View File

@@ -1,5 +1,5 @@
import { AxiosInstance } from "axios";
import { IContext } from "../core";
import { IContext } from "../core/index.js";
export type HttpClient = AxiosInstance;
export type UserContext = IContext;

View File

@@ -1,4 +1,5 @@
import { IStorage, MemoryStorage } from "./storage";
import { IStorage, MemoryStorage } from "./storage.js";
const CONTEXT_VERSION_KEY = "contextVersion";
export interface IContext {
getInt(key: string): Promise<number>;
@@ -20,13 +21,11 @@ export class ContextFactory {
}
getContext(scope: string, namespace: string): IContext {
const context = new StorageContext(scope, namespace, this.storage);
return context;
return new StorageContext(scope, namespace, this.storage);
}
getMemoryContext(scope: string, namespace: string): IContext {
const context = new StorageContext(scope, namespace, this.memoryStorage);
return context;
return new StorageContext(scope, namespace, this.memoryStorage);
}
}

View File

@@ -1,18 +1,18 @@
import { ConcurrencyStrategy, NotificationWhen, Pipeline, ResultType, Runnable, RunStrategy, Stage, Step, Task } from "../d.ts";
import _ from "lodash";
import { RunHistory, RunnableCollection } from "./run-history";
import { AbstractTaskPlugin, PluginDefine, pluginRegistry, TaskInstanceContext } from "../plugin";
import { ContextFactory, IContext } from "./context";
import { IStorage } from "./storage";
import { logger } from "../utils/util.log";
import { ConcurrencyStrategy, NotificationWhen, Pipeline, ResultType, Runnable, RunStrategy, Stage, Step, Task } from "../dt/index.js";
import _ from "lodash-es";
import { RunHistory, RunnableCollection } from "./run-history.js";
import { AbstractTaskPlugin, PluginDefine, pluginRegistry, TaskInstanceContext } from "../plugin/index.js";
import { ContextFactory, IContext } from "./context.js";
import { IStorage } from "./storage.js";
import { logger } from "../utils/util.log.js";
import { Logger } from "log4js";
import { createAxiosService } from "../utils/util.request";
import { IAccessService } from "../access";
import { RegistryItem } from "../registry";
import { Decorator } from "../decorator";
import { IEmailService } from "../service";
import { FileStore } from "./file-store";
import { TimeoutPromise } from "../utils/util.promise";
import { createAxiosService } from "../utils/util.request.js";
import { IAccessService } from "../access/index.js";
import { RegistryItem } from "../registry/index.js";
import { Decorator } from "../decorator/index.js";
import { IEmailService } from "../service/index.js";
import { FileStore } from "./file-store.js";
// import { TimeoutPromise } from "../utils/util.promise.js";
export type ExecutorOptions = {
userId: any;
@@ -33,7 +33,7 @@ export class Executor {
lastRuntime!: RunHistory;
options: ExecutorOptions;
canceled = false;
onChanged: (history: RunHistory) => void;
onChanged: (history: RunHistory) => Promise<void>;
constructor(options: ExecutorOptions) {
this.options = options;
this.pipeline = _.cloneDeep(options.pipeline);
@@ -110,12 +110,13 @@ export class Executor {
const intervalFlushLogId = setInterval(async () => {
await this.onChanged(this.runtime);
}, 5000);
const timeout = runnable.timeout ?? 20 * 60 * 1000;
// const timeout = runnable.timeout ?? 20 * 60 * 1000;
try {
if (this.canceled) {
throw new Error("task canceled");
return ResultType.canceled;
}
await TimeoutPromise(run, timeout);
await run();
this.runtime.success(runnable);
return ResultType.success;
} catch (e: any) {
@@ -142,19 +143,25 @@ export class Executor {
async runStage(stage: Stage) {
const runnerList = [];
for (const task of stage.tasks) {
const runner = this.runWithHistory(task, "task", async () => {
await this.runTask(task);
});
const runner = async () => {
return this.runWithHistory(task, "task", async () => {
await this.runTask(task);
});
};
runnerList.push(runner);
}
let resList: ResultType[] = [];
if (stage.concurrency === ConcurrencyStrategy.Parallel) {
resList = await Promise.all(runnerList);
const pList = [];
for (const item of runnerList) {
pList.push(item());
}
resList = await Promise.all(pList);
} else {
for (let i = 0; i < runnerList.length; i++) {
const runner = runnerList[i];
resList[i] = await runner;
resList[i] = await runner();
}
}
return this.compositionResultType(resList);
@@ -239,7 +246,7 @@ export class Executor {
this.lastStatusMap.clear();
}
//输出到output context
_.forEach(define.output, (item, key) => {
_.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];
@@ -275,12 +282,16 @@ export class Executor {
continue;
}
if (notification.type === "email") {
this.options.emailService?.send({
userId: this.pipeline.userId,
subject,
content,
receivers: notification.options.receivers,
});
try {
this.options.emailService?.send({
userId: this.pipeline.userId,
subject,
content,
receivers: notification.options.receivers,
});
} catch (e) {
logger.error("send email error", e);
}
}
}
}

View File

@@ -1,8 +1,8 @@
import { fileUtils } from "../utils";
import { fileUtils } from "../utils/index.js";
import dayjs from "dayjs";
import path from "path";
import fs from "fs";
import { logger } from "../utils";
import { logger } from "../utils/index.js";
export type FileStoreOptions = {
rootDir?: string;
@@ -10,6 +10,12 @@ export type FileStoreOptions = {
parent: string;
};
export interface IFileStore {
readFile(filePath: string): Buffer | null;
writeFile(filename: string, file: Buffer): string;
deleteByParent(scope: string, parent: string): void;
}
export class FileStore {
rootDir: string;
scope: string;
@@ -35,7 +41,7 @@ export class FileStore {
return localPath;
}
private buildFilePath(filename: string) {
protected buildFilePath(filename: string) {
const parentDir = path.join(this.rootDir, this.scope + "", this.parent + "", dayjs().format("YYYY-MM-DD"));
if (!fs.existsSync(parentDir)) {
fs.mkdirSync(parentDir, { recursive: true });

View File

@@ -1,5 +1,5 @@
export * from "./executor";
export * from "./run-history";
export * from "./context";
export * from "./storage";
export * from "./file-store";
export * from "./executor.js";
export * from "./run-history.js";
export * from "./context.js";
export * from "./storage.js";
export * from "./file-store.js";

View File

@@ -1,6 +1,6 @@
import { Context, HistoryResult, Pipeline, ResultType, Runnable, RunnableMap, Stage, Step, Task } from "../d.ts";
import _ from "lodash";
import { buildLogger } from "../utils/util.log";
import { Context, HistoryResult, Pipeline, ResultType, Runnable, RunnableMap, Stage, Step, Task } from "../dt/index.js";
import _ from "lodash-es";
import { buildLogger } from "../utils/util.log.js";
import { Logger } from "log4js";
export type HistoryStatus = {

View File

@@ -1,6 +1,6 @@
import fs from "fs";
import path from "path";
import { fileUtils } from "../utils/util.file";
import { fileUtils } from "../utils/util.file.js";
export interface IStorage {
get(scope: string, namespace: string, version: string, key: string): Promise<string | null>;

View File

@@ -70,6 +70,7 @@ export type Runnable = {
default?: {
[key: string]: any;
};
context?: Context;
};
export type EmailOptions = {

View File

@@ -1,4 +1,4 @@
import { Decorator } from "./index";
import { Decorator } from "./index.js";
export type AutowireProp = {
name?: string;

View File

@@ -1,2 +1,2 @@
export * from "./utils";
export * from "./common";
export * from "./utils.js";
export * from "./common.js";

View File

@@ -1,4 +1,4 @@
import _ from "lodash";
import _ from "lodash-es";
const propertyMap: any = {};
function attachProperty(target: any, propertyKey: string | symbol) {
@@ -11,7 +11,11 @@ function attachProperty(target: any, propertyKey: string | symbol) {
}
function getClassProperties(target: any) {
return propertyMap[target] || {};
//获取父类
const parent = Object.getPrototypeOf(target);
const parentMap = propertyMap[parent] || {};
const current = propertyMap[target] || {};
return _.merge({}, parentMap, current);
}
function target(target: any, propertyKey?: string | symbol) {
@@ -25,7 +29,7 @@ function target(target: any, propertyKey?: string | symbol) {
}
function inject(define: any, instance: any, context: any, preHandler?: (item: any, key: string, instance: any, context: any) => void) {
_.forEach(define, (item, key) => {
_.forEach(define, (item: any, key: any) => {
if (preHandler) {
preHandler(item, key, instance, context);
}

View File

@@ -0,0 +1,115 @@
/**
* [x]-col的配置
*/
export type ColProps = {
span?: number;
[props: string]: any;
};
export type FormItemProps = {
/**
* 字段label
*/
title?: string;
/**
* 表单字段组件配置
*/
component?: ComponentProps;
/**
* 表单字段 [a|el|n]-col的配置
* 一般用来配置跨列:{span:24} 占满一行
*/
col?: ColProps;
/**
* 默认值
*/
value?: any;
/**
* 帮助提示配置
*/
helper?: string | FormItemHelperProps;
/**
* 排序号
*/
order?: number;
/**
* 是否显示此字段
*/
show?: boolean;
/**
* 是否是空白占位栏
*/
blank?: boolean;
[key: string]: any;
};
/**
* 表单字段帮助说明配置
*/
export type FormItemHelperProps = {
/**
* 自定义渲染帮助说明
* @param scope
*/
render?: (scope: any) => any;
/**
* 帮助文本
*/
text?: string;
/**
* 帮助说明所在的位置,[ undefined | label]
*/
position?: string;
/**
* [a|el|n]-tooltip配置
*/
tooltip?: object;
[key: string]: any;
};
/**
* 组件配置
*/
export type ComponentProps = {
/**
* 组件的名称
*/
name?: string | object;
/**
* vmodel绑定的目标属性名
*/
vModel?: string;
/**
* 当原始组件名的参数被以上属性名占用时,可以配置在这里
* 例如:原始组件有一个叫name的属性你想要配置它则可以按如下配置
* ```
* component:{
* name:"组件的名称"
* props:{
* name:"组件的name属性" <-----------
* }
* }
* ```
*/
props?: {
[key: string]: any;
};
/**
* 组件事件监听
*/
on?: {
[key: string]: (context?: any) => void;
};
/**
* 组件其他参数
* 事件onXxx:(event)=>void 组件原始事件监听
* on.onXxx:(context)=>void 组件事件监听(对原始事件包装)
* 样式style、class等
*/
[key: string]: any;
};

View File

@@ -0,0 +1,2 @@
export * from "./pipeline.js";
export * from "./fast-crud.js";

View File

@@ -0,0 +1,139 @@
export enum RunStrategy {
AlwaysRun,
SkipWhenSucceed,
}
export enum ConcurrencyStrategy {
Serial,
Parallel,
}
export enum NextStrategy {
AllSuccess,
OneSuccess,
}
export enum HandlerType {
//清空后续任务的状态
ClearFollowStatus,
SendEmail,
}
export type EventHandler = {
type: HandlerType;
params: {
[key: string]: any;
};
};
export type RunnableStrategy = {
runStrategy?: RunStrategy;
onSuccess?: EventHandler[];
onError?: EventHandler[];
};
export type Step = Runnable & {
type: string; //插件类型
input: {
[key: string]: any;
};
};
export type Task = Runnable & {
steps: Step[];
};
export type Stage = Runnable & {
tasks: Task[];
concurrency: ConcurrencyStrategy;
next: NextStrategy;
};
export type Trigger = {
id: string;
title: string;
cron: string;
type: string;
};
export type FileItem = {
id: string;
filename: string;
path: string;
};
export type Runnable = {
id: string;
title: string;
strategy?: RunnableStrategy;
runnableType?: string; // pipeline, stage, task , step
status?: HistoryResult;
timeout?: number;
default?: {
[key: string]: any;
};
};
export type EmailOptions = {
receivers: string[];
};
export type NotificationWhen = "error" | "success" | "turnToSuccess" | "start";
export type NotificationType = "email" | "url";
export type Notification = {
type: NotificationType;
when: NotificationWhen[];
options: EmailOptions;
};
export type Pipeline = Runnable & {
version?: number;
userId: any;
stages: Stage[];
triggers: Trigger[];
notifications?: Notification[];
};
export type Context = {
[key: string]: any;
};
export type Log = {
title: string;
time: number;
level: string;
text: string;
};
export enum ResultType {
start = "start",
success = "success",
error = "error",
canceled = "canceled",
skip = "skip",
none = "none",
}
export type HistoryResultGroup = {
[key: string]: {
runnable: Runnable;
res: HistoryResult;
};
};
export type HistoryResult = {
input: any;
output: any;
files?: FileItem[];
/**
* 任务状态
*/
status: ResultType;
startTime: number;
endTime?: number;
/**
* 处理结果
*/
result?: ResultType; //success, error,skip
message?: string;
};
export type RunnableMap = {
[id: string]: Runnable;
};

View File

@@ -1,10 +1,10 @@
import "util";
export * from "./core";
export * from "./d.ts";
export * from "./access";
export * from "./registry";
export * from "./plugin";
export * from "./utils";
export * from "./context";
export * from "./decorator";
export * from "./service";
export * from "./core/index.js";
export * from "./dt/index.js";
export * from "./access/index.js";
export * from "./registry/index.js";
export * from "./plugin/index.js";
export * from "./utils/index.js";
export * from "./context/index.js";
export * from "./decorator/index.js";
export * from "./service/index.js";

View File

@@ -1,12 +1,12 @@
import { Registrable } from "../registry";
import { FileItem, FormItemProps, Pipeline, Runnable, Step } from "../d.ts";
import { FileStore } from "../core/file-store";
import { Registrable } from "../registry/index.js";
import { FileItem, FormItemProps, Pipeline, Runnable, Step } from "../dt/index.js";
import { FileStore } from "../core/file-store.js";
import { Logger } from "log4js";
import { IAccessService } from "../access";
import { IEmailService } from "../service";
import { IContext } from "../core";
import { IAccessService } from "../access/index.js";
import { IEmailService } from "../service/index.js";
import { IContext } from "../core/index.js";
import { AxiosInstance } from "axios";
import { logger } from "../utils";
import { logger } from "../utils/index.js";
export enum ContextScope {
global,
@@ -23,6 +23,7 @@ export type TaskInputDefine = FormItemProps;
export type PluginDefine = Registrable & {
default?: any;
group?: string;
input?: {
[key: string]: TaskInputDefine;
};
@@ -83,7 +84,7 @@ export abstract class AbstractTaskPlugin implements ITaskPlugin {
return Math.random().toString(36).substring(2, 9);
}
linkFile(file: FileItem) {
this._result.files!.push({
this._result.files?.push({
...file,
id: this.randomFileId(),
});
@@ -91,13 +92,20 @@ export abstract class AbstractTaskPlugin implements ITaskPlugin {
saveFile(filename: string, file: Buffer) {
const filePath = this.ctx.fileStore.writeFile(filename, file);
logger.info(`saveFile:${filePath}`);
this._result.files!.push({
this._result.files?.push({
id: this.randomFileId(),
filename,
path: filePath,
});
}
extendsFiles() {
if (this._result.files == null) {
this._result.files = [];
}
this._result.files.push(...(this.ctx.lastStatus?.status?.files || []));
}
get pipeline() {
return this.ctx.pipeline;
}

View File

@@ -1,8 +1,8 @@
import _ from "lodash";
import { pluginRegistry } from "./registry";
import { PluginDefine, TaskInputDefine, TaskOutputDefine } from "./api";
import { Decorator } from "../decorator";
import { AUTOWIRE_KEY } from "../decorator";
import _ from "lodash-es";
import { pluginRegistry } from "./registry.js";
import { PluginDefine, TaskInputDefine, TaskOutputDefine } from "./api.js";
import { Decorator } from "../decorator/index.js";
import { AUTOWIRE_KEY } from "../decorator/index.js";
import "reflect-metadata";
// 提供一个唯一 key
export const PLUGIN_CLASS_KEY = "pipeline:plugin";
@@ -31,7 +31,24 @@ export function IsTaskPlugin(define: PluginDefine): ClassDecorator {
outputs[property] = output;
}
}
_.merge(define, { input: inputs, autowire: autowires, output: outputs });
// inputs 转换为array根据order排序然后再转换为map
let inputArray = [];
for (const key in inputs) {
const _input = inputs[key];
if (_input.order == null) {
_input.order = 0;
}
inputArray.push([key, _input]);
}
inputArray = _.sortBy(inputArray, (item: any) => item[1].order);
const inputMap: any = {};
inputArray.forEach((item: any) => {
inputMap[item[0]] = item[1];
});
_.merge(define, { input: inputMap, autowire: autowires, output: outputs });
Reflect.defineMetadata(PLUGIN_CLASS_KEY, define, target);

View File

@@ -0,0 +1,25 @@
import { PluginDefine } from "./api";
export class PluginGroup {
key: string;
title: string;
desc?: string;
order: number;
plugins: PluginDefine[];
constructor(key: string, title: string, order = 0, desc = "") {
this.key = key;
this.title = title;
this.order = order;
this.desc = desc;
this.plugins = [];
}
}
export const pluginGroups = {
cert: new PluginGroup("cert", "证书申请", 1),
aliyun: new PluginGroup("aliyun", "阿里云", 2),
huawei: new PluginGroup("huawei", "华为云", 3),
tencent: new PluginGroup("tencent", "腾讯云", 4),
host: new PluginGroup("host", "主机", 5),
other: new PluginGroup("other", "其他", 7),
};

View File

@@ -1,3 +1,4 @@
export * from "./api";
export * from "./registry";
export * from "./decorator";
export * from "./api.js";
export * from "./registry.js";
export * from "./decorator.js";
export * from "./group.js";

View File

@@ -1,4 +1,16 @@
import { Registry } from "../registry";
import { AbstractTaskPlugin } from "./api";
import { OnRegisterContext, Registry } from "../registry/index.js";
import { AbstractTaskPlugin } from "./api.js";
import { pluginGroups } from "./group.js";
export const pluginRegistry = new Registry<AbstractTaskPlugin>("plugin");
const onRegister = ({ key, value }: OnRegisterContext<AbstractTaskPlugin>) => {
const group = value?.define?.group as string;
if (group) {
if (pluginGroups.hasOwnProperty(group)) {
// @ts-ignore
pluginGroups[group].plugins.push(value.define);
} else {
pluginGroups.other.plugins.push(value.define);
}
}
};
export const pluginRegistry = new Registry<AbstractTaskPlugin>("plugin", onRegister);

View File

@@ -1,6 +1,5 @@
import { ITaskPlugin } from "../api";
import { IsTaskPlugin, TaskInput } from "../decorator";
import { Autowire } from "../../decorator";
import { ITaskPlugin } from "../api.js";
import { IsTaskPlugin, TaskInput } from "../decorator.js";
@IsTaskPlugin({
name: "EchoPlugin",

View File

@@ -1 +1 @@
export * from "./registry";
export * from "./registry.js";

View File

@@ -1,23 +1,34 @@
import { logger } from "../utils";
import { logger } from "../utils/index.js";
export type Registrable = {
name: string;
title: string;
desc?: string;
group?: string;
};
export type RegistryItem<T> = {
define: Registrable;
target: T;
};
export type OnRegisterContext<T> = {
registry: Registry<T>;
key: string;
value: RegistryItem<T>;
};
export type OnRegister<T> = (ctx: OnRegisterContext<T>) => void;
export class Registry<T> {
type = "";
storage: {
[key: string]: RegistryItem<T>;
} = {};
constructor(type: string) {
onRegister?: OnRegister<T>;
constructor(type: string, onRegister?: OnRegister<T>) {
this.type = type;
this.onRegister = onRegister;
}
register(key: string, value: RegistryItem<T>) {
@@ -25,6 +36,13 @@ export class Registry<T> {
return;
}
this.storage[key] = value;
if (this.onRegister) {
this.onRegister({
registry: this,
key,
value,
});
}
logger.info(`注册插件:${this.type}:${key}`);
}

View File

@@ -1 +1 @@
export * from "./email";
export * from "./email.js";

View File

@@ -1,7 +1,9 @@
import sleep from "./util.sleep";
import { request } from "./util.request";
export * from "./util.log";
export * from "./util.file";
import sleep from "./util.sleep.js";
import { request } from "./util.request.js";
export * from "./util.log.js";
export * from "./util.file.js";
export * from "./util.sp.js";
export * as promises from "./util.promise.js";
export const utils = {
sleep,
http: request,

View File

@@ -1,3 +1,5 @@
import { logger } from "./util.log.js";
export function TimeoutPromise(callback: () => Promise<void>, ms = 30 * 1000) {
let timeout: any;
return Promise.race([
@@ -11,3 +13,14 @@ export function TimeoutPromise(callback: () => Promise<void>, ms = 30 * 1000) {
clearTimeout(timeout);
});
}
export function safePromise<T>(callback: (resolve: (ret: T) => void, reject: (ret: any) => void) => void): Promise<T> {
return new Promise((resolve, reject) => {
try {
callback(resolve, reject);
} catch (e) {
logger.error(e);
reject(e);
}
});
}

View File

@@ -1,7 +1,7 @@
import axios from "axios";
// @ts-ignore
import qs from "qs";
import { logger } from "./util.log";
import { logger } from "./util.log.js";
import { Logger } from "log4js";
/**
* @description 创建请求实例

View File

@@ -5,3 +5,4 @@ export default function (timeout: number) {
}, timeout);
});
}

View File

@@ -0,0 +1,110 @@
//转换为import
import childProcess from "child_process";
import { safePromise } from "./util.promise.js";
import { ILogger, logger } from "./util.log.js";
export type ExecOption = {
cmd: string | string[];
env: any;
logger?: ILogger;
options?: any;
};
async function exec(opts: ExecOption): Promise<string> {
let cmd = "";
const log = opts.logger || logger;
if (opts.cmd instanceof Array) {
for (const item of opts.cmd) {
if (cmd) {
cmd += " && " + item;
} else {
cmd = item;
}
}
}
log.info(`执行命令: ${cmd}`);
return safePromise((resolve, reject) => {
childProcess.exec(
cmd,
{
env: {
...process.env,
...opts.env,
},
...opts.options,
},
(error, stdout, stderr) => {
if (error) {
log.error(`exec error: ${error}`);
reject(error);
} else {
const res = stdout.toString("utf-8");
log.info(`stdout: ${res}`);
resolve(res);
}
}
);
});
}
export type SpawnOption = {
cmd: string | string[];
onStdout?: (data: string) => void;
onStderr?: (data: string) => void;
env: any;
logger?: ILogger;
options?: any;
};
async function spawn(opts: SpawnOption): Promise<string> {
let cmd = "";
const log = opts.logger || logger;
if (opts.cmd instanceof Array) {
for (const item of opts.cmd) {
if (cmd) {
cmd += " && " + item;
} else {
cmd = item;
}
}
}
log.info(`执行命令: ${cmd}`);
let stdout = "";
let stderr = "";
return safePromise((resolve, reject) => {
const ls = childProcess.spawn(cmd, {
shell: process.platform == "win32",
env: {
...process.env,
...opts.env,
},
...opts.options,
});
ls.stdout.on("data", (data) => {
log.info(`stdout: ${data}`);
stdout += data;
});
ls.stderr.on("data", (data) => {
log.error(`stderr: ${data}`);
stderr += data;
});
ls.on("error", (error) => {
log.error(`child process error: ${error}`);
reject(error);
});
ls.on("close", (code: number) => {
if (code !== 0) {
log.error(`child process exited with code ${code}`);
reject(new Error(stderr));
} else {
resolve(stdout);
}
});
});
}
export const sp = {
spawn,
exec,
};

View File

@@ -1,23 +1,41 @@
{
"compileOnSave": true,
"compilerOptions": {
"importHelpers": false,
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"moduleResolution": "node",
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"experimentalDecorators": true,
"paths": {
"tslib" : ["./node_modules/tslib/tslib.d.ts"]
}
"emitDecoratorMetadata": true,
"inlineSourceMap":true,
"noImplicitThis": true,
"noUnusedLocals": true,
"stripInternal": true,
"skipLibCheck": true,
"pretty": true,
"declaration": true,
"forceConsistentCasingInFileNames": true,
"typeRoots": [ "./typings", "./node_modules/@types"],
"outDir": "dist",
"rootDir": "src",
"composite": true,
"useDefineForClassFields": true,
"strict": true,
// "sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": false,
"lib": ["ESNext", "DOM"],
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue","test/**/*.ts","rollup.config.ts"],
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.json"
],
"exclude": [
"*.js",
"*.ts",
"dist",
"node_modules",
"test"
],
}

View File

@@ -1,59 +0,0 @@
import { defineConfig } from "vite";
import visualizer from "rollup-plugin-visualizer";
import typescript from "@rollup/plugin-typescript";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [],
build: {
target: "es2015",
lib: {
entry: "src/index.ts",
name: "CertdPipeline",
},
rollupOptions: {
plugins: [
visualizer(),
typescript({
target: "es2015",
rootDir: "src",
declaration: true,
declarationDir: "dist/d",
exclude: ["./node_modules/**", "./src/**/*.vue"],
allowSyntheticDefaultImports: true,
}),
],
external: [
"vue",
"lodash",
"dayjs",
"@certd/acme-client",
"@certd/plugin-cert",
"@certd/plugin-aliyun",
"@certd/plugin-tencent",
"@certd/plugin-huawei",
"@certd/plugin-host",
"@certd/plugin-tencent",
"@certd/plugin-util",
"log4js",
"@midwayjs/core",
"@midwayjs/decorator",
],
output: {
globals: {
vue: "Vue",
lodash: "_",
dayjs: "dayjs",
"@certd/plugin-cert": "CertdPluginCert",
"@certd/acme-client": "CertdAcmeClient",
"@certd/plugin-aliyun": "CertdPluginAliyun",
"@certd/plugin-host": "CertdPluginHost",
"@certd/plugin-huawei": "CertdPluginHuawei",
"@certd/plugin-util": "CertdPluginUtil",
log4js: "log4js",
"@midwayjs/core": "MidwayjsCore",
"@midwayjs/decorator": "MidwayjsDecorator",
},
},
},
},
});

View File

@@ -23,4 +23,6 @@ dist-ssr
*.sln
*.sw?
test/user.secret.ts
test/user.secret.ts
.rollup.cache

View File

@@ -0,0 +1,3 @@
node_modules
src
.rollup.cache

View File

@@ -0,0 +1,15 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.1](https://github.com/certd/certd/compare/v1.22.0...v1.22.1) (2024-07-20)
**Note:** Version bump only for package @certd/lib-huawei
# [1.22.0](https://github.com/certd/certd/compare/v1.21.2...v1.22.0) (2024-07-19)
### Features
* 升级midway支持esm ([485e603](https://github.com/certd/certd/commit/485e603b5165c28bc08694997726eaf2a585ebe7))
* 支持postgresql ([3b19bfb](https://github.com/certd/certd/commit/3b19bfb4291e89064b3b407a80dae092d54747d5))

View File

@@ -0,0 +1,96 @@
import * as fs from "fs";
import * as path from "path";
// https://gist.github.com/lovasoa/8691344
async function* walk(dir) {
for await (const d of await fs.promises.opendir(dir)) {
const entry = path.join(dir, d.name);
if (d.isDirectory()) {
yield* walk(entry);
} else if (d.isFile()) {
yield entry;
}
}
}
function resolveImportPath(sourceFile, importPath, options) {
const sourceFileAbs = path.resolve(process.cwd(), sourceFile);
const root = path.dirname(sourceFileAbs);
const { moduleFilter = defaultModuleFilter } = options;
if (moduleFilter(importPath)) {
const importPathAbs = path.resolve(root, importPath);
let possiblePath = [path.resolve(importPathAbs, "./index.ts"), path.resolve(importPathAbs, "./index.js"), importPathAbs + ".ts", importPathAbs + ".js"];
if (possiblePath.length) {
for (let i = 0; i < possiblePath.length; i++) {
let entry = possiblePath[i];
if (fs.existsSync(entry)) {
const resolved = path.relative(root, entry.replace(/\.ts$/, ".js"));
if (!resolved.startsWith(".")) {
return "./" + resolved;
}
return resolved;
}
}
}
}
return null;
}
function replace(filePath, outFilePath, options) {
const code = fs.readFileSync(filePath).toString();
const newCode = code.replace(/(import|export) (.+?) from ('[^\n']+'|"[^\n"]+");/gs, function (found, action, imported, from) {
const importPath = from.slice(1, -1);
let resolvedPath = resolveImportPath(filePath, importPath, options);
if (resolvedPath) {
resolvedPath = resolvedPath.replaceAll("\\", "/");
console.log("\t", importPath, resolvedPath);
return `${action} ${imported} from "${resolvedPath}";`;
}
return found;
});
if (code !== newCode) {
fs.writeFileSync(outFilePath, newCode);
}
}
// Then, use it with a simple async for loop
async function run(srcDir, options = defaultOptions) {
const { sourceFileFilter = defaultSourceFileFilter } = options;
for await (const entry of walk(srcDir)) {
if (sourceFileFilter(entry)) {
console.log(entry);
replace(entry, entry, options);
}
}
}
const defaultSourceFileFilter = function (sourceFilePath) {
return /\.(js|ts)$/.test(sourceFilePath) && !/node_modules/.test(sourceFilePath);
};
const defaultModuleFilter = function (importedModule) {
return !path.isAbsolute(importedModule) && !importedModule.startsWith("@") && !importedModule.endsWith(".js");
};
const defaultOptions = {
sourceFileFilter: defaultSourceFileFilter,
moduleFilter: defaultModuleFilter,
};
// Switch this to test on one file or directly run on a directory.
const DEBUG = false;
if (DEBUG) {
replace("./src/index.ts", "./out.ts", defaultOptions);
} else {
await run("./src/", defaultOptions);
}

View File

@@ -0,0 +1,20 @@
{
"name": "@certd/lib-huawei",
"private": false,
"version": "1.22.1",
"main": "./dist/bundle.js",
"module": "./dist/bundle.js",
"types": "./dist/d/index.d.ts",
"scripts": {
"dev": "vite",
"build": "rollup -c ",
"build2": "vue-tsc --noEmit && vite build",
"preview": "vite preview"
},
"dependencies": {
"@certd/pipeline": "1.21.0",
"axios": "^1.7.2",
"rollup": "^3.7.4"
},
"gitHead": "47fe3d5826661f678d081ab53e67c847a3239d88"
}

View File

@@ -32,22 +32,5 @@ module.exports = {
json(),
terser(),
],
external: [
"vue",
"lodash",
"dayjs",
"@certd/acme-client",
"@certd/pipeline",
"@certd/plugin-cert",
"@certd/plugin-aliyun",
"@certd/plugin-tencent",
"@certd/plugin-huawei",
"@certd/plugin-host",
"@certd/plugin-tencent",
"@certd/plugin-util",
"log4js",
"@midwayjs/core",
"@midwayjs/decorator",
"kubernetes-client",
],
external: ["vue", "lodash-es", "dayjs", "log4js", "@midwayjs/core", "@certd/pipeline", "axios"],
};

View File

@@ -0,0 +1,2 @@
export { HuaweiYunClient } from "./lib/client.js";
export { ApiRequestOptions } from "./lib/client.js";

View File

@@ -0,0 +1,12 @@
import { HuaweiAccess } from "../access/index.js";
export type ApiRequestOptions = {
method: string;
url: string;
headers?: any;
data?: any;
};
export declare class HuaweiYunClient {
access: HuaweiAccess;
constructor(access: HuaweiAccess);
request(options: ApiRequestOptions): Promise<any>;
}

View File

@@ -0,0 +1,41 @@
import { Signer, SigHttpRequest } from "./signer.js";
import axios from "axios";
export class HuaweiYunClient {
access;
constructor(access, logger) {
this.access = access;
}
async request(options) {
const sig = new Signer(this.access.accessKeyId, this.access.accessKeySecret);
//The following example shows how to set the request URL and parameters to query a VPC list.
//Specify a request method, such as GET, PUT, POST, DELETE, HEAD, and PATCH.
//Set request host.
//Set request URI.
//Set parameters for the request URL.
let body = undefined;
if (options.data) {
body = JSON.stringify(options.data);
}
const r = new SigHttpRequest(options.method, options.url, options.headers, body);
//Add header parameters, for example, x-domain-id for invoking a global service and x-project-id for invoking a project-level service.
r.headers = { "Content-Type": "application/json" };
//Add a body if you have specified the PUT or POST method. Special characters, such as the double quotation mark ("), contained in the body must be escaped.
// r.body = option;
const opt = sig.Sign(r);
try {
const res = await axios.request({
url: options.url,
method: options.method,
headers: opt.headers,
data: body,
});
return res.data;
} catch (e) {
this.logger.error("华为云接口请求出错:", e?.response?.data);
const error = new Error(e?.response?.data.message);
error.code = e?.response?.code;
throw error;
}
}
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3BsdWdpbnMvcGx1Z2luLWh1YXdlaS9saWIvY2xpZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsY0FBYyxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBRXJELE9BQU8sS0FBSyxNQUFNLE9BQU8sQ0FBQztBQUMxQixPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFRekMsTUFBTSxPQUFPLGVBQWU7SUFDMUIsTUFBTSxDQUFlO0lBQ3JCLFlBQVksTUFBb0I7UUFDOUIsSUFBSSxDQUFDLE1BQU0sR0FBRyxNQUFNLENBQUM7SUFDdkIsQ0FBQztJQUNELEtBQUssQ0FBQyxPQUFPLENBQUMsT0FBMEI7UUFDdEMsTUFBTSxHQUFHLEdBQUcsSUFBSSxNQUFNLENBQ3BCLElBQUksQ0FBQyxNQUFNLENBQUMsV0FBVyxFQUN2QixJQUFJLENBQUMsTUFBTSxDQUFDLGVBQWUsQ0FDNUIsQ0FBQztRQUVGLDRGQUE0RjtRQUM1Riw0RUFBNEU7UUFDNUUsbUJBQW1CO1FBQ25CLGtCQUFrQjtRQUNsQixxQ0FBcUM7UUFDckMsSUFBSSxJQUFJLEdBQUcsU0FBUyxDQUFDO1FBQ3JCLElBQUksT0FBTyxDQUFDLElBQUksRUFBRTtZQUNoQixJQUFJLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7U0FDckM7UUFDRCxNQUFNLENBQUMsR0FBRyxJQUFJLGNBQWMsQ0FDMUIsT0FBTyxDQUFDLE1BQU0sRUFDZCxPQUFPLENBQUMsR0FBRyxFQUNYLE9BQU8sQ0FBQyxPQUFPLEVBQ2YsSUFBSSxDQUNMLENBQUM7UUFDRixzSUFBc0k7UUFDdEksQ0FBQyxDQUFDLE9BQU8sR0FBRyxFQUFFLGNBQWMsRUFBRSxrQkFBa0IsRUFBRSxDQUFDO1FBQ25ELDRKQUE0SjtRQUM1SixtQkFBbUI7UUFDbkIsTUFBTSxHQUFHLEdBQUcsR0FBRyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUN4QixJQUFJO1lBQ0YsTUFBTSxHQUFHLEdBQUcsTUFBTSxLQUFLLENBQUMsT0FBTyxDQUFDO2dCQUM5QixHQUFHLEVBQUUsT0FBTyxDQUFDLEdBQUc7Z0JBQ2hCLE1BQU0sRUFBRSxPQUFPLENBQUMsTUFBTTtnQkFDdEIsT0FBTyxFQUFFLEdBQUcsQ0FBQyxPQUFPO2dCQUNwQixJQUFJLEVBQUUsSUFBSTthQUNYLENBQUMsQ0FBQztZQUNILE9BQU8sR0FBRyxDQUFDLElBQUksQ0FBQztTQUNqQjtRQUFDLE9BQU8sQ0FBTSxFQUFFO1lBQ2YsTUFBTSxDQUFDLEtBQUssQ0FBQyxZQUFZLEVBQUUsQ0FBQyxFQUFFLFFBQVEsRUFBRSxJQUFJLENBQUMsQ0FBQztZQUM5QyxNQUFNLEtBQUssR0FBUSxJQUFJLEtBQUssQ0FBQyxDQUFDLEVBQUUsUUFBUSxFQUFFLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQztZQUN4RCxLQUFLLENBQUMsSUFBSSxHQUFHLENBQUMsRUFBRSxRQUFRLEVBQUUsSUFBSSxDQUFDO1lBQy9CLE1BQU0sS0FBSyxDQUFDO1NBQ2I7SUFDSCxDQUFDO0NBQ0YifQ==

View File

@@ -0,0 +1,20 @@
export declare class SigHttpRequest {
method: string;
host: string;
uri: string;
query: any;
headers: any;
body: string;
constructor(method: any, url: any, headers: any, body: any);
}
export declare class Signer {
Key: string;
Secret: string;
constructor(Key: any, Secret: any);
Sign(r: any): {
hostname: any;
path: string;
method: any;
headers: any;
};
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,41 @@
{
"compileOnSave": true,
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"inlineSourceMap":true,
"noImplicitThis": true,
"noUnusedLocals": true,
"stripInternal": true,
"skipLibCheck": true,
"pretty": true,
"declaration": true,
"forceConsistentCasingInFileNames": true,
"typeRoots": [ "./typings", "./node_modules/@types"],
"outDir": "dist",
"rootDir": "src",
"composite": true,
"useDefineForClassFields": true,
"strict": false,
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": false,
"lib": ["ESNext", "DOM"],
},
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.js",
"src/**/*.json"
],
"exclude": [
"*.ts",
"dist",
"node_modules",
"test"
],
}

View File

@@ -0,0 +1,23 @@
{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier"
],
"env": {
"mocha": true
},
"rules": {
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
// "no-unused-expressions": "off",
"max-len": [0, 160, 2, { "ignoreUrls": true }]
}
}

28
packages/libs/lib-k8s/.gitignore vendored Normal file
View File

@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
src/test/user.secret.ts
src/**/*.js

View File

@@ -0,0 +1,7 @@
{
"printWidth": 160,
"bracketSpacing": true,
"singleQuote": true,
"trailingComma": "es5",
"arrowParens": "avoid"
}

View File

@@ -0,0 +1,15 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.1](https://github.com/certd/certd/compare/v1.22.0...v1.22.1) (2024-07-20)
**Note:** Version bump only for package @certd/lib-k8s
# [1.22.0](https://github.com/certd/certd/compare/v1.21.2...v1.22.0) (2024-07-19)
### Features
* 升级midway支持esm ([485e603](https://github.com/certd/certd/commit/485e603b5165c28bc08694997726eaf2a585ebe7))
* 支持postgresql ([3b19bfb](https://github.com/certd/certd/commit/3b19bfb4291e89064b3b407a80dae092d54747d5))

View File

@@ -0,0 +1,16 @@
# Vue 3 + TypeScript + Vite
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
## Recommended IDE Setup
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
## Type Support For `.vue` Imports in TS
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).

View File

@@ -0,0 +1,96 @@
import * as fs from "fs";
import * as path from "path";
// https://gist.github.com/lovasoa/8691344
async function* walk(dir) {
for await (const d of await fs.promises.opendir(dir)) {
const entry = path.join(dir, d.name);
if (d.isDirectory()) {
yield* walk(entry);
} else if (d.isFile()) {
yield entry;
}
}
}
function resolveImportPath(sourceFile, importPath, options) {
const sourceFileAbs = path.resolve(process.cwd(), sourceFile);
const root = path.dirname(sourceFileAbs);
const { moduleFilter = defaultModuleFilter } = options;
if (moduleFilter(importPath)) {
const importPathAbs = path.resolve(root, importPath);
let possiblePath = [path.resolve(importPathAbs, "./index.ts"), path.resolve(importPathAbs, "./index.js"), importPathAbs + ".ts", importPathAbs + ".js"];
if (possiblePath.length) {
for (let i = 0; i < possiblePath.length; i++) {
let entry = possiblePath[i];
if (fs.existsSync(entry)) {
const resolved = path.relative(root, entry.replace(/\.ts$/, ".js"));
if (!resolved.startsWith(".")) {
return "./" + resolved;
}
return resolved;
}
}
}
}
return null;
}
function replace(filePath, outFilePath, options) {
const code = fs.readFileSync(filePath).toString();
const newCode = code.replace(/(import|export) (.+?) from ('[^\n']+'|"[^\n"]+");/gs, function (found, action, imported, from) {
const importPath = from.slice(1, -1);
let resolvedPath = resolveImportPath(filePath, importPath, options);
if (resolvedPath) {
resolvedPath = resolvedPath.replaceAll("\\", "/");
console.log("\t", importPath, resolvedPath);
return `${action} ${imported} from "${resolvedPath}";`;
}
return found;
});
if (code !== newCode) {
fs.writeFileSync(outFilePath, newCode);
}
}
// Then, use it with a simple async for loop
async function run(srcDir, options = defaultOptions) {
const { sourceFileFilter = defaultSourceFileFilter } = options;
for await (const entry of walk(srcDir)) {
if (sourceFileFilter(entry)) {
console.log(entry);
replace(entry, entry, options);
}
}
}
const defaultSourceFileFilter = function (sourceFilePath) {
return /\.(js|ts)$/.test(sourceFilePath) && !/node_modules/.test(sourceFilePath);
};
const defaultModuleFilter = function (importedModule) {
return !path.isAbsolute(importedModule) && !importedModule.startsWith("@") && !importedModule.endsWith(".js");
};
const defaultOptions = {
sourceFileFilter: defaultSourceFileFilter,
moduleFilter: defaultModuleFilter,
};
// Switch this to test on one file or directly run on a directory.
const DEBUG = false;
if (DEBUG) {
replace("./src/index.ts", "./out.ts", defaultOptions);
} else {
await run("./src/", defaultOptions);
}

View File

@@ -1,18 +1,14 @@
{
"name": "@certd/plugin-util",
"name": "@certd/lib-k8s",
"private": false,
"version": "1.20.16",
"main": "./src/index.ts",
"module": "./src/index.ts",
"types": "./src/index.ts",
"publishConfig": {
"main": "./dist/bundle.js",
"module": "./dist/bundle.mjs",
"types": "./dist/d/index.d.ts"
},
"version": "1.22.1",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"dev": "vite",
"build": "rollup -c",
"build": "tsc --skipLibCheck",
"build3": "rollup -c",
"build2": "vue-tsc --noEmit && vite build",
"preview": "vite preview"
},
@@ -21,14 +17,13 @@
"shelljs": "^0.8.5"
},
"devDependencies": {
"@certd/pipeline": "workspace:^1.20.16",
"@certd/pipeline": "^1.22.1",
"@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.0.0",
"@types/chai": "^4.3.3",
"@types/lodash": "^4.14.186",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"eslint": "^8.24.0",
@@ -43,5 +38,5 @@
"tslib": "^2.5.2",
"typescript": "^4.8.4"
},
"gitHead": "a31f1c7f5e71fa946de9bf0283e11d6ce049b3e9"
"gitHead": "47fe3d5826661f678d081ab53e67c847a3239d88"
}

View File

@@ -0,0 +1 @@
export * from "./lib/k8s.client.js";

View File

@@ -1,8 +1,9 @@
import kubernetesClient from "kubernetes-client";
import dns from "dns";
import { logger } from "@certd/pipeline";
import kubernetesClient from 'kubernetes-client';
//@ts-ignore
import dns from 'dns';
import { logger } from '@certd/pipeline';
// @ts-ignore
//@ts-ignore
const { KubeConfig, Client, Request } = kubernetesClient;
export class K8sClient {
@@ -23,7 +24,7 @@ export class K8sClient {
}
const backend = new Request(reqOpts);
this.client = new Client({ backend, version: "1.13" });
this.client = new Client({ backend, version: '1.13' });
}
/**
@@ -32,9 +33,9 @@ export class K8sClient {
*/
setLookup(localRecords: { [key: string]: { ip: string } }) {
this.lookup = (hostnameReq: any, options: any, callback: any) => {
logger.info("custom lookup", hostnameReq, localRecords);
logger.info('custom lookup', hostnameReq, localRecords);
if (localRecords[hostnameReq]) {
logger.info("local record", hostnameReq, localRecords[hostnameReq]);
logger.info('local record', hostnameReq, localRecords[hostnameReq]);
callback(null, localRecords[hostnameReq].ip, 4);
} else {
dns.lookup(hostnameReq, options, callback);
@@ -49,7 +50,7 @@ export class K8sClient {
* @returns secretsList
*/
async getSecret(opts: { namespace: string }) {
const namespace = opts.namespace || "default";
const namespace = opts.namespace || 'default';
return await this.client.api.v1.namespaces(namespace).secrets.get();
}
@@ -59,19 +60,19 @@ export class K8sClient {
* @returns {Promise<*>}
*/
async createSecret(opts: any) {
const namespace = opts.namespace || "default";
const namespace = opts.namespace || 'default';
const created = await this.client.api.v1.namespaces(namespace).secrets.post({
body: opts.body,
});
logger.info("new secrets:", created);
logger.info('new secrets:', created);
return created;
}
async updateSecret(opts: any) {
const namespace = opts.namespace || "default";
const namespace = opts.namespace || 'default';
const secretName = opts.secretName;
if (secretName == null) {
throw new Error("secretName 不能为空");
throw new Error('secretName 不能为空');
}
return await this.client.api.v1.namespaces(namespace).secrets(secretName).put({
body: opts.body,
@@ -79,10 +80,10 @@ export class K8sClient {
}
async patchSecret(opts: any) {
const namespace = opts.namespace || "default";
const namespace = opts.namespace || 'default';
const secretName = opts.secretName;
if (secretName == null) {
throw new Error("secretName 不能为空");
throw new Error('secretName 不能为空');
}
return await this.client.api.v1.namespaces(namespace).secrets(secretName).patch({
body: opts.body,
@@ -90,24 +91,24 @@ export class K8sClient {
}
async getIngressList(opts: any) {
const namespace = opts.namespace || "default";
const namespace = opts.namespace || 'default';
return await this.client.apis.extensions.v1beta1.namespaces(namespace).ingresses.get();
}
async getIngress(opts: any) {
const namespace = opts.namespace || "default";
const namespace = opts.namespace || 'default';
const ingressName = opts.ingressName;
if (!ingressName) {
throw new Error("ingressName 不能为空");
throw new Error('ingressName 不能为空');
}
return await this.client.apis.extensions.v1beta1.namespaces(namespace).ingresses(ingressName).get();
}
async patchIngress(opts: any) {
const namespace = opts.namespace || "default";
const namespace = opts.namespace || 'default';
const ingressName = opts.ingressName;
if (!ingressName) {
throw new Error("ingressName 不能为空");
throw new Error('ingressName 不能为空');
}
return await this.client.apis.extensions.v1beta1.namespaces(namespace).ingresses(ingressName).patch({
body: opts.body,

View File

@@ -0,0 +1,41 @@
{
"compileOnSave": true,
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"inlineSourceMap":true,
"noImplicitThis": true,
"noUnusedLocals": true,
"stripInternal": true,
"skipLibCheck": true,
"pretty": true,
"declaration": true,
"forceConsistentCasingInFileNames": true,
"typeRoots": [ "./typings", "./node_modules/@types"],
"outDir": "dist",
"rootDir": "src",
"composite": true,
"useDefineForClassFields": true,
"strict": false,
// "sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"lib": ["ESNext", "DOM"],
},
"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.json"
],
"exclude": [
"*.js",
"*.ts",
"dist",
"node_modules",
"src/test"
],
}

View File

@@ -0,0 +1,16 @@
logs/
npm-debug.log
yarn-error.log
node_modules/
package-lock.json
yarn.lock
coverage/
!dist/
.idea/
run/
.DS_Store
*.sw*
*.un~
.tsbuildinfo
.tsbuildinfo.*
/data/db.sqlite

View File

@@ -0,0 +1,11 @@
# 🎨 editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

View File

@@ -0,0 +1,7 @@
{
"extends": "./node_modules/mwts/",
"ignorePatterns": ["node_modules", "dist", "test", "jest.config.js", "typings"],
"env": {
"jest": true
}
}

Some files were not shown because too many files have changed in this diff Show More