Skip to content

Commit

Permalink
Migration to .NET Core 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Feb 18, 2020
1 parent 8e51f7f commit 5cb92d5
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 47 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
5 changes: 3 additions & 2 deletions cli/Squidex.CLI/Squidex.CLI.Tests/MapToSquidexTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// ==========================================================================

using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
Expand All @@ -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");
Expand All @@ -49,7 +50,7 @@ public MapToSquidexTests()
}
}

csvReader = new CsvReader(new StringReader(csv.ToString()));
csvReader = new CsvReader(new StringReader(csv.ToString()), CultureInfo.InvariantCulture);
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions cli/Squidex.CLI/Squidex.CLI.Tests/Squidex.CLI.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
17 changes: 9 additions & 8 deletions cli/Squidex.CLI/Squidex.CLI/Commands/App_Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -139,7 +140,7 @@ public async Task Export(ExportArguments arguments)

var (_, service) = Configuration.Setup();

var client = service.GetClient<DummyEntity, DummyData>(arguments.Schema);
var client = service.CreateContentsClient<DummyEntity, DummyData>(arguments.Schema);

if (arguments.Format == Format.JSON)
{
Expand Down Expand Up @@ -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 = ";"
};
Expand Down Expand Up @@ -250,7 +251,7 @@ await ExportAsync(arguments, entity =>

private async Task ImportAsync(IImortArgumentBase arguments, SquidexClientManager service, IEnumerable<DummyData> datas)
{
var client = service.GetClient<DummyEntity, DummyData>(arguments.Schema);
var client = service.CreateContentsClient<DummyEntity, DummyData>(arguments.Schema);

var totalWritten = 0;

Expand All @@ -277,19 +278,19 @@ private async Task ExportAsync(ExportArguments arguments, Action<DummyEntity> ha

var (_, service) = Configuration.Setup();

var client = service.GetClient<DummyEntity, DummyData>(arguments.Schema);
var client = service.CreateContentsClient<DummyEntity, DummyData>(arguments.Schema);

var total = 0L;
var totalRead = 0;
var currentPage = 0L;

var consoleTop = Console.CursorTop;

var handled = new HashSet<string>();
var handled = new HashSet<Guid>();

do
{
var query = new ODataQuery
var query = new ContentQuery
{
Filter = arguments.Filter,
OrderBy = arguments.OrderBy,
Expand Down
2 changes: 1 addition & 1 deletion cli/Squidex.CLI/Squidex.CLI/Commands/DummyData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed class DummyData : Dictionary<string, Dictionary<string, JToken>>
{
}

public sealed class DummyEntity : SquidexEntityBase<DummyData>
public sealed class DummyEntity : Content<DummyData>
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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();

foreach (var item in fields.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries))
{
var parts = item.Split('=');

JsonPath GetPath(string value)
static JsonPath GetPath(string value)
{
var path = JsonPath.Parse(value);

Expand Down Expand Up @@ -59,15 +59,15 @@ JsonPath GetPath(string value)

public static JsonMapping ForCsv2Json(string fields)
{
fields = fields ?? string.Empty;
fields ??= string.Empty;

var result = new JsonMapping();

foreach (var item in fields.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries))
{
var parts = item.Split('=');

JsonPath GetPath(string value)
static JsonPath GetPath(string value)
{
var path = JsonPath.Parse(value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
}

Expand Down
20 changes: 16 additions & 4 deletions cli/Squidex.CLI/Squidex.CLI/Configuration/ConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Linq;
using Newtonsoft.Json;
using Squidex.ClientLibrary;
using Squidex.ClientLibrary.Configuration;

namespace Squidex.CLI.Configuration
{
Expand Down Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions cli/Squidex.CLI/Squidex.CLI/Squidex.CLI.csproj
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<AssemblyName Condition="'$(PackDotnetTool)'!='1'">sq</AssemblyName>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<Version>4.1</Version>
<PackAsTool>true</PackAsTool>
<ToolCommandName>sq</ToolCommandName>
<Authors>sebastianstehle</Authors>
<Company>Squidex UG (haftungsbeschränkt)</Company>
<Description>Command Line Interface for Squidex Headless CMS</Description>
<Copyright>MIT</Copyright>
<PackageTags>Squidex HeadlessCMS</PackageTags>
<Description>Command Line Interface for Squidex Headless CMS</Description>
<OutputType>Exe</OutputType>
<PackageIconUrl>https://raw.githubusercontent.com/Squidex/squidex/master/media/logo-squared.png</PackageIconUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/Squidex/squidex/</PackageProjectUrl>
<PackageTags>Squidex HeadlessCMS</PackageTags>
<PackAsTool>true</PackAsTool>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<ToolCommandName>sq</ToolCommandName>
<Version>4.2</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ConsoleTables" Version="2.4.0" />
<PackageReference Include="CommandDotNet" Version="2.8.2" />
<PackageReference Include="CommandDotNet.IoC.MicrosoftDependencyInjection" Version="1.1.0" />
<PackageReference Include="CoreTweet" Version="1.0.0.483" />
<PackageReference Include="CsvHelper" Version="12.3.2" />
<PackageReference Include="CsvHelper" Version="15.0.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Slugify.Core" Version="2.3.0" />
<PackageReference Include="Squidex.ClientLibrary" Version="4.0.3" />
<PackageReference Include="Squidex.ClientLibrary" Version="4.2.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
</ItemGroup>
<PropertyGroup>
Expand Down

0 comments on commit 5cb92d5

Please sign in to comment.