diff --git a/TopModel.Generator/Program.cs b/TopModel.Generator/Program.cs index 0a47aa84..7d2cd3c8 100644 --- a/TopModel.Generator/Program.cs +++ b/TopModel.Generator/Program.cs @@ -5,6 +5,7 @@ using System.Text; using System.Text.Encodings.Web; using System.Text.Json.Nodes; +using System.Text.RegularExpressions; using System.Xml; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -88,12 +89,30 @@ void HandleFile(FileInfo file) else { var dir = Directory.GetCurrentDirectory(); - var pattern = "topmodel*.config"; - foreach (var fileName in Directory.EnumerateFiles(dir, pattern, SearchOption.AllDirectories)) + var pattern = new Regex("topmodel\\.?([a-zA-Z-_.]*)\\.config$"); + + void SearchConfigFile(string dirName, int depth = 0) { - HandleFile(new FileInfo(fileName)); + if (depth > 3) + { + return; + } + + foreach (var entryName in Directory.EnumerateFileSystemEntries(dirName)) + { + if (Directory.Exists(entryName)) + { + SearchConfigFile(entryName, depth + 1); + } + else if (pattern.IsMatch(entryName)) + { + HandleFile(new FileInfo(entryName)); + } + } } + SearchConfigFile(dir); + if (configs.Count == 0) { var found = false; @@ -102,7 +121,7 @@ void HandleFile(FileInfo file) dir = Directory.GetParent(dir)?.FullName; if (dir != null) { - foreach (var fileName in Directory.EnumerateFiles(dir, pattern)) + foreach (var fileName in Directory.EnumerateFiles(dir).Where(f => pattern.IsMatch(f))) { HandleFile(new FileInfo(fileName)); found = true; @@ -233,6 +252,8 @@ void HandleFile(FileInfo file) foreach (var cg in config.CustomGenerators) { + var customDir = Path.GetFullPath(Path.Combine(new FileInfo(Path.GetFullPath(fullName)).DirectoryName!, cg)); + string GetCgHash() { return GetHash( @@ -243,7 +264,7 @@ string GetCgHash() SearchOption.AllDirectories) .Where(f => !f.Contains($"{Path.DirectorySeparatorChar}obj{Path.DirectorySeparatorChar}"))) .ToList(), - cg) ?? string.Empty; + customDir) ?? string.Empty; } var customHash = GetCgHash(); @@ -254,9 +275,9 @@ string GetCgHash() { CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, - FileName = "dotnet.exe", + FileName = "dotnet", Arguments = "build -v q", - WorkingDirectory = cg, + WorkingDirectory = customDir, RedirectStandardOutput = true, StandardOutputEncoding = Encoding.UTF8 }); @@ -692,7 +713,7 @@ IEnumerable GetCustomAssemblies(string cg, string fullName) var md5 = MD5.Create(); foreach (var file in files) { - var relativePath = file[(path.Length + 1)..]; + var relativePath = file[(path.Length + 1)..].Replace("\\", "/"); var pathBytes = Encoding.UTF8.GetBytes(relativePath.ToLower()); md5.TransformBlock(pathBytes, 0, pathBytes.Length, pathBytes, 0); diff --git a/samples/model/angular.topmodel.lock b/samples/model/angular.topmodel.lock index 6587c6fc..749622e9 100644 --- a/samples/model/angular.topmodel.lock +++ b/samples/model/angular.topmodel.lock @@ -4,6 +4,8 @@ version: 2.1.0 modules: {} +custom: + ../../../TopModel.Generator.Javascript: 46c0ea3a520d396e7f1b9660c73e1a04 generatedFiles: - ../generators/angular/src/appgenerated/api/securite/profil/profil.service.ts - ../generators/angular/src/appgenerated/api/securite/utilisateur/utilisateur.service.ts diff --git a/samples/model/csharp.topmodel.lock b/samples/model/csharp.topmodel.lock index 307226eb..f2c2d738 100644 --- a/samples/model/csharp.topmodel.lock +++ b/samples/model/csharp.topmodel.lock @@ -4,6 +4,8 @@ version: 2.1.0 modules: {} +custom: + ../../../TopModel.Generator.Csharp: ac9d06ecaad0da1d8f16e82c616ec29e generatedFiles: - ../generators/csharp/src/Clients/CSharp.Clients.Db/generated/CSharpDbContext.comments.cs - ../generators/csharp/src/Clients/CSharp.Clients.Db/generated/CSharpDbContext.cs diff --git a/samples/model/focus.topmodel.lock b/samples/model/focus.topmodel.lock index a1a64cb8..a2ac2627 100644 --- a/samples/model/focus.topmodel.lock +++ b/samples/model/focus.topmodel.lock @@ -4,6 +4,8 @@ version: 2.1.0 modules: {} +custom: + ../../../TopModel.Generator.Javascript: 46c0ea3a520d396e7f1b9660c73e1a04 generatedFiles: - ../generators/focus/src/locale/common.ts - ../generators/focus/src/locale/securite.ts diff --git a/samples/model/jpa.topmodel.lock b/samples/model/jpa.topmodel.lock index e118026f..298d1b94 100644 --- a/samples/model/jpa.topmodel.lock +++ b/samples/model/jpa.topmodel.lock @@ -4,6 +4,8 @@ version: 2.1.0 modules: {} +custom: + ../../../TopModel.Generator.Jpa: cdaafe723c3c8a62fbbae4458e747c78 generatedFiles: - ../generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/profil/ProfilClient.java - ../generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/utilisateur/UtilisateurClient.java diff --git a/samples/model/pg.topmodel.lock b/samples/model/pg.topmodel.lock index 4fb106d2..249e713f 100644 --- a/samples/model/pg.topmodel.lock +++ b/samples/model/pg.topmodel.lock @@ -4,6 +4,8 @@ version: 2.1.0 modules: {} +custom: + ../../../TopModel.Generator.Sql: 034f6c954fd448be54a0874535091f15 generatedFiles: - ../generators/pg/src/01_tables.sql - ../generators/pg/src/02_fk_indexes.sql diff --git a/samples/model/php.topmodel.lock b/samples/model/php.topmodel.lock index 18896a3d..cc0191a8 100644 --- a/samples/model/php.topmodel.lock +++ b/samples/model/php.topmodel.lock @@ -4,6 +4,8 @@ version: 2.1.0 modules: {} +custom: + ../../../TopModel.Generator.Php: edad27472c9f0ff7e6c8904927f0c472 generatedFiles: - ../generators/php/src/Entity/Securite/Profil/Droit.php - ../generators/php/src/Entity/Securite/Profil/Profil.php diff --git a/samples/model/ssdt.topmodel.lock b/samples/model/ssdt.topmodel.lock index 394af1a8..acc8bf4b 100644 --- a/samples/model/ssdt.topmodel.lock +++ b/samples/model/ssdt.topmodel.lock @@ -4,6 +4,8 @@ version: 2.1.0 modules: {} +custom: + ../../../TopModel.Generator.Sql: 034f6c954fd448be54a0874535091f15 generatedFiles: - ../generators/ssdt/src/init/DROIT.insert.sql - ../generators/ssdt/src/init/main.sql diff --git a/samples/model/translation.topmodel.lock b/samples/model/translation.topmodel.lock index fb84e822..33c75a59 100644 --- a/samples/model/translation.topmodel.lock +++ b/samples/model/translation.topmodel.lock @@ -4,6 +4,8 @@ version: 2.1.0 modules: {} +custom: + ../../../TopModel.Generator.Translation: d632c242520f38cceb6e8feafc70a613 generatedFiles: - ../generators/translation/i18n/de_DE/out/common_de_DE.properties - ../generators/translation/i18n/de_DE/out/securite_de_DE.properties