diff --git a/.gitignore b/.gitignore index 8417c3b42..a3dcd1a59 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ bin/ gui/filesystem_vfsdata.go kelp.prefs bind_*.go +bundler.json \ No newline at end of file diff --git a/bundler.json b/bundler.json deleted file mode 100644 index d4a474158..000000000 --- a/bundler.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "app_name": "Kelp", - "icon_path_darwin": "resources/kelp-icon@2x.icns", - "icon_path_linux": "resources/kelp-icon@2x.png", - "icon_path_windows": "resources/kelp-icon@2x.ico", - "bind": { - "output_path": "./cmd", - "package": "cmd" - } -} diff --git a/cmd/root.go b/cmd/root.go index 18fe747e2..7c7968ea0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -20,7 +20,6 @@ var env string const envRelease = "release" const envDev = "dev" - const rootShort = "Kelp is a free and open-source trading bot for the Stellar universal marketplace." const rootLong = `Kelp is a free and open-source trading bot for the Stellar universal marketplace (https://stellar.org). @@ -44,7 +43,15 @@ var RootCmd = &cobra.Command{ ` + version + ` ` fmt.Println(intro) - serverCmd.Run(ccmd, args) + + if hasUICapability { + serverCmd.Run(ccmd, args) + } else { + e := ccmd.Help() + if e != nil { + panic(e) + } + } }, } diff --git a/cmd/server.go b/cmd/server_amd64.go similarity index 99% rename from cmd/server.go rename to cmd/server_amd64.go index f2ea6ee85..c4ad05e7e 100644 --- a/cmd/server.go +++ b/cmd/server_amd64.go @@ -32,11 +32,6 @@ const kelpPrefsDirectory = ".kelp" const kelpAssetsPath = "/assets" const trayIconName = "kelp-icon@1-8x.png" -var serverCmd = &cobra.Command{ - Use: "server", - Short: "Serves the Kelp GUI", -} - type serverInputs struct { port *uint16 dev *bool @@ -47,6 +42,8 @@ type serverInputs struct { } func init() { + hasUICapability = true + options := serverInputs{} options.port = serverCmd.Flags().Uint16P("port", "p", 8000, "port on which to serve") options.dev = serverCmd.Flags().Bool("dev", false, "run in dev mode for hot-reloading of JS code") diff --git a/cmd/server_noop.go b/cmd/server_noop.go new file mode 100644 index 000000000..e1d5f76f5 --- /dev/null +++ b/cmd/server_noop.go @@ -0,0 +1,17 @@ +package cmd + +import ( + "log" + + "github.com/spf13/cobra" +) + +var hasUICapability = false + +var serverCmd = &cobra.Command{ + Use: "server", + Short: "Serves the Kelp GUI", + Run: func(ccmd *cobra.Command, args []string) { + log.Printf("Kelp GUI Server unsupported in this version: %s [%s]\n", version, gitHash) + }, +} diff --git a/scripts/build.sh b/scripts/build.sh index 3fa0b9824..ad8dea1a8 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -162,7 +162,11 @@ check_build_result $? echo "... finished embedding contents of gui/web/build into a .go file (env=$ENV)" echo "" -echo -n "generating the bind file in /cmd to create missing files ... " +echo -n "generating the bundler.json file in / to create missing files for current platform ... " +go run ./scripts/gen_bundler_json/gen_bundler_json.go > $KELP/bundler.json +check_build_result $? +echo "done" +echo -n "generating the bind file in /cmd to create missing files for current platform ... " astilectron-bundler bd -c $KELP/bundler.json check_build_result $? echo "done" @@ -194,6 +198,15 @@ then exit 0 fi # else, we are in deploy mode + +echo -n "generating the bundler.json file in / to create missing files for all remaining platforms ... " +go run ./scripts/gen_bundler_json/gen_bundler_json.go -a > $KELP/bundler.json +check_build_result $? +echo "done" +echo -n "generating the bind file in /cmd to create missing files for all remaining platforms ... " +astilectron-bundler bd -c $KELP/bundler.json +check_build_result $? +echo "done" echo "" ARCHIVE_DIR=build/$DATE @@ -299,6 +312,15 @@ do echo -n "cleaning up UI: $ARCHIVE_DIR_SOURCE_UI ... " rm -rf $ARCHIVE_DIR_SOURCE_UI echo "successful" + + if [[ -f "$KELP/windows.syso" ]] + then + echo -n "removing windows.syso file ... " + rm $KELP/windows.syso + check_build_result $? + echo "successful" + fi + echo "" done diff --git a/scripts/gen_bundler_json/gen_bundler_json.go b/scripts/gen_bundler_json/gen_bundler_json.go new file mode 100644 index 000000000..f111dbaee --- /dev/null +++ b/scripts/gen_bundler_json/gen_bundler_json.go @@ -0,0 +1,57 @@ +package main + +import ( + "encoding/json" + "flag" + "fmt" +) + +var bundler = `{ + "app_name": "Kelp", + "icon_path_darwin": "resources/kelp-icon@2x.icns", + "icon_path_linux": "resources/kelp-icon@2x.png", + "icon_path_windows": "resources/kelp-icon@2x.ico", + "bind": { + "output_path": "./cmd", + "package": "cmd" + } +}` + +var environments = `{ + "environments": [ + {"os": "darwin", "arch": "amd64"}, + {"os": "linux", "arch": "amd64"}, + {"os": "windows", "arch": "amd64"} + ] +}` + +func main() { + buildAllP := flag.Bool("a", false, "whether to build for all platforms (default builds only for native platform)") + flag.Parse() + buildAll := *buildAllP + + var bundlerJSON map[string]interface{} + e := json.Unmarshal([]byte(bundler), &bundlerJSON) + if e != nil { + panic(e) + } + + if buildAll { + var environmentsJSON map[string]interface{} + e := json.Unmarshal([]byte(environments), &environmentsJSON) + if e != nil { + panic(e) + } + + for k, v := range environmentsJSON { + bundlerJSON[k] = v + } + } + + jsonBytes, e := json.MarshalIndent(bundlerJSON, "", " ") + if e != nil { + panic(e) + } + jsonString := string(jsonBytes) + fmt.Println(jsonString) +} diff --git a/support/sdk/ccxt.go b/support/sdk/ccxt.go index 8de1a539f..fca54945a 100644 --- a/support/sdk/ccxt.go +++ b/support/sdk/ccxt.go @@ -109,7 +109,7 @@ func loadExchangeList() { if eMsg1 && eMsg2 && eMsg3 { log.Printf("ccxt-rest is not running at %s so we cannot include those exchanges: %s", ccxtBaseURL, e.Error()) } else { - panic(fmt.Errorf("error getting list of supported exchanges by CCXT: %s", e)) + log.Printf("error getting list of supported exchanges at URL %s by CCXT so we cannot include those exchanges: %s", ccxtBaseURL, e) } } exchangeList = &output