Skip to content

Commit

Permalink
[modgen] maxdepth = 3 lors de la recherche d'un fichier de config + f…
Browse files Browse the repository at this point in the history
…ix build pour samples
  • Loading branch information
JabX committed Sep 24, 2024
1 parent 67f27db commit dfefeee
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 8 deletions.
37 changes: 29 additions & 8 deletions TopModel.Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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();
Expand All @@ -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
});
Expand Down Expand Up @@ -692,7 +713,7 @@ IEnumerable<FileInfo> 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);

Expand Down
2 changes: 2 additions & 0 deletions samples/model/angular.topmodel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

version: 2.1.0
modules: {}
custom:
../../../TopModel.Generator.Javascript: 32e90383e2e9c1d1e2bec7a28828545c
generatedFiles:
- ../generators/angular/src/appgenerated/api/securite/profil/profil.service.ts
- ../generators/angular/src/appgenerated/api/securite/utilisateur/utilisateur.service.ts
Expand Down
2 changes: 2 additions & 0 deletions samples/model/csharp.topmodel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

version: 2.1.0
modules: {}
custom:
../../../TopModel.Generator.Csharp: 432877ea14ff857994e6acb660c56e42
generatedFiles:
- ../generators/csharp/src/Clients/CSharp.Clients.Db/generated/CSharpDbContext.comments.cs
- ../generators/csharp/src/Clients/CSharp.Clients.Db/generated/CSharpDbContext.cs
Expand Down
2 changes: 2 additions & 0 deletions samples/model/focus.topmodel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

version: 2.1.0
modules: {}
custom:
../../../TopModel.Generator.Javascript: 32e90383e2e9c1d1e2bec7a28828545c
generatedFiles:
- ../generators/focus/src/locale/common.ts
- ../generators/focus/src/locale/securite.ts
Expand Down
2 changes: 2 additions & 0 deletions samples/model/jpa.topmodel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

version: 2.1.0
modules: {}
custom:
../../../TopModel.Generator.Jpa: bdce044a2d581964095bc79142c6deca
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
Expand Down
2 changes: 2 additions & 0 deletions samples/model/pg.topmodel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

version: 2.1.0
modules: {}
custom:
../../../TopModel.Generator.Sql: a7b3bbd55f51af14067702de1fb5336d
generatedFiles:
- ../generators/pg/src/01_tables.sql
- ../generators/pg/src/02_fk_indexes.sql
Expand Down
2 changes: 2 additions & 0 deletions samples/model/php.topmodel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

version: 2.1.0
modules: {}
custom:
../../../TopModel.Generator.Php: f95e31455ddcfd77a37c3442de5af904
generatedFiles:
- ../generators/php/src/Entity/Securite/Profil/Droit.php
- ../generators/php/src/Entity/Securite/Profil/Profil.php
Expand Down
2 changes: 2 additions & 0 deletions samples/model/ssdt.topmodel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

version: 2.1.0
modules: {}
custom:
../../../TopModel.Generator.Sql: a7b3bbd55f51af14067702de1fb5336d
generatedFiles:
- ../generators/ssdt/src/init/DROIT.insert.sql
- ../generators/ssdt/src/init/main.sql
Expand Down
2 changes: 2 additions & 0 deletions samples/model/translation.topmodel.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

version: 2.1.0
modules: {}
custom:
../../../TopModel.Generator.Translation: 4e07da1d91debeb0b1ea6b65368a467f
generatedFiles:
- ../generators/translation/i18n/de_DE/out/common_de_DE.properties
- ../generators/translation/i18n/de_DE/out/securite_de_DE.properties
Expand Down

0 comments on commit dfefeee

Please sign in to comment.