From 70f6e411e5d933c807f17d043525ea59ea218e33 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 6 Feb 2023 00:41:35 +0000 Subject: [PATCH] version bump & click fixes --- .vscode/launch.json | 6 +++++- src/isn.abst/isn.abst.csproj | 8 ++++---- src/isn/IDataProtector.cs | 3 ++- src/isn/Program.cs | 9 +++++---- src/isn/Settings.cs | 13 +++++++++++++ src/isn/commands/PushCommand.cs | 3 +-- src/isn/commands/push.cs | 4 ++-- src/isn/commands/set-api-key.cs | 8 ++++---- src/isn/isn.csproj | 8 ++++---- src/isn/model/PushReport.cs | 15 +++++++++++++++ src/isnd/Controllers/Packages/WebViews.cs | 1 + src/isnd/Startup.cs | 1 + src/isnd/ViewModels/PackageDetailViewModel.cs | 2 ++ src/isnd/Views/Packages/Details.cshtml | 4 ++-- src/isnd/isnd.csproj | 8 ++++---- test/data/test-isn/test-isn.csproj | 8 ++++---- test/isn.tests/isn.tests.csproj | 8 ++++---- test/isnd.tests/UnitTestWebHost.cs | 5 ++++- test/isnd.tests/isnd.tests.csproj | 10 +++++----- 19 files changed, 82 insertions(+), 42 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e179e1e..dcae1d6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,7 +17,11 @@ "program": "${workspaceFolder}/src/isn/bin/Debug/netcoreapp2.1/isn.dll", "requireExactSource": false, "args": [ - "push", "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg" + "push", + "-s", "http://localhost:5000/index.json", + "-k", "CfDJ8PZdCuMAkkdPqlnuLoghOuKBNLoprBqsy64fJqrYnVEOCj-eI7pfoVjHPXHazx_YSUDtnz9ic8olLY6JcZYOE2lVfpThjs8bE73AR4HjDQPhiMOY2NU-lWtCuxhk0K16xqOoFU5pAPLF83-YXJtt02_WMAQWfxVbq5_LpskRcZrk", + "-p", + "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg" ], "cwd": "${workspaceFolder}/src/isn", "stopAtEntry": false, diff --git a/src/isn.abst/isn.abst.csproj b/src/isn.abst/isn.abst.csproj index e7c77f1..e679d19 100644 --- a/src/isn.abst/isn.abst.csproj +++ b/src/isn.abst/isn.abst.csproj @@ -1,12 +1,12 @@  1.0.1 - 1.0.5 + 1.0.7 net451; net472; net4.8; netcoreapp2.1 NETSDK1138 - 1.0.5.0 - 1.0.5.0 - 1.0.5+Branch.main.Sha.14206ac477d0f07566d5e8125dc52cbd7f474ca2 + 1.0.7.0 + 1.0.7.0 + 1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327 diff --git a/src/isn/IDataProtector.cs b/src/isn/IDataProtector.cs index 22205d4..d91ea23 100644 --- a/src/isn/IDataProtector.cs +++ b/src/isn/IDataProtector.cs @@ -18,6 +18,7 @@ namespace isn { } + public string Protect(string data) { List protd = new List(); @@ -31,7 +32,7 @@ namespace isn public string UnProtect(string data) { - + if (data==null) return null; StringBuilder sb = new StringBuilder(); List unps = new List(); diff --git a/src/isn/Program.cs b/src/isn/Program.cs index 96f4a66..8a543a6 100644 --- a/src/isn/Program.cs +++ b/src/isn/Program.cs @@ -42,9 +42,11 @@ namespace isn { "v|version", "show soft version info and exit", h => shouldShowVersion = h != null } }; + static string apiKey; + static readonly OptionSet pushoptions = new OptionSet { { "k|api-key=", "use api key", val => apiKey = apiKey ?? val }, - { "p|store-api-key", "store used api key (=)", val => storApiKey = val != null }, + { "p|store-api-key", "store used api key", val => storApiKey = val != null }, { "s|source=", "use source", val => CurrentSource = CurrentSource ?? val }, { "h|help", "show this message and exit", h => shouldShowPushHelp = h != null }, }; @@ -60,10 +62,8 @@ namespace isn private static bool shouldShowVersion; private static bool shouldShowSourceHelp; private static bool shouldShowPushHelp; - private static string apiKey = null; private static string currentSource = null; private static bool storApiKey = false; - public static IDataProtector Protector { get; set; } = new DefaultDataProtector(); static Settings settings = null; @@ -74,11 +74,13 @@ namespace isn if (settings == null) LoadConfig(); if (settings == null) + { settings = new Settings { DataProtectionTitle = "isn", Sources = new Dictionary() }; + } return settings; } } @@ -174,7 +176,6 @@ namespace isn return; } List reports = PushPkg(pargs); - Console.WriteLine(JsonConvert.SerializeObject(reports)); } }; diff --git a/src/isn/Settings.cs b/src/isn/Settings.cs index 3f17fa2..2bd0def 100644 --- a/src/isn/Settings.cs +++ b/src/isn/Settings.cs @@ -8,8 +8,21 @@ namespace isn { public string ApiKey { get; set; } public string Alias { get; set; } + + public string GetClearApiKey() + { + return Protector.UnProtect(ApiKey); + } + public void SetApiKey(string key) + { + ApiKey = Protector.Protect(key); + } + + public static IDataProtector Protector { get; set; } = new DefaultDataProtector(); } + + public class Settings { public string DataProtectionTitle { get; set; } diff --git a/src/isn/commands/PushCommand.cs b/src/isn/commands/PushCommand.cs index f35b3a6..bf4e08a 100644 --- a/src/isn/commands/PushCommand.cs +++ b/src/isn/commands/PushCommand.cs @@ -10,7 +10,7 @@ namespace isn { public static class PushCommand { - static public PushReport Run(string pkg, string source) + static public PushReport Run(string pkg, string source, string apikey) { if (source == null) source = Program.Settings.DefaultSourceKey; if (source == null) throw new InvalidOperationException("source is null"); @@ -18,7 +18,6 @@ namespace isn source = Program.Settings.Sources.First(s=>s.Value.Alias==source).Key; if (source==null) throw new InvalidOperationException("source is invalid"); - string apikey = Program.Protector.UnProtect(Program.Settings.Sources[source].ApiKey); var resources = SourceHelpers.GetServerResources(source); if (resources.Resources == null) throw new InvalidOperationException("source gave no resource"); diff --git a/src/isn/commands/push.cs b/src/isn/commands/push.cs index f8f007b..58daf08 100644 --- a/src/isn/commands/push.cs +++ b/src/isn/commands/push.cs @@ -15,8 +15,8 @@ namespace isn foreach (string pkg in pkgs) { - var report = PushCommand.Run(pkg, CurrentSource); - + var report = PushCommand.Run(pkg, CurrentSource, apiKey); + Console.WriteLine(report.ToDoc()); pushReports.Add(report); } if (storApiKey) diff --git a/src/isn/commands/set-api-key.cs b/src/isn/commands/set-api-key.cs index 2d70340..7b2f018 100644 --- a/src/isn/commands/set-api-key.cs +++ b/src/isn/commands/set-api-key.cs @@ -46,16 +46,16 @@ namespace isn else { // Une mise À jour - string ptd = Protector.Protect(apiKey); - Settings.Sources[CurrentSource].ApiKey = ptd; + Settings.Sources[CurrentSource].SetApiKey(apiKey); if (Settings.DefaultSourceKey == null) Settings.DefaultSourceKey = CurrentSource; } } else if (apiKey != null) { // une addition - string ptd = Protector.Protect(apiKey); - Settings.Sources.Add(CurrentSource, new SourceSettings { ApiKey = ptd }); + var setting = new SourceSettings (); + setting.SetApiKey(apiKey); + Settings.Sources.Add(CurrentSource, setting); } SaveConfig(); } diff --git a/src/isn/isn.csproj b/src/isn/isn.csproj index a32d076..4476947 100644 --- a/src/isn/isn.csproj +++ b/src/isn/isn.csproj @@ -4,15 +4,15 @@ netcoreapp2.1 nuget_cli 45b74c62-05bc-4603-95b4-3e80ae2fdf50 - 1.0.5 + 1.0.7 1.0.1 true WTFPL true NETSDK1138 - 1.0.5.0 - 1.0.5.0 - 1.0.5+Branch.main.Sha.14206ac477d0f07566d5e8125dc52cbd7f474ca2 + 1.0.7.0 + 1.0.7.0 + 1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327 diff --git a/src/isn/model/PushReport.cs b/src/isn/model/PushReport.cs index 1611230..d8e082e 100644 --- a/src/isn/model/PushReport.cs +++ b/src/isn/model/PushReport.cs @@ -1,4 +1,5 @@ using System.Net; +using System.Text; namespace isn { @@ -11,5 +12,19 @@ namespace isn public string Message { get; internal set; } public string StatusCode { get; internal set; } public string StackTrace { get; internal set; } + + public string ToDoc() + { + StringBuilder sb = new StringBuilder($"= Pushing {PkgName}\n\n"); + if (Executed) sb.AppendLine("* Executed"); + if (OK) sb.AppendLine("* OK"); + if (!string.IsNullOrWhiteSpace(Message)) + sb.AppendLine(Message); + if (!string.IsNullOrWhiteSpace(StatusCode)) + sb.AppendLine($"* Status Code : "); + if (!string.IsNullOrWhiteSpace(StackTrace)) + sb.AppendLine($"* StackTrace : "); + return sb.ToString(); + } } } \ No newline at end of file diff --git a/src/isnd/Controllers/Packages/WebViews.cs b/src/isnd/Controllers/Packages/WebViews.cs index a076a19..eb6c477 100644 --- a/src/isnd/Controllers/Packages/WebViews.cs +++ b/src/isnd/Controllers/Packages/WebViews.cs @@ -43,6 +43,7 @@ namespace isnd.Controllers return View("Details", new PackageDetailViewModel { + ExternalUrl = isndSettings.ExternalUrl, latest = latest, pkgid = pkgid, totalHits = packageVersion.Count(), diff --git a/src/isnd/Startup.cs b/src/isnd/Startup.cs index 0e20117..c5a26c2 100644 --- a/src/isnd/Startup.cs +++ b/src/isnd/Startup.cs @@ -131,6 +131,7 @@ namespace isnd app.UseMigrationsEndPoint(); app.UseSwagger(); app.UseSwaggerUI(); + } else { diff --git a/src/isnd/ViewModels/PackageDetailViewModel.cs b/src/isnd/ViewModels/PackageDetailViewModel.cs index 40d31af..f49ab02 100644 --- a/src/isnd/ViewModels/PackageDetailViewModel.cs +++ b/src/isnd/ViewModels/PackageDetailViewModel.cs @@ -10,6 +10,8 @@ namespace isnd.ViewModels public int totalHits { get; set; } public PackageVersion[] data { get; set; } + public string ExternalUrl { get; set; } + } } \ No newline at end of file diff --git a/src/isnd/Views/Packages/Details.cshtml b/src/isnd/Views/Packages/Details.cshtml index bbf7931..beb27fe 100644 --- a/src/isnd/Views/Packages/Details.cshtml +++ b/src/isnd/Views/Packages/Details.cshtml @@ -25,8 +25,8 @@ @Html.DisplayNameFor(model => model.latest.FullString)
- @Html.DisplayFor(model => model.latest.FullString) - nuspec + @Html.DisplayFor(model => model.latest.FullString) + nuspec (version count : @Model.totalHits)
diff --git a/src/isnd/isnd.csproj b/src/isnd/isnd.csproj index a103601..ab5902c 100644 --- a/src/isnd/isnd.csproj +++ b/src/isnd/isnd.csproj @@ -5,10 +5,10 @@ true WTFPL NETSDK1138,CS1591,MSB3243 - 1.0.5.0 - 1.0.5.0 - 1.0.5+Branch.main.Sha.14206ac477d0f07566d5e8125dc52cbd7f474ca2 - 1.0.5 + 1.0.7.0 + 1.0.7.0 + 1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327 + 1.0.7 true diff --git a/test/data/test-isn/test-isn.csproj b/test/data/test-isn/test-isn.csproj index 188a925..dc85e5b 100644 --- a/test/data/test-isn/test-isn.csproj +++ b/test/data/test-isn/test-isn.csproj @@ -5,9 +5,9 @@ test_isn enable enable - 1.0.5.0 - 1.0.5.0 - 1.0.5+Branch.main.Sha.14206ac477d0f07566d5e8125dc52cbd7f474ca2 - 1.0.5 + 1.0.7.0 + 1.0.7.0 + 1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327 + 1.0.7
\ No newline at end of file diff --git a/test/isn.tests/isn.tests.csproj b/test/isn.tests/isn.tests.csproj index 5012d88..2b69678 100644 --- a/test/isn.tests/isn.tests.csproj +++ b/test/isn.tests/isn.tests.csproj @@ -3,10 +3,10 @@ netcoreapp2.1 false NETSDK1138 - 1.0.5.0 - 1.0.5.0 - 1.0.5+Branch.main.Sha.14206ac477d0f07566d5e8125dc52cbd7f474ca2 - 1.0.5 + 1.0.7.0 + 1.0.7.0 + 1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327 + 1.0.7 diff --git a/test/isnd.tests/UnitTestWebHost.cs b/test/isnd.tests/UnitTestWebHost.cs index ad63819..88cc721 100644 --- a/test/isnd.tests/UnitTestWebHost.cs +++ b/test/isnd.tests/UnitTestWebHost.cs @@ -45,9 +45,12 @@ namespace isnd.host.tests var isnSettings = services.GetRequiredService>().Value; var dbContext = services.GetRequiredService(); - var paul = dbContext.Users.FirstOrDefaultAsync(u => u.UserName == "paul").Result; + var paul = dbContext.Users.FirstOrDefaultAsync(u => u.Email == "paul@pschneider.fr").Result; if (paul!=null) + { dbContext.Users.Remove(paul); + dbContext.SaveChanges(); + } } } diff --git a/test/isnd.tests/isnd.tests.csproj b/test/isnd.tests/isnd.tests.csproj index 139c439..21554b4 100644 --- a/test/isnd.tests/isnd.tests.csproj +++ b/test/isnd.tests/isnd.tests.csproj @@ -1,13 +1,13 @@ - + netcoreapp2.1 false d7144e46-4e63-4391-ba86-64b61f6e7be4 NETSDK1138 - 1.0.5.0 - 1.0.5.0 - 1.0.5+Branch.main.Sha.14206ac477d0f07566d5e8125dc52cbd7f474ca2 - 1.0.5 + 1.0.7.0 + 1.0.7.0 + 1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327 + 1.0.7