refacts
This commit is contained in:
@ -1,33 +1,23 @@
|
|||||||
<Properties StartupConfiguration="{9D758F00-17FF-433D-B088-F9C2D97C9BD1}|Default">
|
<Properties StartupConfiguration="{9D758F00-17FF-433D-B088-F9C2D97C9BD1}|Default">
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="src/isn/Program.cs">
|
<MonoDevelop.Ide.Workbench ActiveDocument="src/isnd/isnd.csproj">
|
||||||
<Files>
|
<Files>
|
||||||
<File FileName="src/isn/Program.cs" Line="66" Column="10" />
|
<File FileName="src/isn/Program.cs" Line="55" Column="48" />
|
||||||
|
<File FileName="src/isnd/isnd.csproj" Line="15" Column="56" />
|
||||||
</Files>
|
</Files>
|
||||||
<Pads>
|
<Pads>
|
||||||
<Pad Id="ProjectPad">
|
<Pad Id="ProjectPad">
|
||||||
<State name="__root__">
|
<State name="__root__">
|
||||||
<Node name="isn" expanded="True">
|
<Node name="isn" expanded="True">
|
||||||
<Node name="src" expanded="True">
|
<Node name="src" expanded="True">
|
||||||
<Node name="isn" expanded="True" selected="True" />
|
<Node name="isnd" selected="True" />
|
||||||
<Node name="isn.abst" expanded="True" />
|
|
||||||
</Node>
|
|
||||||
<Node name="test" expanded="True">
|
|
||||||
<Node name="isnd.tests" expanded="True" />
|
|
||||||
</Node>
|
|
||||||
</Node>
|
|
||||||
</State>
|
|
||||||
</Pad>
|
|
||||||
<Pad Id="MonoDevelop.UnitTesting.TestPad">
|
|
||||||
<State name="__root__">
|
|
||||||
<Node name="isn" expanded="True">
|
|
||||||
<Node name="test" expanded="True">
|
|
||||||
<Node name="isn.tests" selected="True" />
|
|
||||||
</Node>
|
</Node>
|
||||||
|
<Node name="test" expanded="True" />
|
||||||
</Node>
|
</Node>
|
||||||
</State>
|
</State>
|
||||||
</Pad>
|
</Pad>
|
||||||
</Pads>
|
</Pads>
|
||||||
</MonoDevelop.Ide.Workbench>
|
</MonoDevelop.Ide.Workbench>
|
||||||
|
<MonoDevelop.Ide.ItemProperties.src.isnd PreferredExecutionTarget="MonoDevelop.Default" />
|
||||||
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
|
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
|
||||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||||
<MonoDevelop.Ide.ItemProperties.test.isnd.tests PreferredExecutionTarget="MonoDevelop.Default" />
|
<MonoDevelop.Ide.ItemProperties.test.isnd.tests PreferredExecutionTarget="MonoDevelop.Default" />
|
||||||
@ -35,4 +25,5 @@
|
|||||||
<BreakpointStore />
|
<BreakpointStore />
|
||||||
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
<MultiItemStartupConfigurations />
|
<MultiItemStartupConfigurations />
|
||||||
|
<MonoDevelop.Ide.ItemProperties.src.isn PreferredExecutionTarget="MonoDevelop.Default" />
|
||||||
</Properties>
|
</Properties>
|
8
src/isn.abst/Constants.cs
Normal file
8
src/isn.abst/Constants.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace isn.abst
|
||||||
|
{
|
||||||
|
public static class Constants
|
||||||
|
{
|
||||||
|
public const string PaquetFileEstension = "nupkg";
|
||||||
|
public const string SpecFileEstension = "nuspec";
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace isnd.Attributes
|
namespace isnd.Attributes
|
||||||
{
|
{
|
||||||
internal class SafeNameAttribute : ValidationAttribute
|
public class SafeNameAttribute : ValidationAttribute
|
||||||
{
|
{
|
||||||
public override bool IsValid(object value)
|
public override bool IsValid(object value)
|
||||||
{
|
{
|
@ -6,7 +6,7 @@ using System.Linq;
|
|||||||
using isnd.ViewModels;
|
using isnd.ViewModels;
|
||||||
using Unleash;
|
using Unleash;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace isnd.Controllers
|
namespace isnd.Controllers
|
||||||
{
|
{
|
||||||
@ -27,7 +27,10 @@ namespace isnd.Controllers
|
|||||||
{
|
{
|
||||||
|
|
||||||
return View(new HomeIndexViewModel{
|
return View(new HomeIndexViewModel{
|
||||||
PkgCount = _dbContext.Packages.Count(),
|
PkgCount = _dbContext.Packages
|
||||||
|
.Include(p => p.Versions)
|
||||||
|
.Where(p => p.Versions.Count > 0)
|
||||||
|
.Count(),
|
||||||
UnleashClient = _unleashĈlient
|
UnleashClient = _unleashĈlient
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -17,26 +17,17 @@ namespace isnd.Controllers
|
|||||||
int skip = 0,
|
int skip = 0,
|
||||||
int take = 25)
|
int take = 25)
|
||||||
{
|
{
|
||||||
CheckParams(take, semVerLevel);
|
if (take > maxTake)
|
||||||
if (ModelState.ErrorCount > 0) return BadRequest(ModelState);
|
|
||||||
|
|
||||||
return Ok(packageManager.AutoComplete(id,skip,take,prerelease,packageType));
|
|
||||||
}
|
|
||||||
protected void CheckParams(int maxTake)
|
|
||||||
{
|
|
||||||
if (maxTake > maxTake)
|
|
||||||
{
|
{
|
||||||
ModelState.AddModelError("take", "Maximum exceeded");
|
ModelState.AddModelError("take", "Maximum exceeded");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected void CheckParams(int take, string semVerLevel)
|
|
||||||
{
|
|
||||||
CheckParams(take);
|
|
||||||
if (semVerLevel != PackageManager.BASE_API_LEVEL)
|
if (semVerLevel != PackageManager.BASE_API_LEVEL)
|
||||||
{
|
{
|
||||||
ModelState.AddModelError("semVerLevel", PackageManager.BASE_API_LEVEL + " expected");
|
ModelState.AddModelError("semVerLevel", PackageManager.BASE_API_LEVEL + " expected");
|
||||||
}
|
}
|
||||||
|
if (ModelState.ErrorCount > 0) return BadRequest(ModelState);
|
||||||
|
|
||||||
|
return Ok(packageManager.AutoComplete(id,skip,take,prerelease,packageType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ using isnd.Services;
|
|||||||
using isnd.Entities;
|
using isnd.Entities;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace isnd.Controllers
|
namespace isnd.Controllers
|
||||||
{
|
{
|
||||||
@ -27,8 +28,8 @@ namespace isnd.Controllers
|
|||||||
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
|
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{*lower}")]
|
[HttpGet(_pkgRootPrefix + ApiConfig.Registration + "/{id}/{*lower}")]
|
||||||
public async Task<IActionResult> CatalogLeafAsync(string id, string lower)
|
public async Task<IActionResult> CatalogRegistrationAsync(string id, string lower)
|
||||||
{
|
{
|
||||||
string pkgType = ParamHelpers.Optional(ref lower);
|
string pkgType = ParamHelpers.Optional(ref lower);
|
||||||
var pkgVersion = await dbContext.PackageVersions
|
var pkgVersion = await dbContext.PackageVersions
|
||||||
@ -39,21 +40,35 @@ namespace isnd.Controllers
|
|||||||
v.Type == pkgType
|
v.Type == pkgType
|
||||||
);
|
);
|
||||||
if (pkgVersion == null) return NotFound();
|
if (pkgVersion == null) return NotFound();
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{version}/{*lower}")]
|
||||||
|
public async Task<IActionResult> CatalogLeafAsync(string id, string version, string lower)
|
||||||
|
{
|
||||||
|
var pkgvs = this.packageManager.GetCatalogLeaf(id, version, lower)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
if (pkgvs.Count()==0) return NotFound();
|
||||||
|
|
||||||
|
List <string> types = pkgvs.Select(
|
||||||
|
v => v.Type ?? "Dependency"
|
||||||
|
).Distinct().ToList();
|
||||||
|
if (!types.Contains("PackageDelete"))
|
||||||
|
types.Add("PackageDetails");
|
||||||
|
var pub = pkgvs.Last().Package.CommitTimeStamp;
|
||||||
|
var firstpub = pkgvs.First().Package.CommitTimeStamp;
|
||||||
|
|
||||||
var pub = await dbContext.Commits
|
|
||||||
.Include(c => c.Versions)
|
|
||||||
.OrderBy(c => c.CommitTimeStamp)
|
|
||||||
.SingleOrDefaultAsync
|
|
||||||
(
|
|
||||||
c => c.Action == PackageAction.PublishPackage
|
|
||||||
&& c.Versions.Contains(pkgVersion)
|
|
||||||
);
|
|
||||||
return Ok(new CatalogLeaf
|
return Ok(new CatalogLeaf
|
||||||
{
|
{
|
||||||
CommitId = id,
|
CommitId = id,
|
||||||
Id = pkgVersion.PackageId,
|
Id = id,
|
||||||
CommitTimeStamp = pkgVersion.LatestCommit.CommitTimeStamp
|
CommitTimeStamp = firstpub,
|
||||||
|
Version = version,
|
||||||
|
Published = pub,
|
||||||
|
RefType = types.ToArray(),
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
38
src/isnd/Controllers/Packages/CatalogRegistration.cs
Normal file
38
src/isnd/Controllers/Packages/CatalogRegistration.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace isnd.Controllers
|
||||||
|
{
|
||||||
|
public class CatalogRegistration
|
||||||
|
{
|
||||||
|
[JsonProperty("@id")]
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
"@id": "https://api.nuget.org/v3/registration3/nuget.versioning/4.3.0.json",
|
||||||
|
"catalogEntry": "https://api.nuget.org/v3/catalog0/data/2017.08.11.18.24.22/nuget.versioning.4.3.0.json",
|
||||||
|
"listed": true,
|
||||||
|
"packageContent": "https://api.nuget.org/v3-flatcontainer/nuget.versioning/4.3.0/nuget.versioning.4.3.0.nupkg",
|
||||||
|
"published": "2017-08-11T18:24:14.36+00:00",
|
||||||
|
"registration": "https://api.nuget.org/v3/registration3/nuget.versioning/index.json"
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
[JsonProperty("catalogEntry")]
|
||||||
|
public string CatalogEntry { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("listed")]
|
||||||
|
public bool Listed { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonProperty("packageContent")]
|
||||||
|
public string PackageContent { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("published")]
|
||||||
|
public DateTime CommitTimeStamp { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("registration")]
|
||||||
|
public string registration { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -3,20 +3,23 @@ using System.IO;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using isnd.Attributes;
|
using isnd.Attributes;
|
||||||
using isnd.Entities;
|
using isnd.Entities;
|
||||||
|
using isn.abst;
|
||||||
|
|
||||||
namespace isnd.Controllers
|
namespace isnd.Controllers
|
||||||
{
|
{
|
||||||
|
|
||||||
public partial class PackagesController
|
public partial class PackagesController
|
||||||
{
|
{
|
||||||
// Web get nupkg
|
// Web get the paquet
|
||||||
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/{idf}-{lowerf}.nupkg")]
|
[HttpGet(_pkgRootPrefix + ApiConfig.GetPackage + "/{id}/{lower}/{idf}-{lowerf}."
|
||||||
|
+ Constants.PaquetFileEstension)]
|
||||||
public IActionResult GetPackage(
|
public IActionResult GetPackage(
|
||||||
[FromRoute][SafeName][Required] string id,
|
[FromRoute][SafeName][Required] string id,
|
||||||
[FromRoute][SafeName][Required] string lower,
|
[FromRoute][SafeName][Required] string lower,
|
||||||
[FromRoute] string idf, [FromRoute] string lowerf)
|
[FromRoute] string idf, [FromRoute] string lowerf)
|
||||||
{
|
{
|
||||||
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
||||||
id, lower, $"{id}-{lower}.nupkg"
|
id, lower, $"{id}-{lower}." + Constants.PaquetFileEstension
|
||||||
);
|
);
|
||||||
|
|
||||||
FileInfo pkgfi = new FileInfo(pkgpath);
|
FileInfo pkgfi = new FileInfo(pkgpath);
|
||||||
@ -29,7 +32,8 @@ namespace isnd.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Web get spec
|
// Web get spec
|
||||||
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/{idf}-{lowerf}.nuspec")]
|
[HttpGet(_pkgRootPrefix + ApiConfig.GetNuspec + "/{id}/{lower}/{idf}-{lowerf}."
|
||||||
|
+ Constants.SpecFileEstension)]
|
||||||
public IActionResult GetNuspec(
|
public IActionResult GetNuspec(
|
||||||
[FromRoute][SafeName][Required] string id,
|
[FromRoute][SafeName][Required] string id,
|
||||||
[FromRoute][SafeName][Required] string lower,
|
[FromRoute][SafeName][Required] string lower,
|
||||||
@ -37,7 +41,7 @@ namespace isnd.Controllers
|
|||||||
[FromRoute][SafeName][Required] string lowerf)
|
[FromRoute][SafeName][Required] string lowerf)
|
||||||
{
|
{
|
||||||
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
||||||
id, lower, $"{id}.nuspec");
|
id, lower, $"{id}." + Constants.SpecFileEstension);
|
||||||
|
|
||||||
FileInfo pkgfi = new FileInfo(pkgpath);
|
FileInfo pkgfi = new FileInfo(pkgpath);
|
||||||
if (!pkgfi.Exists)
|
if (!pkgfi.Exists)
|
||||||
|
@ -6,7 +6,7 @@ namespace isnd.Controllers
|
|||||||
{
|
{
|
||||||
public partial class PackagesController
|
public partial class PackagesController
|
||||||
{
|
{
|
||||||
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/index.json")]
|
[HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/index.json")]
|
||||||
public IActionResult GetVersions(
|
public IActionResult GetVersions(
|
||||||
string id,
|
string id,
|
||||||
string lower,
|
string lower,
|
||||||
|
@ -16,6 +16,7 @@ using isnd.Helpers;
|
|||||||
using isnd.Entities;
|
using isnd.Entities;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using isnd.Data.Catalog;
|
using isnd.Data.Catalog;
|
||||||
|
using isn.abst;
|
||||||
|
|
||||||
namespace isnd.Controllers
|
namespace isnd.Controllers
|
||||||
{
|
{
|
||||||
@ -52,7 +53,7 @@ namespace isnd.Controllers
|
|||||||
{
|
{
|
||||||
string initpath = Path.Combine(Environment.GetEnvironmentVariable("TEMP") ??
|
string initpath = Path.Combine(Environment.GetEnvironmentVariable("TEMP") ??
|
||||||
Environment.GetEnvironmentVariable("TMP") ?? "/tmp",
|
Environment.GetEnvironmentVariable("TMP") ?? "/tmp",
|
||||||
$"isn-{Guid.NewGuid()}.nupkg");
|
$"isn-{Guid.NewGuid()}."+Constants.PaquetFileEstension);
|
||||||
|
|
||||||
using (FileStream fw = new FileStream(initpath, FileMode.Create))
|
using (FileStream fw = new FileStream(initpath, FileMode.Create))
|
||||||
{
|
{
|
||||||
@ -63,14 +64,14 @@ namespace isnd.Controllers
|
|||||||
{
|
{
|
||||||
var archive = new ZipArchive(fw);
|
var archive = new ZipArchive(fw);
|
||||||
|
|
||||||
var nuspec = archive.Entries.FirstOrDefault(e => e.FullName.EndsWith(".nuspec"));
|
var spec = archive.Entries.FirstOrDefault(e => e.FullName.EndsWith("." + Constants.SpecFileEstension));
|
||||||
if (nuspec == null) return BadRequest(new { error = "no nuspec from archive" });
|
if (spec == null) return BadRequest(new { error = "no " + Constants.SpecFileEstension + " from archive" });
|
||||||
string pkgpath;
|
string pkgpath;
|
||||||
NuGetVersion version;
|
NuGetVersion version;
|
||||||
string pkgid;
|
string pkgid;
|
||||||
string fullpath;
|
string fullpath;
|
||||||
|
|
||||||
using (var specstr = nuspec.Open())
|
using (var specstr = spec.Open())
|
||||||
{
|
{
|
||||||
NuspecCoreReader reader = new NuspecCoreReader(specstr);
|
NuspecCoreReader reader = new NuspecCoreReader(specstr);
|
||||||
|
|
||||||
@ -82,29 +83,29 @@ namespace isnd.Controllers
|
|||||||
string pkgidpath = Path.Combine(isndSettings.PackagesRootDir,
|
string pkgidpath = Path.Combine(isndSettings.PackagesRootDir,
|
||||||
pkgid);
|
pkgid);
|
||||||
pkgpath = Path.Combine(pkgidpath, version.ToFullString());
|
pkgpath = Path.Combine(pkgidpath, version.ToFullString());
|
||||||
string name = $"{pkgid}-{version}.nupkg";
|
string name = $"{pkgid}-{version}."+Constants.PaquetFileEstension;
|
||||||
fullpath = Path.Combine(pkgpath, name);
|
fullpath = Path.Combine(pkgpath, name);
|
||||||
|
|
||||||
var destpkgiddir = new DirectoryInfo(pkgidpath);
|
var destpkgiddir = new DirectoryInfo(pkgidpath);
|
||||||
Package package = dbContext.Packages.SingleOrDefault(p => p.Id == pkgid);
|
Package pkg = dbContext.Packages.SingleOrDefault(p => p.Id == pkgid);
|
||||||
if (package != null)
|
if (pkg != null)
|
||||||
{
|
{
|
||||||
if (package.OwnerId != apikey.UserId)
|
if (pkg.OwnerId != apikey.UserId)
|
||||||
{
|
{
|
||||||
return new ForbidResult();
|
return new ForbidResult();
|
||||||
}
|
}
|
||||||
package.Description = pkgdesc;
|
pkg.Description = pkgdesc;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
package = new Package
|
pkg = new Package
|
||||||
{
|
{
|
||||||
Id = pkgid,
|
Id = pkgid,
|
||||||
Description = pkgdesc,
|
Description = pkgdesc,
|
||||||
OwnerId = apikey.UserId,
|
OwnerId = apikey.UserId,
|
||||||
LatestVersion = commit
|
LatestVersion = commit
|
||||||
};
|
};
|
||||||
dbContext.Packages.Add(package);
|
dbContext.Packages.Add(pkg);
|
||||||
}
|
}
|
||||||
if (!destpkgiddir.Exists) destpkgiddir.Create();
|
if (!destpkgiddir.Exists) destpkgiddir.Create();
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ namespace isnd.Controllers
|
|||||||
// mais si elle ne l'est pas en base de donnéés,
|
// mais si elle ne l'est pas en base de donnéés,
|
||||||
// on remplace la version sur disque.
|
// on remplace la version sur disque.
|
||||||
var pkgv = dbContext.PackageVersions.Where(
|
var pkgv = dbContext.PackageVersions.Where(
|
||||||
v => v.PackageId == package.Id
|
v => v.PackageId == pkg.Id
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pkgv !=null && pkgv.Count()==0)
|
if (pkgv !=null && pkgv.Count()==0)
|
||||||
@ -136,7 +137,7 @@ namespace isnd.Controllers
|
|||||||
files.Add(name);
|
files.Add(name);
|
||||||
string fullstringversion = version.ToFullString();
|
string fullstringversion = version.ToFullString();
|
||||||
var pkgvers = dbContext.PackageVersions.Where
|
var pkgvers = dbContext.PackageVersions.Where
|
||||||
(v => v.PackageId == package.Id && v.FullString == fullstringversion);
|
(v => v.PackageId == pkg.Id && v.FullString == fullstringversion);
|
||||||
if (pkgvers.Count() > 0)
|
if (pkgvers.Count() > 0)
|
||||||
{
|
{
|
||||||
foreach (var v in pkgvers.ToArray())
|
foreach (var v in pkgvers.ToArray())
|
||||||
@ -147,7 +148,7 @@ namespace isnd.Controllers
|
|||||||
dbContext.PackageVersions.Add
|
dbContext.PackageVersions.Add
|
||||||
(new PackageVersion{
|
(new PackageVersion{
|
||||||
|
|
||||||
Package = package,
|
Package = pkg,
|
||||||
Major = version.Major,
|
Major = version.Major,
|
||||||
Minor = version.Minor,
|
Minor = version.Minor,
|
||||||
Patch = version.Patch,
|
Patch = version.Patch,
|
||||||
@ -161,7 +162,7 @@ namespace isnd.Controllers
|
|||||||
{
|
{
|
||||||
var pkgver = new PackageVersion
|
var pkgver = new PackageVersion
|
||||||
{
|
{
|
||||||
Package = package,
|
Package = pkg,
|
||||||
Major = version.Major,
|
Major = version.Major,
|
||||||
Minor = version.Minor,
|
Minor = version.Minor,
|
||||||
Patch = version.Patch,
|
Patch = version.Patch,
|
||||||
@ -176,7 +177,7 @@ namespace isnd.Controllers
|
|||||||
await dbContext.SaveChangesAsync();
|
await dbContext.SaveChangesAsync();
|
||||||
packageManager.ÛpdateCatalogFor(commit);
|
packageManager.ÛpdateCatalogFor(commit);
|
||||||
|
|
||||||
logger.LogInformation($"new package : {nuspec.Name}");
|
logger.LogInformation($"new paquet : {spec.Name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
using (var shacrypto = System.Security.Cryptography.SHA512.Create())
|
using (var shacrypto = System.Security.Cryptography.SHA512.Create())
|
||||||
@ -194,12 +195,12 @@ namespace isnd.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string nuspecfullpath = Path.Combine(pkgpath, pkgid + ".nuspec");
|
string nuspecfullpath = Path.Combine(pkgpath, pkgid + "." + Constants.SpecFileEstension);
|
||||||
FileInfo nfpi = new FileInfo(nuspecfullpath);
|
FileInfo nfpi = new FileInfo(nuspecfullpath);
|
||||||
|
|
||||||
if (nfpi.Exists)
|
if (nfpi.Exists)
|
||||||
nfpi.Delete();
|
nfpi.Delete();
|
||||||
nuspec.ExtractToFile(nuspecfullpath);
|
spec.ExtractToFile(nuspecfullpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace isnd.Data.Catalog
|
|||||||
{
|
{
|
||||||
|
|
||||||
[JsonProperty("@type")]
|
[JsonProperty("@type")]
|
||||||
public List<string> RefType { get; set; }
|
public string[] RefType { get; set; }
|
||||||
|
|
||||||
[JsonProperty("commitId")]
|
[JsonProperty("commitId")]
|
||||||
public string CommitId { get; set; }
|
public string CommitId { get; set; }
|
||||||
|
@ -11,7 +11,7 @@ namespace isnd.Data
|
|||||||
{
|
{
|
||||||
[Key][Required]
|
[Key][Required]
|
||||||
[StringLength(1024)]
|
[StringLength(1024)]
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[ForeignKey("Owner")]
|
[ForeignKey("Owner")]
|
||||||
@ -30,8 +30,8 @@ namespace isnd.Data
|
|||||||
public virtual List<PackageVersion> Versions { get; set; }
|
public virtual List<PackageVersion> Versions { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Latest package version put, or post,
|
/// Latest version at put, posted,
|
||||||
/// or { delete when no more active version }.
|
/// or even deletion when no more active version.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
[Required][JsonIgnore]
|
[Required][JsonIgnore]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using isn.abst;
|
||||||
using isnd.Data.Catalog;
|
using isnd.Data.Catalog;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
@ -41,8 +42,10 @@ namespace isnd.Data
|
|||||||
public string CommitId { get => CommitNId.ToString(); }
|
public string CommitId { get => CommitNId.ToString(); }
|
||||||
|
|
||||||
public virtual Commit LatestCommit{ get; set; }
|
public virtual Commit LatestCommit{ get; set; }
|
||||||
public string NugetLink => $"/package/{PackageId}/{FullString}/{PackageId}-{FullString}.nupkg";
|
public string NugetLink => $"/{Constants.PaquetFileEstension}/{PackageId}/{FullString}/{PackageId}-{FullString}."
|
||||||
public string NuspecLink => $"/package/{PackageId}/{FullString}/{PackageId}-{FullString}.nuspec";
|
+ Constants.PaquetFileEstension;
|
||||||
|
public string NuspecLink => $"/{Constants.SpecFileEstension}/{PackageId}/{FullString}/{PackageId}-{FullString}."
|
||||||
|
+ Constants.SpecFileEstension;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,21 +1,20 @@
|
|||||||
|
using isn.abst;
|
||||||
|
|
||||||
namespace isnd.Entities
|
namespace isnd.Entities
|
||||||
{
|
{
|
||||||
public static class ApiConfig
|
public static class ApiConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
public const string Publish = "put";
|
public const string Publish = "put";
|
||||||
public const string Base = "index.json";
|
public const string Base = "index.json";
|
||||||
public const string Catalog = "catalog";
|
public const string Catalog = "catalog";
|
||||||
public const string CatalogPage = "catalog-page";
|
public const string CatalogPage = "catalog-page";
|
||||||
public const string Get = "package";
|
public const string GetPackage = Constants.PaquetFileEstension;
|
||||||
|
public const string GetVersion = "version";
|
||||||
public const string Search = "search";
|
public const string Search = "search";
|
||||||
public const string AutoComplete = "autocomplete";
|
public const string AutoComplete = "autocomplete";
|
||||||
public const string CatalogLeaf = "catalog-leaf";
|
public const string CatalogLeaf = "catalog-leaf";
|
||||||
public const string CatalogPackageDetail = "package-detail";
|
|
||||||
|
|
||||||
public const string Delete = "delete";
|
public const string Delete = "delete";
|
||||||
|
|
||||||
public const string Registration = "registration";
|
public const string Registration = "registration";
|
||||||
|
internal const string GetNuspec = Constants.SpecFileEstension;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,6 +22,7 @@ namespace isnd.Interfaces
|
|||||||
void ÛpdateCatalogFor(Commit commit);
|
void ÛpdateCatalogFor(Commit commit);
|
||||||
Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type);
|
Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type);
|
||||||
Task<PackageVersion> GetPackageAsync(string pkgid, string version, string type);
|
Task<PackageVersion> GetPackageAsync(string pkgid, string version, string type);
|
||||||
|
IEnumerable<PackageVersion> GetCatalogLeaf(string id, string version, string lower);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using isn.Abstract;
|
using isn.Abstract;
|
||||||
|
using isnd.Controllers;
|
||||||
using isnd.Data;
|
using isnd.Data;
|
||||||
using isnd.Data.Catalog;
|
using isnd.Data.Catalog;
|
||||||
using isnd.Entities;
|
using isnd.Entities;
|
||||||
@ -51,8 +52,8 @@ namespace isnd.Services
|
|||||||
res.Add(
|
res.Add(
|
||||||
new Resource
|
new Resource
|
||||||
{
|
{
|
||||||
Id = extUrl + ApiConfig.Base,
|
Id = extUrl + ApiConfig.GetPackage,
|
||||||
Type = "PackageBaseAddress/" + BASE_API_LEVEL,
|
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", false))
|
||||||
@ -79,14 +80,14 @@ namespace isnd.Services
|
|||||||
Type = "Catalog/"+ BASE_API_LEVEL,
|
Type = "Catalog/"+ BASE_API_LEVEL,
|
||||||
Comment = "Package Catalog Index"
|
Comment = "Package Catalog Index"
|
||||||
});
|
});
|
||||||
if (unleashClient.IsEnabled("pkg-registration", false))
|
|
||||||
res.Add(
|
/* FIXME res.Add(
|
||||||
new Resource
|
new Resource
|
||||||
{
|
{
|
||||||
Id = extUrl + ApiConfig.Registration,
|
Id = extUrl + ApiConfig.Registration,
|
||||||
Type = "Catalog/" + BASE_API_LEVEL,
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +257,7 @@ 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 package 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
|
||||||
@ -285,5 +286,24 @@ namespace isnd.Services
|
|||||||
v.Type == type
|
v.Type == type
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<CatalogRegistration> GetPackageRegistrationAsync(string pkgid, string version, string type)
|
||||||
|
{
|
||||||
|
var pkgVersion = await GetPackageAsync(pkgid, version, type);
|
||||||
|
return new CatalogRegistration
|
||||||
|
{
|
||||||
|
Id = pkgVersion.PackageId,
|
||||||
|
CommitTimeStamp = pkgVersion.LatestCommit.CommitTimeStamp,
|
||||||
|
PackageContent = extUrl + pkgVersion.FullString
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<PackageVersion> GetCatalogLeaf(string id, string version, string lower)
|
||||||
|
{
|
||||||
|
return dbContext.PackageVersions
|
||||||
|
.Include(v=>v.Package)
|
||||||
|
.Where(v => v.PackageId == id && v.FullString == version
|
||||||
|
&& (lower == null || lower == v.Type));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ using Newtonsoft.Json;
|
|||||||
using isn.Abstract;
|
using isn.Abstract;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using isn.abst;
|
||||||
|
|
||||||
namespace isn.tests
|
namespace isn.tests
|
||||||
{
|
{
|
||||||
@ -60,7 +61,8 @@ dataTable.Rows.Add(dataRow);
|
|||||||
public void TestPush()
|
public void TestPush()
|
||||||
{
|
{
|
||||||
Program.LoadConfig();
|
Program.LoadConfig();
|
||||||
var report = Program.PushPkg(new string[] { "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg" });
|
var report = Program.PushPkg(new string[] { "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8."
|
||||||
|
+ Constants.PaquetFileEstension });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -10,24 +10,16 @@
|
|||||||
<Version>0.1.175</Version>
|
<Version>0.1.175</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="XunitXml.TestLogger" Version="3.0.70"/>
|
<PackageReference Include="XunitXml.TestLogger" Version="3.0.70" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
|
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
|
||||||
<PackageReference Include="xunit.runner.reporters" Version="2.4.1" />
|
<PackageReference Include="xunit.runner.reporters" Version="2.4.1" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||||
<PackageToolReference Include="xunit.runner.console" Version="2.4.1" PrivateAssets="All" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\isnd\isnd.csproj" />
|
<ProjectReference Include="..\..\src\isnd\isnd.csproj" />
|
||||||
<ProjectReference Include="..\..\src\isn\isn.csproj" />
|
<ProjectReference Include="..\..\src\isn\isn.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<MyTestingConfigFiles Include="appsettings.Testing.json" />
|
|
||||||
</ItemGroup>
|
|
||||||
<!--
|
|
||||||
<Target Name="CopyTestConfig" AfterTargets="Build">
|
|
||||||
<Copy SourceFiles="@(MyTestingConfigFiles)" DestinationFolder="$(OutputPath)" />
|
|
||||||
</Target>-->
|
|
||||||
</Project>
|
</Project>
|
Reference in New Issue
Block a user