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

Commit fcfb3ac

Browse files
JSprumunozemilio
authored andcommitted
Adding 'convert' cmd and cleaning up transcript files after chatdown … (#262)
* Adding 'convert' cmd and cleaning up transcript files after chatdown unit tests * Fix urls in readmes
1 parent 37dd65e commit fcfb3ac

File tree

8 files changed

+146
-238
lines changed

8 files changed

+146
-238
lines changed

packages/chatdown/README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Tool for parsing chat files and outputting replayable activities
1010
# Commands
1111
<!-- commands -->
1212
* [`bf chatdown`](#bf-chatdown)
13+
* [`bf chatdown:convert`](#bf-chatdownconvert)
1314

1415
## `bf chatdown`
1516

@@ -19,6 +20,20 @@ Converts chat dialog files in <filename>.chat format into transcript file. Write
1920
USAGE
2021
$ bf chatdown
2122
23+
OPTIONS
24+
-h, --help Chatdown command help
25+
```
26+
27+
_See code: [src\commands\chatdown\index.ts](https://github.com/microsoft/botframework-cli/tree/master/packages/chatdown/src/commands/chatdown/index.ts)_
28+
29+
## `bf chatdown:convert`
30+
31+
Converts chat dialog files in <filename>.chat format into transcript file. Writes corresponding <filename>.transcript for each .chat file
32+
33+
```
34+
USAGE
35+
$ bf chatdown:convert
36+
2237
OPTIONS
2338
-f, --force If --out flag is provided with the path to an existing file, overwrites that file
2439
-h, --help Chatdown command help
@@ -41,5 +56,5 @@ EXAMPLE
4156
$ (echo user=Joe && [ConversationUpdate=MembersAdded=Joe]) | bf chatdown --static
4257
```
4358

44-
_See code: [src/commands/chatdown.ts](https://github.com/microsoft/botframework-cli/tree/master/packages/chatdown/src/commands/chatdown.ts)_
59+
_See code: [src\commands\chatdown\convert.ts](https://github.com/microsoft/botframework-cli/tree/master/packages/chatdown/src/commands/chatdown/convert.ts)_
4560
<!-- commandsstop -->

packages/chatdown/cli.transcript

Lines changed: 0 additions & 157 deletions
This file was deleted.

packages/chatdown/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@types/chai": "^4.1.7",
3333
"@types/mocha": "^5.2.6",
3434
"@types/node": "^10.14.6",
35+
"@types/rimraf": "^2.0.2",
3536
"chai": "^4.2.0",
3637
"globby": "^8.0.2",
3738
"mocha": "^5.2.0",

packages/chatdown/src/commands/chatdown.ts renamed to packages/chatdown/src/commands/chatdown/convert.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import {flags} from '@oclif/command'
77
import {CLIError, Command, utils} from '@microsoft/bf-cli-command'
88
const chalk = require('chalk')
9-
const chatdown = require('../../utils/index')
9+
const chatdown = require('../../../utils/index')
1010
const fs = require('fs-extra')
1111
const glob = require('glob')
1212
const intercept = require('intercept-stdout')
1313
const path = require('path')
1414

15-
export default class Chatdown extends Command {
15+
export default class ChatdownConvert extends Command {
1616
static description = 'Converts chat dialog files in <filename>.chat format into transcript file. Writes corresponding <filename>.transcript for each .chat file'
1717

1818
static examples = [`
@@ -32,7 +32,7 @@ export default class Chatdown extends Command {
3232

3333
async run() {
3434
try {
35-
const {flags} = this.parse(Chatdown)
35+
const {flags} = this.parse(ChatdownConvert)
3636

3737
let inputIsDirectory = flags.in ? (flags.in.includes('*') || this.isDir(flags.in)) : false
3838

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*!
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
6+
import {Command, flags} from '@microsoft/bf-cli-command'
7+
8+
export default class ChatdownIndex extends Command {
9+
static description = 'Converts chat dialog files in <filename>.chat format into transcript file. Writes corresponding <filename>.transcript for each .chat file'
10+
11+
static flags: flags.Input<any> = {
12+
help: flags.help({char: 'h', description: 'Chatdown command help'})
13+
}
14+
15+
async run() {
16+
this._help()
17+
}
18+
}
Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
import {expect, test} from '@oclif/test'
2-
import * as cp from 'child_process';
3-
import * as path from 'path';
4-
5-
let pkg = require('../../package.json');
6-
let assert = require('assert');
7-
let sv = require('semver');
82

93
describe('chatdown', () => {
104

@@ -15,74 +9,4 @@ describe('chatdown', () => {
159
expect(ctx.stdout).to.contain('Converts chat dialog files in <filename>.')
1610
})
1711

18-
it('should accept data as a pipe and output the results', done => {
19-
cp.exec(`(echo user=Joe && echo bot=LuliBot && echo LuliBot: hello! && echo joe:can I get some help?) | node ./bin/run chatdown`, (error, stdout) => {
20-
assert.doesNotThrow(() => JSON.parse(stdout));
21-
done();
22-
});
23-
});
24-
25-
test
26-
.stdout()
27-
.command(['chatdown'])
28-
.it('should print the help contents when no input is passed', ctx => {
29-
expect(ctx.stdout).to.contain('Converts chat dialog files in <filename>.')
30-
})
31-
32-
it('should throw when a malformed config options is encountered in the input', done => {
33-
cp.exec(`echo bot=LuliBot=joe | node ./bin/run chatdown`, (error, stdout, stderr) => {
34-
assert(stderr.trim().indexOf('Malformed configurations options detected. Options must be in the format optionName=optionValue') >= 0);
35-
done();
36-
});
37-
});
38-
39-
it('should generate static based timestamps when --static is passed as an argument', done => {
40-
cp.exec(`(echo user=Joe && [ConversationUpdate=MembersAdded=Joe]) | node ./bin/run chatdown --static`, (error, stdout) => {
41-
assert.doesNotThrow(() => JSON.parse(stdout));
42-
done();
43-
});
44-
});
45-
46-
it('should read from file when chat file is passed as an argument', done => {
47-
cp.exec(`node ./bin/run chatdown --in "./test/utils/cli.sample.chat"`, (error, stdout) => {
48-
assert.doesNotThrow(() => JSON.parse(stdout));
49-
done();
50-
});
51-
});
52-
53-
it('should process all files when a glob is passed in with the -i argument, and the -o is passed in for the output directory', done => {
54-
cp.exec(`node ./bin/run chatdown -i "./test/utils/*.sample.chat" -o ./`, (error, stdout, stderr) => {
55-
assert(stdout.includes('Successfully wrote'));
56-
done();
57-
});
58-
});
59-
60-
it('should process all files when a glob is passed in with the -i argument', done => {
61-
cp.exec(`node ./bin/run chatdown -i "./test/utils/*.sample.chat"`, (error, stdout, stderr) => {
62-
assert(stdout.includes('Successfully wrote'));
63-
done();
64-
});
65-
});
66-
67-
it('should not prefix [chatdown] to stdout when --prefix is not passed as an argument', done => {
68-
cp.exec(`echo bot=LuliBot | node ./bin/run chatdown`, (error, stdout, stderr) => {
69-
assert.notEqual(stdout.startsWith(`[${pkg.name}]`), `It should not show the tag '[${pkg.name}]' when not using the argument --prefix`);
70-
done();
71-
});
72-
});
73-
74-
it('should prefix [chatdown] to stderr when --prefix is passed as an argument', done => {
75-
cp.exec(`echo bot=LuliBot | node ./bin/run chatdown --prefix`, (error, stdout, stderr) => {
76-
assert(stdout.startsWith(`[${pkg.name}]`), `It should show the tag '[${pkg.name}]' when using the argument --prefix`);
77-
done();
78-
});
79-
});
80-
81-
it('throw error if invalid path in argument', done => {
82-
cp.exec(`node ./bin/run chatdown --in 'aaaaa'`, (error, stdout, stderr) => {
83-
assert(stderr.includes('no such file or directory') || stderr.includes('error'));
84-
done();
85-
});
86-
});
87-
8812
})

0 commit comments

Comments
 (0)