Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ bin/
gui/filesystem_vfsdata.go
kelp.prefs
bind_*.go
bundler.json
10 changes: 0 additions & 10 deletions bundler.json

This file was deleted.

11 changes: 9 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand All @@ -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)
}
}
},
}

Expand Down
7 changes: 2 additions & 5 deletions cmd/server.go → cmd/server_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
17 changes: 17 additions & 0 deletions cmd/server_noop.go
Original file line number Diff line number Diff line change
@@ -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)
},
}
24 changes: 23 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
57 changes: 57 additions & 0 deletions scripts/gen_bundler_json/gen_bundler_json.go
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 1 addition & 1 deletion support/sdk/ccxt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down