Files
git.stella-ops.org/src/Tools/GoldenPairs/Services/GoldenPairsPaths.cs
2026-01-13 18:53:39 +02:00

47 lines
1.5 KiB
C#

namespace StellaOps.Tools.GoldenPairs.Services;
public static class GoldenPairsPaths
{
public const string DatasetRelativePath = "datasets/golden-pairs";
public const string MetadataSchemaRelativePath = "docs/schemas/golden-pair-v1.schema.json";
public const string IndexSchemaRelativePath = "docs/schemas/golden-pairs-index.schema.json";
public static string? TryResolveRepoRoot(string? repoRoot)
{
if (!string.IsNullOrWhiteSpace(repoRoot))
{
return Path.GetFullPath(repoRoot);
}
var current = new DirectoryInfo(Directory.GetCurrentDirectory());
while (current is not null)
{
var solutionPath = Path.Combine(current.FullName, "src", "StellaOps.sln");
if (File.Exists(solutionPath))
{
return current.FullName;
}
current = current.Parent;
}
return null;
}
public static string ResolveDatasetRoot(string repoRoot, string? overridePath = null)
{
if (!string.IsNullOrWhiteSpace(overridePath))
{
return Path.GetFullPath(overridePath);
}
return Path.GetFullPath(Path.Combine(repoRoot, DatasetRelativePath));
}
public static string ResolveMetadataSchemaPath(string repoRoot)
=> Path.GetFullPath(Path.Combine(repoRoot, MetadataSchemaRelativePath));
public static string ResolveIndexSchemaPath(string repoRoot)
=> Path.GetFullPath(Path.Combine(repoRoot, IndexSchemaRelativePath));
}