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
Show all changes
33 commits
Select commit Hold shift + click to select a range
e679bce
Topo sort in progress.
Jun 6, 2020
3da0934
Update sort.
Jun 6, 2020
1749fa0
Merge branch 'master' into chrimc/pkg
Jun 6, 2020
86d0990
Working sort
Jun 6, 2020
aa90e09
Breadth first sort.
Jun 8, 2020
8083a84
Move to building component tree.
Jun 11, 2020
8a9b6d1
Normalize slash in tests.
Jun 11, 2020
f16f573
Update documentation
Jun 11, 2020
5c05ac5
Add --nugetRoot switch.
Jun 11, 2020
eb320c6
Merge branch 'master' into chrimc/pkg
Jun 11, 2020
d4176d3
Merge branch 'master' into chrimc/pkg
Jun 14, 2020
793528a
Merge branch 'master' into chrimc/pkg
Jul 7, 2020
a049d8b
Add $package to app.schema.
Jul 7, 2020
431e3bb
Intermediate progress to switch machines.
Jul 11, 2020
a404aef
Update to move machines.
Jul 13, 2020
5270c70
Update to offical URLS.
Jul 13, 2020
28693b4
Oracles and working tests.
Jul 14, 2020
d0bcd2e
All csproj tests working
Jul 14, 2020
d3f7cbd
All tests work.
Jul 14, 2020
cb13b67
Fix packages.config.
Jul 14, 2020
2e708f8
Add copying C# asset files into output
Jul 14, 2020
78efaa3
Merge branch 'master' into chrimc/pkg
Jul 14, 2020
9abf488
Renable test
Jul 14, 2020
e14161f
Order uischema keys and update oracles.
Jul 14, 2020
6d3f3dc
Merge branch 'master' into chrimc/pkg
Jul 14, 2020
edf18a4
Move write outside of loop.
Jul 14, 2020
05f1490
Merge branch 'master' into chrimc/pkg
Jul 14, 2020
c35eebb
Add missing .uischema files.
Jul 14, 2020
4191893
Use / in paths
Jul 14, 2020
1532d96
Merge branch 'chrimc/pkg' of https://github.com/microsoft/botframewor…
Jul 14, 2020
416926f
Merge branch 'master' into chrimc/pkg
Jul 14, 2020
2fb479a
Update documentation.
Jul 15, 2020
000655b
Update docs.
Jul 15, 2020
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
74 changes: 71 additions & 3 deletions .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 @@ -195,8 +195,7 @@
"dialog:merge",
"schemas/*.schema",
"-o",
"schemas/app.schema",
"-d"
"schemas/app.schema"
],
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${workspaceFolder}/packages/dialog/test/commands/dialog"
Expand Down Expand Up @@ -242,6 +241,75 @@
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${env:TEMP}/sandwich.out"
},
{
"type": "node",
"request": "launch",
"name": "LUIS Build Simple",
"preLaunchTask": "${defaultBuildTask}",
"program": "${workspaceFolder}/packages/luis/bin/run",
"outputCapture": "std",
"outFiles": [
"./packages/luis/lib/**",
"./packages/lu/lib/**"
],
"args": [
"luis:build",
"--luConfig",
"luconfig.json",
"--authoringKey",
"${env:LUIS_AUTHORING_KEY}"
],
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${env:TEMP}/simple.out"
},
{
"type": "node",
"request": "launch",
"name": "LUIS Convert Sandwich",
"preLaunchTask": "${defaultBuildTask}",
"program": "${workspaceFolder}/packages/luis/bin/run",
"outputCapture": "std",
"outFiles": [
"./packages/luis/lib/**",
"./packages/lu/lib/**"
],
"args": [
"luis:convert",
"--in",
"en-us/sandwich.en-us.lu",
"--name",
"sandwich",
"-o",
"converted.json",
"--force"
],
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${env:TEMP}/sandwich.out"
},
{
"type": "node",
"request": "launch",
"name": "LUIS Convert Simple",
"preLaunchTask": "${defaultBuildTask}",
"program": "${workspaceFolder}/packages/luis/bin/run",
"outputCapture": "std",
"outFiles": [
"./packages/luis/lib/**",
"./packages/lu/lib/**"
],
"args": [
"luis:convert",
"--in",
"en-us/simple.en-us.lu",
"--name",
"simple",
"-o",
"converted.json",
"--force"
],
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${env:TEMP}/simple.out"
},
{
"type": "node",
"request": "launch",
Expand Down
16 changes: 6 additions & 10 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions packages/dialog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ This package is intended for Microsoft use only and should be consumed through @

# Commands
<!-- commands -->
* [`bf dialog`](#bf-dialog)
* [`bf dialog:merge PATTERNS`](#bf-dialogmerge-patterns)
* [`bf dialog:verify PATTERNS`](#bf-dialogverify-patterns)
- [@microsoft/bf-dialog](#microsoftbf-dialog)
Copy link
Contributor

@munozemilio munozemilio Jul 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be outside the commands toc otherwise it will be deleted on the next documentation autogen

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did auto-gen and then restored things from the original. For example the slashes for code references are still the wrong way.

- [Relevant docs](#relevant-docs)
- [Commands](#commands)
- [`bf dialog`](#bf-dialog)
- [`bf dialog:merge PATTERNS`](#bf-dialogmerge-patterns)
- [`bf dialog:verify PATTERNS`](#bf-dialogverify-patterns)

## `bf dialog`

Expand All @@ -33,23 +36,24 @@ _See code: [src/commands/dialog/index.ts](https://github.com/microsoft/botframew

## `bf dialog:merge PATTERNS`

Merge component .schema files into an app.schema.
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. For C#, ensures all nuget declarative resources are included in the same location.

```
USAGE
$ bf dialog:merge PATTERNS

ARGUMENTS
PATTERNS Any number of glob regex patterns to match .schema, .csproj, or package.json files.
PATTERNS Any number of glob regex patterns to match .csproj, .nuspec or package.json files.

OPTIONS
-h, --help show CLI help
-o, --output=output [default: app.schema] Output path and filename for merged schema.
-v, --verbose Show verbose logging of files as they are processed.
-h, --help show CLI help
-o, --output=output Output path and filename for merged .schema and .uischema. Defaults to first project name.
-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#.

EXAMPLES
$ bf dialog:merge *.csproj
$ bf dialog:merge libraries/**/*.schema **/*.csproj -o app.schema
$ bf dialog:merge myProject.csproj plugins/*.nuspec
$ bf dialog:merge package.json -o app.schema
```

_See code: [src/commands/dialog/merge.ts](https://github.com/microsoft/botframework-cli/tree/master/packages/dialog/src/commands/dialog/merge.ts)_
Expand Down
28 changes: 20 additions & 8 deletions packages/dialog/docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@

## Merge

This will merge together [Microsoft Bot Builder](https://github.com/Microsoft/BotBuilder) .schema JSON schema files into a single JSON schema file. You can point to the files either directly with a glob pattern or indirectly through a glob pattern that matches a package.json, packages.config or \*.csproj file. The .schema files should have a unique filename that is used to refer to that type using `$kind`. The .schema files should include a `$schema: "https://raw.githubusercontent.com/microsoft/botframework-sdk/master/schemas/component/component.schema"` which defines the schema they are validated against. You can access common definitions by using `$ref: "schema:#/definitions/stringExpression"` in a property definition. At the top-level in a component schema you can use `$role:"implements(<kind>)` to project the type definition into interface types defined using `$role:"interface"` while merging. To extend an existing .schema file use `$role: "extends(<kind>)"`. To refer to a type in a property, use `"$kind":"<kind>"` and the corresponding kind will be wired into your schema. The merger combines all of the component .schema files into a single .schema file that has resolved all external `$ref`, merged `allOf` and connected together schemas through `$role` and `$kind`.
This will merge together [Microsoft Bot Builder](https://github.com/Microsoft/BotBuilder) .schema JSON schema files into a single JSON schema file and .uischema files into a per-locale .uischema file. You can point to the files either directly with a glob pattern or indirectly through a glob pattern that matches a package.json or /*.csproj file. The .schema files should have a unique filename that is used to refer to that type using `$kind`. The .schema files should include a `$schema: "https://schemas.botframework.com/schemas/component/v1.0/component.schema"` which defines the schema they are validated against.

You can also mark properties with a `$role: "expression"` to indicate to tooling that an expression is allowed for that property.
You can also mark properties with a `$role: "expression"` to indicate to tooling that an expression is allowed for that property. A simple way to do this is to make use of common expression definitions like `$ref: "schema:#/definitions/<type>Expression"` in a property definition.

For example look at these files:
At the top-level in a component schema you can use `$role:"implements(<kind>)` to project the type definition into interface types defined using `$role:"interface"` while merging.

- [IRecognizer.schema](test/schemas/IRecognizer.schema) defines the place holder for `IRecognizer` including a default option which is a bare string.
- [Recognizer.schema](test/schemas/Recognizer.schema) includes `$role:"implements(IRecognizer)"` which extends the `IRecognizer` definition when merged.
- [root.schema](test/schemas/root.schema) is a schema file that includes `$kind:"IRecognizer"` in order to make use of the `IRecognizer` place holder. The `$role: []` ensures that this is available as a top-level object.
- [app.schema](test/schemas/app.schema) was created by this tool shows how all of these definitions are merged together. In particular if you look at `IRecognizer` you will see the definition that includes a string, or the complete definition of `Recognizer`.
To extend an existing .schema file use `$role: "extends(<kind>)"`. This will add onto the existing definitions in `<kind>`.

[root.dialog](test/examples/root.dialog) Shows how you could use the resulting schema to enter in JSON schema and get intellisense.
To refer to a type in a property, use `$kind:"<kind>"` and the corresponding kind will be wired into your schema. The merger combines all of the component .schema files into a single .schema file that has resolved all external `$ref`, merged `allOf` and connected together schemas through `$role` and `$kind`.

For `<kind>[.<locale>].uischema` files, use `$schema: "https://schemas.botframework.com/schemas/ui/v1.0/ui.schema"` to define their contents. The `<kind>` must be found in the .schema file and the optional `<locale>` is a string like en-us. All of the individual .uischema files will be combined into a composite one per-locale. If definitions conflict, the definition found first in the topological sort of bread-first, parent before child will be used.

For C#, nuget does not deal well with content files so all declarative .dialog, .lu, .lg, and .qna files will be copied into `generated/<package>` so you can easily include all of them in your project output.

For examples look at these files:

- [IRecognizer.schema](../test/schemas/IRecognizer.schema) defines the place holder for `IRecognizer` including a default option which is a bare string.
- [Recognizer.schema](../test/schemas/Recognizer.schema) includes `$role:"implements(IRecognizer)"` which extends the `IRecognizer` definition when merged.
- [root.schema](../test/schemas/root.schema) is a schema file that includes `$kind:"IRecognizer"` in order to make use of the `IRecognizer` place holder. The `$role: []` ensures that this is available as a top-level object.
- [app.schema](../test/schemas/app.schema) was created by this tool shows how all of these definitions are merged together. In particular if you look at `IRecognizer` you will see the definition that includes a string, or the complete definition of `Recognizer`.
- [nuget3.en-us.uischema](../test/commands/dialog/projects/project3/nuget3.en-us.uischema) shows an example component .uischema file.
- [project3.en-us.uischema](../test/commands/dialog/oracles/project3.en-us.uischema) shows a merged .uischema file.

[root.dialog](../test/examples/root.dialog) Shows how you could use the resulting schema to enter in JSON schema and get intellisense.

## Verify

Expand Down
2 changes: 1 addition & 1 deletion packages/dialog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"seedrandom": "~3.0.5",
"tslib": "^1.10.0",
"xml2js": "^0.4.19",
"json-ptr": "~1.2.0",
"json-ptr": "~1.3.0",
"json-schema-merge-allof": "~0.7.0",
"@snyk/nuget-semver": "~1.3.0"
},
Expand Down
26 changes: 14 additions & 12 deletions packages/dialog/src/commands/dialog/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,35 @@
* Licensed under the MIT License.
*/

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

export default class DialogMerge extends Command {
static description = 'Merge component .schema files into an app.schema.'
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. For C#, ensures all nuget declarative resources are included in the same location.'

static args = [
{ name: 'patterns', required: true, description: 'Any number of glob regex patterns to match .schema, .csproj, or package.json files.'},
{name: 'patterns', required: true, description: 'Any number of glob regex patterns to match .csproj, .nuspec or package.json files.'},
]

static strict = false

static flags: flags.Input<any> = {
debug: flags.boolean({ char: 'd', description: 'Generate debug files.', hidden: true, default: false}),
help: flags.help({ char: 'h' }),
output: flags.string({ char: 'o', description: 'Output path and filename for merged schema.', default: 'app.schema', required: false }),
verbose: flags.boolean({ char: 'v', description: 'Show verbose logging of files as they are processed.', 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']}),
help: flags.help({char: 'h'}),
nugetRoot: flags.string({description: 'Nuget root directory for debugging.', hidden: true}),
output: flags.string({char: 'o', description: 'Output path and filename for merged .schema and .uischema. Defaults to first project name.', required: false}),
verbose: flags.boolean({char: 'v', description: 'Show verbose logging of files as they are processed.', default: false}),
}

static examples = [
'$ bf dialog:merge *.csproj',
'$ bf dialog:merge libraries/**/*.schema **/*.csproj -o app.schema'
'$ bf dialog:merge myProject.csproj plugins/*.nuspec',
'$ bf dialog:merge package.json -o app.schema'
]

async run() {
const { argv, flags } = this.parse(DialogMerge)
let merger = new SchemaMerger(argv, flags.output, flags.verbose, this.log, this.warn, this.error, flags.debug)
await merger.mergeSchemas()
const {argv, flags} = this.parse(DialogMerge)
let merger = new SchemaMerger(argv, flags.output, flags.verbose, this.log, this.warn, this.error, flags.extension, flags.debug, flags.nugetRoot)
await merger.merge()
}
}
Loading