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

Commit 55e0539

Browse files
support extract authoringKey from config (#731)
Co-authored-by: Vishwac Sena Kannan <[email protected]>
1 parent 7a3cc7d commit 55e0539

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/luis/src/commands/luis/build.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const Settings = require('@microsoft/bf-lu/lib/parser/lubuild/settings')
1616
const MultiLanguageRecognizer = require('@microsoft/bf-lu/lib/parser/lubuild/multi-language-recognizer')
1717
const Recognizer = require('@microsoft/bf-lu/lib/parser/lubuild/recognizer')
1818
const Builder = require('@microsoft/bf-lu/lib/parser/lubuild/builder').Builder
19+
const utils = require('../../utils/index')
1920

2021
export default class LuisBuild extends Command {
2122
static description = 'Build lu files to train and publish luis applications'
@@ -27,7 +28,7 @@ export default class LuisBuild extends Command {
2728
static flags: flags.Input<any> = {
2829
help: flags.help({char: 'h'}),
2930
in: flags.string({char: 'i', description: 'Lu file or folder'}),
30-
authoringKey: flags.string({description: 'LUIS authoring key', required: true}),
31+
authoringKey: flags.string({description: 'LUIS authoring key'}),
3132
botName: flags.string({description: 'Bot name'}),
3233
region: flags.string({description: 'LUIS authoring region [westus|westeurope|australiaeast]', default: 'westus'}),
3334
out: flags.string({char: 'o', description: 'Output file or folder name. If not specified, current directory will be used as output'}),
@@ -43,6 +44,7 @@ export default class LuisBuild extends Command {
4344
async run() {
4445
try {
4546
const {flags} = this.parse(LuisBuild)
47+
const userConfig = await utils.getUserConfig(this.config.configDir)
4648

4749
flags.stdin = await this.readStdin()
4850

@@ -66,6 +68,12 @@ export default class LuisBuild extends Command {
6668
throw new CLIError('Missing input. Please use stdin or pass a file or folder location with --in flag')
6769
}
6870

71+
if (!flags.authoringKey && (!userConfig || !userConfig.authoringKey)) {
72+
throw new CLIError('Missing luis authoring key. Please pass authoring key with --authoringKey flag')
73+
} else {
74+
flags.authoringKey = flags.authoringKey || userConfig.authoringKey
75+
}
76+
6977
if (!flags.botName) {
7078
throw new CLIError('Missing bot name. Please pass bot name with --botName flag')
7179
}

packages/luis/test/commands/luis/build.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('luis:build cli parameters test', () => {
2626
.stderr()
2727
.command(['luis:build', '--in', `${path.join(__dirname, './../../fixtures/testcases/lubuild')}`, '--botName', 'Contoso'])
2828
.it('displays an error if any required input parameters are missing', ctx => {
29-
expect(ctx.stderr).to.contain('Missing required flag:\n --authoringKey AUTHORINGKEY')
29+
expect(ctx.stderr).to.contain('Missing luis authoring key. Please pass authoring key with --authoringKey flag')
3030
})
3131

3232
test

0 commit comments

Comments
 (0)