diff --git a/packages/core/basic/src/utils/index.ts b/packages/core/basic/src/utils/index.ts index fb856881..7ca3aa9e 100644 --- a/packages/core/basic/src/utils/index.ts +++ b/packages/core/basic/src/utils/index.ts @@ -8,7 +8,7 @@ export * from './util.hash.js'; export * from './util.merge.js'; export * from './util.cache.js'; import sleep from './util.sleep.js'; -import { http } from './util.request.js'; +import { http, download } from './util.request.js'; import { mergeUtils } from './util.merge.js'; import { sp } from './util.sp.js'; @@ -25,6 +25,7 @@ import * as id from './util.id.js'; export const utils = { sleep, http, + download, sp, hash: hashUtils, promises, diff --git a/packages/core/basic/src/utils/util.request.ts b/packages/core/basic/src/utils/util.request.ts index 10b8b16c..2cd3cebe 100644 --- a/packages/core/basic/src/utils/util.request.ts +++ b/packages/core/basic/src/utils/util.request.ts @@ -6,6 +6,8 @@ import { HttpsProxyAgent } from 'https-proxy-agent'; import nodeHttp from 'http'; import * as https from 'node:https'; import { merge } from 'lodash-es'; +import { safePromise } from './util.promise'; +import fs from 'fs'; export class HttpError extends Error { status?: number; statusText?: string; @@ -214,3 +216,38 @@ export function createAgent(opts: CreateAgentOptions = {}) { httpsAgent, }; } + +export async function download(http: HttpClient, config: HttpRequestConfig, savePath: string) { + return safePromise((resolve, reject) => { + http + .request({ + ...config, + responseType: 'stream', + }) + .then(res => { + const writer = fs.createWriteStream(savePath); + res.data.pipe(writer); + writer.on('close', () => { + console.log('文件下载成功'); + resolve(true); + }); + //error + writer.on('error', err => { + console.error('下载失败', err); + reject(err); + }); + //进度条打印 + const totalLength = res.headers['content-length']; + let currentLength = 0; + res.data.on('data', (chunk: any) => { + currentLength += chunk.length; + const percent = ((currentLength / totalLength) * 100).toFixed(2); + console.log(`下载进度:${percent}%`); + }); + }) + .catch(err => { + console.error('下载失败', err); + reject(err); + }); + }); +} diff --git a/packages/core/pipeline/src/access/api.ts b/packages/core/pipeline/src/access/api.ts index b9ada9f5..5d7a0491 100644 --- a/packages/core/pipeline/src/access/api.ts +++ b/packages/core/pipeline/src/access/api.ts @@ -1,6 +1,6 @@ import { Registrable } from "../registry/index.js"; import { FormItemProps } from "../dt/index.js"; -import { HttpClient, ILogger, utils } from "../utils/index.js"; +import { HttpClient, ILogger, utils } from "@certd/basic"; import _ from "lodash-es"; import { AccessRequestHandleReq } from "../core"; diff --git a/packages/core/pipeline/src/access/decorator.ts b/packages/core/pipeline/src/access/decorator.ts index 445364a6..8fca3438 100644 --- a/packages/core/pipeline/src/access/decorator.ts +++ b/packages/core/pipeline/src/access/decorator.ts @@ -3,7 +3,7 @@ import { AccessContext, AccessDefine, AccessInputDefine } from "./api.js"; import { Decorator } from "../decorator/index.js"; import _ from "lodash-es"; import { accessRegistry } from "./registry.js"; -import { http, logger, utils } from "../utils/index.js"; +import { http, logger, utils } from "@certd/basic"; // 提供一个唯一 key export const ACCESS_CLASS_KEY = "pipeline:access"; diff --git a/packages/core/pipeline/src/core/executor.ts b/packages/core/pipeline/src/core/executor.ts index b0c77d6f..1fde5600 100644 --- a/packages/core/pipeline/src/core/executor.ts +++ b/packages/core/pipeline/src/core/executor.ts @@ -3,7 +3,7 @@ import { RunHistory, RunnableCollection } from "./run-history.js"; import { AbstractTaskPlugin, PluginDefine, pluginRegistry, TaskInstanceContext, UserInfo } from "../plugin/index.js"; import { ContextFactory, IContext } from "./context.js"; import { IStorage } from "./storage.js"; -import { createAxiosService, hashUtils, logger, utils } from "../utils/index.js"; +import { createAxiosService, hashUtils, logger, utils } from "@certd/basic"; import { Logger } from "log4js"; import { IAccessService } from "../access/index.js"; import { RegistryItem } from "../registry/index.js"; diff --git a/packages/core/pipeline/src/core/file-store.ts b/packages/core/pipeline/src/core/file-store.ts index 040752cf..ccc61956 100644 --- a/packages/core/pipeline/src/core/file-store.ts +++ b/packages/core/pipeline/src/core/file-store.ts @@ -1,8 +1,8 @@ -import { fileUtils } from "../utils/index.js"; +import { fileUtils } from "@certd/basic"; import dayjs from "dayjs"; import path from "path"; import fs from "fs"; -import { logger } from "../utils/index.js"; +import { logger } from "@certd/basic"; export type FileStoreOptions = { rootDir?: string; diff --git a/packages/core/pipeline/src/core/handler.ts b/packages/core/pipeline/src/core/handler.ts index 83c0b17f..7d409f5f 100644 --- a/packages/core/pipeline/src/core/handler.ts +++ b/packages/core/pipeline/src/core/handler.ts @@ -1,4 +1,4 @@ -import { HttpClient, ILogger, utils } from "../utils/index.js"; +import { HttpClient, ILogger, utils } from "@certd/basic"; export type PluginRequestHandleReq = { typeName: string; diff --git a/packages/core/pipeline/src/core/license.ts b/packages/core/pipeline/src/core/license.ts index 7914a28e..855f84ec 100644 --- a/packages/core/pipeline/src/core/license.ts +++ b/packages/core/pipeline/src/core/license.ts @@ -1,4 +1,4 @@ -import { logger } from "../utils/index.js"; +import { logger } from "@certd/basic"; import { setLogger, isPlus, isComm } from "@certd/plus-core"; setLogger(logger); export * from "@certd/plus-core"; diff --git a/packages/core/pipeline/src/core/run-history.ts b/packages/core/pipeline/src/core/run-history.ts index fe27f8ea..088fc7d7 100644 --- a/packages/core/pipeline/src/core/run-history.ts +++ b/packages/core/pipeline/src/core/run-history.ts @@ -1,6 +1,6 @@ import { HistoryResult, Pipeline, ResultType, Runnable, RunnableMap, Stage, Step, Task } from "../dt/index.js"; import _ from "lodash-es"; -import { buildLogger } from "../utils/index.js"; +import { buildLogger } from "@certd/basic"; import { Logger } from "log4js"; export type HistoryStatus = { diff --git a/packages/core/pipeline/src/core/storage.ts b/packages/core/pipeline/src/core/storage.ts index f24775ba..5dae52db 100644 --- a/packages/core/pipeline/src/core/storage.ts +++ b/packages/core/pipeline/src/core/storage.ts @@ -1,6 +1,6 @@ import fs from "fs"; import path from "path"; -import { fileUtils } from "../utils/index.js"; +import { fileUtils } from "@certd/basic"; export interface IStorage { get(scope: string, namespace: string, version: string, key: string): Promise; diff --git a/packages/core/pipeline/src/index.ts b/packages/core/pipeline/src/index.ts index e1fa81a7..98b000dc 100644 --- a/packages/core/pipeline/src/index.ts +++ b/packages/core/pipeline/src/index.ts @@ -3,7 +3,6 @@ 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"; diff --git a/packages/core/pipeline/src/plugin/api.ts b/packages/core/pipeline/src/plugin/api.ts index 21f8fd9f..b755cf9b 100644 --- a/packages/core/pipeline/src/plugin/api.ts +++ b/packages/core/pipeline/src/plugin/api.ts @@ -5,8 +5,8 @@ import { Logger } from "log4js"; import { IAccessService } from "../access/index.js"; import { ICnameProxyService, IEmailService } from "../service/index.js"; import { CancelError, IContext, PluginRequestHandleReq, RunnableCollection } from "../core/index.js"; -import { ILogger, logger, utils } from "../utils/index.js"; -import { HttpClient } from "../utils/index.js"; +import { ILogger, logger, utils } from "@certd/basic"; +import { HttpClient } from "@certd/basic"; import dayjs from "dayjs"; import { IPluginConfigService } from "../service/config"; import { upperFirst } from "lodash-es"; diff --git a/packages/core/pipeline/src/registry/registry.ts b/packages/core/pipeline/src/registry/registry.ts index 36780c31..cf49899a 100644 --- a/packages/core/pipeline/src/registry/registry.ts +++ b/packages/core/pipeline/src/registry/registry.ts @@ -1,4 +1,4 @@ -import { isDev, logger } from "../utils/index.js"; +import { isDev, logger } from "@certd/basic"; export type Registrable = { name: string; diff --git a/packages/core/pipeline/src/utils/index.ts b/packages/core/pipeline/src/utils/index.ts deleted file mode 100644 index 5a595f40..00000000 --- a/packages/core/pipeline/src/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "@certd/basic"; diff --git a/packages/libs/lib-k8s/package.json b/packages/libs/lib-k8s/package.json index ef5de94c..26dcc451 100644 --- a/packages/libs/lib-k8s/package.json +++ b/packages/libs/lib-k8s/package.json @@ -18,7 +18,7 @@ "@kubernetes/client-node": "0.21.0" }, "devDependencies": { - "@certd/pipeline": "^1.27.0", + "@certd/basic": "^1.27.0", "@rollup/plugin-commonjs": "^23.0.4", "@rollup/plugin-json": "^6.0.0", "@rollup/plugin-node-resolve": "^15.0.1", diff --git a/packages/libs/lib-k8s/src/lib/k8s.client.ts b/packages/libs/lib-k8s/src/lib/k8s.client.ts index 5e4e7d4a..6eabf744 100644 --- a/packages/libs/lib-k8s/src/lib/k8s.client.ts +++ b/packages/libs/lib-k8s/src/lib/k8s.client.ts @@ -1,6 +1,6 @@ import { CoreV1Api, KubeConfig, NetworkingV1Api, V1Ingress, V1Secret } from '@kubernetes/client-node'; import dns from 'dns'; -import { ILogger } from '@certd/pipeline'; +import { ILogger } from '@certd/basic'; import _ from 'lodash-es'; export type K8sClientOpts = { diff --git a/packages/libs/lib-server/package.json b/packages/libs/lib-server/package.json index d20f6496..0bbe1b40 100644 --- a/packages/libs/lib-server/package.json +++ b/packages/libs/lib-server/package.json @@ -28,6 +28,7 @@ "dependencies": { "@certd/acme-client": "^1.27.0", "@certd/basic": "^1.27.0", + "@certd/plus-core": "^1.27.0", "@certd/pipeline": "^1.27.0", "@midwayjs/cache": "~3.14.0", "@midwayjs/core": "~3.17.1", diff --git a/packages/libs/lib-server/src/configuration.ts b/packages/libs/lib-server/src/configuration.ts index f24ecf5f..dd2bcaac 100644 --- a/packages/libs/lib-server/src/configuration.ts +++ b/packages/libs/lib-server/src/configuration.ts @@ -1,6 +1,6 @@ import type { IMidwayContainer } from '@midwayjs/core'; import { Configuration } from '@midwayjs/core'; -import { logger } from '@certd/pipeline'; +import { logger } from '@certd/basic'; @Configuration({ namespace: 'lib-server', }) diff --git a/packages/libs/lib-server/src/system/basic/service/file-service.ts b/packages/libs/lib-server/src/system/basic/service/file-service.ts index c60d30e7..41f3cbaf 100644 --- a/packages/libs/lib-server/src/system/basic/service/file-service.ts +++ b/packages/libs/lib-server/src/system/basic/service/file-service.ts @@ -2,7 +2,7 @@ import { Provide, Scope, ScopeEnum } from '@midwayjs/core'; import dayjs from 'dayjs'; import path from 'path'; import fs from 'fs'; -import { cache, logger, utils } from '@certd/pipeline'; +import { cache, logger, utils } from '@certd/basic'; import { NotFoundException, ParamException, PermissionException } from '../../../basic/index.js'; export type UploadFileItem = { diff --git a/packages/libs/lib-server/src/system/basic/service/plus-service.ts b/packages/libs/lib-server/src/system/basic/service/plus-service.ts index faa2e2ed..d480ef6f 100644 --- a/packages/libs/lib-server/src/system/basic/service/plus-service.ts +++ b/packages/libs/lib-server/src/system/basic/service/plus-service.ts @@ -1,5 +1,5 @@ import { Config, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core'; -import { AppKey, PlusRequestService, verify } from '@certd/pipeline'; +import { AppKey, PlusRequestService, verify } from '@certd/plus-core'; import { logger } from '@certd/basic'; import { SysInstallInfo, SysLicenseInfo, SysSettingsService } from '../../settings/index.js'; diff --git a/packages/plugins/plugin-cert/src/dns-provider/api.ts b/packages/plugins/plugin-cert/src/dns-provider/api.ts index 015d4d99..3ce83054 100644 --- a/packages/plugins/plugin-cert/src/dns-provider/api.ts +++ b/packages/plugins/plugin-cert/src/dns-provider/api.ts @@ -1,4 +1,5 @@ -import { HttpClient, IAccess, ILogger, Registrable, utils } from "@certd/pipeline"; +import { HttpClient, ILogger, utils } from "@certd/basic"; +import { IAccess, Registrable } from "@certd/pipeline"; export type DnsProviderDefine = Registrable & { accessType: string; diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts index 64c10816..1ebc129a 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts @@ -4,7 +4,8 @@ import { ClientExternalAccountBindingOptions, UrlMapping } from "@certd/acme-cli import _ from "lodash-es"; import { Challenge } from "@certd/acme-client/types/rfc8555"; import { Logger } from "log4js"; -import { IContext, utils } from "@certd/pipeline"; +import { IContext } from "@certd/pipeline"; +import { utils } from "@certd/basic"; import { IDnsProvider, parseDomain } from "../../dns-provider/index.js"; export type CnameVerifyPlan = { diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts index 57cbe9db..d3154365 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts @@ -1,4 +1,4 @@ -import { AbstractTaskPlugin, HttpClient, IContext, Step, TaskInput, TaskOutput } from "@certd/pipeline"; +import { AbstractTaskPlugin, IContext, Step, TaskInput, TaskOutput } from "@certd/pipeline"; import dayjs from "dayjs"; import type { CertInfo } from "./acme.js"; import { CertReader } from "./cert-reader.js"; @@ -6,6 +6,7 @@ import JSZip from "jszip"; import { CertConverter } from "./convert.js"; import fs from "fs"; import { pick } from "lodash-es"; +import { HttpClient } from "@certd/basic"; export { CertReader }; export type { CertInfo }; diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/cert-reader.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/cert-reader.ts index af9ee4cf..604eaada 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/cert-reader.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/cert-reader.ts @@ -3,7 +3,7 @@ import fs from "fs"; import os from "os"; import path from "path"; import { crypto } from "@certd/acme-client"; -import { ILogger } from "@certd/pipeline"; +import { ILogger } from "@certd/basic"; import dayjs from "dayjs"; export type CertReaderHandleContext = { diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/convert.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/convert.ts index 1861e875..677b2a66 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/convert.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/convert.ts @@ -1,4 +1,4 @@ -import { ILogger, sp } from "@certd/pipeline"; +import { ILogger, sp } from "@certd/basic"; import type { CertInfo } from "../cert-plugin/acme.js"; import { CertReader, CertReaderHandleContext } from "../cert-plugin/cert-reader.js"; import path from "path"; diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts index 4be4a86b..d9dd28bc 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts @@ -1,4 +1,6 @@ -import { IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, utils } from "@certd/pipeline"; +import { IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline"; +import { utils } from "@certd/basic"; + import type { CertInfo, CnameVerifyPlan, DomainsVerifyPlan, PrivateKeyType, SSLProvider } from "./acme.js"; import { AcmeService } from "./acme.js"; import _ from "lodash-es"; diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/lego/index.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/lego/index.ts index 5887144b..2bbd9764 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/lego/index.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/lego/index.ts @@ -1,11 +1,10 @@ -import { IsTaskPlugin, pluginGroups, RunStrategy, sp, Step, TaskInput } from "@certd/pipeline"; +import { IsTaskPlugin, pluginGroups, RunStrategy, Step, TaskInput } from "@certd/pipeline"; import type { CertInfo } from "../acme.js"; import { CertReader } from "../cert-reader.js"; import { CertApplyBasePlugin } from "../base.js"; import fs from "fs"; import { EabAccess } from "../../../access/index.js"; import path from "path"; -import { utils } from "@certd/basic"; import JSZip from "jszip"; export { CertReader }; @@ -127,31 +126,51 @@ export class CertApplyLegoPlugin extends CertApplyBasePlugin { const saveDir = `./data/.lego/pipeline_${this.pipeline.id}/`; const savePathArgs = `--path "${saveDir}"`; const os_type = process.platform === "win32" ? "windows" : "linux"; - const legoPath = path.resolve("./tools", os_type, "lego"); + const legoDir = "./tools/lego"; + const legoPath = path.resolve(legoDir, "lego"); if (!fs.existsSync(legoPath)) { //解压缩 + const arch = process.arch; + let platform = "amd64"; + if (arch === "arm64" || arch === "arm") { + platform = "arm64"; + } + const LEGO_VERSION = process.env.LEGO_VERSION; + let legoZipFile = `${legoDir}/lego_v${LEGO_VERSION}_windows_${platform}.zip`; if (os_type === "linux") { - //判断当前是arm64 还是amd64 - const arch = process.arch; - let platform = "amd64"; - if (arch === "arm64" || arch === "arm") { - platform = "arm64"; - } - await utils.sp.spawn({ - cmd: `tar -zxvf ./tools/linux/lego_linux_${platform}.tar.gz -C ./tools/linux/`, + legoZipFile = `${legoDir}/lego_v${LEGO_VERSION}_linux_${platform}.tar.gz`; + } + if (!fs.existsSync(legoZipFile)) { + this.logger.info(`lego文件不存在:${legoZipFile},准备下载`); + const downloadUrl = `https://github.com/go-acme/lego/releases/download/v${LEGO_VERSION}/lego_v${LEGO_VERSION}_${os_type}_${platform}.tar.gz`; + await this.ctx.utils.download( + this.http, + { + url: downloadUrl, + method: "GET", + }, + legoZipFile + ); + this.logger.info("下载lego成功"); + } + + if (os_type === "linux") { + //tar是否存在 + await this.ctx.utils.sp.spawn({ + cmd: `tar -zxvf ${legoZipFile} -C ${legoDir}/`, }); - await utils.sp.spawn({ - cmd: `chmod +x ./tools/linux/*`, + await this.ctx.utils.sp.spawn({ + cmd: `chmod +x ${legoDir}/*`, }); this.logger.info("解压lego成功"); } else { const zip = new JSZip(); - const data = fs.readFileSync("./tools/windows/lego_windows_amd64.zip"); + const data = fs.readFileSync(legoZipFile); const zipData = await zip.loadAsync(data); const files = Object.keys(zipData.files); for (const file of files) { const content = await zipData.files[file].async("nodebuffer"); - fs.writeFileSync(`./tools/windows/${file}`, content); + fs.writeFileSync(legoPath, content); } this.logger.info("解压lego成功"); } @@ -166,7 +185,7 @@ export class CertApplyLegoPlugin extends CertApplyBasePlugin { } run`, ]; - await sp.spawn({ + await this.ctx.utils.sp.spawn({ cmd: cmds, logger: this.logger, env, diff --git a/packages/ui/Dockerfile b/packages/ui/Dockerfile index 337b8ca2..294d205a 100644 --- a/packages/ui/Dockerfile +++ b/packages/ui/Dockerfile @@ -17,15 +17,15 @@ WORKDIR /app/ COPY --from=builder /workspace/certd-server/ /app/ ENV LEGO_VERSION=4.19.2 -ENV LEGO_DOWNLOAD_DIR /app/tools/linux +ENV LEGO_DOWNLOAD_DIR /app/tools/lego RUN mkdir -p $LEGO_DOWNLOAD_DIR # 根据架构下载不同的文件 RUN ARCH=$(uname -m) && \ if [ "$ARCH" = "x86_64" ]; then \ - wget -O $LEGO_DOWNLOAD_DIR/lego_linux_amd64.tar.gz https://github.com/go-acme/lego/releases/download/v${LEGO_VERSION}/lego_v${LEGO_VERSION}_linux_arm64.tar.gz; \ + wget -O $LEGO_DOWNLOAD_DIR/lego_v${LEGO_VERSION}_linux_amd64.tar.gz https://github.com/go-acme/lego/releases/download/v${LEGO_VERSION}/lego_v${LEGO_VERSION}_linux_arm64.tar.gz; \ elif [ "$ARCH" = "aarch64" ]; then \ - wget -O $LEGO_DOWNLOAD_DIR/lego_linux_arm64.tar.gz https://github.com/go-acme/lego/releases/download/v${LEGO_VERSION}/lego_v${LEGO_VERSION}_linux_amd64.tar.gz; \ + wget -O $LEGO_DOWNLOAD_DIR/lego_v${LEGO_VERSION}_linux_arm64.tar.gz https://github.com/go-acme/lego/releases/download/v${LEGO_VERSION}/lego_v${LEGO_VERSION}_linux_amd64.tar.gz; \ else \ echo "Unsupported architecture: $ARCH"; \ fi diff --git a/packages/ui/certd-server/.env b/packages/ui/certd-server/.env new file mode 100644 index 00000000..a4a947dd --- /dev/null +++ b/packages/ui/certd-server/.env @@ -0,0 +1 @@ +LEGO_VERSION=4.19.2 diff --git a/packages/ui/certd-server/.gitignore b/packages/ui/certd-server/.gitignore index f462ff3e..4e02485f 100755 --- a/packages/ui/certd-server/.gitignore +++ b/packages/ui/certd-server/.gitignore @@ -19,6 +19,5 @@ run/ .clinic .env.pgpl.yaml - -tools/windows/* -!tools/windows/*.zip +tools/* +!tools/lego/.keep diff --git a/packages/ui/certd-server/package.json b/packages/ui/certd-server/package.json index 57e3306d..b0895aa8 100644 --- a/packages/ui/certd-server/package.json +++ b/packages/ui/certd-server/package.json @@ -38,6 +38,7 @@ "@certd/plugin-cert": "^1.27.0", "@certd/plugin-plus": "^1.27.0", "@certd/plus-core": "^1.27.0", + "@certd/basic": "^1.27.0", "@huaweicloud/huaweicloud-sdk-cdn": "^3.1.120", "@huaweicloud/huaweicloud-sdk-core": "^3.1.120", "@koa/cors": "^5.0.0", diff --git a/packages/ui/certd-server/src/config/config.default.ts b/packages/ui/certd-server/src/config/config.default.ts index 167598d0..26a3435a 100644 --- a/packages/ui/certd-server/src/config/config.default.ts +++ b/packages/ui/certd-server/src/config/config.default.ts @@ -10,7 +10,7 @@ import { UserEntity } from '../modules/sys/authority/entity/user.js'; import { PipelineEntity } from '../modules/pipeline/entity/pipeline.js'; //import { logger } from '../utils/logger'; // load .env file in process.cwd -import { mergeConfig } from './loader.js'; +import { loadDotEnv, mergeConfig } from './loader.js'; import { libServerEntities } from '@certd/lib-server'; import { commercialEntities } from '@certd/commercial-core'; import { tmpdir } from 'node:os'; @@ -123,6 +123,8 @@ const development = { contactLink: '', }, } as MidwayConfig; +loadDotEnv(); + mergeConfig(development, 'development'); mergeConfig(development, env); diff --git a/packages/ui/certd-server/src/config/loader.ts b/packages/ui/certd-server/src/config/loader.ts index 88f61465..3d18a113 100644 --- a/packages/ui/certd-server/src/config/loader.ts +++ b/packages/ui/certd-server/src/config/loader.ts @@ -46,3 +46,14 @@ export function mergeConfig(config: any, envType: string) { } return config; } + +export function loadDotEnv() { + const envStr = fs.readFileSync('.env').toString(); + envStr.split('\n').forEach(line => { + const [key, value] = line.split('='); + const oldValue = process.env[key]; + if (!oldValue) { + process.env[key] = value; + } + }); +} diff --git a/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts b/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts index 484d5b9b..ab5d65dc 100644 --- a/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts +++ b/packages/ui/certd-server/src/plugins/plugin-host/lib/ssh.ts @@ -86,6 +86,7 @@ export class AsyncSsh2Client { sftp.fastPut(localPath, remotePath, (err: Error) => { if (err) { reject(err); + this.logger.error('请确认路径是否包含文件名,路径本身不能是目录,路径不能有*?之类的特殊符号,要有写入权限'); return; } this.logger.info(`上传文件成功:${localPath} => ${remotePath}`); diff --git a/packages/ui/certd-server/tools/lego/.keep b/packages/ui/certd-server/tools/lego/.keep new file mode 100644 index 00000000..1afab5f7 --- /dev/null +++ b/packages/ui/certd-server/tools/lego/.keep @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865 +size 2 diff --git a/packages/ui/certd-server/tools/linux/lego_linux_amd64.tar.gz b/packages/ui/certd-server/tools/linux/lego_linux_amd64.tar.gz deleted file mode 100644 index 18b1303d..00000000 --- a/packages/ui/certd-server/tools/linux/lego_linux_amd64.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:588e41dfbc2a5ef1596953b605ef0981f95135443a1e66db3e06e1fa2c061eab -size 24746505 diff --git a/packages/ui/certd-server/tools/linux/lego_linux_arm64.tar.gz b/packages/ui/certd-server/tools/linux/lego_linux_arm64.tar.gz deleted file mode 100644 index c0bc0e98..00000000 --- a/packages/ui/certd-server/tools/linux/lego_linux_arm64.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ba47935bd3618ab13f2c10ba8589156e98617ab77f4dd101956cd21e829a6316 -size 23085284 diff --git a/packages/ui/certd-server/tools/windows/lego_windows_amd64.zip b/packages/ui/certd-server/tools/windows/lego_windows_amd64.zip deleted file mode 100644 index 71dfe6bc..00000000 --- a/packages/ui/certd-server/tools/windows/lego_windows_amd64.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9b91a1e4f32b3f5e55fa6e455b8a72069cd2983ec7a36d275f0aa4b0d82a0de6 -size 25579960