diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs index ebad70ce76..aac5ce860c 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs @@ -16,13 +16,14 @@ using Volo.Abp.Cli.ProjectBuilding.Building; using Volo.Abp.Cli.ProjectModification; using Volo.Abp.Cli.Utils; using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus.Local; namespace Volo.Abp.Cli.Commands; public class NewCommand : ProjectCreationCommandBase, IConsoleCommand, ITransientDependency { public const string Name = "new"; - + protected TemplateProjectBuilder TemplateProjectBuilder { get; } public ITemplateInfoProvider TemplateInfoProvider { get; } @@ -33,8 +34,9 @@ public class NewCommand : ProjectCreationCommandBase, IConsoleCommand, ITransien ICmdHelper cmdHelper, IInstallLibsService installLibsService, AngularPwaSupportAdder angularPwaSupportAdder, - InitialMigrationCreator ınitialMigrationCreator) - : base(connectionStringProvider, solutionPackageVersionFinder, cmdHelper, installLibsService, angularPwaSupportAdder, ınitialMigrationCreator) + InitialMigrationCreator ınitialMigrationCreator, + ILocalEventBus eventBus) + : base(connectionStringProvider, solutionPackageVersionFinder, cmdHelper, installLibsService, angularPwaSupportAdder, ınitialMigrationCreator, eventBus) { TemplateProjectBuilder = templateProjectBuilder; TemplateInfoProvider = templateInfoProvider; @@ -79,10 +81,10 @@ public class NewCommand : ProjectCreationCommandBase, IConsoleCommand, ITransien Logger.LogInformation($"'{projectName}' has been successfully created to '{projectArgs.OutputFolder}'"); - RunGraphBuildForMicroserviceServiceTemplate(projectArgs); + await RunGraphBuildForMicroserviceServiceTemplate(projectArgs); await CreateInitialMigrationsAsync(projectArgs); await RunInstallLibsForWebTemplateAsync(projectArgs); - ConfigurePwaSupportForAngular(projectArgs); + await ConfigurePwaSupportForAngular(projectArgs); OpenRelatedWebPage(projectArgs, template, isTiered, commandLineArgs); } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs index 07741779b1..8ef7bcb7e1 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs @@ -13,10 +13,12 @@ using Volo.Abp.Cli.Commands.Services; using Volo.Abp.Cli.LIbs; using Volo.Abp.Cli.ProjectBuilding; using Volo.Abp.Cli.ProjectBuilding.Building; +using Volo.Abp.Cli.ProjectBuilding.Events; using Volo.Abp.Cli.ProjectBuilding.Templates.App; using Volo.Abp.Cli.ProjectBuilding.Templates.Microservice; using Volo.Abp.Cli.ProjectBuilding.Templates.Module; using Volo.Abp.Cli.Utils; +using Volo.Abp.EventBus.Local; namespace Volo.Abp.Cli.Commands; @@ -28,6 +30,7 @@ public abstract class ProjectCreationCommandBase public IInstallLibsService InstallLibsService { get; } public AngularPwaSupportAdder AngularPwaSupportAdder { get; } public InitialMigrationCreator InitialMigrationCreator { get; } + public ILocalEventBus EventBus { get; } public ILogger Logger { get; set; } public ProjectCreationCommandBase( @@ -36,7 +39,8 @@ public abstract class ProjectCreationCommandBase ICmdHelper cmdHelper, IInstallLibsService installLibsService, AngularPwaSupportAdder angularPwaSupportAdder, - InitialMigrationCreator initialMigrationCreator) + InitialMigrationCreator initialMigrationCreator, + ILocalEventBus eventBus) { ConnectionStringProvider = connectionStringProvider; SolutionPackageVersionFinder = solutionPackageVersionFinder; @@ -44,6 +48,7 @@ public abstract class ProjectCreationCommandBase InstallLibsService = installLibsService; AngularPwaSupportAdder = angularPwaSupportAdder; InitialMigrationCreator = initialMigrationCreator; + EventBus = eventBus; Logger = NullLogger.Instance; } @@ -190,6 +195,10 @@ public abstract class ProjectCreationCommandBase protected void ExtractProjectZip(ProjectBuildResult project, string outputFolder) { + EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Extracting solution to file system" + }, false); + using (var templateFileStream = new MemoryStream(project.ZipContent)) { using (var zipInputStream = new ZipInputStream(templateFileStream)) @@ -321,10 +330,14 @@ public abstract class ProjectCreationCommandBase throw new CliUsageException("The option you provided for Database Provider is invalid!"); } - protected virtual void RunGraphBuildForMicroserviceServiceTemplate(ProjectBuildArgs projectArgs) + protected virtual async Task RunGraphBuildForMicroserviceServiceTemplate(ProjectBuildArgs projectArgs) { if (MicroserviceServiceTemplateBase.IsMicroserviceServiceTemplate(projectArgs.TemplateName)) { + await EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Building the microservice solution" + }, false); + CmdHelper.RunCmd("dotnet build /graphbuild", projectArgs.OutputFolder); } } @@ -337,6 +350,11 @@ public abstract class ProjectCreationCommandBase MicroserviceServiceTemplateBase.IsMicroserviceTemplate(projectArgs.TemplateName)) { Logger.LogInformation("Installing client-side packages..."); + + await EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Installing client-side packages" + }, false); + await InstallLibsService.InstallLibsAsync(projectArgs.OutputFolder); } } @@ -373,10 +391,14 @@ public abstract class ProjectCreationCommandBase return; } + await EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Creating the initial migration" + }, false); + await InitialMigrationCreator.CreateAsync(Path.GetDirectoryName(efCoreProjectPath), isLayeredTemplate); } - protected void ConfigurePwaSupportForAngular(ProjectBuildArgs projectArgs) + protected async Task ConfigurePwaSupportForAngular(ProjectBuildArgs projectArgs) { var isAngular = projectArgs.UiFramework == UiFramework.Angular; var isPwa = projectArgs.Pwa; @@ -384,6 +406,7 @@ public abstract class ProjectCreationCommandBase if (isAngular && isPwa) { Logger.LogInformation("Adding PWA Support to Angular app."); + AngularPwaSupportAdder.AddPwaSupport(projectArgs.OutputFolder); } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Events/ProjectCreationProgressEvent.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Events/ProjectCreationProgressEvent.cs new file mode 100644 index 0000000000..24c424f4cb --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Events/ProjectCreationProgressEvent.cs @@ -0,0 +1,6 @@ +namespace Volo.Abp.Cli.ProjectBuilding.Events; + +public class ProjectCreationProgressEvent +{ + public string Message { get; set; } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs index 5743a423c0..db430296fa 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs @@ -10,8 +10,10 @@ using Volo.Abp.Cli.Commands; using Volo.Abp.Cli.Licensing; using Volo.Abp.Cli.ProjectBuilding.Analyticses; using Volo.Abp.Cli.ProjectBuilding.Building; +using Volo.Abp.Cli.ProjectBuilding.Events; using Volo.Abp.Cli.ProjectBuilding.Templates.App; using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus.Local; using Volo.Abp.Json; namespace Volo.Abp.Cli.ProjectBuilding; @@ -26,6 +28,7 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency protected AbpCliOptions Options { get; } protected IJsonSerializer JsonSerializer { get; } protected IApiKeyService ApiKeyService { get; } + protected ILocalEventBus EventBus { get; } private readonly IConfiguration _configuration; @@ -35,7 +38,8 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency IOptions options, IJsonSerializer jsonSerializer, IApiKeyService apiKeyService, - IConfiguration configuration) + IConfiguration configuration, + ILocalEventBus eventBus) { SourceCodeStore = sourceCodeStore; TemplateInfoProvider = templateInfoProvider; @@ -43,6 +47,7 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency Options = options.Value; JsonSerializer = jsonSerializer; ApiKeyService = apiKeyService; + EventBus = eventBus; _configuration = configuration; Logger = NullLogger.Instance; @@ -116,7 +121,11 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency { appTemplateBase.HasDbMigrations = SemanticVersion.Parse(templateFile.Version) < new SemanticVersion(4, 3, 99); } - + + await EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Preparing the solution according to preferences" + }, false); + TemplateProjectBuildPipelineBuilder.Build(context).Execute(); if (!templateInfo.DocumentUrl.IsNullOrEmpty())