Add phase 1 critical import tool
This commit is contained in:
34
src/RolemasterDb.ImportTool/RepositoryPaths.cs
Normal file
34
src/RolemasterDb.ImportTool/RepositoryPaths.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
namespace RolemasterDb.ImportTool;
|
||||
|
||||
public sealed class RepositoryPaths
|
||||
{
|
||||
private RepositoryPaths(string rootPath)
|
||||
{
|
||||
RootPath = rootPath;
|
||||
ManifestPath = Path.Combine(rootPath, "sources", "critical-import-manifest.json");
|
||||
DefaultDatabasePath = Path.Combine(rootPath, "src", "RolemasterDb.App", "rolemaster.db");
|
||||
ArtifactsRootPath = Path.Combine(rootPath, "artifacts", "import", "critical");
|
||||
}
|
||||
|
||||
public string RootPath { get; }
|
||||
public string ManifestPath { get; }
|
||||
public string DefaultDatabasePath { get; }
|
||||
public string ArtifactsRootPath { get; }
|
||||
|
||||
public static RepositoryPaths Discover()
|
||||
{
|
||||
var probe = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||
|
||||
while (probe is not null)
|
||||
{
|
||||
if (File.Exists(Path.Combine(probe.FullName, "RolemasterDB.slnx")))
|
||||
{
|
||||
return new RepositoryPaths(probe.FullName);
|
||||
}
|
||||
|
||||
probe = probe.Parent;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Could not discover the repository root from the current directory.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user