File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 33 type Plugin ,
44 type PluginV1alpha1ConsoleApiListPluginsRequest ,
55} from "@halo-dev/api-client" ;
6- import { checkbox } from "@inquirer/prompts" ;
6+ import { checkbox , confirm } from "@inquirer/prompts" ;
77import cac , { type CAC } from "cac" ;
88import ora , { type Ora } from "ora" ;
99
@@ -754,6 +754,30 @@ function buildPluginCli(runtime: RuntimeContext): CAC {
754754
755755 if ( options . json ) {
756756 printJson ( response . data ) ;
757+ return ;
758+ }
759+
760+ const pluginName = response . data . metadata . name ;
761+ if ( ! response . data . spec . enabled ) {
762+ let shouldEnable = options . yes ?? false ;
763+ if ( ! shouldEnable && process . stdin . isTTY && process . stdout . isTTY ) {
764+ shouldEnable = await confirm ( {
765+ message : `Enable plugin ${ pluginName } now?` ,
766+ default : true ,
767+ } ) ;
768+ }
769+
770+ if ( shouldEnable ) {
771+ await clients . console . plugin . plugin . changePluginRunningState ( {
772+ name : pluginName ,
773+ pluginRunningStateRequest : { enable : true } ,
774+ } ) ;
775+ process . stdout . write ( `Enabled plugin ${ pluginName } .\n` ) ;
776+ } else {
777+ process . stdout . write (
778+ `Plugin ${ pluginName } installed but not enabled. Run \`halo plugin enable ${ pluginName } \` to enable it.\n` ,
779+ ) ;
780+ }
757781 }
758782 } ) ;
759783
You can’t perform that action at this time.
0 commit comments