From 94a6e0bd46ce700312642970fd4225e422aa78b9 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Tue, 2 Apr 2024 18:51:01 -0500 Subject: [PATCH] fix Makefile ; make format --- Makefile | 74 ++++------------------------ cmd/transport-setup/commands/root.go | 63 +++++++++++------------ 2 files changed, 41 insertions(+), 96 deletions(-) diff --git a/Makefile b/Makefile index befef9e0..aa490e06 100644 --- a/Makefile +++ b/Makefile @@ -45,88 +45,32 @@ export REGISTRY=${DOCKER_REGISTRY} ## : ## _ [Prepare code] dep: ## Sorts dependencies + @command -v yarn >/dev/null 2>&1 && yarn --cwd ./pkg/node-visualizer/web install || true # GO111MODULE=on GOPRIVATE=github.com/skycoin/* go get -v github.com/skycoin/skywire@master - GO111MODULE=on GOPRIVATE=github.com/skycoin/* go mod vendor -v - yarn --cwd ./pkg/node-visualizer/web install +# GO111MODULE=on GOPRIVATE=github.com/skycoin/* go mod vendor -v format: dep ## Formats the code. Must have goimports and goimports-reviser installed (use make install-linters). - goimports -w -local github.com/skycoin/skywire-services ./pkg - goimports -w -local github.com/skycoin/skywire-services ./cmd - goimports -w -local github.com/skycoin/skywire-services ./internal - find . -type f -name '*.go' -not -path "./vendor/*" -exec goimports-reviser -project-name ${PROJECT_BASE} {} \; + goimports -w -local github.com/skycoin/skywire-services ./pkg ./cmd ./internal + find . -type f -name '*.go' -not -path "./.git/*" -not -path "./vendor/*" -exec goimports-reviser -project-name ${PROJECT_BASE} {} \; ## : ## _ [Build, install, clean] build: dep ## Build binaries - ${OPTS} go build ${BUILD_OPTS} -o ./bin/route-finder ./cmd/route-finder - ${OPTS} go build ${BUILD_OPTS} -o ./bin/setup-node ./cmd/setup-node - ${OPTS} go build ${BUILD_OPTS} -o ./bin/transport-discovery ./cmd/transport-discovery - ${OPTS} go build ${BUILD_OPTS} -o ./bin/address-resolver ./cmd/address-resolver - ${OPTS} go build ${BUILD_OPTS} -o ./bin/sw-env ./cmd/sw-env - ${OPTS} go build ${BUILD_OPTS} -o ./bin/keys-gen ./cmd/keys-gen - ${OPTS} go build ${BUILD_OPTS} -o ./bin/network-monitor ./cmd/network-monitor - ${OPTS} go build ${BUILD_OPTS} -o ./apps/vpn-client ./cmd/vpn-lite-client - ${OPTS} go build ${BUILD_OPTS} -o ./bin/transport-setup ./cmd/transport-setup - ${OPTS} go build ${BUILD_OPTS} -o ./bin/config-bootstrapper ./cmd/config-bootstrapper - ${OPTS} go build ${BUILD_OPTS} -o ./bin/liveness-checker ./cmd/liveness-checker - ${OPTS} go build ${BUILD_OPTS} -o ./bin/dmsg-monitor ./cmd/dmsg-monitor - ${OPTS} go build ${BUILD_OPTS} -o ./bin/tpd-monitor ./cmd/tpd-monitor - ${OPTS} go build ${BUILD_OPTS} -o ./bin/vpn-monitor ./cmd/vpn-monitor - ${OPTS} go build ${BUILD_OPTS} -o ./bin/skysocks-monitor ./cmd/skysocks-monitor - ${OPTS} go build ${BUILD_OPTS} -o ./apps/skysocks-client ./cmd/skysocks-lite-client - ${OPTS} go build ${BUILD_OPTS} -o ./bin/public-visor-monitor ./cmd/public-visor-monitor - ${OPTS} go build ${BUILD_OPTS} -o ./bin/uptime-tracker ./cmd/uptime-tracker + ${OPTS} go build ${BUILD_OPTS} -o ./bin/skywire-services ./cmd/skywire-services + # yarn --cwd ./pkg/node-visualizer/web build # rm -rf ./pkg/node-visualizer/api/build/static # mv ./pkg/node-visualizer/web/build/* ./pkg/node-visualizer/api/build # ${OPTS} go build ${BUILD_OPTS} -o ./bin/node-visualizer ./cmd/node-visualizer build-deploy: ## Build for deployment Docker images - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/address-resolver ./cmd/address-resolver - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/route-finder ./cmd/route-finder - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/setup-node ./cmd/setup-node - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/transport-discovery ./cmd/transport-discovery - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/network-monitor ./cmd/network-monitor - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/vpn-client ./cmd/vpn-lite-client - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/transport-setup ./cmd/transport-setup - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/node-visualizer ./cmd/node-visualizer - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/dmsg-monitor ./cmd/dmsg-monitor - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/tpd-monitor ./cmd/tpd-monitor - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/vpn-monitor ./cmd/vpn-monitor - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/skysocks-monitor ./cmd/skysocks-monitor - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/skysocks-client ./cmd/skysocks-lite-client - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/public-visor-monitor ./cmd/public-visor-monitor - ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/uptime-tracker ./cmd/uptime-tracker + ${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/skywire-services ./cmd/skywire-services build-race: dep ## Build binaries - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/route-finder ./cmd/route-finder - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/setup-node ./cmd/setup-node - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/transport-discovery ./cmd/transport-discovery - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/address-resolver ./cmd/address-resolver - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/sw-env ./cmd/sw-env - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/keys-gen ./cmd/keys-gen - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/network-monitor ./cmd/network-monitor - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/vpn-client ./cmd/vpn-lite-client - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/transport-setup ./cmd/transport-setup - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/node-visualizer ./cmd/node-visualizer - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/dmsg-monitor ./cmd/dmsg-monitor - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/tpd-monitor ./cmd/tpd-monitor - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/vpn-monitor ./cmd/vpn-monitor - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/skysocks-monitor ./cmd/skysocks-monitor - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/skysocks-client ./cmd/skysocks-lite-client - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/public-visor-monitor ./cmd/public-visor-monitor - ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/uptime-tracker ./cmd/uptime-tracker + ${OPTS} go build ${BUILD_OPTS} -race -o ./bin/skywire-services ./cmd/skywire-services install: ## Install route-finder, transport-discovery, address-resolver, sw-env, keys-gen, network-monitor, node-visualizer - ${OPTS} go install ${BUILD_OPTS} \ - ./cmd/route-finder \ - ./cmd/transport-discovery \ - ./cmd/address-resolver \ - ./cmd/sw-env \ - ./cmd/keys-gen \ - ./cmd/network-monitor \ - ./cmd/uptime-tracker \ - ./cmd/node-visualizer + ${OPTS} go install ${BUILD_OPTS} ./cmd/skywire-services clean: ## Clean compiled binaries rm -rf bin diff --git a/cmd/transport-setup/commands/root.go b/cmd/transport-setup/commands/root.go index b818f2fd..d267aeeb 100644 --- a/cmd/transport-setup/commands/root.go +++ b/cmd/transport-setup/commands/root.go @@ -2,6 +2,7 @@ package commands import ( + "encoding/json" "fmt" "log" "net/http" @@ -9,30 +10,30 @@ import ( "path/filepath" "strings" "time" - "encoding/json" + "github.com/bitfield/script" "github.com/google/uuid" - "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/buildinfo" + "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/spf13/cobra" "github.com/tidwall/pretty" - "github.com/bitfield/script" + "github.com/skycoin/skywire-services/pkg/transport-setup/api" "github.com/skycoin/skywire-services/pkg/transport-setup/config" ) var ( - pk1 cipher.PubKey - pk2 cipher.PubKey + pk1 cipher.PubKey + pk2 cipher.PubKey logLvl string configFile string - tpsnAddr string - fromPK string - toPK string - tpID string - tpType string - nice bool + tpsnAddr string + fromPK string + toPK string + tpID string + tpType string + nice bool ) func init() { @@ -114,9 +115,9 @@ Takes config in the following format: } var addTPCmd = &cobra.Command{ - Use: "add", - Short: "add transport to remote visor", - Long: ``, + Use: "add", + Short: "add transport to remote visor", + Long: ``, SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, @@ -142,22 +143,22 @@ var addTPCmd = &cobra.Command{ if err != nil { log.Fatalf("Error: ", err) } - res, err := script.Echo(string(addtpJSON)).Post(tpsnAddr+"/add").String() + res, err := script.Echo(string(addtpJSON)).Post(tpsnAddr + "/add").String() if err != nil { - log.Fatalf("error: ",err) + log.Fatalf("error: ", err) } if nice { - fmt.Printf("%v",string(pretty.Color(pretty.Pretty([]byte(res)), nil))) + fmt.Printf("%v", string(pretty.Color(pretty.Pretty([]byte(res)), nil))) } else { - fmt.Printf("%v",res) + fmt.Printf("%v", res) } }, } var rmTPCmd = &cobra.Command{ - Use: "rm", - Short: "remove transport from remote visor", - Long: ``, + Use: "rm", + Short: "remove transport from remote visor", + Long: ``, SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, @@ -179,34 +180,34 @@ var rmTPCmd = &cobra.Command{ if err != nil { log.Fatalf("Error: ", err) } - res, err := script.Echo(string(rmtpJSON)).Post(tpsnAddr+"/remove").String() + res, err := script.Echo(string(rmtpJSON)).Post(tpsnAddr + "/remove").String() if err != nil { - log.Fatalf("error: ",err) + log.Fatalf("error: ", err) } if nice { - fmt.Printf("%v",string(pretty.Color(pretty.Pretty([]byte(res)), nil))) + fmt.Printf("%v", string(pretty.Color(pretty.Pretty([]byte(res)), nil))) } else { - fmt.Printf("%v",res) + fmt.Printf("%v", res) } }, } var listTPCmd = &cobra.Command{ - Use: "list", - Short: "list transports of remote visor", - Long: ``, + Use: "list", + Short: "list transports of remote visor", + Long: ``, SilenceErrors: true, SilenceUsage: true, DisableSuggestions: true, DisableFlagsInUseLine: true, Run: func(_ *cobra.Command, args []string) { - res, err := script.Get(tpsnAddr+"/"+fromPK+"/transports").String() + res, err := script.Get(tpsnAddr + "/" + fromPK + "/transports").String() if err != nil { log.Fatal("something unexpected happened: ", err, res) } if nice { - fmt.Printf("%v",string(pretty.Color(pretty.Pretty([]byte(res)), nil))) + fmt.Printf("%v", string(pretty.Color(pretty.Pretty([]byte(res)), nil))) } else { - fmt.Printf("%v",res) + fmt.Printf("%v", res) } }, }