mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 23:20:51 +08:00
[windows] Better wails doctor diagnostics
This commit is contained in:
parent
be39b293b5
commit
1eba408f64
@ -68,7 +68,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
|
||||
name := dependency.Name
|
||||
if dependency.Optional {
|
||||
name += "*"
|
||||
name = "*" + name
|
||||
hasOptionalDependencies = true
|
||||
}
|
||||
packageName := "Unknown"
|
||||
@ -109,6 +109,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
fmt.Fprintf(w, "* - Optional Dependency\n")
|
||||
}
|
||||
w.Flush()
|
||||
logger.Println("")
|
||||
logger.Println("Diagnosis")
|
||||
logger.Println("---------")
|
||||
|
||||
|
@ -3,6 +3,8 @@ package system
|
||||
import (
|
||||
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
|
||||
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Info holds information about the current operating system,
|
||||
@ -24,3 +26,47 @@ func GetInfo() (*Info, error) {
|
||||
}
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,12 @@
|
||||
|
||||
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 {
|
||||
|
||||
@ -12,5 +17,28 @@ func (i *Info) discover() error {
|
||||
return err
|
||||
}
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user