Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to latest versions of SDK #2378

Merged
merged 9 commits into from
May 12, 2020
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
2 changes: 2 additions & 0 deletions experimental/generation/generator/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@microsoft:registry=https://botbuilder.myget.org/F/botframework-cli/npm/
registry=https://botbuilder.myget.org/F/botbuilder-v4-js-daily/npm/
2 changes: 1 addition & 1 deletion experimental/generation/generator/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
{
"type": "node",
"request": "launch",
"name": "Dialog Generator Tests",
Expand Down
4 changes: 4 additions & 0 deletions experimental/generation/generator/bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

require('@oclif/command').run()
.catch(require('@oclif/errors/handle'))
3 changes: 3 additions & 0 deletions experimental/generation/generator/bin/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run" %*
13 changes: 7 additions & 6 deletions experimental/generation/generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
"author": "Microsoft",
"bugs": "https://github.com/Microsoft/BotBuilder-Samples/issues",
"dependencies": {
"@microsoft/bf-cli-command": "^4.8.0",
"@microsoft/bf-cli-command": "^4.9.0-RC6",
Copy link
Contributor

@tomlm tomlm May 12, 2020

Choose a reason for hiding this comment

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

", [](start = 44, length = 2)

this is no rc42? #Resolved

"@microsoft/bf-lu": "^4.10.0-preview.130225",
Copy link
Contributor

@tomlm tomlm May 12, 2020

Choose a reason for hiding this comment

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

"^4.10.0-preview.130225", [](start = 24, length = 25)

this doesn't seem right. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is correct. I have to pick up bug fixes.


In reply to: 423897684 [](ancestors = 423897684)

"@oclif/command": "^1.5.19",
"@oclif/config": "^1.14.0",
"tslib": "^1.11.1",
"@oclif/errors": "~1.2.2",
"@types/lru-cache": "^5.1.0",
"@types/semver": "^6.0.1",
"@types/xml2js": "^0.4.4",
"adaptive-expressions": "^4.9.0-rc42",
"ajv": "^6.9.1",
"botbuilder-lg": "^4.9.0-rc42",
"chalk": "^2.4.2",
"clone": "^2.1.2",
"fs-extra": "^8.1.0",
Expand All @@ -25,10 +27,8 @@
"path": "^0.12.7",
"seedrandom": "~3.0.5",
"semver": "^5.7.0",
"xml2js": "^0.4.19",
"adaptive-expressions": "^4.8.0-preview",
"botbuilder-lg": "^4.8.0-preview",
"@microsoft/bf-lu": "^4.8.0"
"tslib": "^1.11.1",
"xml2js": "^0.4.19"
},
"devDependencies": {
"@oclif/dev-cli": "^1.22.2",
Expand Down Expand Up @@ -58,6 +58,7 @@
"/lib",
"/npm-shrinkwrap.json",
"/oclif.manifest.json",
"/templates",
"/yarn.lock"
],
"homepage": "https://github.com/Microsoft/BotBuilder-Samples",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ async function processTemplate(
feedback(FeedbackType.info, `Generating ${outPath}`)
let result = template
if (typeof template === 'object') {
process.chdir(ppath.dirname(template.allTemplates[0].source))
process.chdir(ppath.dirname(template.allTemplates[0].sourceRange.source))
result = template.evaluate('template', scope) as string
if (Array.isArray(result)) {
result = result.join(os.EOL)
Expand Down
25 changes: 12 additions & 13 deletions experimental/generation/generator/src/library/mergeAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ async function changeEntityEnumLU(schemaName: string, oldPath: string, newPath:
let oldEntitySections = oldLUResource.Sections.filter(s => s.SectionType === lusectiontypes.NEWENTITYSECTION)
let oldIntentSections = oldLUResource.Sections.filter(s => s.SectionType === lusectiontypes.SIMPLEINTENTSECTION && s.Name === schemaName)

let odlSectionOp = new sectionOperator(oldLUResource)
let oldSectionOp = new sectionOperator(oldLUResource)
let updatedLUResource: any = null

let oldListEntitySections = oldEntitySections.filter(s => s.Type === 'list')
Expand Down Expand Up @@ -341,9 +341,7 @@ async function changeEntityEnumLU(schemaName: string, oldPath: string, newPath:

// update content
let entityLUContent = resultStatements.join(os.EOL)
let entityLUName = '@ ' + oldListEntitySection.Type + ' ' + oldListEntitySection.Name + ' ='
let sectionBody = entityLUName + os.EOL + entityLUContent
updatedLUResource = odlSectionOp.updateSection(oldListEntitySection.Id, sectionBody)
updatedLUResource = oldSectionOp.updateSection(oldListEntitySection.Id, entityLUContent)

// update intent content
if (oldIntentSections.length === 0) {
Expand Down Expand Up @@ -487,7 +485,7 @@ async function changeEntityEnumLG(oldPath: string, newPath: string, mergedPath:
let recordPart: object[] = []

for (let oldTemplate of oldTemplates) {
let oldBody = oldTemplate.parseTree.templateBody()
let oldBody = oldTemplate.templateBodyParseTree
if (oldBody === undefined) {
continue
}
Expand All @@ -496,7 +494,7 @@ async function changeEntityEnumLG(oldPath: string, newPath: string, mergedPath:
if (newTemplate.name !== oldTemplate.name) {
continue
}
let newBody = newTemplate.parseTree.templateBody()
let newBody = newTemplate.templateBodyParseTree
if (newBody instanceof SwitchCaseBodyContext) {
let newSwitchStatements: string[] = []
let newEnumValueMap = new Map<string, number>()
Expand All @@ -507,11 +505,11 @@ async function changeEntityEnumLG(oldPath: string, newPath: string, mergedPath:
// get enumEntity and its following statements
if (state.text.match('\s*-\s*CASE:')) {
let enumEntity = state.text.replace('-CASE:${', '').replace('}', '')
let start = state.start.line
let start = state.start.line + newTemplate.sourceRange.range.start.line
newEnumValueMap.set(enumEntity, start)
}
}
const { startIndex, endIndex } = parseLGTemplate(oldBody, oldStatements, newStatements, newEnumValueMap, oldEnumEntitySet, newSwitchStatements)
const { startIndex, endIndex } = parseLGTemplate(oldTemplate, oldBody, oldStatements, newStatements, newEnumValueMap, oldEnumEntitySet, newSwitchStatements)
let statementInfo = {
start: startIndex, end: endIndex, newSStatements: newSwitchStatements
}
Expand Down Expand Up @@ -550,21 +548,22 @@ async function changeEntityEnumLG(oldPath: string, newPath: string, mergedPath:

/**
* @description: Update old LG Template which has SWITCH ENUM.
* @param oldBody Template Body from the old .lg file.
* @param oldTemplate Template from the old .lg file.
* @param oldBody Body from the old .lg file.
* @param oldStatements Statement array from the old .lg file.
* @param newStatements Statement array from the new .lg file.
* @param newEnumValueMap Map for Enum Entity key-value pair from the new .lg file.
* @param oldEnumEntitySet Set for Enum Entity from the old .lg file.
* @param newSwitchStatements Merged switch statement array.
*/
function parseLGTemplate(oldBody: any, oldStatements: string[], newStatements: string[], newEnumValueMap: Map<string, number>, oldEnumEntitySet: Set<string>, newSwitchStatements: string[]): { startIndex: number, endIndex: number } {
function parseLGTemplate(oldTemplate: any, oldBody: any, oldStatements: string[], newStatements: string[], newEnumValueMap: Map<string, number>, oldEnumEntitySet: Set<string>, newSwitchStatements: string[]): { startIndex: number, endIndex: number } {
let startIndex = 0
let endIndex = 0
let oldRules = oldBody.switchCaseTemplateBody().switchCaseRule()
for (let rule of oldRules) {
let state = rule.switchCaseStat()
if (state.text.match('\s*-\s*SWITCH')) {
startIndex = state.start.line - 1;
startIndex = state.start.line + oldTemplate.sourceRange.range.start.line - 1
newSwitchStatements.push(oldStatements[startIndex])
let i = startIndex + 1
while (i < oldStatements.length && !oldStatements[i].toLowerCase().match('case') && !oldStatements[i].toLowerCase().match('default')) {
Expand All @@ -575,7 +574,7 @@ function parseLGTemplate(oldBody: any, oldStatements: string[], newStatements: s
let enumEntity = state.text.replace('-CASE:${', '').replace('}', '')
oldEnumEntitySet.add(enumEntity)
if (newEnumValueMap.has(enumEntity)) {
let k = state.start.line - 1
let k = state.start.line + oldTemplate.sourceRange.range.start.line - 1
newSwitchStatements.push(oldStatements[k])
k++
while (k < oldStatements.length && !oldStatements[k].toLowerCase().match('case') && !oldStatements[k].toLowerCase().match('default')) {
Expand All @@ -596,7 +595,7 @@ function parseLGTemplate(oldBody: any, oldStatements: string[], newStatements: s

}
}
let m = state.start.line - 1
let m = state.start.line + oldTemplate.sourceRange.range.start.line - 1
newSwitchStatements.push(oldStatements[m])
m++
while (m < oldStatements.length && !oldStatements[m].match('#') && !oldStatements[m].startsWith('[')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ export async function processSchemas(schemaPath: string, templateDirs: string[],
}
let formSchema = await getSchema(schemaPath, feedback, resolver)
let required = {}
if (!formSchema.$requires) {
// Default to standard schema
formSchema.$requires = ['standard.schema']
}
await findRequires(formSchema, allRequired, required, resolver, feedback)
let allSchema = clone(formSchema)
addMissing(allSchema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# template
- ```
# booleanEntity(value)
${'#'} booleanEntity(value)
Copy link
Contributor

@tomlm tomlm May 12, 2020

Choose a reason for hiding this comment

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

${'#' [](start = 0, length = 5)

what the wha?
#Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug in LG that they are working on fixing and this is the work-around until they do.


In reply to: 423898362 [](ancestors = 423898362)

- SWITCH: \${value}
- CASE: \${'true'}
- true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ${valueTemplate()}

# AskTemplate
- ```
# Ask${property}
- \${askBoolean('${property}')\}
${'#'} Ask${property}
- \${askBoolean('${property}')}
```

Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ ${chooseEntity()}

# chooseEntity
- ```
# choose${property}Entity
- \${chooseEnumArrayEntity(${concat("'", property, "'")})\}
${'#'} choose${property}Entity
- \${chooseEnumArrayEntity(${concat("'", property, "'")})}
```

# propertyEntity
- ${join(createArray(namePlusSwitch(), cases(), default()), EOL())}${EOL()}

# namePlusSwitch
-```
# ${property}Entity(value)
- SWITCH: \${value\}```
${'#'} ${property}Entity(value)
- SWITCH: \${value}```

# case(option)
-```
- CASE: \${'${option}'\}
- CASE: \${'${option}'}
- ${phrase(option)}```

# cases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ ${ValueTemplate()}

# AskTemplate
- ```
# Ask${property}
- \${askEnumArray('${property}')\}```
${'#'} Ask${property}
- \${askEnumArray('${property}')}```

# ValueTemplate
- ```
# ${property}(values)
${'#'} ${property}(values)
Copy link
Contributor

@tomlm tomlm May 12, 2020

Choose a reason for hiding this comment

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

${'#'} [](start = 0, length = 7)

can you # ? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. That then passes through as #


In reply to: 423898807 [](ancestors = 423898807)

- \${enumArrayValue('${property}', values)}```

Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ ${chooseEntity()}

# chooseEntity
-```
# choose${property}Entity
- \${chooseEnumEntity(${concat("'", property, "'")})\}
${'#'} choose${property}Entity
- \${chooseEnumEntity(${concat("'", property, "'")})}
```

# propertyEntity
- ${join(createArray(namePlusSwitch(), cases(), default()), '')}

# namePlusSwitch
-```
# ${property}Entity(value)
- SWITCH: \${value\}```
${'#'} ${property}Entity(value)
- SWITCH: \${value}```

# case(option)
-```
- CASE: \${'${option}'\}
- CASE: \${'${option}'}
- ${phrase(option)}```

# cases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ ${ValueTemplate()}

# AskTemplate
- ```
# Ask${property}
- \${askEnum('${property}')\}
${'#'} Ask${property}
- \${askEnum('${property}')}
```

# ValueTemplate
- ```
# ${property}(val)
${'#'} ${property}(val)
- \${${property}Entity(val)}
```

Expand Down
14 changes: 7 additions & 7 deletions experimental/generation/generator/templates/generator.lg
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@

# nameTemplate
-```
# ${property}Name
${'#'} ${property}Name
- ${phrase(property, locale)}```

# valueTemplate
-```
# ${property}(val)
${'#'} ${property}(val)
- IF: \${val}
- \${val\}
- \${val}
- ELSE:
- no value
```

# entityDisplay
-```
# ${property}Entity(val)
${'#'} ${property}Entity(val)
- IF: \${val}
- \${val\}
- \${val}
- ELSE:
- no value
```
Expand Down Expand Up @@ -246,7 +246,7 @@
@composite RemoveFromProperty = [${entity}]
@composite ClearProperty = [PROPERTYName]
@composite ShowProperty = [PROPERTYName]
# ${triggerIntent}
${'#'} ${triggerIntent}
${substitutions(`library-operations.${locale}.data`, json(`{"entity": ${list(values)}, "property": ["${property}"]}`), 3)}
- ${property}
```
Expand All @@ -269,7 +269,7 @@ ${substitutions(`library-operations.${locale}.data`, json(`{"entity": ${list(val

> This is useful when importing another .lg file in order to add prefix/locale
# importLG(name)
-\[${prefix}-${name}.${locale}.lg](${prefix}-${name}.${locale}.lg)
-[${prefix}-${name}.${locale}.lg](${prefix}-${name}.${locale}.lg)

# luHeader
-> !# @app.culture = ${locale}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# chooseEnumEntity(property)
- ```
${askHelp()}
Please choose a value for ${name(property)} from \[${join(foreach(turn.dialogEvent.value.entity.value, val, enumEntityValue(property, val)), ', ')}\]
Please choose a value for ${name(property)} from [${join(foreach(turn.dialogEvent.value.entity.value, val, enumEntityValue(property, val)), ', ')}\]
```

# chooseEnumArrayEntity(property)
- ```
${askHelp()}
Please choose a value for ${name(property)} from \[${join(foreach(turn.dialogEvent.value.entity.value, val, enumEntityValue(property, val)), ', ')}\]
Please choose a value for ${name(property)} from [${join(foreach(turn.dialogEvent.value.entity.value, val, enumEntityValue(property, val)), ', ')}\]
```

# chooseProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ You can find out about a specific property by doing 'help <property>'.

# help1(property)
- IF: ${dialogClass.schema.properties[property].enum}
- Possible values for ${name(property)} include: \[${join(possibleValues(property), ', ')}\]
- Possible values for ${name(property)} include: [${join(possibleValues(property), ', ')}\]
- ELSEIF: ${dialogClass.schema.properties[property].type == 'number'}
- Expect a number for ${name(property)}
- ELSEIF: ${dialogClass.schema.properties[property].type == 'string'}
- Enter any string for ${name(property)}
- ELSEIF: ${dialogClass.schema.properties[property].type == 'array'}
- ${name(property)} is a list from: \[${join(possibleArrayValues(property), ', ')}\]
- ${name(property)} is a list from: [${join(possibleArrayValues(property), ', ')}\]
- ELSE:
- No help available.

Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

# namePlusSwitch
-```
# PROPERTYName(value)
- SWITCH: \${value\}```
${'#'} PROPERTYName(value)
- SWITCH: \${value}```

# case(option)
-```
- CASE: \${'${option}'\}
- CASE: \${'${option}'}
- ${phrase(option)}```

# cases
Expand All @@ -22,6 +22,6 @@
# default
-```
- DEFAULT:
- I don't understand \${value\}
- I don't understand \${value}
```

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# template
-```
# ${triggerIntent}
${'#'} ${triggerIntent}
${join(foreach(where(entities, entity, !contains(schema.$expectedOnly, entity)), entity, entityPattern(entity)), EOL())}
- {PROPERTYName}
```
Expand Down
Loading