public static IActivityBuilder Then( this IOutcomeBuilder outcomeBuilder, Func <ActivityExecutionContext, ValueTask <IActivityExecutionResult> > activity, Action <IActivityBuilder>?branch = default, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string?sourceFile = default) => outcomeBuilder.Then <Inline>(inline => inline.Set(x => x.Function, activity), branch, lineNumber, sourceFile);
public static IActivityBuilder Then( this IOutcomeBuilder outcomeBuilder, Action activity, Action <IActivityBuilder>?branch = default, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string?sourceFile = default) => outcomeBuilder.Then <Inline>( inline => inline.Set(x => x.Function, RunInline(activity)), branch, lineNumber, sourceFile);
public static IActivityBuilder AddEntityConstructorsGenerationWorkflow(this IOutcomeBuilder builder) { return(builder .Then <EntityConstructorsStep>() .Then <FileModifierStep>() ); }
public static IActivityBuilder AddLocalizationGenerationWorkflow(this IOutcomeBuilder builder) { return(builder /* Add localization */ .Then <TextGenerationStep>( step => { step.TemplateName = "Localization"; } ).WithName(ActivityNames.LocalizationGeneration) .Then <MultiFileFinderStep>( step => { step.SearchFileName = new LiteralExpression("*.json"); step.BaseDirectory = new JavaScriptExpression <string>(@"`${AspNetCoreDir}/src/${ProjectInfo.FullName}.Domain.Shared/Localization`"); } ) .Then <ForEach>( x => { x.CollectionExpression = new JavaScriptExpression <IList <object> >(MultiFileFinderStep.DefaultFileParameterName); }, branch => branch.When(OutcomeNames.Iterate) .Then <LocalizationJsonModificationCreatorStep>( step => { step.TargetFile = new JavaScriptExpression <string>("CurrentValue"); step.LocalizationJson = new JavaScriptExpression <string>(TextGenerationStep.DefaultGeneratedTextParameterName); } ) .Then(branch) ) ); }
public static IActivityBuilder AddUiRazorPagesGenerationWorkflow(this IOutcomeBuilder builder) { return(builder .Then <IfElse>( step => step.ConditionExpression = new JavaScriptExpression <bool>("ProjectInfo.TemplateType == 1"), ifElse => { // For module, put generated Razor files under the "ProjectName" folder */ ifElse .When(OutcomeNames.True) .Then <SetVariable>( step => { step.VariableName = "Bag.PagesFolder"; step.ValueExpression = new JavaScriptExpression <string>("ProjectInfo.Name"); } ) .Then <SetModelVariableStep>() .Then(ActivityNames.UiRazor) ; ifElse .When(OutcomeNames.False) .Then(ActivityNames.UiRazor) ; } ) /* Generate razor pages ui files*/ .Then <GroupGenerationStep>( step => { step.GroupName = "UiRazor"; step.TargetDirectory = new JavaScriptExpression <string>(VariableNames.AspNetCoreDir); } ).WithName(ActivityNames.UiRazor) /* Add menu name */ .Then <FileFinderStep>( step => step.SearchFileName = new JavaScriptExpression <string>("`${ProjectInfo.Name}Menus.cs`") ) .Then <MenuNameStep>() .Then <FileModifierStep>() /* Add menu */ .Then <FileFinderStep>( step => step.SearchFileName = new JavaScriptExpression <string>("`${ProjectInfo.Name}MenuContributor.cs`") ) .Then <MenuContributorStep>() .Then <FileModifierStep>() /* Add mapping */ .Then <FileFinderStep>( step => { step.BaseDirectory = new JavaScriptExpression <string>(@"`${AspNetCoreDir}/src`"); step.SearchFileName = new JavaScriptExpression <string>("`${ProjectInfo.Name}WebAutoMapperProfile.cs`"); }) .Then <WebAutoMapperProfileStep>() .Then <FileModifierStep>() ); }
public static IActivityBuilder AddTestGenerationWorkflow(this IOutcomeBuilder builder) { return(builder /* Generate test files */ .Then <GroupGenerationStep>( step => { step.GroupName = "Test"; step.TargetDirectory = new JavaScriptExpression <string>(VariableNames.AspNetCoreDir); } ) ); }
public static IActivityBuilder AddUiAngularGenerationWorkflow(this IOutcomeBuilder builder) { string cdOption = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? " /d" : ""; return(builder /* Add angular module */ .Then <RunCommandStep>( step => step.Command = new JavaScriptExpression <string>( @$ "`cd{cdOption} ${{BaseDirectory}}/angular && yarn ng generate module ${{EntityInfo.NamespaceLastPart.toLowerCase()}} --route ${{EntityInfo.NamespaceLastPart.toLowerCase()}} --module app.module`" )) /* Modify app-routing.module.ts */ .Then <FileFinderStep>( step => step.SearchFileName = new LiteralExpression("app-routing.module.ts") ) .Then <AppRoutingModuleStep>() .Then <FileModifierStep>( step => step.NewLine = new JavaScriptExpression <string>(@"'\n'") ) /* Add list component */ .Then <RunCommandStep>( step => step.Command = new JavaScriptExpression <string>( @$ "`cd{cdOption} ${{BaseDirectory}}/angular && yarn ng generate component ${{EntityInfo.NamespaceLastPart.toLowerCase()}}/${{EntityInfo.Name.toLowerCase()}}-list`" )) /* Modify XXX.module.ts */ .Then <FileFinderStep>( step => step.SearchFileName = new JavaScriptExpression <string>("`${EntityInfo.NamespaceLastPart.toLowerCase()}.module.ts`") ) .Then <ModuleStep>() .Then <FileModifierStep>( step => step.NewLine = new JavaScriptExpression <string>(@"'\n'") ) /* Modify XXX-routing.module.ts */ .Then <FileFinderStep>( step => step.SearchFileName = new JavaScriptExpression <string>("`${EntityInfo.NamespaceLastPart.toLowerCase()}-routing.module.ts`") ) .Then <RoutingModuleStep>() .Then <FileModifierStep>( step => step.NewLine = new JavaScriptExpression <string>(@"'\n'") ) /* Create state */ .Then <RunCommandStep>( step => step.Command = new JavaScriptExpression <string>( @$ "`cd{cdOption} ${{BaseDirectory}}/angular && yarn ng generate ngxs-schematic:state ${{EntityInfo.NamespaceLastPart.toLowerCase()}}`" )) /* Generate XXX.ts */ .Then <GroupGenerationStep>( step => { step.GroupName = "UiAngular"; } ) ); }
public static IActivityBuilder AddMigrationAndUpdateDatabaseWorkflow(this IOutcomeBuilder builder) { return(builder .Then <EmptyStep>() .AddConfigureMigrationProjectsWorkflow(ActivityNames.AddMigration) /* Add migration */ .Then <RunCommandStep>( step => step.Command = new JavaScriptExpression <string>("`dotnet ef migrations add Added${EntityInfo.Name} -p \"${MigrationProjectFile}\" -s \"${StartupProjectFile}\"`") ).WithName(ActivityNames.AddMigration) /* Update database */ .Then <RunCommandStep>( step => step.Command = new JavaScriptExpression <string>("`dotnet ef database update -p \"${MigrationProjectFile}\" -s \"${StartupProjectFile}\"`") ) ); }
public static IActivityBuilder AddCustomRepositoryGeneration(this IOutcomeBuilder builder) { return(builder /* Generate custom repository interface and class */ .Then <GroupGenerationStep>( step => { step.GroupName = "Repository"; step.TargetDirectory = new JavaScriptExpression <string>("AspNetCoreDir"); } ) /* Add repository configuration to EntityFrameworkCoreModule */ .Then <FileFinderStep>( step => step.SearchFileName = new LiteralExpression("*EntityFrameworkCoreModule.cs") ) .Then <EntityFrameworkCoreModuleStep>() .Then <FileModifierStep>() ); }
public static IActivityBuilder AddMigrationAndUpdateDatabaseWorkflow(this IOutcomeBuilder builder) { return(builder .Then <IfElse>( ifElse => ifElse.ConditionExpression = new JavaScriptExpression <bool>("Option.MigrationProjectName == null"), ifElse => { ifElse .When(OutcomeNames.True) .Then <SetVariable>( step => { step.VariableName = "AppMigrationProjectName"; step.ValueExpression = new LiteralExpression("*.EntityFrameworkCore.DbMigrations.csproj"); }) .Then <SetVariable>( step => { step.VariableName = "ModuleMigrationProjectName"; step.ValueExpression = new LiteralExpression("*.Web.Unified.csproj"); }) .Then("SearchFiles") ; ifElse .When(OutcomeNames.False) .Then <SetVariable>( step => { step.VariableName = "AppMigrationProjectName"; step.ValueExpression = new JavaScriptExpression <string>("Option.MigrationProjectName"); }) .Then <SetVariable>( step => { step.VariableName = "ModuleMigrationProjectName"; step.ValueExpression = new JavaScriptExpression <string>("Option.MigrationProjectName"); }) .Then("SearchFiles") ; } ) .Then <IfElse>( ifElse => ifElse.ConditionExpression = new JavaScriptExpression <bool>("ProjectInfo.TemplateType == 0"), ifElse => { // Application ifElse .When(OutcomeNames.True) .Then <FileFinderStep>( step => { step.SearchFileName = new JavaScriptExpression <string>("AppMigrationProjectName"); step.ResultVariableName = new LiteralExpression("MigrationProjectFile"); } ) .Then <FileFinderStep>( step => { step.SearchFileName = new LiteralExpression("*.Web.csproj"); step.ResultVariableName = new LiteralExpression <string>("StartupProjectFile"); } ) .Then("RunMigration") ; // Module ifElse .When(OutcomeNames.False) .Then <FileFinderStep>( step => { step.SearchFileName = new JavaScriptExpression <string>("ModuleMigrationProjectName"); step.ResultVariableName = new LiteralExpression("MigrationProjectFile"); } ) .Then <FileFinderStep>( step => { step.SearchFileName = new JavaScriptExpression <string>("ModuleMigrationProjectName"); // For module, the startup project is same with the migration project step.ResultVariableName = new LiteralExpression <string>("StartupProjectFile"); } ) .Then("RunMigration") ; } ).WithName("SearchFiles") /* Add migration */ .Then <RunCommandStep>( step => step.Command = new JavaScriptExpression <string>("`dotnet ef migrations add Added${EntityInfo.Name} -p \"${MigrationProjectFile}\" -s \"${StartupProjectFile}\"`") ).WithName("RunMigration") /* Update database */ .Then <RunCommandStep>( step => step.Command = new JavaScriptExpression <string>("`dotnet ef database update -p \"${MigrationProjectFile}\" -s \"${StartupProjectFile}\"`") ) ); }