Skip to content

Commit

Permalink
chore: remove all from bump
Browse files Browse the repository at this point in the history
  • Loading branch information
jroque committed Nov 10, 2021
1 parent fd06aeb commit 120040e
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 239 deletions.
73 changes: 8 additions & 65 deletions cmf-cli/Commands/bump/BumpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using System.CommandLine;
using System.CommandLine.Invocation;
using System.IO;
using System.IO.Abstractions;

using System.IO.Abstractions;

namespace Cmf.Common.Cli.Commands
{
/// <summary>
Expand Down Expand Up @@ -42,12 +42,8 @@ public override void Configure(Command cmd)
aliases: new string[] { "-r", "--root" },
description: "Will bump only versions under a specific root folder (i.e. 1.0.0)"));

cmd.AddOption(new Option<bool>(
aliases: new string[] { "-a", "--all" },
description: "Will bump all versions beneath where the command is run"));

// Add the handler
cmd.Handler = CommandHandler.Create<DirectoryInfo, string, string, string, bool>(Execute);
cmd.Handler = CommandHandler.Create<DirectoryInfo, string, string, string>(Execute);
}

/// <summary>
Expand All @@ -60,7 +56,7 @@ public override void Configure(Command cmd)
/// <param name="all">if set to <c>true</c> [all].</param>
/// <exception cref="Cmf.Common.Cli.Utilities.CliException"></exception>
/// <exception cref="CliException"></exception>
public void Execute(DirectoryInfo packagePath, string version, string buildNr, string root, bool all)
public void Execute(DirectoryInfo packagePath, string version, string buildNr, string root)
{
IFileInfo cmfpackageFile = this.fileSystem.FileInfo.FromFileName($"{packagePath}/{CliConstants.CmfPackageFileName}");

Expand All @@ -72,7 +68,7 @@ public void Execute(DirectoryInfo packagePath, string version, string buildNr, s
// Reading cmfPackage
CmfPackage cmfPackage = CmfPackage.Load(cmfpackageFile);

Execute(cmfPackage, version, buildNr, root, all);
Execute(cmfPackage, version, buildNr, root);
}

/// <summary>
Expand All @@ -84,7 +80,7 @@ public void Execute(DirectoryInfo packagePath, string version, string buildNr, s
/// <param name="root">The root.</param>
/// <param name="all">if set to <c>true</c> [all].</param>
/// <exception cref="CliException"></exception>
public void Execute(CmfPackage cmfPackage, string version, string buildNr, string root, bool all)
public void Execute(CmfPackage cmfPackage, string version, string buildNr, string root)
{
IDirectoryInfo packageDirectory = cmfPackage.GetFileInfo().Directory;
IPackageTypeHandler packageTypeHandler = PackageTypeFactory.GetPackageTypeHandler(cmfPackage);
Expand All @@ -97,61 +93,8 @@ public void Execute(CmfPackage cmfPackage, string version, string buildNr, strin

packageTypeHandler.Bump(version, buildNr, bumpInformation);

#region Get Dependencies

CmfPackageCollection packagePathCmfPackages = new CmfPackageCollection();
if (all && (cmfPackage.Dependencies.HasAny() || cmfPackage.TestPackages.HasAny()))
{
// Read all local manifests
packagePathCmfPackages = packageDirectory.LoadCmfPackagesFromSubDirectories();
}

if (all && cmfPackage.Dependencies.HasAny())
{
foreach (var dependency in cmfPackage.Dependencies)
{
CmfPackage subCmfPackageWithDependency = packagePathCmfPackages.GetDependency(dependency);

// TODO :: Uncomment if the cmfpackage.json support build number
// dependency.Version = GenericUtilities.RetrieveNewVersion(dependency.Version, version, buildNr);

if (subCmfPackageWithDependency != null)
{
Execute(subCmfPackageWithDependency, version, buildNr, root, all);
dependency.Version = !string.IsNullOrWhiteSpace(version) ? version : dependency.Version;
}
else
{
Log.Warning($"Dependency {dependency.Id}.{dependency.Version} not found");
}
}
}

if (all && cmfPackage.TestPackages.HasAny())
{
foreach (var dependency in cmfPackage.TestPackages)
{
CmfPackage subCmfPackageWithDependency = packagePathCmfPackages.GetDependency(dependency);

// TODO :: Uncomment if the cmfpackage.json support build number
// dependency.Version = GenericUtilities.RetrieveNewVersion(dependency.Version, version, buildNr);

if (subCmfPackageWithDependency != null)
{
Execute(subCmfPackageWithDependency, version, buildNr, root, all);
dependency.Version = !string.IsNullOrWhiteSpace(version) ? version : dependency.Version;
}
else
{
Log.Warning($"Dependency {dependency.Id}.{dependency.Version} not found");
}
}
}

// will save with new version
cmfPackage.SaveCmfPackage();

#endregion
// will save with new version
cmfPackage.SaveCmfPackage();
}
}
}
Loading

0 comments on commit 120040e

Please sign in to comment.