Skip to content

Commit

Permalink
Split the package, added Models and DI package
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Nov 26, 2023
1 parent fb6a788 commit 3da6996
Show file tree
Hide file tree
Showing 34 changed files with 1,110 additions and 767 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish-native-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
with:
fetch-depth: 0

- name: Setup .NET 7
- name: Setup .NET 8
uses: actions/setup-dotnet@master
with:
dotnet-version: 7.x.x
dotnet-version: 8.x.x

- run: dotnet publish -r win-x64 --self-contained -c Debug src/Bannerlord.ModuleManager.Native
- run: dotnet publish -r win-x64 --self-contained -c Release src/Bannerlord.ModuleManager.Native
Expand Down
17 changes: 6 additions & 11 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,17 @@ jobs:
- uses: actions/[email protected]
with:
fetch-depth: 0

- name: Setup .NET 6
uses: actions/setup-dotnet@master
with:
dotnet-version: 6.x.x

- name: Setup .NET 7

- name: Setup .NET 8
uses: actions/setup-dotnet@master
with:
dotnet-version: 7.x.x
dotnet-version: 8.x.x

- run: dotnet pack -c Release src/Bannerlord.ModuleManager -p:VersionOverride=$(git rev-list --no-merges --count master) -p:PackAsSource=false -o ./packages
- run: dotnet pack -c Release src/Bannerlord.ModuleManager -p:VersionOverride=$(git rev-list --no-merges --count master) -o ./packages

- run: dotnet pack -c Release src/Bannerlord.ModuleManager -p:VersionOverride=$(git rev-list --no-merges --count master) -p:PackAsSource=true -o ./packages
- run: dotnet pack -c Release src/Bannerlord.ModuleManager.Source -p:VersionOverride=$(git rev-list --no-merges --count master) -o ./packages

- run: dotnet pack -c Release src/Bannerlord.ModuleManager.Native -p:VersionOverride=$(git rev-list --no-merges --count master) -o ./packages
- run: dotnet pack -c Release src/Bannerlord.ModuleManager.DependencyInjection -p:VersionOverride=$(git rev-list --no-merges --count master) -o ./packages

- name: Push to NuGet
run: dotnet nuget push "./packages/*.nupkg" -k ${{secrets.NUGET_API_KEY}} -s https://www.nuget.org --skip-duplicate
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
with:
fetch-depth: 0

- name: Setup .NET 7
- name: Setup .NET 8
uses: actions/setup-dotnet@master
with:
dotnet-version: 7.x.x
dotnet-version: 8.x.x

- uses: actions/[email protected]
with:
Expand Down
7 changes: 6 additions & 1 deletion build/common.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<!--EXTERNAL_PROPERTIES: GITHUB_ACTIONS-->
<Project>

<PropertyGroup>
<VersionOverride>0</VersionOverride>
<Version>5.0.$(VersionOverride)</Version>
</PropertyGroup>

<!--GitHub Actions-->
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
Expand All @@ -19,7 +24,7 @@
</PropertyGroup>
<!--SorceLink-->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>
<!--CI Builds-->
<ItemGroup Condition="$(TargetFramework) == 'net472' AND $(OS) != 'Windows_NT'">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>10.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<!--NuGet Package-->
<PropertyGroup>
<Authors>BUTR</Authors>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>Butter.png</PackageIcon>
<PackageProjectUrl>https://github.com/BUTR/Bannerlord.ModuleManager</PackageProjectUrl>
<RepositoryUrl>https://github.com/BUTR/Bannerlord.ModuleManager.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>

<PropertyGroup>
<PackageId>Bannerlord.ModuleManager.DependencyInjection</PackageId>
<PackageDescription>DI for managing Mount &amp; Blade 2: Bannerlord Module dependencies.</PackageDescription>
<Title>Bannerlord ModuleManager DependencyInjection</Title>
</PropertyGroup>

<ItemGroup>
<None Include="../../resources/Butter.png" Pack="true" PackagePath="" />
</ItemGroup>
<!--NuGet Package-->

<ItemGroup>
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Bannerlord.ModuleManager\Bannerlord.ModuleManager.csproj" />
</ItemGroup>

</Project>
32 changes: 32 additions & 0 deletions src/Bannerlord.ModuleManager.DependencyInjection/IModuleManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;

namespace Bannerlord.ModuleManager.DependencyInjection;

public interface IModuleManager
{
IList<ModuleInfoExtended> Sort(IReadOnlyCollection<ModuleInfoExtended> source);
IList<ModuleInfoExtended> Sort(IReadOnlyCollection<ModuleInfoExtended> source, ModuleSorterOptions options);

bool AreDependenciesPresent(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module);

IList<ModuleInfoExtended> GetDependencies(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module);
IList<ModuleInfoExtended> GetDependencies(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module, ModuleSorterOptions options);

IList<ModuleIssue> ValidateModule(IReadOnlyList<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider);
IList<ModuleIssue> ValidateLoadOrder(IReadOnlyList<ModuleInfoExtended> modules, ModuleInfoExtended targetModule);

void EnableModule(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider);
void DisableModule(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider);

ModuleInfoExtended? GetModuleInfo(string xml);

SubModuleInfoExtended? GetSubModuleInfo(string xml);

ApplicationVersion ParseApplicationVersion(string value);
int CompareVersions(ApplicationVersion x, ApplicationVersion y);

IList<DependentModuleMetadata> GetDependenciesAll(ModuleInfoExtended moduleInfoExtended);
IList<DependentModuleMetadata> GetDependenciesLoadBeforeThis(ModuleInfoExtended moduleInfoExtended);
IList<DependentModuleMetadata> GetDependenciesLoadAfterThis(ModuleInfoExtended moduleInfoExtended);
IList<DependentModuleMetadata> GetDependenciesIncompatibles(ModuleInfoExtended moduleInfoExtended);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Bannerlord.ModuleManager.DependencyInjection;

public interface IModuleManagerModuleViewModel
{
bool GetSelected(string moduleId);
void SetSelected(string moduleId, bool value);

bool GetDisabled(string moduleId);
void SetDisabled(string moduleId, bool value);
}
74 changes: 74 additions & 0 deletions src/Bannerlord.ModuleManager.DependencyInjection/ModuleManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml;

namespace Bannerlord.ModuleManager.DependencyInjection;

public class ModuleManager : IModuleManager
{
public IList<ModuleInfoExtended> Sort(IReadOnlyCollection<ModuleInfoExtended> source) =>
ModuleSorter.Sort(source);
public IList<ModuleInfoExtended> Sort(IReadOnlyCollection<ModuleInfoExtended> source, ModuleSorterOptions options) =>
ModuleSorter.Sort(source, options);

public bool AreDependenciesPresent(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module) =>
ModuleUtilities.AreDependenciesPresent(modules, module);

public IList<ModuleInfoExtended> GetDependencies(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module) =>
ModuleUtilities.GetDependencies(modules, module).ToList();
public IList<ModuleInfoExtended> GetDependencies(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended module, ModuleSorterOptions options) =>
ModuleUtilities.GetDependencies(modules, module, options).ToList();


public IList<ModuleIssue> ValidateModule(IReadOnlyList<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider) =>
ModuleUtilities.ValidateModule(modules, targetModule, x => provider.GetSelected(x.Id)).ToList();

public IList<ModuleIssue> ValidateLoadOrder(IReadOnlyList<ModuleInfoExtended> modules, ModuleInfoExtended targetModule) =>
ModuleUtilities.ValidateLoadOrder(modules, targetModule).ToList();

public void EnableModule(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider) =>
ModuleUtilities.EnableModule(modules, targetModule, x => provider.GetSelected(x.Id), (x, y) => provider.SetSelected(x.Id, y), x => provider.GetDisabled(x.Id), (x, y) => provider.SetDisabled(x.Id, y));

public void DisableModule(IReadOnlyCollection<ModuleInfoExtended> modules, ModuleInfoExtended targetModule, IModuleManagerModuleViewModel provider) =>
ModuleUtilities.DisableModule(modules, targetModule, x => provider.GetSelected(x.Id), (x, y) => provider.SetSelected(x.Id, y), x => provider.GetDisabled(x.Id), (x, y) => provider.SetDisabled(x.Id, y));

public ModuleInfoExtended? GetModuleInfo(string xml)
{
try
{
var doc = new XmlDocument();
doc.LoadXml(xml);
return ModuleInfoExtended.FromXml(doc);
}
catch { return null; }
}

public SubModuleInfoExtended? GetSubModuleInfo(string xml)
{
try
{
var doc = new XmlDocument();
doc.LoadXml(xml);
return SubModuleInfoExtended.FromXml(doc);
}
catch { return null; }
}

public ApplicationVersion ParseApplicationVersion(string value) =>
ApplicationVersion.TryParse(value, out var x) ? x : ApplicationVersion.Empty;

public int CompareVersions(ApplicationVersion x, ApplicationVersion y) =>
new ApplicationVersionComparer().Compare(x, y);

public IList<DependentModuleMetadata> GetDependenciesAll(ModuleInfoExtended moduleInfoExtended) =>
moduleInfoExtended.DependenciesAllDistinct().ToArray();

public IList<DependentModuleMetadata> GetDependenciesLoadBeforeThis(ModuleInfoExtended moduleInfoExtended) =>
moduleInfoExtended.DependenciesLoadBeforeThisDistinct().ToArray();

public IList<DependentModuleMetadata> GetDependenciesLoadAfterThis(ModuleInfoExtended moduleInfoExtended) =>
moduleInfoExtended.DependenciesLoadAfterThisDistinct().ToArray();

public IList<DependentModuleMetadata> GetDependenciesIncompatibles(ModuleInfoExtended moduleInfoExtended) =>
moduleInfoExtended.DependenciesIncompatiblesDistinct().ToArray();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNetJS" Version="0.23.1" />
<PackageReference Include="DotNetJS" Version="0.23.4" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 3da6996

Please sign in to comment.