Skip to content
Open
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
9 changes: 9 additions & 0 deletions cmf-cli/CliMessages.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions cmf-cli/CliMessages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@
<value>Missing mandatory property {0}</value>
<comment>0 - Property name</comment>
</data>
<data name="MutuallyExclusiveProperties" xml:space="preserve">
<value>Mutually exclusive properties: {0}</value>
<comment>0 - List of properties</comment>
</data>
<data name="NotARootPackage" xml:space="preserve">
<value>This is not a root package</value>
</data>
Expand Down
26 changes: 19 additions & 7 deletions cmf-cli/Commands/bump/BumpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ public override void Configure(Command cmd)
cmd.AddOption(new Option<string>(
aliases: new string[] { "-b", "--buildNr" },
description: "Will add this version next to the version (v-b)"));

cmd.AddOption(new Option<string>(
aliases: new string[] { "-p", "--preRelease" },
description: "Will add this version as pre-release version (v-p)"));

cmd.AddOption(new Option<string>(
aliases: new string[] { "-r", "--root" },
description: "Will bump only versions under a specific root folder (i.e. 1.0.0)"));

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

/// <summary>
Expand All @@ -55,20 +59,26 @@ public override void Configure(Command cmd)
/// <param name="buildNr">The version for build Nr.</param>
/// <param name="root">The root.</param>
/// <exception cref="CliException"></exception>
public void Execute(DirectoryInfo packagePath, string version, string buildNr, string root)
/// <exception cref="CliException"></exception>
public void Execute(DirectoryInfo packagePath, string version, string buildNr, string preRelease, string root)
{
using var activity = ExecutionContext.ServiceProvider?.GetService<ITelemetryService>()?.StartExtendedActivity(this.GetType().Name);
IFileInfo cmfpackageFile = this.fileSystem.FileInfo.New($"{packagePath}/{CliConstants.CmfPackageFileName}");

if (string.IsNullOrEmpty(version) && string.IsNullOrEmpty(buildNr))
if (string.IsNullOrEmpty(version) && (string.IsNullOrEmpty(buildNr) || string.IsNullOrEmpty(preRelease)))
{
throw new CliException(string.Format(CliMessages.MissingMandatoryProperties, "version, buildNr, preRelease"));
}

if (!string.IsNullOrEmpty(buildNr) && !string.IsNullOrEmpty(preRelease))
{
throw new CliException(string.Format(CliMessages.MissingMandatoryProperties, "version, buildNr"));
throw new CliException(string.Format(CliMessages.MutuallyExclusiveProperties, "buildNr, preRelease"));
}

// Reading cmfPackage
CmfPackage cmfPackage = CmfPackage.Load(cmfpackageFile);

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

/// <summary>
Expand All @@ -79,7 +89,7 @@ public void Execute(DirectoryInfo packagePath, string version, string buildNr, s
/// <param name="buildNr">The version for build Nr.</param>
/// <param name="root">The root.</param>
/// <exception cref="CliException"></exception>
public void Execute(CmfPackage cmfPackage, string version, string buildNr, string root)
public void Execute(CmfPackage cmfPackage, string version, string buildNr, string preRelease, string root)
{
IDirectoryInfo packageDirectory = cmfPackage.GetFileInfo().Directory;
IPackageTypeHandler packageTypeHandler = PackageTypeFactory.GetPackageTypeHandler(cmfPackage);
Expand All @@ -90,7 +100,9 @@ public void Execute(CmfPackage cmfPackage, string version, string buildNr, strin
{ "root", root }
};

packageTypeHandler.Bump(version, buildNr, bumpInformation);
string versionSuffix = !string.IsNullOrEmpty(buildNr) ? buildNr : preRelease;

packageTypeHandler.Bump(version, versionSuffix, bumpInformation);

// will save with new version
cmfPackage.SaveCmfPackage();
Expand Down
23 changes: 18 additions & 5 deletions cmf-cli/Commands/bump/BumpIoTConfigurationCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public override void Configure(Command cmd)
aliases: new string[] { "-b", "--buildNrVersion" },
description: "Will add this version next to the version (v-b)"));

cmd.AddOption(new Option<string>(
aliases: new string[] { "-p", "--preReleaseVersion" },
description: "Will add this version as pre-release version (v-p)"));

cmd.AddOption(new Option<bool>(
aliases: new string[] { "-md", "--masterData" },
getDefaultValue: () => { return false; },
Expand Down Expand Up @@ -80,15 +84,16 @@ public override void Configure(Command cmd)
description: "Instead of replacing the version will add -$version"));

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

/// <summary>
/// Executes the specified package directory.
/// </summary>
/// <param name="path">The package directory.</param>
/// <param name="version">The version.</param>
/// <param name="buildNr"></param>
/// <param name="buildNrVersion"></param>
/// <param name="preReleaseVersion"></param>
/// <param name="isToBumpMasterdata">if set to <c>true</c> [is to bump masterdata].</param>
/// <param name="isToBumpIoT">if set to <c>true</c> [is to bump io t].</param>
/// <param name="packageNames">The package names.</param>
Expand All @@ -97,8 +102,9 @@ public override void Configure(Command cmd)
/// <param name="workflowName">Name of the workflow.</param>
/// <param name="isToTag">if set to <c>true</c> [is to tag].</param>
/// <param name="onlyMdCustomization">if set to <c>true</c> [only md customization].</param>
/// <exception cref="CliException"></exception>
/// <returns></returns>
public void Execute(IDirectoryInfo path, string version, string buildNr, bool isToBumpMasterdata, bool isToBumpIoT, string packageNames, string root, string group, string workflowName, bool isToTag, bool onlyMdCustomization)
public void Execute(IDirectoryInfo path, string version, string buildNrVersion, string preReleaseVersion, bool isToBumpMasterdata, bool isToBumpIoT, string packageNames, string root, string group, string workflowName, bool isToTag, bool onlyMdCustomization)
{
using var activity = ExecutionContext.ServiceProvider?.GetService<ITelemetryService>()?.StartExtendedActivity(this.GetType().Name);

Expand All @@ -115,6 +121,13 @@ public void Execute(IDirectoryInfo path, string version, string buildNr, bool is
automationWorkflowDirectories = automationWorkflowDirectories.Where(awf => awf.Contains(root))?.ToList();
}

if (!string.IsNullOrEmpty(buildNrVersion) && !string.IsNullOrEmpty(preReleaseVersion))
{
throw new CliException(string.Format(CliMessages.MutuallyExclusiveProperties, "buildNrVersion, preReleaseVersion"));
}

string versionSuffix = !string.IsNullOrEmpty(buildNrVersion) ? buildNrVersion : preReleaseVersion;

foreach (string automationWorkflowDirectory in automationWorkflowDirectories)
{
#region Bump AutomationWorkflow
Expand All @@ -129,7 +142,7 @@ public void Execute(IDirectoryInfo path, string version, string buildNr, bool is
groups = groups.Where(gr => gr.Contains(group)).ToList();
}

groups.ForEach(group => IoTUtilities.BumpWorkflowFiles(group, version, buildNr, workflowName, packageNames, this.fileSystem));
groups.ForEach(group => IoTUtilities.BumpWorkflowFiles(group, version, versionSuffix, workflowName, packageNames, this.fileSystem));
}

#endregion Bump AutomationWorkflow
Expand All @@ -138,7 +151,7 @@ public void Execute(IDirectoryInfo path, string version, string buildNr, bool is

if (isToBumpMasterdata)
{
IoTUtilities.BumpIoTMasterData(automationWorkflowDirectory, version, buildNr, this.fileSystem, onlyCustomization: onlyMdCustomization);
IoTUtilities.BumpIoTMasterData(automationWorkflowDirectory, version, versionSuffix, this.fileSystem, onlyCustomization: onlyMdCustomization);
}

#endregion Bump IoT Masterdata
Expand Down
28 changes: 20 additions & 8 deletions cmf-cli/Commands/bump/BumpIoTCustomizationCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public override void Configure(Command cmd)
aliases: new string[] { "-b", "--buildNrVersion" },
description: "Will add this version next to the version (v-b)"));

cmd.AddOption(new Option<string>(
aliases: new string[] { "-p", "--preReleaseVersion" },
description: "Will add this version as pre-release version (v-p)"));

cmd.AddOption(new Option<string>(
aliases: new string[] { "-pckNames", "--packageNames" },
description: "Packages to be bumped"));
Expand All @@ -49,20 +53,21 @@ public override void Configure(Command cmd)
getDefaultValue: () => { return false; },
description: "Instead of replacing the version will add -$version"));

cmd.Handler = CommandHandler.Create<IDirectoryInfo, string, string, string, bool>(Execute);
cmd.Handler = CommandHandler.Create<IDirectoryInfo, string, string, string, string, bool>(Execute);
}

/// <summary>
/// Executes the specified package path.
/// </summary>
/// <param name="packagePath">The package path.</param>
/// <param name="version">The version.</param>
/// <param name="buildNr"></param>
/// <param name="buildNrVersion"></param>
/// <param name="preReleaseVersion"></param>
/// <param name="packageNames">The package names.</param>
/// <param name="isToTag">if set to <c>true</c> [is to tag].</param>
/// <exception cref="CliException"></exception>
/// <exception cref="CliException"></exception>
public void Execute(IDirectoryInfo packagePath, string version, string buildNr, string packageNames, bool isToTag)
public void Execute(IDirectoryInfo packagePath, string version, string buildNrVersion, string preReleaseVersion, string packageNames, bool isToTag)
{
using var activity = ExecutionContext.ServiceProvider?.GetService<ITelemetryService>()?.StartExtendedActivity(this.GetType().Name);
IFileInfo cmfpackageFile = this.fileSystem.FileInfo.New($"{packagePath}/{CliConstants.CmfPackageFileName}");
Expand All @@ -72,36 +77,43 @@ public void Execute(IDirectoryInfo packagePath, string version, string buildNr,
throw new CliException(string.Format(CliMessages.MissingMandatoryProperty, "version"));
}

if (!string.IsNullOrEmpty(buildNrVersion) && !string.IsNullOrEmpty(preReleaseVersion))
{
throw new CliException(string.Format(CliMessages.MutuallyExclusiveProperties, "buildNrVersion, preReleaseVersion"));
}

// Reading cmfPackage
CmfPackage cmfPackage = CmfPackage.Load(cmfpackageFile);

Execute(cmfPackage, version, buildNr, packageNames, isToTag);
Execute(cmfPackage, version, buildNrVersion, preReleaseVersion, packageNames, isToTag);
}

/// <summary>
/// Executes the BumpIoTCustomPackages for specified CMF package.
/// </summary>
/// <param name="cmfPackage">The CMF package.</param>
/// <param name="version">The version.</param>
/// <param name="buildNr"></param>
/// <param name="buildNrVersion">The version for build Nr.</param>
/// <param name="preReleaseVersion">The pre-release version.</param>
/// <param name="packageNames">The package names.</param>
/// <param name="isToTag">if set to <c>true</c> [is to tag].</param>
/// <exception cref="CliException"></exception>
public void Execute(CmfPackage cmfPackage, string version, string buildNr, string packageNames, bool isToTag)
public void Execute(CmfPackage cmfPackage, string version, string buildNrVersion, string preReleaseVersion, string packageNames, bool isToTag)
{
string versionSuffix = !string.IsNullOrEmpty(buildNrVersion) ? buildNrVersion : preReleaseVersion;
if (cmfPackage.PackageType != PackageType.IoT)
{
IDirectoryInfo packageDirectory = cmfPackage.GetFileInfo().Directory;
CmfPackageCollection iotPackages = packageDirectory.LoadCmfPackagesFromSubDirectories(packageType: PackageType.IoT);
foreach (var iotPackage in iotPackages)
{
// IoT -> src -> Package XPTO
IoTUtilities.BumpIoTCustomPackages(iotPackage.GetFileInfo().DirectoryName, version, buildNr, packageNames, this.fileSystem);
IoTUtilities.BumpIoTCustomPackages(iotPackage.GetFileInfo().DirectoryName, version, versionSuffix, packageNames, this.fileSystem);
}
}
else
{
IoTUtilities.BumpIoTCustomPackages(cmfPackage.GetFileInfo().DirectoryName, version, buildNr, packageNames, this.fileSystem);
IoTUtilities.BumpIoTCustomPackages(cmfPackage.GetFileInfo().DirectoryName, version, versionSuffix, packageNames, this.fileSystem);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions cmf-cli/Handlers/PackageType/BusinessPackageTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ public BusinessPackageTypeHandler(CmfPackage cmfPackage) : base(cmfPackage)
/// Bumps the specified CMF package.
/// </summary>
/// <param name="version">The version.</param>
/// <param name="buildNr">The version for build Nr.</param>
/// <param name="versionSuffix">The version for build Nr.</param>
/// <param name="bumpInformation">The bump information.</param>
public override void Bump(string version, string buildNr, Dictionary<string, object> bumpInformation = null)
public override void Bump(string version, string versionSuffix, Dictionary<string, object> bumpInformation = null)
{
base.Bump(version, buildNr, bumpInformation);
base.Bump(version, versionSuffix, bumpInformation);

string[] versionTags = null;
if (!string.IsNullOrWhiteSpace(version))
Expand All @@ -109,9 +109,9 @@ public override void Bump(string version, string buildNr, Dictionary<string, obj
string major = versionTags != null && versionTags.Length > 0 ? versionTags[0] : metadataVersionInfo[0];
string minor = versionTags != null && versionTags.Length > 1 ? versionTags[1] : metadataVersionInfo[1];
string patch = versionTags != null && versionTags.Length > 2 ? versionTags[2] : metadataVersionInfo[2];
string build = !string.IsNullOrEmpty(buildNr) ? buildNr : "0";
string newVersion = string.Format(@"Version(""{0}.{1}.{2}.{3}"")", major, minor, patch, build);
text = Regex.Replace(text, pattern, newVersion, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
string suffix = !string.IsNullOrEmpty(versionSuffix) && int.TryParse(versionSuffix, out _) ? versionSuffix : "0";
string newVersion = string.Format(@"Version(""{0}.{1}.{2}.{3}"")", major, minor, patch, suffix);
text = Regex.Replace(text, pattern, newVersion, RegexOptions.IgnoreCase);
this.fileSystem.File.WriteAllText(filePath, text);
}
}
Expand Down
8 changes: 4 additions & 4 deletions cmf-cli/Handlers/PackageType/HelpNgCliPackageTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,19 @@ public HelpNgCliPackageTypeHandler(CmfPackage cmfPackage) : base(cmfPackage)
/// of each project to the specified version.
/// </summary>
/// <param name="version">The version.</param>
/// <param name="buildNr">The version for build Nr.</param>
/// <param name="versionSuffix">The version suffix.</param>
/// <param name="bumpInformation">The bump information.</param>
public override void Bump(string version, string buildNr, Dictionary<string, object> bumpInformation = null)
public override void Bump(string version, string versionSuffix, Dictionary<string, object> bumpInformation = null)
{
base.Bump(version, buildNr, bumpInformation);
base.Bump(version, versionSuffix, bumpInformation);

foreach (var project in Workspace.Projects)
{
if (project.PackageJson.Content.version == null)
{
throw new CliException(string.Format(CoreMessages.MissingMandatoryPropertyInFile, "version", project.PackageJson.File.FullName));
}
project.PackageJson.Content.version = GenericUtilities.RetrieveNewPresentationVersion(project.PackageJson.Content.version.ToString(), version, buildNr);
project.PackageJson.Content.version = GenericUtilities.RetrieveNewPresentationVersion(project.PackageJson.Content.version.ToString(), version, versionSuffix);

// write package.json
fileSystem.File.WriteAllText(project.PackageJson.File.FullName, JsonConvert.SerializeObject(project.PackageJson.Content, Formatting.Indented));
Expand Down
8 changes: 4 additions & 4 deletions cmf-cli/Handlers/PackageType/HtmlNgCliPackageTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,19 @@ public HtmlNgCliPackageTypeHandler(CmfPackage cmfPackage) : base(cmfPackage)
/// of each project to the specified version.
/// </summary>
/// <param name="version">The version.</param>
/// <param name="buildNr">The version for build Nr.</param>
/// <param name="versionSuffix">The version suffix.</param>
/// <param name="bumpInformation">The bump information.</param>
public override void Bump(string version, string buildNr, Dictionary<string, object> bumpInformation = null)
public override void Bump(string version, string versionSuffix, Dictionary<string, object> bumpInformation = null)
{
base.Bump(version, buildNr, bumpInformation);
base.Bump(version, versionSuffix, bumpInformation);

foreach (var project in Workspace.Projects)
{
if (project.PackageJson.Content.version == null)
{
throw new CliException(string.Format(CoreMessages.MissingMandatoryPropertyInFile, "version", project.PackageJson.File.FullName));
}
project.PackageJson.Content.version = GenericUtilities.RetrieveNewPresentationVersion(project.PackageJson.Content.version.ToString(), version, buildNr);
project.PackageJson.Content.version = GenericUtilities.RetrieveNewPresentationVersion(project.PackageJson.Content.version.ToString(), version, versionSuffix);

// write package.json
fileSystem.File.WriteAllText(project.PackageJson.File.FullName, JsonConvert.SerializeObject(project.PackageJson.Content, Formatting.Indented));
Expand Down
Loading
Loading