Skip to content

Commit e34f1c7

Browse files
authored
feat: add config generator module with pipeline architecture (#73)
Add a "Config Generator" page that auto-analyzes .csproj files and generates generalupdate.manifest.json for the GeneralUpdate framework. Features: - Pipeline architecture (IConfigStep) — pluggable, shared by GUI and CLI - CsprojParseStep: extracts AssemblyName from .csproj XML - SemverValidateStep: enforces semver.org version format - ManifestBuildStep / FileEmitStep: assemble and write manifest.json - SamplePublisherService: dotnet publish + directory scaffolding - ConfigViewModel/ConfigView: dual file picker + editable field form - SemverValidator: shared validation used across all 5 modules - DialogHelper: post-generation confirmation popup - Checkboxes to auto-open output directories after generation - All version defaults changed from 4-part to semver (1.0.0.0 → 1.0.0) - LocalUpdateServer: accept both "version" and "currentVersion" in JSON
1 parent 8aae538 commit e34f1c7

30 files changed

Lines changed: 1009 additions & 6 deletions

src/Models/ConfigGeneratorModel.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
3+
namespace GeneralUpdate.Tools.Models;
4+
5+
public partial class ConfigGeneratorModel : ObservableObject
6+
{
7+
// ── File picker paths ──
8+
[ObservableProperty] private string _clientPath = "";
9+
[ObservableProperty] private string _upgradePath = "";
10+
11+
// ── Analysis state ──
12+
[ObservableProperty] private bool _isAnalyzed;
13+
[ObservableProperty] private bool _isAnalyzing;
14+
15+
// ── Editable fields (auto-filled + user input) ──
16+
[ObservableProperty] private string _mainAppName = "";
17+
[ObservableProperty] private string _clientVersion = "";
18+
[ObservableProperty] private string _updateAppName = "Update.exe";
19+
[ObservableProperty] private string _upgradeClientVersion = "";
20+
[ObservableProperty] private string _appType = "Client";
21+
[ObservableProperty] private string _productId = "";
22+
[ObservableProperty] private string _updatePath = "update/";
23+
24+
// ── Info text ──
25+
[ObservableProperty] private string _statusText = "";
26+
[ObservableProperty] private string _clientFramework = "";
27+
[ObservableProperty] private string _upgradeFramework = "";
28+
29+
// ── Checkboxes ──
30+
[ObservableProperty] private bool _openManifestDir = true;
31+
[ObservableProperty] private bool _openSampleDir = true;
32+
33+
// ── Generated JSON preview ──
34+
[ObservableProperty] private string _previewJson = "";
35+
}

src/Models/CsprojInfo.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace GeneralUpdate.Tools.Models;
2+
3+
public class CsprojInfo
4+
{
5+
public string ProjectName { get; set; } = "";
6+
public string AssemblyName { get; set; } = "";
7+
public string OutputType { get; set; } = "";
8+
public string TargetFramework { get; set; } = "";
9+
public string CsprojPath { get; set; } = "";
10+
public string ProjectDir { get; set; } = "";
11+
}

src/Models/ExtensionConfigModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace GeneralUpdate.Tools.Models;
55
public partial class ExtensionConfigModel : ObservableObject
66
{
77
[ObservableProperty] private string _name = "";
8-
[ObservableProperty] private string _version = "1.0.0.0";
8+
[ObservableProperty] private string _version = "1.0.0";
99
[ObservableProperty] private string _description = "";
1010
[ObservableProperty] private string _extensionDirectory = "";
1111
[ObservableProperty] private string _exportPath = "";

src/Models/ManifestModel.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace GeneralUpdate.Tools.Models;
2+
3+
public class ManifestModel
4+
{
5+
public string MainAppName { get; set; } = "";
6+
public string ClientVersion { get; set; } = "";
7+
public string AppType { get; set; } = "Client";
8+
public string UpdateAppName { get; set; } = "Update.exe";
9+
public string UpgradeClientVersion { get; set; } = "";
10+
public string ProductId { get; set; } = "";
11+
public string UpdatePath { get; set; } = "update/";
12+
}

src/Models/OSSConfigModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public partial class OSSConfigModel : ObservableObject
66
{
77
[ObservableProperty] private string _packetName = "Packet";
88
[ObservableProperty] private string _hash = "";
9-
[ObservableProperty] private string _version = "1.0.0.0";
9+
[ObservableProperty] private string _version = "1.0.0";
1010
[ObservableProperty] private string _url = "http://127.0.0.1";
1111
[ObservableProperty] private string _releaseDate = "";
1212
}

src/Models/PatchConfigModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public partial class PatchConfigModel : ObservableObject
77
[ObservableProperty] private string _oldDirectory = "";
88
[ObservableProperty] private string _newDirectory = "";
99
[ObservableProperty] private string _packageName = "";
10-
[ObservableProperty] private string _version = "1.0.0.0";
10+
[ObservableProperty] private string _version = "1.0.0";
1111
[ObservableProperty] private string _format = ".zip";
1212
[ObservableProperty] private string _outputPath = "";
1313
}

src/Models/SimulateConfigModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public partial class SimulateConfigModel : ObservableObject
99
{
1010
[ObservableProperty] private string _appDirectory = string.Empty;
1111
[ObservableProperty] private string _patchFilePath = string.Empty;
12-
[ObservableProperty] private string _currentVersion = "1.0.0.0";
13-
[ObservableProperty] private string _targetVersion = "2.0.0.0";
12+
[ObservableProperty] private string _currentVersion = "1.0.0";
13+
[ObservableProperty] private string _targetVersion = "2.0.0";
1414
[ObservableProperty] private int _platform = 1;
1515
[ObservableProperty] private int _appType = 1;
1616
[ObservableProperty] private string _appSecretKey = "dfeb5833-975e-4afb-88f1-6278ee9aeff6";

src/Pipeline/IConfigStep.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
4+
namespace GeneralUpdate.Tools.Pipeline;
5+
6+
public interface IConfigStep
7+
{
8+
string Name { get; }
9+
Task<PipelineContext> ExecuteAsync(PipelineContext ctx, CancellationToken ct);
10+
}

src/Pipeline/PipelineContext.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Collections.Generic;
2+
using GeneralUpdate.Tools.Models;
3+
4+
namespace GeneralUpdate.Tools.Pipeline;
5+
6+
public class PipelineContext
7+
{
8+
public string ClientPath { get; set; } = "";
9+
public string? UpgradePath { get; set; }
10+
public CsprojInfo? ClientInfo { get; set; }
11+
public CsprojInfo? UpgradeInfo { get; set; }
12+
public ManifestModel Manifest { get; set; } = new();
13+
public List<string> Errors { get; } = new();
14+
public bool IsCli { get; set; }
15+
public bool Force { get; set; }
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Collections.Generic;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
5+
namespace GeneralUpdate.Tools.Pipeline;
6+
7+
public class PipelineOrchestrator
8+
{
9+
private readonly List<IConfigStep> _steps = new();
10+
11+
public PipelineOrchestrator AddStep(IConfigStep step)
12+
{
13+
_steps.Add(step);
14+
return this;
15+
}
16+
17+
public async Task<PipelineContext> RunAsync(PipelineContext ctx, CancellationToken ct = default)
18+
{
19+
foreach (var step in _steps)
20+
{
21+
ctx = await step.ExecuteAsync(ctx, ct);
22+
}
23+
return ctx;
24+
}
25+
}

0 commit comments

Comments
 (0)