Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development remove all from bump #68

Merged
merged 2 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
}
94 changes: 35 additions & 59 deletions docs/cmf/Cmf_Common_Cli_Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,63 +208,55 @@ public override void Configure(System.CommandLine.Command cmd);
`cmd` [System.CommandLine.Command](https://docs.microsoft.com/en-us/dotnet/api/System.CommandLine.Command 'System.CommandLine.Command')


<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_string_string_string_bool)'></a>
## BumpCommand.Execute(CmfPackage, string, string, string, bool) Method
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_string_string_string)'></a>
## BumpCommand.Execute(CmfPackage, string, string, string) Method
Executes the specified CMF package.
```csharp
public void Execute(Cmf.Common.Cli.Objects.CmfPackage cmfPackage, string version, string buildNr, string root, bool all);
public void Execute(Cmf.Common.Cli.Objects.CmfPackage cmfPackage, string version, string buildNr, string root);
```
#### Parameters
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_string_string_string_bool)_cmfPackage'></a>
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_string_string_string)_cmfPackage'></a>
`cmfPackage` [CmfPackage](Cmf_Common_Cli_Objects.md#Cmf_Common_Cli_Objects_CmfPackage 'Cmf.Common.Cli.Objects.CmfPackage')
The CMF package.

<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_string_string_string_bool)_version'></a>
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_string_string_string)_version'></a>
`version` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String')
The version.

<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_string_string_string_bool)_buildNr'></a>
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_string_string_string)_buildNr'></a>
`buildNr` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String')
The version for build Nr.

<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_string_string_string_bool)_root'></a>
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_string_string_string)_root'></a>
`root` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String')
The root.

<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_string_string_string_bool)_all'></a>
`all` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')
if set to `true` [all].

#### Exceptions
[CliException](Cmf_Common_Cli_Utilities.md#Cmf_Common_Cli_Utilities_CliException 'Cmf.Common.Cli.Utilities.CliException')

<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(System_IO_DirectoryInfo_string_string_string_bool)'></a>
## BumpCommand.Execute(DirectoryInfo, string, string, string, bool) Method
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(System_IO_DirectoryInfo_string_string_string)'></a>
## BumpCommand.Execute(DirectoryInfo, string, string, string) Method
Executes the specified package path.
```csharp
public void Execute(System.IO.DirectoryInfo packagePath, string version, string buildNr, string root, bool all);
public void Execute(System.IO.DirectoryInfo packagePath, string version, string buildNr, string root);
```
#### Parameters
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(System_IO_DirectoryInfo_string_string_string_bool)_packagePath'></a>
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(System_IO_DirectoryInfo_string_string_string)_packagePath'></a>
`packagePath` [System.IO.DirectoryInfo](https://docs.microsoft.com/en-us/dotnet/api/System.IO.DirectoryInfo 'System.IO.DirectoryInfo')
The package path.

<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(System_IO_DirectoryInfo_string_string_string_bool)_version'></a>
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(System_IO_DirectoryInfo_string_string_string)_version'></a>
`version` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String')
The version.

<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(System_IO_DirectoryInfo_string_string_string_bool)_buildNr'></a>
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(System_IO_DirectoryInfo_string_string_string)_buildNr'></a>
`buildNr` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String')
The version for build Nr.

<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(System_IO_DirectoryInfo_string_string_string_bool)_root'></a>
<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(System_IO_DirectoryInfo_string_string_string)_root'></a>
`root` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String')
The root.

<a name='Cmf_Common_Cli_Commands_BumpCommand_Execute(System_IO_DirectoryInfo_string_string_string_bool)_all'></a>
`all` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')
if set to `true` [all].

#### Exceptions
[CliException](Cmf_Common_Cli_Utilities.md#Cmf_Common_Cli_Utilities_CliException 'Cmf.Common.Cli.Utilities.CliException')
[CliException](Cmf_Common_Cli_Utilities.md#Cmf_Common_Cli_Utilities_CliException 'Cmf.Common.Cli.Utilities.CliException')
Expand Down Expand Up @@ -850,18 +842,20 @@ public override void Configure(System.CommandLine.Command cmd);
`cmd` [System.CommandLine.Command](https://docs.microsoft.com/en-us/dotnet/api/System.CommandLine.Command 'System.CommandLine.Command')


<a name='Cmf_Common_Cli_Commands_ListDependenciesCommand_Execute(System_IO_Abstractions_IDirectoryInfo_string)'></a>
## ListDependenciesCommand.Execute(IDirectoryInfo, string) Method
Execute the command
<a name='Cmf_Common_Cli_Commands_ListDependenciesCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_Uri__)'></a>
## ListDependenciesCommand.Execute(IDirectoryInfo, Uri[]) Method
Determine and print a package dependency tree
```csharp
public void Execute(System.IO.Abstractions.IDirectoryInfo workingDir, string repo);
public void Execute(System.IO.Abstractions.IDirectoryInfo workingDir, System.Uri[] repos);
```
#### Parameters
<a name='Cmf_Common_Cli_Commands_ListDependenciesCommand_Execute(System_IO_Abstractions_IDirectoryInfo_string)_workingDir'></a>
<a name='Cmf_Common_Cli_Commands_ListDependenciesCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_Uri__)_workingDir'></a>
`workingDir` [System.IO.Abstractions.IDirectoryInfo](https://docs.microsoft.com/en-us/dotnet/api/System.IO.Abstractions.IDirectoryInfo 'System.IO.Abstractions.IDirectoryInfo')
the path of the package which dependency tree we want to obtain

<a name='Cmf_Common_Cli_Commands_ListDependenciesCommand_Execute(System_IO_Abstractions_IDirectoryInfo_string)_repo'></a>
`repo` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String')
<a name='Cmf_Common_Cli_Commands_ListDependenciesCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_Uri__)_repos'></a>
`repos` [System.Uri](https://docs.microsoft.com/en-us/dotnet/api/System.Uri 'System.Uri')[[]](https://docs.microsoft.com/en-us/dotnet/api/System.Array 'System.Array')
a set of repositories for remote packages



Expand Down Expand Up @@ -1008,65 +1002,47 @@ public override void Configure(System.CommandLine.Command cmd);
`cmd` [System.CommandLine.Command](https://docs.microsoft.com/en-us/dotnet/api/System.CommandLine.Command 'System.CommandLine.Command')


<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_System_IO_Abstractions_IDirectoryInfo_System_Uri_Cmf_Common_Cli_Objects_CmfPackageCollection_bool_bool)'></a>
## PackCommand.Execute(CmfPackage, IDirectoryInfo, Uri, CmfPackageCollection, bool, bool) Method
<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_System_IO_Abstractions_IDirectoryInfo_bool)'></a>
## PackCommand.Execute(CmfPackage, IDirectoryInfo, bool) Method
Executes the specified CMF package.
```csharp
public void Execute(Cmf.Common.Cli.Objects.CmfPackage cmfPackage, System.IO.Abstractions.IDirectoryInfo outputDir, System.Uri repoUri, Cmf.Common.Cli.Objects.CmfPackageCollection loadedPackages, bool force, bool skipDependencies);
public void Execute(Cmf.Common.Cli.Objects.CmfPackage cmfPackage, System.IO.Abstractions.IDirectoryInfo outputDir, bool force);
```
#### Parameters
<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_System_IO_Abstractions_IDirectoryInfo_System_Uri_Cmf_Common_Cli_Objects_CmfPackageCollection_bool_bool)_cmfPackage'></a>
<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_System_IO_Abstractions_IDirectoryInfo_bool)_cmfPackage'></a>
`cmfPackage` [CmfPackage](Cmf_Common_Cli_Objects.md#Cmf_Common_Cli_Objects_CmfPackage 'Cmf.Common.Cli.Objects.CmfPackage')
The CMF package.

<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_System_IO_Abstractions_IDirectoryInfo_System_Uri_Cmf_Common_Cli_Objects_CmfPackageCollection_bool_bool)_outputDir'></a>
<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_System_IO_Abstractions_IDirectoryInfo_bool)_outputDir'></a>
`outputDir` [System.IO.Abstractions.IDirectoryInfo](https://docs.microsoft.com/en-us/dotnet/api/System.IO.Abstractions.IDirectoryInfo 'System.IO.Abstractions.IDirectoryInfo')
The output dir.

<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_System_IO_Abstractions_IDirectoryInfo_System_Uri_Cmf_Common_Cli_Objects_CmfPackageCollection_bool_bool)_repoUri'></a>
`repoUri` [System.Uri](https://docs.microsoft.com/en-us/dotnet/api/System.Uri 'System.Uri')
The repo URI.

<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_System_IO_Abstractions_IDirectoryInfo_System_Uri_Cmf_Common_Cli_Objects_CmfPackageCollection_bool_bool)_loadedPackages'></a>
`loadedPackages` [CmfPackageCollection](Cmf_Common_Cli_Objects.md#Cmf_Common_Cli_Objects_CmfPackageCollection 'Cmf.Common.Cli.Objects.CmfPackageCollection')
The loaded packages.

<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_System_IO_Abstractions_IDirectoryInfo_System_Uri_Cmf_Common_Cli_Objects_CmfPackageCollection_bool_bool)_force'></a>
<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_System_IO_Abstractions_IDirectoryInfo_bool)_force'></a>
`force` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')
if set to `true` [force].

<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(Cmf_Common_Cli_Objects_CmfPackage_System_IO_Abstractions_IDirectoryInfo_System_Uri_Cmf_Common_Cli_Objects_CmfPackageCollection_bool_bool)_skipDependencies'></a>
`skipDependencies` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')

#### Exceptions
[CmfPackageCollection](Cmf_Common_Cli_Objects.md#Cmf_Common_Cli_Objects_CmfPackageCollection 'Cmf.Common.Cli.Objects.CmfPackageCollection')

<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_IO_Abstractions_IDirectoryInfo_string_bool_bool)'></a>
## PackCommand.Execute(IDirectoryInfo, IDirectoryInfo, string, bool, bool) Method
<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_IO_Abstractions_IDirectoryInfo_bool)'></a>
## PackCommand.Execute(IDirectoryInfo, IDirectoryInfo, bool) Method
Executes the specified working dir.
```csharp
public void Execute(System.IO.Abstractions.IDirectoryInfo workingDir, System.IO.Abstractions.IDirectoryInfo outputDir, string repo, bool force, bool skipDependencies);
public void Execute(System.IO.Abstractions.IDirectoryInfo workingDir, System.IO.Abstractions.IDirectoryInfo outputDir, bool force);
```
#### Parameters
<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_IO_Abstractions_IDirectoryInfo_string_bool_bool)_workingDir'></a>
<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_IO_Abstractions_IDirectoryInfo_bool)_workingDir'></a>
`workingDir` [System.IO.Abstractions.IDirectoryInfo](https://docs.microsoft.com/en-us/dotnet/api/System.IO.Abstractions.IDirectoryInfo 'System.IO.Abstractions.IDirectoryInfo')
The working dir.

<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_IO_Abstractions_IDirectoryInfo_string_bool_bool)_outputDir'></a>
<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_IO_Abstractions_IDirectoryInfo_bool)_outputDir'></a>
`outputDir` [System.IO.Abstractions.IDirectoryInfo](https://docs.microsoft.com/en-us/dotnet/api/System.IO.Abstractions.IDirectoryInfo 'System.IO.Abstractions.IDirectoryInfo')
The output dir.

<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_IO_Abstractions_IDirectoryInfo_string_bool_bool)_repo'></a>
`repo` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String')
The repo.

<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_IO_Abstractions_IDirectoryInfo_string_bool_bool)_force'></a>
<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_IO_Abstractions_IDirectoryInfo_bool)_force'></a>
`force` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')
if set to `true` [force].

<a name='Cmf_Common_Cli_Commands_PackCommand_Execute(System_IO_Abstractions_IDirectoryInfo_System_IO_Abstractions_IDirectoryInfo_string_bool_bool)_skipDependencies'></a>
`skipDependencies` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean')


#### See Also
- [BaseCommand](Cmf_Common_Cli_Commands.md#Cmf_Common_Cli_Commands_BaseCommand 'Cmf.Common.Cli.Commands.BaseCommand')
Expand Down
Loading