Compare commits
2 Commits
0dde7c40f3
...
3789492de3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3789492de3 | ||
|
|
29e027b918 |
@ -10,27 +10,19 @@ internal sealed record MenuItem(string Display, string Value);
|
||||
public enum AppExitReason { Quit, SwitchProject }
|
||||
public sealed record AppResult(AppExitReason Reason, string? NewProjectRoot = null);
|
||||
|
||||
public sealed class App
|
||||
{
|
||||
private DevToolConfig _config;
|
||||
private string _projectRoot;
|
||||
private readonly WorkspaceConfig? _workspace;
|
||||
private readonly string? _workspaceRoot;
|
||||
|
||||
private IReadOnlyDictionary<string, BuildTarget> TargetMap =>
|
||||
_config.Targets.ToDictionary(t => t.Id, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public App(
|
||||
public sealed class App(
|
||||
DevToolConfig config,
|
||||
string projectRoot,
|
||||
WorkspaceConfig? workspace = null,
|
||||
string? workspaceRoot = null)
|
||||
{
|
||||
_config = config;
|
||||
_projectRoot = projectRoot;
|
||||
_workspace = workspace;
|
||||
_workspaceRoot = workspaceRoot;
|
||||
}
|
||||
private DevToolConfig _config = config;
|
||||
private string _projectRoot = projectRoot;
|
||||
private readonly WorkspaceConfig? _workspace = workspace;
|
||||
private readonly string? _workspaceRoot = workspaceRoot;
|
||||
|
||||
private IReadOnlyDictionary<string, BuildTarget> TargetMap =>
|
||||
_config.Targets.ToDictionary(t => t.Id, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public async Task<AppResult> RunAsync()
|
||||
{
|
||||
|
||||
@ -5,16 +5,10 @@ using Spectre.Console;
|
||||
|
||||
namespace Sdt.Tui;
|
||||
|
||||
public sealed class ToolchainScreen
|
||||
public sealed class ToolchainScreen(DevToolConfig config, string projectRoot)
|
||||
{
|
||||
private readonly DevToolConfig _config;
|
||||
private readonly string _projectRoot;
|
||||
|
||||
public ToolchainScreen(DevToolConfig config, string projectRoot)
|
||||
{
|
||||
_config = config;
|
||||
_projectRoot = projectRoot;
|
||||
}
|
||||
private readonly DevToolConfig _config = config;
|
||||
private readonly string _projectRoot = projectRoot;
|
||||
|
||||
public async Task RunAsync()
|
||||
{
|
||||
@ -263,7 +257,7 @@ public sealed class ToolchainScreen
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
private string ResolvePythonExe(PythonToolchain py)
|
||||
private static string ResolvePythonExe(PythonToolchain py)
|
||||
{
|
||||
if (OperatingSystem.IsWindows() && !string.IsNullOrWhiteSpace(py.WindowsExecutable))
|
||||
return py.WindowsExecutable;
|
||||
|
||||
@ -3,18 +3,11 @@ using Spectre.Console;
|
||||
|
||||
namespace Sdt.Tui;
|
||||
|
||||
public sealed class WorkspaceScreen
|
||||
public sealed class WorkspaceScreen(WorkspaceConfig workspace, string workspaceRoot, string currentProjectRoot)
|
||||
{
|
||||
private readonly WorkspaceConfig _workspace;
|
||||
private readonly string _workspaceRoot;
|
||||
private readonly string _currentProjectRoot;
|
||||
|
||||
public WorkspaceScreen(WorkspaceConfig workspace, string workspaceRoot, string currentProjectRoot)
|
||||
{
|
||||
_workspace = workspace;
|
||||
_workspaceRoot = workspaceRoot;
|
||||
_currentProjectRoot = currentProjectRoot;
|
||||
}
|
||||
private readonly WorkspaceConfig _workspace = workspace;
|
||||
private readonly string _workspaceRoot = workspaceRoot;
|
||||
private readonly string _currentProjectRoot = currentProjectRoot;
|
||||
|
||||
/// <summary>
|
||||
/// Shows the project switcher. Returns the absolute path to the selected project root,
|
||||
|
||||
@ -67,11 +67,11 @@ app.MapPost("/api/command", async (CommandEnvelope? command, Entry entry) =>
|
||||
|
||||
app.MapGet("/api/sidecar/root", (SidecarRootState rootState) =>
|
||||
{
|
||||
var snapshot = rootState.Get();
|
||||
var (root, isCustom) = rootState.Get();
|
||||
return Results.Ok(new
|
||||
{
|
||||
root = snapshot.Root,
|
||||
isCustom = snapshot.IsCustom
|
||||
root,
|
||||
isCustom
|
||||
});
|
||||
});
|
||||
|
||||
@ -84,12 +84,12 @@ app.MapPost("/api/sidecar/root", (SetSidecarRootRequest? request, SidecarRootSta
|
||||
}
|
||||
|
||||
rootState.Set(path);
|
||||
var snapshot = rootState.Get();
|
||||
Environment.SetEnvironmentVariable("JOURNAL_PROJECT_ROOT", snapshot.Root);
|
||||
var (root, isCustom) = rootState.Get();
|
||||
Environment.SetEnvironmentVariable("JOURNAL_PROJECT_ROOT", root);
|
||||
return Results.Ok(new
|
||||
{
|
||||
root = snapshot.Root,
|
||||
isCustom = snapshot.IsCustom
|
||||
root,
|
||||
isCustom
|
||||
});
|
||||
});
|
||||
|
||||
@ -207,32 +207,20 @@ string ResolveWebDist(string repoRootPath)
|
||||
string ErrorResponse(string message)
|
||||
=> JsonSerializer.Serialize(new { ok = false, error = message }, gatewayJsonOptions);
|
||||
|
||||
sealed class WebUiState
|
||||
sealed class WebUiState(string distPath)
|
||||
{
|
||||
public WebUiState(string distPath)
|
||||
{
|
||||
DistPath = distPath;
|
||||
}
|
||||
|
||||
public string DistPath { get; }
|
||||
public string DistPath { get; } = distPath;
|
||||
|
||||
public bool Exists => Directory.Exists(DistPath) && File.Exists(Path.Combine(DistPath, "index.html"));
|
||||
}
|
||||
|
||||
sealed class SidecarRootState
|
||||
sealed class SidecarRootState(string autoRoot)
|
||||
{
|
||||
private readonly object _sync = new();
|
||||
private readonly string _autoRoot;
|
||||
private string _currentRoot;
|
||||
private readonly string _autoRoot = autoRoot;
|
||||
private string _currentRoot = autoRoot;
|
||||
private bool _isCustom;
|
||||
|
||||
public SidecarRootState(string autoRoot)
|
||||
{
|
||||
_autoRoot = autoRoot;
|
||||
_currentRoot = autoRoot;
|
||||
_isCustom = false;
|
||||
}
|
||||
|
||||
public (string Root, bool IsCustom) Get()
|
||||
{
|
||||
lock (_sync)
|
||||
@ -272,5 +260,3 @@ sealed class CommandEnvelope
|
||||
public string? Tag { get; set; }
|
||||
public JsonElement? Payload { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,4 +3,5 @@
|
||||
<Project Path="Journal.Sidecar/Journal.Sidecar.csproj" />
|
||||
<Project Path="Journal.SmokeTests/Journal.SmokeTests.csproj" />
|
||||
<Project Path="Journal.DevTool/Journal.DevTool.csproj" />
|
||||
<Project Path="Journal.WebGateway/Journal.WebGateway.csproj" />
|
||||
</Solution>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user