Bump, currently downloads 2.3.1 zip and latest to needed client patcher based on repo json

This commit is contained in:
CWX 2022-05-30 00:49:58 +01:00
parent e301ef9d05
commit 43098c7578
3 changed files with 63 additions and 0 deletions

View File

@ -2,6 +2,9 @@
using SPT_AKI_Installer.Aki.Helper;
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace SPT_AKI_Installer.Aki.Core
{
@ -11,12 +14,27 @@ namespace SPT_AKI_Installer.Aki.Core
public static class SPTinstaller
{
private static string akiLink;
private static string patcherLink;
static void Main()
{
string targetPath = Environment.CurrentDirectory;
#if DEBUG
targetPath = @"D:\install";
#endif
_ = DownloadFileAsync(targetPath, "https://dev.sp-tarkov.com/api/v1/repos/CWX/Installer_Test/raw/ClientVersions.json", "/ClientVersions.json");
Console.ReadKey();
ReadJson(targetPath);
Console.ReadKey();
_ = DownloadFileAsync(targetPath, akiLink, "/RELEASE-SPT-2.3.1-17349.zip");
Console.ReadKey();
_ = DownloadFileAsync(targetPath, patcherLink, "/Patcher_12.12.15.18103_to_12.12.15.17349.zip");
Console.ReadKey();
SpectreHelper.Figlet("SPT-AKI INSTALLER", Color.Yellow);
PreCheckHelper.GameCheck(out string originalGamePath);
@ -120,5 +138,37 @@ namespace SPT_AKI_Installer.Aki.Core
Console.ReadKey();
Environment.Exit(0);
}
// https://dev.sp-tarkov.com/api/v1/repos/CWX/Installer_Test/raw/ClientVersions.json
// https://dev.sp-tarkov.com/CWX/Installer_Test/src/branch/master/ClientVersions.json
static async Task DownloadFileAsync(string targetFilePath, string targetLink, string newFileName)
{
using (var httpClient = new HttpClient())
{
await httpClient.DownloadFile(targetLink, Path.Join(targetFilePath, newFileName));
}
}
static void ReadJson(string targetPath)
{
var json = FileHelper.FindFile(targetPath, "ClientVersions.json");
var text = File.ReadAllText(json);
dynamic result = JsonConvert.DeserializeObject<object>(text);
akiLink = result.client18103.AKI;
patcherLink = result.client18103.PATCHER;
Console.WriteLine(akiLink);
Console.WriteLine(patcherLink);
}
public static async Task DownloadFile(this HttpClient client, string address, string fileName)
{
using (var response = await client.GetAsync(address))
using (var stream = await response.Content.ReadAsStreamAsync())
using (var file = File.OpenWrite(fileName))
{
stream.CopyTo(file);
}
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SPT_AKI_Installer.Aki.Helper
{
public class DownloadHelper
{
}
}

View File

@ -12,6 +12,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SharpCompress" Version="0.31.0" />
<PackageReference Include="Spectre.Console" Version="0.44.0" />
</ItemGroup>