dependencies
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using isnd.Data.ApiKeys;
|
||||
using isnd.Data.Packages;
|
||||
using Microsoft.VisualStudio.Web.CodeGenerators.Mvc.Templates.BlazorIdentity.Pages;
|
||||
using Microsoft.DotNet.Scaffolding.Shared.ProjectModel;
|
||||
|
||||
namespace isnd.Data
|
||||
{
|
||||
@ -29,6 +31,9 @@ namespace isnd.Data
|
||||
_ = builder.Entity<PackageDependencyGroup>().HasOne(g=>g.PackageVersion)
|
||||
.WithMany(v => v.DependencyGroups).HasForeignKey(x => new { x.PackageId, x.PackageVersionFullString } );
|
||||
|
||||
_ = builder.Entity<Dependency>().HasOne(d=>d.Group)
|
||||
.WithMany(g=>g.Dependencies);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace isnd.Data.Catalog
|
||||
public class CatalogPage : Permalink
|
||||
{
|
||||
private readonly string pkgid;
|
||||
private readonly List<Package> items;
|
||||
private readonly List<RegistrationLeave> items;
|
||||
|
||||
private readonly string apiBase;
|
||||
|
||||
@ -18,12 +18,12 @@ namespace isnd.Data.Catalog
|
||||
public CatalogPage (string pkgid, string apiBase) : base(apiBase + $"/registration/{pkgid}/index.json")
|
||||
{
|
||||
Parent = apiBase + $"/registration/{pkgid}/index.json";
|
||||
this.items = new List<Package>();
|
||||
this.items = new List<RegistrationLeave>();
|
||||
this.pkgid = pkgid;
|
||||
this.apiBase = apiBase;
|
||||
}
|
||||
|
||||
public CatalogPage(string pkgid, string apiBase, List<PackageVersion> versions) : this(pkgid, apiBase)
|
||||
public CatalogPage(string pkgid, string apiBase, IEnumerable<PackageVersion> versions) : this(pkgid, apiBase)
|
||||
{
|
||||
AddVersionRange(versions);
|
||||
}
|
||||
@ -39,7 +39,7 @@ namespace isnd.Data.Catalog
|
||||
/// <value></value>
|
||||
[JsonProperty("items")]
|
||||
|
||||
public Package[] Items { get => items.ToArray(); }
|
||||
public RegistrationLeave[] Items { get => items.ToArray(); }
|
||||
|
||||
public void AddVersionRange(IEnumerable<PackageVersion> vitems)
|
||||
{
|
||||
|
@ -23,7 +23,6 @@ namespace isnd.Data.Catalog
|
||||
/// </summary>
|
||||
/// <param name="pkg">package id</param>
|
||||
/// <param name="apiBase">api Base</param>
|
||||
/// <param name="uri">package permalink</param>
|
||||
/// <returns></returns>
|
||||
public PackageDetails(PackageVersion pkg, string apiBase): base( apiBase + ApiConfig.Registration + "/" + pkg.PackageId + "/" + pkg.FullString + ".json")
|
||||
{
|
||||
@ -38,7 +37,7 @@ namespace isnd.Data.Catalog
|
||||
{
|
||||
if (pkg.DependencyGroups.Count>0)
|
||||
{
|
||||
dependencyGroups = pkg.DependencyGroups.ToArray();
|
||||
DependencySets = pkg.DependencyGroups.ToNugetDepSet();
|
||||
}
|
||||
}
|
||||
PackageDetailsUrl = new Uri(this.id);
|
||||
@ -49,6 +48,68 @@ namespace isnd.Data.Catalog
|
||||
[JsonProperty("@type")]
|
||||
public string[] RefType { get; protected set; } = new string[] { "PackageDetails" };
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="apiBase"></param>
|
||||
/// <param name="pkgId"></param>
|
||||
/// <param name="pkgVersionString"></param>
|
||||
/// <param name="commitId"></param>
|
||||
/// <param name="commitTimeStamp"></param>
|
||||
/// <param name="authors"></param>
|
||||
/// <param name="deprecation"></param>
|
||||
/// <param name="description"></param>
|
||||
/// <param name="iconUrl"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="licenseUrl"></param>
|
||||
/// <param name="licenseExpression"></param>
|
||||
/// <param name="minClientVersion"></param>
|
||||
/// <param name="projectUrl"></param>
|
||||
/// <param name="requireLicenseAcceptance"></param>
|
||||
/// <param name="summary"></param>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="packageContent"></param>
|
||||
/// <param name="version"></param>
|
||||
/// <param name="identity"></param>
|
||||
/// <param name="readmeUrl"></param>
|
||||
/// <param name="reportAbuseUrl"></param>
|
||||
/// <param name="packageDetailsUrl"></param>
|
||||
/// <param name="owners"></param>
|
||||
/// <param name="isListed"></param>
|
||||
/// <param name="prefixReserved"></param>
|
||||
/// <param name="licenseMetadata"></param>
|
||||
public PackageDetails(string apiBase, string pkgId, string pkgVersionString, string commitId, DateTimeOffset commitTimeStamp, string authors, Deprecation deprecation, string description, Uri iconUrl, string language, Uri licenseUrl, string licenseExpression, string minClientVersion, Uri projectUrl, bool requireLicenseAcceptance, string summary, string tags, string title, string packageContent, string version, PackageIdentity identity, Uri readmeUrl, Uri reportAbuseUrl, Uri packageDetailsUrl, string owners, bool isListed, bool prefixReserved, LicenseMetadata licenseMetadata)
|
||||
: base( apiBase + ApiConfig.Registration + "/" + pkgId + "/" + pkgVersionString + ".json")
|
||||
{
|
||||
this.CommitId = commitId;
|
||||
this.CommitTimeStamp = commitTimeStamp;
|
||||
this.Authors = authors;
|
||||
this.deprecation = deprecation;
|
||||
this.Description = description;
|
||||
this.IconUrl = iconUrl;
|
||||
this.language = language;
|
||||
this.LicenseUrl = licenseUrl;
|
||||
this.licenseExpression = licenseExpression;
|
||||
this.minClientVersion = minClientVersion;
|
||||
this.ProjectUrl = projectUrl;
|
||||
this.RequireLicenseAcceptance = requireLicenseAcceptance;
|
||||
this.Summary = summary;
|
||||
this.Tags = tags;
|
||||
this.Title = title;
|
||||
this.packageContent = packageContent;
|
||||
this.Version = version;
|
||||
this.Identity = identity;
|
||||
this.ReadmeUrl = readmeUrl;
|
||||
this.ReportAbuseUrl = reportAbuseUrl;
|
||||
this.PackageDetailsUrl = packageDetailsUrl;
|
||||
this.Owners = owners;
|
||||
this.IsListed = isListed;
|
||||
this.PrefixReserved = prefixReserved;
|
||||
this.LicenseMetadata = licenseMetadata;
|
||||
|
||||
}
|
||||
|
||||
[JsonProperty("commitId")]
|
||||
public string CommitId { get; set; }
|
||||
|
||||
@ -62,12 +123,6 @@ namespace isnd.Data.Catalog
|
||||
[JsonProperty("authors")]
|
||||
public string Authors { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The dependencies of the package, grouped by target framework
|
||||
/// </summary>
|
||||
/// <value>array of objects</value>
|
||||
public PackageDependencyGroup[] dependencyGroups { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The deprecation associated with the package
|
||||
/// </summary>
|
||||
@ -137,9 +192,7 @@ namespace isnd.Data.Catalog
|
||||
[JsonProperty("id")]
|
||||
public string PackageId { get; set; }
|
||||
|
||||
public IEnumerable<NuGet.Packaging.PackageDependencyGroup> DependencySets { get; set; }
|
||||
= Array.Empty<NuGet.Packaging.PackageDependencyGroup>();
|
||||
|
||||
|
||||
public long? DownloadCount { get; set; }
|
||||
|
||||
public PackageIdentity Identity{ get; set; }
|
||||
@ -159,6 +212,8 @@ namespace isnd.Data.Catalog
|
||||
|
||||
public LicenseMetadata LicenseMetadata { get; set; }
|
||||
|
||||
public IEnumerable<NuGet.Packaging.PackageDependencyGroup> DependencySets {get; set;}
|
||||
|
||||
public Task<PackageDeprecationMetadata> GetDeprecationMetadataAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
@ -15,11 +15,11 @@ namespace isnd.Data.Catalog
|
||||
Items = new List<CatalogPage>();
|
||||
}
|
||||
|
||||
public PackageRegistration(string apiBase, Packages.Package pkg) : base($"{apiBase}{ApiConfig.Registration}/{pkg.Id}/index.json")
|
||||
public PackageRegistration(string apiBase, string pkgId, IEnumerable<PackageVersion> versions) : base($"{apiBase}{ApiConfig.Registration}/{pkgId}/index.json")
|
||||
{
|
||||
Items = new List<CatalogPage>
|
||||
{
|
||||
new CatalogPage(pkg.Id, apiBase, pkg.Versions)
|
||||
new CatalogPage(pkgId, apiBase, versions)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,9 @@ namespace isnd.Data.Catalog
|
||||
/// Hosts a catalog entry,
|
||||
/// the atomic content reference
|
||||
/// </summary>
|
||||
public class Package
|
||||
public class RegistrationLeave
|
||||
{
|
||||
public Package(string apiBase, string pkgId, string fullVersionString, PackageDetails entry)
|
||||
public RegistrationLeave(string apiBase, string pkgId, string fullVersionString, PackageDetails entry)
|
||||
{
|
||||
|
||||
this.registration = apiBase + ApiConfig.Registration + "/" + pkgId + "/" + fullVersionString + ".json";
|
||||
|
@ -8,20 +8,23 @@ namespace isnd.Data
|
||||
{
|
||||
public class Dependency
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
/// <summary>
|
||||
/// Dependency Package Identifier
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Key]
|
||||
public string Id { get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Package Id
|
||||
/// </summary> <summary>
|
||||
///
|
||||
/// Dependency Group Id
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Required]
|
||||
[ForeignKey("Group")]
|
||||
[JsonIgnore]
|
||||
public string DependencyGroupId { set ; get ; }
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual PackageDependencyGroup Group{ get; set; }
|
||||
|
||||
public string Version { get; set; }
|
||||
|
@ -1,35 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using Microsoft.DotNet.Scaffolding.Shared.ProjectModel;
|
||||
using Microsoft.Identity.Client;
|
||||
using Newtonsoft.Json;
|
||||
using NuGet.Frameworks;
|
||||
using NuGet.Packaging;
|
||||
using NuGet.Packaging.Core;
|
||||
using NuGet.ProjectModel;
|
||||
using NuGet.Versioning;
|
||||
|
||||
namespace isnd.Data
|
||||
{
|
||||
static class Helpers
|
||||
{
|
||||
public static NuGet.Packaging.PackageDependencyGroup[] ToNugetDepSet(this IEnumerable<PackageDependencyGroup> groups)
|
||||
{
|
||||
return groups.Select(group => new NuGet.Packaging.PackageDependencyGroup(
|
||||
new NuGetFramework(group.TargetFramework),
|
||||
group.Dependencies.Select(dep => new PackageDependency(dep.Id))
|
||||
)).ToArray();
|
||||
}
|
||||
}
|
||||
public class PackageDependencyGroup
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public string Id { get ; set;}
|
||||
|
||||
[Required]
|
||||
[JsonIgnore]
|
||||
public string PackageId { get ; set;}
|
||||
|
||||
[Required]
|
||||
[JsonIgnore]
|
||||
public string PackageVersionFullString { get ; set;}
|
||||
|
||||
[JsonProperty("targetFramework")]
|
||||
[Required]
|
||||
public string TargetFramework { get; set; }
|
||||
|
||||
[JsonProperty("dependencies")]
|
||||
[ForeignKey("DependencyGroupId")]
|
||||
public virtual List<Dependency> Dependencies { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual PackageVersion PackageVersion { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -74,9 +74,9 @@ namespace isnd.Data
|
||||
public string SementicVersionString { get => $"{Major}.{Minor}.{Patch}"; }
|
||||
public NuGetVersion NugetVersion { get => new NuGetVersion(FullString); }
|
||||
|
||||
public Catalog.Package ToPackage(string apiBase)
|
||||
public Catalog.RegistrationLeave ToPackage(string apiBase)
|
||||
{
|
||||
return new Catalog.Package(apiBase, this.PackageId , FullString, new Catalog.PackageDetails(this, apiBase));
|
||||
return new Catalog.RegistrationLeave(apiBase, this.PackageId , FullString, new Catalog.PackageDetails(this, apiBase));
|
||||
}
|
||||
|
||||
public bool IsDeleted => LatestCommit?.Action == PackageAction.DeletePackage;
|
||||
|
Reference in New Issue
Block a user