Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download language server from enterprise portal in enterprise mode. #26

Merged
merged 5 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ node_modules/
**/*.Server/ModelManifest.xml
_Pvt_Extensions

# VsixSignTool
vsixsigntool.exe

# Paket dependency manager
.paket/paket.exe
paket-files/
Expand Down
7 changes: 6 additions & 1 deletion CodeiumVS/CodeiumVSPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,12 @@ public string GetLanguageServerFolder()

public string GetLanguageServerPath()
{
return Path.Combine(GetLanguageServerFolder(), "language_server_windows_x64.exe");
string binaryName = "language_server_windows_x64.exe";
if (SettingsPage.EnterpriseMode)
{
binaryName = "language_server_windows_x64_enterprise.exe";
}
return Path.Combine(GetLanguageServerFolder(), binaryName);
}

public string GetDatabaseDirectory()
Expand Down
34 changes: 28 additions & 6 deletions CodeiumVS/LanguageServer/LanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace CodeiumVS;

public class LanguageServer
{
private const string Version = "1.6.7";
private const string Version = "1.6.10";

private int Port = 0;
private Process process;
Expand Down Expand Up @@ -192,9 +192,31 @@ public async Task PrepareAsync()
var waitDialogFactory = (IVsThreadedWaitDialogFactory)await VS.Services.GetThreadedWaitDialogAsync();
IVsThreadedWaitDialog4 progDialog = waitDialogFactory.CreateInstance();



string extensionBaseUrl = "https://github.com/Exafunction/codeium/releases/download";
string languageServerVersion = Version;
if (Package.SettingsPage.EnterpriseMode)
{
// Get the contents of /api/extension_base_url
try
{
string portalUrl = Package.SettingsPage.PortalUrl.TrimEnd('/');
string result = await new HttpClient().GetStringAsync(portalUrl + "/api/extension_base_url");
extensionBaseUrl = result.Trim().TrimEnd('/');
languageServerVersion = await new HttpClient().GetStringAsync(portalUrl + "/api/version");
}
catch (Exception)
{
await Package.LogAsync("Failed to get extension base url");
fortenforge marked this conversation as resolved.
Show resolved Hide resolved
extensionBaseUrl = "https://github.com/Exafunction/codeium/releases/download";
}
}
Metadata.extension_version = languageServerVersion;

progDialog.StartWaitDialog(
"Codeium", $"Downloading language server v{Version}", "", null,
$"Codeium: Downloading language server v{Version}", 0, false, true
"Codeium", $"Downloading language server v{languageServerVersion}", "", null,
$"Codeium: Downloading language server v{languageServerVersion}", 0, false, true
);

// the language server is downloaded in a thread so that it doesn't block the UI
Expand All @@ -208,7 +230,7 @@ void ThreadDownloadLanguageServer()
Directory.CreateDirectory(langServerFolder);
if (File.Exists(downloadDest)) File.Delete(downloadDest);

Uri url = new($"https://github.com/Exafunction/codeium/releases/download/language-server-v{Version}/language_server_windows_x64.exe.gz");
Uri url = new($"{extensionBaseUrl}/language-server-v{languageServerVersion}/language_server_windows_x64.exe.gz");

WebClient webClient = new();

Expand All @@ -227,9 +249,9 @@ void ThreadDownloadLanguageServer()
double recievedBytesMb = e.BytesReceived / 1024.0 / 1024.0;

progDialog.UpdateProgress(
$"Downloading language server v{Version} ({e.ProgressPercentage}%)",
$"Downloading language server v{languageServerVersion} ({e.ProgressPercentage}%)",
$"{recievedBytesMb:f2}Mb / {totalBytesMb:f2}Mb",
$"Codeium: Downloading language server v{Version} ({e.ProgressPercentage}%)",
$"Codeium: Downloading language server v{languageServerVersion} ({e.ProgressPercentage}%)",
(int)e.BytesReceived, (int)e.TotalBytesToReceive, true, out _
);

Expand Down
2 changes: 1 addition & 1 deletion CodeiumVS/source.extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal sealed partial class Vsix
public const string Name = "Codeium";
public const string Description = @"The modern coding superpower: free AI code acceleration plugin for your favorite languages. Type less. Code more. Ship faster.";
public const string Language = "en-US";
public const string Version = "1.6.7";
public const string Version = "1.6.10";
public const string Author = "Codeium";
public const string Tags = "";
}
Expand Down
2 changes: 1 addition & 1 deletion CodeiumVS/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="Codeium.VisualStudio" Version="1.6.7" Language="en-US" Publisher="Codeium" />
<Identity Id="Codeium.VisualStudio" Version="1.6.10" Language="en-US" Publisher="Codeium" />
<DisplayName>Codeium</DisplayName>
<Description xml:space="preserve">The modern coding superpower: free AI code acceleration plugin for your favorite languages. Type less. Code more. Ship faster.</Description>
<MoreInfo>https://www.codeium.com</MoreInfo>
Expand Down
Loading