From 758905e1c37eeb893dadb20a777f493e2c8dab66 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 1 Mar 2023 20:05:22 +0100 Subject: [PATCH] Update CLI --- cli/Squidex.CLI/Directory.Build.props | 2 +- .../FileSystem/FileExtensions.cs | 1 + .../FileSystem/Git/GitFileSystem.cs | 1 + .../Implementation/ImExport/ImportHelper.cs | 1 + .../Commands/Implementation/LogExtensions.cs | 2 +- .../Sync/App/AppSynchronizer.cs | 1 + .../Sync/Rules/RulesSynchronizer.cs | 20 +++++++++++++------ .../Sync/Schemas/SchemasSynchronizer.cs | 1 + .../Implementation/Sync/Synchronizer.cs | 1 + .../Sync/Workflows/WorkflowsSynchronizer.cs | 1 + .../Implementation/{ => Utils}/Extensions.cs | 6 +++--- .../Implementation/Utils/SimpleMapper.cs | 2 +- .../Implementation/Utils/TaskExtensions.cs | 2 +- .../Configuration/ConfigurationService.cs | 1 + cli/Squidex.CLI/Squidex.CLI.Core/Helper.cs | 2 +- .../Squidex.CLI.Core/Properties/Properties.cs | 10 ++++++++++ .../Squidex.CLI/Commands/App_Content.cs | 1 + 17 files changed, 41 insertions(+), 14 deletions(-) rename cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/{ => Utils}/Extensions.cs (96%) create mode 100644 cli/Squidex.CLI/Squidex.CLI.Core/Properties/Properties.cs diff --git a/cli/Squidex.CLI/Directory.Build.props b/cli/Squidex.CLI/Directory.Build.props index 61036ed6..836ab765 100644 --- a/cli/Squidex.CLI/Directory.Build.props +++ b/cli/Squidex.CLI/Directory.Build.props @@ -15,6 +15,6 @@ Squidex HeadlessCMS true snupkg - 9.5 + 9.6 diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/FileSystem/FileExtensions.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/FileSystem/FileExtensions.cs index 52db52c2..0d53a199 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/FileSystem/FileExtensions.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/FileSystem/FileExtensions.cs @@ -6,6 +6,7 @@ // ========================================================================== using System.Security.Cryptography; +using Squidex.CLI.Commands.Implementation.Utils; namespace Squidex.CLI.Commands.Implementation.FileSystem; diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/FileSystem/Git/GitFileSystem.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/FileSystem/Git/GitFileSystem.cs index ca4fce9e..2ce287a0 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/FileSystem/Git/GitFileSystem.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/FileSystem/Git/GitFileSystem.cs @@ -7,6 +7,7 @@ using LibGit2Sharp; using Squidex.CLI.Commands.Implementation.FileSystem.Default; +using Squidex.CLI.Commands.Implementation.Utils; using Squidex.Text; namespace Squidex.CLI.Commands.Implementation.FileSystem.Git; diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ImportHelper.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ImportHelper.cs index 82cb8e30..c1f56bce 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ImportHelper.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ImExport/ImportHelper.cs @@ -11,6 +11,7 @@ using CsvHelper.Configuration; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Squidex.CLI.Commands.Implementation.Utils; using Squidex.ClientLibrary; using Squidex.ClientLibrary.Management; diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/LogExtensions.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/LogExtensions.cs index c7e8e614..783c4e92 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/LogExtensions.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/LogExtensions.cs @@ -9,7 +9,7 @@ namespace Squidex.CLI.Commands.Implementation; -public static class LogExtensions +internal static class LogExtensions { private static readonly SemaphoreSlim LockObject = new SemaphoreSlim(1); diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/App/AppSynchronizer.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/App/AppSynchronizer.cs index cd4643e1..10856e4d 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/App/AppSynchronizer.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/App/AppSynchronizer.cs @@ -6,6 +6,7 @@ // ========================================================================== using Squidex.CLI.Commands.Implementation.FileSystem; +using Squidex.CLI.Commands.Implementation.Utils; using Squidex.ClientLibrary.Management; namespace Squidex.CLI.Commands.Implementation.Sync.App; diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Rules/RulesSynchronizer.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Rules/RulesSynchronizer.cs index 17dea089..5494ab72 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Rules/RulesSynchronizer.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Rules/RulesSynchronizer.cs @@ -6,6 +6,7 @@ // ========================================================================== using Squidex.CLI.Commands.Implementation.FileSystem; +using Squidex.CLI.Commands.Implementation.Utils; using Squidex.ClientLibrary; using Squidex.ClientLibrary.Management; @@ -189,9 +190,10 @@ private async Task MapSchemaIdsToNamesAsync(ISession session, ExtendableRules cu foreach (var rule in current.Items) { - if (rule.Trigger is ContentChangedRuleTriggerDto contentTrigger && contentTrigger.Schemas != null) + if (rule.Trigger is ContentChangedRuleTriggerDto contentTrigger) { - MapSchemas(contentTrigger, map); + MapSchemas(contentTrigger.Schemas, map); + MapSchemas(contentTrigger.ReferencedSchemas, map); } } } @@ -204,16 +206,22 @@ private async Task MapSchemaNamesToIdsAsync(ISession session, List mo foreach (var newRule in models) { - if (newRule.Trigger is ContentChangedRuleTriggerDto contentTrigger && contentTrigger.Schemas != null) + if (newRule.Trigger is ContentChangedRuleTriggerDto contentTrigger) { - MapSchemas(contentTrigger, map); + MapSchemas(contentTrigger.Schemas, map); + MapSchemas(contentTrigger.ReferencedSchemas, map); } } } - private void MapSchemas(ContentChangedRuleTriggerDto dto, Dictionary schemaMap) + private void MapSchemas(List? schemas, Dictionary schemaMap) { - foreach (var schema in dto.Schemas) + if (schemas == null) + { + return; + } + + foreach (var schema in schemas) { if (!schemaMap.TryGetValue(schema.SchemaId!, out var found)) { diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Schemas/SchemasSynchronizer.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Schemas/SchemasSynchronizer.cs index a029b8f5..e83afe17 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Schemas/SchemasSynchronizer.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Schemas/SchemasSynchronizer.cs @@ -6,6 +6,7 @@ // ========================================================================== using Squidex.CLI.Commands.Implementation.FileSystem; +using Squidex.CLI.Commands.Implementation.Utils; using Squidex.ClientLibrary.Management; #pragma warning disable CS0618 // Type or member is obsolete diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Synchronizer.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Synchronizer.cs index 89549a96..d81c2d76 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Synchronizer.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Synchronizer.cs @@ -6,6 +6,7 @@ // ========================================================================== using Squidex.CLI.Commands.Implementation.FileSystem; +using Squidex.CLI.Commands.Implementation.Utils; namespace Squidex.CLI.Commands.Implementation.Sync; diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Workflows/WorkflowsSynchronizer.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Workflows/WorkflowsSynchronizer.cs index 661dd127..7d296b57 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Workflows/WorkflowsSynchronizer.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Workflows/WorkflowsSynchronizer.cs @@ -6,6 +6,7 @@ // ========================================================================== using Squidex.CLI.Commands.Implementation.FileSystem; +using Squidex.CLI.Commands.Implementation.Utils; using Squidex.ClientLibrary.Management; namespace Squidex.CLI.Commands.Implementation.Sync.Workflows; diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Extensions.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Utils/Extensions.cs similarity index 96% rename from cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Extensions.cs rename to cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Utils/Extensions.cs index 9547c1a1..87d581bf 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Extensions.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Utils/Extensions.cs @@ -10,9 +10,9 @@ using System.Text.RegularExpressions; using Newtonsoft.Json; -namespace Squidex.CLI.Commands.Implementation; +namespace Squidex.CLI.Commands.Implementation.Utils; -public static class Extensions +internal static class Extensions { private static readonly Regex QueryRegex = new Regex(@"[?&](\w[\w.]*)=([^?&]+)"); @@ -57,7 +57,7 @@ public static async Task Foreach(this IEnumerable source, Func(this ISourceBlock source, ITargetBlock target) diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Configuration/ConfigurationService.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Configuration/ConfigurationService.cs index dede7db8..b3882528 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Configuration/ConfigurationService.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Configuration/ConfigurationService.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json; using Squidex.CLI.Commands.Implementation; +using Squidex.CLI.Commands.Implementation.Utils; using Squidex.ClientLibrary; using Squidex.ClientLibrary.Configuration; diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Helper.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Helper.cs index 09521ee0..3e37eb96 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Helper.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Helper.cs @@ -11,7 +11,7 @@ namespace Squidex.CLI; -public static class Helper +internal static class Helper { private static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings(); private static readonly JsonSerializer Serializer; diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Properties/Properties.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Properties/Properties.cs new file mode 100644 index 00000000..806ebdf2 --- /dev/null +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Properties/Properties.cs @@ -0,0 +1,10 @@ +// ========================================================================== +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex UG (haftungsbeschraenkt) +// All rights reserved. Licensed under the MIT license. +// ========================================================================== + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("sq")] diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Content.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Content.cs index a93efe70..d7b48d06 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Content.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Content.cs @@ -13,6 +13,7 @@ using Squidex.CLI.Commands.Implementation; using Squidex.CLI.Commands.Implementation.ImExport; using Squidex.CLI.Commands.Implementation.TestData; +using Squidex.CLI.Commands.Implementation.Utils; using Squidex.CLI.Configuration; using Squidex.ClientLibrary;