Skip to content

Commit

Permalink
Merge pull request #1272 from onflowser/update-flowser-linux-support
Browse files Browse the repository at this point in the history
Update flowser linux support
  • Loading branch information
chasefleming authored Nov 15, 2023
2 parents a9c67ee + 0fedaa5 commit abd7873
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f
github.com/onflow/flow-emulator v0.57.3
github.com/onflow/flow-go-sdk v0.41.16
github.com/onflowser/flowser/v2 v2.0.14-beta
github.com/onflowser/flowser/v3 v3.1.3
github.com/pkg/errors v0.9.1
github.com/psiemens/sconfig v0.1.0
github.com/radovskyb/watcher v1.0.7
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,10 @@ github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d h1:gAEqYPn3DS83rHIKEpsa
github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d/go.mod h1:iMC8gkLqu4nkbkAla5HkSBb+FGyQOZiWz3DYm2wSXCk=
github.com/onflowser/flowser/v2 v2.0.14-beta h1:yvmXyGUkR7e0+Z1t7Gyn+p2Q+CpUmgsqF01M7EtNr3k=
github.com/onflowser/flowser/v2 v2.0.14-beta/go.mod h1:g/nfelBOx0A4j60Twsr7GsmKapr2oxtRZQS0lwPHgZY=
github.com/onflowser/flowser/v3 v3.1.2 h1:ctMBVES3o2wG5b/tuYTYtYoxzeH4M6nsmbPoHkUOOEI=
github.com/onflowser/flowser/v3 v3.1.2/go.mod h1:3UZqdIyKVh+wXOhz9p2YrVl+ZvxohxhAmdM68dDKYPE=
github.com/onflowser/flowser/v3 v3.1.3 h1:Y8HyQRwhroCWGcV2UPBD+GZDLHTzu2GjdaBoIEn6YAU=
github.com/onflowser/flowser/v3 v3.1.3/go.mod h1:3UZqdIyKVh+wXOhz9p2YrVl+ZvxohxhAmdM68dDKYPE=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
6 changes: 6 additions & 0 deletions internal/settings/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var defaults = map[string]any{
const (
Darwin = "darwin"
Windows = "windows"
Linux = "linux"
)

// getDefaultInstallDir returns default installation directory based on the OS.
Expand All @@ -49,6 +50,11 @@ func getDefaultInstallDir() string {
// https://superuser.com/questions/1327037/what-choices-do-i-have-about-where-to-install-software-on-windows-10
usr, _ := user.Current() // safe to ignore cache errors
return fmt.Sprintf(`%s\AppData\Local\Programs`, usr.HomeDir)
case Linux:
// https://unix.stackexchange.com/questions/127076/into-which-directory-should-i-install-programs-in-linux
usr, _ := user.Current() // safe to ignore cache errors
// Use path in users home folder to not require sudo permissions for installation
return fmt.Sprintf(`%s/.local/bin`, usr.HomeDir)
default:
return ""
}
Expand Down
12 changes: 3 additions & 9 deletions internal/tools/flowser.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
package tools

import (
"errors"
"fmt"
"os"
"runtime"

"github.com/onflowser/flowser/v2/pkg/flowser"
"github.com/onflowser/flowser/v3/pkg/flowser"
"github.com/spf13/cobra"

"github.com/onflow/flow-cli/flowkit"
Expand Down Expand Up @@ -58,11 +57,6 @@ func runFlowser(
reader flowkit.ReaderWriter,
_ flowkit.Services,
) (command.Result, error) {
if runtime.GOOS != settings.Windows && runtime.GOOS != settings.Darwin {
fmt.Println("If you want Flowser to be supported on Linux please vote here: https://github.com/onflowser/flowser/discussions/142")
return nil, errors.New("OS not supported, only supporting Windows and Mac OS")
}

flowser := flowser.New()

installPath, err := settings.GetFlowserPath()
Expand Down Expand Up @@ -111,8 +105,8 @@ func installFlowser(flowser *flowser.App, installPath string) (string, error) {
return installPath, nil
}

// we only allow custom paths on Windows since on MacOS apps needs to be installed inside Application folder
if runtime.GOOS == settings.Windows {
// MacOS apps must always be installed inside Application folder
if runtime.GOOS != settings.Darwin {
installPath = util.InstallPathPrompt(installPath)
_ = settings.SetFlowserPath(installPath)
}
Expand Down

0 comments on commit abd7873

Please sign in to comment.