Skip to content

Commit

Permalink
feat: plugin api add isPluginExists (#6713)
Browse files Browse the repository at this point in the history
  • Loading branch information
caohuilin authored Jan 10, 2025
1 parent 86d2edc commit 775bc3b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changeset/plenty-beers-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modern-js/plugin-v2': patch
---

feat: plugin api add isPluginExists

feat: 插件 api 增加 isPluginExists
2 changes: 2 additions & 0 deletions packages/toolkit/plugin-v2/src/cli/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { DeepPartial } from '../types/utils';

export function initPluginAPI<Extends extends CLIPluginExtends>({
context,
pluginManager,
}: {
context: InternalContext<Extends>;
pluginManager: PluginManager;
Expand Down Expand Up @@ -74,6 +75,7 @@ export function initPluginAPI<Extends extends CLIPluginExtends>({
}

return {
isPluginExists: pluginManager.isPluginExists,
getAppContext,
getConfig,
getNormalizedConfig,
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/plugin-v2/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -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';
2 changes: 1 addition & 1 deletion packages/toolkit/plugin-v2/src/cli/run/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createCli } from './create';
export { createLoadedConfig } from './config/createLoadedConfig';
export { initAppDir } from './utils/initAppDir';

export { createCli };
export const cli = createCli();
1 change: 1 addition & 0 deletions packages/toolkit/plugin-v2/src/types/cli/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type { CLIPluginExtends } from './plugin';
* Define a generic CLI plugin API that provider can extend as needed.
*/
export type CLIPluginAPI<Extends extends CLIPluginExtends> = Readonly<{
isPluginExists: (name: string) => boolean;
getAppContext: () => Readonly<AppContext<Extends> & Extends['extendContext']>;
getConfig: () => Readonly<Extends['config']>;
getNormalizedConfig: () => Readonly<Extends['normalizedConfig']>;
Expand Down

0 comments on commit 775bc3b

Please sign in to comment.