Browse Source

Merge pull request #14249 from abpframework/cli-leptonx-fixes

Cli: Enahncement related with LeptonX
pull/14255/head
Alper Ebiçoğlu 4 years ago
committed by GitHub
parent
commit
11d35d5498
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs
  2. 3
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliOptions.cs
  3. 15
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs
  4. 11
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ProjectReferenceReplaceStep.cs

3
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[InstallLibsCommand.Name] = typeof(InstallLibsCommand);
options.Commands[CleanCommand.Name] = typeof(CleanCommand); options.Commands[CleanCommand.Name] = typeof(CleanCommand);
options.Commands[CliCommand.Name] = typeof(CliCommand); options.Commands[CliCommand.Name] = typeof(CliCommand);
options.DisabledModulesToAddToSolution.Add("Volo.Abp.LeptonXTheme.Pro");
options.DisabledModulesToAddToSolution.Add("Volo.Abp.LeptonXTheme.Lite");
}); });
Configure<AbpCliServiceProxyOptions>(options => Configure<AbpCliServiceProxyOptions>(options =>

3
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliOptions.cs

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

15
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;
using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Abstractions;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Volo.Abp.Cli.Args; using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.ProjectBuilding.Templates.MvcModule; using Volo.Abp.Cli.ProjectBuilding.Templates.MvcModule;
using Volo.Abp.Cli.ProjectModification; using Volo.Abp.Cli.ProjectModification;
@ -14,6 +15,7 @@ namespace Volo.Abp.Cli.Commands;
public class AddModuleCommand : IConsoleCommand, ITransientDependency public class AddModuleCommand : IConsoleCommand, ITransientDependency
{ {
private readonly AbpCliOptions _options;
public const string Name = "add-module"; public const string Name = "add-module";
private AddModuleInfoOutput _lastAddedModuleInfo; 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; SolutionModuleAdder = solutionModuleAdder;
SolutionPackageVersionFinder = solutionPackageVersionFinder; SolutionPackageVersionFinder = solutionPackageVersionFinder;
Logger = NullLogger<AddModuleCommand>.Instance; Logger = NullLogger<AddModuleCommand>.Instance;
@ -50,6 +56,13 @@ public class AddModuleCommand : IConsoleCommand, ITransientDependency
GetUsageInfo() 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 newTemplate = commandLineArgs.Options.ContainsKey(Options.NewTemplate.Long);
var template = commandLineArgs.Options.GetOrNull(Options.Template.Short, Options.Template.Long); var template = commandLineArgs.Options.GetOrNull(Options.Template.Short, Options.Template.Long);

11
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ProjectReferenceReplaceStep.cs

@ -117,12 +117,13 @@ public class ProjectReferenceReplaceStep : ProjectBuildPipelineStep
var oldNodeIncludeValue = oldNode.Attributes["Include"].Value; var oldNodeIncludeValue = oldNode.Attributes["Include"].Value;
// ReSharper disable once PossibleNullReferenceException : Can not be null because nodes are selected with include attribute filter in previous method // ReSharper disable once PossibleNullReferenceException : Can not be null because nodes are selected with include attribute filter in previous method
if (oldNodeIncludeValue.Contains(_projectName)) if (oldNodeIncludeValue.Contains(_projectName) && _isMicroserviceServiceTemplate)
{ {
if (_isMicroserviceServiceTemplate || _entries.Any(e => e.Name.EndsWith(GetProjectNameWithExtensionFromProjectReference(oldNodeIncludeValue)))) continue;
{ }
continue; if(_entries.Any(e => e.Name.EndsWith(GetProjectNameWithExtensionFromProjectReference(oldNodeIncludeValue))))
} {
continue;
} }
XmlNode newNode = GetNewReferenceNode(doc, oldNodeIncludeValue); XmlNode newNode = GetNewReferenceNode(doc, oldNodeIncludeValue);

Loading…
Cancel
Save