Skip to content

Commit

Permalink
Merge pull request #144 from Advance-Technologies-Foundation/develop
Browse files Browse the repository at this point in the history
Release 2.0.0.9
  • Loading branch information
vladimir-nikonov committed Apr 8, 2020
2 parents 0755af2 + 2ae2ec4 commit 743b4b3
Show file tree
Hide file tree
Showing 67 changed files with 1,119 additions and 480 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*.suo
# Include dlls if they're in the CommonReferences directory
!*CommonReferences/*.dll
!clio\clio\tools\nuget\nuget.exe
####################
# VS Upgrade stuff #
####################
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ You can dowload release binaries from [latest release](https://github.com/Advanc
- [Compress package](#compress-package)
- [Extract package](#extract-package)
- [Get package list](#get-package-list)
- [Set package version](#set-package-version)
- [Application](#application)
- [Restart application](#restart-application)
- [Clear redis database](#clear-redis-database)
Expand Down Expand Up @@ -178,6 +179,13 @@ for filter results, use -f option
clio get-pkg-list -f clio
```

## Set package version

Set a specified package version into descriptor.json by specified package path.
```
clio set-pkg-version <PACKAGE PATH> -v <PACKAGE VERSION>
```

# Application

## Restart application
Expand Down
6 changes: 4 additions & 2 deletions clio.tests/Command/DeletePackageCommand.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class DeletePackageCommandTestCase
[Test, Category("Unit")]
public void Delete_FormsCorrectApplicationRequest_WhenApplicationRunsUnderNetFramework() {
IApplicationClient applicationClient = Substitute.For<IApplicationClient>();
DeletePackageCommand deleteCommand = new DeletePackageCommand(applicationClient);
var deleteOptions = new DeletePkgOptions {
Login = "Test",
Password = "Test",
Expand All @@ -20,7 +19,10 @@ public class DeletePackageCommandTestCase
Uri = "http://test.domain.com",
Name = "TestPackage"
};
deleteCommand.Delete(deleteOptions);
var settingsRepository = new SettingsRepository();
var environment = settingsRepository.GetEnvironment(deleteOptions);
DeletePackageCommand deleteCommand = new DeletePackageCommand(applicationClient, environment);
deleteCommand.Execute(deleteOptions);
applicationClient.Received(1).ExecutePostRequest(
deleteOptions.Uri + "/0/ServiceModel/AppInstallerService.svc/DeletePackage",
"\"TestPackage\"", Arg.Any<int>());
Expand Down
4 changes: 4 additions & 0 deletions clio/BindingsModule.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Autofac;
using Clio.Command;
using Clio.Command.PackageCommand;
using Clio.Command.SqlScriptCommand;
using Clio.Common;
using System.Reflection;
Expand All @@ -26,6 +27,9 @@ public class BindingsModule
containerBuilder.RegisterType<PackNuGetPackageCommand>();
containerBuilder.RegisterType<RestoreNugetPackageCommand>();
containerBuilder.RegisterType<InstallNugetPackageCommand>();
containerBuilder.RegisterType<SetPackageVersionCommand>();
containerBuilder.RegisterType<CheckNugetUpdateCommand>();
containerBuilder.RegisterType<DeletePackageCommand>();
return containerBuilder.Build();
}
}
Expand Down
29 changes: 10 additions & 19 deletions clio/Command/AssemblyCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using Clio.Common;
using CommandLine;

namespace Clio.Command
Expand All @@ -17,31 +18,21 @@ internal class ExecuteAssemblyOptions : EnvironmentOptions
public string ExecutorType { get; set; }
}

class AssemblyCommand : BaseRemoteCommand
class AssemblyCommand : RemoteCommand<ExecuteAssemblyOptions>
{
private static string ExecutorUrl => AppUrl + @"/IDE/ExecuteScript";
protected override string ServicePath => @"/IDE/ExecuteScript";

private static void ExecuteCodeFromAssemblyInternal(ExecuteAssemblyOptions options) {

public AssemblyCommand(IApplicationClient applicationClient, EnvironmentSettings settings)
: base(applicationClient, settings) {
}

protected override string GetResponseData(ExecuteAssemblyOptions options) {
string filePath = options.Name;
string executorType = options.ExecutorType;
var fileContent = File.ReadAllBytes(filePath);
string body = Convert.ToBase64String(fileContent);
string requestData = @"{""Body"":""" + body + @""",""LibraryType"":""" + executorType + @"""}";
var responseFromServer = CreatioClient.ExecutePostRequest(ExecutorUrl, requestData);
Console.WriteLine(responseFromServer);
}

public static int ExecuteCodeFromAssembly(ExecuteAssemblyOptions options) {
try {
Configure(options);
ExecuteCodeFromAssemblyInternal(options);
Console.WriteLine();
Console.WriteLine("Done");
return 0;
} catch (Exception e) {
Console.WriteLine(e.Message);
return 1;
}
return @"{""Body"":""" + body + @""",""LibraryType"":""" + executorType + @"""}";
}
}
}
55 changes: 0 additions & 55 deletions clio/Command/BaseRemoteCommand.cs

This file was deleted.

65 changes: 65 additions & 0 deletions clio/Command/CheckNugetUpdateCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using Clio.Common;
using Clio.Project.NuGet;
using CommandLine;

namespace Clio.Command
{

[Verb("check-nuget-update", Aliases = new string[] { "check" }, HelpText = "Check for package updates in NuGet")]
public class CheckNugetUpdateOptions : EnvironmentOptions
{

[Option('s', "Source", Required = false, HelpText = "Specifies the server URL",
Default = "https://www.nuget.org")]
public string SourceUrl { get; set; }

}

public class CheckNugetUpdateCommand : Command<CheckNugetUpdateOptions>
{
private INuGetManager _nugetManager;

public CheckNugetUpdateCommand(INuGetManager nugetManager) {
nugetManager.CheckArgumentNull(nameof(nugetManager));
_nugetManager = nugetManager;
}

private static string GetNameAndVersion(string name, PackageVersion version) {
return $"{name} ({version})";
}

private static string GetPackageUpdateMessage(PackageForUpdate packageForUpdate) {
LastVersionNugetPackages lastVersionNugetPackages = packageForUpdate.LastVersionNugetPackages;
PackageInfo applPkg = packageForUpdate.ApplicationPackage;
string pkgName = applPkg.Descriptor.Name;
string message = $" {GetNameAndVersion(pkgName, applPkg.Version)} --> " +
$"{GetNameAndVersion(pkgName, lastVersionNugetPackages.Last.Version)}";
return lastVersionNugetPackages.LastIsStable || lastVersionNugetPackages.StableIsNotExists
? message
: $"{message}; Stable: {GetNameAndVersion(pkgName, lastVersionNugetPackages.Stable.Version)}";
}

private static void PrintPackagesForUpdate(IEnumerable<PackageForUpdate> packagesForUpdate) {
Console.WriteLine("Packages for update:");
foreach (PackageForUpdate packageForUpdate in packagesForUpdate) {
Console.WriteLine(GetPackageUpdateMessage(packageForUpdate));
}
}

public override int Execute(CheckNugetUpdateOptions options) {
try {
IEnumerable<PackageForUpdate> packagesForUpdate = _nugetManager.GetPackagesForUpdate(options.SourceUrl);
PrintPackagesForUpdate(packagesForUpdate);
Console.WriteLine("Done");
return 0;
} catch (Exception e) {
Console.WriteLine(e.Message);
return 1;
}
}

}

}
28 changes: 6 additions & 22 deletions clio/Command/DeletePackageCommand.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,19 @@
namespace Clio.Command.PackageCommand
{
using System;
using System.Threading;
using Clio.Common;

public class DeletePackageCommand : BaseRemoteCommand
public class DeletePackageCommand : RemoteCommand<DeletePkgOptions>
{

public DeletePackageCommand(IApplicationClient applicationClient)
: base(applicationClient) {
public DeletePackageCommand(IApplicationClient applicationClient, EnvironmentSettings settings)
: base(applicationClient, settings) {
}

private static string DeletePackageUrl => AppUrl + @"/ServiceModel/AppInstallerService.svc/DeletePackage";
protected override string ServicePath => @"/ServiceModel/AppInstallerService.svc/DeletePackage";

private void DeletePackage(string code) {
Console.WriteLine("Deleting...");
string deleteRequestData = "\"" + code + "\"";
ApplicationClient.ExecutePostRequest(DeletePackageUrl, deleteRequestData, Timeout.Infinite);
Console.WriteLine("Deleted.");
protected override string GetResponseData(DeletePkgOptions options) {
return "\"" + options.Name + "\"";
}

public int Delete(DeletePkgOptions options) {
try {
Configure(options);
DeletePackage(options.Name);
Console.WriteLine("Done");
return 0;
} catch (Exception e) {
Console.WriteLine(e.Message);
return 1;
}
}
}
}
34 changes: 13 additions & 21 deletions clio/Command/FeatureCommand.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System;
using Clio.Feature;
using Clio.Common;
using CommandLine;

namespace Clio.Command
{
[Verb("set-feature", Aliases = new[] { "feature" }, HelpText = "Set feature state")]
internal class FeatureOptions : EnvironmentOptions
{

[Value(0, MetaName = "Code", Required = true, HelpText = "Feature code")]
public string Code { get; set; }

Expand All @@ -15,27 +16,18 @@ internal class FeatureOptions : EnvironmentOptions

}

class FeatureCommand : BaseRemoteCommand
internal class FeatureCommand : RemoteCommand<FeatureOptions>
{
public static int SetFeatureState(FeatureOptions options) {
try {
Configure(options);
var fm = new FeatureModerator(CreatioClient);
switch (options.State) {
case 0:
fm.SwitchFeatureOff(options.Code);
break;
case 1:
fm.SwitchFeatureOn(options.Code);
break;
default:
throw new NotSupportedException($"You use not supported feature state type {options.State}");
}
} catch (Exception exception) {
Console.WriteLine(exception.Message);
return 1;
}
return 0;

protected override string ServicePath => @"/rest/FeatureStateService/SetFeatureState";

public FeatureCommand(IApplicationClient applicationClient, EnvironmentSettings settings)
: base(applicationClient, settings) {
}

protected override string GetResponseData(FeatureOptions options) {
return "{" + $"\"code\":\"{options.Code}\",\"state\":\"{options.State}\"" + "}";
}

}
}

0 comments on commit 743b4b3

Please sign in to comment.