WIP page leaf

This commit is contained in:
2022-07-10 17:05:05 +01:00
parent 2dcf1a2806
commit 7f9984b059
28 changed files with 164 additions and 75 deletions

View File

@ -1,6 +1,6 @@
{ {
"omnisharp.msbuild": false, "omnisharp.msbuild": true,
"dotnet-test-explorer.testProjectPath": "**/*.sln", "dotnet-test-explorer.testProjectPath": "**/*Tests.csproj",
"dotnet-test-explorer.runInParallel": false, "dotnet-test-explorer.runInParallel": false,
"dotnet-test-explorer.showCodeLens": true, "dotnet-test-explorer.showCodeLens": true,
"dotnet-test-explorer.testArguments": "", "dotnet-test-explorer.testArguments": "",
@ -46,5 +46,7 @@
"database": "isnd", "database": "isnd",
"username": "paul" "username": "paul"
} }
] ],
"omnisharp.disableMSBuildDiagnosticWarning": true,
"omnisharp.enableRoslynAnalyzers": false
} }

View File

@ -76,3 +76,50 @@ sudo chown -R root.root /usr/local/lib/isn
```` ````
## TODO ## TODO
```json
{
"@id": "https://api.nuget.org/v3/registration5-semver1/",
"@type": "RegistrationsBaseUrl",
"comment": "Base URL of Azure storage where NuGet package registration info is stored"
},
{
"@id": "https://api.nuget.org/v3-flatcontainer/",
"@type": "PackageBaseAddress/3.0.0",
"comment": "Base URL of where NuGet packages are stored, in the format https://api.nuget.org/v3-flatcontainer/{id-lower}/{version-lower}/{id-lower}.{version-lower}.nupkg"
},
{
"@id": "https://api.nuget.org/v3/registration5-semver1/",
"@type": "RegistrationsBaseUrl/3.0.0-rc",
"comment": "Base URL of Azure storage where NuGet package registration info is stored used by RC clients. This base URL does not include SemVer 2.0.0 packages."
},
{
"@id": "https://api.nuget.org/v3/registration5-semver1/",
"@type": "RegistrationsBaseUrl/3.0.0-beta",
"comment": "Base URL of Azure storage where NuGet package registration info is stored used by Beta clients. This base URL does not include SemVer 2.0.0 packages."
},
{
"@id": "https://www.nuget.org/packages/{id}/{version}?_src=template",
"@type": "PackageDetailsUriTemplate/5.1.0",
"comment": "URI template used by NuGet Client to construct details URL for packages"
},
{
"@id": "https://api.nuget.org/v3/registration5-gz-semver2/",
"@type": "RegistrationsBaseUrl/3.6.0",
"comment": "Base URL of Azure storage where NuGet package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
},
````

View File

@ -25,10 +25,8 @@ namespace isnd.Controllers
public IActionResult Index() public IActionResult Index()
{ {
return View(new HomeIndexViewModel{ return View(new HomeIndexViewModel{
PkgCount = _dbContext.Packages PkgCount = _dbContext.Packages
.Include(p => p.Versions)
.Where(p => p.Versions.Count > 0) .Where(p => p.Versions.Count > 0)
.Count(), .Count(),
UnleashClient = _unleashĈlient UnleashClient = _unleashĈlient

View File

@ -1,6 +1,5 @@
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using isnd.Data.Catalog;
using isnd.Helpers; using isnd.Helpers;
using isnd.Services; using isnd.Services;
using isnd.Entities; using isnd.Entities;
@ -28,19 +27,18 @@ namespace isnd.Controllers
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]); return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
} }
[HttpGet(_pkgRootPrefix + ApiConfig.Registration + "/{id}/{*lower}")] [HttpGet(_pkgRootPrefix + "{apiVersion}/" + ApiConfig.Registration + "/{id}/{*lower}")]
public async Task<IActionResult> CatalogRegistrationAsync(string id, string lower) public async Task<IActionResult> CatalogRegistrationAsync(string apiVersion, string id, string lower)
{ {
bool askForindex = lower != null && lower.EndsWith(ApiConfig.Base);
if (askForindex)
{
lower = lower.Substring(0, lower.Length - ApiConfig.Base.Length);
}
string pkgType = ParamHelpers.Optional(ref lower); string pkgType = ParamHelpers.Optional(ref lower);
var pkgVersion = await dbContext.PackageVersions var pkgFromname = packageManager.SearchByName(id, 0, 1);
.Include(v => v.LatestCommit) if (pkgFromname == null) return NotFound();
.SingleOrDefaultAsync( return Ok(pkgFromname);
v => v.PackageId == id &&
v.FullString == lower &&
v.Type == pkgType
);
if (pkgVersion == null) return NotFound();
return Ok();
} }
@ -57,15 +55,17 @@ namespace isnd.Controllers
).Distinct().ToList(); ).Distinct().ToList();
if (!types.Contains("PackageDelete")) if (!types.Contains("PackageDelete"))
types.Add("PackageDetails"); types.Add("PackageDetails");
var pub = pkgvs.Last().Package.CommitTimeStamp;
var last = pkgvs.Last();
var pub = last.Package.CommitTimeStamp;
var firstpub = pkgvs.First().Package.CommitTimeStamp; var firstpub = pkgvs.First().Package.CommitTimeStamp;
return Ok(new CatalogLeaf return Ok(new Data.Packages.Catalog.CatalogLeaf
{ {
CommitId = id, CommitId = last.CommitId,
Id = id, Id = id,
CommitTimeStamp = firstpub, CommitTimeStamp = pub,
Version = version, Version = last.FullString,
Published = pub, Published = pub,
RefType = types.ToArray(), RefType = types.ToArray(),

View File

@ -32,7 +32,7 @@ namespace isnd.Controllers
} }
// Web get spec // Web get spec
[HttpGet(_pkgRootPrefix + ApiConfig.GetNuspec + "/{id}/{lower}/{idf}-{lowerf}." [HttpGet(_pkgRootPrefix + Constants.SpecFileEstension + "/{id}/{lower}/{idf}-{lowerf}."
+ Constants.SpecFileEstension)] + Constants.SpecFileEstension)]
public IActionResult GetNuspec( public IActionResult GetNuspec(
[FromRoute][SafeName][Required] string id, [FromRoute][SafeName][Required] string id,

View File

@ -6,7 +6,7 @@ namespace isnd.Controllers
{ {
public partial class PackagesController public partial class PackagesController
{ {
[HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/index.json")] [HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/" + ApiConfig.Base)]
public IActionResult GetVersions( public IActionResult GetVersions(
string id, string id,
string lower, string lower,

View File

@ -15,8 +15,8 @@ using isnd.Data;
using isnd.Helpers; using isnd.Helpers;
using isnd.Entities; using isnd.Entities;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using isnd.Data.Catalog;
using isn.abst; using isn.abst;
using isnd.Data.Packages;
namespace isnd.Controllers namespace isnd.Controllers
{ {

View File

@ -6,8 +6,7 @@ using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using isnd.Data; using isnd.Data;
using isnd.Data.ApiKeys; using isnd.Data.ApiKeys;
using isnd.Data.Catalog; using isnd.Data.Packages;
using isnd.Data.Historic;
namespace isnd.Data namespace isnd.Data
{ {

View File

@ -1,7 +1,8 @@
using System; using System;
using isnd.Interfaces;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isnd.Data.Catalog namespace isnd.Data.Packages.Catalog
{ {
public class PageRef : IObject public class PageRef : IObject
{ {

View File

@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using isnd.Data.Catalog; using isnd.Data.Packages;
using isnd.Data.Packages.Catalog;
namespace isnd.Data.Historic namespace isnd.Data.Historic
{ {

View File

@ -1,8 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using isnd.Interfaces;
namespace isnd.Data.Catalog namespace isnd.Data.Packages.Catalog
{ {
public class CatalogIndex : IObject public class CatalogIndex : IObject
{ {

View File

@ -1,8 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using isnd.Interfaces;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isnd.Data.Catalog namespace isnd.Data.Packages.Catalog
{ {
public class CatalogLeaf : IObject public class CatalogLeaf : IObject
{ {

View File

@ -1,7 +1,7 @@
using System; using System;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isnd.Data.Catalog namespace isnd.Interfaces
{ {
public interface IObject public interface IObject
{ {

View File

@ -1,4 +1,4 @@
namespace isnd.Data.Catalog namespace isnd.Data.Packages.Catalog
{ {
public class PackageDetail : CatalogLeaf public class PackageDetail : CatalogLeaf
{ {

View File

@ -1,8 +1,9 @@
using System; using System;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using isnd.Interfaces;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isnd.Data.Catalog namespace isnd.Data.Packages.Catalog
{ {
/// <summary> /// <summary>
/// An presence of package in a catalog, /// An presence of package in a catalog,

View File

@ -1,8 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using isnd.Interfaces;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isnd.Data.Catalog namespace isnd.Data.Packages.Catalog
{ {
public class Page : IObject public class Page : IObject
{ {

View File

@ -3,8 +3,9 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json; using Newtonsoft.Json;
using isnd.Interfaces;
namespace isnd.Data.Catalog namespace isnd.Data.Packages
{ {
public enum PackageAction public enum PackageAction
{ {

View File

@ -2,10 +2,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using isnd.Data.Catalog; using isnd.Interfaces;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isnd.Data namespace isnd.Data.Packages
{ {
public class Package : IObject public class Package : IObject
{ {

View File

@ -1,7 +1,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using isn.abst; using isn.abst;
using isnd.Data.Catalog; using isnd.Data.Packages;
using isnd.Data.Packages.Catalog;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isnd.Data namespace isnd.Data

View File

@ -3,7 +3,8 @@ using System.Threading.Tasks;
using isn.Abstract; using isn.Abstract;
using isnd.Controllers; using isnd.Controllers;
using isnd.Data; using isnd.Data;
using isnd.Data.Catalog; using isnd.Data.Packages;
using isnd.Data.Packages.Catalog;
using isnd.Services; using isnd.Services;
using isnd.ViewModels; using isnd.ViewModels;
using NuGet.Versioning; using NuGet.Versioning;

View File

@ -6,7 +6,8 @@ using System.Threading.Tasks;
using isn.Abstract; using isn.Abstract;
using isnd.Controllers; using isnd.Controllers;
using isnd.Data; using isnd.Data;
using isnd.Data.Catalog; using isnd.Data.Packages;
using isnd.Data.Packages.Catalog;
using isnd.Entities; using isnd.Entities;
using isnd.Helpers; using isnd.Helpers;
using isnd.Interfaces; using isnd.Interfaces;
@ -48,7 +49,7 @@ namespace isnd.Services
Comment = "Package Publish service" Comment = "Package Publish service"
}); });
// under dev, only leash in release mode // under dev, only leash in release mode
if (unleashClient.IsEnabled("pkg-get", false)) if (unleashClient.IsEnabled("pkg-get", true))
res.Add( res.Add(
new Resource new Resource
{ {
@ -56,7 +57,7 @@ namespace isnd.Services
Type = "PackageBaseAddress/3.0.0", Type = "PackageBaseAddress/3.0.0",
Comment = "Package Base Address service" Comment = "Package Base Address service"
}); });
if (unleashClient.IsEnabled("pkg-autocomplete", false)) if (unleashClient.IsEnabled("pkg-autocomplete", true))
res.Add( res.Add(
new Resource new Resource
{ {
@ -72,7 +73,7 @@ namespace isnd.Services
Type = "SearchQueryService/" + BASE_API_LEVEL, Type = "SearchQueryService/" + BASE_API_LEVEL,
Comment = "Search Query service" Comment = "Search Query service"
}); });
if (unleashClient.IsEnabled("pkg-catalog", false)) if (unleashClient.IsEnabled("pkg-catalog", true))
res.Add( res.Add(
new Resource new Resource
{ {
@ -81,13 +82,42 @@ namespace isnd.Services
Comment = "Package Catalog Index" Comment = "Package Catalog Index"
}); });
/* FIXME res.Add( /* FIXME */
res.Add(
new Resource new Resource
{ {
Id = extUrl + ApiConfig.Registration, Id = extUrl + "v" + BASE_API_LEVEL + "/" + ApiConfig.Registration,
Type = "RegistrationsBaseUrl",
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
});
res.Add(
new Resource
{
Id = extUrl + "v3.0.0-beta/" + ApiConfig.Registration,
Type = "RegistrationsBaseUrl/3.0.0-beta",
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
});
res.Add(
new Resource
{
Id = extUrl + "v3.0.0-rc/" + ApiConfig.Registration,
Type = "RegistrationsBaseUrl/3.0.0-rc",
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
});
res.Add(new Resource
{
Id = extUrl + "v3.4.0/" + ApiConfig.Registration,
Type = "RegistrationsBaseUrl/3.4.0",
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
});
res.Add(new Resource
{
Id = extUrl + "v3.6.0/" + ApiConfig.Registration,
Type = "RegistrationsBaseUrl/3.6.0", Type = "RegistrationsBaseUrl/3.6.0",
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages." Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
}); */ });
return res; return res;
} }
@ -97,7 +127,6 @@ namespace isnd.Services
{ {
var scope = dbContext.Packages var scope = dbContext.Packages
.Include(p => p.Versions)
.Where( .Where(
p => (PackageIdHelpers.CamelCaseMatch(p.Id, query) || PackageIdHelpers.SeparatedByMinusMatch(p.Id, query)) p => (PackageIdHelpers.CamelCaseMatch(p.Id, query) || PackageIdHelpers.SeparatedByMinusMatch(p.Id, query))
&& (prerelease || p.Versions.Any(v => !v.IsPrerelease)) && (prerelease || p.Versions.Any(v => !v.IsPrerelease))
@ -258,7 +287,8 @@ namespace isnd.Services
public async Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type) public async Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type)
{ {
// TODO deletion on disk // TODO deletion on disk
var commit = new Commit{ var commit = new Commit
{
Action = PackageAction.DeletePackage, Action = PackageAction.DeletePackage,
TimeStamp = DateTime.Now TimeStamp = DateTime.Now
}; };

View File

@ -109,13 +109,14 @@ namespace isnd
Microsoft.AspNetCore.Hosting.IHostingEnvironment env, Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
ApplicationDbContext dbContext) ApplicationDbContext dbContext)
{ {
// app.UseForwardedHeaders(); app.UseForwardedHeaders();
// .UseHttpsRedirection(); // if have a cert : app.UseHttpsRedirection();
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
app.UseMigrationsEndPoint(); app.UseMigrationsEndPoint();
app.UseBrowserLink();
} }
else else
{ {

View File

@ -1,4 +1,5 @@
using isnd.Data; using isnd.Data;
using isnd.Data.Packages;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isnd.ViewModels namespace isnd.ViewModels

View File

@ -1,4 +1,5 @@
using isnd.Data; using isnd.Data;
using isnd.Data.Packages;
namespace isnd.Services namespace isnd.Services
{ {

View File

@ -10,6 +10,7 @@ using isn.Abstract;
using System.Linq; using System.Linq;
using Xunit; using Xunit;
using isn.abst; using isn.abst;
using isnd.Entities;
namespace isn.tests namespace isn.tests
{ {
@ -47,7 +48,7 @@ dataTable.Rows.Add(dataRow);
[Fact] [Fact]
public async Task TestHttpClient() public async Task TestHttpClient()
{ {
string url = "http://isn.pschneider.fr/index.json"; string url = "http://isn.pschneider.fr/" + ApiConfig.Base;
HttpClient client = new HttpClient(); HttpClient client = new HttpClient();
// var json = await client.GetStringAsync(new System.Uri(url)); // var json = await client.GetStringAsync(new System.Uri(url));
var response = await client.GetAsync(url); var response = await client.GetAsync(url);