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

Commit 598c15a

Browse files
author
Eyal
authored
Merge branch 'master' into scheyal-patch-3
2 parents 0c8ae7b + b9663e7 commit 598c15a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+999
-406
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# BF Command Line Interface
22

33
[![Build Status](https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/CLI/Botframework-CLI-CI-PR?branchName=master)](https://fuselabs.visualstudio.com/SDK_v4/_build/latest?definitionId=537&branchName=master)
4-
[![Coverage Status](https://coveralls.io/repos/github/microsoft/botframework-cli/badge.svg?branch=master)](https://coveralls.io/github/microsoft/botframework-cli?branch=master)
4+
[![Coverage Status](https://img.shields.io/coveralls/github/microsoft/botframework-cli/master)](https://coveralls.io/github/microsoft/botframework-cli?branch=master)
55

66
As part of the effort to improve Bot Framework SDK toolset we are happy to announce the introduction of a new Command Line Interface tool which will eventually replace the suite of tools currently used during Bot development. The new CLI, called BF is being released as an early preview. We have migrated Chatdown as a first proof of concept plugin. The new Chatdown plugin is fully functional and identical to the standalone tool (with some minor usage bug fixes). Early adopters are welcome to switch to the new CLI. In the meantime the old and new tools will exist side by side for at least a full release cycle.
77

88
## Available Commands
99
The following commands are currently available:
1010
* [Chatdown](https://github.com/microsoft/botframework-cli/tree/master/packages/cli#bf-chatdown)
11-
* [QnAMaker (Preview)](https://github.com/microsoft/botframework-cli/tree/master/packages/cli#bf-qnamaker)
11+
* [QnAMaker](https://github.com/microsoft/botframework-cli/tree/master/packages/cli#bf-qnamaker)
1212
* [Config](https://github.com/microsoft/botframework-cli/tree/master/packages/cli#bf-config)
13+
* [Luis](https://github.com/microsoft/botframework-cli/tree/emimunoz/luis/packages/cli#bf-luis)
1314

1415
## Plugin Architecture
1516
BF CLI is based on [OClif](https://github.com/oclif/oclif) Framework and inherits its command line parsing style, and plugin architecture.

packages/chatdown/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
Tool for parsing chat files and outputting replayable activities
55

66
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7-
[![Version](https://img.shields.io/npm/v/chatdown.svg)](https://www.npmjs.com/package/@microsoft/bf-chatdown)
8-
[![Downloads/week](https://img.shields.io/npm/dw/chatdown.svg)](https://www.npmjs.com/package/@microsoft/bf-chatdown)
9-
[![License](https://img.shields.io/npm/l/chatdown.svg)](https://github.com/microsoft/botframework-cli/blob/master/packages/chatdown/package.json)
7+
[![Version](https://img.shields.io/npm/v/@microsoft/bf-chatdown)](https://www.npmjs.com/package/@microsoft/bf-chatdown)
8+
109

1110
# Commands
1211
<!-- commands -->
@@ -27,7 +26,7 @@ OPTIONS
2726
2827
-h, --help Chatdown command help
2928
30-
-o, --out=out Path to the directory where the output of the multiple chat file processing (-f) will be
29+
-o, --out=out Path to the directory where the output of the multiple chat file processing (-o) will be
3130
placed.
3231
3332
-p, --prefix Prefix stdout with package name.

packages/chatdown/src/commands/chatdown.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ export default class Chatdown extends Command {
3737
})
3838
}
3939

40+
let outputDir = flags.out ? path.resolve(flags.out) : null
41+
4042
if (inputIsDirectory) {
4143
let inputDir = flags.in ? flags.in.trim() : ''
42-
let outputDir = (flags.out) ? flags.out.trim() : './'
43-
if (outputDir.substr(0, 2) === './') {
44-
outputDir = path.resolve(process.cwd(), outputDir.substr(2))
45-
}
44+
4645
const len = await this.processFiles(inputDir, outputDir)
4746
if (len === 0) {
4847
throw new CLIError('No chat files found at: ' + flags.in)
@@ -51,9 +50,10 @@ export default class Chatdown extends Command {
5150
return
5251
} else {
5352
const fileContents = await this.getInput(flags.in)
53+
const fileName = flags.in ? this.getFileName(flags.in) : ''
5454
if (fileContents) {
5555
const activities = await chatdown(fileContents, flags)
56-
const writeConfirmation = await this.writeOut(activities)
56+
const writeConfirmation = await this.writeOut(activities, fileName, outputDir)
5757
/* tslint:disable:strict-type-predicates */
5858
if (typeof writeConfirmation === 'string') {
5959
process.stdout.write(`${chalk.green('Successfully wrote file:')} ${writeConfirmation}\n`)
@@ -91,21 +91,20 @@ export default class Chatdown extends Command {
9191
}
9292
}
9393

94+
private getFileName(file: any) {
95+
let fileName = path.basename(file, path.extname(file))
96+
return fileName
97+
}
98+
9499
private async processFiles(inputDir: any, outputDir: any) {
95100
return new Promise(async (resolve, reject) => {
96101
let files = glob.sync(inputDir, {ignore: ['**/node_modules/**']})
97102
/* tslint:disable:prefer-for-of */
98103
for (let i = 0; i < files.length; i++) {
99104
try {
100-
let fileName = files[i]
101-
if (files[i].lastIndexOf('/') !== -1) {
102-
fileName = files[i].substr(files[i].lastIndexOf('/'))
103-
}
104-
fileName = fileName.split('.')[0]
105+
const fileName = this.getFileName(files[i])
105106
let activities = await chatdown(await utils.readTextFile(files[i]))
106-
let writeFile = `${outputDir}/${fileName}.transcript`
107-
await fs.ensureFile(writeFile)
108-
await fs.writeJson(writeFile, activities, {spaces: 2})
107+
await this.writeOut(activities, fileName, outputDir)
109108
} catch (e) {
110109
if (e.message.match(/no such file or directory/)) {
111110
reject(new CLIError(e.message))
@@ -119,7 +118,13 @@ export default class Chatdown extends Command {
119118
})
120119
}
121120

122-
private async writeOut(activities: any) {
121+
private async writeOut(activities: any, fileName: string, outputDir: any) {
122+
if (fileName && outputDir) {
123+
let writeFile = path.join(outputDir, `${fileName}.transcript`)
124+
await fs.ensureFile(writeFile)
125+
await fs.writeJson(writeFile, activities, {spaces: 2})
126+
return writeFile
127+
}
123128
const output = JSON.stringify(activities, null, 2)
124129
await new Promise(done => process.stdout.write(output, 'utf-8', () => done()))
125130
return true

packages/chatdown/test/commands/chatdown.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('chatdown', () => {
4444
});
4545

4646
it('should read from file when chat file is passed as an argument', done => {
47-
cp.exec(`node ./bin/run chatdown --in ${path.join(__dirname, '../utils/cli.sample.chat')}`, (error, stdout) => {
47+
cp.exec(`node ./bin/run chatdown --in ./test/utils/cli.sample.chat`, (error, stdout) => {
4848
assert.doesNotThrow(() => JSON.parse(stdout));
4949
done();
5050
});

packages/cli/README.md

Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
botframework-cli
22
================
33

4-
5-
64
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7-
[![Version](https://img.shields.io/npm/v/botframework-cli.svg)](https://www.npmjs.com/package/@microsoft/botframework-cli)
8-
[![Downloads/week](https://img.shields.io/npm/dw/botframework-cli.svg)](https://www.npmjs.com/package/@microsoft/botframework-cli)
9-
[![License](https://img.shields.io/npm/l/botframework-cli.svg)](https://github.com/microsoft/botframework-cli/blob/master/packages/cli/package.json)
5+
[![Version](https://img.shields.io/npm/v/@microsoft/botframework-cli)](https://www.npmjs.com/package/@microsoft/botframework-cli)
6+
[![Downloads](https://img.shields.io/npm/dt/@microsoft/botframework-cli)](https://github.com/microsoft/botframework-cli)
7+
[![License](https://img.shields.io/npm/l/@microsoft/botframework-cli)](https://github.com/microsoft/botframework-cli/blob/master/packages/cli/package.json)
108

119
# Usage
12-
<!-- usage -->
10+
1311
```sh-session
1412
$ npm install -g @microsoft/botframework-cli
15-
$ bf COMMAND
16-
running command...
17-
$ bf (-v|--version|version)
18-
@microsoft/botframework-cli/1.0.0 darwin-x64 node-v12.1.0
19-
$ bf --help [COMMAND]
20-
USAGE
21-
$ bf COMMAND
22-
...
13+
2314
```
24-
<!-- usagestop -->
15+
2516
# Commands
2617
<!-- commands -->
2718
* [`bf `](#bf-)
@@ -33,6 +24,7 @@ USAGE
3324
* [`bf config:show:qnamaker`](#bf-configshowqnamaker)
3425
* [`bf config:show:telemetry`](#bf-configshowtelemetry)
3526
* [`bf help [COMMAND]`](#bf-help-command)
27+
* [`bf luis`](#bf-luis)
3628
* [`bf luis:convert`](#bf-luisconvert)
3729
* [`bf luis:generate:cs`](#bf-luisgeneratecs)
3830
* [`bf luis:generate:ts`](#bf-luisgeneratets)
@@ -154,6 +146,7 @@ USAGE
154146
155147
OPTIONS
156148
-d, --disable Disable tlemetry
149+
-e, --enable Enable tlemetry
157150
-h, --help show CLI help
158151
```
159152

@@ -218,6 +211,20 @@ OPTIONS
218211

219212
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.1.6/src/commands/help.ts)_
220213

214+
## `bf luis`
215+
216+
Convert, translate luis/lu files or generate source code
217+
218+
```
219+
USAGE
220+
$ bf luis
221+
222+
OPTIONS
223+
-h, --help Display Luis available commnads
224+
```
225+
226+
_See code: [@microsoft/bf-lu](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/index.ts)_
227+
221228
## `bf luis:convert`
222229

223230
Convert .lu file(s) to a LUIS application JSON model or vice versa
@@ -239,7 +246,7 @@ OPTIONS
239246
--versionid=versionid Version ID of the LUIS application
240247
```
241248

242-
_See code: [@microsoft/bf-luis](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/convert.ts)_
249+
_See code: [@microsoft/bf-lu](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/convert.ts)_
243250

244251
## `bf luis:generate:cs`
245252

@@ -250,13 +257,13 @@ USAGE
250257
$ bf luis:generate:cs
251258
252259
OPTIONS
253-
--className=className Name of the class
254-
--force If --in flag provided with the path to an existing file, overwrites it
255-
--in=in Source .lu file(s) or LUIS application JSON model
260+
--className=className Name of the autogenerated class (can include namespace)
261+
--force If --in flag is provided with the path to an existing file, overwrites that file
262+
--in=in Path to the file containing the LUIS application JSON model
256263
--out=out Output file or folder name. If not specified stdout will be used as output
257264
```
258265

259-
_See code: [@microsoft/bf-luis](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/generate/cs.ts)_
266+
_See code: [@microsoft/bf-lu](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/generate/cs.ts)_
260267

261268
## `bf luis:generate:ts`
262269

@@ -267,13 +274,13 @@ USAGE
267274
$ bf luis:generate:ts
268275
269276
OPTIONS
270-
--className=className Name of the class
271-
--force If --in flag provided with the path to an existing file, overwrites it
272-
--in=in Source .lu file(s) or LUIS application JSON model
277+
--className=className Name of the autogenerated class
278+
--force If --in flag is provided with the path to an existing file, overwrites that file
279+
--in=in Path to the file containing the LUIS application JSON model
273280
--out=out Output file or folder name. If not specified stdout will be used as output
274281
```
275282

276-
_See code: [@microsoft/bf-luis](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/generate/ts.ts)_
283+
_See code: [@microsoft/bf-lu](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/generate/ts.ts)_
277284

278285
## `bf luis:translate`
279286

@@ -284,17 +291,17 @@ USAGE
284291
$ bf luis:translate
285292
286293
OPTIONS
287-
--in=in (required) Source .lu file(s) or LUIS application JSON model
288-
--out=out Output folder name. If not specified stdout will be used as output
289-
--recurse Indicates if sub-folders need to be considered to file .lu file(s)
290-
--srclang=srclang Source lang code. Auto detect if missing.
291-
--tgtlang=tgtlang (required) Comma separated list of target languages.
292-
--translate_comments=translate_comments When set, machine translate comments found in .lu or .qna file
293-
--translate_link_text=translate_link_text When set, machine translate link description in .lu or .qna file
294-
--translatekey=translatekey (required) Machine translation endpoint key.
294+
--in=in Source .lu file(s) or LUIS application JSON model
295+
--out=out Output folder name. If not specified stdout will be used as output
296+
--recurse Indicates if sub-folders need to be considered to file .lu file(s)
297+
--srclang=srclang Source lang code. Auto detect if missing.
298+
--tgtlang=tgtlang (required) Comma separated list of target languages.
299+
--translate_comments When set, machine translate comments found in .lu file
300+
--translate_link_text When set, machine translate link description in .lu file
301+
--translatekey=translatekey (required) Machine translation endpoint key.
295302
```
296303

297-
_See code: [@microsoft/bf-luis](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/translate.ts)_
304+
_See code: [@microsoft/bf-lu](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/luis/translate.ts)_
298305

299306
## `bf plugins`
300307

@@ -437,15 +444,15 @@ USAGE
437444
438445
OPTIONS
439446
--alterations Indicates if files is QnA Alterations
440-
--in=in (required) Source .qna file(s) or QnA KB JSON file
447+
--in=in Source .qna file(s) or QnA KB JSON file
441448
--log Enables log messages
442449
--name=name Name of the QnA KB
443450
--out=out Output file or folder name. If not specified stdout will be used as output
444451
--recurse Indicates if sub-folders need to be considered to file .qna file(s)
445-
--sort When set, questions collections are alphabetically sorted are alphabetically sorted in .lu files
452+
--sort When set, questions collections are alphabetically sorted are alphabetically sorted in .qna files
446453
```
447454

448-
_See code: [@microsoft/bf-luis](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/qnamaker/convert.ts)_
455+
_See code: [@microsoft/bf-lu](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/qnamaker/convert.ts)_
449456

450457
## `bf qnamaker:create:kb`
451458

@@ -710,23 +717,25 @@ USAGE
710717
711718
OPTIONS
712719
-h, --help qnamaker:query command help
720+
--context=context Path to Context object json file with previous QnA
713721
714722
--endpointKey=endpointKey Specifies the endpoint key for your private QnA service (From qnamaker.ai portal user
715-
settings page). Overrides the value present in config.
723+
settings page). Overrides the value present in config
716724
717-
--hostname=hostname Specifies the url for your private QnA service. Overrides the value present in
718-
config.
725+
--hostname=hostname Specifies the url for your private QnA service. Overrides the value present in config
719726
720727
--kbId=kbId Specifies the active qnamaker knowledgebase id. Overrides the value present in the
721728
config
722729
723-
--question=question (required) Query to get a prediction for.
730+
--qnaId=qnaId Exact qnaId to fetch from the knowledgebase, this field takes priority over question
731+
732+
--question=question (required) Query to get a prediction for
724733
725734
--scorethreshold=scorethreshold Specifies the confidence score threshold for the returned answer.
726735
727-
--strictfilters=strictfilters Path to json file {"strictfilters": MetadataDTO[]}
736+
--strictfilters=strictfilters Path to json file with MetadataDTO[] e.g {"strictfilters": MetadataDTO[]}
728737
729-
--test Query against the test index.
738+
--test Query against the test index
730739
731740
--top=top Specifies the number of matching results
732741
```
@@ -839,24 +848,24 @@ _See code: [@microsoft/bf-qnamaker](https://github.com/microsoft/botframework-cl
839848

840849
## `bf qnamaker:translate`
841850

842-
Translate given LUIS application JSON model or lu file(s)
851+
Translate given QnA maker application JSON model or qna file(s)
843852

844853
```
845854
USAGE
846855
$ bf qnamaker:translate
847856
848857
OPTIONS
849-
--in=in (required) Source .lu file(s) or LUIS application JSON model
858+
--in=in Source .qna file(s) or QnA maker application JSON model
850859
--out=out Output folder name. If not specified stdout will be used as output
851-
--recurse Indicates if sub-folders need to be considered to file .lu file(s)
860+
--recurse Indicates if sub-folders need to be considered to find .qna file(s)
852861
--srclang=srclang Source lang code. Auto detect if missing.
853862
--tgtlang=tgtlang (required) Comma separated list of target languages.
854-
--translate_comments=translate_comments When set, machine translate comments found in .lu or .qna file
855-
--translate_link_text=translate_link_text When set, machine translate link description in .lu or .qna file
863+
--translate_comments=translate_comments When set, machine translate comments found in .qna file
864+
--translate_link_text=translate_link_text When set, machine translate link description in .qna file
856865
--translatekey=translatekey (required) Machine translation endpoint key.
857866
```
858867

859-
_See code: [@microsoft/bf-luis](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/qnamaker/translate.ts)_
868+
_See code: [@microsoft/bf-lu](https://github.com/microsoft/botframework-cli/blob/v1.0.0/src/commands/qnamaker/translate.ts)_
860869

861870
## `bf qnamaker:update`
862871

packages/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"dependencies": {
1010
"@microsoft/bf-chatdown": "1.0.0",
1111
"@microsoft/bf-cli-config": "1.0.0",
12-
"@microsoft/bf-luis": "1.0.0",
12+
"@microsoft/bf-lu": "1.0.0",
1313
"@microsoft/bf-qnamaker": "1.0.0",
1414
"@oclif/command": "~1.5.13",
1515
"@oclif/config": "~1.13.0",
@@ -64,7 +64,7 @@
6464
"@microsoft/bf-chatdown",
6565
"@microsoft/bf-cli-config",
6666
"@microsoft/bf-qnamaker",
67-
"@microsoft/bf-luis"
67+
"@microsoft/bf-lu"
6868
],
6969
"hooks": {
7070
"init": "./lib/hooks/init/inithook"

packages/config/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55

66
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7-
[![Version](https://img.shields.io/npm/v/@microsoft/bf-cli-config.svg)](https://www.npmjs.com/package/@microsoft/bf-cli-config)
8-
[![Downloads/week](https://img.shields.io/npm/dw/@microsoft/bf-cli-config.svg)](https://www.npmjs.com/package/@microsoft/bf-cli-config)
9-
[![License](https://img.shields.io/npm/l/@microsoft/bf-cli-config.svg)](https://github.com/microsoft/botframework-cli/blob/master/packages/config/package.json)
7+
[![Version](https://img.shields.io/npm/v/@microsoft/bf-cli-config)](https://www.npmjs.com/package/@microsoft/bf-cli-config)
108

119
# Commands
1210
<!-- commands -->
@@ -73,6 +71,7 @@ USAGE
7371
7472
OPTIONS
7573
-d, --disable Disable tlemetry
74+
-e, --enable Enable tlemetry
7675
-h, --help show CLI help
7776
```
7877

0 commit comments

Comments
 (0)