Catalog packages
This commit is contained in:
@ -93,13 +93,17 @@ namespace isn
|
||||
StreamReader re = new StreamReader(stream);
|
||||
if (resp is HttpWebResponse)
|
||||
{
|
||||
String json = re.ReadToEnd();
|
||||
report.Message = json;
|
||||
var hrep = resp as HttpWebResponse;
|
||||
report.StatusCode = hrep.StatusCode.ToString();
|
||||
report.OK = hrep.StatusCode == HttpStatusCode.Accepted
|
||||
|| hrep.StatusCode == HttpStatusCode.OK;
|
||||
return true;
|
||||
if (resp.ContentType == "text/json")
|
||||
{
|
||||
String json = re.ReadToEnd();
|
||||
report.Message = json;
|
||||
var hrep = resp as HttpWebResponse;
|
||||
report.StatusCode = hrep.StatusCode.ToString();
|
||||
report.OK = hrep.StatusCode == HttpStatusCode.Accepted
|
||||
|| hrep.StatusCode == HttpStatusCode.OK;
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -152,7 +152,8 @@ namespace isnd.Controllers
|
||||
Patch = version.Patch,
|
||||
IsPrerelease = version.IsPrerelease,
|
||||
FullString = version.ToFullString(),
|
||||
Type = "<null-type>"
|
||||
Type = "<null-type>",
|
||||
LatestCommit = commit
|
||||
});
|
||||
else
|
||||
foreach (var type in types)
|
||||
@ -165,7 +166,8 @@ namespace isnd.Controllers
|
||||
Patch = version.Patch,
|
||||
IsPrerelease = version.IsPrerelease,
|
||||
FullString = version.ToFullString(),
|
||||
Type = type.Name
|
||||
Type = type.Name,
|
||||
LatestCommit = commit
|
||||
};
|
||||
_dbContext.PackageVersions.Add(pkgver);
|
||||
}
|
||||
|
@ -105,9 +105,16 @@ namespace isnd.Controllers
|
||||
[HttpGet(_pkgRootPrefix)]
|
||||
public IActionResult Index()
|
||||
{
|
||||
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
|
||||
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
|
||||
return Ok(PackageManager.CurrentCatalogIndex);
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + "/index-{id}")]
|
||||
public IActionResult Index(string id)
|
||||
{
|
||||
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
|
||||
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
|
||||
}
|
||||
|
||||
// GET /autocomplete?id=isn.protocol&prerelease=true
|
||||
[HttpGet(_pkgRootPrefix + "/autocomplete")]
|
||||
|
@ -26,7 +26,7 @@ namespace isnd.Data.Catalog
|
||||
public PackageAction Action { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string CommitId { get => Id.ToString(); }
|
||||
public string CommitId { get => Id.ToString(); }
|
||||
|
||||
[NotMapped]
|
||||
public DateTime CommitTimeStamp { get => TimeStamp; }
|
||||
|
@ -38,10 +38,14 @@ namespace isnd.Data.Catalog
|
||||
|
||||
[JsonProperty("nuget:version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
[JsonProperty("commitId")]
|
||||
public string CommitId { get; set; }
|
||||
|
||||
[ForeignKey("CommitId")]
|
||||
[ForeignKey("CommitId"), JsonIgnore]
|
||||
public virtual Commit LastCommit { get; set; }
|
||||
|
||||
[JsonProperty("commitTimeStamp")]
|
||||
public DateTime CommitTimeStamp { get; set; }
|
||||
}
|
||||
}
|
@ -11,11 +11,9 @@ namespace isnd.Interfaces
|
||||
public interface IPackageManager
|
||||
{
|
||||
AutoCompleteResult AutoComplete(string id, int skip, int take, bool prerelease = false, string packageType = null);
|
||||
Page CatalogPage();
|
||||
CatalogIndex GenerateCatalogIndex(string commitId);
|
||||
|
||||
CatalogIndex GetCatalogIndex();
|
||||
string[] GetVersions(string id, NuGetVersion parsedVersion, bool prerelease = false, string packageType = null, int skip = 0, int take = 25);
|
||||
void PublishCatalog();
|
||||
PackageIndexViewModel SearchByName(string query, int skip, int take, bool prerelease = false, string packageType = null);
|
||||
IEnumerable<Resource> GetResources(IUnleash unleashĈlient);
|
||||
}
|
||||
|
352
src/isnd/Migrations/20210828220901_CommitNoPack.Designer.cs
generated
Normal file
352
src/isnd/Migrations/20210828220901_CommitNoPack.Designer.cs
generated
Normal file
@ -0,0 +1,352 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using isnd.Data;
|
||||
|
||||
namespace isndhost.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20210828220901_CommitNoPack")]
|
||||
partial class CommitNoPack
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
|
||||
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken();
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique()
|
||||
.HasName("RoleNameIndex");
|
||||
|
||||
b.ToTable("AspNetRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("ClaimType");
|
||||
|
||||
b.Property<string>("ClaimValue");
|
||||
|
||||
b.Property<string>("RoleId")
|
||||
.IsRequired();
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetRoleClaims");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("ClaimType");
|
||||
|
||||
b.Property<string>("ClaimValue");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired();
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserClaims");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider");
|
||||
|
||||
b.Property<string>("ProviderKey");
|
||||
|
||||
b.Property<string>("ProviderDisplayName");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired();
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserLogins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId");
|
||||
|
||||
b.Property<string>("RoleId");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetUserRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.Property<string>("UserId");
|
||||
|
||||
b.Property<string>("LoginProvider");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("AspNetUserTokens");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("CreationDate");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<string>("UserId")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<int>("ValidityPeriodInDays");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("ApiKeys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("isnd.Data.ApplicationUser", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("AccessFailedCount");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken();
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<bool>("EmailConfirmed");
|
||||
|
||||
b.Property<string>("FullName");
|
||||
|
||||
b.Property<bool>("LockoutEnabled");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("PasswordHash");
|
||||
|
||||
b.Property<string>("PhoneNumber");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed");
|
||||
|
||||
b.Property<string>("SecurityStamp");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasName("UserNameIndex");
|
||||
|
||||
b.ToTable("AspNetUsers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("isnd.Data.Catalog.Commit", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("Action");
|
||||
|
||||
b.Property<DateTime>("TimeStamp");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Commits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("isnd.Data.Package", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<long>("CommitNId");
|
||||
|
||||
b.Property<DateTime>("CommitTimeStamp");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(1024);
|
||||
|
||||
b.Property<string>("OwnerId")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<bool>("Public");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CommitNId");
|
||||
|
||||
b.HasIndex("OwnerId");
|
||||
|
||||
b.ToTable("Packages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
|
||||
{
|
||||
b.Property<string>("PackageId");
|
||||
|
||||
b.Property<string>("FullString")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("Type")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<long>("CommitNId");
|
||||
|
||||
b.Property<bool>("IsPrerelease");
|
||||
|
||||
b.Property<int>("Major");
|
||||
|
||||
b.Property<int>("Minor");
|
||||
|
||||
b.Property<int>("Patch");
|
||||
|
||||
b.HasKey("PackageId", "FullString", "Type");
|
||||
|
||||
b.HasIndex("CommitNId");
|
||||
|
||||
b.ToTable("PackageVersions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||
{
|
||||
b.HasOne("isnd.Data.ApplicationUser")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||
{
|
||||
b.HasOne("isnd.Data.ApplicationUser")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||
{
|
||||
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("isnd.Data.ApplicationUser")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||
{
|
||||
b.HasOne("isnd.Data.ApplicationUser")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b =>
|
||||
{
|
||||
b.HasOne("isnd.Data.ApplicationUser", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("isnd.Data.Package", b =>
|
||||
{
|
||||
b.HasOne("isnd.Data.Catalog.Commit", "LatestVersion")
|
||||
.WithMany()
|
||||
.HasForeignKey("CommitNId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("isnd.Data.ApplicationUser", "Owner")
|
||||
.WithMany()
|
||||
.HasForeignKey("OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
|
||||
{
|
||||
b.HasOne("isnd.Data.Catalog.Commit", "LatestCommit")
|
||||
.WithMany("Versions")
|
||||
.HasForeignKey("CommitNId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("isnd.Data.Package", "Package")
|
||||
.WithMany("Versions")
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
23
src/isnd/Migrations/20210828220901_CommitNoPack.cs
Normal file
23
src/isnd/Migrations/20210828220901_CommitNoPack.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace isndhost.Migrations
|
||||
{
|
||||
public partial class CommitNoPack : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PackageVersionId",
|
||||
table: "Commits");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PackageVersionId",
|
||||
table: "Commits",
|
||||
nullable: false,
|
||||
defaultValue: "");
|
||||
}
|
||||
}
|
||||
}
|
@ -206,9 +206,6 @@ namespace isndhost.Migrations
|
||||
|
||||
b.Property<int>("Action");
|
||||
|
||||
b.Property<string>("PackageVersionId")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<DateTime>("TimeStamp");
|
||||
|
||||
b.HasKey("Id");
|
||||
@ -338,7 +335,7 @@ namespace isndhost.Migrations
|
||||
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
|
||||
{
|
||||
b.HasOne("isnd.Data.Catalog.Commit", "LatestCommit")
|
||||
.WithMany()
|
||||
.WithMany("Versions")
|
||||
.HasForeignKey("CommitNId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
|
@ -79,23 +79,6 @@ namespace isnd.Services
|
||||
return catalog;
|
||||
|
||||
}
|
||||
public Page CatalogPage()
|
||||
{
|
||||
var scope = dbContext.Packages
|
||||
.Where(P => P.Versions.Count > 0)
|
||||
.Select(
|
||||
p => new PackageRef { Id = p.Id, Version = p.Versions.Max().FullString });
|
||||
|
||||
return new Page
|
||||
{
|
||||
Items = scope.ToList()
|
||||
};
|
||||
}
|
||||
public void PublishCatalog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public AutoCompleteResult AutoComplete(string id,
|
||||
int skip, int take, bool prerelease = false,
|
||||
string packageType = null)
|
||||
@ -157,7 +140,8 @@ namespace isnd.Services
|
||||
var oldPages = CurrentCatalogPages;
|
||||
CurrentCatalogIndex = new CatalogIndex
|
||||
{
|
||||
Id = extApiUrl
|
||||
Id = extApiUrl,
|
||||
Items = new List<PageRef>()
|
||||
};
|
||||
CurrentCatalogPages = new List<Page>();
|
||||
|
||||
@ -175,8 +159,8 @@ namespace isnd.Services
|
||||
Parent = isndSettings.ExternalUrl + "/package",
|
||||
CommitId = commit.CommitId,
|
||||
CommitTimeStamp = commit.CommitTimeStamp,
|
||||
Id = this.isndSettings.ExternalUrl + "/package/index-" + p++
|
||||
|
||||
Id = this.isndSettings.ExternalUrl + "/package/index-" + p++,
|
||||
Items = new List<PackageRef>()
|
||||
};
|
||||
CurrentCatalogPages.Add(page);
|
||||
pageRef = new PageRef
|
||||
@ -188,8 +172,9 @@ namespace isnd.Services
|
||||
}
|
||||
var validPkgs = dbContext.Packages
|
||||
.Include(pkg => pkg.Versions)
|
||||
.Include(pkg => pkg.LatestVersion)
|
||||
.Where(
|
||||
pkg => pkg.Versions.Count() > 0
|
||||
pkg => pkg.Versions.Count() > 0 && pkg.CommitId == commit.CommitId
|
||||
);
|
||||
// pkg.Versions.OrderByDescending(vi => vi.CommitNId).First().FullString
|
||||
foreach (var pkg in validPkgs)
|
||||
@ -202,7 +187,7 @@ namespace isnd.Services
|
||||
LastCommit = v.LatestCommit,
|
||||
CommitId = v.LatestCommit.CommitId,
|
||||
CommitTimeStamp = v.LatestCommit.CommitTimeStamp,
|
||||
RefId = page.Id,
|
||||
RefId = v.NugetLink,
|
||||
Id = v.PackageId
|
||||
};
|
||||
page.Items.Add(pkgref);
|
||||
|
Reference in New Issue
Block a user