From b93c981fcd1ea35910c9d847ac5cbc3180ddca2a Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Tue, 13 Jun 2023 11:30:54 +1000 Subject: [PATCH] main: Added better errors for git, node or npm not installed --- FireWallet/FireWallet.csproj | 2 +- FireWallet/MainForm.cs | 99 ++++++++++++++++++++++++++ FireWalletSetup/FireWalletSetup.vdproj | 6 +- 3 files changed, 103 insertions(+), 4 deletions(-) diff --git a/FireWallet/FireWallet.csproj b/FireWallet/FireWallet.csproj index f5cb4dd..a497ee6 100644 --- a/FireWallet/FireWallet.csproj +++ b/FireWallet/FireWallet.csproj @@ -12,7 +12,7 @@ HSDBatcher.png https://github.com/Nathanwoodburn/FireWallet git - 2.4 + 2.4.1 diff --git a/FireWallet/MainForm.cs b/FireWallet/MainForm.cs index e5c417c..0203139 100644 --- a/FireWallet/MainForm.cs +++ b/FireWallet/MainForm.cs @@ -189,6 +189,13 @@ namespace FireWallet Notifyinstall.CloseNotification(); Notifyinstall.Dispose(); } + if (!Directory.Exists(dir + "hsd\\node_modules")) + { + AddLog("HSD install failed"); + this.Close(); + return false; + } + hsdProcess = new Process(); bool hideScreen = true; @@ -1315,6 +1322,72 @@ namespace FireWallet } } + // Check if git is installed + Process testInstalled = new Process(); + testInstalled.StartInfo.FileName = "git"; + testInstalled.StartInfo.Arguments = "-v"; + testInstalled.StartInfo.RedirectStandardOutput = true; + testInstalled.StartInfo.UseShellExecute = false; + testInstalled.StartInfo.CreateNoWindow = true; + testInstalled.Start(); + string outputInstalled = testInstalled.StandardOutput.ReadToEnd(); + testInstalled.WaitForExit(); + + if (!outputInstalled.Contains("git version")) + { + AddLog("Git is not installed"); + NotifyForm notifyForm = new NotifyForm("Git is not installed\nPlease install it to install HSD dependencies"); + notifyForm.ShowDialog(); + notifyForm.Dispose(); + this.Close(); + return; + } + + // Check if node installed + testInstalled = new Process(); + testInstalled.StartInfo.FileName = "node"; + testInstalled.StartInfo.Arguments = "-v"; + testInstalled.StartInfo.RedirectStandardOutput = true; + testInstalled.StartInfo.UseShellExecute = false; + testInstalled.StartInfo.CreateNoWindow = true; + testInstalled.Start(); + outputInstalled = testInstalled.StandardOutput.ReadToEnd(); + testInstalled.WaitForExit(); + + if (!outputInstalled.Contains("v")) + { + AddLog("Node is not installed"); + NotifyForm notifyForm = new NotifyForm("Node is not installed\nPlease install it to install HSD dependencies"); + notifyForm.ShowDialog(); + notifyForm.Dispose(); + this.Close(); + return; + } + + + // Check if npm installed + testInstalled = new Process(); + testInstalled.StartInfo.FileName = "npm"; + testInstalled.StartInfo.Arguments = "-v"; + testInstalled.StartInfo.RedirectStandardOutput = true; + testInstalled.StartInfo.UseShellExecute = false; + testInstalled.StartInfo.CreateNoWindow = true; + testInstalled.Start(); + outputInstalled = testInstalled.StandardOutput.ReadToEnd(); + testInstalled.WaitForExit(); + + if (outputInstalled.Length < 3) + { + AddLog("NPM is not installed"); + NotifyForm notifyForm = new NotifyForm("NPM is not installed\nPlease install it to install HSD dependencies"); + notifyForm.ShowDialog(); + notifyForm.Dispose(); + this.Close(); + return; + } + + + ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "git"; startInfo.Arguments = $"clone {repositoryUrl} {destinationPath}"; @@ -1362,6 +1435,32 @@ namespace FireWallet { AddLog("Git/NPM Install FAILED"); AddLog(ex.Message); + if (ex.Message.Contains("to start process 'git'")) + { + NotifyForm notifyForm = new NotifyForm("Git needs to be installed\nCheck logs for more details"); + notifyForm.ShowDialog(); + notifyForm.Dispose(); + } + else if (ex.Message.Contains("to start process 'node'")) + { + NotifyForm notifyForm = new NotifyForm("Node needs to be installed\nCheck logs for more details"); + notifyForm.ShowDialog(); + notifyForm.Dispose(); + } + else if (ex.Message.Contains("to start process 'npm'")) + { + NotifyForm notifyForm = new NotifyForm("NPM needs to be installed\nCheck logs for more details"); + notifyForm.ShowDialog(); + notifyForm.Dispose(); + } + else + { + + NotifyForm notifyForm = new NotifyForm("Git/NPM Install FAILED\nCheck logs for more details"); + notifyForm.ShowDialog(); + notifyForm.Dispose(); + } + this.Close(); } } public bool CheckNodeInstalled() diff --git a/FireWalletSetup/FireWalletSetup.vdproj b/FireWalletSetup/FireWalletSetup.vdproj index 01f1fb1..74f66ad 100644 --- a/FireWalletSetup/FireWalletSetup.vdproj +++ b/FireWalletSetup/FireWalletSetup.vdproj @@ -224,15 +224,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:FireWallet" - "ProductCode" = "8:{24264791-86B1-49B5-88C9-5042C3FA1BF2}" - "PackageCode" = "8:{8CC25786-EE60-4F7F-970E-D122B84DF8B5}" + "ProductCode" = "8:{139A6E5A-E5CE-4F8F-8A20-1E6357C7EBFE}" + "PackageCode" = "8:{D71D73E3-BF4D-4E86-B932-E1244DEC1973}" "UpgradeCode" = "8:{0C86F725-6B01-4173-AA05-3F0EDF481362}" "AspNetVersion" = "8:" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:FALSE" - "ProductVersion" = "8:2.4" + "ProductVersion" = "8:2.4.1" "Manufacturer" = "8:Nathan.Woodburn/" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:https://l.woodburn.au/discord"