mirror of
https://github.com/certd/certd.git
synced 2026-08-03 03:50:15 +08:00
style: 统一代码中单引号为双引号并补全格式
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
"scripts": {
|
||||
"before-build": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});fs.rmSync('tsconfig.tsbuildinfo',{force:true});\"",
|
||||
"build": "npm run before-build && tsc -p tsconfig.build.json --skipLibCheck",
|
||||
"lint": "eslint \"src/**/*.ts\" \"types/**/*.ts\"",
|
||||
"lint": "eslint --fix \"src/**/*.ts\" \"types/**/*.ts\"",
|
||||
"lint-types": "tsd --files \"types/index.test-d.ts\"",
|
||||
"prepublishOnly": "npm run build",
|
||||
"test": "mocha -t 60000 \"test/setup.js\" \"test/**/*.spec.js\"",
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"pub": "npm publish",
|
||||
"compile": "tsc --skipLibCheck --watch",
|
||||
"format": "prettier --write src",
|
||||
"lint": "eslint --fix"
|
||||
"lint": "eslint --fix --ext .ts src"
|
||||
},
|
||||
"dependencies": {
|
||||
"async-lock": "^1.4.1",
|
||||
|
||||
@@ -11,9 +11,12 @@ export class LocalCache<V = any> {
|
||||
cache: Map<string, { value: V; expiresAt: number }>;
|
||||
constructor(opts: { clearInterval?: number } = {}) {
|
||||
this.cache = new Map();
|
||||
const intervalId = setInterval(() => {
|
||||
this.clearExpires();
|
||||
}, opts.clearInterval ?? 5 * 60 * 1000);
|
||||
const intervalId = setInterval(
|
||||
() => {
|
||||
this.clearExpires();
|
||||
},
|
||||
opts.clearInterval ?? 5 * 60 * 1000
|
||||
);
|
||||
intervalId.unref?.();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export function isDev() {
|
||||
const nodeEnv = process.env.NODE_ENV || 'dev';
|
||||
return nodeEnv === 'development' || nodeEnv.includes('local') || nodeEnv.startsWith('dev');
|
||||
const nodeEnv = process.env.NODE_ENV || "dev";
|
||||
return nodeEnv === "development" || nodeEnv.includes("local") || nodeEnv.startsWith("dev");
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import fs from 'fs';
|
||||
import fs from "fs";
|
||||
function getFileRootDir(rootDir?: string) {
|
||||
if (rootDir == null) {
|
||||
const userHome = process.env.HOME || process.env.USERPROFILE;
|
||||
rootDir = userHome + '/.certd/storage/';
|
||||
rootDir = userHome + "/.certd/storage/";
|
||||
}
|
||||
|
||||
if (!fs.existsSync(rootDir)) {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
import mitt from 'mitt';
|
||||
import mitt from "mitt";
|
||||
export const mitter = mitt();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"pub": "npm publish",
|
||||
"compile": "tsc --skipLibCheck --watch",
|
||||
"format": "prettier --write src",
|
||||
"lint": "eslint --fix"
|
||||
"lint": "eslint --fix --ext .ts src"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/basic": "^1.42.6",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"pub": "npm publish",
|
||||
"compile": "npm run build",
|
||||
"format": "prettier --write src",
|
||||
"lint": "eslint --fix"
|
||||
"lint": "eslint --fix --ext .ts src"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.9.0",
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"pub": "npm publish",
|
||||
"compile": "npm run build",
|
||||
"format": "prettier --write src",
|
||||
"lint": "eslint --fix"
|
||||
"lint": "eslint --fix --ext .ts src"
|
||||
},
|
||||
"dependencies": {
|
||||
"nanoid": "^5.0.7"
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from './lib/iframe.client.js';
|
||||
export * from "./lib/iframe.client.js";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { nanoid } from 'nanoid';
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
export type IframeMessageData<T> = {
|
||||
action: string;
|
||||
@@ -32,7 +32,7 @@ export class IframeClient {
|
||||
constructor(iframe?: HTMLIFrameElement, onError?: (e: any) => void) {
|
||||
this.iframe = iframe;
|
||||
this.onError = onError;
|
||||
window.addEventListener('message', async (event: MessageEvent<IframeMessageData<any>>) => {
|
||||
window.addEventListener("message", async (event: MessageEvent<IframeMessageData<any>>) => {
|
||||
const data = event.data;
|
||||
if (data.action) {
|
||||
console.log(`收到消息[isSub:${this.isInFrame()}]`, data);
|
||||
@@ -40,20 +40,20 @@ export class IframeClient {
|
||||
const handler = this.handlers[data.action];
|
||||
if (handler) {
|
||||
const res = await handler(data);
|
||||
if (data.id && data.action !== 'reply') {
|
||||
await this.send('reply', res, data.id);
|
||||
if (data.id && data.action !== "reply") {
|
||||
await this.send("reply", res, data.id);
|
||||
}
|
||||
} else {
|
||||
throw new Error(`action:${data.action} 未注册处理器,可能版本过低`);
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
await this.send('reply', {}, data.id, 500, e.message);
|
||||
await this.send("reply", {}, data.id, 500, e.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.register('reply', async data => {
|
||||
this.register("reply", async data => {
|
||||
const req = this.requestQueue[data.replyId!];
|
||||
if (req) {
|
||||
req.onReply(data);
|
||||
@@ -106,12 +106,12 @@ export class IframeClient {
|
||||
console.log(`send message[isSub:${this.isInFrame()}]:`, reqMessageData);
|
||||
if (!this.iframe) {
|
||||
if (!window.parent) {
|
||||
reject('当前页面不在 iframe 中');
|
||||
reject("当前页面不在 iframe 中");
|
||||
}
|
||||
window.parent.postMessage(reqMessageData, '*');
|
||||
window.parent.postMessage(reqMessageData, "*");
|
||||
} else {
|
||||
//子页面
|
||||
this.iframe.contentWindow?.postMessage(reqMessageData, '*');
|
||||
this.iframe.contentWindow?.postMessage(reqMessageData, "*");
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"pub": "npm publish",
|
||||
"compile": "npm run build",
|
||||
"format": "prettier --write src",
|
||||
"lint": "eslint --fix"
|
||||
"lint": "eslint --fix --ext .ts src"
|
||||
},
|
||||
"author": "",
|
||||
"license": "Apache",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import jdCloud from "./lib/core.js";
|
||||
import jdService from './lib/service.js'
|
||||
import jdCloud from './lib/core.js';
|
||||
import jdService from './lib/service.js';
|
||||
|
||||
import domainService from './repo/domainservice/v2/domainservice.js'
|
||||
import cdnService from './repo/cdn/v1/cdn.js'
|
||||
import sslService from './repo/ssl/v1/ssl.js'
|
||||
import domainService from './repo/domainservice/v2/domainservice.js';
|
||||
import cdnService from './repo/cdn/v1/cdn.js';
|
||||
import sslService from './repo/ssl/v1/ssl.js';
|
||||
export const JDCloud = jdCloud;
|
||||
export const JDService = jdService;
|
||||
export const JDDomainService = domainService;
|
||||
export const JDCdnService = cdnService;
|
||||
export const JDSslService = sslService;
|
||||
export const JDSslService = sslService;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"pub": "npm publish",
|
||||
"compile": "tsc --skipLibCheck --watch",
|
||||
"format": "prettier --write src",
|
||||
"lint": "eslint --fix"
|
||||
"lint": "eslint --fix --ext .ts src"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/basic": "^1.42.6",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"pub": "npm publish",
|
||||
"compile": "npm run build",
|
||||
"format": "prettier --write src",
|
||||
"lint": "eslint --fix"
|
||||
"lint": "eslint --fix --ext .ts src"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "greper",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Config, Configuration, Logger } from '@midwayjs/core';
|
||||
import { Flyway } from './flyway.js';
|
||||
import type { ILogger } from '@midwayjs/logger';
|
||||
import { TypeORMDataSourceManager } from '@midwayjs/typeorm';
|
||||
import type { IMidwayContainer } from '@midwayjs/core';
|
||||
import { Config, Configuration, Logger } from "@midwayjs/core";
|
||||
import { Flyway } from "./flyway.js";
|
||||
import type { ILogger } from "@midwayjs/logger";
|
||||
import { TypeORMDataSourceManager } from "@midwayjs/typeorm";
|
||||
import type { IMidwayContainer } from "@midwayjs/core";
|
||||
|
||||
@Configuration({
|
||||
namespace: 'flyway',
|
||||
namespace: "flyway",
|
||||
//importConfigs: [join(__dirname, './config')],
|
||||
})
|
||||
export class FlywayConfiguration {
|
||||
@@ -14,9 +14,9 @@ export class FlywayConfiguration {
|
||||
@Logger()
|
||||
logger!: ILogger;
|
||||
async onReady(container: IMidwayContainer) {
|
||||
this.logger.info('flyway start:' + JSON.stringify(this.flyway));
|
||||
this.logger.info("flyway start:" + JSON.stringify(this.flyway));
|
||||
const dataSourceManager = await container.getAsync(TypeORMDataSourceManager);
|
||||
const dataSourceName = this.flyway.dataSourceName || 'default';
|
||||
const dataSourceName = this.flyway.dataSourceName || "default";
|
||||
const connection = dataSourceManager.getDataSource(dataSourceName);
|
||||
await new Flyway({ ...this.flyway, logger: this.logger, connection }).run();
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('flyway_history')
|
||||
@Entity("flyway_history")
|
||||
export class FlywayHistory {
|
||||
@PrimaryGeneratedColumn()
|
||||
id?: number;
|
||||
|
||||
@Column({ comment: '文件名', length: 100 })
|
||||
@Column({ comment: "文件名", length: 100 })
|
||||
name?: string;
|
||||
|
||||
@Column({ comment: 'hash', length: 32 })
|
||||
@Column({ comment: "hash", length: 32 })
|
||||
hash?: string;
|
||||
|
||||
@Column({
|
||||
comment: '执行时间',
|
||||
comment: "执行时间",
|
||||
})
|
||||
timestamp?: Date;
|
||||
|
||||
@Column({
|
||||
comment: '执行成功',
|
||||
comment: "执行成功",
|
||||
default: true,
|
||||
})
|
||||
success?: boolean;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export { FlywayConfiguration as Configuration } from './configuration.js';
|
||||
export { Flyway, setFlywayLogger } from './flyway.js';
|
||||
export { FlywayHistory } from './entity.js';
|
||||
export { FlywayConfiguration as Configuration } from "./configuration.js";
|
||||
export { Flyway, setFlywayLogger } from "./flyway.js";
|
||||
export { FlywayHistory } from "./entity.js";
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"pub": "npm publish",
|
||||
"compile": "tsc --skipLibCheck --watch",
|
||||
"format": "prettier --write src",
|
||||
"lint": "eslint --fix"
|
||||
"lint": "eslint --fix --ext .ts src"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/plugin-lib": "^1.42.6"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"pub": "npm publish",
|
||||
"compile": "tsc --skipLibCheck --watch",
|
||||
"format": "prettier --write src",
|
||||
"lint": "eslint --fix"
|
||||
"lint": "eslint --fix --ext .ts src"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/acme-client": "^1.42.6",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from "./common/index.js";
|
||||
export * from "./lib/index.js";
|
||||
export * from "./service/index.js";
|
||||
export * from "./cert/index.js";
|
||||
export * from "./cert/index.js";
|
||||
|
||||
Reference in New Issue
Block a user