manager: migrate base project structure & deps
This commit is contained in:
@@ -6,25 +6,25 @@ namespace ModpackUpdater;
|
||||
public class ModpackConfig
|
||||
{
|
||||
public bool Maintenance { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string UpdateUrl { get; set; }
|
||||
public string InstallUrl { get; set; }
|
||||
public string UnleashApiUrl { get; set; }
|
||||
public string UnleashInstanceId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? UpdateUrl { get; set; }
|
||||
public string? InstallUrl { get; set; }
|
||||
public string? UnleashApiUrl { get; set; }
|
||||
public string? UnleashInstanceId { get; set; }
|
||||
public bool PreferDirectLinks { get; set; }
|
||||
public string MinecraftVersion { get; set; }
|
||||
public string RefTag { get; set; }
|
||||
public string? MinecraftVersion { get; set; }
|
||||
public string? RefTag { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public ModLoader ModLoader { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string ConfigUrl { get; private set; }
|
||||
public string? ConfigUrl { get; private set; }
|
||||
|
||||
public static ModpackConfig LoadFromUrl(string url)
|
||||
public static ModpackConfig LoadFromUrl(string? url)
|
||||
{
|
||||
var result = new HttpClient().GetStringAsync(url).Result;
|
||||
var config = JsonConvert.DeserializeObject<ModpackConfig>(result);
|
||||
var config = JsonConvert.DeserializeObject<ModpackConfig>(result) ?? new();
|
||||
config.ConfigUrl = url;
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -9,41 +9,42 @@ public class ModpackInfo
|
||||
private const string FILENAME_MODPACKINFO = "modpack-info.json";
|
||||
|
||||
[JsonConverter(typeof(VersionConverter))]
|
||||
public Version Version { get; set; }
|
||||
public string ConfigUrl { get; set; }
|
||||
public string ExtrasKey { get; set; }
|
||||
public Version? Version { get; set; }
|
||||
public string? ConfigUrl { get; set; }
|
||||
public string? ExtrasKey { get; set; }
|
||||
public InstallOptionValueDictionary Options { get; } = [];
|
||||
|
||||
[JsonIgnore]
|
||||
public string LocaLPath { get; private set; }
|
||||
public string? LocalPath { get; private set; }
|
||||
[JsonIgnore]
|
||||
public bool Exists => File.Exists(GetFilePath(LocaLPath));
|
||||
public bool Exists => LocalPath != null && File.Exists(GetFilePath(LocalPath));
|
||||
|
||||
public void Save()
|
||||
{
|
||||
File.WriteAllText(GetFilePath(LocaLPath), JsonConvert.SerializeObject(this));
|
||||
if (LocalPath != null)
|
||||
File.WriteAllText(GetFilePath(LocalPath), JsonConvert.SerializeObject(this));
|
||||
}
|
||||
|
||||
public void Save(string mcRoot)
|
||||
{
|
||||
LocaLPath = mcRoot;
|
||||
LocalPath = mcRoot;
|
||||
Save();
|
||||
}
|
||||
|
||||
public static ModpackInfo TryLoad(string mcRoot)
|
||||
public static ModpackInfo TryLoad(string? mcRoot)
|
||||
{
|
||||
if (HasModpackInfo(mcRoot))
|
||||
if (mcRoot != null && HasModpackInfo(mcRoot))
|
||||
return Load(mcRoot);
|
||||
return new()
|
||||
{
|
||||
LocaLPath = mcRoot
|
||||
LocalPath = mcRoot
|
||||
};
|
||||
}
|
||||
|
||||
public static ModpackInfo Load(string mcRoot)
|
||||
{
|
||||
var info = JsonConvert.DeserializeObject<ModpackInfo>(File.ReadAllText(GetFilePath(mcRoot)));
|
||||
info.LocaLPath = mcRoot;
|
||||
var info = JsonConvert.DeserializeObject<ModpackInfo>(File.ReadAllText(GetFilePath(mcRoot))) ?? new();
|
||||
info.LocalPath = mcRoot;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user