mirror of https://github.com/certd/certd
				
				
				
			chore: basic 从pipeline中移除
							parent
							
								
									0f572f4cb3
								
							
						
					
					
						commit
						1274f56da8
					
				| 
						 | 
				
			
			@ -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,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
      });
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
import { HttpClient, ILogger, utils } from "../utils/index.js";
 | 
			
		||||
import { HttpClient, ILogger, utils } from "@certd/basic";
 | 
			
		||||
 | 
			
		||||
export type PluginRequestHandleReq<T = any> = {
 | 
			
		||||
  typeName: string;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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<string | null>;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
import { isDev, logger } from "../utils/index.js";
 | 
			
		||||
import { isDev, logger } from "@certd/basic";
 | 
			
		||||
 | 
			
		||||
export type Registrable = {
 | 
			
		||||
  name: string;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
export * from "@certd/basic";
 | 
			
		||||
| 
						 | 
				
			
			@ -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",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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',
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
LEGO_VERSION=4.19.2
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +19,5 @@ run/
 | 
			
		|||
.clinic
 | 
			
		||||
 | 
			
		||||
.env.pgpl.yaml
 | 
			
		||||
 | 
			
		||||
tools/windows/*
 | 
			
		||||
!tools/windows/*.zip
 | 
			
		||||
tools/*
 | 
			
		||||
!tools/lego/.keep
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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}`);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,3 @@
 | 
			
		|||
version https://git-lfs.github.com/spec/v1
 | 
			
		||||
oid sha256:4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865
 | 
			
		||||
size 2
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +0,0 @@
 | 
			
		|||
version https://git-lfs.github.com/spec/v1
 | 
			
		||||
oid sha256:588e41dfbc2a5ef1596953b605ef0981f95135443a1e66db3e06e1fa2c061eab
 | 
			
		||||
size 24746505
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +0,0 @@
 | 
			
		|||
version https://git-lfs.github.com/spec/v1
 | 
			
		||||
oid sha256:ba47935bd3618ab13f2c10ba8589156e98617ab77f4dd101956cd21e829a6316
 | 
			
		||||
size 23085284
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +0,0 @@
 | 
			
		|||
version https://git-lfs.github.com/spec/v1
 | 
			
		||||
oid sha256:9b91a1e4f32b3f5e55fa6e455b8a72069cd2983ec7a36d275f0aa4b0d82a0de6
 | 
			
		||||
size 25579960
 | 
			
		||||
		Loading…
	
		Reference in New Issue