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 7aba9ae849..fefa8552b3 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 @@ -66,6 +66,9 @@ public class AbpCliCoreModule : AbpModule options.Commands[InstallLibsCommand.Name] = typeof(InstallLibsCommand); options.Commands[CleanCommand.Name] = typeof(CleanCommand); options.Commands[CliCommand.Name] = typeof(CliCommand); + + options.DisabledModulesToAddToSolution.Add("Volo.Abp.LeptonXTheme.Pro"); + options.DisabledModulesToAddToSolution.Add("Volo.Abp.LeptonXTheme.Lite"); }); Configure(options => diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliOptions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliOptions.cs index 62a7e59d8e..cf84dd12d4 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliOptions.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliOptions.cs @@ -7,6 +7,8 @@ public class AbpCliOptions { public Dictionary Commands { get; } + public List DisabledModulesToAddToSolution { get; set; } + /// /// Default value: true. /// @@ -20,5 +22,6 @@ public class AbpCliOptions public AbpCliOptions() { Commands = new Dictionary(StringComparer.OrdinalIgnoreCase); + DisabledModulesToAddToSolution = new(); } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs index df81fe4cb7..5a5589e7c5 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs @@ -4,6 +4,7 @@ using System.Text; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using System.Threading.Tasks; +using Microsoft.Extensions.Options; using Volo.Abp.Cli.Args; using Volo.Abp.Cli.ProjectBuilding.Templates.MvcModule; using Volo.Abp.Cli.ProjectModification; @@ -14,6 +15,7 @@ namespace Volo.Abp.Cli.Commands; public class AddModuleCommand : IConsoleCommand, ITransientDependency { + private readonly AbpCliOptions _options; public const string Name = "add-module"; private AddModuleInfoOutput _lastAddedModuleInfo; @@ -33,8 +35,12 @@ public class AddModuleCommand : IConsoleCommand, ITransientDependency } } - public AddModuleCommand(SolutionModuleAdder solutionModuleAdder, SolutionPackageVersionFinder solutionPackageVersionFinder) + public AddModuleCommand( + SolutionModuleAdder solutionModuleAdder, + SolutionPackageVersionFinder solutionPackageVersionFinder, + IOptions options) { + _options = options.Value; SolutionModuleAdder = solutionModuleAdder; SolutionPackageVersionFinder = solutionPackageVersionFinder; Logger = NullLogger.Instance; @@ -50,6 +56,13 @@ public class AddModuleCommand : IConsoleCommand, ITransientDependency GetUsageInfo() ); } + + if (_options.DisabledModulesToAddToSolution.Contains(commandLineArgs.Target)) + { + throw new CliUsageException( + $"{commandLineArgs.Target} Module is not available for this command! You can check the module's documentation for more info." + ); + } var newTemplate = commandLineArgs.Options.ContainsKey(Options.NewTemplate.Long); var template = commandLineArgs.Options.GetOrNull(Options.Template.Short, Options.Template.Long);