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
16 changes: 11 additions & 5 deletions cmf-cli/Factories/PackageTypeFactory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

using Cmf.CLI.Core;
using Cmf.CLI.Core;
using Cmf.CLI.Core.Enums;
using Cmf.CLI.Core.Interfaces;
using Cmf.CLI.Core.Objects;
Expand Down Expand Up @@ -64,7 +63,13 @@ public static IPackageTypeHandler GetPackageTypeHandler(CmfPackage cmfPackage, b
PackageType.ExportedObjects => new ExportedObjectsPackageTypeHandler(cmfPackage),
PackageType.Database => new DatabasePackageTypeHandler(cmfPackage),
PackageType.Tests => new TestPackageTypeHandler(cmfPackage),
PackageType.SecurityPortal => SecurityPortalHandler(cmfPackage),
PackageType.SecurityPortal => cmfPackage.HandlerVersion switch
{
3 => new SecurityPortalPackageTypeHandlerV3(cmfPackage),
2 => new SecurityPortalPackageTypeHandlerV2(cmfPackage),
1 => new SecurityPortalPackageTypeHandler(cmfPackage),
_ => SecurityPortalHandler(cmfPackage)
},
PackageType.Grafana => new GrafanaPackageTypeHandler(cmfPackage),
_ => throw new CliException(string.Format(CoreMessages.PackageTypeHandlerNotImplemented, cmfPackage.PackageType.ToString()))
};
Expand Down Expand Up @@ -98,7 +103,7 @@ private static IPackageTypeHandler HtmlHandler(CmfPackage cmfPackage)

/// <summary>
/// Creates the specific Security Portal package handler.
///
///
/// If the ProjectConfig's MESVersion is less than 10.0.0, a <seealso cref="SecurityPortalPackageTypeHandler"/> is created and returned.
/// Otherwise, a <seealso cref="SecurityPortalPackageTypeHandlerV2"/> is created and returned.
/// </summary>
Expand All @@ -108,6 +113,7 @@ private static IPackageTypeHandler SecurityPortalHandler(CmfPackage cmfPackage)
{
var targetVersion = ExecutionContext.Instance.ProjectConfig.MESVersion;
var minimumVersion = new Version("10.0.0");

if (targetVersion.CompareTo(minimumVersion) < 0)
{
return new SecurityPortalPackageTypeHandler(cmfPackage);
Expand All @@ -116,4 +122,4 @@ private static IPackageTypeHandler SecurityPortalHandler(CmfPackage cmfPackage)
return new SecurityPortalPackageTypeHandlerV2(cmfPackage);
}
}
}
}
70 changes: 70 additions & 0 deletions cmf-cli/Handlers/PackageType/SecurityPortalPackageTypeHandlerV3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Cmf.CLI.Constants;
using Cmf.CLI.Core;
using Cmf.CLI.Core.Enums;
using Cmf.CLI.Core.Objects;
using Cmf.CLI.Utilities;
using System.Collections.Generic;
using System.IO;
using System.IO.Abstractions;

namespace Cmf.CLI.Handlers
{
public class SecurityPortalPackageTypeHandlerV3 : PackageTypeHandler
{
/// <summary>
/// Initializes a new instance of the <see cref="SecurityPortalPackageTypeHandlerV3" /> class.
/// </summary>
/// <param name="cmfPackage"></param>
public SecurityPortalPackageTypeHandlerV3(CmfPackage cmfPackage) : base(cmfPackage)
{
cmfPackage.SetDefaultValues
(
targetDirectory:
"SecurityPortal",
targetLayer:
"securityportal",
steps:
new List<Step>
{
new(StepType.TransformFile)
{
File = "config.json",
TagFile = true,
RelativePath = "./src/"
}
}
);

cmfPackage.DFPackageType = PackageType.Business;
}

/// <summary>
/// Packs the specified package output dir.
/// </summary>
/// <param name="packageOutputDir">The package output dir.</param>
/// <param name="outputDir">The output dir.</param>
public override void Pack(IDirectoryInfo packageOutputDir, IDirectoryInfo outputDir)
{
Log.Debug("Generating SecurityPortal package");
string path = $"{packageOutputDir.FullName}{Path.DirectorySeparatorChar}{CliConstants.CmfPackageSecurityPortalConfig}";

IDirectoryInfo cmfPackageDirectory = CmfPackage.GetFileInfo().Directory;

dynamic configJson = cmfPackageDirectory.GetFile(CliConstants.CmfPackageSecurityPortalConfig);

if (configJson != null)
{
GenerateDeploymentFrameworkManifest(packageOutputDir);

FinalArchive(packageOutputDir, outputDir);

Log.Debug($"{outputDir.FullName}{Path.DirectorySeparatorChar}{CmfPackage.ZipPackageName} created");
Log.Information($"{CmfPackage.PackageName} packed");
}
else
{
throw new CliException("No config.json was provided");
}
}
}
}