mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 01:00:21 +08:00
[mac] better wails doctor
This commit is contained in:
parent
31cf04a944
commit
be39b293b5
@ -3,7 +3,6 @@ package doctor
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@ -25,14 +24,12 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
|||||||
logger := clilogger.New(w)
|
logger := clilogger.New(w)
|
||||||
|
|
||||||
app.PrintBanner()
|
app.PrintBanner()
|
||||||
logger.Print("Scanning system - please wait...")
|
|
||||||
|
|
||||||
// Get system info
|
// Get system info
|
||||||
info, err := system.GetInfo()
|
info, err := system.GetInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.Println("Done.")
|
|
||||||
|
|
||||||
// Start a new tabwriter
|
// Start a new tabwriter
|
||||||
w := new(tabwriter.Writer)
|
w := new(tabwriter.Writer)
|
||||||
@ -46,18 +43,16 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
|||||||
fmt.Fprintf(w, "%s\t%s\n", "Version: ", info.OS.Version)
|
fmt.Fprintf(w, "%s\t%s\n", "Version: ", info.OS.Version)
|
||||||
fmt.Fprintf(w, "%s\t%s\n", "ID:", info.OS.ID)
|
fmt.Fprintf(w, "%s\t%s\n", "ID:", info.OS.ID)
|
||||||
|
|
||||||
// Exit early if PM not found
|
|
||||||
if info.PM == nil {
|
|
||||||
w.Flush()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
fmt.Fprintf(w, "%s\t%s\n", "Package Manager: ", info.PM.Name())
|
|
||||||
|
|
||||||
// Output Go Information
|
// Output Go Information
|
||||||
fmt.Fprintf(w, "%s\t%s\n", "Go Version:", runtime.Version())
|
fmt.Fprintf(w, "%s\t%s\n", "Go Version:", runtime.Version())
|
||||||
fmt.Fprintf(w, "%s\t%s\n", "Platform:", runtime.GOOS)
|
fmt.Fprintf(w, "%s\t%s\n", "Platform:", runtime.GOOS)
|
||||||
fmt.Fprintf(w, "%s\t%s\n", "Architecture:", runtime.GOARCH)
|
fmt.Fprintf(w, "%s\t%s\n", "Architecture:", runtime.GOARCH)
|
||||||
|
|
||||||
|
// Exit early if PM not found
|
||||||
|
if info.PM != nil {
|
||||||
|
fmt.Fprintf(w, "%s\t%s\n", "Package Manager: ", info.PM.Name())
|
||||||
|
}
|
||||||
|
|
||||||
// Output Dependencies Status
|
// Output Dependencies Status
|
||||||
var dependenciesMissing = []string{}
|
var dependenciesMissing = []string{}
|
||||||
var externalPackages = []*packagemanager.Dependancy{}
|
var externalPackages = []*packagemanager.Dependancy{}
|
||||||
@ -67,12 +62,14 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
|||||||
fmt.Fprintf(w, "Dependency\tPackage Name\tStatus\tVersion\n")
|
fmt.Fprintf(w, "Dependency\tPackage Name\tStatus\tVersion\n")
|
||||||
fmt.Fprintf(w, "----------\t------------\t------\t-------\n")
|
fmt.Fprintf(w, "----------\t------------\t------\t-------\n")
|
||||||
|
|
||||||
|
hasOptionalDependencies := false
|
||||||
// Loop over dependencies
|
// Loop over dependencies
|
||||||
for _, dependency := range info.Dependencies {
|
for _, dependency := range info.Dependencies {
|
||||||
|
|
||||||
name := dependency.Name
|
name := dependency.Name
|
||||||
if dependency.Optional {
|
if dependency.Optional {
|
||||||
name += "*"
|
name += "*"
|
||||||
|
hasOptionalDependencies = true
|
||||||
}
|
}
|
||||||
packageName := "Unknown"
|
packageName := "Unknown"
|
||||||
status := "Not Found"
|
status := "Not Found"
|
||||||
@ -107,12 +104,13 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
|||||||
|
|
||||||
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", name, packageName, status, dependency.Version)
|
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", name, packageName, status, dependency.Version)
|
||||||
}
|
}
|
||||||
|
if hasOptionalDependencies {
|
||||||
fmt.Fprintf(w, "\n")
|
fmt.Fprintf(w, "\n")
|
||||||
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("---------\n")
|
logger.Println("---------")
|
||||||
|
|
||||||
// Generate an appropriate diagnosis
|
// Generate an appropriate diagnosis
|
||||||
|
|
||||||
@ -121,11 +119,11 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if dependenciesAvailableRequired != 0 {
|
if dependenciesAvailableRequired != 0 {
|
||||||
log.Println("Install required packages using: " + info.Dependencies.InstallAllRequiredCommand())
|
logger.Println("Install required packages using: " + info.Dependencies.InstallAllRequiredCommand())
|
||||||
}
|
}
|
||||||
|
|
||||||
if dependenciesAvailableOptional != 0 {
|
if dependenciesAvailableOptional != 0 {
|
||||||
log.Println("Install optional packages using: " + info.Dependencies.InstallAllOptionalCommand())
|
logger.Println("Install optional packages using: " + info.Dependencies.InstallAllOptionalCommand())
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(externalPackages) > 0 {
|
if len(externalPackages) > 0 {
|
||||||
@ -133,18 +131,18 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
|||||||
if p.Optional {
|
if p.Optional {
|
||||||
print("[Optional] ")
|
print("[Optional] ")
|
||||||
}
|
}
|
||||||
log.Println("Install " + p.Name + ": " + p.InstallCommand)
|
logger.Println("Install " + p.Name + ": " + p.InstallCommand)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(dependenciesMissing) != 0 {
|
if len(dependenciesMissing) != 0 {
|
||||||
// TODO: Check if apps are available locally and if so, adjust the diagnosis
|
// TODO: Check if apps are available locally and if so, adjust the diagnosis
|
||||||
log.Println("Fatal:")
|
logger.Println("Fatal:")
|
||||||
log.Println("Required dependencies missing: " + strings.Join(dependenciesMissing, " "))
|
logger.Println("Required dependencies missing: " + strings.Join(dependenciesMissing, " "))
|
||||||
log.Println("Please read this article on how to resolve this: https://wails.app/guides/resolving-missing-packages")
|
logger.Println("Please read this article on how to resolve this: https://wails.app/guides/resolving-missing-packages")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("")
|
logger.Println("")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2,7 +2,14 @@
|
|||||||
|
|
||||||
package system
|
package system
|
||||||
|
|
||||||
import "github.com/wailsapp/wails/v2/internal/system/operatingsystem"
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
|
||||||
|
)
|
||||||
|
|
||||||
func (i *Info) discover() error {
|
func (i *Info) discover() error {
|
||||||
var err error
|
var err error
|
||||||
@ -11,5 +18,26 @@ func (i *Info) discover() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
i.OS = osinfo
|
i.OS = osinfo
|
||||||
|
|
||||||
|
// Check for xcode command line tools
|
||||||
|
output, err := exec.Command("xcode-select", "-v").Output()
|
||||||
|
installed := true
|
||||||
|
version := ""
|
||||||
|
if err != nil {
|
||||||
|
installed = false
|
||||||
|
} else {
|
||||||
|
version = strings.TrimPrefix(string(output), "xcode-select version ")
|
||||||
|
version = strings.TrimSuffix(version, ".")
|
||||||
|
}
|
||||||
|
xcodeDep := &packagemanager.Dependancy{
|
||||||
|
Name: "xcode command line tools ",
|
||||||
|
PackageName: "N/A",
|
||||||
|
Installed: installed,
|
||||||
|
InstallCommand: "xcode-select --install",
|
||||||
|
Version: version,
|
||||||
|
Optional: false,
|
||||||
|
External: false,
|
||||||
|
}
|
||||||
|
i.Dependencies = append(i.Dependencies, xcodeDep)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user