perf: 插件贡献文档及示例

pull/68/head
xiaojunnuo 2024-03-22 00:50:02 +08:00
parent d9efc3d4d8
commit 72fb20abf3
43 changed files with 890 additions and 22 deletions

View File

@ -23,6 +23,7 @@
"qs": "^6.11.2"
},
"devDependencies": {
"prettier": "^2.8.8",
"@certd/acme-client": "^1.20.5",
"@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-json": "^6.0.0",

View File

@ -23,6 +23,7 @@
"node-forge": "^0.10.0"
},
"devDependencies": {
"prettier": "^2.8.8",
"@certd/acme-client": "^1.20.5",
"@certd/pipeline": "^1.20.5",
"@certd/plugin-cert": "^1.20.5",

View File

@ -17,7 +17,9 @@
"preview": "vite preview"
},
"devDependencies": {
"prettier": "^2.8.8",
"@certd/pipeline": "^1.20.5",
"@certd/plugin-center": "^1.20.5",
"@certd/plugin-aliyun": "^1.20.5",
"@certd/plugin-cert": "^1.20.5",
"@certd/plugin-host": "^1.20.5",

View File

@ -3,3 +3,4 @@ export * from "@certd/plugin-aliyun";
export * from "@certd/plugin-tencent";
export * from "@certd/plugin-host";
export * from "@certd/plugin-huawei";
export * from "@certd/plugin-center";

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 }]
}
}

View File

@ -0,0 +1,26 @@
# 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?
test/user.secret.ts

View File

@ -0,0 +1,5 @@
{
"extension": ["ts"],
"spec": "test/**/*.test.ts",
"require": "ts-node/register"
}

View File

@ -0,0 +1,2 @@
node_modules
src

View File

@ -0,0 +1,3 @@
{
"printWidth": 160
}

View File

@ -0,0 +1,82 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.20.5](https://github.com/certd/certd/compare/v1.20.2...v1.20.5) (2024-03-11)
### Bug Fixes
* 修复腾讯云cdn部署无法选择端点的bug ([154409b](https://github.com/certd/certd/commit/154409b1dfee3ea1caae740ad9c1f99a6e7a9814))
## [1.20.2](https://github.com/certd/certd/compare/v1.2.1...v1.20.2) (2024-02-28)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.2.1](https://github.com/certd/certd/compare/v1.2.0...v1.2.1) (2023-12-12)
**Note:** Version bump only for package @certd/plugin-tencent
**Note:** Version bump only for package @certd/plugin-tencent
# [1.2.0](https://github.com/certd/certd/compare/v1.1.6...v1.2.0) (2023-10-27)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
### Bug Fixes
* 修复上传证书到腾讯云失败的bug ([e950322](https://github.com/certd/certd/commit/e950322232e19d1263b8552eefa5b0150fd7864e))
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
### Performance Improvements
* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.1.1](https://github.com/certd/certd/compare/v1.1.0...v1.1.1) (2023-06-28)
**Note:** Version bump only for package @certd/plugin-tencent
# [1.1.0](https://github.com/certd/certd/compare/v1.0.6...v1.1.0) (2023-06-28)
### Features
* save files ([671d273](https://github.com/certd/certd/commit/671d273e2f9136d16896536b0ca127cf372f1619))
## [1.0.6](https://github.com/certd/certd/compare/v1.0.5...v1.0.6) (2023-05-25)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.0.5](https://github.com/certd/certd/compare/v1.0.4...v1.0.5) (2023-05-25)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.0.4](https://github.com/certd/certd/compare/v1.0.3...v1.0.4) (2023-05-25)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.0.3](https://github.com/certd/certd/compare/v1.0.2...v1.0.3) (2023-05-25)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.0.2](https://github.com/certd/certd/compare/v1.0.1...v1.0.2) (2023-05-24)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.0.1](https://github.com/certd/certd/compare/v1.0.0...v1.0.1) (2023-05-24)
**Note:** Version bump only for package @certd/plugin-tencent

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,58 @@
{
"name": "@certd/plugin-builder",
"private": false,
"version": "1.20.5",
"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"
},
"scripts": {
"dev": "vite",
"build": "rollup -c",
"build2": "vue-tsc --noEmit && vite build",
"preview": "vite preview"
},
"dependencies": {
"@certd/pipeline": "^1.20.5",
"@certd/plugin-cert": "^1.20.5",
"@certd/plugin-util": "^1.20.5"
},
"devDependencies": {
"prettier": "^2.8.8",
"@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",
"@types/mocha": "^10.0.0",
"@types/node-forge": "^1.3.0",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"axios": "^0.21.1",
"chai": "^4.3.6",
"dayjs": "^1.9.7",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"lodash": "^4.17.20",
"log4js": "^6.7.1",
"mocha": "^10.1.0",
"prettier": "3.0.1",
"rollup": "^3.7.4",
"rollup-plugin-visualizer": "^5.8.2",
"ts-node": "^10.9.1",
"tslib": "^2.5.2",
"typescript": "^4.8.4",
"vite": "^3.1.0",
"vue-tsc": "^0.38.9"
},
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
}

View File

@ -0,0 +1,43 @@
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

@ -0,0 +1,3 @@
export * from "./access";
export * from "./plugin";
export * from "./dns-provider";

View File

@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"experimentalDecorators": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue","test/**/*.ts"],
}

View File

@ -0,0 +1,56 @@
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: {
lib: {
entry: "src/index.ts",
name: "pipeline",
},
rollupOptions: {
plugins: [
// @ts-ignore
visualizer(),
// @ts-ignore
typescript({
target: "esnext",
rootDir: "src",
declaration: true,
declarationDir: "dist/d",
exclude: ["./node_modules/**", "./src/**/*.vue"],
allowSyntheticDefaultImports: true,
}),
],
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",
],
output: {
globals: {
vue: "Vue",
lodash: "_",
dayjs: "dayjs",
"@certd/plugin-cert": "CertdPluginCert",
"@certd/acme-client": "CertdAcmeClient",
"@certd/pipeline": "CertdPluginPipeline",
"@certd/plugin-aliyun": "CertdPluginAliyun",
"@certd/plugin-host": "CertdPluginHost",
"@certd/plugin-huawei": "CertdPluginHuawei",
"@certd/plugin-util": "CertdPluginUtil",
},
},
},
},
});

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 }]
}
}

View File

@ -0,0 +1,26 @@
# 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?
test/user.secret.ts

View File

@ -0,0 +1,5 @@
{
"extension": ["ts"],
"spec": "test/**/*.test.ts",
"require": "ts-node/register"
}

View File

@ -0,0 +1,2 @@
node_modules
src

View File

@ -0,0 +1,3 @@
{
"printWidth": 160
}

View File

@ -0,0 +1,82 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.20.5](https://github.com/certd/certd/compare/v1.20.2...v1.20.5) (2024-03-11)
### Bug Fixes
* 修复腾讯云cdn部署无法选择端点的bug ([154409b](https://github.com/certd/certd/commit/154409b1dfee3ea1caae740ad9c1f99a6e7a9814))
## [1.20.2](https://github.com/certd/certd/compare/v1.2.1...v1.20.2) (2024-02-28)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.2.1](https://github.com/certd/certd/compare/v1.2.0...v1.2.1) (2023-12-12)
**Note:** Version bump only for package @certd/plugin-tencent
**Note:** Version bump only for package @certd/plugin-tencent
# [1.2.0](https://github.com/certd/certd/compare/v1.1.6...v1.2.0) (2023-10-27)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
### Bug Fixes
* 修复上传证书到腾讯云失败的bug ([e950322](https://github.com/certd/certd/commit/e950322232e19d1263b8552eefa5b0150fd7864e))
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
### Performance Improvements
* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.1.1](https://github.com/certd/certd/compare/v1.1.0...v1.1.1) (2023-06-28)
**Note:** Version bump only for package @certd/plugin-tencent
# [1.1.0](https://github.com/certd/certd/compare/v1.0.6...v1.1.0) (2023-06-28)
### Features
* save files ([671d273](https://github.com/certd/certd/commit/671d273e2f9136d16896536b0ca127cf372f1619))
## [1.0.6](https://github.com/certd/certd/compare/v1.0.5...v1.0.6) (2023-05-25)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.0.5](https://github.com/certd/certd/compare/v1.0.4...v1.0.5) (2023-05-25)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.0.4](https://github.com/certd/certd/compare/v1.0.3...v1.0.4) (2023-05-25)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.0.3](https://github.com/certd/certd/compare/v1.0.2...v1.0.3) (2023-05-25)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.0.2](https://github.com/certd/certd/compare/v1.0.1...v1.0.2) (2023-05-24)
**Note:** Version bump only for package @certd/plugin-tencent
## [1.0.1](https://github.com/certd/certd/compare/v1.0.0...v1.0.1) (2023-05-24)
**Note:** Version bump only for package @certd/plugin-tencent

View File

@ -0,0 +1,18 @@
# 贡献插件
## 1.复制demo作为你的根目录
比如你想做cloudflare的插件那么你可以复制demo目录将其命名成cloudflare。
## 2. access授权
如果这是一个新的平台它应该有授权方式比如accessKey accessSecret之类的
参考`demo/access.ts` 修改为你要做的平台的`access`
这样用户就可以在certd后台中创建这种授权凭证了
## 3. dns-provider
如果域名是这个平台进行解析的那么你需要实现dns-provider
参考`demo/dns-provider.ts` 修改为你要做的平台的`dns-provider`
## 4. deploy-plugin
如果这个平台有需要部署证书的地方
参考`demo/deploy-plugin.ts` 修改为你要做的平台的`deploy-plugin`

View File

@ -0,0 +1,2 @@
//@ts-ignore
DYNAMIC_IMPORT_SCRIPT

View File

@ -0,0 +1,57 @@
{
"name": "@certd/plugin-center",
"private": false,
"version": "1.20.5",
"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"
},
"scripts": {
"dev": "vite",
"build": "rollup -c",
"build2": "vue-tsc --noEmit && vite build",
"preview": "vite preview"
},
"dependencies": {
"@certd/pipeline": "^1.20.5",
"@certd/plugin-cert": "^1.20.5",
"@certd/plugin-util": "^1.20.5",
"@rollup/plugin-dynamic-import-vars": "^2.1.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.0.0",
"@types/chai": "^4.3.3",
"@types/lodash": "^4.14.186",
"@types/mocha": "^10.0.0",
"@types/node-forge": "^1.3.0",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"axios": "^0.21.1",
"chai": "^4.3.6",
"dayjs": "^1.9.7",
"eslint": "^8.24.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"lodash": "^4.17.20",
"log4js": "^6.7.1",
"mocha": "^10.1.0",
"prettier": "^2.8.8",
"rollup": "^3.7.4",
"rollup-plugin-visualizer": "^5.8.2",
"ts-node": "^10.9.1",
"tslib": "^2.5.2",
"typescript": "^4.8.4"
},
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
}

View File

@ -0,0 +1,79 @@
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");
const dynamicImportVars =require ('@rollup/plugin-dynamic-import-vars');
const replace =require( '@rollup/plugin-replace')
const path = require("path")
const fs = require("fs")
function dynamicImport(directory) {
function readFilesRecursively(directory) {
let filePaths = [];
const files = fs.readdirSync(directory);
files.forEach(file => {
const filePath = directory+"/"+file;
const stats = fs.statSync(filePath);
if (stats.isDirectory()) {
filePaths = filePaths.concat(readFilesRecursively(filePath)); // Recursively read subdirectory and concatenate the results
} else if(filePath.endsWith(".ts")) {
filePaths.push(filePath); // Add file path to the array
}
});
return filePaths;
}
const files = readFilesRecursively(directory);
console.log("files",files)
return files.filter(file=>file.indexOf("/index.ts")<0).map(file => `import './${file}';`).join('\n');
}
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","./dist/**"],
allowSyntheticDefaultImports: true,
}),
dynamicImportVars({
// options
}),
replace({
'DYNAMIC_IMPORT_SCRIPT': dynamicImport("./src") // 替换成你的目录路径
}),
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

@ -0,0 +1,42 @@
import { IsAccess, AccessInput } from "@certd/pipeline";
/**
*
* certd
*/
@IsAccess({
name: "demo",
title: "授权插件示例",
desc: "",
})
export class DemoAccess {
/**
*
*/
@AccessInput({
title: "密钥Id",
component: {
placeholder: "demoKeyId",
},
required: true,
})
demoKeyId = "";
/**
*
*/
@AccessInput({
//标题
title: "密钥串",
component: {
//input组件的placeholder
placeholder: "demoKeySecret",
},
//是否必填
required: true,
})
//属性名称
demoKeySecret = "";
}
new DemoAccess();

View File

@ -0,0 +1,79 @@
import _ from "lodash";
import { CreateRecordOptions, IDnsProvider, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
import { Autowire, ILogger } from "@certd/pipeline";
import { DemoAccess } from "./access";
// TODO 这里注册一个dnsProvider
@IsDnsProvider({
//注意这里name要跟access的name一致
name: "demo",
title: "Dns提供商Demo",
desc: "demo dns provider示例",
accessType: "demo",
})
export class DemoDnsProvider implements IDnsProvider {
@Autowire()
access!: DemoAccess;
@Autowire()
logger!: ILogger;
async onInstance() {
const access: any = this.access;
this.logger.debug("access",access)
//初始化的操作
//...
}
async getDomainList():Promise<any[]> {
// TODO 这里你要实现一个获取域名列表的方法
const access = this.access
this.logger.debug("access",access)
return []
}
async matchDomain(dnsRecord: string):Promise<any> {
const domainList = await this.getDomainList();
let domainRecord = null;
for (const item of domainList) {
//TODO 根据域名去匹配账户中是否有该域名, 这里不一定是item.name 具体要看你要实现的平台的接口而定
if (_.endsWith(dnsRecord + ".", item.name)) {
domainRecord = item;
break;
}
}
if (!domainRecord) {
this.logger.info("账户中域名列表:",domainList)
this.logger.error("找不到域名,请确认账户中是否真的有此域名")
throw new Error("can not find Domain:"+dnsRecord);
}
return domainRecord;
}
async createRecord(options: CreateRecordOptions): Promise<any> {
const { fullRecord, value, type } = options;
this.logger.info("添加域名解析:", fullRecord, value,type);
//先确定账户中是否有该域名
const domainRecord = await this.matchDomain(fullRecord);
this.logger.debug("matchDomain:",domainRecord)
//TODO 然后调用接口创建txt类型的dns解析记录
// .. 这里调用对应平台的后台接口
const access = this.access
this.logger.debug("access",access)
}
async removeRecord(options: RemoveRecordOptions): Promise<any> {
const { fullRecord, value, record } = options;
this.logger.info("删除域名解析:", fullRecord, value,record);
//TODO 这里调用删除txt dns解析记录接口
const access = this.access
this.logger.debug("access",access)
this.logger.info("删除域名解析成功:", fullRecord, value);
}
}
//TODO 实例化这个provider将其自动注册到系统中
new DemoDnsProvider();

View File

@ -0,0 +1,3 @@
export * from './dns-provider'
export * from './plugin-test'
export * from './access'

View File

@ -0,0 +1,87 @@
import { AbstractTaskPlugin, IAccessService, ILogger, IsTaskPlugin, RunStrategy, TaskInput } from "@certd/pipeline";
import { CertInfo, CertReader } from "@certd/plugin-cert";
@IsTaskPlugin({
name: "demoTest",
title: "Demo测试插件",
default: {
strategy: {
runStrategy: RunStrategy.SkipWhenSucceed,
},
},
})
export class DemoTestPlugin extends AbstractTaskPlugin {
//测试参数
@TaskInput({
title: "属性示例",
})
text!: string;
//测试参数
@TaskInput({
title: "选择框",
component:{
name:"a-select",
options:[
{value:"1",label:"选项1"},
{value:"2",label:"选项2"},
]
}
})
select!: string;
//测试参数
@TaskInput({
title: "switch",
component:{
name:"a-switch",
}
})
switch!: boolean;
//证书选择,此项必须要有
@TaskInput({
title: "域名证书",
helper: "请选择前置任务输出的域名证书",
component: {
name: "pi-output-selector",
},
required: true,
})
cert!: CertInfo;
//授权选择框
@TaskInput({
title: "demo授权",
helper: "demoAccess授权",
component: {
name: "pi-access-selector",
type: "demoAccess",
},
rules: [{ required: true, message: "此项必填" }],
})
accessId!: string;
accessService!: IAccessService;
logger!: ILogger;
async onInstance() {
this.accessService = this.ctx.accessService;
this.logger = this.ctx.logger;
}
async execute(): Promise<void> {
const { select, text, cert, accessId } = this;
const certReader = new CertReader(cert);
const access = await this.accessService.getById(accessId);
this.logger.debug("access",access)
this.logger.debug("certReader",certReader)
this.logger.info("DemoTestPlugin execute");
this.logger.info( "text:", text);
this.logger.info( "select:", select);
this.logger.info( "switch:", this.switch);
this.logger.info( "授权id:", accessId);
//TODO 这里实现你要部署的执行方法
}
}
//TODO 这里实例化插件,进行注册
new DemoTestPlugin();

View File

@ -0,0 +1 @@
export * from "./demo"

View File

@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"experimentalDecorators": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue","test/**/*.ts"],
}

View File

@ -23,6 +23,7 @@
"node-forge": "^0.10.0"
},
"devDependencies": {
"prettier": "^2.8.8",
"@alicloud/cs20151215": "^3.0.3",
"@alicloud/openapi-client": "^0.4.0",
"@alicloud/pop-core": "^1.7.10",

View File

@ -22,9 +22,7 @@
"ssh2": "^0.8.9"
},
"devDependencies": {
"@alicloud/cs20151215": "^3.0.3",
"@alicloud/openapi-client": "^0.4.0",
"@alicloud/pop-core": "^1.7.10",
"prettier": "^2.8.8",
"@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",

View File

@ -27,9 +27,6 @@
"node-forge": "^0.10.0"
},
"devDependencies": {
"@alicloud/cs20151215": "^3.0.3",
"@alicloud/openapi-client": "^0.4.0",
"@alicloud/pop-core": "^1.7.10",
"@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
@ -49,7 +46,7 @@
"eslint-plugin-prettier": "^4.2.1",
"log4js": "^6.7.1",
"mocha": "^10.1.0",
"prettier": "3.0.1",
"prettier": "^2.8.8",
"rollup": "^3.7.4",
"rollup-plugin-visualizer": "^5.8.2",
"ts-node": "^10.9.1",

View File

@ -23,9 +23,7 @@
"tencentcloud-sdk-nodejs": "^4.0.44"
},
"devDependencies": {
"@alicloud/cs20151215": "^3.0.3",
"@alicloud/openapi-client": "^0.4.0",
"@alicloud/pop-core": "^1.7.10",
"prettier": "^2.8.8",
"@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",

View File

@ -21,6 +21,7 @@
"shelljs": "^0.8.5"
},
"devDependencies": {
"prettier": "^2.8.8",
"@certd/pipeline": "^1.20.5",
"@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-json": "^6.0.0",
@ -40,9 +41,7 @@
"rollup-plugin-visualizer": "^5.8.2",
"ts-node": "^10.9.1",
"tslib": "^2.5.2",
"typescript": "^4.8.4",
"vite": "^3.1.0",
"vue-tsc": "^0.38.9"
"typescript": "^4.8.4"
},
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
}

View File

@ -93,7 +93,7 @@
"less-loader": "^11.1.3",
"lint-staged": "^13.2.3",
"postcss": "^8.4.27",
"prettier": "3.0.1",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"rimraf": "^5.0.1",
"rollup": "^3.27.2",

View File

@ -17,6 +17,7 @@
import { defineComponent, reactive, ref, watch } from "vue";
import * as api from "../api";
import CertAccessModal from "./access/index.vue";
import { GetProviderDefineByAccessType } from "../api";
export default defineComponent({
name: "PiAccessSelector",

View File

@ -47,3 +47,11 @@ export function GetProviderDefine(type: string) {
params: { type }
});
}
export function GetProviderDefineByAccessType(type: string) {
return request({
url: apiPrefix + "/defineByAccessType",
method: "post",
params: { type }
});
}

View File

@ -64,6 +64,7 @@
"typeorm": "^0.3.11"
},
"devDependencies": {
"prettier": "^2.8.8",
"@midwayjs/luckyeye": "^1.1.0",
"@midwayjs/mock": "^3.9.0",
"@midwayjs/mwcc": "^0.8.0",

View File

@ -62,8 +62,8 @@ export class AccessController extends CrudController<AccessService> {
@Post('/define', { summary: Constants.per.authOnly })
async define(@Query('type') type) {
const provider = this.service.getDefineByType(type);
return this.ok(provider);
const access = this.service.getDefineByType(type);
return this.ok(access);
}
@Post('/accessTypeDict', { summary: Constants.per.authOnly })

View File

@ -1,12 +1,9 @@
import { Provide, Scope, ScopeEnum } from "@midwayjs/decorator";
import { Provide, Scope, ScopeEnum } from '@midwayjs/decorator';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { BaseService } from '../../../basic/base-service';
import { AccessEntity } from '../entity/access';
import {
accessRegistry,
IAccessService,
} from '@certd/pipeline';
import { accessRegistry, IAccessService } from '@certd/pipeline';
/**
*
@ -38,7 +35,8 @@ export class AccessService
return accessRegistry.getDefineList();
}
getDefineByType(type) {
getDefineByType(type: string) {
return accessRegistry.getDefine(type);
}
}