Skip to content

Commit

Permalink
perf: update code style
Browse files Browse the repository at this point in the history
  • Loading branch information
liuweiGL committed Aug 15, 2024
1 parent e1fb6ee commit 2ccce41
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 101 deletions.
2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type PluginOption } from 'vite';
import { MkcertBaseOptions } from './mkcert/index';
import { type MkcertBaseOptions } from './mkcert/index';
export { BaseSource, type SourceInfo } from './mkcert/source';
export type MkcertPluginOptions = MkcertBaseOptions & {
/**
Expand Down
5 changes: 2 additions & 3 deletions dist/lib/util.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="node" />
import { ExecOptions } from 'child_process';
import { type ExecOptions } from 'node:child_process';
/**
* Check if file exists
*
Expand All @@ -22,4 +21,4 @@ export declare const getDefaultHosts: () => string[];
export declare const getHash: (filePath: string) => Promise<string>;
export declare const deepMerge: (target: any, ...source: any[]) => any;
export declare const prettyLog: (obj?: Record<string, any>) => string;
export declare const escape: (path?: string) => string;
export declare const escapeStr: (path?: string) => string;
78 changes: 39 additions & 39 deletions dist/mkcert.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/mkcert.js.map

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions dist/mkcert.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
import { createLogger } from "vite";

// plugin/lib/constant.ts
import os from "os";
import path from "path";
import os from "node:os";
import path from "node:path";
var PKG_NAME = "vite-plugin-mkcert";
var PLUGIN_NAME = PKG_NAME.replace(/-/g, ":");
var PLUGIN_DATA_DIR = path.join(os.homedir(), `.${PKG_NAME}`);

// plugin/lib/util.ts
import child_process from "child_process";
import crypto from "crypto";
import fs from "fs";
import os2 from "os";
import path2 from "path";
import util from "util";
import child_process from "node:child_process";
import crypto from "node:crypto";
import fs from "node:fs";
import os2 from "node:os";
import path2 from "node:path";
import util from "node:util";
var exists = async (filePath) => {
try {
await fs.promises.access(filePath);
return true;
} catch (error) {
} catch (_error) {
return false;
}
};
Expand Down Expand Up @@ -110,21 +110,21 @@ var deepMerge = (target, ...source) => {
var prettyLog = (obj) => {
return JSON.stringify(obj, null, 2);
};
var escape = (path5) => {
var escapeStr = (path5) => {
return `"${path5}"`;
};

// plugin/mkcert/index.ts
import path4 from "path";
import process2 from "process";
import path4 from "node:path";
import process2 from "node:process";
import pc from "picocolors";

// plugin/lib/logger.ts
import Debug from "debug";
var debug = Debug(PLUGIN_NAME);

// plugin/mkcert/config.ts
import path3 from "path";
import path3 from "node:path";
var CONFIG_FILE_NAME = "config.json";
var Config = class {
/**
Expand Down Expand Up @@ -450,7 +450,7 @@ var Mkcert = class _Mkcert {
} else if (await exists(this.savedMkcert)) {
binary = this.savedMkcert;
}
return binary ? escape(binary) : void 0;
return binary;
}
async checkCAExists() {
const files = await readDir(this.savePath);
Expand All @@ -461,7 +461,7 @@ var Mkcert = class _Mkcert {
return;
}
const mkcertBinary = await this.getMkcertBinary();
const commandStatement = `${escape(mkcertBinary)} -CAROOT`;
const commandStatement = `${escapeStr(mkcertBinary)} -CAROOT`;
debug(`Exec ${commandStatement}`);
const commandResult = await exec(commandStatement);
const caDirPath = path4.resolve(
Expand Down Expand Up @@ -494,9 +494,9 @@ var Mkcert = class _Mkcert {
}
await ensureDirExist(this.savePath);
await this.retainExistedCA();
const cmd = `${escape(mkcertBinary)} -install -key-file ${escape(
const cmd = `${escapeStr(mkcertBinary)} -install -key-file ${escapeStr(
this.keyFilePath
)} -cert-file ${escape(this.certFilePath)} ${names}`;
)} -cert-file ${escapeStr(this.certFilePath)} ${names}`;
await exec(cmd, {
env: {
...process2.env,
Expand Down Expand Up @@ -581,7 +581,7 @@ ${this.certFilePath}`
async renew(hosts) {
const record = new record_default({ config: this.config });
if (this.force) {
debug(`Certificate is forced to regenerate`);
debug("Certificate is forced to regenerate");
await this.regenerate(record, hosts);
}
if (!record.contains(hosts)) {
Expand Down
4 changes: 2 additions & 2 deletions dist/mkcert.mjs.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/mkcert/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Logger } from 'vite';
import { BaseSource } from './source';
import type { Logger } from 'vite';
import { type BaseSource } from './source';
export type SourceType = 'github' | 'coding' | BaseSource;
export type MkcertBaseOptions = {
/**
Expand Down
3 changes: 2 additions & 1 deletion dist/mkcert/record.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Config, { RecordHash, RecordMate } from './config';
import type Config from './config';
import type { RecordHash, RecordMate } from './config';
export type RecordProps = {
config: Config;
};
Expand Down
2 changes: 1 addition & 1 deletion dist/mkcert/version.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Config from './config';
import type Config from './config';
export type VersionMangerProps = {
config: Config;
};
Expand Down
2 changes: 1 addition & 1 deletion plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createLogger, type PluginOption } from 'vite'

import { PLUGIN_NAME } from './lib/constant'
import { getDefaultHosts } from './lib/util'
import Mkcert, { MkcertBaseOptions } from './mkcert/index'
import Mkcert, { type MkcertBaseOptions } from './mkcert/index'

export { BaseSource, type SourceInfo } from './mkcert/source'

Expand Down
4 changes: 2 additions & 2 deletions plugin/lib/constant.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os from 'os'
import path from 'path'
import os from 'node:os'
import path from 'node:path'

export const PKG_NAME = 'vite-plugin-mkcert'

Expand Down
Loading

0 comments on commit 2ccce41

Please sign in to comment.