Skip to content

Commit 02729d7

Browse files
Gold872Gold856spacey-sootycalcmogulsciencewhiz
authored
Install Elastic (#456)
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]>
1 parent 6a21d3b commit 02729d7

File tree

11 files changed

+251
-1
lines changed

11 files changed

+251
-1
lines changed

WPILibInstaller-Avalonia/Interfaces/IConfigurationProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public interface IConfigurationProvider
1818

1919
ChoreoConfig ChoreoConfig { get; }
2020

21+
ElasticConfig ElasticConfig { get; }
22+
2123
VsCodeConfig VsCodeConfig { get; }
2224

2325
string InstallDirectory { get; }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#nullable disable
2+
3+
using Newtonsoft.Json;
4+
5+
namespace WPILibInstaller.Models
6+
{
7+
public class ElasticConfig
8+
{
9+
[JsonProperty("zipFile")]
10+
public string ZipFile { get; set; }
11+
[JsonProperty("folder")]
12+
public string Folder { get; set; }
13+
}
14+
}

WPILibInstaller-Avalonia/ViewModels/InstallPageViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ await ExtractArchive(token, new[] {
9696
configurationProvider.UpgradeConfig.Tools.Folder + "/",
9797
configurationProvider.AdvantageScopeConfig.Folder + "/",
9898
configurationProvider.ChoreoConfig.Folder + "/",
99+
configurationProvider.ElasticConfig.Folder + "/",
99100
"installUtils/"});
100101
}
101102

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

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

863866
if (toInstallProvider.Model.InstallEverything)
864867
{

WPILibInstaller-Avalonia/ViewModels/StartPageViewModel.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ private async Task<bool> SelectResourceFilesWithFile(string file)
225225
}) ?? throw new InvalidOperationException("Not Valid");
226226
}
227227

228+
entry = zipArchive.GetEntry("elasticConfig.json");
229+
230+
using (StreamReader reader = new StreamReader(entry!.Open()))
231+
{
232+
var configStr = await reader.ReadToEndAsync();
233+
ElasticConfig = JsonConvert.DeserializeObject<ElasticConfig>(configStr, new JsonSerializerSettings
234+
{
235+
MissingMemberHandling = MissingMemberHandling.Error
236+
}) ?? throw new InvalidOperationException("Not Valid");
237+
}
238+
228239
entry = zipArchive.GetEntry("fullConfig.json");
229240

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

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

441+
public ElasticConfig ElasticConfig { get; private set; } = null!;
442+
430443
public VsCodeConfig VsCodeConfig { get; private set; } = null!;
431444

432445
}

apps/ToolsUpdater/src/main/java/Program.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,23 @@ private static void installAdvantageScope(String toolsPath) {
116116
}
117117
}
118118

119+
private static void installElastic(String toolsPath) {
120+
if (SystemUtils.IS_OS_MAC) {
121+
String archiveFileName = "Elastic-WPILib-macOS.tar.gz";
122+
String elasticFolder = Paths.get(new File(toolsPath).getParent(), "elastic").toString();
123+
Path archivePath = Paths.get(elasticFolder, archiveFileName);
124+
125+
try {
126+
Runtime.getRuntime().exec(new String[] {
127+
"tar", "-xzf", archivePath.toString(), "-C", elasticFolder
128+
}).waitFor();
129+
} catch (IOException | InterruptedException e) {
130+
System.out.println(e.toString());
131+
e.printStackTrace();
132+
}
133+
}
134+
}
135+
119136
private static void installUtility(String toolsPath) {
120137
if (SystemUtils.IS_OS_MAC) {
121138
String archiveFileName = "wpilibutility-mac.tar.gz";
@@ -148,7 +165,9 @@ public static void main(String[] args) throws URISyntaxException, IOException {
148165
System.out.println("Installing " + tool.name);
149166
if (tool.name.equals("AdvantageScope")) {
150167
installAdvantageScope(toolsPath);
151-
} if (tool.name.equals("Utility")) {
168+
} else if (tool.name.equals("Elastic")) {
169+
installElastic(toolsPath);
170+
} else if (tool.name.equals("Utility")) {
152171
installUtility(toolsPath);
153172
} else if (tool.artifact != null) {
154173
if (tool.cpp) {

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ apply from: 'scripts/maven.gradle'
104104

105105
apply from: 'scripts/advantagescope.gradle'
106106
apply from: 'scripts/choreo.gradle'
107+
apply from: 'scripts/elastic.gradle'
107108

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

224225
advantageScopeZipSetup(it)
225226
choreoZipSetup(it)
227+
elasticZipSetup(it)
226228

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

330332
advantageScopeConfigFileSetup(zip)
331333
choreoConfigFileSetup(zip)
334+
elasticConfigFileSetup(zip)
332335

333336
vscodeConfigZipSetup(zip)
334337
}

files/Elastic.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
SCRIPT_PATH="$(dirname "$(realpath "$0")")"
4+
SCRIPT_NAME="$(basename "$(realpath "$0")")"
5+
SCRIPT_BASE="$(basename -s .sh "$SCRIPT_NAME")"
6+
OS_NAME="$(uname -s)"
7+
ELASTIC_PATH="$(realpath "$SCRIPT_PATH/../elastic")"
8+
9+
if [ "$OS_NAME" = "Darwin" ]; then
10+
open "$ELASTIC_PATH/elastic_dashboard.app"
11+
else
12+
exec "$ELASTIC_PATH/elastic_dashboard"
13+
fi

files/Elastic.vbs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'Create File System Object for working with directories
2+
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
3+
4+
'Get the folder of this script
5+
toolsFolder = fso.GetParentFolderName(WScript.ScriptFullName)
6+
7+
'Get the Elastic folder
8+
toolsFolder = fso.GetParentFolderName(WScript.ScriptFullName)
9+
yearFolder = fso.GetParentFolderName(toolsFolder)
10+
elasticFolder = fso.BuildPath(yearFolder, "elastic")
11+
12+
'Get the full path to the exe
13+
fullExeName = fso.BuildPath(elasticFolder, "elastic_dashboard.exe")
14+
15+
shellScript = fullExeName
16+
17+
'Create Shell Object
18+
Set objShell = WScript.CreateObject( "WScript.Shell" )
19+
Set objEnv = objShell.Environment("PROCESS")
20+
dim runObject
21+
' Allow us to catch a script run failure
22+
On Error Resume Next
23+
Set runObj = objShell.Exec(shellScript)
24+
If Err.Number <> 0 Then
25+
If WScript.Arguments.Count > 0 Then
26+
If (WScript.Arguments(0) <> "silent") Then
27+
WScript.Echo "Error Launching Tool" + vbCrLf + Err.Description
28+
Else
29+
WScript.StdOut.Write("Error Launching Tool")
30+
WScript.StdOut.Write(Error.Description)
31+
End If
32+
Else
33+
WScript.Echo "Error Launching Tool" + vbCrLf + Err.Description
34+
End If
35+
Set runObj = Nothing
36+
Set objShell = Nothing
37+
Set fso = Nothing
38+
WScript.Quit(1)
39+
End If
40+
41+
Set runObj = Nothing
42+
Set objShell = Nothing
43+
Set fso = Nothing
44+
WScript.Quit(0)

scripts/elastic.gradle

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
apply from: 'scripts/versions.gradle'
2+
3+
def baseUrl = "https://github.com/Gold872/elastic-dashboard/releases/download/$elasticGitTag/"
4+
5+
def fileNameWindows = 'Elastic-WPILib-Windows.zip'
6+
7+
def downloadUrlWindows = baseUrl + fileNameWindows
8+
9+
def fileNameMac = 'Elastic-WPILib-macOS.tar.gz'
10+
11+
def downloadUrlMac = baseUrl + fileNameMac
12+
13+
def fileNameMacArm = 'Elastic-WPILib-macOS.tar.gz'
14+
15+
def downloadUrlMacArm = baseUrl + fileNameMacArm
16+
17+
def fileNameLinux = 'Elastic-WPILib-Linux.zip'
18+
19+
def downloadUrlLinux = baseUrl + fileNameLinux
20+
21+
apply plugin: 'de.undercouch.download'
22+
23+
def downloadTaskWindows = tasks.register('downloadElasticWindows', Download) {
24+
src downloadUrlWindows
25+
def fileName = file(src.file).name
26+
dest "$buildDir/downloads/$fileName"
27+
overwrite true
28+
}
29+
30+
def downloadTaskMac = tasks.register('downloadElasticMac', Download) {
31+
src downloadUrlMac
32+
def fileName = file(src.file).name
33+
dest "$buildDir/downloads/$fileName"
34+
overwrite true
35+
}
36+
37+
def downloadTaskMacArm = tasks.register('downloadElasticMacArm', Download) {
38+
src downloadUrlMacArm
39+
def fileName = file(src.file).name
40+
dest "$buildDir/downloads/$fileName"
41+
overwrite true
42+
}
43+
44+
def downloadTaskLinux = tasks.register('downloadElasticLinux', Download) {
45+
src downloadUrlLinux
46+
def fileName = file(src.file).name
47+
dest "$buildDir/downloads/$fileName"
48+
overwrite true
49+
}
50+
51+
def elasticConfigFile = file("$buildDir/elasticConfig.json")
52+
53+
def elasticConfigFileTask = tasks.register('elasticConfigFile') {
54+
it.outputs.file elasticConfigFile
55+
56+
doLast {
57+
def config = [:]
58+
config['folder'] = 'elastic'
59+
config['zipFile'] = 'elastic.zip'
60+
61+
def gbuilder = getGsonBuilder()
62+
63+
gbuilder.setPrettyPrinting()
64+
def json = gbuilder.create().toJson(config)
65+
66+
elasticConfigFile.parentFile.mkdirs()
67+
68+
elasticConfigFile.text = json
69+
}
70+
}
71+
72+
ext.elasticConfigFileSetup = { AbstractArchiveTask zip->
73+
zip.dependsOn elasticConfigFileTask
74+
zip.inputs.file elasticConfigFile
75+
76+
zip.from(elasticConfigFile) {
77+
rename { 'elasticConfig.json' }
78+
}
79+
}
80+
81+
ext.elasticZipSetup = { AbstractArchiveTask zip->
82+
if (project.hasProperty('linuxBuild')) {
83+
zip.dependsOn downloadTaskLinux
84+
85+
zip.inputs.files downloadTaskLinux.get().outputFiles
86+
87+
zip.from(project.zipTree(downloadTaskLinux.get().outputFiles.first())) {
88+
into '/elastic'
89+
includeEmptyDirs = false
90+
}
91+
} else if (project.hasProperty('macBuild')) {
92+
zip.dependsOn downloadTaskMac
93+
94+
zip.inputs.files downloadTaskMac.get().outputFiles
95+
96+
// Cannot extract, otherwise breaks mac
97+
zip.from(downloadTaskMac.get().outputFiles.first()) {
98+
into '/elastic'
99+
}
100+
} else if (project.hasProperty('macBuildArm')) {
101+
zip.dependsOn downloadTaskMacArm
102+
103+
zip.inputs.files downloadTaskMacArm.get().outputFiles
104+
105+
// Cannot extract, otherwise breaks mac
106+
zip.from(downloadTaskMacArm.get().outputFiles.first()) {
107+
into '/elastic'
108+
}
109+
} else {
110+
zip.dependsOn downloadTaskWindows
111+
112+
zip.inputs.files downloadTaskWindows.get().outputFiles
113+
114+
zip.from(project.zipTree(downloadTaskWindows.get().outputFiles.first())) {
115+
into '/elastic'
116+
includeEmptyDirs = false
117+
}
118+
}
119+
}
120+

scripts/tools.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ def advantageScopeScriptUnixFile = file("files/AdvantageScope.sh")
1111
def choreoScriptFile = file("files/Choreo.vbs")
1212
def choreoScriptUnixFile = file("files/Choreo.sh")
1313

14+
def elasticScriptFile = file("files/Elastic.vbs")
15+
def elasticScriptUnixFile = file("files/Elastic.sh")
16+
1417
def toolsJsonTask = tasks.register('toolsJson', Task) {
1518

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

67+
def elasticItem = [:]
68+
elasticItem['name'] = "Elastic"
69+
elasticItem['version'] = elasticGitTag
70+
config << elasticItem
71+
6472
def utilityItem = [:]
6573
utilityItem['name'] = "Utility"
6674
utilityItem['version'] = wpilibVersion
@@ -113,6 +121,10 @@ ext.toolsSetup = { AbstractArchiveTask zip->
113121
zip.from (choreoScriptFile) {
114122
into '/tools'
115123
}
124+
125+
zip.from (elasticScriptFile) {
126+
into '/tools'
127+
}
116128
} else {
117129
zip.from (scriptBaseUnixFile) {
118130
into '/tools'
@@ -133,6 +145,11 @@ ext.toolsSetup = { AbstractArchiveTask zip->
133145
into '/tools'
134146
fileMode 0755
135147
}
148+
149+
zip.from (elasticScriptUnixFile) {
150+
into '/tools'
151+
fileMode 0755
152+
}
136153
}
137154

138155
}

0 commit comments

Comments
 (0)