From b2647857709070148cadac63ac32e7bf1f90fe8a Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Tue, 9 Jun 2020 18:29:29 +0200 Subject: [PATCH 01/12] Added option to run BaGet server on specific port. --- src/BaGet.Core/Configuration/BaGetOptions.cs | 7 +- .../Extensions/IHostExtensions.cs | 4 +- src/BaGet.UI/package-lock.json | 91 ++++++++++++++----- .../Extensions/IHostBuilderExtensions.cs | 4 +- src/BaGet/Program.cs | 32 +++---- src/BaGet/appsettings.json | 1 + 6 files changed, 93 insertions(+), 46 deletions(-) diff --git a/src/BaGet.Core/Configuration/BaGetOptions.cs b/src/BaGet.Core/Configuration/BaGetOptions.cs index 932c2681..fd53f00c 100644 --- a/src/BaGet.Core/Configuration/BaGetOptions.cs +++ b/src/BaGet.Core/Configuration/BaGetOptions.cs @@ -5,7 +5,7 @@ namespace BaGet.Core { public class BaGetOptions { - /// + /// /// The API Key required to authenticate package /// operations. If empty, package operations do not require authentication. /// @@ -38,6 +38,11 @@ public class BaGetOptions /// public bool IsReadOnlyMode { get; set; } = false; + /// + /// The port the baGet server will run on. + /// + public string Port { get; set; } + [Required] public DatabaseOptions Database { get; set; } diff --git a/src/BaGet.Hosting/Extensions/IHostExtensions.cs b/src/BaGet.Hosting/Extensions/IHostExtensions.cs index ce730c48..52d68184 100644 --- a/src/BaGet.Hosting/Extensions/IHostExtensions.cs +++ b/src/BaGet.Hosting/Extensions/IHostExtensions.cs @@ -2,14 +2,14 @@ using System.Threading.Tasks; using BaGet.Core; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Options; namespace BaGet.Hosting { public static class IHostExtensions { - public static async Task RunMigrationsAsync(this IHost host, CancellationToken cancellationToken) + public static async Task RunMigrationsAsync(this IWebHost host, CancellationToken cancellationToken) { // Run migrations if necessary. var options = host.Services.GetRequiredService>(); diff --git a/src/BaGet.UI/package-lock.json b/src/BaGet.UI/package-lock.json index 8f01d393..32a6c902 100644 --- a/src/BaGet.UI/package-lock.json +++ b/src/BaGet.UI/package-lock.json @@ -7162,7 +7162,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -7180,11 +7181,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7197,15 +7200,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -7308,7 +7314,8 @@ }, "inherits": { "version": "2.0.4", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -7318,6 +7325,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7330,17 +7338,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "1.2.5", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.9.0", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -7357,6 +7368,7 @@ "mkdirp": { "version": "0.5.3", "bundled": true, + "optional": true, "requires": { "minimist": "^1.2.5" } @@ -7412,7 +7424,8 @@ }, "npm-normalize-package-bin": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "npm-packlist": { "version": "1.4.8", @@ -7437,7 +7450,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -7447,6 +7461,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -7515,7 +7530,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -7545,6 +7561,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7562,6 +7579,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7600,11 +7618,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.1.1", - "bundled": true + "bundled": true, + "optional": true } } } @@ -13641,7 +13661,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -13823,7 +13844,8 @@ }, "minimist": { "version": "1.2.5", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.9.0", @@ -13845,6 +13867,7 @@ "mkdirp": { "version": "0.5.3", "bundled": true, + "optional": true, "requires": { "minimist": "^1.2.5" } @@ -14006,7 +14029,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -14054,6 +14078,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -14092,11 +14117,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.1.1", - "bundled": true + "bundled": true, + "optional": true } } }, @@ -14416,7 +14443,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -14453,7 +14481,8 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", @@ -14462,7 +14491,8 @@ }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -14565,7 +14595,8 @@ }, "inherits": { "version": "2.0.4", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -14575,6 +14606,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -14600,6 +14632,7 @@ "minipass": { "version": "2.9.0", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -14616,6 +14649,7 @@ "mkdirp": { "version": "0.5.3", "bundled": true, + "optional": true, "requires": { "minimist": "^1.2.5" } @@ -14697,7 +14731,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -14707,6 +14742,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -14775,7 +14811,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -14805,6 +14842,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -14822,6 +14860,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -14860,11 +14899,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.1.1", - "bundled": true + "bundled": true, + "optional": true } } }, diff --git a/src/BaGet/Extensions/IHostBuilderExtensions.cs b/src/BaGet/Extensions/IHostBuilderExtensions.cs index 28f9a933..8816c552 100644 --- a/src/BaGet/Extensions/IHostBuilderExtensions.cs +++ b/src/BaGet/Extensions/IHostBuilderExtensions.cs @@ -1,13 +1,13 @@ using System; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; +using Microsoft.AspNetCore.Hosting; namespace BaGet { // TODO: Move this to BaGet.Hosting. public static class IHostBuilderExtensions { - public static IHostBuilder UseBaGet(this IHostBuilder host) + public static IWebHostBuilder UseBaGet(this IWebHostBuilder host) { host.ConfigureServices((context, services) => { diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index 1d2f16a8..ecda5f6d 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -4,10 +4,12 @@ using McMaster.Extensions.CommandLineUtils; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; +using Microsoft.AspNetCore; namespace BaGet { + using Microsoft.Extensions.Options; + public class Program { public static async Task Main(string[] args) @@ -18,7 +20,7 @@ public static async Task Main(string[] args) Description = "A light-weight NuGet service", }; - app.HelpOption(inherited: true); + app.HelpOption(true); app.Command("import", import => { @@ -38,6 +40,10 @@ public static async Task Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); + // Todo: Don't know how to get the options without rebuilding the host! + var baGetOptions = host.Services.GetRequiredService>(); + host = CreateHostBuilder(args).UseUrls(baGetOptions.Value.Port).Build(); + await host.RunMigrationsAsync(cancellationToken); await host.RunAsync(cancellationToken); }); @@ -45,22 +51,16 @@ public static async Task Main(string[] args) await app.ExecuteAsync(args); } - public static IHostBuilder CreateWebHostBuilder(string[] args) => - CreateHostBuilder(args) - .ConfigureWebHostDefaults(web => + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + CreateHostBuilder(args).ConfigureKestrel(options => { - web.ConfigureKestrel(options => - { - // Remove the upload limit from Kestrel. If needed, an upload limit can - // be enforced by a reverse proxy server, like IIS. - options.Limits.MaxRequestBodySize = null; - }); - - web.UseStartup(); - }); + // Remove the upload limit from Kestrel. If needed, an upload limit can + // be enforced by a reverse proxy server, like IIS. + options.Limits.MaxRequestBodySize = null; + }).UseStartup(); - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) + public static IWebHostBuilder CreateHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) .UseBaGet(); } } diff --git a/src/BaGet/appsettings.json b/src/BaGet/appsettings.json index 09f1283f..02350554 100644 --- a/src/BaGet/appsettings.json +++ b/src/BaGet/appsettings.json @@ -1,5 +1,6 @@ { "ApiKey": "", + "Port": "http://*:5000", "PackageDeletionBehavior": "Unlist", "AllowPackageOverwrites": false, From 167fc22f0d6ecc3a5db4be9d180d4cfdefc2144c Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Tue, 9 Jun 2020 19:20:36 +0200 Subject: [PATCH 02/12] BaGet: Fixed small bug in startup with port. --- src/BaGet/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index ecda5f6d..dffc066a 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -42,7 +42,7 @@ public static async Task Main(string[] args) // Todo: Don't know how to get the options without rebuilding the host! var baGetOptions = host.Services.GetRequiredService>(); - host = CreateHostBuilder(args).UseUrls(baGetOptions.Value.Port).Build(); + host = CreateWebHostBuilder(args).UseUrls(baGetOptions.Value.Port).Build(); await host.RunMigrationsAsync(cancellationToken); await host.RunAsync(cancellationToken); From 6dfa47860aa5ff60f225c1ebdd72572f70d53052 Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Wed, 10 Jun 2020 18:57:39 +0200 Subject: [PATCH 03/12] Renamed port to urls, added documentation link. --- src/BaGet.Core/Configuration/BaGetOptions.cs | 5 +++-- src/BaGet/Program.cs | 2 +- src/BaGet/appsettings.json | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/BaGet.Core/Configuration/BaGetOptions.cs b/src/BaGet.Core/Configuration/BaGetOptions.cs index fd53f00c..20c9639b 100644 --- a/src/BaGet.Core/Configuration/BaGetOptions.cs +++ b/src/BaGet.Core/Configuration/BaGetOptions.cs @@ -39,9 +39,10 @@ public class BaGetOptions public bool IsReadOnlyMode { get; set; } = false; /// - /// The port the baGet server will run on. + /// The URLs the BaGet server will use. + /// As per documentation here (Server URLs). /// - public string Port { get; set; } + public string Urls { get; set; } [Required] public DatabaseOptions Database { get; set; } diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index dffc066a..9b363305 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -42,7 +42,7 @@ public static async Task Main(string[] args) // Todo: Don't know how to get the options without rebuilding the host! var baGetOptions = host.Services.GetRequiredService>(); - host = CreateWebHostBuilder(args).UseUrls(baGetOptions.Value.Port).Build(); + host = CreateWebHostBuilder(args).UseUrls(baGetOptions.Value.Urls).Build(); await host.RunMigrationsAsync(cancellationToken); await host.RunAsync(cancellationToken); diff --git a/src/BaGet/appsettings.json b/src/BaGet/appsettings.json index 02350554..cd2b5778 100644 --- a/src/BaGet/appsettings.json +++ b/src/BaGet/appsettings.json @@ -1,6 +1,6 @@ { "ApiKey": "", - "Port": "http://*:5000", + "Urls": "http://*:5000", "PackageDeletionBehavior": "Unlist", "AllowPackageOverwrites": false, From 81d175abb011cc64ffad0df04a764cc70dfe4744 Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Wed, 10 Jun 2020 19:23:11 +0200 Subject: [PATCH 04/12] Adjusted startup, program and extension methods to work with more generic host and urls. --- src/BaGet.Core/Configuration/BaGetOptions.cs | 3 +- .../Extensions/IHostExtensions.cs | 3 +- .../Extensions/IHostBuilderExtensions.cs | 4 +- src/BaGet/Program.cs | 90 ++++++++++--------- src/BaGet/Startup.cs | 2 +- 5 files changed, 56 insertions(+), 46 deletions(-) diff --git a/src/BaGet.Core/Configuration/BaGetOptions.cs b/src/BaGet.Core/Configuration/BaGetOptions.cs index 20c9639b..c55c0183 100644 --- a/src/BaGet.Core/Configuration/BaGetOptions.cs +++ b/src/BaGet.Core/Configuration/BaGetOptions.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace BaGet.Core @@ -34,7 +33,7 @@ public class BaGetOptions public bool AllowPackageOverwrites { get; set; } = false; /// - /// If true, disables package pushing, deleting, and relisting. + /// If true, disables package pushing, deleting, and re-listing. /// public bool IsReadOnlyMode { get; set; } = false; diff --git a/src/BaGet.Hosting/Extensions/IHostExtensions.cs b/src/BaGet.Hosting/Extensions/IHostExtensions.cs index 52d68184..9e502dd1 100644 --- a/src/BaGet.Hosting/Extensions/IHostExtensions.cs +++ b/src/BaGet.Hosting/Extensions/IHostExtensions.cs @@ -4,12 +4,13 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Options; +using Microsoft.Extensions.Hosting; namespace BaGet.Hosting { public static class IHostExtensions { - public static async Task RunMigrationsAsync(this IWebHost host, CancellationToken cancellationToken) + public static async Task RunMigrationsAsync(this IHost host, CancellationToken cancellationToken) { // Run migrations if necessary. var options = host.Services.GetRequiredService>(); diff --git a/src/BaGet/Extensions/IHostBuilderExtensions.cs b/src/BaGet/Extensions/IHostBuilderExtensions.cs index 8816c552..28f9a933 100644 --- a/src/BaGet/Extensions/IHostBuilderExtensions.cs +++ b/src/BaGet/Extensions/IHostBuilderExtensions.cs @@ -1,13 +1,13 @@ using System; using Microsoft.Extensions.Configuration; -using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; namespace BaGet { // TODO: Move this to BaGet.Hosting. public static class IHostBuilderExtensions { - public static IWebHostBuilder UseBaGet(this IWebHostBuilder host) + public static IHostBuilder UseBaGet(this IHostBuilder host) { host.ConfigureServices((context, services) => { diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index 9b363305..fe6cba81 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -4,63 +4,73 @@ using McMaster.Extensions.CommandLineUtils; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; -using Microsoft.AspNetCore; +using System.IO; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; namespace BaGet { - using Microsoft.Extensions.Options; - - public class Program + namespace BaGet { - public static async Task Main(string[] args) + public class Program { - var app = new CommandLineApplication + public static async Task Main(string[] args) { - Name = "baget", - Description = "A light-weight NuGet service", - }; + var app = new CommandLineApplication + { + Name = "baget", + Description = "A light-weight NuGet service", + }; - app.HelpOption(true); + app.HelpOption(true); - app.Command("import", import => - { - import.Command("downloads", downloads => + app.Command("import", import => { - downloads.OnExecuteAsync(async cancellationToken => + import.Command("downloads", downloads => { - var host = CreateHostBuilder(args).Build(); - var importer = host.Services.GetRequiredService(); - - await importer.ImportAsync(cancellationToken); + downloads.OnExecuteAsync(async cancellationToken => + { + var host = CreateHostBuilder(args).Build(); + var importer = host.Services.GetRequiredService(); + await importer.ImportAsync(cancellationToken); + }); }); }); - }); - app.OnExecuteAsync(async cancellationToken => - { - var host = CreateWebHostBuilder(args).Build(); + app.OnExecuteAsync(async cancellationToken => + { + var host = CreateWebHostBuilder(args).Build(); + await host.RunMigrationsAsync(cancellationToken); + await host.RunAsync(cancellationToken); + }); - // Todo: Don't know how to get the options without rebuilding the host! - var baGetOptions = host.Services.GetRequiredService>(); - host = CreateWebHostBuilder(args).UseUrls(baGetOptions.Value.Urls).Build(); + await app.ExecuteAsync(args); + } - await host.RunMigrationsAsync(cancellationToken); - await host.RunAsync(cancellationToken); - }); + public static IHostBuilder CreateWebHostBuilder(string[] args) => + CreateHostBuilder(args) + .ConfigureWebHostDefaults(web => + { + web.ConfigureKestrel(options => + { + // Remove the upload limit from Kestrel. If needed, an upload limit can + // be enforced by a reverse proxy server, like IIS. + options.Limits.MaxRequestBodySize = null; + }); - await app.ExecuteAsync(args); - } + var config = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", true) + .AddCommandLine(args) + .Build(); - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - CreateHostBuilder(args).ConfigureKestrel(options => - { - // Remove the upload limit from Kestrel. If needed, an upload limit can - // be enforced by a reverse proxy server, like IIS. - options.Limits.MaxRequestBodySize = null; - }).UseStartup(); + web.UseUrls(config["Urls"]); + web.UseStartup(); + }); - public static IWebHostBuilder CreateHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseBaGet(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .UseBaGet(); + } } } diff --git a/src/BaGet/Startup.cs b/src/BaGet/Startup.cs index ac219c97..f1998229 100644 --- a/src/BaGet/Startup.cs +++ b/src/BaGet/Startup.cs @@ -5,8 +5,8 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.DependencyInjection; namespace BaGet { From 3c9f1cf8b1365043988369b8cd0cf2786092e4ad Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Wed, 10 Jun 2020 19:25:57 +0200 Subject: [PATCH 05/12] Added check for empty urls (Service should use the default). --- src/BaGet/Program.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index fe6cba81..a8734415 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -64,7 +64,13 @@ public static IHostBuilder CreateWebHostBuilder(string[] args) => .AddCommandLine(args) .Build(); - web.UseUrls(config["Urls"]); + var urls = config["Urls"]; + + if (!string.IsNullOrWhiteSpace(urls)) + { + web.UseUrls(urls); + } + web.UseStartup(); }); From a513445d47cbc97e1edeaa3469e87dc97748f6a3 Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Thu, 11 Jun 2020 13:11:59 +0200 Subject: [PATCH 06/12] Fixed duplicate namespace in BaGet program. --- src/BaGet/Program.cs | 97 +++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 50 deletions(-) diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index a8734415..3599785c 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -10,73 +10,70 @@ namespace BaGet { - namespace BaGet + public class Program { - public class Program + public static async Task Main(string[] args) { - public static async Task Main(string[] args) + var app = new CommandLineApplication { - var app = new CommandLineApplication - { - Name = "baget", - Description = "A light-weight NuGet service", - }; + Name = "baget", + Description = "A light-weight NuGet service", + }; - app.HelpOption(true); + app.HelpOption(true); - app.Command("import", import => + app.Command("import", import => + { + import.Command("downloads", downloads => { - import.Command("downloads", downloads => + downloads.OnExecuteAsync(async cancellationToken => { - downloads.OnExecuteAsync(async cancellationToken => - { - var host = CreateHostBuilder(args).Build(); - var importer = host.Services.GetRequiredService(); - await importer.ImportAsync(cancellationToken); - }); + var host = CreateHostBuilder(args).Build(); + var importer = host.Services.GetRequiredService(); + await importer.ImportAsync(cancellationToken); }); }); + }); - app.OnExecuteAsync(async cancellationToken => - { - var host = CreateWebHostBuilder(args).Build(); - await host.RunMigrationsAsync(cancellationToken); - await host.RunAsync(cancellationToken); - }); + app.OnExecuteAsync(async cancellationToken => + { + var host = CreateWebHostBuilder(args).Build(); + await host.RunMigrationsAsync(cancellationToken); + await host.RunAsync(cancellationToken); + }); - await app.ExecuteAsync(args); - } + await app.ExecuteAsync(args); + } - public static IHostBuilder CreateWebHostBuilder(string[] args) => - CreateHostBuilder(args) - .ConfigureWebHostDefaults(web => + public static IHostBuilder CreateWebHostBuilder(string[] args) => + CreateHostBuilder(args) + .ConfigureWebHostDefaults(web => + { + web.ConfigureKestrel(options => { - web.ConfigureKestrel(options => - { - // Remove the upload limit from Kestrel. If needed, an upload limit can - // be enforced by a reverse proxy server, like IIS. - options.Limits.MaxRequestBodySize = null; - }); + // Remove the upload limit from Kestrel. If needed, an upload limit can + // be enforced by a reverse proxy server, like IIS. + options.Limits.MaxRequestBodySize = null; + }); - var config = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", true) - .AddCommandLine(args) - .Build(); + var config = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", true) + .AddCommandLine(args) + .Build(); - var urls = config["Urls"]; + var urls = config["Urls"]; - if (!string.IsNullOrWhiteSpace(urls)) - { - web.UseUrls(urls); - } + if (!string.IsNullOrWhiteSpace(urls)) + { + web.UseUrls(urls); + } - web.UseStartup(); - }); + web.UseStartup(); + }); - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .UseBaGet(); - } + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .UseBaGet(); } } From 41b3dcdbc8663843cb1e813188f741dadc59e0f4 Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Thu, 11 Jun 2020 13:13:09 +0200 Subject: [PATCH 07/12] Added named parameter for help option again. --- src/BaGet/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index 3599785c..8ce002e6 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -20,7 +20,7 @@ public static async Task Main(string[] args) Description = "A light-weight NuGet service", }; - app.HelpOption(true); + app.HelpOption(inherited: true); app.Command("import", import => { From ee4144011c1d26522d49027b91d7d774da8be514 Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Thu, 11 Jun 2020 13:18:11 +0200 Subject: [PATCH 08/12] Added named optional parameter. --- src/BaGet/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index 8ce002e6..e70abb48 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -58,7 +58,7 @@ public static IHostBuilder CreateWebHostBuilder(string[] args) => var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", true) + .AddJsonFile("appsettings.json", optional: true) .AddCommandLine(args) .Build(); From 03a9f44bf78506102fd62c2b4eee324b222d847a Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Thu, 11 Jun 2020 13:20:27 +0200 Subject: [PATCH 09/12] Sorted usings alphabetically. --- src/BaGet/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BaGet/Program.cs b/src/BaGet/Program.cs index e70abb48..32c88394 100644 --- a/src/BaGet/Program.cs +++ b/src/BaGet/Program.cs @@ -1,11 +1,11 @@ +using System.IO; using System.Threading.Tasks; using BaGet.Core; using BaGet.Hosting; using McMaster.Extensions.CommandLineUtils; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using System.IO; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace BaGet From 964ededdf25fd450d81acde621ef4dbf18ee0cb3 Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Thu, 11 Jun 2020 13:21:32 +0200 Subject: [PATCH 10/12] Sorted usings alphabetically in Startup. --- src/BaGet/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaGet/Startup.cs b/src/BaGet/Startup.cs index f1998229..ac219c97 100644 --- a/src/BaGet/Startup.cs +++ b/src/BaGet/Startup.cs @@ -5,8 +5,8 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace BaGet { From 5e43812849e773aea147c2ac590a99706142cfad Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Thu, 11 Jun 2020 13:22:37 +0200 Subject: [PATCH 11/12] Sorted usings alphabetically in IHostExtensions class. --- src/BaGet.Hosting/Extensions/IHostExtensions.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/BaGet.Hosting/Extensions/IHostExtensions.cs b/src/BaGet.Hosting/Extensions/IHostExtensions.cs index 9e502dd1..ce730c48 100644 --- a/src/BaGet.Hosting/Extensions/IHostExtensions.cs +++ b/src/BaGet.Hosting/Extensions/IHostExtensions.cs @@ -2,9 +2,8 @@ using System.Threading.Tasks; using BaGet.Core; using Microsoft.Extensions.DependencyInjection; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Options; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Options; namespace BaGet.Hosting { From 2df3d6c4b5b3af4e6ddec5f4197fc5de514083f1 Mon Sep 17 00:00:00 2001 From: SeppPenner Date: Thu, 11 Jun 2020 13:25:45 +0200 Subject: [PATCH 12/12] Reverted changes in package-lock.json. --- src/BaGet.UI/package-lock.json | 91 ++++++++++------------------------ 1 file changed, 25 insertions(+), 66 deletions(-) diff --git a/src/BaGet.UI/package-lock.json b/src/BaGet.UI/package-lock.json index 32a6c902..8f01d393 100644 --- a/src/BaGet.UI/package-lock.json +++ b/src/BaGet.UI/package-lock.json @@ -7162,8 +7162,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -7181,13 +7180,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7200,18 +7197,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -7314,8 +7308,7 @@ }, "inherits": { "version": "2.0.4", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -7325,7 +7318,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7338,20 +7330,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "1.2.5", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.9.0", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -7368,7 +7357,6 @@ "mkdirp": { "version": "0.5.3", "bundled": true, - "optional": true, "requires": { "minimist": "^1.2.5" } @@ -7424,8 +7412,7 @@ }, "npm-normalize-package-bin": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "npm-packlist": { "version": "1.4.8", @@ -7450,8 +7437,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -7461,7 +7447,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -7530,8 +7515,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -7561,7 +7545,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7579,7 +7562,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7618,13 +7600,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.1.1", - "bundled": true, - "optional": true + "bundled": true } } } @@ -13661,8 +13641,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -13844,8 +13823,7 @@ }, "minimist": { "version": "1.2.5", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.9.0", @@ -13867,7 +13845,6 @@ "mkdirp": { "version": "0.5.3", "bundled": true, - "optional": true, "requires": { "minimist": "^1.2.5" } @@ -14029,8 +14006,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -14078,7 +14054,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -14117,13 +14092,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.1.1", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -14443,8 +14416,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -14481,8 +14453,7 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", @@ -14491,8 +14462,7 @@ }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -14595,8 +14565,7 @@ }, "inherits": { "version": "2.0.4", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -14606,7 +14575,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -14632,7 +14600,6 @@ "minipass": { "version": "2.9.0", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -14649,7 +14616,6 @@ "mkdirp": { "version": "0.5.3", "bundled": true, - "optional": true, "requires": { "minimist": "^1.2.5" } @@ -14731,8 +14697,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -14742,7 +14707,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -14811,8 +14775,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -14842,7 +14805,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -14860,7 +14822,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -14899,13 +14860,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.1.1", - "bundled": true, - "optional": true + "bundled": true } } },