@@ -2,32 +2,47 @@ import {CLIChoice, CLIQuestion} from "../question.js";
22import { Answers , CheckboxQuestion , Question } from "inquirer" ;
33import { CLIConfig } from "../../config/config" ;
44import { MxOpsScenesPathQuestion } from "./mxOpsScenesPathQuestion.js" ;
5+ import { CustomAddressToGiveEGLDQuestion } from "./customAddressToGiveEGLDQuestion.js" ;
56
6- export abstract class FeaturesQuestion extends CLIQuestion {
7+ export class FeaturesQuestion extends CLIQuestion {
78
89 private static apiChoice = 'Enable full API (like api.multiversx.com)'
10+ private static xExplorerChoice = 'Enable xExplorer, requires the full API'
911 private static mxOpsChoice = 'Run MxOps scenes at startup'
12+ static readonly giveToCustomAddressChoice = 'Give 1,000,000 EGLD to a custom address (otherwise a new one will be generated for you)'
1013
1114 override async getQuestion ( ) : Promise < Question > {
1215 const question : CheckboxQuestion = {
1316 type : 'checkbox' ,
1417 name : 'choice' ,
1518 message : 'Which features do you want to enable ?' ,
16- choices : this . generalFeatures . concat ( this . cliChoices )
19+ choices : this . generalFeatures
1720 }
1821
1922 return question
2023 }
2124
2225 private generalFeatures : CLIChoice [ ] = [
2326 FeaturesQuestion . apiChoice ,
24- FeaturesQuestion . mxOpsChoice
27+ FeaturesQuestion . xExplorerChoice ,
28+ FeaturesQuestion . mxOpsChoice ,
29+ FeaturesQuestion . giveToCustomAddressChoice
2530 ]
2631
27- abstract cliChoices : CLIChoice [ ]
28-
2932 override async handleAnswer ( answers : Answers , config : CLIConfig ) : Promise < CLIQuestion [ ] > {
30- if ( answers . choice . includes ( FeaturesQuestion . apiChoice ) ) {
33+ const hasAPI = answers . choice . includes ( FeaturesQuestion . apiChoice )
34+ if ( answers . choice . includes ( FeaturesQuestion . xExplorerChoice ) ) {
35+ if ( hasAPI ) {
36+ config . shouldHaveXExplorer = true
37+ } else {
38+ const errorMessage = '\n❌ You have to opt for the full API in order to run xExplorer.\n'
39+ console . log ( errorMessage )
40+
41+ return [ new FeaturesQuestion ( ) ]
42+ }
43+ }
44+
45+ if ( hasAPI ) {
3146 config . shouldHaveElasticSearch = true
3247 config . shouldHaveMySQL = true
3348 config . shouldHaveRabbitMQ = true
@@ -41,6 +56,10 @@ export abstract class FeaturesQuestion extends CLIQuestion {
4156 questions . push ( new MxOpsScenesPathQuestion ( ) )
4257 }
4358
59+ if ( answers . choice . includes ( FeaturesQuestion . giveToCustomAddressChoice ) ) {
60+ questions . push ( new CustomAddressToGiveEGLDQuestion ( ) )
61+ }
62+
4463 return questions
4564 }
4665}
0 commit comments