Skip to content

Commit

Permalink
Revert "2.0.0" (#17)
Browse files Browse the repository at this point in the history
Reverts #14
  • Loading branch information
OrnarasUS authored Feb 6, 2025
2 parents 6e58df5 + 53beb55 commit 784a020
Show file tree
Hide file tree
Showing 19 changed files with 573 additions and 181 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,26 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Auth GitHub NuGet
run: dotnet nuget add source --username OrnarasUS --password ${{ secrets.TOKEN_GITHUB }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/OrnarasUS/index.json"
- name: Build project
run: dotnet build
- name: Set variables
id: vars
run: echo "nupkg=bin/Debug/$(ls bin/Debug | grep '\.nupkg')" >> $GITHUB_OUTPUT
run: |
echo "nupkg=bin/Debug/$(ls bin/Debug | grep '\.nupkg')" >> $GITHUB_OUTPUT
echo "dll=bin/Debug/net8.0/$(ls bin/Debug/net8.0 | grep '\.dll')" >> $GITHUB_OUTPUT
- name: Publish to NuGet
run: dotnet nuget push ${{ steps.vars.outputs.nupkg }} --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
run: |
dotnet nuget push ${{ steps.vars.outputs.nupkg }} --source "github"
dotnet nuget push ${{ steps.vars.outputs.nupkg }} --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
- name: Publish to GitHub Release
uses: softprops/action-gh-release@v2
with:
repository: OrnarasUS/OrnaLibs.Utils
token: ${{ secrets.PUBLISH_GITHUB_TOKEN }}
files: ${{ steps.vars.outputs.dll }}
name: ${{ github.event.pull_request.title }}
tag_name: ${{ github.event.pull_request.title }}
body: ${{ github.event.pull_request.body }}

27 changes: 0 additions & 27 deletions ActionScheduler/ActionTypes/DailyAction.cs

This file was deleted.

16 changes: 0 additions & 16 deletions ActionScheduler/Builders/ActionBuilder.cs

This file was deleted.

28 changes: 0 additions & 28 deletions ActionScheduler/Builders/DailyBuilder.cs

This file was deleted.

10 changes: 0 additions & 10 deletions ActionScheduler/IExpectedAction.cs

This file was deleted.

59 changes: 0 additions & 59 deletions ActionScheduler/Scheduler.cs

This file was deleted.

47 changes: 47 additions & 0 deletions Application/Base.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
namespace OrnaLibs;

/// <summary>
/// Информация о приложении
/// </summary>
public partial struct Application
{
/// <summary>
/// Регистрация приложения
/// </summary>
public void Registration()
{
if (OperatingSystem.IsWindows())
RegistrationWindows();
}

/// <summary>
/// Удаление записи о приложении
/// </summary>
public void Unregistration()
{
if (OperatingSystem.IsWindows())
RegistryKeys.LocalMachineUninstallX86.DeleteSubKey(Name, false);
}

/// <summary>
/// Регистрация сервиса
/// </summary>
public void RegistrationService()
{
if (string.IsNullOrWhiteSpace(ServicePath))
throw new ArgumentNullException(nameof(ServicePath));
if (OperatingSystem.IsWindows())
CreateWindowsService();
}

/// <summary>
/// Удаление сервиса
/// </summary>
public void UnregistrationService()
{
if (string.IsNullOrWhiteSpace(ServicePath))
throw new ArgumentNullException(nameof(ServicePath));
if (OperatingSystem.IsWindows())
Utils.CMD($"sc stop {Name} && sc delete {Name}");
}
}
49 changes: 49 additions & 0 deletions Application/Properties.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace OrnaLibs;

public partial struct Application
{
/// <summary>
/// Название приложения
/// </summary>
public string Name { get; init; }

/// <summary>
/// Версия приложения
/// </summary>
public Version? Version { get; init; }

/// <summary>
/// Отображаемое название приложения
/// </summary>
public string DisplayName { get; init; }

/// <summary>
/// Разработчик приложения (Организация в GitHub)
/// </summary>
public string CompanyName { get; init; }

/// <summary>
/// Путь до исполняемого файла
/// </summary>
public string AppPath { get; init; }

/// <summary>
/// Путь до иконки приложения
/// </summary>
public string IconPath { get; init; }

/// <summary>
/// Путь до конфигуратора
/// </summary>
public string Configurator { get; init; }

/// <summary>
/// Путь до деинсталятора
/// </summary>
public string Uninstaller { get; init; }

/// <summary>
/// Путь до сервис-приложения
/// </summary>
public string ServicePath { get; init; }
}
38 changes: 38 additions & 0 deletions Application/Windows.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Microsoft.Win32;
using System.Runtime.Versioning;
using System.Text;

namespace OrnaLibs;

public partial struct Application
{
[SupportedOSPlatform("windows")]
private void RegistrationWindows()
{
using var reg = RegistryKeys.LocalMachineUninstallX86.CreateSubKey(Name, true);
reg.SetValue("Publisher", CompanyName, RegistryValueKind.String);
reg.SetValue("EstimatedSize", new FileInfo(AppPath).Length / 1024, RegistryValueKind.DWord);
reg.SetValue("InstallLocation", Path.GetDirectoryName(AppPath)!, RegistryValueKind.String);
if (Version is { })
reg.SetValue("DisplayVersion", Version.ToString(), RegistryValueKind.String);
if (!string.IsNullOrWhiteSpace(DisplayName))
reg.SetValue("DisplayName", DisplayName, RegistryValueKind.String);
if (!string.IsNullOrWhiteSpace(IconPath))
reg.SetValue("DisplayIcon", IconPath, RegistryValueKind.String);
if (!string.IsNullOrWhiteSpace(Configurator))
reg.SetValue("ModifyPath", Configurator, RegistryValueKind.String);
if (!string.IsNullOrWhiteSpace(Uninstaller))
reg.SetValue("UninstallString", Uninstaller, RegistryValueKind.String);
}

[SupportedOSPlatform("windows")]
private void CreateWindowsService()
{
var builder = new StringBuilder("New-Service");
builder.AppendFormat(" -Name \"{0}\"", Name);
builder.AppendFormat(" -DisplayName \"{0}\"", DisplayName);
builder.AppendFormat(" -BinaryPathName \"{0}\"", ServicePath);
builder.AppendFormat(" -StartupType \"{0}\"", "Automatic");
Utils.PowerShell(builder.ToString());
}
}
1 change: 1 addition & 0 deletions ConsoleUI.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using OrnaLibs.DataTypes;
using System.Globalization;

namespace OrnaLibs
Expand Down
28 changes: 28 additions & 0 deletions DataTypes/RequiredDirectory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace OrnaLibs.DataTypes
{
public struct RequiredDirectory(string path)
{
private void RecursiveCreate()
{
var elems = new Queue<string>(path.Split(Path.DirectorySeparatorChar));
var _path = elems.Dequeue();
do
{
_path = Path.Combine(_path, elems.Dequeue());
if(!Directory.Exists(_path))
Directory.CreateDirectory(_path);
}
while (elems.Count > 0);
}

public override string ToString()
{
if (!Directory.Exists(path))
RecursiveCreate();
return path;
}

public static implicit operator RequiredDirectory(string path) => new(path);
public static implicit operator string(RequiredDirectory dir) => dir.ToString();
}
}
1 change: 0 additions & 1 deletion Managers/TaskScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/// <summary>
/// Планировщик задач
/// </summary>
[Obsolete("Рекомендуется использовать ActionScheduler")]
public static class TaskScheduler
{
private static TimeOnly?[] times = null!;
Expand Down
Loading

0 comments on commit 784a020

Please sign in to comment.