Skip to content

Commit

Permalink
Install Elastic (#456)
Browse files Browse the repository at this point in the history
Co-authored-by: Gold856 <[email protected]>
Co-authored-by: Jade <[email protected]>
Co-authored-by: Tyler Veness <[email protected]>
Co-authored-by: sciencewhiz <[email protected]>
  • Loading branch information
5 people authored Nov 18, 2024
1 parent 6a21d3b commit 02729d7
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 1 deletion.
2 changes: 2 additions & 0 deletions WPILibInstaller-Avalonia/Interfaces/IConfigurationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public interface IConfigurationProvider

ChoreoConfig ChoreoConfig { get; }

ElasticConfig ElasticConfig { get; }

VsCodeConfig VsCodeConfig { get; }

string InstallDirectory { get; }
Expand Down
14 changes: 14 additions & 0 deletions WPILibInstaller-Avalonia/Models/ElasticConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#nullable disable

using Newtonsoft.Json;

namespace WPILibInstaller.Models
{
public class ElasticConfig
{
[JsonProperty("zipFile")]
public string ZipFile { get; set; }
[JsonProperty("folder")]
public string Folder { get; set; }
}
}
3 changes: 3 additions & 0 deletions WPILibInstaller-Avalonia/ViewModels/InstallPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ await ExtractArchive(token, new[] {
configurationProvider.UpgradeConfig.Tools.Folder + "/",
configurationProvider.AdvantageScopeConfig.Folder + "/",
configurationProvider.ChoreoConfig.Folder + "/",
configurationProvider.ElasticConfig.Folder + "/",
"installUtils/"});
}

Expand Down Expand Up @@ -847,6 +848,7 @@ private async Task RunShortcutCreator(CancellationToken token)
shortcutData.DesktopShortcuts.Add(new ShortcutInfo(Path.Join(frcHomePath, "tools", "DataLogTool.exe"), $"{frcYear} WPILib Tools/Data Log Tool {frcYear}", $"Data Log Tool {frcYear}", ""));
shortcutData.DesktopShortcuts.Add(new ShortcutInfo(Path.Join(frcHomePath, "advantagescope", "AdvantageScope (WPILib).exe"), $"{frcYear} WPILib Tools/AdvantageScope (WPILib) {frcYear}", $"AdvantageScope (WPILib) {frcYear}", ""));
shortcutData.DesktopShortcuts.Add(new ShortcutInfo(Path.Join(frcHomePath, "choreo", "choreo.exe"), $"{frcYear} WPILib Tools/Choreo (WPILib) {frcYear}", $"Choreo (WPILib) {frcYear}", ""));
shortcutData.DesktopShortcuts.Add(new ShortcutInfo(Path.Join(frcHomePath, "elastic", "elastic_dashboard.exe"), $"{frcYear} WPILib Tools/Elastic (WPILib) {frcYear}", $"Elastic (WPILib) {frcYear}", ""));

shortcutData.StartMenuShortcuts.Add(new ShortcutInfo(Path.Join(frcHomePath, "tools", "Glass.exe"), $"Programs/{frcYear} WPILib Tools/Glass {frcYear}", $"Glass {frcYear}", ""));
shortcutData.StartMenuShortcuts.Add(new ShortcutInfo(Path.Join(frcHomePath, "tools", "OutlineViewer.exe"), $"Programs/{frcYear} WPILib Tools/OutlineViewer {frcYear}", $"OutlineViewer {frcYear}", ""));
Expand All @@ -859,6 +861,7 @@ private async Task RunShortcutCreator(CancellationToken token)
shortcutData.StartMenuShortcuts.Add(new ShortcutInfo(Path.Join(frcHomePath, "tools", "DataLogTool.exe"), $"Programs/{frcYear} WPILib Tools/Data Log Tool {frcYear}", $"Data Log Tool {frcYear}", ""));
shortcutData.StartMenuShortcuts.Add(new ShortcutInfo(Path.Join(frcHomePath, "advantagescope", "AdvantageScope (WPILib).exe"), $"Programs/{frcYear} WPILib Tools/AdvantageScope (WPILib) {frcYear}", $"AdvantageScope (WPILib) {frcYear}", ""));
shortcutData.StartMenuShortcuts.Add(new ShortcutInfo(Path.Join(frcHomePath, "choreo", "choreo.exe"), $"Programs/{frcYear} WPILib Tools/Choreo (WPILib) {frcYear}", $"Choreo (WPILib) {frcYear}", ""));
shortcutData.StartMenuShortcuts.Add(new ShortcutInfo(Path.Join(frcHomePath, "elastic", "elastic_dashboard.exe"), $"Programs/{frcYear} WPILib Tools/Elastic (WPILib) {frcYear}", $"Elastic (WPILib) {frcYear}", ""));

if (toInstallProvider.Model.InstallEverything)
{
Expand Down
13 changes: 13 additions & 0 deletions WPILibInstaller-Avalonia/ViewModels/StartPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,17 @@ private async Task<bool> SelectResourceFilesWithFile(string file)
}) ?? throw new InvalidOperationException("Not Valid");
}

entry = zipArchive.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 = zipArchive.GetEntry("fullConfig.json");

using (StreamReader reader = new StreamReader(entry!.Open()))
Expand Down Expand Up @@ -427,6 +438,8 @@ public override PageViewModelBase MoveNext()

public ChoreoConfig ChoreoConfig { get; private set; } = null!;

public ElasticConfig ElasticConfig { get; private set; } = null!;

public VsCodeConfig VsCodeConfig { get; private set; } = null!;

}
Expand Down
21 changes: 20 additions & 1 deletion apps/ToolsUpdater/src/main/java/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ private static void installAdvantageScope(String toolsPath) {
}
}

private static void installElastic(String toolsPath) {
if (SystemUtils.IS_OS_MAC) {
String archiveFileName = "Elastic-WPILib-macOS.tar.gz";
String elasticFolder = Paths.get(new File(toolsPath).getParent(), "elastic").toString();
Path archivePath = Paths.get(elasticFolder, archiveFileName);

try {
Runtime.getRuntime().exec(new String[] {
"tar", "-xzf", archivePath.toString(), "-C", elasticFolder
}).waitFor();
} catch (IOException | InterruptedException e) {
System.out.println(e.toString());
e.printStackTrace();
}
}
}

private static void installUtility(String toolsPath) {
if (SystemUtils.IS_OS_MAC) {
String archiveFileName = "wpilibutility-mac.tar.gz";
Expand Down Expand Up @@ -148,7 +165,9 @@ public static void main(String[] args) throws URISyntaxException, IOException {
System.out.println("Installing " + tool.name);
if (tool.name.equals("AdvantageScope")) {
installAdvantageScope(toolsPath);
} if (tool.name.equals("Utility")) {
} else if (tool.name.equals("Elastic")) {
installElastic(toolsPath);
} else if (tool.name.equals("Utility")) {
installUtility(toolsPath);
} else if (tool.artifact != null) {
if (tool.cpp) {
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ apply from: 'scripts/maven.gradle'

apply from: 'scripts/advantagescope.gradle'
apply from: 'scripts/choreo.gradle'
apply from: 'scripts/elastic.gradle'

// Tools must happen after maven
apply from: 'scripts/tools.gradle'
Expand Down Expand Up @@ -223,6 +224,7 @@ def generateFullResourcesTask = tasks.register('generateFullResources', project.

advantageScopeZipSetup(it)
choreoZipSetup(it)
elasticZipSetup(it)

if (OperatingSystem.current().isWindows()) {
def task = it
Expand Down Expand Up @@ -329,6 +331,7 @@ def generateConfigFiles = tasks.register('generateCommonResources', Zip) {

advantageScopeConfigFileSetup(zip)
choreoConfigFileSetup(zip)
elasticConfigFileSetup(zip)

vscodeConfigZipSetup(zip)
}
Expand Down
13 changes: 13 additions & 0 deletions files/Elastic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

SCRIPT_PATH="$(dirname "$(realpath "$0")")"
SCRIPT_NAME="$(basename "$(realpath "$0")")"
SCRIPT_BASE="$(basename -s .sh "$SCRIPT_NAME")"
OS_NAME="$(uname -s)"
ELASTIC_PATH="$(realpath "$SCRIPT_PATH/../elastic")"

if [ "$OS_NAME" = "Darwin" ]; then
open "$ELASTIC_PATH/elastic_dashboard.app"
else
exec "$ELASTIC_PATH/elastic_dashboard"
fi
44 changes: 44 additions & 0 deletions files/Elastic.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'Create File System Object for working with directories
Set fso = WScript.CreateObject("Scripting.FileSystemObject")

'Get the folder of this script
toolsFolder = fso.GetParentFolderName(WScript.ScriptFullName)

'Get the Elastic folder
toolsFolder = fso.GetParentFolderName(WScript.ScriptFullName)
yearFolder = fso.GetParentFolderName(toolsFolder)
elasticFolder = fso.BuildPath(yearFolder, "elastic")

'Get the full path to the exe
fullExeName = fso.BuildPath(elasticFolder, "elastic_dashboard.exe")

shellScript = fullExeName

'Create Shell Object
Set objShell = WScript.CreateObject( "WScript.Shell" )
Set objEnv = objShell.Environment("PROCESS")
dim runObject
' Allow us to catch a script run failure
On Error Resume Next
Set runObj = objShell.Exec(shellScript)
If Err.Number <> 0 Then
If WScript.Arguments.Count > 0 Then
If (WScript.Arguments(0) <> "silent") Then
WScript.Echo "Error Launching Tool" + vbCrLf + Err.Description
Else
WScript.StdOut.Write("Error Launching Tool")
WScript.StdOut.Write(Error.Description)
End If
Else
WScript.Echo "Error Launching Tool" + vbCrLf + Err.Description
End If
Set runObj = Nothing
Set objShell = Nothing
Set fso = Nothing
WScript.Quit(1)
End If

Set runObj = Nothing
Set objShell = Nothing
Set fso = Nothing
WScript.Quit(0)
120 changes: 120 additions & 0 deletions scripts/elastic.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
apply from: 'scripts/versions.gradle'

def baseUrl = "https://github.com/Gold872/elastic-dashboard/releases/download/$elasticGitTag/"

def fileNameWindows = 'Elastic-WPILib-Windows.zip'

def downloadUrlWindows = baseUrl + fileNameWindows

def fileNameMac = 'Elastic-WPILib-macOS.tar.gz'

def downloadUrlMac = baseUrl + fileNameMac

def fileNameMacArm = 'Elastic-WPILib-macOS.tar.gz'

def downloadUrlMacArm = baseUrl + fileNameMacArm

def fileNameLinux = 'Elastic-WPILib-Linux.zip'

def downloadUrlLinux = baseUrl + fileNameLinux

apply plugin: 'de.undercouch.download'

def downloadTaskWindows = tasks.register('downloadElasticWindows', Download) {
src downloadUrlWindows
def fileName = file(src.file).name
dest "$buildDir/downloads/$fileName"
overwrite true
}

def downloadTaskMac = tasks.register('downloadElasticMac', Download) {
src downloadUrlMac
def fileName = file(src.file).name
dest "$buildDir/downloads/$fileName"
overwrite true
}

def downloadTaskMacArm = tasks.register('downloadElasticMacArm', Download) {
src downloadUrlMacArm
def fileName = file(src.file).name
dest "$buildDir/downloads/$fileName"
overwrite true
}

def downloadTaskLinux = tasks.register('downloadElasticLinux', Download) {
src downloadUrlLinux
def fileName = file(src.file).name
dest "$buildDir/downloads/$fileName"
overwrite true
}

def elasticConfigFile = file("$buildDir/elasticConfig.json")

def elasticConfigFileTask = tasks.register('elasticConfigFile') {
it.outputs.file elasticConfigFile

doLast {
def config = [:]
config['folder'] = 'elastic'
config['zipFile'] = 'elastic.zip'

def gbuilder = getGsonBuilder()

gbuilder.setPrettyPrinting()
def json = gbuilder.create().toJson(config)

elasticConfigFile.parentFile.mkdirs()

elasticConfigFile.text = json
}
}

ext.elasticConfigFileSetup = { AbstractArchiveTask zip->
zip.dependsOn elasticConfigFileTask
zip.inputs.file elasticConfigFile

zip.from(elasticConfigFile) {
rename { 'elasticConfig.json' }
}
}

ext.elasticZipSetup = { AbstractArchiveTask zip->
if (project.hasProperty('linuxBuild')) {
zip.dependsOn downloadTaskLinux

zip.inputs.files downloadTaskLinux.get().outputFiles

zip.from(project.zipTree(downloadTaskLinux.get().outputFiles.first())) {
into '/elastic'
includeEmptyDirs = false
}
} else if (project.hasProperty('macBuild')) {
zip.dependsOn downloadTaskMac

zip.inputs.files downloadTaskMac.get().outputFiles

// Cannot extract, otherwise breaks mac
zip.from(downloadTaskMac.get().outputFiles.first()) {
into '/elastic'
}
} else if (project.hasProperty('macBuildArm')) {
zip.dependsOn downloadTaskMacArm

zip.inputs.files downloadTaskMacArm.get().outputFiles

// Cannot extract, otherwise breaks mac
zip.from(downloadTaskMacArm.get().outputFiles.first()) {
into '/elastic'
}
} else {
zip.dependsOn downloadTaskWindows

zip.inputs.files downloadTaskWindows.get().outputFiles

zip.from(project.zipTree(downloadTaskWindows.get().outputFiles.first())) {
into '/elastic'
includeEmptyDirs = false
}
}
}

17 changes: 17 additions & 0 deletions scripts/tools.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ def advantageScopeScriptUnixFile = file("files/AdvantageScope.sh")
def choreoScriptFile = file("files/Choreo.vbs")
def choreoScriptUnixFile = file("files/Choreo.sh")

def elasticScriptFile = file("files/Elastic.vbs")
def elasticScriptUnixFile = file("files/Elastic.sh")

def toolsJsonTask = tasks.register('toolsJson', Task) {

dependsOn tasks.named('lazyModelEvaluation')
Expand Down Expand Up @@ -61,6 +64,11 @@ def toolsJsonTask = tasks.register('toolsJson', Task) {
choreoItem['version'] = choreoGitTag
config << choreoItem

def elasticItem = [:]
elasticItem['name'] = "Elastic"
elasticItem['version'] = elasticGitTag
config << elasticItem

def utilityItem = [:]
utilityItem['name'] = "Utility"
utilityItem['version'] = wpilibVersion
Expand Down Expand Up @@ -113,6 +121,10 @@ ext.toolsSetup = { AbstractArchiveTask zip->
zip.from (choreoScriptFile) {
into '/tools'
}

zip.from (elasticScriptFile) {
into '/tools'
}
} else {
zip.from (scriptBaseUnixFile) {
into '/tools'
Expand All @@ -133,6 +145,11 @@ ext.toolsSetup = { AbstractArchiveTask zip->
into '/tools'
fileMode 0755
}

zip.from (elasticScriptUnixFile) {
into '/tools'
fileMode 0755
}
}

}
2 changes: 2 additions & 0 deletions scripts/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ ext.advantagescopeGitTag = 'v4.0.0-beta-3'

ext.choreoGitTag = 'v2025.0.0-beta-6'

ext.elasticGitTag = 'v2025.0.0-beta-4'

ext.frcYear = '2025'

ext.gradleWrapperVersion = '8.11'

0 comments on commit 02729d7

Please sign in to comment.