unit tests and pkg version commits
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -3,5 +3,6 @@
|
||||
"dotnet-test-explorer.runInParallel": false,
|
||||
"dotnet-test-explorer.showCodeLens": true,
|
||||
"dotnet-test-explorer.testArguments": "",
|
||||
"nxunitExplorer.nunit": ""
|
||||
"nxunitExplorer.nunit": "${workspaceFolder}/packages/nunit3-console.1.0.0/lib/net20/nunit3-console.exe",
|
||||
"nxunitExplorer.xunit": "${workspaceFolder}/packages/xunit.runner.console.2.4.1/tools/net472/xunit.console.exe"
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<RootNamespace>nuget_cli</RootNamespace>
|
||||
<UserSecretsId>45b74c62-05bc-4603-95b4-3e80ae2fdf50</UserSecretsId>
|
||||
<PackageVersion>1.0.1</PackageVersion>
|
||||
|
@ -10,17 +10,13 @@ namespace isnd.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ApplicationDbContext _dbContext;
|
||||
private readonly IHostingEnvironment _env;
|
||||
private readonly IUnleash _unleashĈlient;
|
||||
|
||||
public HomeController(
|
||||
ApplicationDbContext dbContext,
|
||||
IUnleash unleashĈlient,
|
||||
ILogger<HomeController> logger)
|
||||
IUnleash unleashĈlient)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
_unleashĈlient = unleashĈlient;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ using NuGet.Versioning;
|
||||
using isnd.Data;
|
||||
using isnd.Helpers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using isnd.Data.Catalog;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
@ -39,6 +40,12 @@ namespace isnd.Controllers
|
||||
_logger.LogError("403 : no api-key");
|
||||
return Unauthorized();
|
||||
}
|
||||
Commit commit = new Commit
|
||||
{
|
||||
Action = PackageAction.PublishPackage,
|
||||
TimeStamp = DateTime.Now
|
||||
};
|
||||
_dbContext.Commits.Add(commit);
|
||||
|
||||
foreach (IFormFile file in Request.Form.Files)
|
||||
{
|
||||
@ -93,7 +100,8 @@ namespace isnd.Controllers
|
||||
{
|
||||
Id = pkgid,
|
||||
Description = pkgdesc,
|
||||
OwnerId = apikey.UserId
|
||||
OwnerId = apikey.UserId,
|
||||
LatestVersion = commit
|
||||
};
|
||||
_dbContext.Packages.Add(package);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
{
|
||||
@ -12,21 +14,25 @@ namespace isnd.Data.Catalog
|
||||
|
||||
public class Commit : IObject
|
||||
{
|
||||
[Key][Required,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Key,
|
||||
DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Required][JsonIgnore]
|
||||
public DateTime TimeStamp{ get; set; }
|
||||
|
||||
[Required]
|
||||
public PackageAction Action { get; set; }
|
||||
|
||||
[Required]
|
||||
public string PackageVersionId { get; set; }
|
||||
[ForeignKey("PackageVersionId")]
|
||||
|
||||
public virtual PackageVersion PackageVersion{ get; set; }
|
||||
[NotMapped]
|
||||
public string CommitId { get => Id.ToString(); }
|
||||
|
||||
[NotMapped]
|
||||
public DateTime CommitTimeStamp { get => TimeStamp; }
|
||||
|
||||
[ForeignKey("CommitNId")]
|
||||
|
||||
public virtual List<PackageVersion> Versions { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
@ -38,6 +39,9 @@ namespace isnd.Data.Catalog
|
||||
[JsonProperty("nuget:version")]
|
||||
public string Version { get; set; }
|
||||
public string CommitId { get; set; }
|
||||
|
||||
[ForeignKey("CommitId")]
|
||||
public virtual Commit LastCommit { get; set; }
|
||||
public DateTime CommitTimeStamp { get; set; }
|
||||
}
|
||||
}
|
@ -27,7 +27,21 @@ namespace isnd.Data
|
||||
[JsonIgnore]
|
||||
|
||||
public virtual List<PackageVersion> Versions { get; set; }
|
||||
public string CommitId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Latest package version put, or post,
|
||||
/// or { delete when no more active version }.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Required][JsonIgnore]
|
||||
public long CommitNId { get; set ; }
|
||||
|
||||
[NotMapped]
|
||||
public string CommitId { get => CommitNId.ToString(); }
|
||||
|
||||
[ForeignKey("CommitNId")]
|
||||
|
||||
public virtual Commit LatestVersion{ get; set; }
|
||||
public DateTime CommitTimeStamp { get; set; }
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using isnd.Data.Catalog;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data
|
||||
@ -30,6 +31,16 @@ namespace isnd.Data
|
||||
[JsonIgnore]
|
||||
public virtual Package Package { get; set; }
|
||||
|
||||
[Required][JsonIgnore]
|
||||
public long CommitNId { get; set ; }
|
||||
|
||||
[NotMapped]
|
||||
|
||||
public string CommitId { get => CommitNId.ToString(); }
|
||||
|
||||
[ForeignKey("CommitNId")]
|
||||
|
||||
public virtual Commit LatestCommit{ get; set; }
|
||||
public string NugetLink => $"/package/{PackageId}/{FullString}/{PackageId}-{FullString}.nupkg";
|
||||
public string NuspecLink => $"/package/{PackageId}/{FullString}/{PackageId}-{FullString}.nuspec";
|
||||
|
||||
|
@ -10,8 +10,8 @@ using isnd.Data;
|
||||
namespace isndhost.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20210827201859_commitVersion")]
|
||||
partial class commitVersion
|
||||
[Migration("20210828142245_versionCommit")]
|
||||
partial class versionCommit
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -208,15 +208,13 @@ namespace isndhost.Migrations
|
||||
|
||||
b.Property<int>("Action");
|
||||
|
||||
b.Property<string>("PackageId")
|
||||
b.Property<string>("PackageVersionId")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<DateTime>("TimeStamp");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PackageId");
|
||||
|
||||
b.ToTable("Commits");
|
||||
});
|
||||
|
||||
@ -225,7 +223,7 @@ namespace isndhost.Migrations
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("CommitId");
|
||||
b.Property<long>("CommitNId");
|
||||
|
||||
b.Property<DateTime>("CommitTimeStamp");
|
||||
|
||||
@ -239,6 +237,8 @@ namespace isndhost.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CommitNId");
|
||||
|
||||
b.HasIndex("OwnerId");
|
||||
|
||||
b.ToTable("Packages");
|
||||
@ -320,16 +320,13 @@ namespace isndhost.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("isnd.Data.Catalog.Commit", b =>
|
||||
{
|
||||
b.HasOne("isnd.Data.Package", "Package")
|
||||
.WithMany()
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("isnd.Data.Package", b =>
|
||||
{
|
||||
b.HasOne("isnd.Data.Catalog.Commit", "LatestCommit")
|
||||
.WithMany()
|
||||
.HasForeignKey("CommitNId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("isnd.Data.ApplicationUser", "Owner")
|
||||
.WithMany()
|
||||
.HasForeignKey("OwnerId")
|
@ -4,14 +4,15 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
namespace isndhost.Migrations
|
||||
{
|
||||
public partial class commitVersion : Migration
|
||||
public partial class versionCommit : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "CommitId",
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "CommitNId",
|
||||
table: "Packages",
|
||||
nullable: true);
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CommitTimeStamp",
|
||||
@ -33,32 +34,47 @@ namespace isndhost.Migrations
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
|
||||
TimeStamp = table.Column<DateTime>(nullable: false),
|
||||
Action = table.Column<int>(nullable: false),
|
||||
PackageId = table.Column<string>(nullable: false)
|
||||
PackageVersionId = table.Column<string>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Commits", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Commits_Packages_PackageId",
|
||||
column: x => x.PackageId,
|
||||
principalTable: "Packages",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.Sql(
|
||||
@"delete from 'PackageVersions'; delete from 'Packages';"
|
||||
);
|
||||
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Commits_PackageId",
|
||||
table: "Commits",
|
||||
column: "PackageId");
|
||||
name: "IX_Packages_CommitNId",
|
||||
table: "Packages",
|
||||
column: "CommitNId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Packages_Commits_CommitNId",
|
||||
table: "Packages",
|
||||
column: "CommitNId",
|
||||
principalTable: "Commits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Packages_Commits_CommitNId",
|
||||
table: "Packages");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Commits");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Packages_CommitNId",
|
||||
table: "Packages");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CommitId",
|
||||
name: "CommitNId",
|
||||
table: "Packages");
|
||||
|
||||
migrationBuilder.DropColumn(
|
355
src/isnd/Migrations/20210828150712_pkgVersionCommit.Designer.cs
generated
Normal file
355
src/isnd/Migrations/20210828150712_pkgVersionCommit.Designer.cs
generated
Normal file
@ -0,0 +1,355 @@
|
||||
// <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("20210828150712_pkgVersionCommit")]
|
||||
partial class pkgVersionCommit
|
||||
{
|
||||
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<string>("PackageVersionId")
|
||||
.IsRequired();
|
||||
|
||||
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()
|
||||
.HasForeignKey("CommitNId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("isnd.Data.Package", "Package")
|
||||
.WithMany("Versions")
|
||||
.HasForeignKey("PackageId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
44
src/isnd/Migrations/20210828150712_pkgVersionCommit.cs
Normal file
44
src/isnd/Migrations/20210828150712_pkgVersionCommit.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace isndhost.Migrations
|
||||
{
|
||||
public partial class pkgVersionCommit : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "CommitNId",
|
||||
table: "PackageVersions",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PackageVersions_CommitNId",
|
||||
table: "PackageVersions",
|
||||
column: "CommitNId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_PackageVersions_Commits_CommitNId",
|
||||
table: "PackageVersions",
|
||||
column: "CommitNId",
|
||||
principalTable: "Commits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_PackageVersions_Commits_CommitNId",
|
||||
table: "PackageVersions");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_PackageVersions_CommitNId",
|
||||
table: "PackageVersions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CommitNId",
|
||||
table: "PackageVersions");
|
||||
}
|
||||
}
|
||||
}
|
@ -206,15 +206,13 @@ namespace isndhost.Migrations
|
||||
|
||||
b.Property<int>("Action");
|
||||
|
||||
b.Property<string>("PackageId")
|
||||
b.Property<string>("PackageVersionId")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<DateTime>("TimeStamp");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PackageId");
|
||||
|
||||
b.ToTable("Commits");
|
||||
});
|
||||
|
||||
@ -223,7 +221,7 @@ namespace isndhost.Migrations
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("CommitId");
|
||||
b.Property<long>("CommitNId");
|
||||
|
||||
b.Property<DateTime>("CommitTimeStamp");
|
||||
|
||||
@ -237,6 +235,8 @@ namespace isndhost.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CommitNId");
|
||||
|
||||
b.HasIndex("OwnerId");
|
||||
|
||||
b.ToTable("Packages");
|
||||
@ -252,6 +252,8 @@ namespace isndhost.Migrations
|
||||
b.Property<string>("Type")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<long>("CommitNId");
|
||||
|
||||
b.Property<bool>("IsPrerelease");
|
||||
|
||||
b.Property<int>("Major");
|
||||
@ -262,6 +264,8 @@ namespace isndhost.Migrations
|
||||
|
||||
b.HasKey("PackageId", "FullString", "Type");
|
||||
|
||||
b.HasIndex("CommitNId");
|
||||
|
||||
b.ToTable("PackageVersions");
|
||||
});
|
||||
|
||||
@ -318,16 +322,13 @@ namespace isndhost.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("isnd.Data.Catalog.Commit", b =>
|
||||
{
|
||||
b.HasOne("isnd.Data.Package", "Package")
|
||||
.WithMany()
|
||||
.HasForeignKey("PackageId")
|
||||
.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")
|
||||
@ -336,6 +337,11 @@ namespace isndhost.Migrations
|
||||
|
||||
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
|
||||
{
|
||||
b.HasOne("isnd.Data.Catalog.Commit", "LatestCommit")
|
||||
.WithMany()
|
||||
.HasForeignKey("CommitNId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("isnd.Data.Package", "Package")
|
||||
.WithMany("Versions")
|
||||
.HasForeignKey("PackageId")
|
||||
|
@ -14,12 +14,12 @@ using Unleash;
|
||||
|
||||
namespace isnd.Services
|
||||
{
|
||||
|
||||
|
||||
|
||||
public class PackageManager : IPackageManager
|
||||
{
|
||||
ApplicationDbContext dbContext;
|
||||
public PackageManager(ApplicationDbContext dbContext,
|
||||
public PackageManager(ApplicationDbContext dbContext,
|
||||
IOptions<IsndSettings> siteConfigOptionsOptions)
|
||||
{
|
||||
this.dbContext = dbContext;
|
||||
@ -55,10 +55,6 @@ namespace isnd.Services
|
||||
|
||||
public CatalogIndex GenerateCatalogIndex(string commitId)
|
||||
{
|
||||
|
||||
var root = "/index.json";
|
||||
|
||||
|
||||
var catalog = new CatalogIndex
|
||||
{
|
||||
CommitId = commitId,
|
||||
@ -155,13 +151,13 @@ namespace isnd.Services
|
||||
}
|
||||
void LoadCatalogFromDb()
|
||||
{
|
||||
int i=0;
|
||||
int p=0;
|
||||
int i = 0;
|
||||
int p = 0;
|
||||
var oldIndex = CurrentCatalogIndex;
|
||||
var oldPages = CurrentCatalogPages;
|
||||
CurrentCatalogIndex = new CatalogIndex
|
||||
{
|
||||
|
||||
|
||||
};
|
||||
CurrentCatalogPages = new List<Page>();
|
||||
|
||||
@ -169,46 +165,60 @@ namespace isnd.Services
|
||||
Commit last = null;
|
||||
PageRef pageRef = null;
|
||||
Page page = null;
|
||||
i=pmConfigOptions.CatalogPageLen;
|
||||
i = pmConfigOptions.CatalogPageLen;
|
||||
foreach (var commit in scope)
|
||||
{
|
||||
if (i >= this.pmConfigOptions.CatalogPageLen)
|
||||
{
|
||||
page = new Page{
|
||||
Parent = pmConfigOptions.ExternalUrl + "/package",
|
||||
page = new Page
|
||||
{
|
||||
Parent = pmConfigOptions.ExternalUrl + "/package",
|
||||
CommitId = commit.CommitId,
|
||||
CommitTimeStamp = commit.CommitTimeStamp,
|
||||
Id = this.pmConfigOptions.ExternalUrl + "/package/index-" + p++
|
||||
|
||||
};
|
||||
CurrentCatalogPages.Add(page);
|
||||
pageRef = new PageRef{
|
||||
Id = page.Id
|
||||
pageRef = new PageRef
|
||||
{
|
||||
Id = page.Id
|
||||
};
|
||||
CurrentCatalogIndex.Items.Add(pageRef);
|
||||
i = 0;
|
||||
}
|
||||
PackageRef packageref = new PackageRef
|
||||
var validPkgs = dbContext.Packages
|
||||
.Include(pkg => pkg.Versions)
|
||||
.Where(
|
||||
pkg => pkg.Versions.Count() > 0
|
||||
);
|
||||
// pkg.Versions.OrderByDescending(vi => vi.CommitNId).First().FullString
|
||||
foreach (var pkg in validPkgs)
|
||||
{
|
||||
CommitId = commit.Id.ToString(),
|
||||
Id = commit.PackageVersionId,
|
||||
|
||||
var v = pkg.Versions.OrderByDescending(vc => vc.CommitNId).First();
|
||||
|
||||
CommitTimeStamp = commit.CommitTimeStamp,
|
||||
RefType = commit.Action == PackageAction.PublishPackage ?
|
||||
"nuget:PackageDetails" : "nuget:PackageDelete"
|
||||
};
|
||||
|
||||
page.Items.Add(packageref);
|
||||
var pkgref = new PackageRef
|
||||
{
|
||||
Version = v.FullString,
|
||||
LastCommit = v.LatestCommit,
|
||||
CommitId = v.LatestCommit.CommitId,
|
||||
CommitTimeStamp = v.LatestCommit.CommitTimeStamp,
|
||||
RefId = page.Id,
|
||||
Id = v.PackageId
|
||||
};
|
||||
page.Items.Add(pkgref);
|
||||
}
|
||||
last = commit;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (last!=null)
|
||||
if (last != null)
|
||||
{
|
||||
CurrentCatalogIndex.CommitId = last.CommitId;
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
else
|
||||
{
|
||||
CurrentCatalogIndex.CommitId = "none";
|
||||
}
|
||||
}
|
||||
|
||||
protected static bool CamelCaseMatch(string id, string query)
|
||||
|
@ -14,13 +14,8 @@ using isnd.Authorization;
|
||||
using isnd.Data.Roles;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Unleash;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Unleash.ClientFactory;
|
||||
using isnd.Entities;
|
||||
using Microsoft.Extensions.Options;
|
||||
using isnd.Helpers;
|
||||
using isnd.Services;
|
||||
|
||||
namespace isnd
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
@ -10,7 +10,6 @@
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="NUnit" Version="3.13.1" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
|
||||
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -9,10 +9,12 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="xunit" Version="2.4.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
|
||||
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.reporters" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
|
||||
<PackageToolReference Include="xunit.runner.console" Version="2.4.1" PrivateAssets="All"/>
|
||||
<PackageReference Include="coverlet.collector" Version="1.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Reference in New Issue
Block a user