From fcd634caf9eeac605bcacbac1dd3351fa711d073 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 23 Feb 2021 14:30:13 +0300 Subject: [PATCH 1/2] CLI: Create a command to list open-source modules resolves https://github.com/abpframework/abp/issues/3161 --- docs/en/CLI.md | 21 +++++ .../Volo/Abp/Cli/AbpCliCoreModule.cs | 1 + .../Abp/Cli/Commands/ListModulesCommand.cs | 83 +++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ListModulesCommand.cs diff --git a/docs/en/CLI.md b/docs/en/CLI.md index fc76aa997b..d4a33a2a12 100644 --- a/docs/en/CLI.md +++ b/docs/en/CLI.md @@ -31,6 +31,7 @@ Here, the list of all available commands before explaining their details: * **`update`**: Automatically updates all ABP related NuGet and NPM packages in a solution. * **`add-package`**: Adds an ABP package to a project. * **`add-module`**: Adds a [multi-package application module](https://docs.abp.io/en/abp/latest/Modules/Index) to a solution. +* **`list-modules`**: Lists names of open-source application modules. * **`get-source`**: Downloads the source code of a module. * **`generate-proxy`**: Generates client side proxies to use HTTP API endpoints. * **`remove-proxy`**: Removes previously generated client side proxies. @@ -202,6 +203,26 @@ abp add-module ProductManagement --new --add-to-solution-file * `--with-source-code`: Downloads the source code of the module to your solution folder and uses local project references instead of NuGet/NPM packages. This options is always `True` if `--new` is used. * `--add-to-solution-file`: Adds the downloaded/created module to your solution file, so you will also see the projects of the module when you open the solution on a IDE. (only available when `--with-source-code` is `True`.) +### list-modules + +Lists names of open-source application modules. + +Usage + +````bash +abp list-modules [options] +```` + +Example: + +```bash +abp list-modules +``` + +#### Options + +* `--include-pro-modules`: Includes commercial (pro) modules in the output. + ### get-source Downloads the source code of a module to your computer. diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs index 6b23857233..f6afda5809 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs @@ -34,6 +34,7 @@ namespace Volo.Abp.Cli options.Commands["update"] = typeof(UpdateCommand); options.Commands["add-package"] = typeof(AddPackageCommand); options.Commands["add-module"] = typeof(AddModuleCommand); + options.Commands["list-modules"] = typeof(ListModulesCommand); options.Commands["login"] = typeof(LoginCommand); options.Commands["logout"] = typeof(LogoutCommand); options.Commands[GenerateProxyCommand.Name] = typeof(GenerateProxyCommand); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ListModulesCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ListModulesCommand.cs new file mode 100644 index 0000000000..cb05a19031 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ListModulesCommand.cs @@ -0,0 +1,83 @@ +using System; +using System.IO; +using System.Linq; +using System.Text; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using System.Threading.Tasks; +using Volo.Abp.Cli.Args; +using Volo.Abp.Cli.ProjectBuilding; +using Volo.Abp.Cli.ProjectBuilding.Templates.MvcModule; +using Volo.Abp.Cli.ProjectModification; +using Volo.Abp.Cli.Utils; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Cli.Commands +{ + public class ListModulesCommand : IConsoleCommand, ITransientDependency + { + public ModuleInfoProvider ModuleInfoProvider { get; } + public ILogger Logger { get; set; } + + + public ListModulesCommand(ModuleInfoProvider moduleInfoProvider) + { + ModuleInfoProvider = moduleInfoProvider; + Logger = NullLogger.Instance; + } + + public async Task ExecuteAsync(CommandLineArgs commandLineArgs) + { + var modules = await ModuleInfoProvider.GetModuleListAsync(); + var freeModules = modules.Where(m => !m.IsPro).ToList(); + var proModules = modules.Where(m => m.IsPro).ToList(); + + var output = new StringBuilder(Environment.NewLine); + output.AppendLine("Open Source Application Modules"); + output.AppendLine(); + + foreach (var module in freeModules) + { + output.AppendLine($"> {module.DisplayName.PadRight(50)} ({module.Name})"); + } + + if (commandLineArgs.Options.ContainsKey("include-pro-modules")) + { + output.AppendLine(); + output.AppendLine("Commercial (Pro) Application Modules"); + output.AppendLine(); + foreach (var module in proModules) + { + output.AppendLine($"> {module.DisplayName.PadRight(50)} ({module.Name})"); + } + } + + Logger.LogInformation(output.ToString()); + } + + public string GetUsageInfo() + { + var sb = new StringBuilder(); + + sb.AppendLine(""); + sb.AppendLine("'list-modules' command is used for listing open source application modules."); + sb.AppendLine(""); + sb.AppendLine("Usage:"); + sb.AppendLine(" abp list-modules"); + sb.AppendLine(" abp list-modules --include-pro-modules"); + sb.AppendLine(""); + sb.AppendLine("Options:"); + sb.AppendLine(" --include-pro-modules Includes commercial (pro) modules in the output."); + sb.AppendLine(""); + sb.AppendLine("See the documentation for more info: https://docs.abp.io/en/abp/latest/CLI"); + + return sb.ToString(); + } + + public string GetShortDescription() + { + return "List open source application modules"; + } + + } +} From 50319ad7d3274849dfd5debed93f8666bcfa28b0 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 23 Feb 2021 14:32:50 +0300 Subject: [PATCH 2/2] Update ListModulesCommand.cs --- .../Volo/Abp/Cli/Commands/ListModulesCommand.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ListModulesCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ListModulesCommand.cs index cb05a19031..ed201d77d7 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ListModulesCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ListModulesCommand.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using System.Linq; using System.Text; using Microsoft.Extensions.Logging; @@ -7,9 +6,6 @@ using Microsoft.Extensions.Logging.Abstractions; using System.Threading.Tasks; using Volo.Abp.Cli.Args; using Volo.Abp.Cli.ProjectBuilding; -using Volo.Abp.Cli.ProjectBuilding.Templates.MvcModule; -using Volo.Abp.Cli.ProjectModification; -using Volo.Abp.Cli.Utils; using Volo.Abp.DependencyInjection; namespace Volo.Abp.Cli.Commands