Skip to content

Commit

Permalink
Update to v0.1.0-rc1 (#38)
Browse files Browse the repository at this point in the history
* Handle IOException separately in ApiProcedures

Caught IOException explicitly to provide more granular error handling. This allows to throw the IOException immediately while preserving the behavior for general exceptions. Adjusted throttler release comment to remove redundant text.

* Enable output redirection in ApiProcedures

This commit updates the process start information in ApiProcedures.cs to redirect standard output and error. It also sets UseShellExecute to false and CreateNoWindow to true for better process control and visibility.

* Merge pull request #37

* Add support for bug tracking and enhance profile management
* Add ability to change installation directory dynamically

---------

Co-authored-by: Akemiko <[email protected]>
  • Loading branch information
GamerVII-NET and Arsenii1109 authored Sep 1, 2024
1 parent ec929a3 commit b37ad25
Show file tree
Hide file tree
Showing 32 changed files with 600 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/Gml.Client/Helpers/SystemIOProcedures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ public Task RemoveFiles(ProfileReadInfoDto profileInfo)
{
try
{
string[] allowedPaths =
List<string> allowedPaths =
[
Path.Combine(_installationDirectory, "clients", profileInfo.ProfileName, "saves"),
Path.Combine(_installationDirectory, "clients", profileInfo.ProfileName, "logs"),
Path.Combine(_installationDirectory, "clients", profileInfo.ProfileName, "crash-reports")
];

allowedPaths.AddRange(profileInfo.WhiteListFolders.Select(path => Path.Combine(_installationDirectory, "clients", profileInfo.ProfileName, Path.Combine(path.Path.Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries)))));

var profilePath = Path.Combine(_installationDirectory, "clients", profileInfo.ProfileName);

var directoryInfo = new DirectoryInfo(profilePath);
Expand Down
1 change: 0 additions & 1 deletion src/Gml.Client/IGmlClientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public interface IGmlClientManager : IDisposable
Task<IVersionFile?> GetActualVersion(OsType osType, Architecture osArch);
Task UpdateCurrentLauncher((IVersionFile? ActualVersion, bool IsActuallVersion) versionInfo, OsType osType,
string originalFileName);

Task OpenServerConnection(IUser user);
void ChangeInstallationFolder(string installationDirectory);
}
8 changes: 8 additions & 0 deletions src/Gml.Core.Interfaces/Bootstrap/IBootstrapProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace GmlCore.Interfaces.Bootstrap;

public interface IBootstrapProgram
{
string Name { get; set; }
string Version { get; set; }
int MajorVersion { get; set; }
}
1 change: 1 addition & 0 deletions src/Gml.Core.Interfaces/Enums/AuthType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public enum AuthType
EasyCabinet = 4,
UnicoreCMS = 5,
CustomEndpoint = 6,
NamelessMC = 7,
}
1 change: 1 addition & 0 deletions src/Gml.Core.Interfaces/IGmlManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace GmlCore.Interfaces
public interface IGmlManager
{
public ILauncherInfo LauncherInfo { get; }
public IBugTrackerProcedures BugTracker { get; }
public IProfileProcedures Profiles { get; }
public IFileStorageProcedures Files { get; }
public IServicesIntegrationProcedures Integrations { get; }
Expand Down
18 changes: 18 additions & 0 deletions src/Gml.Core.Interfaces/Launcher/IBugInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using GmlCore.Interfaces.Sentry;

namespace GmlCore.Interfaces.Launcher;

public interface IBugInfo
{
string Id { get; set; }
public string? PcName { get; set; }
public string? Username { get; set; }
public IMemoryInfo? MemoryInfo { get; set; }
public IEnumerable<IExceptionReport?>? Exceptions { get; set; }
public DateTime SendAt { get; set; }
public string? IpAddress { get; set; }
public string? OsVeriosn { get; set; }
public string? OsIdentifier { get; set; }
}
4 changes: 3 additions & 1 deletion src/Gml.Core.Interfaces/Launcher/IGameProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ public interface IGameProfile : IDisposable
string BackgroundImageKey { get; set; }
string Description { get; set; }
List<IFileInfo>? FileWhiteList { get; set; }
List<IFolderInfo>? FolderWhiteList { get; set; }
List<IProfileServer> Servers { get; set; }
DateTimeOffset CreateDate { get; set; }
string? JvmArguments { get; set; }
string? GameArguments { get; set; }
ProfileState State { get; set; }

Task<bool> ValidateProfile();
Expand All @@ -46,6 +48,6 @@ public interface IGameProfile : IDisposable
void RemoveServer(IProfileServer server);
Task CreateModsFolder();
Task<IEnumerable<IFileInfo>> GetProfileFiles(string osName, string osArchitecture);
Task<IFileInfo[]> GetAllProfileFiles();
Task<IFileInfo[]> GetAllProfileFiles(bool needRestoreCache);
}
}
2 changes: 2 additions & 0 deletions src/Gml.Core.Interfaces/Launcher/IGmlSettings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Net.Http;
using GmlCore.Interfaces.Enums;
using GmlCore.Interfaces.Procedures;
using GmlCore.Interfaces.Storage;
Expand All @@ -9,6 +10,7 @@ public interface IGmlSettings
public string Name { get; }
public string BaseDirectory { get; }
public string InstallationDirectory { get; }
public HttpClient HttpClient { get; }
IStorageSettings StorageSettings { get; set; }
string SecurityKey { get; set; }
ISystemProcedures SystemProcedures { get; }
Expand Down
13 changes: 13 additions & 0 deletions src/Gml.Core.Interfaces/Mods/IMod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.IO;

namespace GmlCore.Interfaces.Mods;

public interface IMod
{
string Name { get; set; }
string Url { get; set; }
Stream Icon { get; set; }
IEnumerable<string> Files { get; set; }
IEnumerable<IMod> Dependencies { get; set; }
}
13 changes: 13 additions & 0 deletions src/Gml.Core.Interfaces/Procedures/IBugTrackerProcedures.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using GmlCore.Interfaces.Launcher;

namespace GmlCore.Interfaces.Procedures;

public interface IBugTrackerProcedures
{
void CaptureException(IBugInfo bugInfo);
Task<IEnumerable<IBugInfo>> GetAllBugs();
Task<IBugInfo> GetBugId(string id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using GmlCore.Interfaces.Bootstrap;
using GmlCore.Interfaces.Enums;
using GmlCore.Interfaces.Launcher;
using GmlCore.Interfaces.System;
Expand All @@ -17,9 +18,11 @@ public interface IGameDownloaderProcedures
IObservable<string> LoadLog { get;}
IObservable<Exception> LoadException { get;}

Task<string> DownloadGame(string version, string? launchVersion, GameLoader loader);
Task<Process> CreateProcess(IStartupOptions startupOptions, IUser user, bool needDownload, string[] jvmArguments);
Task<IFileInfo[]> GetAllFiles();
Task<string> DownloadGame(string version, string? launchVersion, GameLoader loader,
IBootstrapProgram? bootstrapProgram);
Task<Process> CreateProcess(IStartupOptions startupOptions, IUser user, bool needDownload,
string[] jvmArguments, string[] gameArguments);
Task<IFileInfo[]> GetAllFiles(bool needRestoreCache);
bool GetLauncher(string launcherKey, out object launcher);
Task<IEnumerable<IFileInfo>> GetLauncherFiles(string osName, string osArchitecture);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gml.Core.Interfaces/Procedures/ILauncherProcedures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace GmlCore.Interfaces.Procedures;
public interface ILauncherProcedures
{
Task<string> CreateVersion(IVersionFile version, ILauncherBuild launcherBuild);
Task Build(string version, string[] versions);
Task Build(string version, string[] osNameVersions);
IObservable<string> BuildLogs { get; }
bool CanCompile(string version, out string message);
Task<IEnumerable<string>> GetPlatforms();
Expand Down
12 changes: 12 additions & 0 deletions src/Gml.Core.Interfaces/Procedures/IModsProcedures.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using GmlCore.Interfaces.Launcher;
using GmlCore.Interfaces.Mods;

namespace GmlCore.Interfaces.Procedures;

public interface IModsProcedures
{
Task<IEnumerable<IMod>> GetModsAsync(IGameProfile profile);
Task<IEnumerable<IMod>> GetModsAsync(IGameProfile profile, string name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public interface INotificationProcedures
Task SendMessage(string message, NotificationType type);
Task SendMessage(string message, Exception exception);
Task Retore();
Task Clear();
}
13 changes: 10 additions & 3 deletions src/Gml.Core.Interfaces/Procedures/IProfileProcedures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Threading.Tasks;
using Gml.Web.Api.Domains.System;
using GmlCore.Interfaces.Bootstrap;
using GmlCore.Interfaces.Enums;
using GmlCore.Interfaces.Launcher;
using GmlCore.Interfaces.System;
Expand All @@ -16,6 +17,7 @@ public interface IProfileProcedures
public delegate void ProgressPackChanged(ProgressChangedEventArgs e);

IObservable<double> PackChanged { get; }
IObservable<int> ProfilesChanged { get; }
Task AddProfile(IGameProfile? profile);

Task<IGameProfile?> AddProfile(string name, string version, string loaderVersion, GameLoader loader,
Expand All @@ -31,7 +33,7 @@ public interface IProfileProcedures
Task<bool> ValidateProfileAsync(IGameProfile baseProfile);
bool ValidateProfile();
Task SaveProfiles();
Task DownloadProfileAsync(IGameProfile baseProfile);
Task DownloadProfileAsync(IGameProfile baseProfile, IBootstrapProgram? version = default);
Task<IEnumerable<IFileInfo>> GetProfileFiles(IGameProfile baseProfile);
Task<IGameProfile?> GetProfile(string profileName);
Task<IEnumerable<IGameProfile>> GetProfiles();
Expand All @@ -42,13 +44,18 @@ public interface IProfileProcedures
Task RemoveFileFromWhiteList(IGameProfile profile, IFileInfo file);
Task UpdateProfile(IGameProfile profile, string newProfileName, Stream? icon, Stream? backgroundImage,
string updateDtoDescription, bool isEnabled,
string jvmArguments);
string jvmArguments, string gameArguments);
Task<string[]> InstallAuthLib(IGameProfile profile);
Task<IGameProfileInfo?> GetCacheProfile(IGameProfile baseProfile);
Task SetCacheProfile(IGameProfileInfo profile);
Task CreateModsFolder(IGameProfile profile);
Task<IEnumerable<IFileInfo>> GetProfileFiles(IGameProfile profile, string osName, string osArchitecture);
Task<IFileInfo[]> GetAllProfileFiles(IGameProfile baseProfile);
Task<IFileInfo[]> GetAllProfileFiles(IGameProfile baseProfile, bool needRestoreCache);
Task<IEnumerable<string>> GetAllowVersions(GameLoader result, string? minecraftVersion);
Task ChangeBootstrapProgram(IGameProfile testGameProfile, IBootstrapProgram version);
Task AddFolderToWhiteList(IGameProfile profile, IFolderInfo folder);
Task RemoveFolderFromWhiteList(IGameProfile profile, IFolderInfo folder);
Task RemoveFolderFromWhiteList(IGameProfile profile, IEnumerable<IFolderInfo> folders);
Task AddFolderToWhiteList(IGameProfile profile, IEnumerable<IFolderInfo> folders);
}
}
3 changes: 3 additions & 0 deletions src/Gml.Core.Interfaces/Procedures/ISystemProcedures.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using GmlCore.Interfaces.Bootstrap;
using GmlCore.Interfaces.Launcher;

namespace GmlCore.Interfaces.Procedures
Expand All @@ -17,5 +19,6 @@ public interface ISystemProcedures
Task DownloadFileAsync(string url, string destinationFilePath);
void ExtractZipFile(string zipFilePath, string extractPath);
void SetFileExecutable(string filePath);
Task<IEnumerable<IBootstrapProgram>> GetJavaVersions();
}
}
15 changes: 15 additions & 0 deletions src/Gml.Core.Interfaces/Sentry/IExceptionReport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections.Generic;

namespace GmlCore.Interfaces.Sentry;

public interface IExceptionReport
{
public string Type { get; set; }
public string ValueData { get; set; }
public string Module { get; set; }
public int ThreadId { get; set; }
public int Id { get; set; }
public bool Crashed { get; set; }
public bool Current { get; set; }
public IEnumerable<IStackTrace> StackTrace { get; set; }
}
14 changes: 14 additions & 0 deletions src/Gml.Core.Interfaces/Sentry/IMemoryInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;

namespace GmlCore.Interfaces.Sentry;

public interface IMemoryInfo
{
public long AllocatedBytes { get; set; }
public long HighMemoryLoadThresholdBytes { get; set; }
public long TotalAvailableMemoryBytes { get; set; }
public int FinalizationPendingCount { get; set; }
public bool Compacted { get; set; }
public bool Concurrent { get; set; }
public List<double> PauseDurations { get; set; }
}
15 changes: 15 additions & 0 deletions src/Gml.Core.Interfaces/Sentry/IStackTrace.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace GmlCore.Interfaces.Sentry;

public interface IStackTrace
{
public string Filename { get; set; }
public string Function { get; set; }
public int Lineno { get; set; }
public int Colno { get; set; }
public string AbsPath { get; set; }
public bool InApp { get; set; }
public string Package { get; set; }
public string InstructionAddr { get; set; }
public string AddrMode { get; set; }
public string FunctionId { get; set; }
}
6 changes: 6 additions & 0 deletions src/Gml.Core.Interfaces/System/IFolderInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace GmlCore.Interfaces.System;

public interface IFolderInfo
{
public string Path { get; set; }
}
12 changes: 12 additions & 0 deletions src/Gml.Web.Api.Domains/Sentry/SentryBugs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Generic;
using GmlCore.Interfaces.Launcher;

namespace Gml.Web.Api.Domains.Sentry;

public class SentryBugs
{
public string Exception { get; set; }
public long Users { get; set; }
public long Errors { get; set; }
public IEnumerable<IBugInfo> Bugs { get; set; }
}
9 changes: 9 additions & 0 deletions src/Gml.Web.Api.Dto/Files/FolderWhiteListDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using GmlCore.Interfaces.System;

namespace Gml.Web.Api.Dto.Files;

public class FolderWhiteListDto
{
public string ProfileName { get; set; }
public string Path { get; set; }
}
6 changes: 6 additions & 0 deletions src/Gml.Web.Api.Dto/Files/ProfileFolderReadDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Gml.Web.Api.Dto.Files;

public class ProfileFolderReadDto
{
public string Path { get; set; }
}
1 change: 0 additions & 1 deletion src/Gml.Web.Api.Dto/Gml.Web.Api.Dto.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@
<ItemGroup>
<ProjectReference Include="..\Gml.Web.Api.Domains\Gml.Web.Api.Domains.csproj"/>
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/Gml.Web.Api.Dto/Profile/ProfileReadDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ProfileReadDto
public string IconBase64 { get; set; }
public string Background { get; set; }
public string JvmArguments { get; set; }
public string GameArguments { get; set; }
public ProfileState State { get; set; }
public int Loader { get; set; }
public List<ServerReadDto> Servers { get; set; } = [];
Expand Down
3 changes: 3 additions & 0 deletions src/Gml.Web.Api.Dto/Profile/ProfileReadInfoDto.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Gml.Web.Api.Dto.Files;
using GmlCore.Interfaces.Enums;
using GmlCore.Interfaces.System;

namespace Gml.Web.Api.Dto.Profile;

Expand All @@ -15,9 +16,11 @@ public class ProfileReadInfoDto
public string Description { get; set; }
public string Arguments { get; set; }
public string JvmArguments { get; set; }
public string GameArguments { get; set; }
public bool HasUpdate { get; set; }
public ProfileState State { get; set; }
public List<ProfileFileReadDto> Files { get; set; }
public List<ProfileFolderReadDto> WhiteListFolders { get; set; }
public List<ProfileFileReadDto> WhiteListFiles { get; set; }
public string Background { get; set; }
}
1 change: 1 addition & 0 deletions src/Gml.Web.Api.Dto/Profile/ProfileUpdateDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public class ProfileUpdateDto
public string IconBase64 { get; set; } = null!;
public string BackgroundImageKey { get; set; }
public string JvmArguments { get; set; }
public string GameArguments { get; set; }
}
11 changes: 11 additions & 0 deletions src/Gml.Web.Api.Dto/Sentry/BaseSentryError.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using Gml.Web.Api.Domains.Sentry;

namespace Gml.Web.Api.Dto.Sentry;

public class BaseSentryError
{
public IEnumerable<SentryBugs> Bugs { get; set; }
public long CountUsers { get; set; }
public long Count { get; set; }
}
Loading

0 comments on commit b37ad25

Please sign in to comment.