Compilation warns
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<NoWarn>NETSDK1138</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -166,7 +166,7 @@ namespace isn
|
||||
pushoptions.WriteOptionDescriptions(Console.Out);
|
||||
return;
|
||||
}
|
||||
List<PushReport> reports = PushPkg(pargs);
|
||||
List<PushReport> reports = await PushPkgAsync(pargs);
|
||||
Console.WriteLine(JsonConvert.SerializeObject(reports));
|
||||
pushKO = reports.Count(r => !r.OK && !r.AlreadyPresent);
|
||||
}
|
||||
|
@ -3,30 +3,23 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using isn.Abstract;
|
||||
using Newtonsoft.Json;
|
||||
using isn.Abstract;
|
||||
|
||||
namespace isn
|
||||
{
|
||||
public static class SourceHelpers
|
||||
{
|
||||
public static ApiIndexViewModel GetServerResources(string url)
|
||||
public static async Task<ApiIndexViewModel> GetServerResourcesAsync(string url)
|
||||
{
|
||||
HttpClient client = new HttpClient();
|
||||
ApiIndexViewModel result = null;
|
||||
// var json = await client.GetStringAsync(new System.Uri(url));
|
||||
try
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
|
||||
|
||||
var response = await client.GetStringAsync(url);
|
||||
result = JsonConvert.DeserializeObject<ApiIndexViewModel>(response);
|
||||
}).Wait();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,12 @@ namespace isn
|
||||
{
|
||||
public class PushCommand
|
||||
{
|
||||
static public PushReport Run(string pkg, string source)
|
||||
static public async Task<PushReport> RunAsync(string pkg, string source)
|
||||
{
|
||||
if (source == null) source = Program.Settings.DefaultSource;
|
||||
if (source == null) throw new InvalidOperationException("source is null");
|
||||
string apikey = Program.Protector.UnProtect(Program.Settings.Sources[source].ApiKey);
|
||||
var resources = SourceHelpers.GetServerResources(source);
|
||||
var resources = await SourceHelpers.GetServerResourcesAsync(source);
|
||||
if (resources.Resources == null)
|
||||
throw new InvalidOperationException("source gave no resource");
|
||||
if (!resources.Resources.Any(res => res.Type == "PackagePublish/3.5.0"))
|
||||
|
@ -9,13 +9,13 @@ namespace isn
|
||||
|
||||
partial class Program
|
||||
{
|
||||
public static List<PushReport> PushPkg(IEnumerable<string> pkgs)
|
||||
public static async Task<List<PushReport>> PushPkgAsync(IEnumerable<string> pkgs)
|
||||
{
|
||||
List<PushReport> pushReports = new List<PushReport>();
|
||||
|
||||
foreach (string pkg in pkgs)
|
||||
{
|
||||
var report = PushCommand.Run(pkg, source);
|
||||
var report = await PushCommand.RunAsync(pkg, source);
|
||||
|
||||
pushReports.Add(report);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
<IsPackable>true</IsPackable>
|
||||
<PackageLicenseExpression>WTFPL</PackageLicenseExpression>
|
||||
<IsTool>true</IsTool>
|
||||
<NoWarn>NETSDK1138</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
31
src/isnd/Controllers/Packages/ApiIndex.cs
Normal file
31
src/isnd/Controllers/Packages/ApiIndex.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NuGet.Versioning;
|
||||
using isnd.Data;
|
||||
using isnd.Entities;
|
||||
using Unleash;
|
||||
using isnd.Services;
|
||||
using isnd.ViewModels;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Interfaces;
|
||||
using isn.Abstract;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController : Controller
|
||||
{
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Base)]
|
||||
public IActionResult ApiIndex()
|
||||
{
|
||||
return Ok(new ApiIndexViewModel{ Version = PackageManager.BASE_API_LEVEL, Resources = _resources });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using isnd.Services;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace isnd.Controllers
|
@ -3,7 +3,7 @@ using System.Threading.Tasks;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Helpers;
|
||||
using isnd.Services;
|
||||
using isnd.ViewModels;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
@ -49,12 +49,5 @@ namespace isnd.Controllers
|
||||
_unleashĈlient = unleashĈlient;
|
||||
_resources = _packageManager.GetResources(_unleashĈlient).ToArray();
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Base)]
|
||||
public IActionResult ApiIndex()
|
||||
{
|
||||
return Ok(new ApiIndexViewModel{ Version = PackageManager.BASE_API_LEVEL, Resources = _resources });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using isnd.Helpers;
|
||||
using isnd.Entities;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using isnd.Attributes;
|
||||
namespace isnd.Controllers
|
@ -2,15 +2,13 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using isnd.Attributes;
|
||||
using isnd.Entities;
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
// TODO GET GET {@id}/{LOWER_ID}/{LOWER_VERSION}/{LOWER_ID}.{LOWER_VERSION}.nupkg
|
||||
// LOWER_ID URL string yes The package ID, lowercase
|
||||
// LOWER_VERSION URL string yes The package version, normalized and lowercased
|
||||
// response 200 : the package
|
||||
// Web get nupkg
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/{idf}-{lowerf}.nupkg")]
|
||||
public IActionResult GetPackage(
|
||||
[FromRoute][SafeName][Required] string id,
|
||||
@ -30,8 +28,7 @@ namespace isnd.Controllers
|
||||
return File(pkgfi.OpenRead(), "application/zip; charset=binary");
|
||||
}
|
||||
|
||||
// TODO GET {@id}/{LOWER_ID}/{LOWER_VERSION}/{LOWER_ID}.nuspec
|
||||
// response 200 : the nuspec
|
||||
// Web get spec
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Get + "/{id}/{lower}/{idf}-{lowerf}.nuspec")]
|
||||
public IActionResult GetNuspec(
|
||||
[FromRoute][SafeName][Required] string id,
|
@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NuGet.Versioning;
|
||||
using isnd.Entities;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
@ -13,6 +13,7 @@ using NuGet.Packaging.Core;
|
||||
using NuGet.Versioning;
|
||||
using isnd.Data;
|
||||
using isnd.Helpers;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using isnd.Data.Catalog;
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using isnd.Entities;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
@ -10,7 +10,7 @@ namespace isnd.Controllers
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
// GET: PackageVersion
|
||||
// Web search
|
||||
public async Task<IActionResult> Index(PackageIndexViewModel model)
|
||||
{
|
||||
var applicationDbContext = _dbContext.Packages.Include(p => p.Versions).Where(
|
@ -1,4 +1,4 @@
|
||||
namespace isnd
|
||||
namespace isnd.Entities
|
||||
{
|
||||
public static class ApiConfig
|
||||
{
|
||||
@ -15,5 +15,7 @@ namespace isnd
|
||||
|
||||
public const string Delete = "delete";
|
||||
|
||||
public const string Registration = "registration";
|
||||
|
||||
}
|
||||
}
|
@ -71,33 +71,23 @@ namespace isnd.Services
|
||||
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(
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + ApiConfig.Catalog,
|
||||
Type = "Catalog/3.0.0",
|
||||
Type = "Catalog/"+ BASE_API_LEVEL,
|
||||
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."
|
||||
|
||||
},
|
||||
*/
|
||||
});
|
||||
if (unleashClient.IsEnabled("pkg-registration", false))
|
||||
res.Add(
|
||||
new Resource
|
||||
{
|
||||
Id = extUrl + ApiConfig.Registration,
|
||||
Type = "Catalog/" + BASE_API_LEVEL,
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
public PackageIndexViewModel SearchByName(string query,
|
||||
|
@ -6,6 +6,7 @@
|
||||
<PackageVersion>1.0.1</PackageVersion>
|
||||
<IsPackable>true</IsPackable>
|
||||
<PackageLicenseExpression>WTFPL</PackageLicenseExpression>
|
||||
<NoWarn>NETSDK1138</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -57,10 +57,10 @@ dataTable.Rows.Add(dataRow);
|
||||
Assert.NotNull(vm.Resources);
|
||||
}
|
||||
[Fact]
|
||||
public void TestPush()
|
||||
public async Task TestPush()
|
||||
{
|
||||
Program.LoadConfig();
|
||||
var report = Program.PushPkg(new string[] { "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg" });
|
||||
var report = await Program.PushPkgAsync(new string[] { "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg" });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<NoWarn>NETSDK1138</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<UserSecretsId>d7144e46-4e63-4391-ba86-64b61f6e7be4</UserSecretsId>
|
||||
<NoWarn>NETSDK1138</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user