<commit_before>using Lombiq.HelpfulLibraries.OrchardCore.Contents;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentManagement.Metadata.Settings;
using OrchardCore.Data.Migration;
using static Lombiq.HelpfulExtensions.Extensions.Widgets.WidgetTypes;

namespace Lombiq.HelpfulExtensions.Extensions.Widgets;

public class Migrations : DataMigration
{
    private readonly IContentDefinitionManager _contentDefinitionManager;

    public Migrations(IContentDefinitionManager contentDefinitionManager) =>
        _contentDefinitionManager = contentDefinitionManager;

    public int Create()
    {
        _contentDefinitionManager.AlterTypeDefinition(ContainerWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
            .WithPart("TitlePart", part => part.WithPosition("0"))
            .WithPart("FlowPart", part => part.WithPosition("1"))
        );

        _contentDefinitionManager.AlterTypeDefinition(HtmlWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
            .WithPart("HtmlBodyPart", part => part
                .WithDisplayName("HTML Body")
                .WithSettings(new ContentTypePartSettings
                {
                    Editor = "Trumbowyg",
                })
            )
        );

        _contentDefinitionManager.AlterTypeDefinition(LiquidWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
            .WithPart("LiquidPart", part => part
                .WithDisplayName("Liquid Part")
            )
        );

        _contentDefinitionManager.AlterTypeDefinition(MenuWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
        );

        _contentDefinitionManager.AlterTypeDefinition(MarkdownWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
            .WithPart("MarkdownBodyPart", part => part
                .WithDisplayName("Markdown Part")
            )
        );

        return 4;
    }

    public int UpdateFrom1()
    {
        _contentDefinitionManager.AlterTypeDefinition(ContainerWidget, builder => builder
            .WithPart("TitlePart", part => part.WithPosition("0"))
            .WithPart("FlowPart", part => part.WithPosition("1"))
        );

        return 3;
    }

    public int UpdateFrom2()
    {
        _contentDefinitionManager.AlterTypeDefinition(MenuWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
        );

        return 4;
    }

    public int UpdateFrom3()
    {
        _contentDefinitionManager.AlterTypeDefinition(MarkdownWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
            .WithPart("MarkdownBodyPart", part => part
                .WithDisplayName("Markdown Part")
                )
            );

        return 4;
    }
}
<commit_msg>Fixing return values, fixing indent<commit_after>using Lombiq.HelpfulLibraries.OrchardCore.Contents;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentManagement.Metadata.Settings;
using OrchardCore.Data.Migration;
using static Lombiq.HelpfulExtensions.Extensions.Widgets.WidgetTypes;

namespace Lombiq.HelpfulExtensions.Extensions.Widgets;

public class Migrations : DataMigration
{
    private readonly IContentDefinitionManager _contentDefinitionManager;

    public Migrations(IContentDefinitionManager contentDefinitionManager) =>
        _contentDefinitionManager = contentDefinitionManager;

    public int Create()
    {
        _contentDefinitionManager.AlterTypeDefinition(ContainerWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
            .WithPart("TitlePart", part => part.WithPosition("0"))
            .WithPart("FlowPart", part => part.WithPosition("1"))
        );

        _contentDefinitionManager.AlterTypeDefinition(HtmlWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
            .WithPart("HtmlBodyPart", part => part
                .WithDisplayName("HTML Body")
                .WithSettings(new ContentTypePartSettings
                {
                    Editor = "Trumbowyg",
                })
            )
        );

        _contentDefinitionManager.AlterTypeDefinition(LiquidWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
            .WithPart("LiquidPart", part => part
                .WithDisplayName("Liquid Part")
            )
        );

        _contentDefinitionManager.AlterTypeDefinition(MenuWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
        );

        _contentDefinitionManager.AlterTypeDefinition(MarkdownWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
            .WithPart("MarkdownBodyPart", part => part
                .WithDisplayName("Markdown Part")
            )
        );

        return 4;
    }

    public int UpdateFrom1()
    {
        _contentDefinitionManager.AlterTypeDefinition(ContainerWidget, builder => builder
            .WithPart("TitlePart", part => part.WithPosition("0"))
            .WithPart("FlowPart", part => part.WithPosition("1"))
        );

        return 2;
    }

    public int UpdateFrom2()
    {
        _contentDefinitionManager.AlterTypeDefinition(MenuWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
        );

        return 3;
    }

    public int UpdateFrom3()
    {
        _contentDefinitionManager.AlterTypeDefinition(MarkdownWidget, builder => builder
            .Securable()
            .Stereotype(CommonStereotypes.Widget)
            .WithPart("MarkdownBodyPart", part => part
                .WithDisplayName("Markdown Part")
            )
        );

        return 4;
    }
}

{'fraction_non_alphanumeric': 0.08781190019193857, 'fraction_numerical': 0.0035188739603326936, 'mean_word_length': 2.0970777612679545, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '949262', 'n_tokens_mistral': 1638, 'n_tokens_neox': 1519, 'n_words': 244}