Versioning

broken/ef
Paul Schneider 2 years ago
parent 328f6f166a
commit 5c1a49811a
15 changed files with 112 additions and 97 deletions

@ -1,12 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<NoWarn>NETSDK1138</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.1"/>
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageVersion>1.0.1</PackageVersion>
<Version>0.1.0</Version>
<TargetFramework>netcoreapp2.1</TargetFramework>
<NoWarn>NETSDK1138</NoWarn>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
<FileVersion>0.1.0.0</FileVersion>
<InformationalVersion>0.1.0+171.Branch.main.Sha.328f6f166a68b3e44ada08e9a13dd12570238679</InformationalVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
</ItemGroup>
</Project>

@ -10,8 +10,6 @@ namespace isn
public partial class Program
{
public static IEnumerable<IsnSourceSettings> Sources { get; protected set; }
public static void LoadConfig()
{
FileInfo cfgSettingIf = new FileInfo(_configFileName);
@ -19,11 +17,11 @@ namespace isn
{
var json = File.ReadAllText(cfgSettingIf.FullName);
settings = JsonConvert.DeserializeObject<Settings>(json);
source = settings.DefaultSource;
currentSource = settings.DefaultSource;
}
}
static OptionSet storeoptions = new OptionSet {
{ "s|source=", "use source", val => source = source ?? val },
{ "s|source=", "use source", val => currentSource = currentSource ?? val },
{ "h|help", "show this message and exit", h => shouldShowPushHelp = h != null },
};
private static string _configFileName =
@ -41,7 +39,7 @@ namespace isn
static OptionSet pushoptions = new OptionSet {
{ "k|api-key=", "use api key", val => apiKey = apiKey ?? val },
{ "p|store-api-key", "store used api key (=<true|false>)", val => storApiKey = val != null },
{ "s|source=", "use source", val => source = source ?? val },
{ "s|source=", "use source", val => currentSource = currentSource ?? val },
{ "h|help", "show this message and exit", h => shouldShowPushHelp = h != null },
};
static OptionSet sourceoptions = new OptionSet {
@ -56,7 +54,7 @@ namespace isn
private static bool shouldShowSourceHelp;
private static bool shouldShowPushHelp;
private static string apiKey = null;
private static string source = null;
private static string currentSource = null;
private static int pushKO = 0;
private static bool storApiKey = false;
public static IDataProtector Protector { get; set; } = new DefaultDataProtector();
@ -166,7 +164,7 @@ namespace isn
pushoptions.WriteOptionDescriptions(Console.Out);
return;
}
List<PushReport> reports = await PushPkgAsync(pargs);
List<PushReport> reports = PushPkg(pargs);
Console.WriteLine(JsonConvert.SerializeObject(reports));
pushKO = reports.Count(r => !r.OK && !r.AlreadyPresent);
}

@ -10,15 +10,16 @@ namespace isn
{
public static class SourceHelpers
{
public static async Task<ApiIndexViewModel> GetServerResourcesAsync(string url)
public static ApiIndexViewModel GetServerResources(string url)
{
HttpClient client = new HttpClient();
ApiIndexViewModel result = null;
// var json = await client.GetStringAsync(new System.Uri(url));
var response = await client.GetStringAsync(url);
Task.Run(async ()=> {
var response = await client.GetStringAsync(url);
result = JsonConvert.DeserializeObject<ApiIndexViewModel>(response);
}).Wait();
return result;
}

@ -9,17 +9,17 @@ namespace isn
{
public class PushCommand
{
static public async Task<PushReport> RunAsync(string pkg, string source)
static public PushReport Run(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 = await SourceHelpers.GetServerResourcesAsync(source);
var resources = SourceHelpers.GetServerResources(source);
if (resources.Resources == null)
throw new InvalidOperationException("source gave no resource");
if (!resources.Resources.Any(res => res.Type == "PackagePublish/3.5.0"))
if (!resources.Resources.Any(res => res.Type == "PackagePublish/2.0.0"))
throw new InvalidOperationException("Source won't serve the expected push command");
var pubRes = resources.Resources.First(res => res.Type == "PackagePublish/3.5.0");
var pubRes = resources.Resources.First(res => res.Type == "PackagePublish/2.0.0");
FileInfo fi = new FileInfo(pkg);
if (!fi.Exists)
{

@ -9,13 +9,13 @@ namespace isn
partial class Program
{
public static async Task<List<PushReport>> PushPkgAsync(IEnumerable<string> pkgs)
public static List<PushReport> PushPkg(IEnumerable<string> pkgs)
{
List<PushReport> pushReports = new List<PushReport>();
foreach (string pkg in pkgs)
{
var report = await PushCommand.RunAsync(pkg, source);
var report = PushCommand.Run(pkg, currentSource);
pushReports.Add(report);
}

@ -28,34 +28,34 @@ namespace isn
public static void EnsureKeyStored()
{
if (source == null)
if (currentSource == null)
{
if (Settings.DefaultSource == null)
return;
source = Settings.DefaultSource;
currentSource = Settings.DefaultSource;
}
if (Settings.Sources.ContainsKey(source))
if (Settings.Sources.ContainsKey(currentSource))
{
if (apiKey == null)
{
// Une suppression
Settings.Sources.Remove(source);
if (Settings.DefaultSource == source) Settings.DefaultSource = null;
Settings.Sources.Remove(currentSource);
if (Settings.DefaultSource == currentSource) Settings.DefaultSource = null;
}
else
{
// Une mise À jour
string ptd = Protector.Protect(apiKey);
Settings.Sources[source].ApiKey = ptd;
if (Settings.DefaultSource == null) Settings.DefaultSource = source;
Settings.Sources[currentSource].ApiKey = ptd;
if (Settings.DefaultSource == null) Settings.DefaultSource = currentSource;
}
}
else if (apiKey != null)
{
// une addition
string ptd = Protector.Protect(apiKey);
Settings.Sources.Add(source, new SourceSettings { ApiKey = ptd });
Settings.Sources.Add(currentSource, new SourceSettings { ApiKey = ptd });
}
SaveConfig();
}

@ -1,27 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<RootNamespace>nuget_cli</RootNamespace>
<UserSecretsId>45b74c62-05bc-4603-95b4-3e80ae2fdf50</UserSecretsId>
<Version>0.1.0</Version>
<PackageVersion>1.0.1</PackageVersion>
<IsPackable>true</IsPackable>
<PackageLicenseExpression>WTFPL</PackageLicenseExpression>
<IsTool>true</IsTool>
<NoWarn>NETSDK1138</NoWarn>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
<FileVersion>0.1.0.0</FileVersion>
<InformationalVersion>0.1.0+171.Branch.main.Sha.328f6f166a68b3e44ada08e9a13dd12570238679</InformationalVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.Options" Version="5.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Mono.Options" Version="5.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="unleash.client" Version="1.6.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<Reference Include="System.Net.Http" Version="4.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../isn.abst/isn.abst.csproj" />
</ItemGroup>
</Project>
</Project>

@ -5,6 +5,8 @@ using isnd.Data;
using System.Linq;
using isnd.ViewModels;
using Unleash;
using System.Reflection;
namespace isnd.Controllers
{
@ -23,6 +25,7 @@ namespace isnd.Controllers
public IActionResult Index()
{
return View(new HomeIndexViewModel{
PkgCount = _dbContext.Packages.Count(),
UnleashClient = _unleashĈlient
@ -39,6 +42,11 @@ namespace isnd.Controllers
public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";
var ass = typeof(isn.Abstract.Resource).GetType().Assembly;
var attrs = ass.GetCustomAttributes(true);
// ass.GetCustomAttributes(true);
System.Reflection.AssemblyFileVersionAttribute v = (AssemblyFileVersionAttribute)
GetType().Assembly.GetCustomAttribute(typeof(AssemblyFileVersionAttribute));
return View();
}
@ -56,3 +64,6 @@ namespace isnd.Controllers
}
}
}

@ -0,0 +1,9 @@
namespace isnd.Helpers
{
public static class SiteHelpers
{
public static string SemVer {
get => GitVersionInformation.SemVer;
}
}
}

@ -40,8 +40,7 @@
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2021 - isn - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
&copy; 2021 - isn <span>@SiteHelpers.SemVer</span>- <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<!-- <script src="/lib/jquery/dist/jquery.slim.min.js" ></script>

@ -1,3 +1,4 @@
@using isnd.Data
@using isnd.ViewModels
@using isnd.Helpers
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@ -1,42 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<UserSecretsId>85fd766d-5d23-4476-aed1-463b2942e86a</UserSecretsId>
<PackageVersion>1.0.1</PackageVersion>
<Version>0.1.0</Version>
<IsPackable>true</IsPackable>
<PackageLicenseExpression>WTFPL</PackageLicenseExpression>
<NoWarn>NETSDK1138</NoWarn>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
<FileVersion>0.1.0.0</FileVersion>
<InformationalVersion>0.1.0+171.Branch.main.Sha.328f6f166a68b3e44ada08e9a13dd12570238679</InformationalVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.All" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="NuGet.Packaging.Core" Version="5.9.0"/>
<PackageReference Include="NuGet.Packaging.Core" Version="5.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.1" />
<PackageReference Include="MailKit" Version="2.11.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1" IncludeAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.1" IncludeAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.1" IncludeAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1" />
<PackageReference Include="unleash.client" Version="1.6.1" />
<PackageReference Include="GitVersion.MsBuild" Version="5.6.10*">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../isn.abst/isn.abst.csproj" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.1.0-preview1-final" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="LICENSE"/>
<None Include="..\..\LICENSE" Pack="true" PackagePath="LICENSE" />
</ItemGroup>
</Project>
</Project>

@ -57,19 +57,19 @@ dataTable.Rows.Add(dataRow);
Assert.NotNull(vm.Resources);
}
[Fact]
public async Task TestPush()
public void TestPush()
{
Program.LoadConfig();
var report = await Program.PushPkgAsync(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.nupkg" });
}
[Fact]
public async Task GetServerResourcesUsingHttpClientAsyncTest()
{
var model = await SourceHelpers.GetServerResourcesAsync("Http://isn.pschneider.fr/index.json");
var model = SourceHelpers.GetServerResources("Http://isn.pschneider.fr/index.json");
Console.WriteLine(JsonConvert.SerializeObject(model));
Assert.NotNull(model.Resources);
var pub = model.Resources.FirstOrDefault((r) => r.Type == "PackagePublish/3.5.0");
var pub = model.Resources.FirstOrDefault((r) => r.Type.StartsWith("PackagePublish/"));
Assert.True(pub!=null);
}

@ -1,26 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<NoWarn>NETSDK1138</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<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\isn\isn.csproj" />
<Reference Include="System.Net.Http" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<NoWarn>NETSDK1138</NoWarn>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
<FileVersion>0.1.0.0</FileVersion>
<InformationalVersion>0.1.0+171.Branch.main.Sha.328f6f166a68b3e44ada08e9a13dd12570238679</InformationalVersion>
<Version>0.1.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<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\isn\isn.csproj" />
<Reference Include="System.Net.Http" />
</ItemGroup>
</Project>

@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<UserSecretsId>d7144e46-4e63-4391-ba86-64b61f6e7be4</UserSecretsId>
<NoWarn>NETSDK1138</NoWarn>
<AssemblyVersion>0.1.0.0</AssemblyVersion>
<FileVersion>0.1.0.0</FileVersion>
<InformationalVersion>0.1.0+171.Branch.main.Sha.328f6f166a68b3e44ada08e9a13dd12570238679</InformationalVersion>
<Version>0.1.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
@ -15,20 +16,16 @@
<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"/>
<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"/>
<MyTestingConfigFiles Include="appsettings.Testing.json" />
</ItemGroup>
<Target Name="CopyTestConfig">
<Copy
SourceFiles="@(MyTestingConfigFiles)"
DestinationFolder="bin\Debug\net6.0"
/>
</Target>
</Project>
<Copy SourceFiles="@(MyTestingConfigFiles)" DestinationFolder="bin\Debug\net6.0" />
</Target>
</Project>
Loading…