Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSOE-751: Upgrade to Orchard Core 1.8 #51

Merged
merged 21 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<Title>Lombiq Hosting - Media Theme Bridge for Orchard Core</Title>
</PropertyGroup>
Expand Down Expand Up @@ -29,12 +29,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Deployment.Abstractions" Version="1.7.0" />
<PackageReference Include="OrchardCore.DisplayManagement.Abstractions" Version="1.7.0" />
<PackageReference Include="OrchardCore.Recipes.Abstractions" Version="1.7.0" />
<PackageReference Include="OrchardCore.ResourceManagement.Abstractions" Version="1.7.0" />
<PackageReference Include="OrchardCore.Media" Version="1.7.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.7.0" />
<PackageReference Include="OrchardCore.Deployment.Abstractions" Version="1.8.2" />
<PackageReference Include="OrchardCore.DisplayManagement.Abstractions" Version="1.8.2" />
<PackageReference Include="OrchardCore.Recipes.Abstractions" Version="1.8.2" />
<PackageReference Include="OrchardCore.ResourceManagement.Abstractions" Version="1.8.2" />
<PackageReference Include="OrchardCore.Media" Version="1.8.2" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.8.2" />
<PackageReference Include="Scrutor" Version="4.2.2" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Lombiq.Hosting.MediaTheme.Bridge/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
Version = "0.0.1",
Description = "Provides the processing logic for the Media Theme.",
Category = "Hosting",
Dependencies = new[] { "OrchardCore.Deployment", "OrchardCore.Media" }
Dependencies = ["OrchardCore.Deployment", "OrchardCore.Media"]
)]
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task InvokeAsync(HttpContext context)
}

context.Response.StatusCode = 404;
context.Response.Headers.Add("Content-Length", "0");
context.Response.Headers.Append("Content-Length", "0");
await context.Response.Body.FlushAsync(context.RequestAborted);
context.Abort();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public IEnumerable<IFeatureInfo> GetFeatures(string[] featureIdsToLoad)
if (featureIdsToLoad.Contains(FeatureNames.MediaTheme))
{
var baseThemeId = GetBaseThemeId();
if (!string.IsNullOrEmpty(baseThemeId)) featureIdsToLoad = featureIdsToLoad.Append(baseThemeId).ToArray();
if (!string.IsNullOrEmpty(baseThemeId)) featureIdsToLoad = [.. featureIdsToLoad, baseThemeId];
}

return _decorated.GetFeatures(featureIdsToLoad);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackAsTool>true</PackAsTool>
Expand Down
18 changes: 11 additions & 7 deletions Lombiq.Hosting.MediaTheme.Deployer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class CommandLineOptions
public string? RemoteDeploymentClientApiKey { get; set; }
}

internal static class Program
internal static partial class Program
{
public static Task Main(string[] args) =>
Parser.Default.ParseArguments<CommandLineOptions>(args)
Expand All @@ -76,7 +76,7 @@ public static Task Main(string[] args) =>
private static void HandleParseError(IEnumerable<Error> errors)
{
var errorsList = errors.ToList();
if (errorsList.Any())
if (errorsList.Count != 0)
{
foreach (var error in errorsList)
{
Expand All @@ -102,6 +102,8 @@ private static async Task RunOptionsAsync(CommandLineOptions options)
}
}

internal static readonly string[] FeaturesToEnable = ["Lombiq.Hosting.MediaTheme.Bridge", "Lombiq.Hosting.MediaTheme"];
Piedone marked this conversation as resolved.
Show resolved Hide resolved

private static async Task RunOptionsInnerAsync(CommandLineOptions options)
{
// Creating directory for the deployment.
Expand Down Expand Up @@ -134,7 +136,7 @@ private static async Task RunOptionsInnerAsync(CommandLineOptions options)
var featureStep = JObject.FromObject(new
{
name = "Feature",
enable = new[] { "Lombiq.Hosting.MediaTheme.Bridge", "Lombiq.Hosting.MediaTheme" },
enable = FeaturesToEnable,
});
recipeSteps.Add(featureStep);

Expand All @@ -152,12 +154,11 @@ private static async Task RunOptionsInnerAsync(CommandLineOptions options)
{
var manifestPath = Path.Combine(themePath, "Manifest.cs");
var manifestContent = await File.ReadAllTextAsync(manifestPath);
var basteThemeMatch = Regex.Match(
manifestContent, @"BaseTheme\s*=\s*""(?<baseThemeId>.*)""", RegexOptions.ExplicitCapture, TimeSpan.FromSeconds(1));
var baseThemeMatch = BaseThemeRegex().Match(manifestContent);

if (basteThemeMatch.Success)
if (baseThemeMatch.Success)
{
baseThemeId = basteThemeMatch.Groups["baseThemeId"].Value;
baseThemeId = baseThemeMatch.Groups["baseThemeId"].Value;
}
}

Expand Down Expand Up @@ -343,4 +344,7 @@ private static void CreateRecipeAndWriteIt(CommandLineOptions options, JArray st

file.Close();
}

[GeneratedRegex(@"BaseTheme\s*=\s*""(?<baseThemeId>.*)""", RegexOptions.ExplicitCapture, matchTimeoutMilliseconds: 1000)]
private static partial Regex BaseThemeRegex();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**</DefaultItemExcludes>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions Lombiq.Hosting.MediaTheme/Lombiq.Hosting.MediaTheme.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<Title>Lombiq Hosting - Media Theme for Orchard Core</Title>
</PropertyGroup>
Expand Down Expand Up @@ -33,7 +33,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Theme.Targets" Version="1.7.0" />
<PackageReference Include="OrchardCore.Theme.Targets" Version="1.8.2" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Lombiq.Hosting.MediaTheme/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
Version = "0.0.1",
Description = "It allows developers to host their themes in the Orchard Core Media Library, including templates and assets.",
Category = "Hosting",
Dependencies = new[] { MediaThemeBridge }
Dependencies = [MediaThemeBridge]
)]