WIP page leaf
This commit is contained in:
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"omnisharp.msbuild": false,
|
||||
"dotnet-test-explorer.testProjectPath": "**/*.sln",
|
||||
"omnisharp.msbuild": true,
|
||||
"dotnet-test-explorer.testProjectPath": "**/*Tests.csproj",
|
||||
"dotnet-test-explorer.runInParallel": false,
|
||||
"dotnet-test-explorer.showCodeLens": true,
|
||||
"dotnet-test-explorer.testArguments": "",
|
||||
@ -46,5 +46,7 @@
|
||||
"database": "isnd",
|
||||
"username": "paul"
|
||||
}
|
||||
]
|
||||
],
|
||||
"omnisharp.disableMSBuildDiagnosticWarning": true,
|
||||
"omnisharp.enableRoslynAnalyzers": false
|
||||
}
|
||||
|
47
README.md
47
README.md
@ -76,3 +76,50 @@ sudo chown -R root.root /usr/local/lib/isn
|
||||
````
|
||||
|
||||
## 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."
|
||||
|
||||
},
|
||||
|
||||
````
|
||||
|
||||
|
@ -25,10 +25,8 @@ namespace isnd.Controllers
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
|
||||
return View(new HomeIndexViewModel{
|
||||
PkgCount = _dbContext.Packages
|
||||
.Include(p => p.Versions)
|
||||
.Where(p => p.Versions.Count > 0)
|
||||
.Count(),
|
||||
UnleashClient = _unleashĈlient
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Helpers;
|
||||
using isnd.Services;
|
||||
using isnd.Entities;
|
||||
@ -28,19 +27,18 @@ namespace isnd.Controllers
|
||||
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Registration + "/{id}/{*lower}")]
|
||||
public async Task<IActionResult> CatalogRegistrationAsync(string id, string lower)
|
||||
[HttpGet(_pkgRootPrefix + "{apiVersion}/" + ApiConfig.Registration + "/{id}/{*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);
|
||||
var pkgVersion = await dbContext.PackageVersions
|
||||
.Include(v => v.LatestCommit)
|
||||
.SingleOrDefaultAsync(
|
||||
v => v.PackageId == id &&
|
||||
v.FullString == lower &&
|
||||
v.Type == pkgType
|
||||
);
|
||||
if (pkgVersion == null) return NotFound();
|
||||
return Ok();
|
||||
var pkgFromname = packageManager.SearchByName(id, 0, 1);
|
||||
if (pkgFromname == null) return NotFound();
|
||||
return Ok(pkgFromname);
|
||||
}
|
||||
|
||||
|
||||
@ -57,15 +55,17 @@ namespace isnd.Controllers
|
||||
).Distinct().ToList();
|
||||
if (!types.Contains("PackageDelete"))
|
||||
types.Add("PackageDetails");
|
||||
var pub = pkgvs.Last().Package.CommitTimeStamp;
|
||||
|
||||
var last = pkgvs.Last();
|
||||
var pub = last.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,
|
||||
CommitTimeStamp = firstpub,
|
||||
Version = version,
|
||||
CommitTimeStamp = pub,
|
||||
Version = last.FullString,
|
||||
Published = pub,
|
||||
RefType = types.ToArray(),
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace isnd.Controllers
|
||||
}
|
||||
|
||||
// Web get spec
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.GetNuspec + "/{id}/{lower}/{idf}-{lowerf}."
|
||||
[HttpGet(_pkgRootPrefix + Constants.SpecFileEstension + "/{id}/{lower}/{idf}-{lowerf}."
|
||||
+ Constants.SpecFileEstension)]
|
||||
public IActionResult GetNuspec(
|
||||
[FromRoute][SafeName][Required] string id,
|
||||
|
@ -6,7 +6,7 @@ namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
{
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/index.json")]
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/" + ApiConfig.Base)]
|
||||
public IActionResult GetVersions(
|
||||
string id,
|
||||
string lower,
|
||||
|
@ -15,8 +15,8 @@ using isnd.Data;
|
||||
using isnd.Helpers;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using isnd.Data.Catalog;
|
||||
using isn.abst;
|
||||
using isnd.Data.Packages;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
@ -6,8 +6,7 @@ using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using isnd.Data;
|
||||
using isnd.Data.ApiKeys;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Data.Historic;
|
||||
using isnd.Data.Packages;
|
||||
|
||||
namespace isnd.Data
|
||||
{
|
||||
|
@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using isnd.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
namespace isnd.Data.Packages.Catalog
|
||||
{
|
||||
public class PageRef : IObject
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Data.Packages;
|
||||
using isnd.Data.Packages.Catalog;
|
||||
|
||||
namespace isnd.Data.Historic
|
||||
{
|
||||
|
@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using isnd.Interfaces;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
namespace isnd.Data.Packages.Catalog
|
||||
{
|
||||
public class CatalogIndex : IObject
|
||||
{
|
@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using isnd.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
namespace isnd.Data.Packages.Catalog
|
||||
{
|
||||
public class CatalogLeaf : IObject
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
namespace isnd.Interfaces
|
||||
{
|
||||
public interface IObject
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
namespace isnd.Data.Catalog
|
||||
namespace isnd.Data.Packages.Catalog
|
||||
{
|
||||
public class PackageDetail : CatalogLeaf
|
||||
{
|
@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using isnd.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
namespace isnd.Data.Packages.Catalog
|
||||
{
|
||||
/// <summary>
|
||||
/// An presence of package in a catalog,
|
@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using isnd.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
namespace isnd.Data.Packages.Catalog
|
||||
{
|
||||
public class Page : IObject
|
||||
{
|
@ -3,8 +3,9 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
using isnd.Interfaces;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
namespace isnd.Data.Packages
|
||||
{
|
||||
public enum PackageAction
|
||||
{
|
@ -2,10 +2,10 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data
|
||||
namespace isnd.Data.Packages
|
||||
{
|
||||
public class Package : IObject
|
||||
{
|
@ -1,7 +1,8 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using isn.abst;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Data.Packages;
|
||||
using isnd.Data.Packages.Catalog;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data
|
@ -3,7 +3,8 @@ using System.Threading.Tasks;
|
||||
using isn.Abstract;
|
||||
using isnd.Controllers;
|
||||
using isnd.Data;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Data.Packages;
|
||||
using isnd.Data.Packages.Catalog;
|
||||
using isnd.Services;
|
||||
using isnd.ViewModels;
|
||||
using NuGet.Versioning;
|
||||
|
@ -6,7 +6,8 @@ using System.Threading.Tasks;
|
||||
using isn.Abstract;
|
||||
using isnd.Controllers;
|
||||
using isnd.Data;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Data.Packages;
|
||||
using isnd.Data.Packages.Catalog;
|
||||
using isnd.Entities;
|
||||
using isnd.Helpers;
|
||||
using isnd.Interfaces;
|
||||
@ -48,7 +49,7 @@ namespace isnd.Services
|
||||
Comment = "Package Publish service"
|
||||
});
|
||||
// under dev, only leash in release mode
|
||||
if (unleashClient.IsEnabled("pkg-get", false))
|
||||
if (unleashClient.IsEnabled("pkg-get", true))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
@ -56,7 +57,7 @@ namespace isnd.Services
|
||||
Type = "PackageBaseAddress/3.0.0",
|
||||
Comment = "Package Base Address service"
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-autocomplete", false))
|
||||
if (unleashClient.IsEnabled("pkg-autocomplete", true))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
@ -72,7 +73,7 @@ namespace isnd.Services
|
||||
Type = "SearchQueryService/" + BASE_API_LEVEL,
|
||||
Comment = "Search Query service"
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-catalog", false))
|
||||
if (unleashClient.IsEnabled("pkg-catalog", true))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
@ -81,13 +82,42 @@ namespace isnd.Services
|
||||
Comment = "Package Catalog Index"
|
||||
});
|
||||
|
||||
/* FIXME res.Add(
|
||||
/* FIXME */
|
||||
res.Add(
|
||||
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",
|
||||
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;
|
||||
}
|
||||
|
||||
@ -97,7 +127,6 @@ namespace isnd.Services
|
||||
{
|
||||
|
||||
var scope = dbContext.Packages
|
||||
.Include(p => p.Versions)
|
||||
.Where(
|
||||
p => (PackageIdHelpers.CamelCaseMatch(p.Id, query) || PackageIdHelpers.SeparatedByMinusMatch(p.Id, query))
|
||||
&& (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)
|
||||
{
|
||||
// TODO deletion on disk
|
||||
var commit = new Commit{
|
||||
var commit = new Commit
|
||||
{
|
||||
Action = PackageAction.DeletePackage,
|
||||
TimeStamp = DateTime.Now
|
||||
};
|
||||
|
@ -109,13 +109,14 @@ namespace isnd
|
||||
Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
|
||||
ApplicationDbContext dbContext)
|
||||
{
|
||||
// app.UseForwardedHeaders();
|
||||
// .UseHttpsRedirection();
|
||||
app.UseForwardedHeaders();
|
||||
// if have a cert : app.UseHttpsRedirection();
|
||||
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseMigrationsEndPoint();
|
||||
app.UseBrowserLink();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using isnd.Data;
|
||||
using isnd.Data.Packages;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.ViewModels
|
||||
|
@ -1,4 +1,5 @@
|
||||
using isnd.Data;
|
||||
using isnd.Data.Packages;
|
||||
|
||||
namespace isnd.Services
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ using isn.Abstract;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using isn.abst;
|
||||
using isnd.Entities;
|
||||
|
||||
namespace isn.tests
|
||||
{
|
||||
@ -47,7 +48,7 @@ dataTable.Rows.Add(dataRow);
|
||||
[Fact]
|
||||
public async Task TestHttpClient()
|
||||
{
|
||||
string url = "http://isn.pschneider.fr/index.json";
|
||||
string url = "http://isn.pschneider.fr/" + ApiConfig.Base;
|
||||
HttpClient client = new HttpClient();
|
||||
// var json = await client.GetStringAsync(new System.Uri(url));
|
||||
var response = await client.GetAsync(url);
|
||||
|
Reference in New Issue
Block a user