diff --git a/.vscode/launch.json b/.vscode/launch.json index 39df29e60..0ab2a9977 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,9 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/cli/bin/run", "outputCapture": "std", - "outFiles": ["${workspaceFolder}/packages/luis/lib/**"], + "outFiles": [ + "${workspaceFolder}/packages/luis/lib/**" + ], "args": [ "luis:build", "--luConfig", @@ -36,7 +38,9 @@ "cwd": "${workspaceFolder}/packages/dialog", "internalConsoleOptions": "openOnSessionStart", "outputCapture": "std", - "outFiles": ["./package/dialog/lib/**"] + "outFiles": [ + "./package/dialog/lib/**" + ] }, { "type": "node", @@ -57,7 +61,9 @@ ], "internalConsoleOptions": "openOnSessionStart", "outputCapture": "std", - "outFiles": ["./package/dialog/lib/**"] + "outFiles": [ + "./package/dialog/lib/**" + ] }, { "type": "node", @@ -78,7 +84,9 @@ ".*" ], "internalConsoleOptions": "openOnSessionStart", - "outFiles": ["./lib/**"] + "outFiles": [ + "./lib/**" + ] }, { "type": "node", @@ -87,10 +95,19 @@ "preLaunchTask": "${defaultBuildTask}", "cwd": "${workspaceFolder}/packages/lu", "runtimeExecutable": "npm", - "runtimeArgs": ["run", "test", "--", "--timeout", "999999", "--colors"], + "runtimeArgs": [ + "run", + "test", + "--", + "--timeout", + "999999", + "--colors" + ], "internalConsoleOptions": "openOnSessionStart", "outputCapture": "std", - "outFiles": ["./packages/lu/lib/**"] + "outFiles": [ + "./packages/lu/lib/**" + ] }, { "type": "node", @@ -111,7 +128,9 @@ ], "internalConsoleOptions": "openOnSessionStart", "outputCapture": "std", - "outFiles": ["./packages/lu/lib/**"] + "outFiles": [ + "./packages/lu/lib/**" + ] }, { "type": "node", @@ -120,7 +139,9 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/dialog/bin/run", "outputCapture": "std", - "outFiles": ["./packages/dialog/lib/**"], + "outFiles": [ + "./packages/dialog/lib/**" + ], "args": [ "dialog:merge", "libraries/**/*.schema", @@ -132,6 +153,26 @@ "internalConsoleOptions": "openOnSessionStart", "cwd": "${workspaceFolder}/../botbuilder-dotnet" }, + { + "type": "node", + "request": "launch", + "name": "Composer schema", + "preLaunchTask": "${defaultBuildTask}", + "program": "${workspaceFolder}/packages/dialog/bin/run", + "outputCapture": "std", + "outFiles": [ + "./packages/dialog/lib/**" + ], + "args": [ + "dialog:merge", + "**/*.csproj", + "-o", + "${env:TEMP}/sdk.schema", + "--verbose" + ], + "internalConsoleOptions": "openOnSessionStart", + "cwd": "${workspaceFolder}/../BotFramework-Composer/runtime/dotnet" + }, { "type": "node", "request": "launch", @@ -139,7 +180,9 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/dialog/bin/run", "outputCapture": "std", - "outFiles": ["./packages/dialog/lib/**"], + "outFiles": [ + "./packages/dialog/lib/**" + ], "args": [ "dialog:merge", "tests/Microsoft.Bot.Builder.Dialogs.Declarative.Tests/*.csproj", @@ -157,7 +200,9 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/dialog/bin/run", "outputCapture": "std", - "outFiles": ["./packages/dialog/lib/**"], + "outFiles": [ + "./packages/dialog/lib/**" + ], "args": [ "dialog:merge", "*.csproj", @@ -175,8 +220,14 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/dialog/bin/run", "outputCapture": "std", - "outFiles": ["./packages/dialog/lib/**"], - "args": ["dialog:verify", "tests/**/*.dialog", "--verbose"], + "outFiles": [ + "./packages/dialog/lib/**" + ], + "args": [ + "dialog:verify", + "tests/**/*.dialog", + "--verbose" + ], "internalConsoleOptions": "openOnSessionStart", "cwd": "${workspaceFolder}/../botbuilder-dotnet" }, @@ -187,7 +238,9 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/dialog/bin/run", "outputCapture": "std", - "outFiles": ["./packages/dialog/lib/**"], + "outFiles": [ + "./packages/dialog/lib/**" + ], "args": [ "dialog:merge", "libraries/**/*.schema", @@ -206,7 +259,9 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/dialog/bin/run", "outputCapture": "std", - "outFiles": ["./packages/dialog/lib/**"], + "outFiles": [ + "./packages/dialog/lib/**" + ], "args": [ "dialog:merge", "RunBot.csproj", @@ -246,7 +301,10 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/luis/bin/run", "outputCapture": "std", - "outFiles": ["./packages/luis/lib/**", "./packages/lu/lib/**"], + "outFiles": [ + "./packages/luis/lib/**", + "./packages/lu/lib/**" + ], "args": [ "luis:build", "--luConfig", @@ -264,7 +322,10 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/luis/bin/run", "outputCapture": "std", - "outFiles": ["./packages/luis/lib/**", "./packages/lu/lib/**"], + "outFiles": [ + "./packages/luis/lib/**", + "./packages/lu/lib/**" + ], "args": [ "luis:convert", "--in", @@ -285,7 +346,10 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/luis/bin/run", "outputCapture": "std", - "outFiles": ["./packages/luis/lib/**", "./packages/lu/lib/**"], + "outFiles": [ + "./packages/luis/lib/**", + "./packages/lu/lib/**" + ], "args": [ "luis:convert", "--in", @@ -306,7 +370,10 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/lu/bin/run", "outputCapture": "std", - "outFiles": ["./packages/lu/lib/**", "./pacakges/luis/lib/**"], + "outFiles": [ + "./packages/lu/lib/**", + "./pacakges/luis/lib/**" + ], "args": [ "luis:build", "--in", @@ -327,7 +394,9 @@ "preLaunchTask": "${defaultBuildTask}", "program": "${workspaceFolder}/packages/lg/bin/run", "outputCapture": "std", - "outFiles": ["./packages/lg/lib/**"], + "outFiles": [ + "./packages/lg/lib/**" + ], "args": [ "lg:expand", "--in", @@ -341,4 +410,4 @@ "cwd": "${workspaceFolder}/packages/lg/test/fixtures/testcase" } ] -} +} \ No newline at end of file diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 732f37f40..c0b882de7 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -64,7 +64,6 @@ dependencies: read-text-file: 1.1.0 readline: 1.3.0 seedrandom: 3.0.5 - semver: 5.7.1 sinon: 7.5.0 source-map-support: 0.5.16 testdouble: 3.13.0 @@ -3848,6 +3847,14 @@ packages: dev: false resolution: integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== + /lru-cache/6.0.0: + dependencies: + yallist: 4.0.0 + dev: false + engines: + node: '>=10' + resolution: + integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== /make-dir/2.1.0: dependencies: pify: 4.0.1 @@ -5132,6 +5139,15 @@ packages: hasBin: true resolution: integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + /semver/7.3.4: + dependencies: + lru-cache: 6.0.0 + dev: false + engines: + node: '>=10' + hasBin: true + resolution: + integrity: sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw== /set-blocking/2.0.0: dev: false resolution: @@ -6179,6 +6195,10 @@ packages: dev: false resolution: integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== + /yallist/4.0.0: + dev: false + resolution: + integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== /yargs-parser/13.1.1: dependencies: camelcase: 5.3.1 @@ -6265,7 +6285,7 @@ packages: dev: false name: '@rush-temp/bf-chatdown' resolution: - integrity: sha512-Wb4uaq0qzFykhafngtZf7SiHiNrGzhhmof6QqgeoME7tHLszySHESBlOXKFyn18QHxiqfrSrDxNwYA1d1CVAEg== + integrity: sha512-LwnxaJqorI7QZOxe9fA42tJiw9KC018EJ4/Nb5TJdhnH4W9jI6hsFnai/7KrPok+1l4hdb2Dp0p2Yqft0+MM+w== tarball: 'file:projects/bf-chatdown.tgz' version: 0.0.0 'file:projects/bf-cli-command.tgz': @@ -6306,7 +6326,7 @@ packages: dev: false name: '@rush-temp/bf-cli-command' resolution: - integrity: sha512-kYzHgqDKu3wAjtUuKwtp8FvZt5AkCADPxQPvs3lV9U//bYD5o2d27xl6Dmj9T2namd/AR5S4LwxBkJD+De2bxQ== + integrity: sha512-j/EQpgif6mijXWVVa6eTxJ1W/rvMNHJ/1JQy+CHJz/M6NkCVCvLFlR5modLisPLKCDRRT+29eygP/SMpCRrWcg== tarball: 'file:projects/bf-cli-command.tgz' version: 0.0.0 'file:projects/bf-cli-config.tgz': @@ -6335,7 +6355,7 @@ packages: dev: false name: '@rush-temp/bf-cli-config' resolution: - integrity: sha512-ksGLovc5xrgg1UroumRsRoMMdhcYIWHpcMrOOWAFc+TupPLMJ9OHZ9V5unfN4fi4e4OSVxZK1EQBQRqa0ok0Gg== + integrity: sha512-jROoKQr6sygYp+6RJDEF5Yo+W4e4mJtjih6nMCDl+jllo13ZLkvXgrrxTLmJiVp1BD2r2La0Ydgcu0LKwH0u5w== tarball: 'file:projects/bf-cli-config.tgz' version: 0.0.0 'file:projects/bf-cli-plugins.tgz': @@ -6364,7 +6384,7 @@ packages: dev: false name: '@rush-temp/bf-cli-plugins' resolution: - integrity: sha512-xS786DuaVjEi8tPoDFgpWainsqS3Cb1CmzJSLX4zTTKyE60p+HTYwmUQx1JKq8dggoNO+P2lbz/51SflCV0L7Q== + integrity: sha512-f4KIJd3jxLMwW29Gf/E7a1PdcJa1LqZTxYgcsgivlfGedKFVho+BSoJxhhJ99c7RYqiMI8vvoNzKmwuzzFzAtw== tarball: 'file:projects/bf-cli-plugins.tgz' version: 0.0.0 'file:projects/bf-dialog.tgz': @@ -6410,7 +6430,7 @@ packages: path: 0.12.7 rimraf: 2.7.1 seedrandom: 3.0.5 - semver: 5.7.1 + semver: 7.3.4 ts-node: 9.0.0_typescript@4.0.3 tslib: 2.0.3 tslint: 5.20.1_typescript@4.0.3 @@ -6419,7 +6439,7 @@ packages: dev: false name: '@rush-temp/bf-dialog' resolution: - integrity: sha512-8kUxj5rw5WU5RlPdqqOUfIZ0FrC93AIcrRaEmIeT/ThY6y+kRFYiNBafWNdgZuV4tDhwjbdWCPZsLReXBzo0Ag== + integrity: sha512-RKFohAxZBJ6lsydNs3Oel2pjEeFUqSZUGPjW20cdw0iRTYNoj4HN0hNJSqdYoslu9GKHtO7hHJfUSUE7uFPQXA== tarball: 'file:projects/bf-dialog.tgz' version: 0.0.0 'file:projects/bf-lg-cli.tgz': @@ -6458,7 +6478,7 @@ packages: dev: false name: '@rush-temp/bf-lg-cli' resolution: - integrity: sha512-gvrRLE11wdMMjPil7NxZa0Xj+IkTEx6Q5eehmv5v+Af7ifkxOe3n2bNyTyAYEe/7dzY2jca3dTvuBR3D77hZvA== + integrity: sha512-n/fsTdjvlGsrNbOvuBZiKxWCb2OTQS/Cqt+C6rqrGKibe3hnTFF24RjJhuU1CBkPw3CDHJkfA9pAPnwoXNM4Jg== tarball: 'file:projects/bf-lg-cli.tgz' version: 0.0.0 'file:projects/bf-lu.tgz': @@ -6500,7 +6520,7 @@ packages: dev: false name: '@rush-temp/bf-lu' resolution: - integrity: sha512-BZgbZNnq37dDSnbEv71cYgExtHIwGoJtTRLI1Lg3JhyS37Ctvu71fOEsC5Igz7QfZCwVy44FHL30XjLc0yxQng== + integrity: sha512-idgtiuhAkB8CwVNp0iQcGkBUCIbsmQab6zQujW1T1AOUwPZjE1Aml1y9NUizV4G5batuOhygJvtZHcYB4UZrKQ== tarball: 'file:projects/bf-lu.tgz' version: 0.0.0 'file:projects/bf-luis-cli.tgz': @@ -6544,7 +6564,7 @@ packages: dev: false name: '@rush-temp/bf-luis-cli' resolution: - integrity: sha512-h38qp0iFrAg2EGh054ZZicscEWGmEvg0sRhwPuiVppm/iA+KXtYTFJFwz6Kw8R7EZoEbmbE9Dt1eWM0vr9eO3Q== + integrity: sha512-IvEe5WBbavK6PUFtDRqATprW3PXQ4hZWSEqZ+wneCXq48Ow0/0YlXZf7D+pm6rTm6ij6EK93/DDK3rtktACnqA== tarball: 'file:projects/bf-luis-cli.tgz' version: 0.0.0 'file:projects/bf-qnamaker.tgz': @@ -6595,7 +6615,7 @@ packages: dev: false name: '@rush-temp/bf-qnamaker' resolution: - integrity: sha512-k458yG6b0VkPZ5wy4E0Kc3z+V91k6rrdCrYNZSJ6wGHbHIFtoIU0jEObi/tDMdhE7OzVvHPqz0vXWmeWnDcb6g== + integrity: sha512-GpMpI9b+pI8abjKmCCvp0BH2T/P0Di+k5dATmhcmgCHz8UOjkjGByZKqO+YirQGhjXEoaBImaVQ7dP5aj57Qsw== tarball: 'file:projects/bf-qnamaker.tgz' version: 0.0.0 'file:projects/botframework-cli.tgz': @@ -6631,7 +6651,7 @@ packages: dev: false name: '@rush-temp/botframework-cli' resolution: - integrity: sha512-AX7BHfM3wGdgxGgtJAKJWtH+k+GkPR/OntSH6FI/oFadniGwg4CjKD01YIhC4NSKb+pzBZXTXj48Ler8sbcODw== + integrity: sha512-9/0dyLrvSjgWsNXuBSOXqwjTbMLJAZYYvD7wX2OQWvadN/vq5ghqSNXuB78IZiFaClFOdiuueRHQqPDVNL8VVQ== tarball: 'file:projects/botframework-cli.tgz' version: 0.0.0 registry: '' @@ -6701,7 +6721,6 @@ specifiers: read-text-file: ^1.1.0 readline: ^1.3.0 seedrandom: ~3.0.5 - semver: ^5.5.1 sinon: ^7.5.0 source-map-support: ~0.5.16 testdouble: ^3.11.0 diff --git a/packages/dialog/package.json b/packages/dialog/package.json index fa2caa4d9..bfa73b846 100644 --- a/packages/dialog/package.json +++ b/packages/dialog/package.json @@ -54,6 +54,7 @@ "os": "~0.1.1", "path": "^0.12.7", "seedrandom": "~3.0.5", + "semver": "^7.3.4", "tslib": "^2.0.3", "xml2js": "^0.4.19", "json-ptr": "~1.3.0", diff --git a/packages/dialog/src/library/schemaMerger.ts b/packages/dialog/src/library/schemaMerger.ts index 09fb61994..fd194a90a 100644 --- a/packages/dialog/src/library/schemaMerger.ts +++ b/packages/dialog/src/library/schemaMerger.ts @@ -17,6 +17,7 @@ const allof = require('json-schema-merge-allof') const clone = require('clone') const getUri = require('get-uri') const glob = require('globby') +const semverRsort = require('semver/functions/rsort') const util = require('util') const exec = util.promisify(require('child_process').exec) @@ -1055,6 +1056,31 @@ export class SchemaMerger { } } + // Convert a nuget pattern to a regexp + // 4.*.2.*-* would go to ^4\.[^.]*\.2\.[^-]*-.*$ + private nugetPattern(version: string): RegExp { + let pattern = '^' + for (let i = 0; i < version.length; ++i) { + let ch = version[i] + switch (ch) { + case '*': + if (i + 1 < version.length) { + pattern += `[^${version[i + 1]}]*` + } else { + pattern += '.*' + } + break + case '.': + pattern += '\\.' + break + default: + pattern += ch + } + } + pattern += '$' + return new RegExp(pattern) + } + // Expand nuget package and all of its dependencies private async expandNuget(packageName: string, minVersion: string): Promise { // Linux/Mac are case sensitive and nuget/dotnet lowercase package names @@ -1069,18 +1095,27 @@ export class SchemaMerger { for (const pkgVersion of await fs.readdir(pkgPath)) { versions.push(pkgVersion.toLowerCase()) } - // NOTE: The semver package does not handle more complex nuget range revisions - // We get an exception and will ignore those dependencies. + let versionToUse = '' minVersion = minVersion || '0.0.0' if (minVersion.startsWith('$')) { // Deal with build variables by installing most recent version - minVersion = nuget.maxSatisfying(versions, '0-1000') + versionToUse = nuget.maxSatisfying(versions, '0-1000') if (this.debug) { this.parsingWarning(`Using most recent version ${minVersion}`) } + } else if (minVersion.includes('*')) { + // Match pattern against available versions + const pattern = this.nugetPattern(minVersion) + for (const version of semverRsort(versions)) { + if (pattern.exec(version)) { + versionToUse = version + break + } + } + } else { + versionToUse = nuget.minSatisfying(versions, minVersion) } - const version = nuget.minSatisfying(versions, minVersion) - pkgPath = ppath.join(pkgPath, version ?? '') + pkgPath = ppath.join(pkgPath, versionToUse ?? '') const nuspecPath = ppath.join(pkgPath, `${packageName}.nuspec`) await this.expandNuspec(nuspecPath) } else if (this.debug) { diff --git a/packages/dialog/test/commands/dialog/projects/project1/project1.csproj b/packages/dialog/test/commands/dialog/projects/project1/project1.csproj index d0205d298..319db2b5c 100644 --- a/packages/dialog/test/commands/dialog/projects/project1/project1.csproj +++ b/packages/dialog/test/commands/dialog/projects/project1/project1.csproj @@ -39,7 +39,7 @@ - +