@@ -40,6 +40,8 @@ export type PluginRunnerOptions = {
4040    schema : Model ; 
4141    schemaPath : string ; 
4242    output ?: string ; 
43+     withPlugins ?: string [ ] ; 
44+     withoutPlugins ?: string [ ] ; 
4345    defaultPlugins : boolean ; 
4446    compile : boolean ; 
4547} ; 
@@ -137,7 +139,17 @@ export class PluginRunner {
137139        const  project  =  createProject ( ) ; 
138140        for  ( const  {  name,  description,  run,  options : pluginOptions  }  of  corePlugins )  { 
139141            const  options  =  {  ...pluginOptions ,  prismaClientPath } ; 
140-             const  r  =  await  this . runPlugin ( name ,  description ,  run ,  runnerOptions ,  options ,  dmmf ,  shortNameMap ,  project ) ; 
142+             const  r  =  await  this . runPlugin ( 
143+                 name , 
144+                 description , 
145+                 run , 
146+                 runnerOptions , 
147+                 options , 
148+                 dmmf , 
149+                 shortNameMap , 
150+                 project , 
151+                 true 
152+             ) ; 
141153            warnings . push ( ...( r ?. warnings  ??  [ ] ) ) ;  // the null-check is for backward compatibility 
142154
143155            if  ( r . dmmf )  { 
@@ -162,7 +174,17 @@ export class PluginRunner {
162174        // run user plugins 
163175        for  ( const  {  name,  description,  run,  options : pluginOptions  }  of  userPlugins )  { 
164176            const  options  =  {  ...pluginOptions ,  prismaClientPath } ; 
165-             const  r  =  await  this . runPlugin ( name ,  description ,  run ,  runnerOptions ,  options ,  dmmf ,  shortNameMap ,  project ) ; 
177+             const  r  =  await  this . runPlugin ( 
178+                 name , 
179+                 description , 
180+                 run , 
181+                 runnerOptions , 
182+                 options , 
183+                 dmmf , 
184+                 shortNameMap , 
185+                 project , 
186+                 false 
187+             ) ; 
166188            warnings . push ( ...( r ?. warnings  ??  [ ] ) ) ;  // the null-check is for backward compatibility 
167189        } 
168190
@@ -180,8 +202,7 @@ export class PluginRunner {
180202        if  ( existingPrisma )  { 
181203            corePlugins . push ( existingPrisma ) ; 
182204            plugins . splice ( plugins . indexOf ( existingPrisma ) ,  1 ) ; 
183-         }  else  if  ( options . defaultPlugins  ||  plugins . some ( ( p )  =>  p . provider  !==  CorePlugins . Prisma ) )  { 
184-             // "@core/prisma" is enabled as default or if any other plugin is configured 
205+         }  else  if  ( options . defaultPlugins )  { 
185206            corePlugins . push ( this . makeCorePlugin ( CorePlugins . Prisma ,  options . schemaPath ,  { } ) ) ; 
186207        } 
187208
@@ -215,7 +236,8 @@ export class PluginRunner {
215236
216237        if  ( 
217238            ! corePlugins . some ( ( p )  =>  p . provider  ===  CorePlugins . Zod )  && 
218-             ( options . defaultPlugins  ||  corePlugins . some ( ( p )  =>  p . provider  ===  CorePlugins . Enhancer ) )  && 
239+             options . defaultPlugins  && 
240+             corePlugins . some ( ( p )  =>  p . provider  ===  CorePlugins . Enhancer )  && 
219241            hasValidation 
220242        )  { 
221243            // ensure "@core/zod" is enabled if "@core/enhancer" is enabled and there're validation rules 
@@ -319,10 +341,17 @@ export class PluginRunner {
319341        options : PluginDeclaredOptions , 
320342        dmmf : DMMF . Document  |  undefined , 
321343        shortNameMap : Map < string ,  string >  |  undefined , 
322-         project : Project 
344+         project : Project , 
345+         isCorePlugin : boolean 
323346    )  { 
347+         if  ( ! isCorePlugin  &&  ! this . isPluginEnabled ( name ,  runnerOptions ) )  { 
348+             ora ( `Plugin "${ name }  ) . start ( ) . warn ( ) ; 
349+             return  {  warnings : [ ]  } ; 
350+         } 
351+ 
324352        const  title  =  description  ??  `Running plugin ${ colors . cyan ( name ) }  ; 
325353        const  spinner  =  ora ( title ) . start ( ) ; 
354+ 
326355        try  { 
327356            const  r  =  await  telemetry . trackSpan < PluginResult  |  void > ( 
328357                'cli:plugin:start' , 
@@ -358,6 +387,18 @@ export class PluginRunner {
358387        } 
359388    } 
360389
390+     private  isPluginEnabled ( name : string ,  runnerOptions : PluginRunnerOptions )  { 
391+         if  ( runnerOptions . withPlugins  &&  ! runnerOptions . withPlugins . includes ( name ) )  { 
392+             return  false ; 
393+         } 
394+ 
395+         if  ( runnerOptions . withoutPlugins  &&  runnerOptions . withoutPlugins . includes ( name ) )  { 
396+             return  false ; 
397+         } 
398+ 
399+         return  true ; 
400+     } 
401+ 
361402    private  getPluginModulePath ( provider : string ,  schemaPath : string )  { 
362403        if  ( process . env . ZENSTACK_TEST  ===  '1'  &&  provider . startsWith ( '@zenstackhq/' ) )  { 
363404            // test code runs with its own sandbox of node_modules, make sure we don't 
0 commit comments