Skip to content

Commit

Permalink
Updated the package manifest parsing logic
Browse files Browse the repository at this point in the history
Since the project has been updated to target Umbraco 13, we can now access the C# properties exposing the package ID and version assembly name
  • Loading branch information
abjerner committed Apr 15, 2024
1 parent 9cda895 commit 44166eb
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions src/Limbo.Umbraco.Iddqd/Models/Packages/IddqdPackageManifest.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System.IO;
using System.Linq;
using System.Linq;
using System.Reflection;
using Limbo.Umbraco.Iddqd.Models.Assemblies;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Skybrud.Essentials.Json.Newtonsoft;
using Skybrud.Essentials.Json.Newtonsoft.Extensions;
using Skybrud.Essentials.Reflection;
using Skybrud.Essentials.Strings;
using Umbraco.Cms.Core.Manifest;
Expand Down Expand Up @@ -72,20 +68,9 @@ public IddqdPackageManifest(PackageManifest manifest) {
Type = IddqdPackageType.PackageManifest;
Version = manifest.Version;

// Since the package.manifest file may include properties not supported in Umbraco 10, we should try to parse
// the package.manifest file on our own
string? packageId = null;
string? versionAssemblyName = null;
try {
if (File.Exists(_manifest.Source)) {
JObject json = JsonUtils.LoadJsonObject(_manifest.Source);
packageId = json.GetString("packageId");
versionAssemblyName = json.GetString("versionAssemblyName");
if (!string.IsNullOrWhiteSpace(packageId)) PackageId = packageId;
}
} catch {
// ignore
}
// Get the package ID and/or assembly version from the package.manifest file
string? packageId = manifest.PackageId;
string? versionAssemblyName = manifest.VersionAssemblyName;

// If the path is within the content root, we should only show the file's virtual path instead
string[] path = Path.Split('/', '\\');
Expand Down

0 comments on commit 44166eb

Please sign in to comment.