...
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,3 +13,5 @@ test/isn.tests/obj/
|
|||||||
test/isnd.tests/appsettings.Testing.json
|
test/isnd.tests/appsettings.Testing.json
|
||||||
wwwroot/.sass-cache/
|
wwwroot/.sass-cache/
|
||||||
src/isnd/wwwroot/.sass-cache/
|
src/isnd/wwwroot/.sass-cache/
|
||||||
|
src/isn.abst/bin
|
||||||
|
src/isn.abst/obj
|
||||||
|
@ -64,7 +64,8 @@ sudo ln -s /usr/local/lib/isn/isn /usr/local/bin/isn
|
|||||||
|
|
||||||
````bash
|
````bash
|
||||||
# compiler tout
|
# compiler tout
|
||||||
dotnet publish -c Release
|
dotnet build -c Release
|
||||||
|
dotnet publish -c Release -f netcoreapp2.1 src/isnd
|
||||||
# MAJ du serveur
|
# MAJ du serveur
|
||||||
sudo systemctl stop isnd
|
sudo systemctl stop isnd
|
||||||
sudo cp -a src/isnd/bin/Release/netcoreapp2.1/publish/* /srv/www/isnd
|
sudo cp -a src/isnd/bin/Release/netcoreapp2.1/publish/* /srv/www/isnd
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net4.7.2</TargetFramework>
|
<TargetFramework>net45</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -7,7 +7,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace isn
|
namespace isn
|
||||||
{
|
{
|
||||||
partial class Program
|
public partial class Program
|
||||||
{
|
{
|
||||||
|
|
||||||
public static IEnumerable<IsnSourceSettings> Sources { get; protected set; }
|
public static IEnumerable<IsnSourceSettings> Sources { get; protected set; }
|
||||||
@ -155,7 +155,6 @@ namespace isn
|
|||||||
|
|
||||||
var pushCmd = new Command(push)
|
var pushCmd = new Command(push)
|
||||||
{
|
{
|
||||||
|
|
||||||
Run = async sargs =>
|
Run = async sargs =>
|
||||||
{
|
{
|
||||||
var pargs = pushoptions.Parse(sargs);
|
var pargs = pushoptions.Parse(sargs);
|
||||||
@ -172,11 +171,11 @@ namespace isn
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
commandSet.Add(pushCmd);
|
|
||||||
var setapikey = new Command("set-api-key")
|
var setapikey = new Command("set-api-key")
|
||||||
{
|
{
|
||||||
Run = sargs => StoreApiKey(sargs)
|
Run = sargs => StoreApiKey(sargs)
|
||||||
};
|
};
|
||||||
|
commandSet.Add(pushCmd);
|
||||||
commandSet.Add(setapikey);
|
commandSet.Add(setapikey);
|
||||||
commandSet.Add(srcCmd);
|
commandSet.Add(srcCmd);
|
||||||
commandSet.Add(showCommand);
|
commandSet.Add(showCommand);
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using isn.Abstract;
|
using isn.Abstract;
|
||||||
@ -10,12 +13,50 @@ namespace isn
|
|||||||
public static async Task<ApiIndexViewModel> GetServerResourcesAsync(string url)
|
public static async Task<ApiIndexViewModel> GetServerResourcesAsync(string url)
|
||||||
{
|
{
|
||||||
HttpClient client = new HttpClient();
|
HttpClient client = new HttpClient();
|
||||||
client.DefaultRequestHeaders.Add("content-type","application/json; utf-8");
|
// var json = await client.GetStringAsync(new System.Uri(url));
|
||||||
using (var indexResponse = await client.GetAsync(url))
|
try
|
||||||
{
|
{
|
||||||
var json = await indexResponse.Content.ReadAsStringAsync();
|
var response = await client.GetStringAsync(url);
|
||||||
return JsonConvert.DeserializeObject<ApiIndexViewModel>(json);
|
// var json = await response.Content.ReadAsStringAsync();
|
||||||
|
return JsonConvert.DeserializeObject<ApiIndexViewModel>(response);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<ApiIndexViewModel> GetServerResourcesUsingWebRequestAsync(string url)
|
||||||
|
{
|
||||||
|
ApiIndexViewModel viewModel=null;
|
||||||
|
var uri = new Uri(url);
|
||||||
|
|
||||||
|
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
|
||||||
|
httpWebRequest.Method = "GET";
|
||||||
|
httpWebRequest.AllowAutoRedirect = false;
|
||||||
|
try{
|
||||||
|
|
||||||
|
using (var resp = await httpWebRequest.GetResponseAsync())
|
||||||
|
{
|
||||||
|
using (var stream = resp.GetResponseStream())
|
||||||
|
{
|
||||||
|
using (var reader = new StreamReader(stream))
|
||||||
|
{
|
||||||
|
var json = await reader.ReadToEndAsync();
|
||||||
|
Console.Write("got json : "+json);
|
||||||
|
viewModel = JsonConvert.DeserializeObject<ApiIndexViewModel>(json);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
return viewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,9 +7,9 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace isn
|
namespace isn
|
||||||
{
|
{
|
||||||
internal class PushCommand
|
public class PushCommand
|
||||||
{
|
{
|
||||||
static internal async Task<PushReport> RunAsync(string pkg, string source, string apikey)
|
static public async Task<PushReport> RunAsync(string pkg, string source, string apikey)
|
||||||
{
|
{
|
||||||
FileInfo fi = new FileInfo(pkg);
|
FileInfo fi = new FileInfo(pkg);
|
||||||
var report = new PushReport
|
var report = new PushReport
|
||||||
@ -39,7 +39,8 @@ namespace isn
|
|||||||
var resources = await SourceHelpers.GetServerResourcesAsync(source);
|
var resources = await SourceHelpers.GetServerResourcesAsync(source);
|
||||||
if (resources.Resources==null || resources.Resources.Any(res => res.Id == "" ))
|
if (resources.Resources==null || resources.Resources.Any(res => res.Id == "" ))
|
||||||
throw new InvalidOperationException("Source won't serve the expected push command");
|
throw new InvalidOperationException("Source won't serve the expected push command");
|
||||||
wrqueryHandler.UploadFilesToServer(report, new Uri(source), fi, apikey);
|
Console.WriteLine(JsonConvert.SerializeObject(resources));
|
||||||
|
wrqueryHandler.UploadFilesToServer(report, new Uri(resources.Resources[0].Id), fi, apikey);
|
||||||
}
|
}
|
||||||
catch (WebException ex)
|
catch (WebException ex)
|
||||||
{
|
{
|
@ -9,7 +9,7 @@ namespace isn
|
|||||||
|
|
||||||
partial class Program
|
partial class Program
|
||||||
{
|
{
|
||||||
private static async Task<List<PushReport>> PushPkgAsync(IEnumerable<string> pkgs)
|
public static async Task<List<PushReport>> PushPkgAsync(IEnumerable<string> pkgs)
|
||||||
{
|
{
|
||||||
List<PushReport> pushReports = new List<PushReport>();
|
List<PushReport> pushReports = new List<PushReport>();
|
||||||
|
|
||||||
|
@ -28,7 +28,12 @@ namespace isn
|
|||||||
|
|
||||||
public static void EnsureKeyStored()
|
public static void EnsureKeyStored()
|
||||||
{
|
{
|
||||||
if (source == null) return;
|
if (source == null)
|
||||||
|
{
|
||||||
|
if (Settings.DefaultSource == null)
|
||||||
|
return;
|
||||||
|
source = Settings.DefaultSource;
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings.Sources.ContainsKey(source))
|
if (Settings.Sources.ContainsKey(source))
|
||||||
{
|
{
|
||||||
@ -52,7 +57,6 @@ namespace isn
|
|||||||
string ptd = Protector.Protect(apiKey);
|
string ptd = Protector.Protect(apiKey);
|
||||||
Settings.Sources.Add(source, new SourceSettings { ApiKey = ptd });
|
Settings.Sources.Add(source, new SourceSettings { ApiKey = ptd });
|
||||||
}
|
}
|
||||||
else return;
|
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
}
|
}
|
||||||
public static void SaveConfig()
|
public static void SaveConfig()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6</TargetFramework>
|
<TargetFrameworks>net45;netcoreapp2.1;net6</TargetFrameworks>
|
||||||
<RootNamespace>nuget_cli</RootNamespace>
|
<RootNamespace>nuget_cli</RootNamespace>
|
||||||
<UserSecretsId>45b74c62-05bc-4603-95b4-3e80ae2fdf50</UserSecretsId>
|
<UserSecretsId>45b74c62-05bc-4603-95b4-3e80ae2fdf50</UserSecretsId>
|
||||||
<PackageVersion>1.0.1</PackageVersion>
|
<PackageVersion>1.0.1</PackageVersion>
|
||||||
|
@ -2,7 +2,13 @@ using System;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using isn.Abstract;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace isn.tests
|
namespace isn.tests
|
||||||
{
|
{
|
||||||
@ -35,5 +41,35 @@ dataRow[1]= 2;
|
|||||||
dataTable.Rows.Add(dataRow);
|
dataTable.Rows.Add(dataRow);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task TestHttpClient()
|
||||||
|
{
|
||||||
|
string url = "http://localhost:88/index.json";
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
// var json = await client.GetStringAsync(new System.Uri(url));
|
||||||
|
var response = await client.GetAsync(url);
|
||||||
|
var json = await response.Content.ReadAsStringAsync();
|
||||||
|
var vm = JsonConvert.DeserializeObject<ApiIndexViewModel>(json);
|
||||||
|
Console.WriteLine( JsonConvert.SerializeObject(vm));
|
||||||
|
Assert.NotNull(vm);
|
||||||
|
Assert.NotNull(vm.Resources);
|
||||||
|
}
|
||||||
|
[Test]
|
||||||
|
public async Task TestPush()
|
||||||
|
{
|
||||||
|
Program.LoadConfig();
|
||||||
|
var report = await Program.PushPkgAsync(new string[] { "bin/Debug/isn.1.0.1.nupkg" });
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task GetServerResourcesUsingWebRequestAsyncTest()
|
||||||
|
{
|
||||||
|
var model = await SourceHelpers.GetServerResourcesUsingWebRequestAsync("Http://localhost:88/index.json");
|
||||||
|
Console.WriteLine(JsonConvert.SerializeObject(model));
|
||||||
|
Assert.NotNull(model.Resources);
|
||||||
|
Assert.True(model.Resources.Any((r) => r.Type == "PackagePublish/2.0.0"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6</TargetFramework>
|
<TargetFrameworks>net45</TargetFrameworks>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\isn\isn.csproj" />
|
<ProjectReference Include="..\..\src\isn\isn.csproj" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Reference in New Issue
Block a user