Skip to content

Commit

Permalink
starting sc tool
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatandrei committed Oct 11, 2024
1 parent f62dda2 commit ad15795
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 18 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: 3.1.301
dotnet-version: 8.0.x
- name: Build
run: |
cd src
Expand All @@ -29,20 +29,20 @@ jobs:
dotnet publish -c Release --no-restore -r linux-x64 -p:PublishTrimmed=true --self-contained -o linuxx64
dotnet publish -c Release --no-restore -r win-x64 -p:PublishTrimmed=true --self-contained -o winx64
dotnet pack -c Release --include-source --include-symbols -o toolpack
- uses: actions/upload-artifact@v2
with:
name: winx64
path: src/SideCarCLI/SideCarCLI/winx64/
# - uses: actions/upload-artifact@v2
# with:
# name: winx64
# path: src/SideCarCLI/SideCarCLI/winx64/

- uses: actions/upload-artifact@v2
with:
name: linuxx64
path: src/SideCarCLI/SideCarCLI/linuxx64/
# - uses: actions/upload-artifact@v2
# with:
# name: linuxx64
# path: src/SideCarCLI/SideCarCLI/linuxx64/

- uses: actions/upload-artifact@v2
with:
name: dotnetTool
path: src/SideCarCLI/SideCarCLI/toolpack/
# - uses: actions/upload-artifact@v2
# with:
# name: dotnetTool
# path: src/SideCarCLI/SideCarCLI/toolpack/

#- name: Test
# run: dotnet test --no-restore --verbosity normal
24 changes: 24 additions & 0 deletions src/SideCarCLI/SC_Interfaces/IRunWatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace SC_Interfaces;
public interface IRunWatcherDetect
{
public string Folder { get; set; }
public IRunWatcher[] DetectVersions();
}

public interface IRunWatcher
{
public int Version { get; }
public Task<int> Run(string[] args);

}

public interface IRunWatcherV1: IRunWatcher
{
public int DelaySeconds { get; set; }

}

public interface IRunWatcherFile
{
public Version DetectFile();
}
9 changes: 9 additions & 0 deletions src/SideCarCLI/SC_Interfaces/SC_Interfaces.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
32 changes: 32 additions & 0 deletions src/SideCarCLI/SC_Tool/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.Extensions.Logging.Abstractions;

public class Program
{
public static async Task<int> Main(string[] args)
{
var services = CreateServices();
var watcher = services.GetRequiredService<IRunWatcherDetect>();
ArgumentNullException.ThrowIfNull(watcher, nameof(watcher));
watcher.Folder = Environment.CurrentDirectory;
var logger= services.GetRequiredService<ILogger<Program>>();
var versions = await watcher.DetectVersions();
if (versions.Length == 0)
{
logger.LogError("No versions detected");
throw new InvalidOperationException("No versions detected");
}
var lastVersion = versions.OrderByDescending(v => v.Version).First();
logger.LogInformation($"Running version {lastVersion.Version}");
return await lastVersion.Run(args);

}
private static ServiceProvider CreateServices()
{
var serviceProvider = new ServiceCollection()
//.AddSingleton<IRunWatcher>((IRunWatcher)null)
//.AddSingleton<ILogger>(new NullLogger())
.BuildServiceProvider();

return serviceProvider;
}
}
21 changes: 21 additions & 0 deletions src/SideCarCLI/SC_Tool/SC_Tool.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SC_Interfaces\SC_Interfaces.csproj" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions src/SideCarCLI/SC_Tool/globals.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
global using SC_Interfaces;
global using Microsoft.Extensions.DependencyInjection;
global using System;
global using Microsoft.Extensions.Logging;
18 changes: 15 additions & 3 deletions src/SideCarCLI/SideCarCLI.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30523.141
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SideCarCLI", "SideCarCLI\SideCarCLI.csproj", "{8D1D2CEC-3F82-4691-BDF1-981C999E2653}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SideCarCLI", "SideCarCLI\SideCarCLI.csproj", "{8D1D2CEC-3F82-4691-BDF1-981C999E2653}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SC_Interfaces", "SC_Interfaces\SC_Interfaces.csproj", "{12DDD1BC-9605-4384-9964-93410668CA98}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SC_Tool", "SC_Tool\SC_Tool.csproj", "{652096DC-5CF1-4263-A947-9A2A82B0C966}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +19,14 @@ Global
{8D1D2CEC-3F82-4691-BDF1-981C999E2653}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D1D2CEC-3F82-4691-BDF1-981C999E2653}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D1D2CEC-3F82-4691-BDF1-981C999E2653}.Release|Any CPU.Build.0 = Release|Any CPU
{12DDD1BC-9605-4384-9964-93410668CA98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12DDD1BC-9605-4384-9964-93410668CA98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12DDD1BC-9605-4384-9964-93410668CA98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12DDD1BC-9605-4384-9964-93410668CA98}.Release|Any CPU.Build.0 = Release|Any CPU
{652096DC-5CF1-4263-A947-9A2A82B0C966}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{652096DC-5CF1-4263-A947-9A2A82B0C966}.Debug|Any CPU.Build.0 = Debug|Any CPU
{652096DC-5CF1-4263-A947-9A2A82B0C966}.Release|Any CPU.ActiveCfg = Release|Any CPU
{652096DC-5CF1-4263-A947-9A2A82B0C966}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion src/SideCarCLI/SideCarCLI/SideCarCLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
<PackAsTool>true</PackAsTool>
<ToolCommandName>sidecarcli</ToolCommandName>
Expand Down

0 comments on commit ad15795

Please sign in to comment.