@@ -20,6 +20,7 @@ import (
2020const (
2121 darwin = "darwin"
2222 windows = "windows"
23+ linux = "linux"
2324)
2425
2526// New create new Flowser application.
@@ -29,7 +30,7 @@ func New() *App {
2930
3031type App struct {}
3132
32- var errorPlatformNotSupported = errors .New ("OS not supported, only supporting Windows and Mac OS " )
33+ var errorPlatformNotSupported = errors .New ("platform not supported, please submit an issue: https://github.com/onflowser/flowser/issues " )
3334
3435// Run starts the Flowser application with provided path to the flow project.
3536//
@@ -94,23 +95,26 @@ func (a *App) Remove(installDir string) error {
9495// unzip content from source compressed file to a target directory.
9596func (a * App ) unzip (source string , target string ) error {
9697 var cmd * exec.Cmd
98+
99+ appDir , err := a .appDir (target )
100+ if err != nil {
101+ return err
102+ }
103+
97104 switch runtime .GOOS {
98105 case darwin :
99106 // Use native unzip tool as it handles the creation of required symbolic links
100107 cmd = exec .Command ("unzip" , source , "-d" , target )
101108 case windows :
102- appDir , err := a .appDir (target )
103- if err != nil {
104- return err
105- }
106-
107109 if err := os .MkdirAll (appDir , os .ModePerm ); err != nil {
108110 return err
109111 }
110112
111113 // tar utility is available from Windows build 17063 consider using other command or a custom implementation
112114 // https://learn.microsoft.com/en-us/virtualization/community/team-blog/2017/20171219-tar-and-curl-come-to-windows
113115 cmd = exec .Command ("tar" , "-xf" , source , "-C" , appDir )
116+ case linux :
117+ cmd = exec .Command ("unzip" , source , "-d" , appDir )
114118 default :
115119 return errorPlatformNotSupported
116120 }
@@ -123,6 +127,7 @@ func (a *App) appDir(installDir string) (string, error) {
123127 files := map [string ]string {
124128 darwin : "Flowser.app" ,
125129 windows : "@flowserapp" ,
130+ linux : "Flowser" ,
126131 }
127132 executable , ok := files [runtime .GOOS ]
128133 if ! ok {
@@ -137,18 +142,25 @@ func (a *App) executable(installDir string) (string, error) {
137142 files := map [string ]string {
138143 darwin : "Contents/MacOS/Flowser" ,
139144 windows : "Flowser.exe" ,
145+ linux : "flowser" ,
140146 }
141- file , ok := files [runtime .GOOS ]
147+ execFileSubPath , ok := files [runtime .GOOS ]
142148 if ! ok {
143149 return "" , errorPlatformNotSupported
144150 }
145151
152+ // some linux installers may install app in folder present in PATH.
153+ execFilePath , err := exec .LookPath ("flowser" )
154+ if err == nil {
155+ return execFilePath , nil
156+ }
157+
146158 appDir , err := a .appDir (installDir )
147159 if err != nil {
148160 return "" , err
149161 }
150162
151- return path .Join (appDir , file ), nil
163+ return path .Join (appDir , execFileSubPath ), nil
152164}
153165
154166func downloadLatestReleaseAsset () (string , error ) {
@@ -189,10 +201,7 @@ func getLatestRelease() (*flowserRelease, error) {
189201 return nil , err
190202 }
191203 latestVersion := strings .Replace (* release .TagName , "v" , "" , 1 )
192- targetAssetName , err := getAssetName (latestVersion )
193- if err != nil {
194- return nil , err
195- }
204+ targetAssetName := getAssetName (latestVersion )
196205 for _ , asset := range release .Assets {
197206 if * asset .Name == targetAssetName {
198207 return & flowserRelease {
@@ -201,20 +210,9 @@ func getLatestRelease() (*flowserRelease, error) {
201210 }, nil
202211 }
203212 }
204- return nil , errors . New ( "no asset found" )
213+ return nil , fmt . Errorf ( " asset not found: %s" , targetAssetName )
205214}
206215
207- func getAssetName (version string ) (string , error ) {
208- isArm := strings .HasPrefix (runtime .GOARCH , "arm" )
209- switch runtime .GOOS {
210- case darwin :
211- if isArm {
212- return fmt .Sprintf ("Flowser-%s-arm64-mac.zip" , version ), nil
213- }
214- return fmt .Sprintf ("Flowser-%s-mac.zip" , version ), nil
215- case windows :
216- return fmt .Sprintf ("Flowser-%s-win.zip" , version ), nil
217- default :
218- return "" , errorPlatformNotSupported
219- }
216+ func getAssetName (version string ) string {
217+ return fmt .Sprintf ("Flowser-%s-%s-%s.zip" , version , runtime .GOOS , runtime .GOARCH )
220218}
0 commit comments