Browse Source

Merge pull request #8696 from abpframework/volo/issues/6308

cli: Added min-max version for NpmPackageInfo
pull/8720/head
Alper Ebicoglu 6 years ago
committed by GitHub
parent
commit
688638b035
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackageInfo.cs
  2. 13
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs

6
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackageInfo.cs

@ -5,5 +5,9 @@
public string Name { get; set; } public string Name { get; set; }
public NpmApplicationType ApplicationType { get; set; } public NpmApplicationType ApplicationType { get; set; }
public string MinVersion { get; set; }
public string MaxVersion { get; set; }
} }
} }

13
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs

@ -135,24 +135,25 @@ namespace Volo.Abp.Cli.ProjectModification
private ModuleWithMastersInfo RemoveIncompatiblePackages(ModuleWithMastersInfo module, string version) private ModuleWithMastersInfo RemoveIncompatiblePackages(ModuleWithMastersInfo module, string version)
{ {
module.NugetPackages.RemoveAll(np => IsPackageInCompatible(np, version)); module.NugetPackages.RemoveAll(np => IsPackageInCompatible(np.MinVersion, np.MaxVersion, version));
module.NpmPackages.RemoveAll(np => IsPackageInCompatible(np.MinVersion, np.MaxVersion, version));
return module; return module;
} }
private bool IsPackageInCompatible(NugetPackageInfo package, string version) private bool IsPackageInCompatible(string minVersion, string maxVersion, string version)
{ {
try try
{ {
if (!string.IsNullOrWhiteSpace(package.MinVersion)) if (!string.IsNullOrWhiteSpace(minVersion))
{ {
if (SemanticVersion.Parse(package.MinVersion) > SemanticVersion.Parse(version)) if (SemanticVersion.Parse(minVersion) > SemanticVersion.Parse(version))
{ {
return true; return true;
} }
} }
if (!string.IsNullOrWhiteSpace(package.MaxVersion)) if (!string.IsNullOrWhiteSpace(maxVersion))
{ {
if (SemanticVersion.Parse(package.MaxVersion) < SemanticVersion.Parse(version)) if (SemanticVersion.Parse(maxVersion) < SemanticVersion.Parse(version))
{ {
return true; return true;
} }

Loading…
Cancel
Save