From 0184ff09c5c3aff722fbc8a57b97bf6912730d20 Mon Sep 17 00:00:00 2001 From: Chris McConnell Date: Mon, 25 Jan 2021 15:56:10 -0800 Subject: [PATCH] Hash line ending agnostic and import exclusion bug (#1095) * Make hashing line ending agnostic. Fix bug where imports were not excluded properly. Added obj to exclusions. * Add missing wildcard. Co-authored-by: Chris McConnell --- packages/dialog/README.md | 2 +- packages/dialog/src/commands/dialog/merge.ts | 2 +- packages/dialog/src/library/hash.ts | 3 ++- packages/dialog/src/library/schemaMerger.ts | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/dialog/README.md b/packages/dialog/README.md index d5e50e2d..456bf9d8 100644 --- a/packages/dialog/README.md +++ b/packages/dialog/README.md @@ -36,7 +36,7 @@ _See code: [src/commands/dialog/index.ts](https://github.com/microsoft/botframew ## `bf dialog:merge PATTERNS` -Merge `.schema` and `[.].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 "exported" directory it is copied to / in the --imports directory. +Merge `.schema` and `[.].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 "exported" directory it is copied to / in the --imports directory. You can make use of negative patterns like !**/generated/** to exclude particular directories or files, although some directories like bin, obj and node_modules are automatically excluded. ``` USAGE diff --git a/packages/dialog/src/commands/dialog/merge.ts b/packages/dialog/src/commands/dialog/merge.ts index 644805a7..a0a33622 100644 --- a/packages/dialog/src/commands/dialog/merge.ts +++ b/packages/dialog/src/commands/dialog/merge.ts @@ -7,7 +7,7 @@ import { Command, flags } from '@microsoft/bf-cli-command' import { SchemaMerger } from '../../library/schemaMerger' export default class DialogMerge extends Command { - static description = 'Merge `.schema` and `[.].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 "exported" directory it is copied to / in the --imports directory.' + static description = 'Merge `.schema` and `[.].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 "exported" directory it is copied to / in the --imports directory. You can make use of negative patterns like !**/generated/** to exclude particular directories or files, although some directories like bin, obj and node_modules are automatically excluded.' static args = [ { name: 'patterns', required: true, description: 'Any number of glob regex patterns to match .csproj, .nuspec or package.json files.' }, diff --git a/packages/dialog/src/library/hash.ts b/packages/dialog/src/library/hash.ts index cb1c6384..299843f1 100644 --- a/packages/dialog/src/library/hash.ts +++ b/packages/dialog/src/library/hash.ts @@ -9,7 +9,8 @@ import * as os from 'os' import * as ppath from 'path' export function computeHash(val: string): string { - return crypto.createHash('md5').update(val).digest('hex') + // We write out OS.EOL, but want hash independent of endings + return crypto.createHash('md5').update(val.replace(/\r/, '')).digest('hex') } // Normalize to OS line endings diff --git a/packages/dialog/src/library/schemaMerger.ts b/packages/dialog/src/library/schemaMerger.ts index 67c7154c..09fb6199 100644 --- a/packages/dialog/src/library/schemaMerger.ts +++ b/packages/dialog/src/library/schemaMerger.ts @@ -153,8 +153,9 @@ class ComponentNode { patterns.push(`!${ppath.join(root, 'node_modules', '**')}`) } else if (this.metadata.path.endsWith('.csproj')) { patterns.push(`!${ppath.join(root, 'bin', '**')}`) + patterns.push(`!${ppath.join(root, 'obj', '**')}`) } - patterns.push(`!${imports}`) + patterns.push(`!${ppath.join(ppath.resolve(imports), '**')}`) patterns.push(`!${ppath.join(root, 'test', '**')}`) patterns.push(`!${ppath.join(root, 'tests', '**')}`) patterns = [...patterns, ...negativePatterns]