Skip to content

Commit

Permalink
[release] auto update RLS.
Browse files Browse the repository at this point in the history
  • Loading branch information
parthopdas committed Jan 20, 2024
1 parent b3d2f1b commit 3f0124d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/RustAnalyzer.TestAdapter/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace KS.RustAnalyzer.TestAdapter;

public static class Constants
{
public const string ReleaseSummary = $"Relaxing VS version check based on user feedback. Please report any issues you face. Consider giving 5⭐ if you find this extension useful.";
public const string ReleaseSummary = $"Rust Language Server will auto update from now on. Please report any issues you face. Consider giving 5⭐ if you find this extension useful.";
public const string ReleaseNotesUrl = $"https://github.com/kitamstudios/rust-analyzer.vs/releases/{Vsix.Version}";
public const string DiscordUrl = "https://discord.gg/JyK55EsACr";
public const string TestExperienceDemoUrl = "https://youtu.be/pE1Vr2zVCbg?t=170";
Expand Down
6 changes: 3 additions & 3 deletions src/RustAnalyzer.UnitTests/RAExeReleaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public sealed class RAExeReleaseTests
[Fact]
public async Task LastUpdateShouldNotBeOlderThan30DaysAsync()
{
var ret = await RADownloaderService.GetLatestRAReleaseRedirectUriAsync();
var ret = await RAInstallerService.GetLatestRAReleaseRedirectUriAsync();

var latestRelDate = DateTime.ParseExact(ret?.Version, RADownloaderService.RAVersionFormat, CultureInfo.InvariantCulture);
var lastUpdateDate = DateTime.ParseExact(RADownloaderService.LatestInPackageRAVersion, RADownloaderService.RAVersionFormat, CultureInfo.InvariantCulture);
var latestRelDate = DateTime.ParseExact(ret?.Version, RAInstallerService.RAVersionFormat, CultureInfo.InvariantCulture);
var lastUpdateDate = DateTime.ParseExact(RAInstallerService.LatestInPackageRAVersion, RAInstallerService.RAVersionFormat, CultureInfo.InvariantCulture);
lastUpdateDate.Should().NotBeBefore(latestRelDate.AddDays(-120), $"new rust-analyzer.exe is available {ret?.Uri}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

namespace KS.RustAnalyzer.Infrastructure;

public interface IRADownloaderService
public interface IRAInstallerService
{
Task<PathEx> GetRustAnalyzerExePathAsync();

Task DownloadLatestRAAsync();
Task InstallLatestRAAsync();
}

[Export(typeof(IRADownloaderService))]
[Export(typeof(IRAInstallerService))]
[PartCreationPolicy(CreationPolicy.Shared)]
public class RADownloaderService : IRADownloaderService
public class RAInstallerService : IRAInstallerService
{
public const string LatestInPackageRAVersion = "2024-01-08";
public const string RAVersionFormat = "yyyy-MM-dd";
Expand All @@ -32,7 +32,7 @@ public class RADownloaderService : IRADownloaderService
private readonly TL _tl;

[ImportingConstructor]
public RADownloaderService(IRegistrySettingsService regSettings, [Import] ITelemetryService t, [Import] ILogger l)
public RAInstallerService(IRegistrySettingsService regSettings, [Import] ITelemetryService t, [Import] ILogger l)
{
_regSettings = regSettings;
_tl = new TL
Expand All @@ -42,13 +42,8 @@ public RADownloaderService(IRegistrySettingsService regSettings, [Import] ITelem
};
}

public async Task DownloadLatestRAAsync()
public async Task InstallLatestRAAsync()
{
if (!IsDownloadEnabled())
{
return;
}

_tl.L.WriteLine("Initiating download of RA...");
try
{
Expand Down Expand Up @@ -100,12 +95,6 @@ public async Task<PathEx> GetRustAnalyzerExePathAsync()
}
}

private bool IsDownloadEnabled()
{
var id = Environment.ExpandEnvironmentVariables("%USERNAME%@%COMPUTERNAME%.%USERDOMAIN%");
return id?.Equals("parth@unrenormlizable.unrenormlizable", StringComparison.OrdinalIgnoreCase) ?? false;
}

private PathEx GetVersionedRAExePath(string version)
{
return GetRAFolder(version) + (PathEx)$"rust-analyzer.exe";
Expand Down
2 changes: 1 addition & 1 deletion src/RustAnalyzer/LanguageService/LanguageClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class LanguageClient : ILanguageClient, ILanguageClientCustomMessage2
public ITelemetryService T { get; set; }

[Import]
public IRADownloaderService RADownloader { get; set; }
public IRAInstallerService RADownloader { get; set; }

public JsonRpc Rpc { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/RustAnalyzer/RustAnalyzer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Infrastructure\RADownloaderService.cs" />
<Compile Include="Infrastructure\RAInstallerService.cs" />
<Compile Include="Infrastructure\RegistrySettingsService.cs" />
<Compile Include="Infrastructure\SettingsInfo.cs" />
<Compile Include="LanguageService\CommentHelper.cs" />
Expand Down
6 changes: 3 additions & 3 deletions src/RustAnalyzer/RustAnalyzerPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public sealed class RustAnalyzerPackage : ToolkitPackage
private TL _tl;
private IRegistrySettingsService _regSettings;
private IPreReqsCheckService _preReqs;
private IRADownloaderService _raDownloader;
private IRAInstallerService _raDownloader;

protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
Expand All @@ -52,7 +52,7 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
};
_regSettings = cmServiceProvider?.GetService<IRegistrySettingsService>();
_preReqs = cmServiceProvider?.GetService<IPreReqsCheckService>();
_raDownloader = cmServiceProvider?.GetService<IRADownloaderService>();
_raDownloader = cmServiceProvider?.GetService<IRAInstallerService>();
}

protected override async Task OnAfterPackageLoadedAsync(CancellationToken cancellationToken)
Expand All @@ -64,7 +64,7 @@ protected override async Task OnAfterPackageLoadedAsync(CancellationToken cancel
await ReleaseSummaryNotification.ShowAsync(_regSettings, _tl);
await SearchAndDisableIncompatibleExtensionsAsync();
await _preReqs.SatisfyAsync();
await _raDownloader.DownloadLatestRAAsync();
await _raDownloader.InstallLatestRAAsync();
}

#region Handling incompatible extensions
Expand Down

0 comments on commit 3f0124d

Please sign in to comment.