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 6eb2784bb2..1cffbfe407 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; } @@ -34,8 +35,9 @@ public class NewCommand : ProjectCreationCommandBase, IConsoleCommand, ITransien IInstallLibsService installLibsService, AngularPwaSupportAdder angularPwaSupportAdder, InitialMigrationCreator initialMigrationCreator, - ThemePackageAdder themePackageAdder) - : base(connectionStringProvider, solutionPackageVersionFinder, cmdHelper, installLibsService, angularPwaSupportAdder, initialMigrationCreator, themePackageAdder) + ThemePackageAdder themePackageAdder, + ILocalEventBus eventBus) + : base(connectionStringProvider, solutionPackageVersionFinder, cmdHelper, installLibsService, angularPwaSupportAdder, initialMigrationCreator, themePackageAdder, eventBus) { TemplateProjectBuilder = templateProjectBuilder; TemplateInfoProvider = templateInfoProvider; @@ -81,10 +83,10 @@ public class NewCommand : ProjectCreationCommandBase, IConsoleCommand, ITransien Logger.LogInformation($"'{projectName}' has been successfully created to '{projectArgs.OutputFolder}'"); ConfigureNpmPackagesForTheme(projectArgs); - 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 c422646337..42a2fd72cb 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 @@ -14,10 +14,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; @@ -29,6 +31,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 ThemePackageAdder ThemePackageAdder { get; } @@ -40,7 +43,8 @@ public abstract class ProjectCreationCommandBase IInstallLibsService installLibsService, AngularPwaSupportAdder angularPwaSupportAdder, InitialMigrationCreator initialMigrationCreator, - ThemePackageAdder themePackageAdder) + ThemePackageAdder themePackageAdder, + ILocalEventBus eventBus) { ConnectionStringProvider = connectionStringProvider; SolutionPackageVersionFinder = solutionPackageVersionFinder; @@ -48,6 +52,7 @@ public abstract class ProjectCreationCommandBase InstallLibsService = installLibsService; AngularPwaSupportAdder = angularPwaSupportAdder; InitialMigrationCreator = initialMigrationCreator; + EventBus = eventBus; ThemePackageAdder = themePackageAdder; Logger = NullLogger.Instance; @@ -201,6 +206,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)) @@ -332,10 +341,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); } } @@ -348,6 +361,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); } } @@ -384,10 +402,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; @@ -395,6 +417,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..bc071a4288 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; @@ -54,6 +59,10 @@ public class TemplateProjectBuilder : IProjectBuilder, ITransientDependency NormalizeArgs(args, templateInfo); + await EventBus.PublishAsync(new ProjectCreationProgressEvent { + Message = "Fetching the solution template" + }, false); + var templateFile = await SourceCodeStore.GetAsync( args.TemplateName, SourceCodeTypes.Template, @@ -116,7 +125,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())