diff --git a/src/isn.abst/isn.abst.csproj b/src/isn.abst/isn.abst.csproj index 5f73854..1229696 100644 --- a/src/isn.abst/isn.abst.csproj +++ b/src/isn.abst/isn.abst.csproj @@ -1,12 +1,14 @@ - - - - netcoreapp2.1 - NETSDK1138 - - - - - - - + + + 1.0.1 + 0.1.0 + netcoreapp2.1 + NETSDK1138 + 0.1.0.0 + 0.1.0.0 + 0.1.0+171.Branch.main.Sha.328f6f166a68b3e44ada08e9a13dd12570238679 + + + + + \ No newline at end of file diff --git a/src/isn/Program.cs b/src/isn/Program.cs index 8789561..db0ff5d 100644 --- a/src/isn/Program.cs +++ b/src/isn/Program.cs @@ -10,8 +10,6 @@ namespace isn public partial class Program { - public static IEnumerable 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(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 (=)", 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 reports = await PushPkgAsync(pargs); + List reports = PushPkg(pargs); Console.WriteLine(JsonConvert.SerializeObject(reports)); pushKO = reports.Count(r => !r.OK && !r.AlreadyPresent); } diff --git a/src/isn/SourceHelpers.cs b/src/isn/SourceHelpers.cs index add0256..3b5dc97 100644 --- a/src/isn/SourceHelpers.cs +++ b/src/isn/SourceHelpers.cs @@ -10,15 +10,16 @@ namespace isn { public static class SourceHelpers { - public static async Task 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(response); + }).Wait(); return result; } diff --git a/src/isn/commands/PushCommand.cs b/src/isn/commands/PushCommand.cs index 0d57c8d..8ff7a0f 100644 --- a/src/isn/commands/PushCommand.cs +++ b/src/isn/commands/PushCommand.cs @@ -9,17 +9,17 @@ namespace isn { public class PushCommand { - static public async Task 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) { diff --git a/src/isn/commands/push.cs b/src/isn/commands/push.cs index ef5a302..ff71f4c 100644 --- a/src/isn/commands/push.cs +++ b/src/isn/commands/push.cs @@ -9,13 +9,13 @@ namespace isn partial class Program { - public static async Task> PushPkgAsync(IEnumerable pkgs) + public static List PushPkg(IEnumerable pkgs) { List pushReports = new List(); foreach (string pkg in pkgs) { - var report = await PushCommand.RunAsync(pkg, source); + var report = PushCommand.Run(pkg, currentSource); pushReports.Add(report); } diff --git a/src/isn/commands/set-api-key.cs b/src/isn/commands/set-api-key.cs index 02d651b..aea8ab6 100644 --- a/src/isn/commands/set-api-key.cs +++ b/src/isn/commands/set-api-key.cs @@ -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(); } diff --git a/src/isn/isn.csproj b/src/isn/isn.csproj index 2366882..db26051 100644 --- a/src/isn/isn.csproj +++ b/src/isn/isn.csproj @@ -1,27 +1,27 @@  - Exe netcoreapp2.1 nuget_cli 45b74c62-05bc-4603-95b4-3e80ae2fdf50 + 0.1.0 1.0.1 true WTFPL true NETSDK1138 + 0.1.0.0 + 0.1.0.0 + 0.1.0+171.Branch.main.Sha.328f6f166a68b3e44ada08e9a13dd12570238679 - - - + + - - - + \ No newline at end of file diff --git a/src/isnd/Controllers/HomeController.cs b/src/isnd/Controllers/HomeController.cs index a1c9f22..7d11d02 100644 --- a/src/isnd/Controllers/HomeController.cs +++ b/src/isnd/Controllers/HomeController.cs @@ -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 } } } + + + diff --git a/src/isnd/Helpers/SiteHelpers.cs b/src/isnd/Helpers/SiteHelpers.cs new file mode 100644 index 0000000..d9cb317 --- /dev/null +++ b/src/isnd/Helpers/SiteHelpers.cs @@ -0,0 +1,9 @@ +namespace isnd.Helpers +{ + public static class SiteHelpers + { + public static string SemVer { + get => GitVersionInformation.SemVer; + } + } +} \ No newline at end of file diff --git a/src/isnd/Views/Shared/_Layout.cshtml b/src/isnd/Views/Shared/_Layout.cshtml index 3fe4a69..e25c4ff 100644 --- a/src/isnd/Views/Shared/_Layout.cshtml +++ b/src/isnd/Views/Shared/_Layout.cshtml @@ -40,8 +40,7 @@
-
- © 2021 - isn - Privacy + © 2021 - isn @SiteHelpers.SemVer- Privacy