Skip to content

Commit d2c6869

Browse files
authored
fix: Add generator questions. (#25)
* fix: Add generator questions. Signed-off-by: Paolo Insogna <paolo@cowtech.it> * fixup Signed-off-by: Paolo Insogna <paolo@cowtech.it> --------- Signed-off-by: Paolo Insogna <paolo@cowtech.it>
1 parent 8cea78d commit d2c6869

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

lib/generator.js

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,63 @@ export class Generator extends ServiceGenerator {
3030
var: 'PLT_KAFKA_BROKER',
3131
label: 'Which is the address of one of the Kafka brokers?',
3232
default: 'localhost:9092',
33-
type: 'string'
33+
type: 'string',
34+
configValue: 'broker'
3435
},
3536
{
3637
var: 'PLT_KAFKA_TOPIC',
3738
label: 'Which Kafka topic do you want to use?',
3839
default: 'events',
39-
type: 'string'
40+
type: 'string',
41+
configValue: 'topic'
4042
},
4143
{
4244
var: 'PLT_KAFKA_URL',
4345
label: 'Which URL you want to forward messages to?',
4446
default: 'http://localhost:3000',
45-
type: 'string'
47+
type: 'string',
48+
configValue: 'url'
4649
},
4750
{
4851
var: 'PLT_KAFKA_CONSUMER_GROUP',
4952
label: 'Which Kafka consumer group do you want to use?',
5053
default: 'plt-kafka-hooks-consumer',
51-
type: 'string'
54+
type: 'string',
55+
configValue: 'consumerGroup'
5256
}
5357
]
5458
}
5559

60+
async prepareQuestions () {
61+
this.questions.push({
62+
type: 'input',
63+
name: 'broker',
64+
message: 'Which is the address of one of the Kafka brokers?',
65+
default: 'localhost:9092'
66+
})
67+
68+
this.questions.push({
69+
type: 'input',
70+
name: 'topic',
71+
message: 'Which Kafka topic do you want to use?',
72+
default: 'topic'
73+
})
74+
75+
this.questions.push({
76+
type: 'input',
77+
name: 'url',
78+
message: 'Which URL you want to forward messages to?',
79+
default: 'http://localhost:3000'
80+
})
81+
82+
this.questions.push({
83+
type: 'input',
84+
name: 'consumerGroup',
85+
message: 'Which Kafka consumer group do you want to use?',
86+
default: 'consumerGroup'
87+
})
88+
}
89+
5690
async generatePackageJson () {
5791
const template = await super.generatePackageJson()
5892

test/generator.test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,29 @@ test('should return Generator config fields definitions', async () => {
5050
var: 'PLT_KAFKA_BROKER',
5151
label: 'Which is the address of one of the Kafka brokers?',
5252
default: 'localhost:9092',
53-
type: 'string'
53+
type: 'string',
54+
configValue: 'broker'
5455
},
5556
{
5657
var: 'PLT_KAFKA_TOPIC',
5758
label: 'Which Kafka topic do you want to use?',
5859
default: 'events',
59-
type: 'string'
60+
type: 'string',
61+
configValue: 'topic'
6062
},
6163
{
6264
var: 'PLT_KAFKA_URL',
6365
label: 'Which URL you want to forward messages to?',
6466
default: 'http://localhost:3000',
65-
type: 'string'
67+
type: 'string',
68+
configValue: 'url'
6669
},
6770
{
6871
var: 'PLT_KAFKA_CONSUMER_GROUP',
6972
label: 'Which Kafka consumer group do you want to use?',
7073
default: 'plt-kafka-hooks-consumer',
71-
type: 'string'
74+
type: 'string',
75+
configValue: 'consumerGroup'
7276
}
7377
])
7478
})

0 commit comments

Comments
 (0)