diff --git a/.changeset/plenty-beers-guess.md b/.changeset/plenty-beers-guess.md new file mode 100644 index 000000000000..c53ba26c3a35 --- /dev/null +++ b/.changeset/plenty-beers-guess.md @@ -0,0 +1,7 @@ +--- +'@modern-js/plugin-v2': patch +--- + +feat: plugin api add isPluginExists + +feat: 插件 api 增加 isPluginExists diff --git a/packages/toolkit/plugin-v2/src/cli/api.ts b/packages/toolkit/plugin-v2/src/cli/api.ts index 79922afdf652..bf9faa7537eb 100644 --- a/packages/toolkit/plugin-v2/src/cli/api.ts +++ b/packages/toolkit/plugin-v2/src/cli/api.ts @@ -8,6 +8,7 @@ import type { DeepPartial } from '../types/utils'; export function initPluginAPI({ context, + pluginManager, }: { context: InternalContext; pluginManager: PluginManager; @@ -74,6 +75,7 @@ export function initPluginAPI({ } return { + isPluginExists: pluginManager.isPluginExists, getAppContext, getConfig, getNormalizedConfig, diff --git a/packages/toolkit/plugin-v2/src/cli/index.ts b/packages/toolkit/plugin-v2/src/cli/index.ts index 9c2bb2c07806..100370208d9c 100644 --- a/packages/toolkit/plugin-v2/src/cli/index.ts +++ b/packages/toolkit/plugin-v2/src/cli/index.ts @@ -1,4 +1,4 @@ export { initPluginAPI } from './api'; export { initAppContext, createContext } from './context'; export { initHooks, type Hooks } from './hooks'; -export { cli, createLoadedConfig, initAppDir } from './run'; +export { cli, createLoadedConfig, initAppDir, createCli } from './run'; diff --git a/packages/toolkit/plugin-v2/src/cli/run/index.ts b/packages/toolkit/plugin-v2/src/cli/run/index.ts index 90521fdf56af..69766707aa29 100644 --- a/packages/toolkit/plugin-v2/src/cli/run/index.ts +++ b/packages/toolkit/plugin-v2/src/cli/run/index.ts @@ -1,5 +1,5 @@ import { createCli } from './create'; export { createLoadedConfig } from './config/createLoadedConfig'; export { initAppDir } from './utils/initAppDir'; - +export { createCli }; export const cli = createCli(); diff --git a/packages/toolkit/plugin-v2/src/types/cli/api.ts b/packages/toolkit/plugin-v2/src/types/cli/api.ts index b6feda706d31..2f04bb7e9b51 100644 --- a/packages/toolkit/plugin-v2/src/types/cli/api.ts +++ b/packages/toolkit/plugin-v2/src/types/cli/api.ts @@ -35,6 +35,7 @@ import type { CLIPluginExtends } from './plugin'; * Define a generic CLI plugin API that provider can extend as needed. */ export type CLIPluginAPI = Readonly<{ + isPluginExists: (name: string) => boolean; getAppContext: () => Readonly & Extends['extendContext']>; getConfig: () => Readonly; getNormalizedConfig: () => Readonly;