diff --git a/.gitignore b/.gitignore index d722330..95b51b2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ src/isnd/bin/ src/isnd/obj/ src/isn/obj src/isn/bin -.vscode/launch.json src/isn/.vscode/ test/isnd.tests/obj/ test/isnd.tests/bin/ @@ -10,7 +9,8 @@ packages/ bower_components/ test/isn.tests/bin test/isn.tests/obj/ -test/isnd.tests/appsettings.Testing.json +appsettings.Testing.json +appsettings.Development.json wwwroot/.sass-cache/ src/isnd/wwwroot/.sass-cache/ src/isn.abst/bin diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e179e1e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,48 @@ +{ + // Utilisez IntelliSense pour en savoir plus sur les attributs possibles. + // Pointez pour afficher la description des attributs existants. + // Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + }, + { + "name": "push", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/src/isn/bin/Debug/netcoreapp2.1/isn.dll", + "requireExactSource": false, + "args": [ + "push", "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg" + ], + "cwd": "${workspaceFolder}/src/isn", + "stopAtEntry": false, + "console": "internalConsole" + }, + { + "name": "web", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/src/isnd/bin/Debug/netcoreapp2.1/isnd.dll", + "args": [], + "cwd": "${workspaceFolder}/src/isnd", + "stopAtEntry": false, + "requireExactSource": false, + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + } +] +} \ No newline at end of file diff --git a/src/isn.abst/Constants.cs b/src/isn.abst/Constants.cs deleted file mode 100644 index bc5cf0a..0000000 --- a/src/isn.abst/Constants.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace isn.abst -{ - public static class Constants - { - public const string PublishCommandId = "PackagePublish/2.0.0"; - - } -} \ No newline at end of file diff --git a/src/isnd/Controllers/PackageVersionController.cs b/src/isnd/Controllers/PackageVersionController.cs index f4483e0..a4783b3 100644 --- a/src/isnd/Controllers/PackageVersionController.cs +++ b/src/isnd/Controllers/PackageVersionController.cs @@ -91,7 +91,7 @@ namespace isnd public async Task DeleteConfirmed(string PackageId, string FullString, string Type) { - PackageVersion packageVersion = await _context.PackageVersions.Include(p => p.Package) + PackageVersion packageVersion = await _context.PackageVersions .FirstOrDefaultAsync(m => m.PackageId == PackageId && m.FullString == FullString && m.Type == Type); if (packageVersion == null) return NotFound(); diff --git a/src/isnd/Controllers/PackagesController.AutoComplete.cs b/src/isnd/Controllers/PackagesController.AutoComplete.cs new file mode 100644 index 0000000..940eb18 --- /dev/null +++ b/src/isnd/Controllers/PackagesController.AutoComplete.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Mvc; + +namespace isnd.Controllers +{ + public partial class PackagesController + { + + // GET /autocomplete?id=isn.protocol&prerelease=true + [HttpGet(_pkgRootPrefix + ApiConfig.AutoComplete)] + public IActionResult AutoComplete( + string id, + string semVerLevel, + bool prerelease = false, + string packageType = null, + int skip = 0, + int take = 25) + { + if (take > maxTake) + { + ModelState.AddModelError("take", "Maximum exceeded"); + return BadRequest(ModelState); + } + if (semVerLevel != defaultSemVer) + { + ModelState.AddModelError("semVerLevel", defaultSemVer + " expected"); + } + + return Ok(_packageManager.AutoComplete(id,skip,take,prerelease,packageType)); + } + } +} \ No newline at end of file diff --git a/src/isnd/Controllers/PackagesController.Catalog.cs b/src/isnd/Controllers/PackagesController.Catalog.cs index 45d1a09..6e45692 100644 --- a/src/isnd/Controllers/PackagesController.Catalog.cs +++ b/src/isnd/Controllers/PackagesController.Catalog.cs @@ -33,7 +33,6 @@ namespace isnd.Controllers string pkgType = ParamHelpers.Optional(ref lower); var pkgVersion = await _dbContext.PackageVersions .Include(v => v.LatestCommit) - .Include(v => v.Package) .SingleOrDefaultAsync( v => v.PackageId == id && v.FullString == lower && diff --git a/src/isnd/Controllers/PackagesController.GetVersions.cs b/src/isnd/Controllers/PackagesController.GetVersions.cs new file mode 100644 index 0000000..ea83192 --- /dev/null +++ b/src/isnd/Controllers/PackagesController.GetVersions.cs @@ -0,0 +1,37 @@ +using Microsoft.AspNetCore.Mvc; +using NuGet.Versioning; + +namespace isnd.Controllers +{ + public partial class PackagesController + { + [HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/index.json")] + public IActionResult GetVersions( + string id, + string lower, + bool prerelease = false, + string packageType = null, + int skip = 0, + int take = 25) + { + if (take > maxTake) + { + ModelState.AddModelError("take", "Maximum exceeded"); + } + // NugetVersion + if (!NuGetVersion.TryParse(lower, out NuGetVersion parsedVersion)) + { + ModelState.AddModelError("lower", "invalid version string"); + } + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + return Ok(new + { + versions = _packageManager.GetVersions( + id, parsedVersion, prerelease, packageType, skip, take) + }); + } + } +} diff --git a/src/isnd/Controllers/PackagesController.Search.cs b/src/isnd/Controllers/PackagesController.Search.cs new file mode 100644 index 0000000..ab237d6 --- /dev/null +++ b/src/isnd/Controllers/PackagesController.Search.cs @@ -0,0 +1,28 @@ + +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace isnd.Controllers +{ + + public partial class PackagesController + { + +// GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE} + [HttpGet(_pkgRootPrefix + ApiConfig.Search)] + public async Task Search( + + string q, + int skip = 0, + int take = 25, + bool prerelease = false, + string semVerLevel = null, + string packageType = null + ) + { + + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/isnd/Controllers/PackagesController.Views.cs b/src/isnd/Controllers/PackagesController.Views.cs index e09df3f..0a0ad7d 100644 --- a/src/isnd/Controllers/PackagesController.Views.cs +++ b/src/isnd/Controllers/PackagesController.Views.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Threading.Tasks; using isnd.ViewModels; @@ -9,7 +10,6 @@ namespace isnd.Controllers public partial class PackagesController { - // GET: PackageVersion public async Task Index(PackageIndexViewModel model) { diff --git a/src/isnd/Controllers/PackagesController.cs b/src/isnd/Controllers/PackagesController.cs index 3ba324d..042e8cb 100644 --- a/src/isnd/Controllers/PackagesController.cs +++ b/src/isnd/Controllers/PackagesController.cs @@ -57,59 +57,6 @@ namespace isnd.Controllers { return Ok(new ApiIndexViewModel{ Version = "3.0.0", Resources = _resources }); } - - // GET /autocomplete?id=isn.protocol&prerelease=true - [HttpGet(_pkgRootPrefix + ApiConfig.AutoComplete)] - public IActionResult AutoComplete( - string id, - string semVerLevel, - bool prerelease = false, - string packageType = null, - int skip = 0, - int take = 25) - { - if (take > maxTake) - { - ModelState.AddModelError("take", "Maximum exceeded"); - return BadRequest(ModelState); - } - if (semVerLevel != defaultSemVer) - { - ModelState.AddModelError("semVerLevel", defaultSemVer + " expected"); - } - - return Ok(_packageManager.AutoComplete(id,skip,take,prerelease,packageType)); - } - // TODO GET {@id}/{LOWER_ID}/index.json - // LOWER_ID URL string yes The package ID, lowercased - // response : versions array of strings yes The versions available - [HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/index.json")] - public IActionResult GetVersions( - string id, - string lower, - bool prerelease = false, - string packageType = null, - int skip = 0, - int take = 25) - { - if (take > maxTake) - { - ModelState.AddModelError("take", "Maximum exceeded"); - } - // NugetVersion - if (!NuGetVersion.TryParse(lower, out NuGetVersion parsedVersion)) - { - ModelState.AddModelError("lower", "invalid version string"); - } - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - return Ok(new - { - versions = _packageManager.GetVersions( - id, parsedVersion, prerelease, packageType, skip, take) - }); - } } + } \ No newline at end of file diff --git a/src/isnd/Services/PackageManager.cs b/src/isnd/Services/PackageManager.cs index 0f251df..b447a3f 100644 --- a/src/isnd/Services/PackageManager.cs +++ b/src/isnd/Services/PackageManager.cs @@ -3,9 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using isn.abst; using isn.Abstract; -using isnd.Controllers; using isnd.Data; using isnd.Data.Catalog; using isnd.Entities; @@ -21,6 +19,7 @@ namespace isnd.Services { public class PackageManager : IPackageManager { + public const string BASE_API_LEVEL = "3.5.0"; ApplicationDbContext dbContext; public PackageManager(ApplicationDbContext dbContext, @@ -43,7 +42,7 @@ namespace isnd.Services new Resource { Id = extUrl + ApiConfig.Publish, - Type = Constants.PublishCommandId, + Type = "PackagePublish/2.0.0", // TODO BASE_API_LEVEL Comment = "Package Publish service" }); // under dev, only leash in release mode @@ -52,7 +51,7 @@ namespace isnd.Services new Resource { Id = extUrl + ApiConfig.Base, - Type = "PackageBaseAddress/3.0.0", + Type = "PackageBaseAddress/" + BASE_API_LEVEL, Comment = "Package Base Address service" }); if (unleashClient.IsEnabled("pkg-autocomplete", false)) @@ -60,17 +59,23 @@ namespace isnd.Services new Resource { Id = extUrl + ApiConfig.AutoComplete, - Type = "SearchAutocompleteService/3.5.0", + Type = "SearchAutocompleteService/" + BASE_API_LEVEL, Comment = "Auto complete service" }); - if (unleashClient.IsEnabled("pkg-search", false)) + if (unleashClient.IsEnabled("pkg-search", true)) res.Add( new Resource { Id = extUrl + ApiConfig.Search, - Type = "SearchQueryService/3.5.0", + Type = "SearchQueryService/" + BASE_API_LEVEL, Comment = "Search Query service" }); + /* + { + "@id": "https://api-v2v3search-0.nuget.org/query", + "@type": "SearchQueryService/3.0.0-rc", + "comment": "Query endpoint of NuGet Search service (primary) used by RC clients" + }, if (unleashClient.IsEnabled("pkg-catalog", false)) res.Add( @@ -79,7 +84,17 @@ namespace isnd.Services Id = extUrl + ApiConfig.Catalog, Type = "Catalog/3.0.0", Comment = "Package Catalog Index" - }); + });*/ + + /* TODO ? { + + "@id": "https://api.nuget.org/v3/registration5-gz-semver2/", + "@type": "RegistrationsBaseUrl/Versioned", + "clientVersion": "4.3.0-alpha", + "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." + +}, +*/ return res; } diff --git a/src/isnd/appsettings.Development.json b/src/isnd/appsettings.Development.json deleted file mode 100644 index f0eee3f..0000000 --- a/src/isnd/appsettings.Development.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "AdminStartupList": { - "Users": [ - "paul@pschneider.fr" - ] - }, - "Isn": { - "ExternalUrl": "http://localhost:5000", - "PackagesRootDir" : "packages", - "ProtectionTitle": "protected-data-v1", - "MaxUserKeyCount": 5 - }, - "Smtp": { - "Server": "localhost", - "Port": 25, - "SenderName": "Paul Schneider", - "SenderEmail": "paul@pschneider.fr" - }, - "Unleash": - { - "ClientApiKey": "6f08a4b280ec4d4fd58b8a471fee4d0ceeb9b665ffd45dc957f8e695e0a0dfa6" - } -}