mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Rework DeployManager
This commit is contained in:
parent
2b646e2b55
commit
d76d7b42e4
@ -38,11 +38,11 @@ namespace Bloxstrap
|
|||||||
public static bool IsMenuLaunch { get; private set; } = false;
|
public static bool IsMenuLaunch { get; private set; } = false;
|
||||||
public static string[] LaunchArgs { get; private set; } = null!;
|
public static string[] LaunchArgs { get; private set; } = null!;
|
||||||
|
|
||||||
|
|
||||||
public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
||||||
|
|
||||||
// singletons
|
// singletons
|
||||||
public static readonly Logger Logger = new();
|
public static readonly Logger Logger = new();
|
||||||
|
public static readonly DeployManager DeployManager = new();
|
||||||
public static readonly JsonManager<Settings> Settings = new();
|
public static readonly JsonManager<Settings> Settings = new();
|
||||||
public static readonly JsonManager<State> State = new();
|
public static readonly JsonManager<State> State = new();
|
||||||
public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All });
|
public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All });
|
||||||
@ -207,7 +207,7 @@ namespace Bloxstrap
|
|||||||
if (!IsFirstRun)
|
if (!IsFirstRun)
|
||||||
ShouldSaveConfigs = true;
|
ShouldSaveConfigs = true;
|
||||||
|
|
||||||
DeployManager.Channel = Settings.Prop.Channel;
|
DeployManager.SetChannel(Settings.Prop.Channel);
|
||||||
|
|
||||||
// start bootstrapper and show the bootstrapper modal if we're not running silently
|
// start bootstrapper and show the bootstrapper modal if we're not running silently
|
||||||
Bootstrapper bootstrapper = new Bootstrapper(commandLine);
|
Bootstrapper bootstrapper = new Bootstrapper(commandLine);
|
||||||
|
@ -193,7 +193,7 @@ namespace Bloxstrap
|
|||||||
{
|
{
|
||||||
SetStatus("Connecting to Roblox...");
|
SetStatus("Connecting to Roblox...");
|
||||||
|
|
||||||
ClientVersion clientVersion = await DeployManager.GetLastDeploy(App.Settings.Prop.Channel);
|
ClientVersion clientVersion = await App.DeployManager.GetLastDeploy();
|
||||||
_versionGuid = clientVersion.VersionGuid;
|
_versionGuid = clientVersion.VersionGuid;
|
||||||
_versionFolder = Path.Combine(Directories.Versions, _versionGuid);
|
_versionFolder = Path.Combine(Directories.Versions, _versionGuid);
|
||||||
_versionPackageManifest = await PackageManifest.Get(_versionGuid);
|
_versionPackageManifest = await PackageManifest.Get(_versionGuid);
|
||||||
@ -780,7 +780,7 @@ namespace Bloxstrap
|
|||||||
if (_cancelFired)
|
if (_cancelFired)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string packageUrl = $"{DeployManager.BaseUrl}/{_versionGuid}-{package.Name}";
|
string packageUrl = $"{App.DeployManager.BaseUrl}/{_versionGuid}-{package.Name}";
|
||||||
string packageLocation = Path.Combine(Directories.Downloads, package.Signature);
|
string packageLocation = Path.Combine(Directories.Downloads, package.Signature);
|
||||||
string robloxPackageLocation = Path.Combine(Directories.LocalAppData, "Roblox", "Downloads", package.Signature);
|
string robloxPackageLocation = Path.Combine(Directories.LocalAppData, "Roblox", "Downloads", package.Signature);
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ using System.Text.Json;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Bloxstrap.Models;
|
using Bloxstrap.Models;
|
||||||
|
using DiscordRPC;
|
||||||
|
|
||||||
namespace Bloxstrap.Helpers
|
namespace Bloxstrap.Helpers
|
||||||
{
|
{
|
||||||
@ -13,13 +14,13 @@ namespace Bloxstrap.Helpers
|
|||||||
{
|
{
|
||||||
#region Properties
|
#region Properties
|
||||||
public const string DefaultBaseUrl = "https://setup.rbxcdn.com";
|
public const string DefaultBaseUrl = "https://setup.rbxcdn.com";
|
||||||
public static string BaseUrl { get; private set; } = DefaultBaseUrl;
|
|
||||||
|
|
||||||
public const string DefaultChannel = "LIVE";
|
public const string DefaultChannel = "LIVE";
|
||||||
public static string Channel { set => BaseUrl = BuildBaseUrl(value); }
|
|
||||||
|
public string BaseUrl { get; private set; } = DefaultBaseUrl;
|
||||||
|
public string Channel { get; private set; } = DefaultChannel;
|
||||||
|
|
||||||
// basically any channel that has had a deploy within the past month with a windowsplayer build
|
// basically any channel that has had a deploy within the past month with a windowsplayer build
|
||||||
public static readonly List<string> ChannelsAbstracted = new List<string>()
|
public static readonly List<string> ChannelsAbstracted = new()
|
||||||
{
|
{
|
||||||
"LIVE",
|
"LIVE",
|
||||||
"ZNext",
|
"ZNext",
|
||||||
@ -28,7 +29,7 @@ namespace Bloxstrap.Helpers
|
|||||||
};
|
};
|
||||||
|
|
||||||
// why not?
|
// why not?
|
||||||
public static readonly List<string> ChannelsAll = new List<string>()
|
public static readonly List<string> ChannelsAll = new()
|
||||||
{
|
{
|
||||||
"LIVE",
|
"LIVE",
|
||||||
"ZAvatarTeam",
|
"ZAvatarTeam",
|
||||||
@ -50,13 +51,22 @@ namespace Bloxstrap.Helpers
|
|||||||
};
|
};
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static string BuildBaseUrl(string channel) => channel == DefaultChannel ? DefaultBaseUrl : $"{DefaultBaseUrl}/channel/{channel.ToLower()}";
|
public void SetChannel(string channel)
|
||||||
|
|
||||||
public static async Task<ClientVersion> GetLastDeploy(string channel, bool timestamp = false)
|
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine($"[DeployManager::GetLastDeploy] Getting deploy info for channel {channel} (timestamp={timestamp})");
|
if (Channel == channel)
|
||||||
|
return;
|
||||||
|
|
||||||
HttpResponseMessage deployInfoResponse = await App.HttpClient.GetAsync($"https://clientsettings.roblox.com/v2/client-version/WindowsPlayer/channel/{channel}");
|
App.Logger.WriteLine($"[DeployManager::SetChannel] Set channel to {Channel}");
|
||||||
|
|
||||||
|
Channel = channel;
|
||||||
|
BaseUrl = channel == DefaultChannel ? DefaultBaseUrl : $"{DefaultBaseUrl}/channel/{channel.ToLower()}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<ClientVersion> GetLastDeploy(bool timestamp = false)
|
||||||
|
{
|
||||||
|
App.Logger.WriteLine($"[DeployManager::GetLastDeploy] Getting deploy info for channel {Channel} (timestamp={timestamp})");
|
||||||
|
|
||||||
|
HttpResponseMessage deployInfoResponse = await App.HttpClient.GetAsync($"https://clientsettings.roblox.com/v2/client-version/WindowsPlayer/channel/{Channel}");
|
||||||
|
|
||||||
string rawResponse = await deployInfoResponse.Content.ReadAsStringAsync();
|
string rawResponse = await deployInfoResponse.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
@ -73,7 +83,7 @@ namespace Bloxstrap.Helpers
|
|||||||
$"\tResponse: {rawResponse}"
|
$"\tResponse: {rawResponse}"
|
||||||
);
|
);
|
||||||
|
|
||||||
throw new Exception($"Could not get latest deploy for channel {channel}! (HTTP {deployInfoResponse.StatusCode})");
|
throw new Exception($"Could not get latest deploy for channel {Channel}! (HTTP {deployInfoResponse.StatusCode})");
|
||||||
}
|
}
|
||||||
|
|
||||||
App.Logger.WriteLine($"[DeployManager::GetLastDeploy] Got JSON: {rawResponse}");
|
App.Logger.WriteLine($"[DeployManager::GetLastDeploy] Got JSON: {rawResponse}");
|
||||||
@ -85,8 +95,7 @@ namespace Bloxstrap.Helpers
|
|||||||
{
|
{
|
||||||
App.Logger.WriteLine("[DeployManager::GetLastDeploy] Getting timestamp...");
|
App.Logger.WriteLine("[DeployManager::GetLastDeploy] Getting timestamp...");
|
||||||
|
|
||||||
string channelUrl = BuildBaseUrl(channel);
|
string manifestUrl = $"{BaseUrl}/{clientVersion.VersionGuid}-rbxPkgManifest.txt";
|
||||||
string manifestUrl = $"{channelUrl}/{clientVersion.VersionGuid}-rbxPkgManifest.txt";
|
|
||||||
|
|
||||||
// get an approximate deploy time from rbxpkgmanifest's last modified date
|
// get an approximate deploy time from rbxpkgmanifest's last modified date
|
||||||
HttpResponseMessage pkgResponse = await App.HttpClient.GetAsync(manifestUrl);
|
HttpResponseMessage pkgResponse = await App.HttpClient.GetAsync(manifestUrl);
|
||||||
@ -95,7 +104,7 @@ namespace Bloxstrap.Helpers
|
|||||||
{
|
{
|
||||||
string lastModified = values.First();
|
string lastModified = values.First();
|
||||||
App.Logger.WriteLine($"[DeployManager::GetLastDeploy] {manifestUrl} - Last-Modified: {lastModified}");
|
App.Logger.WriteLine($"[DeployManager::GetLastDeploy] {manifestUrl} - Last-Modified: {lastModified}");
|
||||||
clientVersion.Timestamp = DateTime.Parse(lastModified);
|
clientVersion.Timestamp = DateTime.Parse(lastModified).ToLocalTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ namespace Bloxstrap.Helpers.RSMM
|
|||||||
|
|
||||||
public static async Task<PackageManifest> Get(string versionGuid)
|
public static async Task<PackageManifest> Get(string versionGuid)
|
||||||
{
|
{
|
||||||
string pkgManifestUrl = $"{DeployManager.BaseUrl}/{versionGuid}-rbxPkgManifest.txt";
|
string pkgManifestUrl = $"{App.DeployManager.BaseUrl}/{versionGuid}-rbxPkgManifest.txt";
|
||||||
var pkgManifestData = await App.HttpClient.GetStringAsync(pkgManifestUrl);
|
var pkgManifestData = await App.HttpClient.GetStringAsync(pkgManifestUrl);
|
||||||
|
|
||||||
return new PackageManifest(pkgManifestData);
|
return new PackageManifest(pkgManifestData);
|
||||||
|
@ -39,13 +39,14 @@ namespace Bloxstrap.ViewModels
|
|||||||
ChannelDeployInfo = null;
|
ChannelDeployInfo = null;
|
||||||
OnPropertyChanged(nameof(ChannelDeployInfo));
|
OnPropertyChanged(nameof(ChannelDeployInfo));
|
||||||
|
|
||||||
ClientVersion info = await DeployManager.GetLastDeploy(channel, true);
|
App.DeployManager.SetChannel(channel);
|
||||||
|
ClientVersion info = await App.DeployManager.GetLastDeploy(true);
|
||||||
|
|
||||||
ChannelDeployInfo = new DeployInfo
|
ChannelDeployInfo = new DeployInfo
|
||||||
{
|
{
|
||||||
Version = info.Version,
|
Version = info.Version,
|
||||||
VersionGuid = info.VersionGuid,
|
VersionGuid = info.VersionGuid,
|
||||||
Timestamp = info.Timestamp?.ToString("MM/dd/yyyy h:mm:ss tt", App.CultureFormat)!
|
Timestamp = info.Timestamp?.ToString("dddd, d MMMM yyyy 'at' h:mm:ss tt", App.CultureFormat)!
|
||||||
};
|
};
|
||||||
|
|
||||||
OnPropertyChanged(nameof(ChannelDeployInfo));
|
OnPropertyChanged(nameof(ChannelDeployInfo));
|
||||||
|
Loading…
Reference in New Issue
Block a user