Skip to content

Commit

Permalink
completes command
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Krylo committed Sep 13, 2024
1 parent 932ecaf commit 83b8a3e
Show file tree
Hide file tree
Showing 29 changed files with 476 additions and 89 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ docker run -it --rm clio reg-web-app -help
- [Get package list](#get-package-list)
- [Set package version](#set-package-version)
- [Set application version](#set-application-version)
- [Set application icon](#set-application-icon)
- [NuGet Packages](#nuget-packages)
- [Pack NuGet package](#pack-nuget-package)
- [Push NuGet package](#push-nuget-package)
Expand Down Expand Up @@ -423,6 +424,29 @@ clio set-app-versin -f <PACKAGE FOLDER PATH> -v <APP VERSION>
```


## Set Application Icon

The `set-app-icon` command is used to set the icon for a specified application
by updating the `app-descriptor.json` file.

### Usage

```bash
clio set-app-icon [options]
```
-p, --app-name (required): The name or code of the application.
-i, --app-icon (required): The path to the SVG icon file to be set.
-f, --package-folder (required): The path to the folder containing the application packages.

Examples
Set the icon for an application with a specified name:

```bash
clio set-app-icon -p MyAppName -i /path/to/icon.svg -f /path/to/package/folder
```


## Enable/Disable pkg hotfix mode

To see full description about Hot Fix mode visit [Creatio Academy](https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/development-tools/delivery/hotfix-mode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,72 +1,48 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Abstractions.TestingHelpers;
using System.Json;
using Autofac;
using Clio.Command.ApplicationCommand;
using Clio.ComposableApplication;
using FluentAssertions;
using ICSharpCode.SharpZipLib.Zip;
using NSubstitute;
using NUnit.Framework;

namespace Clio.Tests.Command.ApplicationCommand
namespace Clio.Tests.Command.ApplicationCommand;

internal class SetApplicationIconCommandTestCase : BaseCommandTests<SetApplicationVersionOption>
{

internal class SetApplicationIconCommandTestCase : BaseCommandTests<SetApplicationVersionOption>
{
private static string mockPackageFolderPath = Path.Combine("C:", "MockPackageFolder");
private static string mockPackageAppDescriptorPath = Path.Combine(mockPackageFolderPath, "Files", "app-descriptor.json");
private static string mockWorspacePath = Path.Combine("C:", "MockWorkspaceFolder");
private static string mockWorkspaceAppPackageFolderPath = Path.Combine(mockWorspacePath, "packages", "IFrameSample");
private static string mockWorkspaceAppDescriptorPath = Path.Combine(mockWorkspaceAppPackageFolderPath, "Files", "app-descriptor.json");
#region Fields: Private

private static readonly string MockWorkspacePath = Path.Combine("C:", "MockWorkspaceFolder");

private static MockFileSystem CreateFs(string filePath, string packagePath) {
string originClioSourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
string appDescriptorExamplesDescriptorPath = Path.Combine(originClioSourcePath, "Examples", "AppDescriptors", filePath);
string mockAppDescriptorFilePath = Path.Combine(packagePath, "Files", "app-descriptor.json");
return new MockFileSystem(new Dictionary<string, MockFileData> {
{
mockAppDescriptorFilePath,
new MockFileData(File.ReadAllText(appDescriptorExamplesDescriptorPath))
}
});
}
private static readonly string MockWorkspaceAppPackageFolderPath
= Path.Combine(MockWorkspacePath, "packages", "IFrameSample");

private static MockFileSystem CreateFs(Dictionary<string, string> appDescriptors) {
string originClioSourcePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
MockFileSystem mockFileSystem = new MockFileSystem();
foreach (var appDescriptor in appDescriptors) {
string appDescriptorExamplesDescriptorPath = Path.Combine(originClioSourcePath, "Examples", "AppDescriptors", appDescriptor.Value);
string mockAppDescriptorJsonPath = Path.Combine(mockWorspacePath, "packages", appDescriptor.Key, "Files", "app-descriptor.json");
mockFileSystem.AddFile(mockAppDescriptorJsonPath, new MockFileData(File.ReadAllText(appDescriptorExamplesDescriptorPath)));
}
return mockFileSystem;
}
private IComposableApplicationManager _composableApplicationManager;

private MockFileSystem _fileSystem;
private IComposableApplicationManager composableApplicationManager;
#endregion

protected override void AdditionalRegistrations(ContainerBuilder containerBuilder) {
composableApplicationManager = Substitute.For<IComposableApplicationManager>();
containerBuilder.RegisterInstance(composableApplicationManager);
base.AdditionalRegistrations(containerBuilder);
}
#region Methods: Protected

[Test]
public void SetApplicationIconCommand_CallsComposableAppmanager() {
string iconPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", "icon.svg");
string appName = "ExampleAppName";
var command = Container.Resolve<SetApplicationIconCommand>();
command.Execute(new SetApplicationIconOption {
IconPath = iconPath,
WorspaceFolderPath = mockWorspacePath,
PackageFolderPath = mockWorkspaceAppPackageFolderPath,
AppName = appName
});
composableApplicationManager.Received(1).SetIcon(mockWorkspaceAppPackageFolderPath, iconPath, appName);
}
protected override void AdditionalRegistrations(ContainerBuilder containerBuilder){
_composableApplicationManager = Substitute.For<IComposableApplicationManager>();
containerBuilder.RegisterInstance(_composableApplicationManager);
base.AdditionalRegistrations(containerBuilder);
}

#endregion

[Test]
public void SetApplicationIconCommand_CallsComposableAppmanager(){
string iconPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", "icon.svg");
string appName = "ExampleAppName";
SetApplicationIconCommand command = Container.Resolve<SetApplicationIconCommand>();
command.Execute(new SetApplicationIconOption {
IconPath = iconPath,
PackageFolderPath = MockWorkspaceAppPackageFolderPath,
AppName = appName
});
_composableApplicationManager.Received(1).SetIcon(MockWorkspaceAppPackageFolderPath, iconPath, appName);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static MockFileSystem CreateFs(Dictionary<string, string> appDescriptors
public void SetVersion_WhenWorkspaceContainsOneApplication(string descriptorPath) {
_fileSystem = CreateFs(descriptorPath, mockWorkspaceAppPackageFolderPath);
string expectedVersion = "8.1.1";
var composableApplicationManager = new ComposableApplicationManager(_fileSystem);
var composableApplicationManager = new ComposableApplicationManager(_fileSystem, null);
var command = new SetApplicationVersionCommand(composableApplicationManager);
string worspaceFolderPath = mockWorspacePath;
command.Execute(new SetApplicationVersionOption() {
Expand All @@ -70,7 +70,7 @@ public void SetVersion_ThrowException_WhenWorkspaceContainsMoreThanOneApplicatio
appDescriptions.Add("Package1", "app1-app-descriptor.json");
appDescriptions.Add("Package2", "app2-app-descriptor.json");
_fileSystem = CreateFs(appDescriptions);
var composableApplicationManager = new ComposableApplicationManager(_fileSystem);
var composableApplicationManager = new ComposableApplicationManager(_fileSystem, null);
var command = new SetApplicationVersionCommand(composableApplicationManager);
string expectedVersion = "8.1.1";
string worspaceFolderPath = mockWorspacePath;
Expand All @@ -87,7 +87,7 @@ public void SetVersion_ThrowExceptionWhenAplicationExtendedAndPackageNotDefined(
appDescriptions.Add("Package2", "app1-ext-app-descriptor.json");
_fileSystem = CreateFs(appDescriptions);
string expectedVersion = "8.1.1";
var composableApplicationManager = new ComposableApplicationManager(_fileSystem);
var composableApplicationManager = new ComposableApplicationManager(_fileSystem, null);
var command = new SetApplicationVersionCommand(composableApplicationManager);
string worspaceFolderPath = mockWorspacePath;
var exception = Assert.Throws<Exception>(() => command.Execute(new SetApplicationVersionOption() {
Expand All @@ -104,7 +104,7 @@ public void SetVersion_WhenAplicationExtendedAndPackageDefined() {
appDescriptions.Add(extendPackageName, "app1-ext-app-descriptor.json");
_fileSystem = CreateFs(appDescriptions);
string expectedVersion = "8.1.1";
var composableApplicationManager = new ComposableApplicationManager(_fileSystem);
var composableApplicationManager = new ComposableApplicationManager(_fileSystem, null);
var command = new SetApplicationVersionCommand(composableApplicationManager);
string worspaceFolderPath = mockWorspacePath;
command.Execute(new SetApplicationVersionOption() {
Expand All @@ -120,7 +120,7 @@ public void SetVersion_WhenAplicationExtendedAndPackageDefined() {
public void SetVersion_WhenSetAppFolderPathForOneApplication(string descriptorPath) {
_fileSystem = CreateFs(descriptorPath, mockPackageFolderPath);
string expectedVersion = "8.1.1";
var composableApplicationManager = new ComposableApplicationManager(_fileSystem);
var composableApplicationManager = new ComposableApplicationManager(_fileSystem, null);
var command = new SetApplicationVersionCommand(composableApplicationManager);
command.Execute(new SetApplicationVersionOption() {
Version = expectedVersion,
Expand Down
Loading

0 comments on commit 83b8a3e

Please sign in to comment.