Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"999999",
"--colors",
"-g",
".*"
"dialog:merge.*"
],
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std",
Expand Down Expand Up @@ -164,6 +164,26 @@
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${workspaceFolder}/../botbuilder-dotnet"
},
{
"type": "node",
"request": "launch",
"name": "Adaptive Sample 08 project",
"preLaunchTask": "${defaultBuildTask}",
"program": "${workspaceFolder}/packages/dialog/bin/run",
"outputCapture": "std",
"outFiles": [
"./packages/dialog/lib/**"
],
"args": [
"dialog:merge",
"*.csproj",
"--verbose",
"-o",
"${env:TEMP}/app.schema",
],
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${workspaceFolder}/../botbuilder-samples/samples/csharp_dotnetcore/adaptive-dialog/08.todo-bot-luis-qnamaker"
},
{
"type": "node",
"request": "launch",
Expand Down
8 changes: 5 additions & 3 deletions packages/dialog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ ARGUMENTS
PATTERNS Any number of glob regex patterns to match .csproj, .nuspec or package.json files.

OPTIONS
-c, --checkOnly Check and do not write files.
-h, --help show CLI help
-o, --output=output Output path and filename for merged .schema and .uischema. Defaults to first project name.
-s, --schema=schema Path to merged .schema file to use if merging .uischema only.
-v, --verbose Show verbose logging of files as they are processed.
--extension=extension [default: .dialog,.lg,.lu,.schema,.qna,.uischema] Extension to include as a resource for C#.
--extension=extension [default: .dialog,.lg,.lu,.schema,.qna,.uischema] Extension to include as a resource.

--imports=imports Output path for imported assets. Defaults to the directory of --out with an ImportedAssets
directory.
Expand All @@ -74,8 +75,9 @@ ARGUMENTS
PATTERNS Any number of glob regex patterns to match .dialog files.

OPTIONS
-h, --help show CLI help
-v, --verbose Show verbose output
-h, --help show CLI help
-s, --schema=schema Default schema to use if no $schema in dialog file.
-v, --verbose Show verbose output
```

_See code: [src/commands/dialog/verify.ts](https://github.com/microsoft/botframework-cli/tree/master/packages/dialog/blob/v1.0.0/src/commands/dialog/verify.ts)_
Expand Down
7 changes: 4 additions & 3 deletions packages/dialog/src/commands/dialog/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import {Command, flags} from '@microsoft/bf-cli-command'
import SchemaMerger from '../../library/schemaMerger'
import { SchemaMerger } from '../../library/schemaMerger'

export default class DialogMerge extends Command {
static description = 'Merge `<kind>.schema` and `<kind>[.<locale>].uischema` definitions from a project and its dependencies into a single .schema for describing .dialog files and a per locale .uischema for describing how Composer shows them. If a dependent package has an ExportedAssets directory it is copied to ImportedAssets/<package> in the --imports directory.'
Expand All @@ -16,8 +16,9 @@ export default class DialogMerge extends Command {
static strict = false

static flags: flags.Input<any> = {
checkOnly: flags.boolean({char: 'c', description: 'Check and do not write files.', default: false}),
debug: flags.boolean({char: 'd', description: 'Generate debug files.', hidden: true, default: false}),
extension: flags.string({description: 'Extension to include as a resource for C#.', required: false, multiple: true, default: ['.dialog', '.lg', '.lu', '.schema', '.qna', '.uischema']}),
extension: flags.string({description: 'Extension to include as a resource.', required: false, multiple: true, default: ['.dialog', '.lg', '.lu', '.schema', '.qna', '.uischema']}),
help: flags.help({char: 'h'}),
nugetRoot: flags.string({description: 'Nuget root directory for debugging.', hidden: true}),
imports: flags.string({description: 'Output path for imported assets. Defaults to the directory of --out with an ImportedAssets directory.', required: false}),
Expand All @@ -33,7 +34,7 @@ export default class DialogMerge extends Command {

async run() {
const {argv, flags} = this.parse(DialogMerge)
let merger = new SchemaMerger(argv, flags.output, flags.imports, flags.verbose, this.log, this.warn, this.error, flags.extension, flags.schema, flags.debug, flags.nugetRoot)
let merger = new SchemaMerger(argv, flags.output, flags.imports, flags.checkOnly, flags.verbose, this.log, this.warn, this.error, flags.extension, flags.schema, flags.debug, flags.nugetRoot)
await merger.merge()
}
}
40 changes: 23 additions & 17 deletions packages/dialog/src/commands/dialog/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@
* Licensed under the MIT License.
*/

import { Command, flags } from '@microsoft/bf-cli-command';
import {Command, flags} from '@microsoft/bf-cli-command';
import * as chalk from 'chalk';
import { Definition, DialogTracker, SchemaTracker } from '../../library/dialogTracker';
import {Definition, DialogTracker, SchemaTracker} from '../../library/dialogTracker';

export default class DialogVerify extends Command {
static description = 'Verify .dialog files match their app.schema.'

static args = [
{ name: 'patterns', required: true, description: 'Any number of glob regex patterns to match .dialog files.' },
{name: 'patterns', required: true, description: 'Any number of glob regex patterns to match .dialog files.'}
]

static strict = false

static flags: flags.Input<any> = {
help: flags.help({ char: 'h' }),
verbose: flags.boolean({ char: 'v', description: 'Show verbose output', default: false }),
help: flags.help({char: 'h'}),
schema: flags.string({char: 's', description: 'Default schema to use if no $schema in dialog file.'}),
verbose: flags.boolean({char: 'v', description: 'Show verbose output', default: false}),
}

private currentFile = ''
Expand All @@ -27,13 +28,13 @@ export default class DialogVerify extends Command {
private warnings = 0

async run() {
const { argv, flags } = this.parse(DialogVerify)
await this.execute(argv, flags.verbose)
const {argv, flags} = this.parse(DialogVerify)
await this.execute(argv, flags.verbose, flags.schema)
}

async execute(dialogFiles: string[], verbose?: boolean): Promise<void> {
async execute(dialogFiles: string[], verbose?: boolean, schemaPath?: string): Promise<void> {
const schema = new SchemaTracker()
const tracker = new DialogTracker(schema)
const tracker = new DialogTracker(schema, undefined, schemaPath)

await tracker.addDialogFiles(dialogFiles)

Expand All @@ -49,10 +50,11 @@ export default class DialogVerify extends Command {
}
} else {
for (let error of dialog.errors) {
this.consoleError(`${error.message.trim()}`, 'DLG001')
this.consoleError(`${error.message}`, 'DLG001')
}
}
}
this.currentFile = ''

for (let defs of tracker.multipleDefinitions()) {
let def = (defs as Definition[])[0]
Expand All @@ -66,8 +68,10 @@ export default class DialogVerify extends Command {
this.consoleError(`Missing definition for ${def} ${def.usedByString()}`, 'DLG003')
}

for (let def of tracker.missingTypes) {
this.consoleError(`Missing $kind for ${def}`, 'DLG004')
for (let def of tracker.typeMismatches()) {
for (let use of def.typeMismatches()) {
this.consoleError(`Type mismatch ${def} does not match ${use}`, 'DLG004')
}
}

for (let def of tracker.unusedIDs()) {
Expand All @@ -84,9 +88,11 @@ export default class DialogVerify extends Command {
}

this.log(`${this.files} files processed.`)
this.error(`${this.warnings} found.`)
if (this.warnings > 0) {
this.warn(`Warnings: ${this.warnings} found.`)
}
if (this.errors > 0) {
this.error(`Error: ${this.errors} found.`)
this.error(`Errors: ${this.errors} found.`)
}
}
}
Expand All @@ -101,11 +107,11 @@ export default class DialogVerify extends Command {

consoleWarn(msg: string, code: string): void {
this.warnings++
this.warn(`${this.currentFile} - warning ${code || ''}: ${msg}`)
this.warn(`${this.currentFile ? `${this.currentFile} - ` : ''}Warning ${code || ''}: ${msg}`)
}

consoleError(msg: string, code: string): void {
this.errors++
this.error(`${this.currentFile} - error ${code || ''}: ${msg}`)
this.error(`${this.currentFile ? `${this.currentFile} - ` : ''}Error ${code || ''}: ${msg}`)
}
}
Loading