refacts
This commit is contained in:
@ -1,33 +1,23 @@
|
||||
<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>
|
||||
<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>
|
||||
<Pads>
|
||||
<Pad Id="ProjectPad">
|
||||
<State name="__root__">
|
||||
<Node name="isn" expanded="True">
|
||||
<Node name="src" expanded="True">
|
||||
<Node name="isn" expanded="True" 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 name="isnd" selected="True" />
|
||||
</Node>
|
||||
<Node name="test" expanded="True" />
|
||||
</Node>
|
||||
</State>
|
||||
</Pad>
|
||||
</Pads>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.ItemProperties.src.isnd PreferredExecutionTarget="MonoDevelop.Default" />
|
||||
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.ItemProperties.test.isnd.tests PreferredExecutionTarget="MonoDevelop.Default" />
|
||||
@ -35,4 +25,5 @@
|
||||
<BreakpointStore />
|
||||
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<MultiItemStartupConfigurations />
|
||||
<MonoDevelop.Ide.ItemProperties.src.isn PreferredExecutionTarget="MonoDevelop.Default" />
|
||||
</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
|
||||
{
|
||||
internal class SafeNameAttribute : ValidationAttribute
|
||||
public class SafeNameAttribute : ValidationAttribute
|
||||
{
|
||||
public override bool IsValid(object value)
|
||||
{
|
@ -6,7 +6,7 @@ using System.Linq;
|
||||
using isnd.ViewModels;
|
||||
using Unleash;
|
||||
using System.Reflection;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
@ -27,7 +27,10 @@ namespace isnd.Controllers
|
||||
{
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
|
@ -17,26 +17,17 @@ namespace isnd.Controllers
|
||||
int skip = 0,
|
||||
int take = 25)
|
||||
{
|
||||
CheckParams(take, semVerLevel);
|
||||
if (ModelState.ErrorCount > 0) return BadRequest(ModelState);
|
||||
|
||||
return Ok(packageManager.AutoComplete(id,skip,take,prerelease,packageType));
|
||||
}
|
||||
protected void CheckParams(int maxTake)
|
||||
{
|
||||
if (maxTake > maxTake)
|
||||
if (take > maxTake)
|
||||
{
|
||||
ModelState.AddModelError("take", "Maximum exceeded");
|
||||
}
|
||||
}
|
||||
|
||||
protected void CheckParams(int take, string semVerLevel)
|
||||
{
|
||||
CheckParams(take);
|
||||
if (semVerLevel != PackageManager.BASE_API_LEVEL)
|
||||
{
|
||||
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 Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
@ -27,8 +28,8 @@ namespace isnd.Controllers
|
||||
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{*lower}")]
|
||||
public async Task<IActionResult> CatalogLeafAsync(string id, string lower)
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Registration + "/{id}/{*lower}")]
|
||||
public async Task<IActionResult> CatalogRegistrationAsync(string id, string lower)
|
||||
{
|
||||
string pkgType = ParamHelpers.Optional(ref lower);
|
||||
var pkgVersion = await dbContext.PackageVersions
|
||||
@ -39,20 +40,34 @@ namespace isnd.Controllers
|
||||
v.Type == pkgType
|
||||
);
|
||||
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
|
||||
{
|
||||
CommitId = id,
|
||||
Id = pkgVersion.PackageId,
|
||||
CommitTimeStamp = pkgVersion.LatestCommit.CommitTimeStamp
|
||||
Id = id,
|
||||
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 isnd.Attributes;
|
||||
using isnd.Entities;
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
// Web get nupkg
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/{idf}-{lowerf}.nupkg")]
|
||||
// Web get the paquet
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.GetPackage + "/{id}/{lower}/{idf}-{lowerf}."
|
||||
+ Constants.PaquetFileEstension)]
|
||||
public IActionResult GetPackage(
|
||||
[FromRoute][SafeName][Required] string id,
|
||||
[FromRoute][SafeName][Required] string lower,
|
||||
[FromRoute] string idf, [FromRoute] string lowerf)
|
||||
{
|
||||
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
||||
id, lower, $"{id}-{lower}.nupkg"
|
||||
id, lower, $"{id}-{lower}." + Constants.PaquetFileEstension
|
||||
);
|
||||
|
||||
FileInfo pkgfi = new FileInfo(pkgpath);
|
||||
@ -29,7 +32,8 @@ namespace isnd.Controllers
|
||||
}
|
||||
|
||||
// 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(
|
||||
[FromRoute][SafeName][Required] string id,
|
||||
[FromRoute][SafeName][Required] string lower,
|
||||
@ -37,7 +41,7 @@ namespace isnd.Controllers
|
||||
[FromRoute][SafeName][Required] string lowerf)
|
||||
{
|
||||
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
||||
id, lower, $"{id}.nuspec");
|
||||
id, lower, $"{id}." + Constants.SpecFileEstension);
|
||||
|
||||
FileInfo pkgfi = new FileInfo(pkgpath);
|
||||
if (!pkgfi.Exists)
|
||||
|
@ -6,7 +6,7 @@ namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
{
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/index.json")]
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/index.json")]
|
||||
public IActionResult GetVersions(
|
||||
string id,
|
||||
string lower,
|
||||
|
@ -16,6 +16,7 @@ using isnd.Helpers;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using isnd.Data.Catalog;
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
@ -52,7 +53,7 @@ namespace isnd.Controllers
|
||||
{
|
||||
string initpath = Path.Combine(Environment.GetEnvironmentVariable("TEMP") ??
|
||||
Environment.GetEnvironmentVariable("TMP") ?? "/tmp",
|
||||
$"isn-{Guid.NewGuid()}.nupkg");
|
||||
$"isn-{Guid.NewGuid()}."+Constants.PaquetFileEstension);
|
||||
|
||||
using (FileStream fw = new FileStream(initpath, FileMode.Create))
|
||||
{
|
||||
@ -63,14 +64,14 @@ namespace isnd.Controllers
|
||||
{
|
||||
var archive = new ZipArchive(fw);
|
||||
|
||||
var nuspec = archive.Entries.FirstOrDefault(e => e.FullName.EndsWith(".nuspec"));
|
||||
if (nuspec == null) return BadRequest(new { error = "no nuspec from archive" });
|
||||
var spec = archive.Entries.FirstOrDefault(e => e.FullName.EndsWith("." + Constants.SpecFileEstension));
|
||||
if (spec == null) return BadRequest(new { error = "no " + Constants.SpecFileEstension + " from archive" });
|
||||
string pkgpath;
|
||||
NuGetVersion version;
|
||||
string pkgid;
|
||||
string fullpath;
|
||||
|
||||
using (var specstr = nuspec.Open())
|
||||
using (var specstr = spec.Open())
|
||||
{
|
||||
NuspecCoreReader reader = new NuspecCoreReader(specstr);
|
||||
|
||||
@ -82,29 +83,29 @@ namespace isnd.Controllers
|
||||
string pkgidpath = Path.Combine(isndSettings.PackagesRootDir,
|
||||
pkgid);
|
||||
pkgpath = Path.Combine(pkgidpath, version.ToFullString());
|
||||
string name = $"{pkgid}-{version}.nupkg";
|
||||
string name = $"{pkgid}-{version}."+Constants.PaquetFileEstension;
|
||||
fullpath = Path.Combine(pkgpath, name);
|
||||
|
||||
var destpkgiddir = new DirectoryInfo(pkgidpath);
|
||||
Package package = dbContext.Packages.SingleOrDefault(p => p.Id == pkgid);
|
||||
if (package != null)
|
||||
Package pkg = dbContext.Packages.SingleOrDefault(p => p.Id == pkgid);
|
||||
if (pkg != null)
|
||||
{
|
||||
if (package.OwnerId != apikey.UserId)
|
||||
if (pkg.OwnerId != apikey.UserId)
|
||||
{
|
||||
return new ForbidResult();
|
||||
}
|
||||
package.Description = pkgdesc;
|
||||
pkg.Description = pkgdesc;
|
||||
}
|
||||
else
|
||||
{
|
||||
package = new Package
|
||||
pkg = new Package
|
||||
{
|
||||
Id = pkgid,
|
||||
Description = pkgdesc,
|
||||
OwnerId = apikey.UserId,
|
||||
LatestVersion = commit
|
||||
};
|
||||
dbContext.Packages.Add(package);
|
||||
dbContext.Packages.Add(pkg);
|
||||
}
|
||||
if (!destpkgiddir.Exists) destpkgiddir.Create();
|
||||
|
||||
@ -117,7 +118,7 @@ namespace isnd.Controllers
|
||||
// mais si elle ne l'est pas en base de donnéés,
|
||||
// on remplace la version sur disque.
|
||||
var pkgv = dbContext.PackageVersions.Where(
|
||||
v => v.PackageId == package.Id
|
||||
v => v.PackageId == pkg.Id
|
||||
);
|
||||
|
||||
if (pkgv !=null && pkgv.Count()==0)
|
||||
@ -136,7 +137,7 @@ namespace isnd.Controllers
|
||||
files.Add(name);
|
||||
string fullstringversion = version.ToFullString();
|
||||
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)
|
||||
{
|
||||
foreach (var v in pkgvers.ToArray())
|
||||
@ -147,7 +148,7 @@ namespace isnd.Controllers
|
||||
dbContext.PackageVersions.Add
|
||||
(new PackageVersion{
|
||||
|
||||
Package = package,
|
||||
Package = pkg,
|
||||
Major = version.Major,
|
||||
Minor = version.Minor,
|
||||
Patch = version.Patch,
|
||||
@ -161,7 +162,7 @@ namespace isnd.Controllers
|
||||
{
|
||||
var pkgver = new PackageVersion
|
||||
{
|
||||
Package = package,
|
||||
Package = pkg,
|
||||
Major = version.Major,
|
||||
Minor = version.Minor,
|
||||
Patch = version.Patch,
|
||||
@ -176,7 +177,7 @@ namespace isnd.Controllers
|
||||
await dbContext.SaveChangesAsync();
|
||||
packageManager.ÛpdateCatalogFor(commit);
|
||||
|
||||
logger.LogInformation($"new package : {nuspec.Name}");
|
||||
logger.LogInformation($"new paquet : {spec.Name}");
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
if (nfpi.Exists)
|
||||
nfpi.Delete();
|
||||
nuspec.ExtractToFile(nuspecfullpath);
|
||||
spec.ExtractToFile(nuspecfullpath);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace isnd.Data.Catalog
|
||||
{
|
||||
|
||||
[JsonProperty("@type")]
|
||||
public List<string> RefType { get; set; }
|
||||
public string[] RefType { get; set; }
|
||||
|
||||
[JsonProperty("commitId")]
|
||||
public string CommitId { get; set; }
|
||||
|
@ -30,8 +30,8 @@ namespace isnd.Data
|
||||
public virtual List<PackageVersion> Versions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Latest package version put, or post,
|
||||
/// or { delete when no more active version }.
|
||||
/// Latest version at put, posted,
|
||||
/// or even deletion when no more active version.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Required][JsonIgnore]
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using isn.abst;
|
||||
using isnd.Data.Catalog;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@ -41,8 +42,10 @@ namespace isnd.Data
|
||||
public string CommitId { get => CommitNId.ToString(); }
|
||||
|
||||
public virtual Commit LatestCommit{ get; set; }
|
||||
public string NugetLink => $"/package/{PackageId}/{FullString}/{PackageId}-{FullString}.nupkg";
|
||||
public string NuspecLink => $"/package/{PackageId}/{FullString}/{PackageId}-{FullString}.nuspec";
|
||||
public string NugetLink => $"/{Constants.PaquetFileEstension}/{PackageId}/{FullString}/{PackageId}-{FullString}."
|
||||
+ Constants.PaquetFileEstension;
|
||||
public string NuspecLink => $"/{Constants.SpecFileEstension}/{PackageId}/{FullString}/{PackageId}-{FullString}."
|
||||
+ Constants.SpecFileEstension;
|
||||
|
||||
}
|
||||
}
|
@ -1,21 +1,20 @@
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Entities
|
||||
{
|
||||
public static class ApiConfig
|
||||
{
|
||||
|
||||
public const string Publish = "put";
|
||||
public const string Base = "index.json";
|
||||
public const string Catalog = "catalog";
|
||||
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 AutoComplete = "autocomplete";
|
||||
public const string CatalogLeaf = "catalog-leaf";
|
||||
public const string CatalogPackageDetail = "package-detail";
|
||||
|
||||
public const string Delete = "delete";
|
||||
|
||||
public const string Registration = "registration";
|
||||
|
||||
internal const string GetNuspec = Constants.SpecFileEstension;
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ namespace isnd.Interfaces
|
||||
void ÛpdateCatalogFor(Commit commit);
|
||||
Task<PackageDeletionReport> DeletePackageAsync(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.Threading.Tasks;
|
||||
using isn.Abstract;
|
||||
using isnd.Controllers;
|
||||
using isnd.Data;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Entities;
|
||||
@ -51,8 +52,8 @@ namespace isnd.Services
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + ApiConfig.Base,
|
||||
Type = "PackageBaseAddress/" + BASE_API_LEVEL,
|
||||
Id = extUrl + ApiConfig.GetPackage,
|
||||
Type = "PackageBaseAddress/3.0.0" ,
|
||||
Comment = "Package Base Address service"
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-autocomplete", false))
|
||||
@ -79,14 +80,14 @@ namespace isnd.Services
|
||||
Type = "Catalog/"+ BASE_API_LEVEL,
|
||||
Comment = "Package Catalog Index"
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-registration", false))
|
||||
res.Add(
|
||||
|
||||
/* FIXME res.Add(
|
||||
new Resource
|
||||
{
|
||||
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."
|
||||
});
|
||||
}); */
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -256,7 +257,7 @@ namespace isnd.Services
|
||||
|
||||
public async Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type)
|
||||
{
|
||||
// TODO package deletion on disk
|
||||
// TODO deletion on disk
|
||||
var commit = new Commit{
|
||||
Action = PackageAction.DeletePackage,
|
||||
TimeStamp = DateTime.Now
|
||||
@ -285,5 +286,24 @@ namespace isnd.Services
|
||||
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 System.Linq;
|
||||
using Xunit;
|
||||
using isn.abst;
|
||||
|
||||
namespace isn.tests
|
||||
{
|
||||
@ -60,7 +61,8 @@ dataTable.Rows.Add(dataRow);
|
||||
public void TestPush()
|
||||
{
|
||||
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]
|
||||
|
@ -17,17 +17,9 @@
|
||||
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\isnd\isnd.csproj" />
|
||||
<ProjectReference Include="..\..\src\isn\isn.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MyTestingConfigFiles Include="appsettings.Testing.json" />
|
||||
</ItemGroup>
|
||||
<!--
|
||||
<Target Name="CopyTestConfig" AfterTargets="Build">
|
||||
<Copy SourceFiles="@(MyTestingConfigFiles)" DestinationFolder="$(OutputPath)" />
|
||||
</Target>-->
|
||||
</Project>
|
Reference in New Issue
Block a user