Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit af5b47f

Browse files
authored
Merge pull request #144 from microsoft/qnamaker-fixes
Qnamaker fixes
2 parents 0b72671 + 838d7f3 commit af5b47f

39 files changed

+708
-644
lines changed

packages/cli/README.md

Lines changed: 164 additions & 260 deletions
Large diffs are not rendered by default.

packages/cli/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"@oclif/plugin-help": "~2.1.6",
1313
"@microsoft/bf-chatdown": "1.0.0",
1414
"@microsoft/bf-cli-config": "1.0.0",
15-
"@microsoft/bf-dialog": "1.0.0",
1615
"@microsoft/bf-qnamaker": "1.0.0",
1716
"chalk": "2.4.1",
1817
"cli-ux": "^5.3.0",
@@ -61,7 +60,6 @@
6160
"@oclif/plugin-help",
6261
"@microsoft/bf-chatdown",
6362
"@microsoft/bf-cli-config",
64-
"@microsoft/bf-dialog",
6563
"@microsoft/bf-qnamaker"
6664
],
6765
"hooks": {

packages/config/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ USAGE
3333
* [`bf config:set:qnamaker`](#bf-configsetqnamaker)
3434
* [`bf config:set:telemetry`](#bf-configsettelemetry)
3535
* [`bf config:show`](#bf-configshow)
36-
* [`bf config:show:qnamaker [FILE]`](#bf-configshowqnamaker-file)
36+
* [`bf config:show:qnamaker`](#bf-configshowqnamaker)
3737
* [`bf config:show:telemetry`](#bf-configshowtelemetry)
3838

3939
## `bf `
@@ -73,8 +73,10 @@ USAGE
7373
$ bf config:set:qnamaker
7474
7575
OPTIONS
76-
--kbid=kbid QnAMaker kbid to be set
77-
--subscriptionkey=subscriptionkey QnAMaker subscriptionkey to be set
76+
--endpointKey=endpointKey QnAMaker endpointKey to be set
77+
--hostname=hostname QnAMaker hostname to be set
78+
--kbId=kbId QnAMaker kbId to be set
79+
--subscriptionKey=subscriptionKey QnAMaker subscriptionkey to be set
7880
```
7981

8082
_See code: [src/commands/config/set/qnamaker.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/config/set/qnamaker.ts)_
@@ -108,18 +110,16 @@ OPTIONS
108110

109111
_See code: [src/commands/config/show.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/config/show.ts)_
110112

111-
## `bf config:show:qnamaker [FILE]`
113+
## `bf config:show:qnamaker`
112114

113-
describe the command here
115+
Display QnAMaker settings
114116

115117
```
116118
USAGE
117-
$ bf config:show:qnamaker [FILE]
119+
$ bf config:show:qnamaker
118120
119121
OPTIONS
120-
-f, --force
121-
-h, --help show CLI help
122-
-n, --name=name name to print
122+
-h, --help show CLI help
123123
```
124124

125125
_See code: [src/commands/config/show/qnamaker.ts](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/config/show/qnamaker.ts)_

packages/config/src/commands/config/set/qnamaker.ts

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,47 @@ export default class ConfigSetQnamaker extends Command {
55
static description = 'Set the QnAMaker config data'
66

77
static flags = {
8-
kbid: flags.string({description: 'QnAMaker kbid to be set'}),
9-
subscriptionkey: flags.string({description: 'QnAMaker subscriptionkey to be set'}),
8+
kbId: flags.string({description: 'QnAMaker kbId to be set'}),
9+
subscriptionKey: flags.string({description: 'QnAMaker subscriptionkey to be set'}),
10+
hostname: flags.string({description: 'QnAMaker hostname to be set'}),
11+
endpointKey: flags.string({description: 'QnAMaker endpointKey to be set'}),
1012
}
1113

1214
async run() {
1315
const {flags} = this.parse(ConfigSetQnamaker)
1416
let userConfig: Config = await getConfigFile(this.config.configDir)
15-
let qnamaker = userConfig.qnamaker
1617

17-
if (flags.subscriptionkey) {
18-
if (qnamaker) {
19-
qnamaker.subscriptionKey = flags.subscriptionkey
20-
} else {
21-
userConfig.qnamaker = {subscriptionKey: flags.subscriptionkey}
22-
}
23-
this.log('Subscriptionkey set to ' + flags.subscriptionkey)
18+
if (flags.subscriptionKey) {
19+
this.setValue('subscriptionKey', flags.subscriptionKey, userConfig)
20+
}
21+
22+
if (flags.kbId) {
23+
this.setValue('kbId', flags.kbId, userConfig)
24+
}
25+
26+
if (flags.hostname) {
27+
this.setValue('hostname', flags.hostname, userConfig)
2428
}
2529

26-
if (flags.kbid) {
27-
if (qnamaker) {
28-
qnamaker.kbId = flags.kbid
29-
} else {
30-
userConfig.qnamaker = {kbId: flags.kbid}
31-
}
32-
this.log('Kbid set to ' + flags.kbid)
30+
if (flags.endpointKey) {
31+
this.setValue('endpointKey', flags.endpointKey, userConfig)
3332
}
3433

35-
if (flags.kbid || flags.subscriptionkey) {
34+
if (flags.kbId || flags.subscriptionKey || flags.hostname || flags.endpointKey) {
3635
await writeConfigFile(this.config.configDir, userConfig)
3736
} else {
3837
this.log('Plase specify flag')
3938
this._help()
4039
}
4140
}
41+
42+
setValue(key: string, value: string, userConfig: Config) {
43+
let qnamaker = userConfig.qnamaker
44+
if (!qnamaker) {
45+
userConfig.qnamaker = {}
46+
}
47+
48+
userConfig.qnamaker[key] = value
49+
this.log(`${key} set to ${value}`)
50+
}
4251
}

packages/config/test/commands/config/set/qnamaker.test.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,56 @@ describe('config:set:qnamaker', () => {
1313

1414
test
1515
.stdout()
16-
.command(['config:set:qnamaker', '--kbid', 'aaaaaaaa'])
16+
.command(['config:set:qnamaker', '--kbId', 'aaaaaaaa'])
1717
.it('Sets kbid in config file', async ctx => {
1818
let config = await fs.readJSON(getConfigFile())
1919
expect(config.qnamaker.kbId).to.contain('aaaaaaaa')
2020
})
2121

2222
test
2323
.stdout()
24-
.command(['config:set:qnamaker', '--subscriptionkey', 'aaaaaaaa'])
24+
.command(['config:set:qnamaker', '--subscriptionKey', 'aaaaaaaa'])
2525
.it('Sets subscriptionkey in config file', async ctx => {
2626
let config = await fs.readJSON(getConfigFile())
2727
expect(config.qnamaker.subscriptionKey).to.contain('aaaaaaaa')
2828
})
2929

30+
test
31+
.stdout()
32+
.command(['config:set:qnamaker', '--endpointKey', 'aaaaaaaa'])
33+
.it('Sets endpointKey in config file', async ctx => {
34+
let config = await fs.readJSON(getConfigFile())
35+
expect(config.qnamaker.subscriptionKey).to.contain('aaaaaaaa')
36+
})
37+
38+
test
39+
.stdout()
40+
.command(['config:set:qnamaker', '--hostname', 'aaaaaaaa'])
41+
.it('Sets hostname in config file', async ctx => {
42+
let config = await fs.readJSON(getConfigFile())
43+
expect(config.qnamaker.subscriptionKey).to.contain('aaaaaaaa')
44+
})
45+
3046
test
3147
.stdout()
3248
.command(['config:set:qnamaker'])
3349
.it('Asks for a flag', ctx => {
3450
expect(ctx.stdout).to.contain('Plase specify flag')
3551
})
3652
})
53+
54+
describe('config:set:qnamaker empty config file', () => {
55+
56+
after(async function() {
57+
await deleteTestConfigFile()
58+
});
59+
60+
test
61+
.stdout()
62+
.command(['config:set:qnamaker', '--kbId', 'aaaaaaaa'])
63+
.it('Sets kbid in config file', async ctx => {
64+
let config = await fs.readJSON(getConfigFile())
65+
expect(config.qnamaker.kbId).to.contain('aaaaaaaa')
66+
})
67+
})
68+

0 commit comments

Comments
 (0)