Skip to content

Commit

Permalink
Merge pull request #43 from m-s-/development-40-manifest-targetlayer-…
Browse files Browse the repository at this point in the history
…support

feat(pack): support targetLayer in manifests
  • Loading branch information
joaoopereira authored Oct 14, 2021
2 parents 1681fef + 1df212b commit 1c3e633
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 55 deletions.
13 changes: 7 additions & 6 deletions cmf-cli/Commands/build/BuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,21 @@ public BuildCommand(IFileSystem fileSystem) : base(fileSystem)
public override void Configure(Command cmd)
{
var packageRoot = FileSystemUtilities.GetPackageRoot(this.fileSystem);
var packagePath = ".";
if (packageRoot != null)
{
packagePath = this.fileSystem.Path.GetRelativePath(this.fileSystem.Directory.GetCurrentDirectory(), packageRoot.FullName);
}
var arg = new Argument<IDirectoryInfo>(
name: "packagePath",
parse: (argResult) => Parse<IDirectoryInfo>(argResult, "."),
parse: (argResult) => Parse<IDirectoryInfo>(argResult, packagePath),
isDefault: true)
{
Description = "Package Path"
};

cmd.AddArgument(arg);
if (packageRoot != null)
{
var packagePath = Path.GetRelativePath(Directory.GetCurrentDirectory(), packageRoot.FullName);
arg.SetDefaultValue(new DirectoryInfo(packagePath));
}

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

Expand Down
2 changes: 2 additions & 0 deletions cmf-cli/Handlers/PackageType/BusinessPackageTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public BusinessPackageTypeHandler(CmfPackage cmfPackage) : base(cmfPackage)
cmfPackage.SetDefaultValues(
targetDirectory:
"BusinessTier",
targetLayer:
"host",
steps:
new List<Step>()
{
Expand Down
4 changes: 3 additions & 1 deletion cmf-cli/Handlers/PackageType/HelpPackageTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public HelpPackageTypeHandler(CmfPackage cmfPackage) : base(cmfPackage)
cmfPackage.SetDefaultValues
(
targetDirectory:
"UI/Help"
"UI/Help",
targetLayer:
"help"
);

BuildSteps = new IBuildCommand[]
Expand Down
8 changes: 5 additions & 3 deletions cmf-cli/Handlers/PackageType/HtmlPackageTypeHandler.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Cmf.Common.Cli.Builders;
using Cmf.Common.Cli.Enums;
using Cmf.Common.Cli.Objects;
using System.Collections.Generic;

using System.Collections.Generic;

namespace Cmf.Common.Cli.Handlers
{
/// <summary>
Expand All @@ -21,13 +21,15 @@ public HtmlPackageTypeHandler(CmfPackage cmfPackage) : base(cmfPackage)
(
targetDirectory:
"UI/Html",
targetLayer:
"ui",
steps:
new List<Step>
{
new Step(StepType.DeployFiles)
{
ContentPath = "bundles/**"
}
}
}
);

Expand Down
6 changes: 4 additions & 2 deletions cmf-cli/Handlers/PackageType/IoTPackageTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.IO.Abstractions;

using System.IO.Abstractions;

namespace Cmf.Common.Cli.Handlers
{
/// <summary>
Expand All @@ -29,6 +29,8 @@ public IoTPackageTypeHandler(CmfPackage cmfPackage) : base(cmfPackage)
(
targetDirectory:
"UI/Html",
targetLayer:
"ui",
steps:
new List<Step>()
{
Expand Down
43 changes: 31 additions & 12 deletions cmf-cli/Objects/CmfPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,32 @@ public class CmfPackage : IEquatable<CmfPackage>
public PackageType PackageType { get; private set; }

/// <summary>
/// Gets or sets the target directory.
/// Gets or sets the target directory where the package contents should be installed.
/// This is used when the package is installed using Deployment Framework and ignored when it is installed using Environment Manager.
/// </summary>
/// <value>
/// The target directory.
/// </value>
[JsonProperty(Order = 5)]
public string TargetDirectory { get; private set; }

/// <summary>
/// Gets or sets the target layer, which means the container in which the packages contents should be installed.
/// This is used when the package is installed using Environment Manager and ignored when it is installed using Deployment Framework.
/// </summary>
/// <value>
/// The target layer.
/// </value>
[JsonProperty(Order = 6)]
public string TargetLayer { get; private set; }

/// <summary>
/// Gets or sets a value indicating whether this instance is installable.
/// </summary>
/// <value>
/// <c>true</c> if this instance is installable; otherwise, <c>false</c>.
/// </value>
[JsonProperty(Order = 6)]
[JsonProperty(Order = 7)]
public bool? IsInstallable { get; private set; }

/// <summary>
Expand All @@ -131,7 +142,7 @@ public class CmfPackage : IEquatable<CmfPackage>
/// <value>
/// The is unique install.
/// </value>
[JsonProperty(Order = 7)]
[JsonProperty(Order = 8)]
public bool? IsUniqueInstall { get; private set; }

/// <summary>
Expand All @@ -140,7 +151,7 @@ public class CmfPackage : IEquatable<CmfPackage>
/// <value>
/// The is root package.
/// </value>
[JsonProperty(Order = 8)]
[JsonProperty(Order = 9)]
[JsonIgnore]
public string Keywords { get; private set; }

Expand All @@ -150,7 +161,7 @@ public class CmfPackage : IEquatable<CmfPackage>
/// <value>
/// The set default steps.
/// </value>
[JsonProperty(Order = 9)]
[JsonProperty(Order = 10)]
[JsonIgnore]
public bool? IsToSetDefaultSteps { get; private set; }

Expand All @@ -160,7 +171,7 @@ public class CmfPackage : IEquatable<CmfPackage>
/// <value>
/// The dependencies.
/// </value>
[JsonProperty(Order = 10)]
[JsonProperty(Order = 11)]
public DependencyCollection Dependencies { get; private set; }

/// <summary>
Expand All @@ -169,7 +180,7 @@ public class CmfPackage : IEquatable<CmfPackage>
/// <value>
/// The steps.
/// </value>
[JsonProperty(Order = 11)]
[JsonProperty(Order = 12)]
public List<Step> Steps { get; private set; }

/// <summary>
Expand All @@ -178,7 +189,7 @@ public class CmfPackage : IEquatable<CmfPackage>
/// <value>
/// The content to pack.
/// </value>
[JsonProperty(Order = 12)]
[JsonProperty(Order = 13)]
public List<ContentToPack> ContentToPack { get; private set; }

/// <summary>
Expand All @@ -187,7 +198,7 @@ public class CmfPackage : IEquatable<CmfPackage>
/// <value>
/// The deployment framework UI file.
/// </value>
[JsonProperty(Order = 13)]
[JsonProperty(Order = 14)]
public List<string> XmlInjection { get; private set; }

/// <summary>
Expand All @@ -196,13 +207,13 @@ public class CmfPackage : IEquatable<CmfPackage>
/// <value>
/// The Test Package Id.
/// </value>
[JsonProperty(Order = 14)]
[JsonProperty(Order = 15)]
public DependencyCollection TestPackages { get; set; }

/// <summary>
/// The location of the package
/// </summary>
[JsonProperty(Order = 15)]
[JsonProperty(Order = 16)]
[JsonIgnore]
public PackageLocation Location { get; private set; }

Expand Down Expand Up @@ -250,6 +261,7 @@ private void ValidatePackage()
/// <param name="description">The description.</param>
/// <param name="packageType">Type of the package.</param>
/// <param name="targetDirectory">The target directory.</param>
/// <param name="targetLayer">The target layer.</param>
/// <param name="isInstallable">The is installable.</param>
/// <param name="isUniqueInstall">The is unique install.</param>
/// <param name="keywords">The keywords.</param>
Expand All @@ -261,7 +273,7 @@ private void ValidatePackage()
/// <param name="testPackages">The test Packages.</param>
[JsonConstructor]
public CmfPackage(string name, string packageId, string version, string description, PackageType packageType,
string targetDirectory, bool? isInstallable, bool? isUniqueInstall, string keywords,
string targetDirectory, string targetLayer, bool? isInstallable, bool? isUniqueInstall, string keywords,
bool? isToSetDefaultSteps, DependencyCollection dependencies, List<Step> steps,
List<ContentToPack> contentToPack, List<string> xmlInjection, DependencyCollection testPackages = null) : this()
{
Expand All @@ -271,6 +283,7 @@ public CmfPackage(string name, string packageId, string version, string descript
Description = description;
PackageType = packageType;
TargetDirectory = targetDirectory;
TargetLayer = targetLayer;
IsInstallable = isInstallable ?? true;
IsUniqueInstall = isUniqueInstall ?? false;
Keywords = keywords;
Expand Down Expand Up @@ -320,6 +333,7 @@ public bool Equals(CmfPackage other)
Description.IgnoreCaseEquals(other.Description) &&
PackageType == other.PackageType &&
TargetDirectory.IgnoreCaseEquals(other.TargetDirectory) &&
TargetLayer.IgnoreCaseEquals(other.TargetLayer) &&
IsInstallable == other.IsInstallable &&
IsUniqueInstall == other.IsUniqueInstall &&
Keywords.IgnoreCaseEquals(other.Keywords) &&
Expand Down Expand Up @@ -355,6 +369,7 @@ public void SetFileInfo(IFileInfo value)
/// </summary>
/// <param name="name">The name.</param>
/// <param name="targetDirectory">The target directory.</param>
/// <param name="targetLayer">The target layer container.</param>
/// <param name="isInstallable">The is installable.</param>
/// <param name="isUniqueInstall">The is unique install.</param>
/// <param name="keywords">The keywords.</param>
Expand All @@ -363,6 +378,7 @@ public void SetFileInfo(IFileInfo value)
public void SetDefaultValues(
string name = null,
string targetDirectory = null,
string targetLayer = null,
bool? isInstallable = null,
bool? isUniqueInstall = null,
string keywords = null,
Expand All @@ -373,6 +389,8 @@ public void SetDefaultValues(
Name = string.IsNullOrEmpty(Name) ? string.IsNullOrEmpty(name) ? $"{PackageId.Replace(".", " ")}" : name : Name;

TargetDirectory = string.IsNullOrEmpty(TargetDirectory) ? targetDirectory : TargetDirectory;

TargetLayer = string.IsNullOrEmpty(TargetLayer) ? targetLayer : TargetLayer;

IsInstallable ??= isInstallable;

Expand Down Expand Up @@ -570,6 +588,7 @@ public static CmfPackage FromManifest(string manifest, bool setDefaultValues = f
tokens.ContainsKey("description") ? tokens["description"] : null,
PackageType.Generic,
"",
"",
false,
false,
tokens.ContainsKey("keywords") ? tokens["keywords"] : null,
Expand Down
1 change: 1 addition & 0 deletions cmf-cli/resources/templateFiles/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<packageId>$(packageId)</packageId>
<name>$(name)</name>
<targetDirectory>$(targetDirectory)</targetDirectory>
<targetLayer>$(targetLayer)</targetLayer>
<packageType>$(packageType)</packageType>
<description>$(description)</description>
<version>$(version)</version>
Expand Down
Loading

0 comments on commit 1c3e633

Please sign in to comment.