diff --git a/cli/Squidex.CLI/Directory.Build.props b/cli/Squidex.CLI/Directory.Build.props
index 23c47298..a8f5da2c 100644
--- a/cli/Squidex.CLI/Directory.Build.props
+++ b/cli/Squidex.CLI/Directory.Build.props
@@ -15,6 +15,6 @@
Squidex HeadlessCMS
true
snupkg
- 12.1
+ 12.2
diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/CLIException.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/CLIException.cs
index 948e13c1..f1bcf7aa 100644
--- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/CLIException.cs
+++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/CLIException.cs
@@ -5,8 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
-using System.Runtime.Serialization;
-
namespace Squidex.CLI.Commands.Implementation;
[Serializable]
diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ConsoleLogger.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ConsoleLogger.cs
index 84d91dbb..65c3456b 100644
--- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ConsoleLogger.cs
+++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/ConsoleLogger.cs
@@ -35,22 +35,22 @@ public void Dispose()
public void WriteLine(string message, params object[] args)
{
- Console.WriteLine(message, args);
-
if (consoleTop >= 0)
{
Console.SetCursorPosition(0, consoleTop);
}
+
+ Console.WriteLine(message, args);
}
public void WriteLine(string message)
{
- Console.WriteLine(message);
-
if (consoleTop >= 0)
{
Console.SetCursorPosition(0, consoleTop);
}
+
+ Console.WriteLine(message);
}
}
diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Utils/Extensions.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Utils/Extensions.cs
index 5b7360c1..dd1c2a58 100644
--- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Utils/Extensions.cs
+++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Utils/Extensions.cs
@@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
-using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App.cs
index 933b99c0..d2fed884 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App.cs
@@ -10,15 +10,8 @@
namespace Squidex.CLI.Commands;
-public partial class App
+public partial class App(ILogger log)
{
- private readonly ILogger log;
-
- public App(ILogger log)
- {
- this.log = log;
- }
-
[Command("info", Description = "Shows information about the CLI.")]
public void Info()
{
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_AI.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_AI.cs
index af4bea0f..5b783714 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_AI.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_AI.cs
@@ -24,20 +24,8 @@ public partial class App
{
[Command("ai", Description = "Uses AI commands.")]
[Subcommand]
- public sealed class AI
+ public sealed class AI(IConfigurationService configuration, IConfigurationStore configurationStore, ILogger log)
{
- private readonly IConfigurationService configuration;
- private readonly IConfigurationStore configurationStore;
- private readonly ILogger log;
-
- public AI(IConfigurationService configuration, IConfigurationStore configurationStore, ILogger log)
- {
- this.configuration = configuration;
- this.configurationStore = configurationStore;
-
- this.log = log;
- }
-
[Command("generate-contents", Description = "Generates content items and the corresponding schema.",
ExtendedHelpText =
@"Use descriptions with the following syntax:
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Apps.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Apps.cs
index 4ebb042d..7c8c7579 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Apps.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Apps.cs
@@ -20,18 +20,8 @@ public partial class App
{
[Command("apps", Description = "Manages apps.")]
[Subcommand]
- public sealed class Apps
+ public sealed class Apps(IConfigurationService configuration, ILogger log)
{
- private readonly IConfigurationService configuration;
- private readonly ILogger log;
-
- public Apps(IConfigurationService configuration, ILogger log)
- {
- this.configuration = configuration;
-
- this.log = log;
- }
-
[Command("list", Description = "List all schemas.")]
public async Task List(ListArguments arguments)
{
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Assets.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Assets.cs
index d2a3bef1..54cc6c4e 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Assets.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Assets.cs
@@ -22,18 +22,8 @@ public partial class App
{
[Command("assets", Description = "Manages assets.")]
[Subcommand]
- public sealed class Assets
+ public sealed class Assets(IConfigurationService configuration, ILogger log)
{
- private readonly IConfigurationService configuration;
- private readonly ILogger log;
-
- public Assets(IConfigurationService configuration, ILogger log)
- {
- this.configuration = configuration;
-
- this.log = log;
- }
-
[Command("import", Description = "Import all files from the source folder.")]
public async Task Import(ImportArguments arguments)
{
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs
index a9d39533..ecb3923a 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Backup.cs
@@ -19,18 +19,8 @@ public sealed partial class App
{
[Command("backup", Description = "Manage backups.")]
[Subcommand]
- public sealed class Backup
+ public sealed class Backup(IConfigurationService configuration, ILogger log)
{
- private readonly IConfigurationService configuration;
- private readonly ILogger log;
-
- public Backup(IConfigurationService configuration, ILogger log)
- {
- this.configuration = configuration;
-
- this.log = log;
- }
-
[Command("create", Description = "Create and download an backup.")]
public async Task Create(CreateArguments arguments)
{
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Config.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Config.cs
index a9ecc078..9735715d 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Config.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Config.cs
@@ -19,18 +19,8 @@ public partial class App
{
[Command("config", Description = "Manage configurations.")]
[Subcommand]
- public sealed class Config
+ public sealed class Config(IConfigurationService configuration, ILogger log)
{
- private readonly IConfigurationService configuration;
- private readonly ILogger log;
-
- public Config(IConfigurationService configuration, ILogger log)
- {
- this.configuration = configuration;
-
- this.log = log;
- }
-
[Command("list", Description = "Shows the current configuration.")]
public void List(ListArguments arguments)
{
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Contents.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Contents.cs
index c0e1b3db..571eaa3a 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Contents.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Contents.cs
@@ -7,18 +7,15 @@
using System.Globalization;
using CommandDotNet;
-using ConsoleTables;
using CsvHelper;
using CsvHelper.Configuration;
using FluentValidation;
using Squidex.CLI.Commands.Implementation;
-using Squidex.CLI.Commands.Implementation.AI;
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;
-using static Squidex.CLI.Commands.App.AI;
#pragma warning disable MA0048 // File name must match type name
@@ -30,18 +27,8 @@ public partial class App
[Command("contents", Description = "Manage contents.")]
[Subcommand]
- public sealed class Contents
+ public sealed class Contents(IConfigurationService configuration, ILogger log)
{
- private readonly IConfigurationService configuration;
- private readonly ILogger log;
-
- public Contents(IConfigurationService configuration, ILogger log)
- {
- this.configuration = configuration;
-
- this.log = log;
- }
-
[Command("generate", Description = "Generates test data.")]
public async Task GenerateDummies(GenerateDummiesArguments arguments)
{
@@ -81,6 +68,49 @@ await Task.WhenAll(
}
}
+ [Command("enrich-defaults", Description = "Enrich the content items with its defaults.")]
+ public async Task EnrichDefaults(EnrichDefaultsArguments arguments)
+ {
+ var session = configuration.StartSession(arguments.App);
+
+ var line = log.WriteSameLine();
+
+ var idsRequest = new List();
+ var idsTotal = 0;
+
+ async Task BulkUpdateAsync()
+ {
+ if (idsRequest.Count == 0)
+ {
+ return;
+ }
+
+ var request = new BulkUpdate
+ {
+ Jobs = idsRequest.Select(x => new BulkUpdateJob { Id = x, Type = BulkUpdateType.EnrichDefaults }).ToList()
+ };
+
+ await session.Client.DynamicContents(arguments.Schema).BulkUpdateAsync(request);
+
+ idsTotal += idsRequest.Count;
+ idsRequest.Clear();
+
+ line.WriteLine("Contents handled: {0}", idsTotal);
+ }
+
+ await session.Client.DynamicContents(arguments.Schema).GetAllAsync(async content =>
+ {
+ idsRequest.Add(content.Id);
+
+ if (idsRequest.Count >= 200)
+ {
+ await BulkUpdateAsync();
+ }
+ }, context: QueryContext.Default.Unpublished(arguments.Unpublished));
+
+ await BulkUpdateAsync();
+ }
+
[Command("import", Description = "Import the content to a schema.",
ExtendedHelpText =
@"Use the following format to define fields from the CSV/JSON file:
@@ -406,5 +436,18 @@ public Validator()
}
}
}
+
+ public sealed class EnrichDefaultsArguments : AppArguments
+ {
+ [Operand("schema", Description = "The name of the schema.")]
+ public string Schema { get; set; }
+
+ [Option('u', "unpublished", Description = "Handle unpublished content.")]
+ public bool Unpublished { get; set; }
+
+ public sealed class Validator : AbstractValidator
+ {
+ }
+ }
}
}
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Log.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Log.cs
index d040d4c5..c7b30b8f 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Log.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Log.cs
@@ -22,15 +22,8 @@ public sealed partial class App
{
[Command("log", Description = "Analyze request log.")]
[Subcommand]
- public sealed class Log
+ public sealed class Log(ILogger log)
{
- private readonly ILogger log;
-
- public Log(ILogger log)
- {
- this.log = log;
- }
-
[Command("analyze", Description = "Analyzes request log files.")]
public void Analyze(AnalyzeArguments arguments)
{
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_OpenLibrary.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_OpenLibrary.cs
index c51c8c0c..8c95bebe 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_OpenLibrary.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_OpenLibrary.cs
@@ -11,7 +11,6 @@
using Squidex.CLI.Commands.Implementation.OpenLibrary;
using Squidex.CLI.Commands.Implementation.Sync;
using Squidex.CLI.Configuration;
-using Squidex.ClientLibrary;
#pragma warning disable MA0048 // File name must match type name
@@ -21,20 +20,8 @@ public sealed partial class App
{
[Command("openlib", Description = "Openlibrary example.")]
[Subcommand]
- public sealed class OpenLibrary
+ public sealed class OpenLibrary(IConfigurationService configuration, Synchronizer synchronizer, ILogger log)
{
- private readonly IConfigurationService configuration;
- private readonly Synchronizer synchronizer;
- private readonly ILogger log;
-
- public OpenLibrary(IConfigurationService configuration, Synchronizer synchronizer, ILogger log)
- {
- this.configuration = configuration;
- this.synchronizer = synchronizer;
-
- this.log = log;
- }
-
[Command("generate", Description = "Generate the necessary schemas.")]
public async Task New(NewArguments arguments)
{
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Schemas.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Schemas.cs
index 338973ae..9190c326 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Schemas.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Schemas.cs
@@ -23,18 +23,8 @@ public partial class App
{
[Command("schemas", Description = "Manage schemas.")]
[Subcommand]
- public sealed class Schemas
+ public sealed class Schemas(IConfigurationService configuration, ILogger log)
{
- private readonly IConfigurationService configuration;
- private readonly ILogger log;
-
- public Schemas(IConfigurationService configuration, ILogger log)
- {
- this.configuration = configuration;
-
- this.log = log;
- }
-
[Command("list", Description = "List all schemas.")]
public async Task List(ListArguments arguments)
{
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Sync.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Sync.cs
index 1896c5cd..5ad6067d 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Sync.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Sync.cs
@@ -21,20 +21,8 @@ public sealed partial class App
{
[Command("sync", Description = "Synchronizes apps.")]
[Subcommand]
- public sealed class Sync
+ public sealed class Sync(IConfigurationService configuration, Synchronizer synchronizer, ILogger log)
{
- private readonly IConfigurationService configuration;
- private readonly Synchronizer synchronizer;
- private readonly ILogger log;
-
- public Sync(IConfigurationService configuration, Synchronizer synchronizer, ILogger log)
- {
- this.configuration = configuration;
- this.synchronizer = synchronizer;
-
- this.log = log;
- }
-
[Command("new", Description = "Creates a new folder with sample files how to create an app from json files.")]
public async Task New(NewArgument arguments)
{
diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Twitter.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Twitter.cs
index 7f6e2937..39d02499 100644
--- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Twitter.cs
+++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Twitter.cs
@@ -18,15 +18,8 @@ public sealed partial class App
{
[Command("twitter", Description = "Manage twitter.")]
[Subcommand]
- public sealed class Twitter
+ public sealed class Twitter(ILogger log)
{
- private readonly ILogger log;
-
- public Twitter(ILogger log)
- {
- this.log = log;
- }
-
[Command("auth", Description = "Starts the authentication.")]
public async Task Auth(AuthArguments arguments)
{