Skip to content

Commit 9f4c49e

Browse files
stidsborgclaude
andcommitted
Simplify CLI after source generator removal
Remove source generator publishing and NuGet package modification code since source generators are no longer used. CLI now just updates versions and packs projects, matching the ResilientFunctions CLI style. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 57e58ec commit 9f4c49e

2 files changed

Lines changed: 19 additions & 57 deletions

File tree

Cli/PathResolver.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ public static RepoAndDotnetPaths ResolvePaths(OperatingSystem operatingSystem)
66
{
77
return operatingSystem switch
88
{
9-
OperatingSystem.Windows =>
9+
OperatingSystem.Windows =>
1010
new RepoAndDotnetPaths(
1111
RepoPath: "../",
1212
DotnetPath: @"C:\Program Files\dotnet\dotnet.exe"
1313
),
14-
OperatingSystem.Linux =>
14+
OperatingSystem.Linux =>
1515
new RepoAndDotnetPaths(
16-
RepoPath: $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Repos/Cleipnir.Flows",
16+
RepoPath: "../",
1717
DotnetPath: "/usr/bin/dotnet"
1818
),
19-
OperatingSystem.MacOs =>
19+
OperatingSystem.MacOs =>
2020
new RepoAndDotnetPaths(
21-
RepoPath: $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Repos/Cleipnir.Flows",
21+
RepoPath: "../",
2222
DotnetPath: "/usr/local/share/dotnet/dotnet"
2323
),
2424
_ => throw new ArgumentOutOfRangeException(nameof(operatingSystem), operatingSystem, null)

Cli/Program.cs

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,48 @@
1-
using System.Diagnostics;
2-
using System.IO.Compression;
3-
using System.Text.RegularExpressions;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.IO;
5+
using System.Linq;
46

57
namespace Cleipnir.Flows.Cli;
68

79
internal static class Program
810
{
911
private static int Main(string[] args)
1012
{
11-
var (repoPath, dotnetPath) = PathResolver.ResolvePaths(OperatingSystem.Windows);
13+
var (repoPath, dotnetPath) = PathResolver.ResolvePaths(OperatingSystem.MacOs);
14+
1215
var root = repoPath;
1316
var output = Path.GetFullPath("./nugets");
1417

1518
if (Directory.Exists(output))
1619
Directory.Delete(output, recursive: true);
17-
20+
1821
Directory.CreateDirectory(output);
1922

2023
Console.WriteLine($"Root path: {root}");
2124
Console.WriteLine($"Output path: {output}");
22-
25+
2326
Console.WriteLine("Processing projects: ");
24-
25-
//update version
27+
2628
foreach (var projectPath in FindAllProjects(root).Where(IsPackageProject))
2729
{
30+
Console.WriteLine("---------------------------------------------------------");
2831
Console.WriteLine("Updating package version: " + LeafFolderName(projectPath));
2932
Console.WriteLine("Project path: " + Path.GetDirectoryName(projectPath)!);
3033
UpdatePackageVersion(projectPath);
34+
Console.WriteLine();
3135
}
3236

33-
//compile & publish source generator
34-
PublishSourceGenerator($"{root}/SourceGeneration/Cleipnir.Flows.SourceGenerator", output, dotnetPath);
35-
36-
//pack
3737
foreach (var projectPath in FindAllProjects(root).Where(IsPackageProject))
3838
{
39+
Console.WriteLine("---------------------------------------------------------");
3940
Console.WriteLine("Packing nuget package: " + LeafFolderName(projectPath));
4041
Console.WriteLine("Project path: " + Path.GetDirectoryName(projectPath)!);
4142
PackProject(Path.GetDirectoryName(projectPath)!, output, dotnetPath);
43+
Console.WriteLine();
4244
}
4345

44-
//add source generator to core flow nuget packages
45-
var nugetPackages = Directory.GetFiles(output, "*.nupkg");
46-
var coreProjectNugetPackage = nugetPackages
47-
.Single(nugetPackage => Regex.IsMatch(nugetPackage, @"Cleipnir.Flows.\d*.\d*.\d*.nupkg"));
48-
AddSourceGeneratorToNugetPackage(
49-
coreProjectNugetPackage,
50-
$"{output}/Cleipnir.Flows.SourceGenerator.dll"
51-
);
52-
53-
foreach (var outputFile in Directory.GetFiles(output))
54-
if (!outputFile.EndsWith(".nupkg") && !outputFile.EndsWith(".snupkg"))
55-
File.Delete(outputFile);
56-
5746
return 0;
5847
}
5948

@@ -108,34 +97,7 @@ private static void PackProject(string projectPath, string outputPath, string do
10897

10998
p.WaitForExit();
11099
}
111-
112-
private static void PublishSourceGenerator(string sourceGeneratorProjectPath, string outputPath, string dotnetPath)
113-
{
114-
//dotnet publish -c Release -o Output
115-
var p = new Process();
116-
p.StartInfo.RedirectStandardInput = true;
117-
p.StartInfo.RedirectStandardOutput = true;
118-
p.StartInfo.RedirectStandardError = true;
119-
p.StartInfo.UseShellExecute = false;
120-
p.StartInfo.FileName = dotnetPath;
121-
p.StartInfo.WorkingDirectory = sourceGeneratorProjectPath;
122-
p.StartInfo.Arguments = $"dotnet publish -c Release -o {outputPath}";
123-
p.Start();
124-
125-
while (!p.StandardOutput.EndOfStream)
126-
Console.WriteLine(p.StandardOutput.ReadLine());
127-
128-
p.WaitForExit();
129-
}
130100

131101
private static string LeafFolderName(string path)
132102
=> Path.GetDirectoryName(path)!.Split('/').Last();
133-
134-
private static void AddSourceGeneratorToNugetPackage(string nugetPath, string sourceGeneratorDllPath)
135-
{
136-
using var zipArchive = ZipFile.Open(nugetPath, ZipArchiveMode.Update);
137-
138-
var fileInfo = new FileInfo(sourceGeneratorDllPath);
139-
zipArchive.CreateEntryFromFile(sourceGeneratorDllPath, $"analyzers/dotnet/cs/{fileInfo.Name}");
140-
}
141103
}

0 commit comments

Comments
 (0)