From 2573200bf06fe8e90ae98d725fd3e33cff918bec Mon Sep 17 00:00:00 2001 From: Matteo Gregoricchio Date: Sat, 22 Mar 2025 12:30:53 +0100 Subject: [PATCH 1/5] fix #167: create new option to provide server deployment sub-path --- samples/WebApp/Program.cs | 4 ++- samples/WebApp/Properties/launchSettings.json | 2 +- samples/WebApp/appsettings.json | 7 ++-- .../Endpoints/SerilogUiAppRoutes.cs | 16 ++++++++-- src/Serilog.Ui.Web/Models/UiOptions.cs | 23 +++++++++++++ .../Endpoints/SerilogUiAppRoutesTest.cs | 32 +++++++++++-------- .../Models/UiOptionsTest.cs | 3 ++ 7 files changed, 66 insertions(+), 21 deletions(-) diff --git a/samples/WebApp/Program.cs b/samples/WebApp/Program.cs index f60d0cf5..a793c17a 100644 --- a/samples/WebApp/Program.cs +++ b/samples/WebApp/Program.cs @@ -36,12 +36,14 @@ app.UseAuthentication(); app.UseAuthorization(); +var serverSubPath = bool.Parse(builder.Configuration["SerilogUi:AddServerSubPath"] ?? "false") == true ? "log" : ""; app.UseSerilogUi(options => options .WithHomeUrl("/#Test") + .WithServerSubPath(serverSubPath) .WithAuthenticationType(AuthenticationType.Jwt) .WithExpandedDropdownsByDefault() .EnableAuthorizationOnAppRoutes() - .InjectJavascript("/js/serilog-ui/custom.js") + .InjectJavascript($"{serverSubPath}/js/serilog-ui/custom.js") ); app.MapControllerRoute( diff --git a/samples/WebApp/Properties/launchSettings.json b/samples/WebApp/Properties/launchSettings.json index c3f722f2..76c9231f 100644 --- a/samples/WebApp/Properties/launchSettings.json +++ b/samples/WebApp/Properties/launchSettings.json @@ -4,7 +4,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:40034", + "applicationUrl": "http://localhost:40034/logs", "sslPort": 44304 } }, diff --git a/samples/WebApp/appsettings.json b/samples/WebApp/appsettings.json index 420ec9f2..3c7f4266 100644 --- a/samples/WebApp/appsettings.json +++ b/samples/WebApp/appsettings.json @@ -17,12 +17,11 @@ }, "SerilogUi": { "UserName": "BasicSampleUser", - "Password": "BasicSamplePwd" + "Password": "BasicSamplePwd", + "AddServerSubPath": true }, "Serilog": { - "Using": [ - "Serilog.Sinks.MongoDB" - ], + "Using": ["Serilog.Sinks.MongoDB"], "MinimumLevel": "Debug", "WriteTo": [ { diff --git a/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs b/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs index 26d7acac..3ab1b0eb 100644 --- a/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs +++ b/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs @@ -51,7 +51,7 @@ public Task RedirectHomeAsync() private async Task LoadStream(Stream stream, UiOptions options) { - StringBuilder htmlStringBuilder = new StringBuilder(await new StreamReader(stream).ReadToEndAsync()); + StringBuilder htmlStringBuilder = new(await new StreamReader(stream).ReadToEndAsync()); string authType = options.Authorization.AuthenticationType.ToString(); var feOpts = new @@ -63,7 +63,7 @@ private async Task LoadStream(Stream stream, UiOptions options) options.ShowBrand, options.HomeUrl, BlockHomeAccess, - options.RoutePrefix, + routePrefix = ConstructRoutesPrefix(options), options.ExpandDropdownsByDefault }; string encodeAuthOpts = Uri.EscapeDataString(JsonSerializer.Serialize(feOpts, JsonSerializerOptionsFactory.GetDefaultOptions)); @@ -75,4 +75,16 @@ private async Task LoadStream(Stream stream, UiOptions options) return htmlStringBuilder.ToString(); } + + private static string ConstructRoutesPrefix(UiOptions options) + { + var safeHostPath = string.IsNullOrWhiteSpace(options.ServerSubPath) ? "" : options.ServerSubPath; + var hostPathWithoutInitialSlash = safeHostPath.StartsWith("/", StringComparison.OrdinalIgnoreCase) ? + safeHostPath[1..] : safeHostPath; + var hostPathWithDivider = !string.IsNullOrWhiteSpace(hostPathWithoutInitialSlash) && + !hostPathWithoutInitialSlash.EndsWith('/') ? + $"{hostPathWithoutInitialSlash}/" : hostPathWithoutInitialSlash; + + return $"{hostPathWithDivider}{options.RoutePrefix}"; + } } \ No newline at end of file diff --git a/src/Serilog.Ui.Web/Models/UiOptions.cs b/src/Serilog.Ui.Web/Models/UiOptions.cs index b9820cf6..8b8ab88b 100644 --- a/src/Serilog.Ui.Web/Models/UiOptions.cs +++ b/src/Serilog.Ui.Web/Models/UiOptions.cs @@ -27,6 +27,12 @@ public class UiOptions(ProvidersOptions options) /// The route prefix. public string RoutePrefix { get; private set; } = "serilog-ui"; + /// + /// Gets the server sub-path deployment. + /// + /// The server sub path. + public string ServerSubPath { get; private set; } = string.Empty; + /// /// Get the option to auto-expand dropdowns in the log viewer. /// @@ -126,6 +132,23 @@ public UiOptions WithRoutePrefix(string routePrefix) return this; } + /// + /// Sets the server hosting base-path. + /// If the application is deployed under a server sub-path, this property provides the additional sub-path to + /// the dashboard to help the client-side routing.
+ /// If provided, the final routing result will be:
{server-base-path}/{UiOptions.ServerSubPath}/{UiOptions.RoutePrefix}. + ///
+ /// + /// Server root: "server.com" + /// IF the application is deployed at root level ("server.com/{my-app}") => NOT set ServerSubPath + /// IF the application is deployed at sub-path level ("server.com/{additional-path}/{my-app}") => MUST set ServerSubPath + /// + public UiOptions WithServerSubPath(string serverSubPath) + { + ServerSubPath = serverSubPath; + return this; + } + internal void Validate() { if (RoutePrefix.EndsWith('/')) throw new ArgumentException($"{nameof(RoutePrefix)} can't end with a slash."); diff --git a/tests/Serilog.Ui.Web.Tests/Endpoints/SerilogUiAppRoutesTest.cs b/tests/Serilog.Ui.Web.Tests/Endpoints/SerilogUiAppRoutesTest.cs index 07ec5640..c67b1054 100644 --- a/tests/Serilog.Ui.Web.Tests/Endpoints/SerilogUiAppRoutesTest.cs +++ b/tests/Serilog.Ui.Web.Tests/Endpoints/SerilogUiAppRoutesTest.cs @@ -39,18 +39,25 @@ public SerilogUiAppRoutesTest() _sut = new SerilogUiAppRoutes(_contextAccessor, _streamLoaderMock); } - [Fact] - public async Task It_gets_app_home() + [Theory] + [InlineData(null, "test")] + [InlineData("", "test")] + [InlineData(" ", "test")] + [InlineData("sub-path", "sub-path/test")] + [InlineData("sub-path/", "sub-path/test")] + [InlineData("/sub-path/", "sub-path/test")] + public async Task It_gets_app_home(string? serverSubPath, string expectedRoutePrefix) { // Arrange - _sut.SetOptions(new UiOptions(new ProvidersOptions()) - { - BodyContent = "
body-test
", - HeadContent = "
head-test
" - } - .WithAuthenticationType(AuthenticationType.Jwt) - .WithRoutePrefix("test") - .WithHomeUrl("home-url") + var body = "
body-test
"; + var head = "
head-test
"; + var baseOpts = new UiOptions(new()) { BodyContent = body, HeadContent = head }; + _sut + .SetOptions(baseOpts + .WithAuthenticationType(AuthenticationType.Jwt) + .WithRoutePrefix("test") + .WithServerSubPath(serverSubPath!) + .WithHomeUrl("home-url") ); _testContext.Request.Path = "/serilog-ui-url/"; _testContext.Response.Body = new MemoryStream(); @@ -75,9 +82,8 @@ public async Task It_gets_app_home() "
" + "
body-test
" - ); + "%22%2C%22blockHomeAccess%22%3Afalse%2C%22routePrefix%22%3A%22" + Uri.EscapeDataString(expectedRoutePrefix) + + "%22%2C%22expandDropdownsByDefault%22%3Afalse%7D';
body-test
"); } [Fact] diff --git a/tests/Serilog.Ui.Web.Tests/Models/UiOptionsTest.cs b/tests/Serilog.Ui.Web.Tests/Models/UiOptionsTest.cs index cebb72d0..eddd7fa4 100644 --- a/tests/Serilog.Ui.Web.Tests/Models/UiOptionsTest.cs +++ b/tests/Serilog.Ui.Web.Tests/Models/UiOptionsTest.cs @@ -16,6 +16,7 @@ public void It_gets_default_options() sut.HomeUrl.Should().Be("/"); sut.RoutePrefix.Should().Be("serilog-ui"); + sut.ServerSubPath.Should().BeEmpty(); sut.BodyContent.Should().BeEmpty(); sut.HeadContent.Should().BeEmpty(); sut.ShowBrand.Should().BeTrue(); @@ -33,12 +34,14 @@ public void It_sets_options() .WithHomeUrl("test") .WithAuthenticationType(AuthenticationType.Basic) .WithRoutePrefix("prefix") + .WithServerSubPath("log") .HideSerilogUiBrand() .WithExpandedDropdownsByDefault() .EnableAuthorizationOnAppRoutes(); sut.HomeUrl.Should().Be("test"); sut.RoutePrefix.Should().Be("prefix"); + sut.ServerSubPath.Should().Be("log"); sut.ShowBrand.Should().BeFalse(); sut.ExpandDropdownsByDefault.Should().BeTrue(); sut.Authorization.AuthenticationType.Should().Be(AuthenticationType.Basic); From 500dbb5363a72fcd911274c5909ab84aaa27d642 Mon Sep 17 00:00:00 2001 From: Matteo Gregoricchio Date: Sat, 22 Mar 2025 12:35:51 +0100 Subject: [PATCH 2/5] fix program --- samples/WebApp/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/WebApp/Program.cs b/samples/WebApp/Program.cs index a793c17a..92b81a59 100644 --- a/samples/WebApp/Program.cs +++ b/samples/WebApp/Program.cs @@ -36,7 +36,7 @@ app.UseAuthentication(); app.UseAuthorization(); -var serverSubPath = bool.Parse(builder.Configuration["SerilogUi:AddServerSubPath"] ?? "false") == true ? "log" : ""; +var serverSubPath = bool.Parse(builder.Configuration["SerilogUi:AddServerSubPath"] ?? "false") == true ? "log" : "/"; app.UseSerilogUi(options => options .WithHomeUrl("/#Test") .WithServerSubPath(serverSubPath) From 05f9c0894af7336e171569e9b75a70438e4738dd Mon Sep 17 00:00:00 2001 From: Matteo Gregoricchio Date: Sun, 23 Mar 2025 00:32:34 +0100 Subject: [PATCH 3/5] fix sample --- samples/WebApp/Program.cs | 4 ++-- samples/WebApp/Properties/launchSettings.json | 3 ++- samples/WebApp/appsettings.json | 2 +- src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs | 10 +++++----- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/samples/WebApp/Program.cs b/samples/WebApp/Program.cs index 92b81a59..afec8efc 100644 --- a/samples/WebApp/Program.cs +++ b/samples/WebApp/Program.cs @@ -36,14 +36,14 @@ app.UseAuthentication(); app.UseAuthorization(); -var serverSubPath = bool.Parse(builder.Configuration["SerilogUi:AddServerSubPath"] ?? "false") == true ? "log" : "/"; +var serverSubPath = bool.Parse(builder.Configuration["SerilogUi:AddServerSubPath"] ?? "false") ? "logs/" : ""; app.UseSerilogUi(options => options .WithHomeUrl("/#Test") .WithServerSubPath(serverSubPath) .WithAuthenticationType(AuthenticationType.Jwt) .WithExpandedDropdownsByDefault() .EnableAuthorizationOnAppRoutes() - .InjectJavascript($"{serverSubPath}/js/serilog-ui/custom.js") + .InjectJavascript($"/{serverSubPath}js/serilog-ui/custom.js") ); app.MapControllerRoute( diff --git a/samples/WebApp/Properties/launchSettings.json b/samples/WebApp/Properties/launchSettings.json index 76c9231f..a74b5495 100644 --- a/samples/WebApp/Properties/launchSettings.json +++ b/samples/WebApp/Properties/launchSettings.json @@ -23,7 +23,8 @@ "commandName": "IISExpress", "launchBrowser": true, "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "SerilogUi:AddServerSubPath": "true" } } } diff --git a/samples/WebApp/appsettings.json b/samples/WebApp/appsettings.json index 3c7f4266..129561f7 100644 --- a/samples/WebApp/appsettings.json +++ b/samples/WebApp/appsettings.json @@ -18,7 +18,7 @@ "SerilogUi": { "UserName": "BasicSampleUser", "Password": "BasicSamplePwd", - "AddServerSubPath": true + "AddServerSubPath": false }, "Serilog": { "Using": ["Serilog.Sinks.MongoDB"], diff --git a/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs b/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs index 3ab1b0eb..e8b3483b 100644 --- a/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs +++ b/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs @@ -63,7 +63,7 @@ private async Task LoadStream(Stream stream, UiOptions options) options.ShowBrand, options.HomeUrl, BlockHomeAccess, - routePrefix = ConstructRoutesPrefix(options), + RoutePrefix = ConstructRoutesPrefix(options), options.ExpandDropdownsByDefault }; string encodeAuthOpts = Uri.EscapeDataString(JsonSerializer.Serialize(feOpts, JsonSerializerOptionsFactory.GetDefaultOptions)); @@ -79,11 +79,11 @@ private async Task LoadStream(Stream stream, UiOptions options) private static string ConstructRoutesPrefix(UiOptions options) { var safeHostPath = string.IsNullOrWhiteSpace(options.ServerSubPath) ? "" : options.ServerSubPath; - var hostPathWithoutInitialSlash = safeHostPath.StartsWith("/", StringComparison.OrdinalIgnoreCase) ? - safeHostPath[1..] : safeHostPath; + var hostPathWithoutInitialSlash = safeHostPath.StartsWith("/", StringComparison.OrdinalIgnoreCase) ? safeHostPath[1..] : safeHostPath; var hostPathWithDivider = !string.IsNullOrWhiteSpace(hostPathWithoutInitialSlash) && - !hostPathWithoutInitialSlash.EndsWith('/') ? - $"{hostPathWithoutInitialSlash}/" : hostPathWithoutInitialSlash; + !hostPathWithoutInitialSlash.EndsWith('/') + ? $"{hostPathWithoutInitialSlash}/" + : hostPathWithoutInitialSlash; return $"{hostPathWithDivider}{options.RoutePrefix}"; } From 633eab14d47b1c9537cad40e0defee6131ea6d86 Mon Sep 17 00:00:00 2001 From: followynne Date: Sat, 29 Mar 2025 15:36:49 +0100 Subject: [PATCH 4/5] fix: apply review comment --- .../Endpoints/SerilogUiAppRoutes.cs | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs b/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs index e8b3483b..091091b9 100644 --- a/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs +++ b/src/Serilog.Ui.Web/Endpoints/SerilogUiAppRoutes.cs @@ -78,13 +78,26 @@ private async Task LoadStream(Stream stream, UiOptions options) private static string ConstructRoutesPrefix(UiOptions options) { - var safeHostPath = string.IsNullOrWhiteSpace(options.ServerSubPath) ? "" : options.ServerSubPath; - var hostPathWithoutInitialSlash = safeHostPath.StartsWith("/", StringComparison.OrdinalIgnoreCase) ? safeHostPath[1..] : safeHostPath; - var hostPathWithDivider = !string.IsNullOrWhiteSpace(hostPathWithoutInitialSlash) && - !hostPathWithoutInitialSlash.EndsWith('/') - ? $"{hostPathWithoutInitialSlash}/" - : hostPathWithoutInitialSlash; - - return $"{hostPathWithDivider}{options.RoutePrefix}"; + // If ServerSubPath is empty, just return the RoutePrefix + if (string.IsNullOrWhiteSpace(options.ServerSubPath)) return options.RoutePrefix; + + // Create a span to avoid allocations when slicing + ReadOnlySpan path = options.ServerSubPath.AsSpan(); + // Skip leading slash if present + if (path.Length > 0 && path[0] == '/') + { + path = path[1..]; + } + + // If the path is empty after removing the slash, just return the RoutePrefix + if (path.Length == 0) + { + return options.RoutePrefix; + } + + // Check if we need a trailing slash + bool needsTrailingSlash = path.Length > 0 && path[^1] != '/'; + // Build the final string with minimal allocations + return needsTrailingSlash ? string.Concat(path.ToString(), "/", options.RoutePrefix) : string.Concat(path.ToString(), options.RoutePrefix); } } \ No newline at end of file From 027441305f9f13557453a42ce9f17ba3ffb58d72 Mon Sep 17 00:00:00 2001 From: followynne Date: Sat, 29 Mar 2025 18:30:41 +0100 Subject: [PATCH 5/5] chore: update & rewrite pipelines build --- .github/workflows/DotNET-build.yml | 15 +- .../workflows/DotNET-reporting-on-build.yml | 17 +- .github/workflows/JS-build.yml | 1 + .github/workflows/JS-reporting-on-build.yml | 19 +- .github/workflows/Release.yml | 19 +- .nuke/build.schema.json | 206 ++- build/Build.Backend.Tests.cs | 10 +- build/Build.CI.GithubActions.cs | 32 +- build/CustomGithubActionsAttribute.cs | 39 +- build/YarnTasks.cs | 1554 ----------------- build/_build.csproj | 7 +- build/custom-tooling/yarn.Generated.cs | 495 ++++++ build/custom-tooling/yarn.json | 164 ++ .../Serilog.Ui.MongoDbProvider.csproj | 2 +- tests/Directory.Build.props | 2 +- .../Serilog.Ui.MongoDbProvider.Tests.csproj | 7 +- .../Builders/MongoDbDataProviderBuilder.cs | 6 +- .../Util/IntegrationDbGeneration.cs | 27 +- 18 files changed, 877 insertions(+), 1745 deletions(-) delete mode 100644 build/YarnTasks.cs create mode 100644 build/custom-tooling/yarn.Generated.cs create mode 100644 build/custom-tooling/yarn.json diff --git a/.github/workflows/DotNET-build.yml b/.github/workflows/DotNET-build.yml index 7a39ec1d..64c74768 100644 --- a/.github/workflows/DotNET-build.yml +++ b/.github/workflows/DotNET-build.yml @@ -30,22 +30,15 @@ jobs: ubuntu-latest: name: ubuntu-latest runs-on: ubuntu-latest - steps: - # temporary from here... - - name: Setup dotnet 6 - uses: actions/setup-dotnet@v4 + + - uses: actions/setup-dotnet@v4 with: dotnet-version: '6.0.x' - - name: Setup dotnet 7 - uses: actions/setup-dotnet@v4 - with: - dotnet-version: '7.0.x' - - name: Setup dotnet 8 - uses: actions/setup-dotnet@v4 + + - uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' - # ...to here - uses: actions/setup-java@v4 with: diff --git a/.github/workflows/DotNET-reporting-on-build.yml b/.github/workflows/DotNET-reporting-on-build.yml index f270d63a..18020d3f 100644 --- a/.github/workflows/DotNET-reporting-on-build.yml +++ b/.github/workflows/DotNET-reporting-on-build.yml @@ -7,15 +7,20 @@ on: workflows: ['DotNET-build'] types: - completed +permissions: + contents: read + actions: read + checks: write jobs: upload: runs-on: ubuntu-latest steps: - - uses: phoenix-actions/test-reporting@v14 + - uses: actions/checkout@v4 + - uses: dorny/test-reporter@v2 with: - artifact: test-results # artifact name - name: DotNET - Tests # Name of the check run which will be created - path: '**/test-results.trx' # Path to test results (inside artifact .zip) - reporter: dotnet-trx # Format of test results - output-to: checks + artifact: test-results + name: DotNET - Tests + path: '**/test-results.trx' + reporter: dotnet-trx + fail-on-error: false diff --git a/.github/workflows/JS-build.yml b/.github/workflows/JS-build.yml index 233bd1b4..c1454cfa 100644 --- a/.github/workflows/JS-build.yml +++ b/.github/workflows/JS-build.yml @@ -31,6 +31,7 @@ jobs: name: ubuntu-latest runs-on: ubuntu-latest steps: + - uses: actions/setup-java@v4 with: distribution: 'temurin' diff --git a/.github/workflows/JS-reporting-on-build.yml b/.github/workflows/JS-reporting-on-build.yml index 23d05c31..e14d1747 100644 --- a/.github/workflows/JS-reporting-on-build.yml +++ b/.github/workflows/JS-reporting-on-build.yml @@ -7,15 +7,20 @@ on: workflows: ['JS-build'] types: - completed +permissions: + contents: read + actions: read + checks: write jobs: - upload: + report: runs-on: ubuntu-latest steps: - - uses: phoenix-actions/test-reporting@v14 + - uses: actions/checkout@v4 + - uses: dorny/test-reporter@v2 with: - artifact: test-results # artifact name - name: JS - Tests # Name of the check run which will be created - path: '**/test-junit-report.xml' # Path to test results (inside artifact .zip) - reporter: jest-junit # Format of test results - output-to: checks + artifact: test-results + name: JS - Tests + path: '**/test-junit-report.xml' + reporter: jest-junit + fail-on-error: false diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 962e9b37..194547c3 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -20,22 +20,22 @@ on: workflow_dispatch: inputs: ElasticProvider: - description: 'Elastic Provider' + description: "Elastic Provider" required: true MongoProvider: - description: 'Mongo Provider' + description: "Mongo Provider" required: true MsSqlProvider: - description: 'Ms Sql Provider' + description: "Ms Sql Provider" required: true MySqlProvider: - description: 'My Sql Provider' + description: "My Sql Provider" required: true PostgresProvider: - description: 'Postgres Provider' + description: "Postgres Provider" required: true Ui: - description: 'Ui' + description: "Ui" required: true jobs: @@ -43,6 +43,7 @@ jobs: name: ubuntu-latest runs-on: ubuntu-latest steps: + - uses: actions/setup-java@v4 with: distribution: 'temurin' @@ -71,11 +72,10 @@ jobs: NugetApiKey: ${{ secrets.NUGET_API_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: phoenix-actions/test-reporting@v14 + - uses: dorny/test-reporter@v2 if: always() with: name: DotNET - Tests - output-to: checks path: '**/test-results.trx' reporter: dotnet-trx fail-on-error: false @@ -96,11 +96,10 @@ jobs: -Dsonar.test.inclusions=src/Serilog.Ui.Web/src/__tests__/**/* -Dsonar.javascript.lcov.reportPaths=./src/Serilog.Ui.Web/src/reports/coverage/lcov.info - - uses: phoenix-actions/test-reporting@v14 + - uses: dorny/test-reporter@v2 if: always() with: name: JS - Tests - output-to: checks path: '**/test-junit-report.xml' reporter: jest-junit fail-on-error: false diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 12486dce..33c361d3 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -1,68 +1,75 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "$ref": "#/definitions/build", - "title": "Build Schema", "definitions": { - "build": { - "type": "object", + "Host": { + "type": "string", + "enum": [ + "AppVeyor", + "AzurePipelines", + "Bamboo", + "Bitbucket", + "Bitrise", + "GitHubActions", + "GitLab", + "Jenkins", + "Rider", + "SpaceAutomation", + "TeamCity", + "Terminal", + "TravisCI", + "VisualStudio", + "VSCode" + ] + }, + "ExecutableTarget": { + "type": "string", + "enum": [ + "Backend_Clean", + "Backend_Compile", + "Backend_Report_Ci", + "Backend_Restore", + "Backend_SonarScan_End", + "Backend_SonarScan_Start", + "Backend_Test", + "Backend_Test_Ci", + "Clean", + "Frontend_Build", + "Frontend_Clean", + "Frontend_Restore", + "Frontend_Tests", + "Frontend_Tests_Ci", + "Pack", + "Publish" + ] + }, + "Verbosity": { + "type": "string", + "description": "", + "enum": [ + "Verbose", + "Normal", + "Minimal", + "Quiet" + ] + }, + "NukeBuild": { "properties": { - "Configuration": { - "type": "string", - "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", - "enum": [ - "Debug", - "Release" - ] - }, "Continue": { "type": "boolean", "description": "Indicates to continue a previously failed build attempt" }, - "ElasticProvider": { - "type": "string" - }, "Help": { "type": "boolean", "description": "Shows the help text for this build assembly" }, "Host": { - "type": "string", "description": "Host for execution. Default is 'automatic'", - "enum": [ - "AppVeyor", - "AzurePipelines", - "Bamboo", - "Bitbucket", - "Bitrise", - "GitHubActions", - "GitLab", - "Jenkins", - "Rider", - "SpaceAutomation", - "TeamCity", - "Terminal", - "TravisCI", - "VisualStudio", - "VSCode" - ] - }, - "MongoProvider": { - "type": "string" - }, - "MsSqlProvider": { - "type": "string" - }, - "MySqlProvider": { - "type": "string" + "$ref": "#/definitions/Host" }, "NoLogo": { "type": "boolean", "description": "Disables displaying the NUKE logo" }, - "NugetApiKey": { - "type": "string", - "default": "Secrets must be entered via 'nuke :secrets [profile]'" - }, "Partition": { "type": "string", "description": "Partition to use on CI" @@ -71,9 +78,6 @@ "type": "boolean", "description": "Shows the execution plan (HTML)" }, - "PostgresProvider": { - "type": "string" - }, "Profile": { "type": "array", "description": "Defines the profiles to load", @@ -89,27 +93,53 @@ "type": "array", "description": "List of targets to be skipped. Empty list skips all dependencies", "items": { - "type": "string", - "enum": [ - "Backend_Clean", - "Backend_Compile", - "Backend_Report_Ci", - "Backend_Restore", - "Backend_SonarScan_End", - "Backend_SonarScan_Start", - "Backend_Test", - "Backend_Test_Ci", - "Clean", - "Frontend_Build", - "Frontend_Clean", - "Frontend_Restore", - "Frontend_Tests", - "Frontend_Tests_Ci", - "Pack", - "Publish" - ] + "$ref": "#/definitions/ExecutableTarget" + } + }, + "Target": { + "type": "array", + "description": "List of targets to be invoked. Default is '{default_target}'", + "items": { + "$ref": "#/definitions/ExecutableTarget" } }, + "Verbosity": { + "description": "Logging verbosity during build execution. Default is 'Normal'", + "$ref": "#/definitions/Verbosity" + } + } + } + }, + "allOf": [ + { + "properties": { + "Configuration": { + "type": "string", + "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", + "enum": [ + "Debug", + "Release" + ] + }, + "ElasticProvider": { + "type": "string" + }, + "MongoProvider": { + "type": "string" + }, + "MsSqlProvider": { + "type": "string" + }, + "MySqlProvider": { + "type": "string" + }, + "NugetApiKey": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" + }, + "PostgresProvider": { + "type": "string" + }, "Solution": { "type": "string", "description": "Path to a solution file that is automatically loaded" @@ -122,45 +152,13 @@ "type": "string", "default": "Secrets must be entered via 'nuke :secrets [profile]'" }, - "Target": { - "type": "array", - "description": "List of targets to be invoked. Default is '{default_target}'", - "items": { - "type": "string", - "enum": [ - "Backend_Clean", - "Backend_Compile", - "Backend_Report_Ci", - "Backend_Restore", - "Backend_SonarScan_End", - "Backend_SonarScan_Start", - "Backend_Test", - "Backend_Test_Ci", - "Clean", - "Frontend_Build", - "Frontend_Clean", - "Frontend_Restore", - "Frontend_Tests", - "Frontend_Tests_Ci", - "Pack", - "Publish" - ] - } - }, "Ui": { "type": "string" - }, - "Verbosity": { - "type": "string", - "description": "Logging verbosity during build execution. Default is 'Normal'", - "enum": [ - "Minimal", - "Normal", - "Quiet", - "Verbose" - ] } } + }, + { + "$ref": "#/definitions/NukeBuild" } - } + ] } diff --git a/build/Build.Backend.Tests.cs b/build/Build.Backend.Tests.cs index 1bba24ff..d9136a34 100644 --- a/build/Build.Backend.Tests.cs +++ b/build/Build.Backend.Tests.cs @@ -1,3 +1,4 @@ +using System; using Nuke.Common; using Nuke.Common.Tooling; using Nuke.Common.Tools.Docker; @@ -35,8 +36,15 @@ partial class Build .Description("Runs dotnet-coverage collect, with coverlet coverage") .Executes(() => { + var user = Environment.GetEnvironmentVariable("USER") ?? Environment.GetEnvironmentVariable("USERNAME"); + + // due to [ref](https://github.com/Mongo2Go/Mongo2Go/issues/144) + ProcessTasks + .StartProcess("sudo", $"chown -R {user}:{user} /home/runneradmin") + .AssertZeroExitCode(); + // encoded spaces [ref](https://github.com/microsoft/azure-pipelines-tasks/issues/18731#issuecomment-1689118779) DotnetCoverage?.Invoke( - @"collect -f xml -o coverage.xml dotnet test --configuration Release --no-build --collect=""XPlat Code Coverage;Format=cobertura"" --logger=""trx;LogFileName=test-results.trx"""); + "collect -f xml -o coverage.xml dotnet test --configuration=Release --no-build --collect=XPlat%20Code%20Coverage;Format=cobertura --logger=trx;LogFileName=test-results.trx"); }); Target Backend_Report_Ci => targetDefinition => targetDefinition diff --git a/build/Build.CI.GithubActions.cs b/build/Build.CI.GithubActions.cs index d486fc75..a986e0b1 100644 --- a/build/Build.CI.GithubActions.cs +++ b/build/Build.CI.GithubActions.cs @@ -2,6 +2,7 @@ using Nuke.Common.CI.GitHubActions; using Nuke.Common.Tooling; using Nuke.Common.Tools.SonarScanner; +using Serilog; using static CustomGithubActionsAttribute; /** @@ -79,20 +80,24 @@ ReleaseParams[] ReleaseInfos() => new(nameof(Ui), Ui, "Serilog.Ui.Web") ]; - readonly bool OnGithubActionRun = GitHubActions.Instance != null && - !string.IsNullOrWhiteSpace(GitHubActions.Instance.RunId.ToString()); + readonly bool OnGithubActionRun = GitHubActions.Instance != null && !string.IsNullOrWhiteSpace($"{GitHubActions.Instance.RunId}"); - readonly bool IsPr = GitHubActions.Instance != null && - GitHubActions.Instance.IsPullRequest; + readonly bool IsPr = GitHubActions.Instance != null && GitHubActions.Instance.IsPullRequest; + + private bool RunSonarqube() + => OnGithubActionRun && !IsPr && !string.IsNullOrWhiteSpace(SonarCloudInfo.Organization) && !string.IsNullOrWhiteSpace(SonarCloudInfo.BackendProjectKey); Target Backend_SonarScan_Start => targetDefinition => targetDefinition .DependsOn(Backend_Restore) - .OnlyWhenStatic(() => OnGithubActionRun && !IsPr && - !string.IsNullOrWhiteSpace(SonarCloudInfo.Organization) && - !string.IsNullOrWhiteSpace(SonarCloudInfo.BackendProjectKey) - ) .Executes(() => { + var condition = RunSonarqube(); + if (!condition) + { + Log.Information("--- Skipped Sonarqube analysis ---"); + return; + } + SonarScannerTasks.SonarScannerBegin(new SonarScannerBeginSettings() .SetExcludeTestProjects(true) .SetToken(SonarToken) @@ -116,12 +121,15 @@ ReleaseParams[] ReleaseInfos() => Target Backend_SonarScan_End => targetDefinition => targetDefinition .DependsOn(Backend_Report_Ci) - .OnlyWhenStatic(() => OnGithubActionRun && !IsPr && - !string.IsNullOrWhiteSpace(SonarCloudInfo.Organization) && - !string.IsNullOrWhiteSpace(SonarCloudInfo.BackendProjectKey) - ) .Executes(() => { + var condition = RunSonarqube(); + if (!condition) + { + Log.Information("--- Skipped Sonarqube analysis ---"); + return; + } + SonarScannerTasks.SonarScannerEnd(new SonarScannerEndSettings() .SetToken(SonarToken) .SetProcessEnvironmentVariable("GITHUB_TOKEN", GitHubActions.Instance.Token) diff --git a/build/CustomGithubActionsAttribute.cs b/build/CustomGithubActionsAttribute.cs index 9e984889..d94775bc 100644 --- a/build/CustomGithubActionsAttribute.cs +++ b/build/CustomGithubActionsAttribute.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Nuke.Common.CI.GitHubActions; using Nuke.Common.CI.GitHubActions.Configuration; @@ -12,25 +11,24 @@ class CustomGithubActionsAttribute(string name, GitHubActionsImage image, params GitHubActionsImage[] images) : GitHubActionsAttribute(name, image, images) { - public GithubAction[] AddGithubActions { get; set; } = Array.Empty(); + public GithubAction[] AddGithubActions { get; set; } = []; public enum GithubAction { Frontend_SonarScan_Task, - Frontend_Reporter, - Frontend_Artifact, - Backend_Reporter, - Backend_Artifact, } protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyCollection relevantTargets) { var job = base.GetJobs(image, relevantTargets); - var newSteps = new List(new GitHubActionsStep[] { new GitHubActionSetupJava17() }.Concat(job.Steps)); + GitHubActionsStep[] backendSteps = AddGithubActions.Any(act => act == GithubAction.Backend_Artifact) ? + [new GitHubActionSetupDotnet("6.0.x"), new GitHubActionSetupDotnet("8.0.x"),] : []; + GitHubActionsStep[] setupSteps = [.. backendSteps, new GitHubActionSetupJava17(), .. job.Steps]; + var newSteps = new List(setupSteps); foreach (var act in AddGithubActions) { @@ -54,7 +52,7 @@ protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyC } } - job.Steps = newSteps.ToArray(); + job.Steps = [.. newSteps]; return job; } } @@ -83,6 +81,26 @@ public override void Write(CustomFileWriter writer) } } +class GitHubActionSetupDotnet(string dotnetV) : GitHubActionsStep +{ + public override void Write(CustomFileWriter writer) + { + writer.WriteLine(); // empty line to separate tasks + + writer.WriteLine("- uses: actions/setup-dotnet@v4"); + + using (writer.Indent()) + { + writer.WriteLine("with:"); + + using (writer.Indent()) + { + writer.WriteLine($"dotnet-version: '{dotnetV}'"); + } + } + } +} + class GithubActionUploadArtifact(string path) : GitHubActionsStep { public override void Write(CustomFileWriter writer) @@ -158,7 +176,7 @@ public override void Write(CustomFileWriter writer) { writer.WriteLine(); // empty line to separate tasks - writer.WriteLine("- uses: phoenix-actions/test-reporting@v14"); + writer.WriteLine("- uses: dorny/test-reporter@v2"); using (writer.Indent()) { @@ -168,7 +186,6 @@ public override void Write(CustomFileWriter writer) using (writer.Indent()) { writer.WriteLine($"name: {name}"); - writer.WriteLine($"output-to: checks"); writer.WriteLine($"path: {path}"); writer.WriteLine($"reporter: {reporter}"); writer.WriteLine("fail-on-error: false"); diff --git a/build/YarnTasks.cs b/build/YarnTasks.cs deleted file mode 100644 index 93f63f3f..00000000 --- a/build/YarnTasks.cs +++ /dev/null @@ -1,1554 +0,0 @@ -// Generated from https://github.com/nuke-build/nuke/blob/master/source/Nuke.Common/Tools/Yarn/Yarn.json -// TODO: replace with official implementation when ready - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using JetBrains.Annotations; -using Nuke.Common.IO; -using Nuke.Common.Tooling; -using Serilog; - -// ReSharper disable All - -/// -///

Yarn is a package manager that doubles down as project manager. Whether you work on one-shot projects or large monorepos, as a hobbyist or an enterprise user, we've got you covered.

-///

For more details, visit the official website.

-///
-[PublicAPI] -[ExcludeFromCodeCoverage] -[PathToolRequirement(YarnPathExecutable)] -public partial class YarnTasks - : IRequirePathTool -{ - public const string YarnPathExecutable = "yarn"; - - /// - /// Path to the Yarn executable. - /// - public static string YarnPath => - ToolPathResolver.TryGetEnvironmentExecutable("YARN_EXE") ?? - ToolPathResolver.GetPathExecutable("yarn"); - - public static Action YarnLogger { get; set; } = CustomLogger; - - /// - ///

Yarn is a package manager that doubles down as project manager. Whether you work on one-shot projects or large monorepos, as a hobbyist or an enterprise user, we've got you covered.

- ///

For more details, visit the official website.

- ///
- public static IReadOnlyCollection Yarn(ref ArgumentStringHandler arguments, - string? workingDirectory = null, - IReadOnlyDictionary? environmentVariables = null, - int? timeout = null, - bool? logOutput = null, - bool? logInvocation = null, - Action? customLogger = null) - { - using var process = ProcessTasks.StartProcess(YarnPath, - arguments, workingDirectory, environmentVariables, timeout, logOutput, - logInvocation, customLogger ?? YarnLogger); - process.AssertZeroExitCode(); - return process.Output; - } - - /// - ///

Install the project dependencies

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • --check-cache via
  • - ///
  • --immutable via
  • - ///
  • --immutable-cache via
  • - ///
  • --inline-builds via
  • - ///
  • --json via
  • - ///
  • --mode via
  • - ///
- ///
- public static IReadOnlyCollection YarnInstall(YarnInstallSettings? toolSettings = null) - { - toolSettings = toolSettings ?? new YarnInstallSettings(); - using var process = ProcessTasks.StartProcess(toolSettings); - process.AssertZeroExitCode(); - return process.Output; - } - - /// - ///

Install the project dependencies

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • --check-cache via
  • - ///
  • --immutable via
  • - ///
  • --immutable-cache via
  • - ///
  • --inline-builds via
  • - ///
  • --json via
  • - ///
  • --mode via
  • - ///
- ///
- public static IReadOnlyCollection YarnInstall(Configure configurator) - { - return YarnInstall(configurator(new YarnInstallSettings())); - } - - /// - ///

Install the project dependencies

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • --check-cache via
  • - ///
  • --immutable via
  • - ///
  • --immutable-cache via
  • - ///
  • --inline-builds via
  • - ///
  • --json via
  • - ///
  • --mode via
  • - ///
- ///
- public static IEnumerable<(YarnInstallSettings Settings, IReadOnlyCollection Output)> YarnInstall( - CombinatorialConfigure configurator, - int degreeOfParallelism = 1, - bool completeOnFailure = false) - { - return configurator.Invoke(YarnInstall, YarnLogger, degreeOfParallelism, completeOnFailure); - } - - /// - ///

Run a script defined in the package.json

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • <arguments> via
  • - ///
  • <command> via
  • - ///
  • --binaries-only via
  • - ///
  • --top-level via
  • - ///
- ///
- public static IReadOnlyCollection YarnRun(YarnRunSettings? toolSettings = null) - { - toolSettings = toolSettings ?? new YarnRunSettings(); - using var process = ProcessTasks.StartProcess(toolSettings); - process.AssertZeroExitCode(); - return process.Output; - } - - /// - ///

Run a script defined in the package.json

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • <arguments> via
  • - ///
  • <command> via
  • - ///
  • --binaries-only via
  • - ///
  • --top-level via
  • - ///
- ///
- public static IReadOnlyCollection YarnRun(Configure configurator) - { - return YarnRun(configurator(new YarnRunSettings())); - } - - /// - ///

Run a script defined in the package.json

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • <arguments> via
  • - ///
  • <command> via
  • - ///
  • --binaries-only via
  • - ///
  • --top-level via
  • - ///
- ///
- public static IEnumerable<(YarnRunSettings Settings, IReadOnlyCollection Output)> YarnRun( - CombinatorialConfigure configurator, - int degreeOfParallelism = 1, - bool completeOnFailure = false) - { - return configurator.Invoke(YarnRun, YarnLogger, degreeOfParallelism, completeOnFailure); - } - - /// - ///

Read a configuration settings

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • <name> via
  • - ///
  • --json via
  • - ///
  • --no-redacted via
  • - ///
- ///
- public static IReadOnlyCollection YarnGetConfig(YarnGetConfigSettings? toolSettings = null) - { - toolSettings = toolSettings ?? new YarnGetConfigSettings(); - using var process = ProcessTasks.StartProcess(toolSettings); - process.AssertZeroExitCode(); - return process.Output; - } - - /// - ///

Read a configuration settings

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • <name> via
  • - ///
  • --json via
  • - ///
  • --no-redacted via
  • - ///
- ///
- public static IReadOnlyCollection YarnGetConfig(Configure configurator) - { - return YarnGetConfig(configurator(new YarnGetConfigSettings())); - } - - /// - ///

Read a configuration settings

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • <name> via
  • - ///
  • --json via
  • - ///
  • --no-redacted via
  • - ///
- ///
- public static IEnumerable<(YarnGetConfigSettings Settings, IReadOnlyCollection Output)> YarnGetConfig( - CombinatorialConfigure configurator, - int degreeOfParallelism = 1, - bool completeOnFailure = false) - { - return configurator.Invoke(YarnGetConfig, YarnLogger, degreeOfParallelism, completeOnFailure); - } - - /// - ///

Change a configuration settings

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • <name> via
  • - ///
  • <value> via
  • - ///
  • --home via
  • - ///
  • --json via
  • - ///
- ///
- public static IReadOnlyCollection YarnSetConfig(YarnSetConfigSettings? toolSettings = null) - { - toolSettings = toolSettings ?? new YarnSetConfigSettings(); - using var process = ProcessTasks.StartProcess(toolSettings); - process.AssertZeroExitCode(); - return process.Output; - } - - /// - ///

Change a configuration settings

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • <name> via
  • - ///
  • <value> via
  • - ///
  • --home via
  • - ///
  • --json via
  • - ///
- ///
- public static IReadOnlyCollection YarnSetConfig(Configure configurator) - { - return YarnSetConfig(configurator(new YarnSetConfigSettings())); - } - - /// - ///

Change a configuration settings

- ///

For more details, visit the official website.

- ///
- /// - ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

- ///
    - ///
  • <name> via
  • - ///
  • <value> via
  • - ///
  • --home via
  • - ///
  • --json via
  • - ///
- ///
- public static IEnumerable<(YarnSetConfigSettings Settings, IReadOnlyCollection Output)> YarnSetConfig( - CombinatorialConfigure configurator, - int degreeOfParallelism = 1, - bool completeOnFailure = false) - { - return configurator.Invoke(YarnSetConfig, YarnLogger, degreeOfParallelism, completeOnFailure); - } - - public static void CustomLogger(OutputType type, string output) - { - switch (type) - { - // Log standard output as Normal - case OutputType.Std: - Log.Debug("{Output}", output); - break; - - // Log output on err stream that contains 'warning' as Warning - case OutputType.Err when output.Contains("warning", StringComparison.OrdinalIgnoreCase): - Log.Warning("{Output}", output); - break; - - // Log diagnostic output on error stream as Trace - case OutputType.Err - when output.Contains("Building", StringComparison.OrdinalIgnoreCase) && - output.Contains("for production", StringComparison.OrdinalIgnoreCase): - Log.Verbose("{Output}", output); - break; - - // Log other output on err stream as Error - case OutputType.Err: - Log.Error("{Output}", output); - break; - default: - throw new ArgumentOutOfRangeException(nameof(type), type, null); - } - } - - public static bool IsScriptAvailable(string name, AbsolutePath sourceDirectory) - { - var output = YarnRun(o => o.SetProcessWorkingDirectory(sourceDirectory) - .DisableProcessLogOutput() - .DisableProcessLogInvocation()); - var scripts = output.Where(o => o.Type == OutputType.Std).Select(o => o.Text); - return scripts.Any(line => line.EndsWith($"- {name}")); - } -} - -#region YarnInstallSettings - -/// -/// Used within . -/// -[PublicAPI] -[ExcludeFromCodeCoverage] -[Serializable] -public partial class YarnInstallSettings : ToolSettings -{ - /// - /// Path to the Yarn executable. - /// - public override string ProcessToolPath => base.ProcessToolPath ?? YarnTasks.YarnPath; - - public override Action ProcessLogger => base.ProcessLogger ?? YarnTasks.YarnLogger; - - /// - /// Format the output as an NDJSON stream. - /// - public virtual bool? Json { get; internal set; } - - /// - /// Abort with an error exit code if the lockfile was to be modified. - /// - public virtual bool? Immutable { get; internal set; } - - /// - /// Abort with an error exit code if the cache folder was to be modified. - /// - public virtual bool? ImmutableCache { get; internal set; } - - /// - /// Always refetch the packages and ensure that their checksums are consistent. - /// - public virtual bool? CheckCache { get; internal set; } - - /// - /// Verbosely print the output of the build steps of dependencies. - /// - public virtual bool? InlineBuilds { get; internal set; } - - /// - /// If the --mode= option is set, Yarn will change which artifacts are generated. - /// - public virtual YarnInstallMode? Mode { get; internal set; } - - protected override Arguments ConfigureProcessArguments(Arguments arguments) - { - arguments - .Add("install") - .Add("--json", Json) - .Add("--immutable", Immutable) - .Add("--immutable-cache", ImmutableCache) - .Add("--check-cache", CheckCache) - .Add("--inline-builds", InlineBuilds) - .Add("--mode={value}", Mode); - return base.ConfigureProcessArguments(arguments); - } -} - -#endregion - -#region YarnRunSettings - -/// -/// Used within . -/// -[PublicAPI] -[ExcludeFromCodeCoverage] -[Serializable] -public partial class YarnRunSettings : ToolSettings -{ - /// - /// Path to the Yarn executable. - /// - public override string ProcessToolPath => base.ProcessToolPath ?? YarnTasks.YarnPath; - - public override Action ProcessLogger => base.ProcessLogger ?? YarnTasks.YarnLogger; - - /// - /// The command to be executed. - /// - public virtual string? Command { get; internal set; } - - /// - /// Arguments passed to the script. - /// - public virtual IReadOnlyList Arguments => ArgumentsInternal.AsReadOnly(); - - internal List ArgumentsInternal { get; set; } = new List(); - - /// - /// Check the root workspace for scripts and/or binaries instead of the current one. - /// - public virtual bool? TopLevel { get; internal set; } - - /// - /// Ignore any user defined scripts and only check for binaries. - /// - public virtual bool? BinariesOnly { get; internal set; } - - protected override Arguments ConfigureProcessArguments(Arguments arguments) - { - arguments - .Add("run") - .Add("{value}", Command) - .Add("{value}", Arguments, separator: ' ') - .Add("--top-level", TopLevel) - .Add("--binaries-only", BinariesOnly); - return base.ConfigureProcessArguments(arguments); - } -} - -#endregion - -#region YarnGetConfigSettings - -/// -/// Used within . -/// -[PublicAPI] -[ExcludeFromCodeCoverage] -[Serializable] -public partial class YarnGetConfigSettings : ToolSettings -{ - /// - /// Path to the Yarn executable. - /// - public override string ProcessToolPath => base.ProcessToolPath ?? YarnTasks.YarnPath; - - public override Action ProcessLogger => base.ProcessLogger ?? YarnTasks.YarnLogger; - - /// - /// The name of the configuration setting. - /// - public virtual string? Name { get; internal set; } - - /// - /// Format the output as an NDJSON stream. - /// - public virtual bool? Json { get; internal set; } - - /// - /// Don't redact secrets (such as tokens) from the output. - /// - public virtual bool? NoRedacted { get; internal set; } - - protected override Arguments ConfigureProcessArguments(Arguments arguments) - { - arguments - .Add("config get") - .Add("{value}", Name) - .Add("--json", Json) - .Add("--no-redacted", NoRedacted); - return base.ConfigureProcessArguments(arguments); - } -} - -#endregion - -#region YarnSetConfigSettings - -/// -/// Used within . -/// -[PublicAPI] -[ExcludeFromCodeCoverage] -[Serializable] -public partial class YarnSetConfigSettings : ToolSettings -{ - /// - /// Path to the Yarn executable. - /// - public override string ProcessToolPath => base.ProcessToolPath ?? YarnTasks.YarnPath; - - public override Action ProcessLogger => base.ProcessLogger ?? YarnTasks.YarnLogger; - - /// - /// The name of the configuration setting. - /// - public virtual string? Name { get; internal set; } - - /// - /// Set complex configuration settings to JSON values. - /// - public virtual bool? Json { get; internal set; } - - /// - /// The value of the configuration setting. - /// - public virtual string? Value { get; internal set; } - - /// - /// Update the home configuration instead of the project configuration. - /// - public virtual bool? Home { get; internal set; } - - protected override Arguments ConfigureProcessArguments(Arguments arguments) - { - arguments - .Add("config set") - .Add("{value}", Name) - .Add("--json", Json) - .Add("{value}", Value) - .Add("--home", Home); - return base.ConfigureProcessArguments(arguments); - } -} - -#endregion - -#region YarnInstallSettingsExtensions - -/// -/// Used within . -/// -[PublicAPI] -[ExcludeFromCodeCoverage] -public static partial class YarnInstallSettingsExtensions -{ - #region Json - - /// - ///

Sets

- ///

Format the output as an NDJSON stream.

- ///
- [Pure] - public static T SetJson(this T toolSettings, bool? json) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = json; - return toolSettings; - } - - /// - ///

Resets

- ///

Format the output as an NDJSON stream.

- ///
- [Pure] - public static T ResetJson(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = null; - return toolSettings; - } - - /// - ///

Enables

- ///

Format the output as an NDJSON stream.

- ///
- [Pure] - public static T EnableJson(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = true; - return toolSettings; - } - - /// - ///

Disables

- ///

Format the output as an NDJSON stream.

- ///
- [Pure] - public static T DisableJson(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = false; - return toolSettings; - } - - /// - ///

Toggles

- ///

Format the output as an NDJSON stream.

- ///
- [Pure] - public static T ToggleJson(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = !toolSettings.Json; - return toolSettings; - } - - #endregion - - #region Immutable - - /// - ///

Sets

- ///

Abort with an error exit code if the lockfile was to be modified.

- ///
- [Pure] - public static T SetImmutable(this T toolSettings, bool? immutable) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Immutable = immutable; - return toolSettings; - } - - /// - ///

Resets

- ///

Abort with an error exit code if the lockfile was to be modified.

- ///
- [Pure] - public static T ResetImmutable(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Immutable = null; - return toolSettings; - } - - /// - ///

Enables

- ///

Abort with an error exit code if the lockfile was to be modified.

- ///
- [Pure] - public static T EnableImmutable(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Immutable = true; - return toolSettings; - } - - /// - ///

Disables

- ///

Abort with an error exit code if the lockfile was to be modified.

- ///
- [Pure] - public static T DisableImmutable(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Immutable = false; - return toolSettings; - } - - /// - ///

Toggles

- ///

Abort with an error exit code if the lockfile was to be modified.

- ///
- [Pure] - public static T ToggleImmutable(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Immutable = !toolSettings.Immutable; - return toolSettings; - } - - #endregion - - #region ImmutableCache - - /// - ///

Sets

- ///

Abort with an error exit code if the cache folder was to be modified.

- ///
- [Pure] - public static T SetImmutableCache(this T toolSettings, bool? immutableCache) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.ImmutableCache = immutableCache; - return toolSettings; - } - - /// - ///

Resets

- ///

Abort with an error exit code if the cache folder was to be modified.

- ///
- [Pure] - public static T ResetImmutableCache(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.ImmutableCache = null; - return toolSettings; - } - - /// - ///

Enables

- ///

Abort with an error exit code if the cache folder was to be modified.

- ///
- [Pure] - public static T EnableImmutableCache(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.ImmutableCache = true; - return toolSettings; - } - - /// - ///

Disables

- ///

Abort with an error exit code if the cache folder was to be modified.

- ///
- [Pure] - public static T DisableImmutableCache(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.ImmutableCache = false; - return toolSettings; - } - - /// - ///

Toggles

- ///

Abort with an error exit code if the cache folder was to be modified.

- ///
- [Pure] - public static T ToggleImmutableCache(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.ImmutableCache = !toolSettings.ImmutableCache; - return toolSettings; - } - - #endregion - - #region CheckCache - - /// - ///

Sets

- ///

Always refetch the packages and ensure that their checksums are consistent.

- ///
- [Pure] - public static T SetCheckCache(this T toolSettings, bool? checkCache) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.CheckCache = checkCache; - return toolSettings; - } - - /// - ///

Resets

- ///

Always refetch the packages and ensure that their checksums are consistent.

- ///
- [Pure] - public static T ResetCheckCache(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.CheckCache = null; - return toolSettings; - } - - /// - ///

Enables

- ///

Always refetch the packages and ensure that their checksums are consistent.

- ///
- [Pure] - public static T EnableCheckCache(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.CheckCache = true; - return toolSettings; - } - - /// - ///

Disables

- ///

Always refetch the packages and ensure that their checksums are consistent.

- ///
- [Pure] - public static T DisableCheckCache(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.CheckCache = false; - return toolSettings; - } - - /// - ///

Toggles

- ///

Always refetch the packages and ensure that their checksums are consistent.

- ///
- [Pure] - public static T ToggleCheckCache(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.CheckCache = !toolSettings.CheckCache; - return toolSettings; - } - - #endregion - - #region InlineBuilds - - /// - ///

Sets

- ///

Verbosely print the output of the build steps of dependencies.

- ///
- [Pure] - public static T SetInlineBuilds(this T toolSettings, bool? inlineBuilds) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.InlineBuilds = inlineBuilds; - return toolSettings; - } - - /// - ///

Resets

- ///

Verbosely print the output of the build steps of dependencies.

- ///
- [Pure] - public static T ResetInlineBuilds(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.InlineBuilds = null; - return toolSettings; - } - - /// - ///

Enables

- ///

Verbosely print the output of the build steps of dependencies.

- ///
- [Pure] - public static T EnableInlineBuilds(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.InlineBuilds = true; - return toolSettings; - } - - /// - ///

Disables

- ///

Verbosely print the output of the build steps of dependencies.

- ///
- [Pure] - public static T DisableInlineBuilds(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.InlineBuilds = false; - return toolSettings; - } - - /// - ///

Toggles

- ///

Verbosely print the output of the build steps of dependencies.

- ///
- [Pure] - public static T ToggleInlineBuilds(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.InlineBuilds = !toolSettings.InlineBuilds; - return toolSettings; - } - - #endregion - - #region Mode - - /// - ///

Sets

- ///

If the --mode= option is set, Yarn will change which artifacts are generated.

- ///
- [Pure] - public static T SetMode(this T toolSettings, YarnInstallMode mode) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Mode = mode; - return toolSettings; - } - - /// - ///

Resets

- ///

If the --mode= option is set, Yarn will change which artifacts are generated.

- ///
- [Pure] - public static T ResetMode(this T toolSettings) where T : YarnInstallSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Mode = null; - return toolSettings; - } - - #endregion -} - -#endregion - -#region YarnRunSettingsExtensions - -/// -/// Used within . -/// -[PublicAPI] -[ExcludeFromCodeCoverage] -public static partial class YarnRunSettingsExtensions -{ - #region Command - - /// - ///

Sets

- ///

The command to be executed.

- ///
- [Pure] - public static T SetCommand(this T toolSettings, string command) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Command = command; - return toolSettings; - } - - /// - ///

Resets

- ///

The command to be executed.

- ///
- [Pure] - public static T ResetCommand(this T toolSettings) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Command = null; - return toolSettings; - } - - #endregion - - #region Arguments - - /// - ///

Sets to a new list

- ///

Arguments passed to the script.

- ///
- [Pure] - public static T SetArguments(this T toolSettings, params string[] arguments) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.ArgumentsInternal = arguments.ToList(); - return toolSettings; - } - - /// - ///

Sets to a new list

- ///

Arguments passed to the script.

- ///
- [Pure] - public static T SetArguments(this T toolSettings, IEnumerable arguments) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.ArgumentsInternal = arguments.ToList(); - return toolSettings; - } - - /// - ///

Adds values to

- ///

Arguments passed to the script.

- ///
- [Pure] - public static T AddArguments(this T toolSettings, params string[] arguments) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.ArgumentsInternal.AddRange(arguments); - return toolSettings; - } - - /// - ///

Adds values to

- ///

Arguments passed to the script.

- ///
- [Pure] - public static T AddArguments(this T toolSettings, IEnumerable arguments) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.ArgumentsInternal.AddRange(arguments); - return toolSettings; - } - - /// - ///

Clears

- ///

Arguments passed to the script.

- ///
- [Pure] - public static T ClearArguments(this T toolSettings) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.ArgumentsInternal.Clear(); - return toolSettings; - } - - /// - ///

Removes values from

- ///

Arguments passed to the script.

- ///
- [Pure] - public static T RemoveArguments(this T toolSettings, params string[] arguments) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - var hashSet = new HashSet(arguments); - toolSettings.ArgumentsInternal.RemoveAll(x => hashSet.Contains(x)); - return toolSettings; - } - - /// - ///

Removes values from

- ///

Arguments passed to the script.

- ///
- [Pure] - public static T RemoveArguments(this T toolSettings, IEnumerable arguments) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - var hashSet = new HashSet(arguments); - toolSettings.ArgumentsInternal.RemoveAll(x => hashSet.Contains(x)); - return toolSettings; - } - - #endregion - - #region TopLevel - - /// - ///

Sets

- ///

Check the root workspace for scripts and/or binaries instead of the current one.

- ///
- [Pure] - public static T SetTopLevel(this T toolSettings, bool? topLevel) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.TopLevel = topLevel; - return toolSettings; - } - - /// - ///

Resets

- ///

Check the root workspace for scripts and/or binaries instead of the current one.

- ///
- [Pure] - public static T ResetTopLevel(this T toolSettings) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.TopLevel = null; - return toolSettings; - } - - /// - ///

Enables

- ///

Check the root workspace for scripts and/or binaries instead of the current one.

- ///
- [Pure] - public static T EnableTopLevel(this T toolSettings) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.TopLevel = true; - return toolSettings; - } - - /// - ///

Disables

- ///

Check the root workspace for scripts and/or binaries instead of the current one.

- ///
- [Pure] - public static T DisableTopLevel(this T toolSettings) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.TopLevel = false; - return toolSettings; - } - - /// - ///

Toggles

- ///

Check the root workspace for scripts and/or binaries instead of the current one.

- ///
- [Pure] - public static T ToggleTopLevel(this T toolSettings) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.TopLevel = !toolSettings.TopLevel; - return toolSettings; - } - - #endregion - - #region BinariesOnly - - /// - ///

Sets

- ///

Ignore any user defined scripts and only check for binaries.

- ///
- [Pure] - public static T SetBinariesOnly(this T toolSettings, bool? binariesOnly) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.BinariesOnly = binariesOnly; - return toolSettings; - } - - /// - ///

Resets

- ///

Ignore any user defined scripts and only check for binaries.

- ///
- [Pure] - public static T ResetBinariesOnly(this T toolSettings) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.BinariesOnly = null; - return toolSettings; - } - - /// - ///

Enables

- ///

Ignore any user defined scripts and only check for binaries.

- ///
- [Pure] - public static T EnableBinariesOnly(this T toolSettings) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.BinariesOnly = true; - return toolSettings; - } - - /// - ///

Disables

- ///

Ignore any user defined scripts and only check for binaries.

- ///
- [Pure] - public static T DisableBinariesOnly(this T toolSettings) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.BinariesOnly = false; - return toolSettings; - } - - /// - ///

Toggles

- ///

Ignore any user defined scripts and only check for binaries.

- ///
- [Pure] - public static T ToggleBinariesOnly(this T toolSettings) where T : YarnRunSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.BinariesOnly = !toolSettings.BinariesOnly; - return toolSettings; - } - - #endregion -} - -#endregion - -#region YarnGetConfigSettingsExtensions - -/// -/// Used within . -/// -[PublicAPI] -[ExcludeFromCodeCoverage] -public static partial class YarnGetConfigSettingsExtensions -{ - #region Name - - /// - ///

Sets

- ///

The name of the configuration setting.

- ///
- [Pure] - public static T SetName(this T toolSettings, string name) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Name = name; - return toolSettings; - } - - /// - ///

Resets

- ///

The name of the configuration setting.

- ///
- [Pure] - public static T ResetName(this T toolSettings) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Name = null; - return toolSettings; - } - - #endregion - - #region Json - - /// - ///

Sets

- ///

Format the output as an NDJSON stream.

- ///
- [Pure] - public static T SetJson(this T toolSettings, bool? json) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = json; - return toolSettings; - } - - /// - ///

Resets

- ///

Format the output as an NDJSON stream.

- ///
- [Pure] - public static T ResetJson(this T toolSettings) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = null; - return toolSettings; - } - - /// - ///

Enables

- ///

Format the output as an NDJSON stream.

- ///
- [Pure] - public static T EnableJson(this T toolSettings) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = true; - return toolSettings; - } - - /// - ///

Disables

- ///

Format the output as an NDJSON stream.

- ///
- [Pure] - public static T DisableJson(this T toolSettings) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = false; - return toolSettings; - } - - /// - ///

Toggles

- ///

Format the output as an NDJSON stream.

- ///
- [Pure] - public static T ToggleJson(this T toolSettings) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = !toolSettings.Json; - return toolSettings; - } - - #endregion - - #region NoRedacted - - /// - ///

Sets

- ///

Don't redact secrets (such as tokens) from the output.

- ///
- [Pure] - public static T SetNoRedacted(this T toolSettings, bool? noRedacted) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.NoRedacted = noRedacted; - return toolSettings; - } - - /// - ///

Resets

- ///

Don't redact secrets (such as tokens) from the output.

- ///
- [Pure] - public static T ResetNoRedacted(this T toolSettings) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.NoRedacted = null; - return toolSettings; - } - - /// - ///

Enables

- ///

Don't redact secrets (such as tokens) from the output.

- ///
- [Pure] - public static T EnableNoRedacted(this T toolSettings) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.NoRedacted = true; - return toolSettings; - } - - /// - ///

Disables

- ///

Don't redact secrets (such as tokens) from the output.

- ///
- [Pure] - public static T DisableNoRedacted(this T toolSettings) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.NoRedacted = false; - return toolSettings; - } - - /// - ///

Toggles

- ///

Don't redact secrets (such as tokens) from the output.

- ///
- [Pure] - public static T ToggleNoRedacted(this T toolSettings) where T : YarnGetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.NoRedacted = !toolSettings.NoRedacted; - return toolSettings; - } - - #endregion -} - -#endregion - -#region YarnSetConfigSettingsExtensions - -/// -/// Used within . -/// -[PublicAPI] -[ExcludeFromCodeCoverage] -public static partial class YarnSetConfigSettingsExtensions -{ - #region Name - - /// - ///

Sets

- ///

The name of the configuration setting.

- ///
- [Pure] - public static T SetName(this T toolSettings, string name) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Name = name; - return toolSettings; - } - - /// - ///

Resets

- ///

The name of the configuration setting.

- ///
- [Pure] - public static T ResetName(this T toolSettings) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Name = null; - return toolSettings; - } - - #endregion - - #region Json - - /// - ///

Sets

- ///

Set complex configuration settings to JSON values.

- ///
- [Pure] - public static T SetJson(this T toolSettings, bool? json) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = json; - return toolSettings; - } - - /// - ///

Resets

- ///

Set complex configuration settings to JSON values.

- ///
- [Pure] - public static T ResetJson(this T toolSettings) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = null; - return toolSettings; - } - - /// - ///

Enables

- ///

Set complex configuration settings to JSON values.

- ///
- [Pure] - public static T EnableJson(this T toolSettings) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = true; - return toolSettings; - } - - /// - ///

Disables

- ///

Set complex configuration settings to JSON values.

- ///
- [Pure] - public static T DisableJson(this T toolSettings) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = false; - return toolSettings; - } - - /// - ///

Toggles

- ///

Set complex configuration settings to JSON values.

- ///
- [Pure] - public static T ToggleJson(this T toolSettings) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Json = !toolSettings.Json; - return toolSettings; - } - - #endregion - - #region Value - - /// - ///

Sets

- ///

The value of the configuration setting.

- ///
- [Pure] - public static T SetValue(this T toolSettings, string value) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Value = value; - return toolSettings; - } - - /// - ///

Resets

- ///

The value of the configuration setting.

- ///
- [Pure] - public static T ResetValue(this T toolSettings) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Value = null; - return toolSettings; - } - - #endregion - - #region Home - - /// - ///

Sets

- ///

Update the home configuration instead of the project configuration.

- ///
- [Pure] - public static T SetHome(this T toolSettings, bool? home) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Home = home; - return toolSettings; - } - - /// - ///

Resets

- ///

Update the home configuration instead of the project configuration.

- ///
- [Pure] - public static T ResetHome(this T toolSettings) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Home = null; - return toolSettings; - } - - /// - ///

Enables

- ///

Update the home configuration instead of the project configuration.

- ///
- [Pure] - public static T EnableHome(this T toolSettings) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Home = true; - return toolSettings; - } - - /// - ///

Disables

- ///

Update the home configuration instead of the project configuration.

- ///
- [Pure] - public static T DisableHome(this T toolSettings) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Home = false; - return toolSettings; - } - - /// - ///

Toggles

- ///

Update the home configuration instead of the project configuration.

- ///
- [Pure] - public static T ToggleHome(this T toolSettings) where T : YarnSetConfigSettings - { - toolSettings = toolSettings.NewInstance(); - toolSettings.Home = !toolSettings.Home; - return toolSettings; - } - - #endregion -} - -#endregion - -#region YarnInstallMode - -/// -/// Used within . -/// -[PublicAPI] -[Serializable] -[ExcludeFromCodeCoverage] -[TypeConverter(typeof(TypeConverter))] -public partial class YarnInstallMode : Enumeration -{ - public static YarnInstallMode skip_build = (YarnInstallMode)"skip-build"; - - public static YarnInstallMode update_lockfile = (YarnInstallMode)"update-lockfile"; - - public static implicit operator YarnInstallMode(string value) - { - return new YarnInstallMode { Value = value }; - } -} - -#endregion \ No newline at end of file diff --git a/build/_build.csproj b/build/_build.csproj index 414edcea..35061507 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -21,12 +21,13 @@ - + + - - + + diff --git a/build/custom-tooling/yarn.Generated.cs b/build/custom-tooling/yarn.Generated.cs new file mode 100644 index 00000000..4ff54c61 --- /dev/null +++ b/build/custom-tooling/yarn.Generated.cs @@ -0,0 +1,495 @@ +using JetBrains.Annotations; +using Newtonsoft.Json; +using Nuke.Common; +using Nuke.Common.Tooling; +using Nuke.Common.Tools; +using Nuke.Common.Utilities.Collections; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Linq; +using System.Text; + + +///

Yarn is a package manager that doubles down as project manager. Whether you work on one-shot projects or large monorepos, as a hobbyist or an enterprise user, we've got you covered.

For more details, visit the official website.

+[PublicAPI] +[ExcludeFromCodeCoverage] +[PathTool(Executable = PathExecutable)] +public partial class YarnTasks : ToolTasks, IRequirePathTool +{ + public static string YarnPath { get => new YarnTasks().GetToolPathInternal(); set => new YarnTasks().SetToolPath(value); } + public const string PathExecutable = "yarn"; + ///

Yarn is a package manager that doubles down as project manager. Whether you work on one-shot projects or large monorepos, as a hobbyist or an enterprise user, we've got you covered.

For more details, visit the official website.

+ public static IReadOnlyCollection Yarn(ArgumentStringHandler arguments, string workingDirectory = null, IReadOnlyDictionary environmentVariables = null, int? timeout = null, bool? logOutput = null, bool? logInvocation = null, Action logger = null, Func exitHandler = null) => new YarnTasks().Run(arguments, workingDirectory, environmentVariables, timeout, logOutput, logInvocation, logger, exitHandler); + ///

Install the project dependencies

For more details, visit the official website.

+ ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

  • --check-cache via
  • --immutable via
  • --immutable-cache via
  • --inline-builds via
  • --json via
  • --mode via
+ public static IReadOnlyCollection YarnInstall(YarnInstallSettings options = null) => new YarnTasks().Run(options); + /// + public static IReadOnlyCollection YarnInstall(Configure configurator) => new YarnTasks().Run(configurator.Invoke(new YarnInstallSettings())); + /// + public static IEnumerable<(YarnInstallSettings Settings, IReadOnlyCollection Output)> YarnInstall(CombinatorialConfigure configurator, int degreeOfParallelism = 1, bool completeOnFailure = false) => configurator.Invoke(YarnInstall, degreeOfParallelism, completeOnFailure); + ///

Run a script defined in the package.json

For more details, visit the official website.

+ ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

  • <arguments> via
  • <command> via
  • --binaries-only via
  • --top-level via
+ public static IReadOnlyCollection YarnRun(YarnRunSettings options = null) => new YarnTasks().Run(options); + /// + public static IReadOnlyCollection YarnRun(Configure configurator) => new YarnTasks().Run(configurator.Invoke(new YarnRunSettings())); + /// + public static IEnumerable<(YarnRunSettings Settings, IReadOnlyCollection Output)> YarnRun(CombinatorialConfigure configurator, int degreeOfParallelism = 1, bool completeOnFailure = false) => configurator.Invoke(YarnRun, degreeOfParallelism, completeOnFailure); + ///

Read a configuration settings

For more details, visit the official website.

+ ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

  • <name> via
  • --json via
  • --no-redacted via
+ public static IReadOnlyCollection YarnGetConfig(YarnGetConfigSettings options = null) => new YarnTasks().Run(options); + /// + public static IReadOnlyCollection YarnGetConfig(Configure configurator) => new YarnTasks().Run(configurator.Invoke(new YarnGetConfigSettings())); + /// + public static IEnumerable<(YarnGetConfigSettings Settings, IReadOnlyCollection Output)> YarnGetConfig(CombinatorialConfigure configurator, int degreeOfParallelism = 1, bool completeOnFailure = false) => configurator.Invoke(YarnGetConfig, degreeOfParallelism, completeOnFailure); + ///

Change a configuration settings

For more details, visit the official website.

+ ///

This is a CLI wrapper with fluent API that allows to modify the following arguments:

  • <name> via
  • <value> via
  • --home via
  • --json via
+ public static IReadOnlyCollection YarnSetConfig(YarnSetConfigSettings options = null) => new YarnTasks().Run(options); + /// + public static IReadOnlyCollection YarnSetConfig(Configure configurator) => new YarnTasks().Run(configurator.Invoke(new YarnSetConfigSettings())); + /// + public static IEnumerable<(YarnSetConfigSettings Settings, IReadOnlyCollection Output)> YarnSetConfig(CombinatorialConfigure configurator, int degreeOfParallelism = 1, bool completeOnFailure = false) => configurator.Invoke(YarnSetConfig, degreeOfParallelism, completeOnFailure); +} +#region YarnInstallSettings +/// +[PublicAPI] +[ExcludeFromCodeCoverage] +[Command(Type = typeof(YarnTasks), Command = nameof(YarnTasks.YarnInstall), Arguments = "install")] +public partial class YarnInstallSettings : ToolOptions +{ + /// Format the output as an NDJSON stream. + [Argument(Format = "--json")] public bool? Json => Get(() => Json); + /// Abort with an error exit code if the lockfile was to be modified. + [Argument(Format = "--immutable")] public bool? Immutable => Get(() => Immutable); + /// Abort with an error exit code if the cache folder was to be modified. + [Argument(Format = "--immutable-cache")] public bool? ImmutableCache => Get(() => ImmutableCache); + /// Always refetch the packages and ensure that their checksums are consistent. + [Argument(Format = "--check-cache")] public bool? CheckCache => Get(() => CheckCache); + /// Verbosely print the output of the build steps of dependencies. + [Argument(Format = "--inline-builds")] public bool? InlineBuilds => Get(() => InlineBuilds); + /// If the --mode= option is set, Yarn will change which artifacts are generated. + [Argument(Format = "--mode={value}")] public YarnInstallMode Mode => Get(() => Mode); +} +#endregion +#region YarnRunSettings +/// +[PublicAPI] +[ExcludeFromCodeCoverage] +[Command(Type = typeof(YarnTasks), Command = nameof(YarnTasks.YarnRun), Arguments = "run")] +public partial class YarnRunSettings : ToolOptions +{ + /// The command to be executed. + [Argument(Format = "{value}")] public string Command => Get(() => Command); + /// Arguments passed to the script. + [Argument(Format = "{value}", Separator = " ")] public IReadOnlyList Arguments => Get>(() => Arguments); + /// Check the root workspace for scripts and/or binaries instead of the current one. + [Argument(Format = "--top-level")] public bool? TopLevel => Get(() => TopLevel); + /// Ignore any user defined scripts and only check for binaries. + [Argument(Format = "--binaries-only")] public bool? BinariesOnly => Get(() => BinariesOnly); +} +#endregion +#region YarnGetConfigSettings +/// +[PublicAPI] +[ExcludeFromCodeCoverage] +[Command(Type = typeof(YarnTasks), Command = nameof(YarnTasks.YarnGetConfig), Arguments = "config get")] +public partial class YarnGetConfigSettings : ToolOptions +{ + /// The name of the configuration setting. + [Argument(Format = "{value}")] public string Name => Get(() => Name); + /// Format the output as an NDJSON stream. + [Argument(Format = "--json")] public bool? Json => Get(() => Json); + /// Don't redact secrets (such as tokens) from the output. + [Argument(Format = "--no-redacted")] public bool? NoRedacted => Get(() => NoRedacted); +} +#endregion +#region YarnSetConfigSettings +/// +[PublicAPI] +[ExcludeFromCodeCoverage] +[Command(Type = typeof(YarnTasks), Command = nameof(YarnTasks.YarnSetConfig), Arguments = "config set")] +public partial class YarnSetConfigSettings : ToolOptions +{ + /// The name of the configuration setting. + [Argument(Format = "{value}")] public string Name => Get(() => Name); + /// Set complex configuration settings to JSON values. + [Argument(Format = "--json")] public bool? Json => Get(() => Json); + /// The value of the configuration setting. + [Argument(Format = "{value}")] public string Value => Get(() => Value); + /// Update the home configuration instead of the project configuration. + [Argument(Format = "--home")] public bool? Home => Get(() => Home); +} +#endregion +#region YarnInstallSettingsExtensions +/// +[PublicAPI] +[ExcludeFromCodeCoverage] +public static partial class YarnInstallSettingsExtensions +{ + #region Json + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Json))] + public static T SetJson(this T o, bool? v) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.Json, v)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Json))] + public static T ResetJson(this T o) where T : YarnInstallSettings => o.Modify(b => b.Remove(() => o.Json)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Json))] + public static T EnableJson(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.Json, true)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Json))] + public static T DisableJson(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.Json, false)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Json))] + public static T ToggleJson(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.Json, !o.Json)); + #endregion + #region Immutable + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Immutable))] + public static T SetImmutable(this T o, bool? v) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.Immutable, v)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Immutable))] + public static T ResetImmutable(this T o) where T : YarnInstallSettings => o.Modify(b => b.Remove(() => o.Immutable)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Immutable))] + public static T EnableImmutable(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.Immutable, true)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Immutable))] + public static T DisableImmutable(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.Immutable, false)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Immutable))] + public static T ToggleImmutable(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.Immutable, !o.Immutable)); + #endregion + #region ImmutableCache + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.ImmutableCache))] + public static T SetImmutableCache(this T o, bool? v) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.ImmutableCache, v)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.ImmutableCache))] + public static T ResetImmutableCache(this T o) where T : YarnInstallSettings => o.Modify(b => b.Remove(() => o.ImmutableCache)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.ImmutableCache))] + public static T EnableImmutableCache(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.ImmutableCache, true)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.ImmutableCache))] + public static T DisableImmutableCache(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.ImmutableCache, false)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.ImmutableCache))] + public static T ToggleImmutableCache(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.ImmutableCache, !o.ImmutableCache)); + #endregion + #region CheckCache + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.CheckCache))] + public static T SetCheckCache(this T o, bool? v) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.CheckCache, v)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.CheckCache))] + public static T ResetCheckCache(this T o) where T : YarnInstallSettings => o.Modify(b => b.Remove(() => o.CheckCache)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.CheckCache))] + public static T EnableCheckCache(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.CheckCache, true)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.CheckCache))] + public static T DisableCheckCache(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.CheckCache, false)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.CheckCache))] + public static T ToggleCheckCache(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.CheckCache, !o.CheckCache)); + #endregion + #region InlineBuilds + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.InlineBuilds))] + public static T SetInlineBuilds(this T o, bool? v) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.InlineBuilds, v)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.InlineBuilds))] + public static T ResetInlineBuilds(this T o) where T : YarnInstallSettings => o.Modify(b => b.Remove(() => o.InlineBuilds)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.InlineBuilds))] + public static T EnableInlineBuilds(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.InlineBuilds, true)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.InlineBuilds))] + public static T DisableInlineBuilds(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.InlineBuilds, false)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.InlineBuilds))] + public static T ToggleInlineBuilds(this T o) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.InlineBuilds, !o.InlineBuilds)); + #endregion + #region Mode + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Mode))] + public static T SetMode(this T o, YarnInstallMode v) where T : YarnInstallSettings => o.Modify(b => b.Set(() => o.Mode, v)); + /// + [Pure] + [Builder(Type = typeof(YarnInstallSettings), Property = nameof(YarnInstallSettings.Mode))] + public static T ResetMode(this T o) where T : YarnInstallSettings => o.Modify(b => b.Remove(() => o.Mode)); + #endregion +} +#endregion +#region YarnRunSettingsExtensions +/// +[PublicAPI] +[ExcludeFromCodeCoverage] +public static partial class YarnRunSettingsExtensions +{ + #region Command + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.Command))] + public static T SetCommand(this T o, string v) where T : YarnRunSettings => o.Modify(b => b.Set(() => o.Command, v)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.Command))] + public static T ResetCommand(this T o) where T : YarnRunSettings => o.Modify(b => b.Remove(() => o.Command)); + #endregion + #region Arguments + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.Arguments))] + public static T SetArguments(this T o, params string[] v) where T : YarnRunSettings => o.Modify(b => b.Set(() => o.Arguments, v)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.Arguments))] + public static T SetArguments(this T o, IEnumerable v) where T : YarnRunSettings => o.Modify(b => b.Set(() => o.Arguments, v)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.Arguments))] + public static T AddArguments(this T o, params string[] v) where T : YarnRunSettings => o.Modify(b => b.AddCollection(() => o.Arguments, v)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.Arguments))] + public static T AddArguments(this T o, IEnumerable v) where T : YarnRunSettings => o.Modify(b => b.AddCollection(() => o.Arguments, v)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.Arguments))] + public static T RemoveArguments(this T o, params string[] v) where T : YarnRunSettings => o.Modify(b => b.RemoveCollection(() => o.Arguments, v)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.Arguments))] + public static T RemoveArguments(this T o, IEnumerable v) where T : YarnRunSettings => o.Modify(b => b.RemoveCollection(() => o.Arguments, v)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.Arguments))] + public static T ClearArguments(this T o) where T : YarnRunSettings => o.Modify(b => b.ClearCollection(() => o.Arguments)); + #endregion + #region TopLevel + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.TopLevel))] + public static T SetTopLevel(this T o, bool? v) where T : YarnRunSettings => o.Modify(b => b.Set(() => o.TopLevel, v)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.TopLevel))] + public static T ResetTopLevel(this T o) where T : YarnRunSettings => o.Modify(b => b.Remove(() => o.TopLevel)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.TopLevel))] + public static T EnableTopLevel(this T o) where T : YarnRunSettings => o.Modify(b => b.Set(() => o.TopLevel, true)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.TopLevel))] + public static T DisableTopLevel(this T o) where T : YarnRunSettings => o.Modify(b => b.Set(() => o.TopLevel, false)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.TopLevel))] + public static T ToggleTopLevel(this T o) where T : YarnRunSettings => o.Modify(b => b.Set(() => o.TopLevel, !o.TopLevel)); + #endregion + #region BinariesOnly + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.BinariesOnly))] + public static T SetBinariesOnly(this T o, bool? v) where T : YarnRunSettings => o.Modify(b => b.Set(() => o.BinariesOnly, v)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.BinariesOnly))] + public static T ResetBinariesOnly(this T o) where T : YarnRunSettings => o.Modify(b => b.Remove(() => o.BinariesOnly)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.BinariesOnly))] + public static T EnableBinariesOnly(this T o) where T : YarnRunSettings => o.Modify(b => b.Set(() => o.BinariesOnly, true)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.BinariesOnly))] + public static T DisableBinariesOnly(this T o) where T : YarnRunSettings => o.Modify(b => b.Set(() => o.BinariesOnly, false)); + /// + [Pure] + [Builder(Type = typeof(YarnRunSettings), Property = nameof(YarnRunSettings.BinariesOnly))] + public static T ToggleBinariesOnly(this T o) where T : YarnRunSettings => o.Modify(b => b.Set(() => o.BinariesOnly, !o.BinariesOnly)); + #endregion +} +#endregion +#region YarnGetConfigSettingsExtensions +/// +[PublicAPI] +[ExcludeFromCodeCoverage] +public static partial class YarnGetConfigSettingsExtensions +{ + #region Name + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.Name))] + public static T SetName(this T o, string v) where T : YarnGetConfigSettings => o.Modify(b => b.Set(() => o.Name, v)); + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.Name))] + public static T ResetName(this T o) where T : YarnGetConfigSettings => o.Modify(b => b.Remove(() => o.Name)); + #endregion + #region Json + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.Json))] + public static T SetJson(this T o, bool? v) where T : YarnGetConfigSettings => o.Modify(b => b.Set(() => o.Json, v)); + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.Json))] + public static T ResetJson(this T o) where T : YarnGetConfigSettings => o.Modify(b => b.Remove(() => o.Json)); + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.Json))] + public static T EnableJson(this T o) where T : YarnGetConfigSettings => o.Modify(b => b.Set(() => o.Json, true)); + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.Json))] + public static T DisableJson(this T o) where T : YarnGetConfigSettings => o.Modify(b => b.Set(() => o.Json, false)); + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.Json))] + public static T ToggleJson(this T o) where T : YarnGetConfigSettings => o.Modify(b => b.Set(() => o.Json, !o.Json)); + #endregion + #region NoRedacted + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.NoRedacted))] + public static T SetNoRedacted(this T o, bool? v) where T : YarnGetConfigSettings => o.Modify(b => b.Set(() => o.NoRedacted, v)); + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.NoRedacted))] + public static T ResetNoRedacted(this T o) where T : YarnGetConfigSettings => o.Modify(b => b.Remove(() => o.NoRedacted)); + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.NoRedacted))] + public static T EnableNoRedacted(this T o) where T : YarnGetConfigSettings => o.Modify(b => b.Set(() => o.NoRedacted, true)); + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.NoRedacted))] + public static T DisableNoRedacted(this T o) where T : YarnGetConfigSettings => o.Modify(b => b.Set(() => o.NoRedacted, false)); + /// + [Pure] + [Builder(Type = typeof(YarnGetConfigSettings), Property = nameof(YarnGetConfigSettings.NoRedacted))] + public static T ToggleNoRedacted(this T o) where T : YarnGetConfigSettings => o.Modify(b => b.Set(() => o.NoRedacted, !o.NoRedacted)); + #endregion +} +#endregion +#region YarnSetConfigSettingsExtensions +/// +[PublicAPI] +[ExcludeFromCodeCoverage] +public static partial class YarnSetConfigSettingsExtensions +{ + #region Name + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Name))] + public static T SetName(this T o, string v) where T : YarnSetConfigSettings => o.Modify(b => b.Set(() => o.Name, v)); + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Name))] + public static T ResetName(this T o) where T : YarnSetConfigSettings => o.Modify(b => b.Remove(() => o.Name)); + #endregion + #region Json + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Json))] + public static T SetJson(this T o, bool? v) where T : YarnSetConfigSettings => o.Modify(b => b.Set(() => o.Json, v)); + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Json))] + public static T ResetJson(this T o) where T : YarnSetConfigSettings => o.Modify(b => b.Remove(() => o.Json)); + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Json))] + public static T EnableJson(this T o) where T : YarnSetConfigSettings => o.Modify(b => b.Set(() => o.Json, true)); + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Json))] + public static T DisableJson(this T o) where T : YarnSetConfigSettings => o.Modify(b => b.Set(() => o.Json, false)); + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Json))] + public static T ToggleJson(this T o) where T : YarnSetConfigSettings => o.Modify(b => b.Set(() => o.Json, !o.Json)); + #endregion + #region Value + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Value))] + public static T SetValue(this T o, string v) where T : YarnSetConfigSettings => o.Modify(b => b.Set(() => o.Value, v)); + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Value))] + public static T ResetValue(this T o) where T : YarnSetConfigSettings => o.Modify(b => b.Remove(() => o.Value)); + #endregion + #region Home + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Home))] + public static T SetHome(this T o, bool? v) where T : YarnSetConfigSettings => o.Modify(b => b.Set(() => o.Home, v)); + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Home))] + public static T ResetHome(this T o) where T : YarnSetConfigSettings => o.Modify(b => b.Remove(() => o.Home)); + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Home))] + public static T EnableHome(this T o) where T : YarnSetConfigSettings => o.Modify(b => b.Set(() => o.Home, true)); + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Home))] + public static T DisableHome(this T o) where T : YarnSetConfigSettings => o.Modify(b => b.Set(() => o.Home, false)); + /// + [Pure] + [Builder(Type = typeof(YarnSetConfigSettings), Property = nameof(YarnSetConfigSettings.Home))] + public static T ToggleHome(this T o) where T : YarnSetConfigSettings => o.Modify(b => b.Set(() => o.Home, !o.Home)); + #endregion +} +#endregion +#region YarnInstallMode +/// Used within . +[PublicAPI] +[Serializable] +[ExcludeFromCodeCoverage] +[TypeConverter(typeof(TypeConverter))] +public partial class YarnInstallMode : Enumeration +{ + public static YarnInstallMode skip_build = (YarnInstallMode)"skip-build"; + public static YarnInstallMode update_lockfile = (YarnInstallMode)"update-lockfile"; + public static implicit operator YarnInstallMode(string value) + { + return new YarnInstallMode { Value = value }; + } +} +#endregion diff --git a/build/custom-tooling/yarn.json b/build/custom-tooling/yarn.json new file mode 100644 index 00000000..16157334 --- /dev/null +++ b/build/custom-tooling/yarn.json @@ -0,0 +1,164 @@ +{ + "$schema": "https://raw.githubusercontent.com/nuke-build/nuke/master/source/Nuke.Tooling.Generator/schema.json", + "references": [ + "https://yarnpkg.com/cli/install", + "https://yarnpkg.com/cli/run", + "https://yarnpkg.com/cli/config/get", + "https://yarnpkg.com/cli/config/set" + ], + "name": "Yarn", + "officialUrl": "https://yarnpkg.com/", + "help": "Yarn is a package manager that doubles down as project manager. Whether you work on one-shot projects or large monorepos, as a hobbyist or an enterprise user, we've got you covered.", + "pathExecutable": "yarn", + "customLogger": true, + "tasks": [ + { + "help": "Install the project dependencies", + "postfix": "Install", + "definiteArgument": "install", + "settingsClass": { + "properties": [ + { + "name": "Json", + "type": "bool", + "format": "--json", + "help": "Format the output as an NDJSON stream." + }, + { + "name": "Immutable", + "type": "bool", + "format": "--immutable", + "help": "Abort with an error exit code if the lockfile was to be modified." + }, + { + "name": "ImmutableCache", + "type": "bool", + "format": "--immutable-cache", + "help": "Abort with an error exit code if the cache folder was to be modified." + }, + { + "name": "CheckCache", + "type": "bool", + "format": "--check-cache", + "help": "Always refetch the packages and ensure that their checksums are consistent." + }, + { + "name": "InlineBuilds", + "type": "bool", + "format": "--inline-builds", + "help": "Verbosely print the output of the build steps of dependencies." + }, + { + "name": "Mode", + "type": "YarnInstallMode", + "format": "--mode={value}", + "help": "If the --mode= option is set, Yarn will change which artifacts are generated." + } + ] + } + }, + { + "help": "Run a script defined in the package.json", + "postfix": "Run", + "definiteArgument": "run", + "settingsClass": { + "properties": [ + { + "name": "Command", + "type": "string", + "format": "{value}", + "help": "The command to be executed." + }, + { + "name": "Arguments", + "type": "List", + "format": "{value}", + "separator": " ", + "help": "Arguments passed to the script." + }, + { + "name": "TopLevel", + "type": "bool", + "format": "--top-level", + "help": "Check the root workspace for scripts and/or binaries instead of the current one." + }, + { + "name": "BinariesOnly", + "type": "bool", + "format": "--binaries-only", + "help": "Ignore any user defined scripts and only check for binaries." + } + ] + } + }, + { + "help": "Read a configuration settings", + "postfix": "GetConfig", + "definiteArgument": "config get", + "settingsClass": { + "properties": [ + { + "name": "Name", + "type": "string", + "format": "{value}", + "help": "The name of the configuration setting." + }, + { + "name": "Json", + "type": "bool", + "format": "--json", + "help": "Format the output as an NDJSON stream." + }, + { + "name": "NoRedacted", + "type": "bool", + "format": "--no-redacted", + "help": "Don't redact secrets (such as tokens) from the output." + } + ] + } + }, + { + "help": "Change a configuration settings", + "postfix": "SetConfig", + "definiteArgument": "config set", + "settingsClass": { + "properties": [ + { + "name": "Name", + "type": "string", + "format": "{value}", + "help": "The name of the configuration setting." + }, + { + "name": "Json", + "type": "bool", + "format": "--json", + "help": "Set complex configuration settings to JSON values." + }, + { + "name": "Value", + "type": "string", + "format": "{value}", + "help": "The value of the configuration setting." + }, + { + "name": "Home", + "type": "bool", + "format": "--home", + "help": "Update the home configuration instead of the project configuration." + } + ] + } + } + ], + "enumerations": [ + { + "name": "YarnInstallMode", + "values": [ + "skip-build", + "update-lockfile" + ] + } + ] +} diff --git a/src/Serilog.Ui.MongoDbProvider/Serilog.Ui.MongoDbProvider.csproj b/src/Serilog.Ui.MongoDbProvider/Serilog.Ui.MongoDbProvider.csproj index 8b3898a1..df1e0435 100644 --- a/src/Serilog.Ui.MongoDbProvider/Serilog.Ui.MongoDbProvider.csproj +++ b/src/Serilog.Ui.MongoDbProvider/Serilog.Ui.MongoDbProvider.csproj @@ -13,7 +13,7 @@ - + diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 555a684f..939207ef 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -1,7 +1,7 @@ - net6.0;net7.0;net8.0 + net6.0;net8.0 latest false diff --git a/tests/Serilog.Ui.MongoDbProvider.Tests/Serilog.Ui.MongoDbProvider.Tests.csproj b/tests/Serilog.Ui.MongoDbProvider.Tests/Serilog.Ui.MongoDbProvider.Tests.csproj index 32d200ef..40d116f1 100644 --- a/tests/Serilog.Ui.MongoDbProvider.Tests/Serilog.Ui.MongoDbProvider.Tests.csproj +++ b/tests/Serilog.Ui.MongoDbProvider.Tests/Serilog.Ui.MongoDbProvider.Tests.csproj @@ -8,11 +8,8 @@ - - - - - + + diff --git a/tests/Serilog.Ui.MongoDbProvider.Tests/Util/Builders/MongoDbDataProviderBuilder.cs b/tests/Serilog.Ui.MongoDbProvider.Tests/Util/Builders/MongoDbDataProviderBuilder.cs index 4965c523..173fe973 100644 --- a/tests/Serilog.Ui.MongoDbProvider.Tests/Util/Builders/MongoDbDataProviderBuilder.cs +++ b/tests/Serilog.Ui.MongoDbProvider.Tests/Util/Builders/MongoDbDataProviderBuilder.cs @@ -1,4 +1,4 @@ -using EphemeralMongo; +using Mongo2Go; using MongoDB.Driver; using Serilog; using Serilog.Ui.Common.Tests.DataSamples; @@ -11,7 +11,7 @@ public class MongoDbDataProviderBuilder { private const string DefaultDbName = "IntegrationTests"; - internal readonly IMongoRunner Runner; + internal readonly MongoDbRunner Runner; internal readonly MongoDbOptions Options; internal readonly IMongoClient Client; internal readonly IMongoDatabase Database; @@ -22,7 +22,7 @@ private MongoDbDataProviderBuilder(MongoDbOptions options) { Options = options; (Runner, Client) = IntegrationDbGeneration.Generate(options); - Database = Client.GetDatabase(options.DatabaseName); + Database = Client!.GetDatabase(options.DatabaseName); Sut = new MongoDbDataProvider(Client, Options); Collector = Seed(Options.ConnectionString); diff --git a/tests/Serilog.Ui.MongoDbProvider.Tests/Util/IntegrationDbGeneration.cs b/tests/Serilog.Ui.MongoDbProvider.Tests/Util/IntegrationDbGeneration.cs index 2b6ce5dd..03a7a1a5 100644 --- a/tests/Serilog.Ui.MongoDbProvider.Tests/Util/IntegrationDbGeneration.cs +++ b/tests/Serilog.Ui.MongoDbProvider.Tests/Util/IntegrationDbGeneration.cs @@ -1,25 +1,20 @@ using System; -using EphemeralMongo; +using Mongo2Go; using MongoDB.Driver; using Serilog.Ui.Core.Extensions; using Serilog.Ui.MongoDbProvider; -namespace MongoDb.Tests.Util +namespace MongoDb.Tests.Util; + +public static class IntegrationDbGeneration { - public static class IntegrationDbGeneration + public static (MongoDbRunner runner, IMongoClient client) Generate(MongoDbOptions options) { - public static (IMongoRunner runner, IMongoClient client) Generate(MongoDbOptions options) - { - var runner = MongoRunner.Run(new MongoRunnerOptions - { - UseSingleNodeReplicaSet = true, - AdditionalArguments = "--quiet" - }); - var settings = MongoClientSettings.FromConnectionString(runner.ConnectionString); - settings.ServerSelectionTimeout = TimeSpan.FromSeconds(10); - var client = new MongoClient(settings); - options.WithConnectionString(runner.ConnectionString); - return (runner, client); - } + var runner = MongoDbRunner.Start(singleNodeReplSet: true); + var settings = MongoClientSettings.FromConnectionString(runner.ConnectionString); + settings.ServerSelectionTimeout = TimeSpan.FromSeconds(10); + var client = new MongoClient(settings); + options.WithConnectionString(runner.ConnectionString); + return (runner, client); } } \ No newline at end of file