using Octokit; using StabilityMatrix.Core.Models.Database; using StabilityMatrix.Core.Models.Progress; using StabilityMatrix.Core.Processes; namespace StabilityMatrix.Core.Models.Packages; public abstract class BasePackage { public string ByAuthor => $"By {Author}"; public abstract string Name { get; } public abstract string DisplayName { get; set; } public abstract string Author { get; } public abstract string Blurb { get; } public abstract string GithubUrl { get; } public abstract string LicenseType { get; } public abstract string LicenseUrl { get; } public abstract string LaunchCommand { get; } public abstract Uri PreviewImageUri { get; } public virtual bool ShouldIgnoreReleases => false; public virtual bool UpdateAvailable { get; set; } public abstract Task DownloadPackage(string version, bool isCommitHash, IProgress? progress = null); public abstract Task InstallPackage(IProgress? progress = null); public abstract Task RunPackage(string installedPackagePath, string arguments); /// /// Shuts down the subprocess, canceling any pending streams. /// public abstract void Shutdown(); /// /// Shuts down the process, returning a Task to wait for output EOF. /// public abstract Task WaitForShutdown(); public abstract Task CheckForUpdates(InstalledPackage package); public abstract Task Update(InstalledPackage installedPackage, IProgress? progress = null, bool includePrerelease = false); public abstract Task> GetReleaseTags(); public abstract List LaunchOptions { get; } public virtual string? ExtraLaunchArguments { get; set; } = null; /// /// The shared folders that this package supports. /// Mapping of to the relative path from the package root. /// public virtual Dictionary? SharedFolders { get; } public abstract Task GetLatestVersion(); public abstract Task> GetAllVersions(bool isReleaseMode = true); public abstract Task?> GetAllCommits(string branch, int page = 1, int perPage = 10); public abstract Task> GetAllBranches(); public abstract Task> GetAllReleases(); public abstract string DownloadLocation { get; } public abstract string InstallLocation { get; set; } public event EventHandler? ConsoleOutput; public event EventHandler? Exited; public event EventHandler? StartupComplete; public void OnConsoleOutput(ProcessOutput output) => ConsoleOutput?.Invoke(this, output); public void OnExit(int exitCode) => Exited?.Invoke(this, exitCode); public void OnStartupComplete(string url) => StartupComplete?.Invoke(this, url); }