From 391e12c5f6d147afb72f3f470dc0e25edaf00526 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Tue, 21 Jun 2022 20:10:44 -0500 Subject: [PATCH] refactor: Move AppPaths to TrashLib --- src/Recyclarr.Gui/CompositionRoot.cs | 9 +++++++++ src/Recyclarr.Gui/Pages/_Host.cshtml | 1 + src/Recyclarr.Gui/Pages/_Layout.cshtml | 1 + src/Recyclarr/Command/BaseCommand.cs | 2 +- src/Recyclarr/Command/CreateConfigCommand.cs | 2 +- src/Recyclarr/Command/Helpers/CacheStoragePath.cs | 2 +- src/Recyclarr/ConfigurationFinder.cs | 1 + src/Recyclarr/Logging/LogJanitor.cs | 2 +- src/Recyclarr/Logging/LoggerFactory.cs | 4 ++-- .../Migration/Steps/MigrateTrashUpdaterAppDataDir.cs | 2 +- src/TrashLib/AppPaths.cs | 1 + src/TrashLib/Config/Settings/SettingsPersister.cs | 2 ++ .../Guide/LocalRepoCustomFormatJsonParser.cs | 1 + .../RadarrQualityDefinitionGuideParser.cs | 1 + src/TrashLib/Repo/RepoUpdater.cs | 1 + .../SonarrQualityDefinitionGuideParser.cs | 1 + .../Guide/LocalRepoReleaseProfileJsonParser.cs | 1 + src/TrashLib/{ => Startup}/IAppPaths.cs | 2 +- 18 files changed, 28 insertions(+), 8 deletions(-) rename src/TrashLib/{ => Startup}/IAppPaths.cs (91%) diff --git a/src/Recyclarr.Gui/CompositionRoot.cs b/src/Recyclarr.Gui/CompositionRoot.cs index 99e261ce..9ded8907 100644 --- a/src/Recyclarr.Gui/CompositionRoot.cs +++ b/src/Recyclarr.Gui/CompositionRoot.cs @@ -1,4 +1,7 @@ +using System.IO.Abstractions; using Autofac; +using Common; +using TrashLib.Startup; namespace Recyclarr.Gui; @@ -6,6 +9,12 @@ public static class CompositionRoot { public static void Setup(ContainerBuilder builder) { + builder.RegisterModule(); + builder.RegisterType().As(); + builder.RegisterType(); + builder.Register(c => c.Resolve().CreateAppPaths()) + .As() + .SingleInstance(); } } diff --git a/src/Recyclarr.Gui/Pages/_Host.cshtml b/src/Recyclarr.Gui/Pages/_Host.cshtml index 6d282722..44a361fe 100644 --- a/src/Recyclarr.Gui/Pages/_Host.cshtml +++ b/src/Recyclarr.Gui/Pages/_Host.cshtml @@ -1,4 +1,5 @@ @page "/" +@using Microsoft.AspNetCore.Mvc.TagHelpers @namespace Recyclarr.Gui.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ diff --git a/src/Recyclarr.Gui/Pages/_Layout.cshtml b/src/Recyclarr.Gui/Pages/_Layout.cshtml index 5d920af8..dbbc7528 100644 --- a/src/Recyclarr.Gui/Pages/_Layout.cshtml +++ b/src/Recyclarr.Gui/Pages/_Layout.cshtml @@ -1,4 +1,5 @@ @using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Mvc.TagHelpers @namespace Recyclarr.Gui.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/Recyclarr/Command/BaseCommand.cs b/src/Recyclarr/Command/BaseCommand.cs index 620a0048..ac7dcc36 100644 --- a/src/Recyclarr/Command/BaseCommand.cs +++ b/src/Recyclarr/Command/BaseCommand.cs @@ -6,7 +6,7 @@ using JetBrains.Annotations; using Recyclarr.Logging; using Serilog; using Serilog.Events; -using TrashLib; +using TrashLib.Startup; namespace Recyclarr.Command; diff --git a/src/Recyclarr/Command/CreateConfigCommand.cs b/src/Recyclarr/Command/CreateConfigCommand.cs index c02ae6fe..e6901d77 100644 --- a/src/Recyclarr/Command/CreateConfigCommand.cs +++ b/src/Recyclarr/Command/CreateConfigCommand.cs @@ -4,7 +4,7 @@ using CliFx.Exceptions; using Common; using JetBrains.Annotations; using Serilog; -using TrashLib; +using TrashLib.Startup; namespace Recyclarr.Command; diff --git a/src/Recyclarr/Command/Helpers/CacheStoragePath.cs b/src/Recyclarr/Command/Helpers/CacheStoragePath.cs index 3e6b211c..87d10403 100644 --- a/src/Recyclarr/Command/Helpers/CacheStoragePath.cs +++ b/src/Recyclarr/Command/Helpers/CacheStoragePath.cs @@ -1,6 +1,6 @@ using System.IO.Abstractions; -using TrashLib; using TrashLib.Cache; +using TrashLib.Startup; namespace Recyclarr.Command.Helpers; diff --git a/src/Recyclarr/ConfigurationFinder.cs b/src/Recyclarr/ConfigurationFinder.cs index f2d473c7..696b5add 100644 --- a/src/Recyclarr/ConfigurationFinder.cs +++ b/src/Recyclarr/ConfigurationFinder.cs @@ -2,6 +2,7 @@ using System.IO.Abstractions; using Common; using Serilog; using TrashLib; +using TrashLib.Startup; namespace Recyclarr; diff --git a/src/Recyclarr/Logging/LogJanitor.cs b/src/Recyclarr/Logging/LogJanitor.cs index b074233e..10cce014 100644 --- a/src/Recyclarr/Logging/LogJanitor.cs +++ b/src/Recyclarr/Logging/LogJanitor.cs @@ -1,4 +1,4 @@ -using TrashLib; +using TrashLib.Startup; namespace Recyclarr.Logging; diff --git a/src/Recyclarr/Logging/LoggerFactory.cs b/src/Recyclarr/Logging/LoggerFactory.cs index ec9a8403..298907d2 100644 --- a/src/Recyclarr/Logging/LoggerFactory.cs +++ b/src/Recyclarr/Logging/LoggerFactory.cs @@ -1,11 +1,11 @@ using System.IO.Abstractions; using Serilog; using Serilog.Events; -using TrashLib; +using TrashLib.Startup; namespace Recyclarr.Logging; -public class LoggerFactory +internal class LoggerFactory { private readonly IAppPaths _paths; diff --git a/src/Recyclarr/Migration/Steps/MigrateTrashUpdaterAppDataDir.cs b/src/Recyclarr/Migration/Steps/MigrateTrashUpdaterAppDataDir.cs index 223d74c5..b08bf052 100644 --- a/src/Recyclarr/Migration/Steps/MigrateTrashUpdaterAppDataDir.cs +++ b/src/Recyclarr/Migration/Steps/MigrateTrashUpdaterAppDataDir.cs @@ -2,7 +2,7 @@ using System.IO.Abstractions; using CliFx.Infrastructure; using Common.Extensions; using JetBrains.Annotations; -using TrashLib; +using TrashLib.Startup; namespace Recyclarr.Migration.Steps; diff --git a/src/TrashLib/AppPaths.cs b/src/TrashLib/AppPaths.cs index 374fb463..b63cc007 100644 --- a/src/TrashLib/AppPaths.cs +++ b/src/TrashLib/AppPaths.cs @@ -1,4 +1,5 @@ using System.IO.Abstractions; +using TrashLib.Startup; namespace TrashLib; diff --git a/src/TrashLib/Config/Settings/SettingsPersister.cs b/src/TrashLib/Config/Settings/SettingsPersister.cs index 34649d9b..e0d82529 100644 --- a/src/TrashLib/Config/Settings/SettingsPersister.cs +++ b/src/TrashLib/Config/Settings/SettingsPersister.cs @@ -1,3 +1,5 @@ +using TrashLib.Startup; + namespace TrashLib.Config.Settings; public class SettingsPersister : ISettingsPersister diff --git a/src/TrashLib/Radarr/CustomFormat/Guide/LocalRepoCustomFormatJsonParser.cs b/src/TrashLib/Radarr/CustomFormat/Guide/LocalRepoCustomFormatJsonParser.cs index 4d9f4b8e..cfa824cd 100644 --- a/src/TrashLib/Radarr/CustomFormat/Guide/LocalRepoCustomFormatJsonParser.cs +++ b/src/TrashLib/Radarr/CustomFormat/Guide/LocalRepoCustomFormatJsonParser.cs @@ -6,6 +6,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Serilog; using TrashLib.Radarr.CustomFormat.Models; +using TrashLib.Startup; namespace TrashLib.Radarr.CustomFormat.Guide; diff --git a/src/TrashLib/Radarr/QualityDefinition/RadarrQualityDefinitionGuideParser.cs b/src/TrashLib/Radarr/QualityDefinition/RadarrQualityDefinitionGuideParser.cs index f45725e3..22c426a2 100644 --- a/src/TrashLib/Radarr/QualityDefinition/RadarrQualityDefinitionGuideParser.cs +++ b/src/TrashLib/Radarr/QualityDefinition/RadarrQualityDefinitionGuideParser.cs @@ -1,6 +1,7 @@ using System.IO.Abstractions; using System.Text.RegularExpressions; using Common.Extensions; +using TrashLib.Startup; namespace TrashLib.Radarr.QualityDefinition; diff --git a/src/TrashLib/Repo/RepoUpdater.cs b/src/TrashLib/Repo/RepoUpdater.cs index 56493ddf..b0bb692a 100644 --- a/src/TrashLib/Repo/RepoUpdater.cs +++ b/src/TrashLib/Repo/RepoUpdater.cs @@ -3,6 +3,7 @@ using Common; using LibGit2Sharp; using Serilog; using TrashLib.Config.Settings; +using TrashLib.Startup; using VersionControl; namespace TrashLib.Repo; diff --git a/src/TrashLib/Sonarr/QualityDefinition/SonarrQualityDefinitionGuideParser.cs b/src/TrashLib/Sonarr/QualityDefinition/SonarrQualityDefinitionGuideParser.cs index 7d5a6f04..7a602ab5 100644 --- a/src/TrashLib/Sonarr/QualityDefinition/SonarrQualityDefinitionGuideParser.cs +++ b/src/TrashLib/Sonarr/QualityDefinition/SonarrQualityDefinitionGuideParser.cs @@ -1,6 +1,7 @@ using System.IO.Abstractions; using System.Text.RegularExpressions; using Common.Extensions; +using TrashLib.Startup; namespace TrashLib.Sonarr.QualityDefinition; diff --git a/src/TrashLib/Sonarr/ReleaseProfile/Guide/LocalRepoReleaseProfileJsonParser.cs b/src/TrashLib/Sonarr/ReleaseProfile/Guide/LocalRepoReleaseProfileJsonParser.cs index ebb37b68..5e85db9d 100644 --- a/src/TrashLib/Sonarr/ReleaseProfile/Guide/LocalRepoReleaseProfileJsonParser.cs +++ b/src/TrashLib/Sonarr/ReleaseProfile/Guide/LocalRepoReleaseProfileJsonParser.cs @@ -4,6 +4,7 @@ using Common.FluentValidation; using MoreLinq; using Newtonsoft.Json; using Serilog; +using TrashLib.Startup; namespace TrashLib.Sonarr.ReleaseProfile.Guide; diff --git a/src/TrashLib/IAppPaths.cs b/src/TrashLib/Startup/IAppPaths.cs similarity index 91% rename from src/TrashLib/IAppPaths.cs rename to src/TrashLib/Startup/IAppPaths.cs index 500f09fe..d7b3a5ba 100644 --- a/src/TrashLib/IAppPaths.cs +++ b/src/TrashLib/Startup/IAppPaths.cs @@ -1,6 +1,6 @@ using System.IO.Abstractions; -namespace TrashLib; +namespace TrashLib.Startup; public interface IAppPaths {