mirror of
https://github.com/certd/certd.git
synced 2026-07-14 01:17:31 +08:00
refactor(plugins): 部分插件改用运行时导入依赖替代静态导入
将所有插件内的静态依赖导入改为通过access.importRuntime动态导入,并调整package.json依赖顺序
This commit is contained in:
@@ -41,8 +41,6 @@
|
|||||||
"lint1": "eslint --fix"
|
"lint1": "eslint --fix"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@azure/arm-dns": "^5.1.0",
|
|
||||||
"@azure/identity": "^4.13.1",
|
|
||||||
"@certd/acme-client": "^1.41.4",
|
"@certd/acme-client": "^1.41.4",
|
||||||
"@certd/basic": "^1.41.4",
|
"@certd/basic": "^1.41.4",
|
||||||
"@certd/commercial-core": "^1.41.4",
|
"@certd/commercial-core": "^1.41.4",
|
||||||
@@ -57,12 +55,6 @@
|
|||||||
"@certd/plugin-lib": "^1.41.4",
|
"@certd/plugin-lib": "^1.41.4",
|
||||||
"@certd/plugin-plus": "^1.41.4",
|
"@certd/plugin-plus": "^1.41.4",
|
||||||
"@certd/plus-core": "^1.41.4",
|
"@certd/plus-core": "^1.41.4",
|
||||||
"@google-cloud/dns": "^5.3.1",
|
|
||||||
"@google-cloud/publicca": "^1.3.0",
|
|
||||||
"@huaweicloud/huaweicloud-sdk-cdn": "3.1.185",
|
|
||||||
"@huaweicloud/huaweicloud-sdk-core": "3.1.185",
|
|
||||||
"@huaweicloud/huaweicloud-sdk-elb": "3.1.185",
|
|
||||||
"@huaweicloud/huaweicloud-sdk-iam": "3.1.185",
|
|
||||||
"@koa/cors": "^5.0.0",
|
"@koa/cors": "^5.0.0",
|
||||||
"@midwayjs/bootstrap": "3.20.11",
|
"@midwayjs/bootstrap": "3.20.11",
|
||||||
"@midwayjs/cache": "3.14.0",
|
"@midwayjs/cache": "3.14.0",
|
||||||
@@ -79,19 +71,14 @@
|
|||||||
"@peculiar/x509": "^1.11.0",
|
"@peculiar/x509": "^1.11.0",
|
||||||
"@simplewebauthn/browser": "^13.2.2",
|
"@simplewebauthn/browser": "^13.2.2",
|
||||||
"@simplewebauthn/server": "^13.2.3",
|
"@simplewebauthn/server": "^13.2.3",
|
||||||
"@ucloud-sdks/ucloud-sdk-js": "^0.2.4",
|
|
||||||
"@volcengine/openapi": "^1.28.1",
|
|
||||||
"@volcengine/tos-sdk": "^2.9.1",
|
|
||||||
"alipay-sdk": "^4.13.0",
|
"alipay-sdk": "^4.13.0",
|
||||||
"axios": "^1.9.0",
|
"axios": "^1.9.0",
|
||||||
"basic-ftp": "^5.0.5",
|
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"better-sqlite3": "^11.1.2",
|
"better-sqlite3": "^11.1.2",
|
||||||
"cache-manager": "^6.1.0",
|
"cache-manager": "^6.1.0",
|
||||||
"cron-parser": "^4.9.0",
|
"cron-parser": "^4.9.0",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"dayjs": "^1.11.7",
|
"dayjs": "^1.11.7",
|
||||||
"esdk-obs-nodejs": "^3.25.6",
|
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"glob": "^11.0.0",
|
"glob": "^11.0.0",
|
||||||
"https-proxy-agent": "^7.0.5",
|
"https-proxy-agent": "^7.0.5",
|
||||||
@@ -115,7 +102,6 @@
|
|||||||
"pg": "^8.12.0",
|
"pg": "^8.12.0",
|
||||||
"psl": "^1.15.0",
|
"psl": "^1.15.0",
|
||||||
"punycode.js": "^2.3.1",
|
"punycode.js": "^2.3.1",
|
||||||
"qiniu": "^7.12.0",
|
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"qs": "^6.13.1",
|
"qs": "^6.13.1",
|
||||||
"querystring": "^0.2.1",
|
"querystring": "^0.2.1",
|
||||||
@@ -148,7 +134,21 @@
|
|||||||
"@aws-sdk/client-sts": "^3.990.0",
|
"@aws-sdk/client-sts": "^3.990.0",
|
||||||
"ali-oss": "^6.21.0",
|
"ali-oss": "^6.21.0",
|
||||||
"tencentcloud-sdk-nodejs": "^4.1.112",
|
"tencentcloud-sdk-nodejs": "^4.1.112",
|
||||||
"cos-nodejs-sdk-v5": "^2.14.6"
|
"cos-nodejs-sdk-v5": "^2.14.6",
|
||||||
|
"@azure/arm-dns": "^5.1.0",
|
||||||
|
"@azure/identity": "^4.13.1",
|
||||||
|
"@huaweicloud/huaweicloud-sdk-cdn": "3.1.185",
|
||||||
|
"@huaweicloud/huaweicloud-sdk-core": "3.1.185",
|
||||||
|
"@huaweicloud/huaweicloud-sdk-elb": "3.1.185",
|
||||||
|
"@huaweicloud/huaweicloud-sdk-iam": "3.1.185",
|
||||||
|
"@ucloud-sdks/ucloud-sdk-js": "^0.2.4",
|
||||||
|
"@volcengine/openapi": "^1.28.1",
|
||||||
|
"@volcengine/tos-sdk": "^2.9.1",
|
||||||
|
"@google-cloud/dns": "^5.3.1",
|
||||||
|
"@google-cloud/publicca": "^1.3.0",
|
||||||
|
"basic-ftp": "^5.0.5",
|
||||||
|
"esdk-obs-nodejs": "^3.25.6",
|
||||||
|
"qiniu": "^7.12.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mwts": "^1.3.0",
|
"mwts": "^1.3.0",
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export class AzureAccess extends BaseAccess {
|
|||||||
this.ctx.logger.info("开始测试 Azure 认证...");
|
this.ctx.logger.info("开始测试 Azure 认证...");
|
||||||
|
|
||||||
// 1. 先测试身份认证,获取访问令牌
|
// 1. 先测试身份认证,获取访问令牌
|
||||||
const { ClientSecretCredential } = await import("@azure/identity");
|
const { ClientSecretCredential } = await this.importRuntime("@azure/identity");
|
||||||
|
|
||||||
const credential = new ClientSecretCredential(this.tenantId, this.clientId, this.clientSecret);
|
const credential = new ClientSecretCredential(this.tenantId, this.clientId, this.clientSecret);
|
||||||
|
|
||||||
@@ -88,8 +88,8 @@ export class AzureAccess extends BaseAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getDnsManagementClient() {
|
async getDnsManagementClient() {
|
||||||
const { DnsManagementClient } = await import("@azure/arm-dns");
|
const { DnsManagementClient } = await this.importRuntime("@azure/arm-dns");
|
||||||
const { ClientSecretCredential } = await import("@azure/identity");
|
const { ClientSecretCredential } = await this.importRuntime("@azure/identity");
|
||||||
|
|
||||||
const credential = new ClientSecretCredential(this.tenantId, this.clientId, this.clientSecret);
|
const credential = new ClientSecretCredential(this.tenantId, this.clientId, this.clientSecret);
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export class GoogleClient {
|
|||||||
}
|
}
|
||||||
async getEab() {
|
async getEab() {
|
||||||
// https://cloud.google.com/docs/authentication/api-keys-use#using-with-client-libs
|
// https://cloud.google.com/docs/authentication/api-keys-use#using-with-client-libs
|
||||||
const { v1 } = await import("@google-cloud/publicca");
|
const { v1 } = await this.access.importRuntime("@google-cloud/publicca");
|
||||||
// process.env.HTTPS_PROXY = "http://127.0.0.1:10811";
|
// process.env.HTTPS_PROXY = "http://127.0.0.1:10811";
|
||||||
const access = this.access;
|
const access = this.access;
|
||||||
if (!access.serviceAccountSecret) {
|
if (!access.serviceAccountSecret) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export class GoogleCloudDnsProvider extends AbstractDnsProvider<GoogleCloudDnsRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getGoogleDnsClient() {
|
private async getGoogleDnsClient() {
|
||||||
const { DNS } = await import("@google-cloud/dns");
|
const { DNS } = await this.importRuntime("@google-cloud/dns");
|
||||||
return new DNS({ credentials: this.credentials });
|
return new DNS({ credentials: this.credentials });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ export class HuaweiAccess extends BaseAccess {
|
|||||||
async getProjectList() {
|
async getProjectList() {
|
||||||
const endpoint = "https://iam.cn-north-4.myhuaweicloud.com";
|
const endpoint = "https://iam.cn-north-4.myhuaweicloud.com";
|
||||||
|
|
||||||
const { BasicCredentials } = await import("@huaweicloud/huaweicloud-sdk-core");
|
const { BasicCredentials } = await this.importRuntime("@huaweicloud/huaweicloud-sdk-core");
|
||||||
const iam = await import("@huaweicloud/huaweicloud-sdk-iam/v3/public-api.js");
|
const iam = await this.importRuntime("@huaweicloud/huaweicloud-sdk-iam/v3/public-api.js");
|
||||||
//恢复华为云把log4j的config改了的问题
|
//恢复华为云把log4j的config改了的问题
|
||||||
resetLogConfigure();
|
resetLogConfigure();
|
||||||
const credentials: any = new BasicCredentials().withAk(this.accessKeyId).withSk(this.accessKeySecret);
|
const credentials: any = new BasicCredentials().withAk(this.accessKeyId).withSk(this.accessKeySecret);
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ export class HauweiDeployCertToCDN extends AbstractTaskPlugin {
|
|||||||
|
|
||||||
async getCdnClient() {
|
async getCdnClient() {
|
||||||
const access = await this.getAccess<HuaweiAccess>(this.accessId);
|
const access = await this.getAccess<HuaweiAccess>(this.accessId);
|
||||||
const { BasicCredentials } = await import("@huaweicloud/huaweicloud-sdk-core");
|
const { BasicCredentials } = await this.importRuntime("@huaweicloud/huaweicloud-sdk-core");
|
||||||
const cdn = await import("@huaweicloud/huaweicloud-sdk-cdn/v2/public-api.js");
|
const cdn = await this.importRuntime("@huaweicloud/huaweicloud-sdk-cdn/v2/public-api.js");
|
||||||
//恢复华为云把log4j的config改了的问题
|
//恢复华为云把log4j的config改了的问题
|
||||||
resetLogConfigure();
|
resetLogConfigure();
|
||||||
const credentials = new BasicCredentials().withAk(access.accessKeyId).withSk(access.accessKeySecret);
|
const credentials = new BasicCredentials().withAk(access.accessKeyId).withSk(access.accessKeySecret);
|
||||||
|
|||||||
@@ -103,8 +103,8 @@ export class HauweiDeployCertToELB extends AbstractTaskPlugin {
|
|||||||
throw new Error("项目ID不能为空");
|
throw new Error("项目ID不能为空");
|
||||||
}
|
}
|
||||||
const access = await this.getAccess<HuaweiAccess>(this.accessId);
|
const access = await this.getAccess<HuaweiAccess>(this.accessId);
|
||||||
const { BasicCredentials } = await import("@huaweicloud/huaweicloud-sdk-core");
|
const { BasicCredentials } = await this.importRuntime("@huaweicloud/huaweicloud-sdk-core");
|
||||||
const elb = await import("@huaweicloud/huaweicloud-sdk-elb/v3/public-api.js");
|
const elb = await this.importRuntime("@huaweicloud/huaweicloud-sdk-elb/v3/public-api.js");
|
||||||
//恢复华为云把log4j的config改了的问题
|
//恢复华为云把log4j的config改了的问题
|
||||||
resetLogConfigure();
|
resetLogConfigure();
|
||||||
const projectArr = this.projectId.split("_");
|
const projectArr = this.projectId.split("_");
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export class HauweiDeployCertToOBS extends AbstractTaskPlugin {
|
|||||||
const regionStr = region ? `${region}.` : "cn-north-4.";
|
const regionStr = region ? `${region}.` : "cn-north-4.";
|
||||||
const bucketStr = bucket ? `${bucket}.` : "";
|
const bucketStr = bucket ? `${bucket}.` : "";
|
||||||
const access = await this.getAccess<HuaweiAccess>(this.accessId);
|
const access = await this.getAccess<HuaweiAccess>(this.accessId);
|
||||||
const sdk = await import("esdk-obs-nodejs");
|
const sdk = await this.importRuntime("esdk-obs-nodejs");
|
||||||
const obsClient = new sdk.default({
|
const obsClient = new sdk.default({
|
||||||
// 推荐通过环境变量获取AKSK,这里也可以使用其他外部引入方式传入,如果使用硬编码可能会存在泄露风险
|
// 推荐通过环境变量获取AKSK,这里也可以使用其他外部引入方式传入,如果使用硬编码可能会存在泄露风险
|
||||||
// 您可以登录访问管理控制台获取访问密钥AK/SK,获取方式请参见https://support.huaweicloud.com/usermanual-ca/ca_01_0003.html
|
// 您可以登录访问管理控制台获取访问密钥AK/SK,获取方式请参见https://support.huaweicloud.com/usermanual-ca/ca_01_0003.html
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ export class HauweiUploadToCCM extends AbstractTaskPlugin {
|
|||||||
|
|
||||||
async getCcmClient() {
|
async getCcmClient() {
|
||||||
const access = await this.getAccess<HuaweiAccess>(this.accessId);
|
const access = await this.getAccess<HuaweiAccess>(this.accessId);
|
||||||
const { BasicCredentials } = await import("@huaweicloud/huaweicloud-sdk-core");
|
const { BasicCredentials } = await this.importRuntime("@huaweicloud/huaweicloud-sdk-core");
|
||||||
const { ClientBuilder } = await import("@huaweicloud/huaweicloud-sdk-core/ClientBuilder.js");
|
const { ClientBuilder } = await this.importRuntime("@huaweicloud/huaweicloud-sdk-core/ClientBuilder.js");
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const { HuaweiCcmClient } = await import("./ccm-client.js");
|
const { HuaweiCcmClient } = await import("./ccm-client.js");
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export class FtpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async connect(callback: (client: FtpClient) => Promise<any>) {
|
async connect(callback: (client: FtpClient) => Promise<any>) {
|
||||||
const ftp = await import("basic-ftp");
|
const ftp = await this.access.importRuntime("basic-ftp");
|
||||||
const Client = ftp.Client;
|
const Client = ftp.Client;
|
||||||
const client = new Client();
|
const client = new Client();
|
||||||
client.ftp.verbose = true;
|
client.ftp.verbose = true;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export class QiniuClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async doRequest(url: string, method: string, body?: any) {
|
async doRequest(url: string, method: string, body?: any) {
|
||||||
const { generateAccessToken } = await import("qiniu/qiniu/util.js");
|
const { generateAccessToken } = await this.access.importRuntime("qiniu/qiniu/util.js");
|
||||||
const token = generateAccessToken(this.access, url);
|
const token = generateAccessToken(this.access, url);
|
||||||
const res = await this.http.request({
|
const res = await this.http.request({
|
||||||
url,
|
url,
|
||||||
@@ -65,8 +65,8 @@ export class QiniuClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async doRequestV2(opts: { url: string; method: string; body?: any; contentType: string }) {
|
async doRequestV2(opts: { url: string; method: string; body?: any; contentType: string }) {
|
||||||
const { HttpClient } = await import("qiniu/qiniu/httpc/client.js");
|
const { HttpClient } = await this.access.importRuntime("qiniu/qiniu/httpc/client.js");
|
||||||
const { QiniuAuthMiddleware } = await import("qiniu/qiniu/httpc/middleware/qiniuAuth.js");
|
const { QiniuAuthMiddleware } = await this.access.importRuntime("qiniu/qiniu/httpc/middleware/qiniuAuth.js");
|
||||||
// X-Qiniu-Date: 20060102T150405Z
|
// X-Qiniu-Date: 20060102T150405Z
|
||||||
const auth = new QiniuAuthMiddleware({
|
const auth = new QiniuAuthMiddleware({
|
||||||
mac: {
|
mac: {
|
||||||
@@ -100,7 +100,7 @@ export class QiniuClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async uploadFile(bucket: string, key: string, content: Buffer | string) {
|
async uploadFile(bucket: string, key: string, content: Buffer | string) {
|
||||||
const sdk = await import("qiniu");
|
const sdk = await this.access.importRuntime("qiniu");
|
||||||
const qiniu = sdk.default;
|
const qiniu = sdk.default;
|
||||||
const mac = new qiniu.auth.digest.Mac(this.access.accessKey, this.access.secretKey);
|
const mac = new qiniu.auth.digest.Mac(this.access.accessKey, this.access.secretKey);
|
||||||
const options = {
|
const options = {
|
||||||
@@ -161,7 +161,7 @@ export class QiniuClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getBucketManager() {
|
private async getBucketManager() {
|
||||||
const sdk = await import("qiniu");
|
const sdk = await this.access.importRuntime("qiniu");
|
||||||
const qiniu = sdk.default;
|
const qiniu = sdk.default;
|
||||||
const mac = new qiniu.auth.digest.Mac(this.access.accessKey, this.access.secretKey);
|
const mac = new qiniu.auth.digest.Mac(this.access.accessKey, this.access.secretKey);
|
||||||
const config = new qiniu.conf.Config();
|
const config = new qiniu.conf.Config();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export class UCloudAccess extends BaseAccess {
|
|||||||
if (this.client) {
|
if (this.client) {
|
||||||
return this.client;
|
return this.client;
|
||||||
}
|
}
|
||||||
const { Client } = await import("@ucloud-sdks/ucloud-sdk-js");
|
const { Client } = await this.importRuntime("@ucloud-sdks/ucloud-sdk-js");
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
config: {
|
config: {
|
||||||
region: region || "cn-bj2",
|
region: region || "cn-bj2",
|
||||||
@@ -197,7 +197,7 @@ export class UCloudAccess extends BaseAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async invoke(req: { Action: string; [key: string]: any }) {
|
async invoke(req: { Action: string; [key: string]: any }) {
|
||||||
const { Request } = await import("@ucloud-sdks/ucloud-sdk-js");
|
const { Request } = await this.importRuntime("@ucloud-sdks/ucloud-sdk-js");
|
||||||
const client = await this.getClient();
|
const client = await this.getClient();
|
||||||
const resp = await client.invoke(
|
const resp = await client.invoke(
|
||||||
new Request({
|
new Request({
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export class VolcengineCdnClient {
|
|||||||
if (this.service) {
|
if (this.service) {
|
||||||
return this.service;
|
return this.service;
|
||||||
}
|
}
|
||||||
const { cdn } = await import("@volcengine/openapi");
|
const { cdn } = await this.opts.access.importRuntime("@volcengine/openapi");
|
||||||
const service = new cdn.CdnService();
|
const service = new cdn.CdnService();
|
||||||
// 设置ak、sk
|
// 设置ak、sk
|
||||||
service.setAccessKeyId(this.opts.access.accessKeyId);
|
service.setAccessKeyId(this.opts.access.accessKeyId);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export class VolcengineDnsClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async doRequest(req: VolcengineReq) {
|
async doRequest(req: VolcengineReq) {
|
||||||
const { Signer } = await import("@volcengine/openapi");
|
const { Signer } = await this.opts.access.importRuntime("@volcengine/openapi");
|
||||||
|
|
||||||
// http request data
|
// http request data
|
||||||
const openApiRequestData: any = {
|
const openApiRequestData: any = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { VolcengineAccess } from "./access.js";
|
import { VolcengineAccess } from "./access.js";
|
||||||
import { HttpClient, ILogger } from "@certd/basic";
|
import { HttpClient, ILogger } from "@certd/basic";
|
||||||
|
|
||||||
export type VolcengineOpts = {
|
export type VolcengineOpts = {
|
||||||
@@ -140,7 +140,7 @@ export class VolcengineClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getTOSService(opts: { region?: string }) {
|
async getTOSService(opts: { region?: string }) {
|
||||||
const { TosClient } = await import("@volcengine/tos-sdk");
|
const { TosClient } = await this.opts.access.importRuntime("@volcengine/tos-sdk");
|
||||||
|
|
||||||
const client = new TosClient({
|
const client = new TosClient({
|
||||||
accessKeyId: this.opts.access.accessKeyId,
|
accessKeyId: this.opts.access.accessKeyId,
|
||||||
@@ -169,7 +169,7 @@ export class VolcengineClient {
|
|||||||
if (this.CommonService) {
|
if (this.CommonService) {
|
||||||
return this.CommonService;
|
return this.CommonService;
|
||||||
}
|
}
|
||||||
const { Service } = await import("@volcengine/openapi");
|
const { Service } = await this.opts.access.importRuntime("@volcengine/openapi");
|
||||||
|
|
||||||
class CommonService extends Service {
|
class CommonService extends Service {
|
||||||
Generic: any;
|
Generic: any;
|
||||||
|
|||||||
Reference in New Issue
Block a user