Skip to content

Commit 67b5983

Browse files
authored
Merge pull request #1135 from ionite34/merge-main-to-dev-2345f69
2 parents fdf2ae0 + 5961f42 commit 67b5983

File tree

3 files changed

+76
-11
lines changed

3 files changed

+76
-11
lines changed

StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,21 @@ public Task<ProcessResult> GetGitOutput(ProcessArgs args, string? workingDirecto
377377
return ProcessRunner.RunBashCommand(args.Prepend("git"), workingDirectory ?? "");
378378
}
379379

380+
private async Task<string> RunNode(
381+
ProcessArgs args,
382+
string? workingDirectory = null,
383+
IReadOnlyDictionary<string, string>? envVars = null
384+
)
385+
{
386+
var nodePath = Path.Combine(NodeDir, "bin", "node");
387+
var result = await ProcessRunner
388+
.GetProcessResultAsync(nodePath, args, workingDirectory, envVars)
389+
.ConfigureAwait(false);
390+
391+
result.EnsureSuccessExitCode();
392+
return result.StandardOutput ?? result.StandardError ?? string.Empty;
393+
}
394+
380395
[Localizable(false)]
381396
[SupportedOSPlatform("Linux")]
382397
[SupportedOSPlatform("macOS")]
@@ -476,17 +491,32 @@ public async Task<Process> RunDotnet(
476491
[SupportedOSPlatform("macOS")]
477492
public async Task InstallNodeIfNecessary(IProgress<ProgressReport>? progress = null)
478493
{
479-
if (IsNodeInstalled)
494+
// NOTE TO FUTURE DEVS: if this is causing merge conflicts with dev, just nuke it we don't need anymore
495+
if (NodeDir.Exists)
480496
{
481-
Logger.Info("node already installed");
482-
return;
497+
try
498+
{
499+
var result = await RunNode("-v");
500+
if (result.Contains("20.19.3"))
501+
{
502+
Logger.Debug("Node.js already installed at {NodeExistsPath}", NodeDir);
503+
return;
504+
}
505+
}
506+
catch (Exception)
507+
{
508+
// ignored
509+
}
510+
511+
Logger.Warn("Node.js version mismatch, reinstalling...");
512+
await NodeDir.DeleteAsync(true);
483513
}
484514

485515
Logger.Info("Downloading node");
486516

487517
var downloadUrl = Compat.IsMacOS
488-
? "https://nodejs.org/dist/v20.11.0/node-v20.11.0-darwin-arm64.tar.gz"
489-
: "https://nodejs.org/dist/v20.11.0/node-v20.11.0-linux-x64.tar.gz";
518+
? "https://nodejs.org/dist/v20.19.3/node-v20.19.3-darwin-arm64.tar.gz"
519+
: "https://nodejs.org/dist/v20.19.3/node-v20.19.3-linux-x64.tar.gz";
490520

491521
var nodeDownloadPath = AssetsDir.JoinFile(Path.GetFileName(downloadUrl));
492522

@@ -506,8 +536,8 @@ public async Task InstallNodeIfNecessary(IProgress<ProgressReport>? progress = n
506536
await ArchiveHelper.Extract7ZAuto(nodeDownloadPath, AssetsDir);
507537

508538
var nodeDir = Compat.IsMacOS
509-
? AssetsDir.JoinDir("node-v20.11.0-darwin-arm64")
510-
: AssetsDir.JoinDir("node-v20.11.0-linux-x64");
539+
? AssetsDir.JoinDir("node-v20.19.3-darwin-arm64")
540+
: AssetsDir.JoinDir("node-v20.19.3-linux-x64");
511541
Directory.Move(nodeDir, NodeDir);
512542

513543
progress?.Report(

StabilityMatrix.Avalonia/Helpers/WindowsPrerequisiteHelper.cs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ IPyInstallationManager pyInstallationManager
3434
private const string TkinterDownloadUrl =
3535
"https://cdn.lykos.ai/tkinter-cpython-embedded-3.10.11-win-x64.zip";
3636

37-
private const string NodeDownloadUrl = "https://nodejs.org/dist/v20.11.0/node-v20.11.0-win-x64.zip";
37+
private const string NodeDownloadUrl = "https://nodejs.org/dist/v20.19.3/node-v20.19.3-win-x64.zip";
3838

3939
private const string Dotnet7DownloadUrl =
4040
"https://download.visualstudio.microsoft.com/download/pr/2133b143-9c4f-4daa-99b0-34fa6035d67b/193ede446d922eb833f1bfe0239be3fc/dotnet-sdk-7.0.405-win-x64.zip";
@@ -89,6 +89,7 @@ private string GetPythonLibraryZipPath(PyVersion version) =>
8989
private string TkinterExtractPath => Path.Combine(AssetsDir, "Python310");
9090
private string TkinterExistsPath => Path.Combine(TkinterExtractPath, "tkinter");
9191
private string NodeExistsPath => Path.Combine(AssetsDir, "nodejs", "npm.cmd");
92+
private string NodeExePath => Path.Combine(AssetsDir, "nodejs", "node.exe");
9293
private string NodeDownloadPath => Path.Combine(AssetsDir, "nodejs.zip");
9394
private string Dotnet7DownloadPath => Path.Combine(AssetsDir, "dotnet-sdk-7.0.405-win-x64.zip");
9495
private string Dotnet8DownloadPath => Path.Combine(AssetsDir, "dotnet-sdk-8.0.101-win-x64.zip");
@@ -176,6 +177,20 @@ public Task<ProcessResult> GetGitOutput(ProcessArgs args, string? workingDirecto
176177
);
177178
}
178179

180+
private async Task<string> RunNode(
181+
ProcessArgs args,
182+
string? workingDirectory = null,
183+
IReadOnlyDictionary<string, string>? envVars = null
184+
)
185+
{
186+
var result = await ProcessRunner
187+
.GetProcessResultAsync(NodeExePath, args, workingDirectory, envVars)
188+
.ConfigureAwait(false);
189+
190+
result.EnsureSuccessExitCode();
191+
return result.StandardOutput ?? result.StandardError ?? string.Empty;
192+
}
193+
179194
public async Task RunNpm(
180195
ProcessArgs args,
181196
string? workingDirectory = null,
@@ -685,12 +700,31 @@ await downloadService.DownloadToFileAsync(
685700
[SupportedOSPlatform("windows")]
686701
public async Task InstallNodeIfNecessary(IProgress<ProgressReport>? progress = null)
687702
{
688-
if (File.Exists(NodeExistsPath))
689-
return;
703+
// NOTE TO FUTURE DEVS: if this is causing merge conflicts with dev, just nuke it we don't need anymore
704+
var nodeFolder = new DirectoryPath(AssetsDir, "nodejs");
705+
if (nodeFolder.Exists)
706+
{
707+
try
708+
{
709+
var result = await RunNode("-v");
710+
if (result.Contains("20.19.3"))
711+
{
712+
Logger.Debug("Node.js already installed at {NodeExistsPath}", NodeExistsPath);
713+
return;
714+
}
715+
}
716+
catch (Exception)
717+
{
718+
// ignored
719+
}
720+
721+
Logger.Warn("Node.js version mismatch, reinstalling...");
722+
await nodeFolder.DeleteAsync(true);
723+
}
690724

691725
await DownloadAndExtractPrerequisite(progress, NodeDownloadUrl, NodeDownloadPath, AssetsDir);
692726

693-
var extractedNodeDir = Path.Combine(AssetsDir, "node-v20.11.0-win-x64");
727+
var extractedNodeDir = Path.Combine(AssetsDir, "node-v20.19.3-win-x64");
694728
if (Directory.Exists(extractedNodeDir))
695729
{
696730
Directory.Move(extractedNodeDir, Path.Combine(AssetsDir, "nodejs"));

StabilityMatrix.Core/Helper/ImageMetadata.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Text;
33
using System.Text.Json;
44
using ExifLibrary;
5+
using KGySoft.CoreLibraries;
56
using MetadataExtractor;
67
using MetadataExtractor.Formats.Exif;
78
using MetadataExtractor.Formats.Png;

0 commit comments

Comments
 (0)