From 02860cba8618d99f489318ebcead1eb7166da24a Mon Sep 17 00:00:00 2001 From: Dan Kadera Date: Wed, 8 Nov 2023 18:08:15 +0100 Subject: [PATCH] stabilise order of generated definitions' imports --- core/cli/package.json | 2 +- core/cli/src/compiler.ts | 12 +++++++++--- package-lock.json | 8 ++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/core/cli/package.json b/core/cli/package.json index f4b98a8..0c3f05a 100644 --- a/core/cli/package.json +++ b/core/cli/package.json @@ -9,7 +9,7 @@ "ioc", "inversion of control" ], - "version": "0.0.40", + "version": "0.0.41", "license": "MIT", "author": { "name": "Dan Kadera", diff --git a/core/cli/src/compiler.ts b/core/cli/src/compiler.ts index 27005c1..817bcca 100644 --- a/core/cli/src/compiler.ts +++ b/core/cli/src/compiler.ts @@ -447,9 +447,15 @@ function compareIDs(a: string, b: string): number { } function extractSources(definitions: ServiceDefinitionInfo[]): Map { - return new Map([ - ...new Set(definitions.flatMap((d) => [d.source, ...d.decorators.map((o) => o.source)])), - ].map((s, i) => [s, `defs${i}`])); + const sources = [...new Set(definitions.flatMap((d) => [d.source, ...d.decorators.map((o) => o.source)]))]; + sources.sort(compareSourceFiles); + return new Map(sources.map((s, i) => [s, `defs${i}`])); +} + +function compareSourceFiles(a: SourceFile, b: SourceFile): number { + const pa = a.getFilePath(); + const pb = b.getFilePath(); + return pa < pb ? -1 : pa > pb ? 1 : 0; } function join(separator: string, ...tokens: (string | 0 | false | undefined)[]): string { diff --git a/package-lock.json b/package-lock.json index 5190e14..322067f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ }, "core/cli": { "name": "dicc-cli", - "version": "0.0.40", + "version": "0.0.41", "license": "MIT", "dependencies": { "@debugr/console": "^3.0.0-rc.10", @@ -1370,9 +1370,9 @@ } }, "node_modules/zod": { - "version": "3.21.4", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz", - "integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==", + "version": "3.22.4", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz", + "integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==", "funding": { "url": "https://github.com/sponsors/colinhacks" }