diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml index 3a08522e..0a1fce56 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/cli.yml @@ -19,7 +19,7 @@ jobs: - name: setup dotnet uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.0.100 + dotnet-version: 3.1.101 - name: publish dotnet run: | @@ -29,27 +29,27 @@ jobs: - name: publish win-x64 run: | cd cli/Squidex.CLI/Squidex.CLI - dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true /p:UseAppHost=true + dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:UseAppHost=true - name: publish win-x86 run: | cd cli/Squidex.CLI/Squidex.CLI - dotnet publish -r win-x86 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true + dotnet publish -r win-x86 -c Release /p:PublishSingleFile=true - name: publish linux-x64 run: | cd cli/Squidex.CLI/Squidex.CLI - dotnet publish -r linux-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true + dotnet publish -r linux-x64 -c Release /p:PublishSingleFile=true - name: publish ubuntu-x64 run: | cd cli/Squidex.CLI/Squidex.CLI - dotnet publish -r ubuntu-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true + dotnet publish -r ubuntu-x64 -c Release /p:PublishSingleFile=true - name: publish osx-x64 run: | cd cli/Squidex.CLI/Squidex.CLI - dotnet publish -r osx-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true + dotnet publish -r osx-x64 -c Release /p:PublishSingleFile=true - name: pack dotnet tool run: | diff --git a/.github/workflows/sdk.yml b/.github/workflows/sdk.yml index 0f1f266c..a8e8629a 100644 --- a/.github/workflows/sdk.yml +++ b/.github/workflows/sdk.yml @@ -16,7 +16,7 @@ jobs: - name: setup dotnet uses: actions/setup-dotnet@v1 with: - dotnet-version: 2.2.108 + dotnet-version: 3.1.101 - name: publish run: | diff --git a/cli/Squidex.CLI/Squidex.CLI.Tests/MapToSquidexTests.cs b/cli/Squidex.CLI/Squidex.CLI.Tests/MapToSquidexTests.cs index 0c45a40e..7d47a896 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Tests/MapToSquidexTests.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Tests/MapToSquidexTests.cs @@ -6,6 +6,7 @@ // ========================================================================== using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -29,7 +30,7 @@ public MapToSquidexTests() using (var stringWriter = new StringWriter(csv)) { - using (var writer = new CsvWriter(stringWriter)) + using (var writer = new CsvWriter(stringWriter, CultureInfo.InvariantCulture)) { writer.WriteField("text"); writer.WriteField("boolean"); @@ -49,7 +50,7 @@ public MapToSquidexTests() } } - csvReader = new CsvReader(new StringReader(csv.ToString())); + csvReader = new CsvReader(new StringReader(csv.ToString()), CultureInfo.InvariantCulture); } [Fact] diff --git a/cli/Squidex.CLI/Squidex.CLI.Tests/Squidex.CLI.Tests.csproj b/cli/Squidex.CLI/Squidex.CLI.Tests/Squidex.CLI.Tests.csproj index 13f2d8c0..4d9fc511 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Tests/Squidex.CLI.Tests.csproj +++ b/cli/Squidex.CLI/Squidex.CLI.Tests/Squidex.CLI.Tests.csproj @@ -1,9 +1,9 @@  - netcoreapp3.0 + netcoreapp3.1 - + diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Content.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Content.cs index 0f94aee7..97ed3af4 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Content.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Content.cs @@ -7,18 +7,19 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Threading.Tasks; using CommandDotNet; using CommandDotNet.Attributes; using CsvHelper; +using CsvHelper.Configuration; using FluentValidation; using FluentValidation.Attributes; using Newtonsoft.Json; using Squidex.CLI.Commands.Implementation; using Squidex.CLI.Configuration; using Squidex.ClientLibrary; -using CsvOptions = CsvHelper.Configuration.Configuration; #pragma warning disable IDE0059 // Value assigned to symbol is never used @@ -103,7 +104,7 @@ public async Task Import(ImportArguments arguments) { using (var streamReader = new StreamReader(stream)) { - var csvOptions = new CsvOptions + var csvOptions = new CsvConfiguration(CultureInfo.InvariantCulture) { Delimiter = arguments.Delimiter }; @@ -139,7 +140,7 @@ public async Task Export(ExportArguments arguments) var (_, service) = Configuration.Setup(); - var client = service.GetClient(arguments.Schema); + var client = service.CreateContentsClient(arguments.Schema); if (arguments.Format == Format.JSON) { @@ -212,7 +213,7 @@ await ExportAsync(arguments, entity => { using (var streamWriter = new StreamWriter(stream)) { - var csvOptions = new CsvOptions + var csvOptions = new CsvConfiguration(CultureInfo.InvariantCulture) { Delimiter = ";" }; @@ -250,7 +251,7 @@ await ExportAsync(arguments, entity => private async Task ImportAsync(IImortArgumentBase arguments, SquidexClientManager service, IEnumerable datas) { - var client = service.GetClient(arguments.Schema); + var client = service.CreateContentsClient(arguments.Schema); var totalWritten = 0; @@ -277,7 +278,7 @@ private async Task ExportAsync(ExportArguments arguments, Action ha var (_, service) = Configuration.Setup(); - var client = service.GetClient(arguments.Schema); + var client = service.CreateContentsClient(arguments.Schema); var total = 0L; var totalRead = 0; @@ -285,11 +286,11 @@ private async Task ExportAsync(ExportArguments arguments, Action ha var consoleTop = Console.CursorTop; - var handled = new HashSet(); + var handled = new HashSet(); do { - var query = new ODataQuery + var query = new ContentQuery { Filter = arguments.Filter, OrderBy = arguments.OrderBy, diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/DummyData.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/DummyData.cs index 0862c7a8..f7d56b4b 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/DummyData.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/DummyData.cs @@ -16,7 +16,7 @@ public sealed class DummyData : Dictionary> { } - public sealed class DummyEntity : SquidexEntityBase + public sealed class DummyEntity : Content { } } diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Csv2SquidexConverter.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Csv2SquidexConverter.cs index e216f2cc..a7c7210b 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Csv2SquidexConverter.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/Csv2SquidexConverter.cs @@ -66,7 +66,7 @@ private void SetValue(DummyData data, JToken value, JsonPath path) data[path[0].Key] = property; } - object AddElement(object parent, string key, int index, JToken currentValue, bool merge) + static object AddElement(object parent, string key, int index, JToken currentValue, bool merge) { if (index >= 0) { diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/JsonMapping.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/JsonMapping.cs index 59021ea0..936ac838 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/JsonMapping.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/JsonMapping.cs @@ -15,7 +15,7 @@ public sealed class JsonMapping : List<(string Name, JsonPath Path)> { public static JsonMapping ForJson2Csv(string fields) { - fields = fields ?? string.Empty; + fields ??= string.Empty; var result = new JsonMapping(); @@ -23,7 +23,7 @@ public static JsonMapping ForJson2Csv(string fields) { var parts = item.Split('='); - JsonPath GetPath(string value) + static JsonPath GetPath(string value) { var path = JsonPath.Parse(value); @@ -59,7 +59,7 @@ JsonPath GetPath(string value) public static JsonMapping ForCsv2Json(string fields) { - fields = fields ?? string.Empty; + fields ??= string.Empty; var result = new JsonMapping(); @@ -67,7 +67,7 @@ public static JsonMapping ForCsv2Json(string fields) { var parts = item.Split('='); - JsonPath GetPath(string value) + static JsonPath GetPath(string value) { var path = JsonPath.Parse(value); diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/TestDataGenerator.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/TestDataGenerator.cs index 8cbc4a95..4df163d3 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/TestDataGenerator.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/Implementation/TestDataGenerator.cs @@ -73,15 +73,12 @@ private JToken GenerateValue(FieldDto field) { var value = random.Next(3); - switch (value) + return value switch { - case 1: - return true; - case 2: - return false; - default: - return null; - } + 1 => true, + 2 => false, + _ => null, + }; } } diff --git a/cli/Squidex.CLI/Squidex.CLI/Configuration/ConfigurationService.cs b/cli/Squidex.CLI/Squidex.CLI/Configuration/ConfigurationService.cs index 0eb971c6..31e067b8 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Configuration/ConfigurationService.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Configuration/ConfigurationService.cs @@ -10,6 +10,7 @@ using System.Linq; using Newtonsoft.Json; using Squidex.ClientLibrary; +using Squidex.ClientLibrary.Configuration; namespace Squidex.CLI.Configuration { @@ -144,21 +145,32 @@ public void UseAppInSession(string entry) { if (!string.IsNullOrWhiteSpace(sessionApp) && configuration.Apps.TryGetValue(sessionApp, out var app)) { - var authenticator = new Authenticator(app.ServiceUrl, app.ClientId, app.ClientSecret); + var options = CreateOptions(app); - return (app.Name, new SquidexClientManager(app.ServiceUrl, app.Name, authenticator)); + return (app.Name, new SquidexClientManager(options)); } if (!string.IsNullOrWhiteSpace(configuration.CurrentApp) && configuration.Apps.TryGetValue(configuration.CurrentApp, out app)) { - var authenticator = new Authenticator(app.ServiceUrl, app.ClientId, app.ClientSecret); + var options = CreateOptions(app); - return (app.Name, new SquidexClientManager(app.ServiceUrl, app.Name, authenticator)); + return (app.Name, new SquidexClientManager(options)); } throw new SquidexException("Cannot find valid configuration."); } + private static SquidexOptions CreateOptions(ConfiguredApp app) + { + return new SquidexOptions + { + AppName = app.Name, + ClientId = app.ClientId, + ClientSecret = app.ClientSecret, + Url = app.ServiceUrl + }; + } + public Configuration GetConfiguration() { return configuration; diff --git a/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj b/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj index 4f0542c2..01d412b7 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj +++ b/cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj @@ -1,30 +1,30 @@  - Exe sq - netcoreapp3.0 - true - 4.1 - true - sq sebastianstehle Squidex UG (haftungsbeschränkt) - Command Line Interface for Squidex Headless CMS MIT - Squidex HeadlessCMS + Command Line Interface for Squidex Headless CMS + Exe https://raw.githubusercontent.com/Squidex/squidex/master/media/logo-squared.png MIT https://github.com/Squidex/squidex/ + Squidex HeadlessCMS + true + netcoreapp3.1 + true + sq + 4.2 - + - +