From a975868d39b37e14b2fc0a6b3e6495d681d5ce1c Mon Sep 17 00:00:00 2001 From: hemengke <23536175@qq.com> Date: Thu, 30 May 2024 09:53:28 +0800 Subject: [PATCH] refactor!: rename `VPPTPluginOptions` to `VitePublicTypescriptOptions` --- package.json | 2 +- src/node/helper/default-options.ts | 4 ++-- src/node/helper/utils.ts | 10 +++++----- src/node/index.ts | 4 ++-- src/node/interface.ts | 2 +- src/node/processor/FileCacheProcessor.ts | 2 +- src/node/processor/ManifestCacheProcessor.ts | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index cdbe772..bd02167 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "test:serve": "vitest run -c vitest.config.e2e.ts", "test:build": "cross-env VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts", "commitlint": "commitlint -e", - "lint": "eslint . --fix", + "lint": "eslint --fix", "up": "taze -I -w", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", "bump": "bumpp package.json -c --no-push -t --all -x \"pnpm run changelog\"" diff --git a/src/node/helper/default-options.ts b/src/node/helper/default-options.ts index 6277ef5..acfafbb 100644 --- a/src/node/helper/default-options.ts +++ b/src/node/helper/default-options.ts @@ -1,6 +1,6 @@ import path from 'node:path' import { type ResolvedConfig, normalizePath } from 'vite' -import { type VPPTPluginOptions } from '../interface' +import { type VitePublicTypescriptOptions } from '../interface' import { type OptionsTypeWithDefault } from './utils' function resolve(root?: string, ...args: string[]) { @@ -9,7 +9,7 @@ function resolve(root?: string, ...args: string[]) { export function resolveOptions( resolvedViteConfig?: ResolvedConfig, - options?: VPPTPluginOptions, + options?: VitePublicTypescriptOptions, ): OptionsTypeWithDefault { const publicDir = resolve(resolvedViteConfig?.root, resolvedViteConfig?.publicDir || 'public') diff --git a/src/node/helper/utils.ts b/src/node/helper/utils.ts index 1d0cb3d..b088e35 100644 --- a/src/node/helper/utils.ts +++ b/src/node/helper/utils.ts @@ -7,7 +7,7 @@ import { isCI, isWindows } from 'std-env' import { type ResolvedConfig, createLogger, normalizePath } from 'vite' import { name as pkgName } from '../../../package.json' import { globalConfig } from '../global-config' -import { type VPPTPluginOptions } from '../interface' +import { type VitePublicTypescriptOptions } from '../interface' import { manifestCache, saveManifestPathToDisk } from '../manifest-cache' import { initCacheProcessor } from '../processor/processor' import { disableManifestHmr } from './server' @@ -16,7 +16,7 @@ const debug = createDebug('vite-plugin-public-typescript:util ===> ') // type PartialBy = Omit & Partial> -export type OptionsTypeWithDefault = Required +export type OptionsTypeWithDefault = Required export { pkgName } @@ -89,11 +89,11 @@ const HASH_LEN = 8 export const linebreak = isWindows ? '\r\n' : '\n' -export function getHashLen(hash: VPPTPluginOptions['hash']) { +export function getHashLen(hash: VitePublicTypescriptOptions['hash']) { return typeof hash === 'number' ? hash : HASH_LEN } -export function extractHashFromFileName(filename: string, hash: VPPTPluginOptions['hash']) { +export function extractHashFromFileName(filename: string, hash: VitePublicTypescriptOptions['hash']) { const hashLen = getHashLen(hash) const regex = new RegExp(`\\.([\\w\\d]{${hashLen}})\\.?`) const match = filename.match(regex) @@ -103,7 +103,7 @@ export function extractHashFromFileName(filename: string, hash: VPPTPluginOption return '' } -export function getContentHash(chunk: string | Uint8Array | undefined, hash?: VPPTPluginOptions['hash']) { +export function getContentHash(chunk: string | Uint8Array | undefined, hash?: VitePublicTypescriptOptions['hash']) { if (!chunk) { return '' } diff --git a/src/node/index.ts b/src/node/index.ts index 0c65a75..b86c0b6 100644 --- a/src/node/index.ts +++ b/src/node/index.ts @@ -18,14 +18,14 @@ import { setupGlobalConfig, setupManifestCache, } from './helper/utils' -import { type VPPTPluginOptions } from './interface' +import { type VitePublicTypescriptOptions } from './interface' import { getManifest, manifestCache } from './manifest-cache' import { pluginServer } from './plugins/server' import { pluginVirtual } from './plugins/virtual' const debug = createDebug('vite-plugin-public-typescript:index ===> ') -export default function publicTypescript(options: VPPTPluginOptions = {}) { +export default function publicTypescript(options: VitePublicTypescriptOptions = {}) { debug('user options:', options) let viteConfig: ResolvedConfig diff --git a/src/node/interface.ts b/src/node/interface.ts index 0b40dc2..48e74d2 100644 --- a/src/node/interface.ts +++ b/src/node/interface.ts @@ -1,7 +1,7 @@ import { type BuildOptions } from 'esbuild' import { type ESBuildPluginBabelOptions } from './build/babel' -export interface VPPTPluginOptions { +export interface VitePublicTypescriptOptions { /** * @description dir of input typescript files * @default 'public-typescript' diff --git a/src/node/processor/FileCacheProcessor.ts b/src/node/processor/FileCacheProcessor.ts index c1f153c..9eaf692 100644 --- a/src/node/processor/FileCacheProcessor.ts +++ b/src/node/processor/FileCacheProcessor.ts @@ -1,6 +1,6 @@ -import path from 'node:path' import createDebug from 'debug' import fs from 'fs-extra' +import path from 'node:path' import colors from 'picocolors' import { normalizePath } from 'vite' import { globalConfig } from '../global-config' diff --git a/src/node/processor/ManifestCacheProcessor.ts b/src/node/processor/ManifestCacheProcessor.ts index 6cec403..044f52a 100644 --- a/src/node/processor/ManifestCacheProcessor.ts +++ b/src/node/processor/ManifestCacheProcessor.ts @@ -1,5 +1,5 @@ -import path from 'node:path' import createDebug from 'debug' +import path from 'node:path' import { normalizePath } from 'vite' import { type GlobalConfig } from '../global-config/GlobalConfigBuilder' import { type CacheValueEx } from '../manifest-cache'