Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f72f960
Started implementing CLI
noamzaks May 2, 2021
dec1aab
Added FRC year and file to options
noamzaks May 2, 2021
47d5b24
Quick and dirty
noamzaks Aug 2, 2021
4fa4625
Added cli options
noamzaks Aug 3, 2021
962c354
Merge remote-tracking branch 'origin/main' into cli
reedws Oct 24, 2024
8e44f3a
feat!: Ensure that CLI finds Advantage scope config and Choreo config
vramaiah Oct 2, 2025
9b821f4
feat: Fixed icon paths in shortcut creator
vramaiah Oct 2, 2025
02845e5
fix: Made sure hash was supplied in VsCodeModel Creation
vramaiah Oct 2, 2025
506ac19
fix: Fix a few more things in CLI Installer
vramaiah Oct 2, 2025
c39fd6f
Merge branch 'wpilibsuite:main' into cli
vramaiah Oct 2, 2025
cb068a9
chore: Fix formatting
vramaiah Oct 2, 2025
aca3af1
fix: Fix some more compile errors
vramaiah Oct 2, 2025
19a13f9
chore: Fix formatting
vramaiah Oct 2, 2025
22cb744
fix: Remove ChoreoConfig
vramaiah Oct 2, 2025
b1b102a
chore: Fix formatting
vramaiah Oct 2, 2025
858a74a
fix: Make tools be installed
vramaiah Oct 5, 2025
f6be168
fix: Change CLI install location
vramaiah Oct 10, 2025
4f9c1da
fix: Make VS Code Install work
vramaiah Oct 11, 2025
fa7d43b
feat: Make tool install more quiet
vramaiah Oct 11, 2025
513fabe
feat: Add Spectre TUI library
vramaiah Oct 11, 2025
69f8653
feat: Add VS Code download progress bar
vramaiah Oct 12, 2025
3b5c1c7
feat: Remove VS Code download progress bar
vramaiah Oct 12, 2025
e0ef348
feat: Add spinners to CLI
vramaiah Oct 12, 2025
695dddf
Merge branch 'main' into cli
vramaiah Oct 12, 2025
98d590d
style: Run dotnet format
vramaiah Oct 12, 2025
383c69c
chore: Remove unnecessary comments
vramaiah Oct 14, 2025
d5dc006
feat: Create InstallTask abstract class
vramaiah Nov 11, 2025
1f8963f
refactor: Refactor the ExtractArchive method as a class implementing
vramaiah Nov 11, 2025
928b57d
refactor: Refactor gradle install to use seperate class
vramaiah Nov 11, 2025
33c57a0
refactor: Refactor all other installation tasks
vramaiah Nov 11, 2025
803e4df
refactor: Reduce boilerplate for InstallTask child classes
vramaiah Nov 12, 2025
e2b94ad
refactor: Consolidate some smaller install tasks into one file
vramaiah Nov 12, 2025
4b7b75f
fix: Fix errorin VsCodeExtensionsSetup
vramaiah Nov 12, 2025
44e66db
style: Run dotnet format
vramaiah Nov 12, 2025
9cf592a
refactor: Refactor CLI to use new install tasks
vramaiah Nov 14, 2025
b656611
style: run dotnet format
vramaiah Nov 14, 2025
b1c819a
feat: Change CLI to have progress bars
vramaiah Nov 15, 2025
bf98506
feat: Tweak the CLI a bit more
vramaiah Nov 15, 2025
db11f74
Merge branch 'main' of https://github.com/wpilibsuite/WPILibInstaller…
vramaiah Nov 15, 2025
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
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17
188 changes: 188 additions & 0 deletions WPILibInstaller-Avalonia/CLI/CLIConfigurationProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using WPILibInstaller.Interfaces;
using WPILibInstaller.Models;
using WPILibInstaller.Utils;

namespace WPILibInstaller.CLI
{
class CLIConfigurationProvider : IConfigurationProvider
{
private CLIConfigurationProvider(UpgradeConfig upgradeConfig,
FullConfig fullConfig, JdkConfig jdkConfig,
VsCodeConfig vsCodeConfig,
AdvantageScopeConfig advantageScopeConfig,
ElasticConfig elasticConfig,
IArchiveExtractor zipArchive, string installDirectory
)
{
UpgradeConfig = upgradeConfig;
FullConfig = fullConfig;
JdkConfig = jdkConfig;
VsCodeConfig = vsCodeConfig;
ZipArchive = zipArchive;
InstallDirectory = installDirectory;
AdvantageScopeConfig = advantageScopeConfig;
ElasticConfig = elasticConfig;

// Create VsCodeModel
VsCodeModel = new VsCodeModel(VsCodeConfig.VsCodeVersion);
VsCodeModel.Platforms.Add(Utils.Platform.Win64, new VsCodeModel.PlatformData(VsCodeConfig.VsCodeWindowsUrl, VsCodeConfig.VsCodeWindowsName, VsCodeConfig.VsCodeWindowsHash));
VsCodeModel.Platforms.Add(Utils.Platform.Linux64, new VsCodeModel.PlatformData(VsCodeConfig.VsCodeLinuxUrl, VsCodeConfig.VsCodeLinuxName, VsCodeConfig.VsCodeLinuxHash));
VsCodeModel.Platforms.Add(Utils.Platform.LinuxArm64, new VsCodeModel.PlatformData(VsCodeConfig.VsCodeLinuxArm64Url, VsCodeConfig.VsCodeLinuxArm64Name, VsCodeConfig.VsCodeLinuxArm64Hash));
VsCodeModel.Platforms.Add(Utils.Platform.Mac64, new VsCodeModel.PlatformData(VsCodeConfig.VsCodeMacUrl, VsCodeConfig.VsCodeMacName, VsCodeConfig.VsCodeMacHash));
VsCodeModel.Platforms.Add(Utils.Platform.MacArm64, new VsCodeModel.PlatformData(VsCodeConfig.VsCodeMacUrl, VsCodeConfig.VsCodeMacName, VsCodeConfig.VsCodeMacHash));
}

public static async Task<CLIConfigurationProvider> From(string artifactsFile, string resourcesFile)
{
UpgradeConfig UpgradeConfig;
FullConfig FullConfig;
JdkConfig JdkConfig;
VsCodeConfig VsCodeConfig;
AdvantageScopeConfig AdvantageScopeConfig;
ElasticConfig ElasticConfig;

var publicFolder = Environment.GetEnvironmentVariable("PUBLIC");
if (publicFolder == null)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
publicFolder = "C:\\Users\\Public";
}
else
{
publicFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
}
}

FileStream fileStream = File.OpenRead(artifactsFile);
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
// Read the original hash.
string hash = File.ReadAllText(Path.Join(AppContext.BaseDirectory, "checksum.txt")).Trim();

// Compute the hash of the file that exists.
string s;
using (var sha256 = SHA256.Create())
{
s = Convert.ToHexString(await sha256.ComputeHashAsync(fileStream));
}

// Make sure they match.
if (!s.Equals(hash.ToUpper()))
{
throw new Exception("The artifacts file was damaged.");
}
}


fileStream.Position = 0;
var ZipArchive = ArchiveUtils.OpenArchive(fileStream);


var resourcesArchive = ZipFile.OpenRead(resourcesFile);

var entry = resourcesArchive.GetEntry("vscodeConfig.json");

using (StreamReader reader = new StreamReader(entry!.Open()))
{
var vsConfigStr = await reader.ReadToEndAsync();
VsCodeConfig = JsonConvert.DeserializeObject<VsCodeConfig>(vsConfigStr, new JsonSerializerSettings
{
MissingMemberHandling = MissingMemberHandling.Error
}) ?? throw new InvalidOperationException("Not Valid");
}

entry = resourcesArchive.GetEntry("jdkConfig.json");

using (StreamReader reader = new StreamReader(entry!.Open()))
{
var configStr = await reader.ReadToEndAsync();
JdkConfig = JsonConvert.DeserializeObject<JdkConfig>(configStr, new JsonSerializerSettings
{
MissingMemberHandling = MissingMemberHandling.Error
}) ?? throw new InvalidOperationException("Not Valid");
}

entry = resourcesArchive.GetEntry("advantageScopeConfig.json");
using (StreamReader reader = new StreamReader(entry!.Open()))
{
var configStr = await reader.ReadToEndAsync();
AdvantageScopeConfig = JsonConvert.DeserializeObject<AdvantageScopeConfig>(configStr, new JsonSerializerSettings
{
MissingMemberHandling = MissingMemberHandling.Error
}) ?? throw new InvalidOperationException("Not Valid");
}

entry = resourcesArchive.GetEntry("fullConfig.json");

using (StreamReader reader = new StreamReader(entry!.Open()))
{
var configStr = await reader.ReadToEndAsync();
FullConfig = JsonConvert.DeserializeObject<FullConfig>(configStr, new JsonSerializerSettings
{
MissingMemberHandling = MissingMemberHandling.Error
}) ?? throw new InvalidOperationException("Not Valid");
}

entry = resourcesArchive.GetEntry("elasticConfig.json");

using (StreamReader reader = new StreamReader(entry!.Open()))
{
var configStr = await reader.ReadToEndAsync();
ElasticConfig = JsonConvert.DeserializeObject<ElasticConfig>(configStr, new JsonSerializerSettings
{
MissingMemberHandling = MissingMemberHandling.Error
}) ?? throw new InvalidOperationException("Not Valid");
}

entry = resourcesArchive.GetEntry("upgradeConfig.json");

using (StreamReader reader = new StreamReader(entry!.Open()))
{
var configStr = await reader.ReadToEndAsync();
UpgradeConfig = JsonConvert.DeserializeObject<UpgradeConfig>(configStr, new JsonSerializerSettings
{
MissingMemberHandling = MissingMemberHandling.Error
}) ?? throw new InvalidOperationException("Not Valid");
}

var InstallDirectory = Path.Combine(publicFolder, "wpilib", UpgradeConfig.FrcYear);
return new CLIConfigurationProvider(
UpgradeConfig, FullConfig, JdkConfig, VsCodeConfig,
AdvantageScopeConfig, ElasticConfig, ZipArchive,
InstallDirectory
);
}

public VsCodeModel VsCodeModel { get; private set; }

public IArchiveExtractor ZipArchive { get; private set; }

public UpgradeConfig UpgradeConfig { get; private set; }

public FullConfig FullConfig { get; private set; }

public JdkConfig JdkConfig { get; private set; }

public VsCodeConfig VsCodeConfig { get; private set; }

public ElasticConfig ElasticConfig { get; private set; }

public AdvantageScopeConfig AdvantageScopeConfig { get; private set; }

public string InstallDirectory { get; private set; }
}
}
Loading