5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 23:40:43 +08:00

[windows] Better wails doctor diagnostics

This commit is contained in:
Lea Anthony 2021-05-30 09:34:07 +10:00
parent be39b293b5
commit 1eba408f64
3 changed files with 77 additions and 2 deletions

View File

@ -68,7 +68,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
name := dependency.Name name := dependency.Name
if dependency.Optional { if dependency.Optional {
name += "*" name = "*" + name
hasOptionalDependencies = true hasOptionalDependencies = true
} }
packageName := "Unknown" packageName := "Unknown"
@ -109,6 +109,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
fmt.Fprintf(w, "* - Optional Dependency\n") fmt.Fprintf(w, "* - Optional Dependency\n")
} }
w.Flush() w.Flush()
logger.Println("")
logger.Println("Diagnosis") logger.Println("Diagnosis")
logger.Println("---------") logger.Println("---------")

View File

@ -3,6 +3,8 @@ package system
import ( import (
"github.com/wailsapp/wails/v2/internal/system/operatingsystem" "github.com/wailsapp/wails/v2/internal/system/operatingsystem"
"github.com/wailsapp/wails/v2/internal/system/packagemanager" "github.com/wailsapp/wails/v2/internal/system/packagemanager"
"os/exec"
"strings"
) )
// Info holds information about the current operating system, // Info holds information about the current operating system,
@ -24,3 +26,47 @@ func GetInfo() (*Info, error) {
} }
return &result, nil return &result, nil
} }
func checkNPM() *packagemanager.Dependancy {
// Check for npm
output, err := exec.Command("npm", "-version").Output()
installed := true
version := ""
if err != nil {
installed = false
} else {
version = strings.TrimSpace(strings.Split(string(output), "\n")[0])
}
return &packagemanager.Dependancy{
Name: "npm ",
PackageName: "N/A",
Installed: installed,
InstallCommand: "Install from https://nodejs.org/en/download/",
Version: version,
Optional: false,
External: false,
}
}
func checkUPX() *packagemanager.Dependancy {
// Check for npm
output, err := exec.Command("upx", "-V").Output()
installed := true
version := ""
if err != nil {
installed = false
} else {
version = strings.TrimSpace(strings.Split(string(output), "\n")[0])
}
return &packagemanager.Dependancy{
Name: "upx ",
PackageName: "N/A",
Installed: installed,
InstallCommand: "Install from https://upx.github.io/",
Version: version,
Optional: true,
External: false,
}
}

View File

@ -2,7 +2,12 @@
package system package system
import "github.com/wailsapp/wails/v2/internal/system/operatingsystem" import (
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
"os/exec"
"strings"
)
func (i *Info) discover() error { func (i *Info) discover() error {
@ -12,5 +17,28 @@ func (i *Info) discover() error {
return err return err
} }
i.OS = osinfo i.OS = osinfo
// Check for gcc
output, err := exec.Command("gcc", "--version").Output()
installed := true
version := ""
if err != nil {
installed = false
} else {
version = strings.TrimSpace(strings.Split(string(output), "\n")[0])
}
gccDependency := &packagemanager.Dependancy{
Name: "gcc ",
PackageName: "N/A",
Installed: installed,
InstallCommand: "",
Version: version,
Optional: false,
External: false,
}
i.Dependencies = append(i.Dependencies, gccDependency)
i.Dependencies = append(i.Dependencies, checkNPM())
i.Dependencies = append(i.Dependencies, checkUPX())
return nil return nil
} }