Cli: Dsable LeptonX module from add-module command

pull/14249/head
Yunus Emre Kalkan 3 years ago
parent 434c0b07e6
commit 46ae3d65f9

@ -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<AbpCliServiceProxyOptions>(options =>

@ -7,6 +7,8 @@ public class AbpCliOptions
{
public Dictionary<string, Type> Commands { get; }
public List<string> DisabledModulesToAddToSolution { get; set; }
/// <summary>
/// Default value: true.
/// </summary>
@ -20,5 +22,6 @@ public class AbpCliOptions
public AbpCliOptions()
{
Commands = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
DisabledModulesToAddToSolution = new();
}
}

@ -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<AbpCliOptions> options)
{
_options = options.Value;
SolutionModuleAdder = solutionModuleAdder;
SolutionPackageVersionFinder = solutionPackageVersionFinder;
Logger = NullLogger<AddModuleCommand>.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);

Loading…
Cancel
Save