Skip to content

Commit

Permalink
fix Makefile ; make format
Browse files Browse the repository at this point in the history
  • Loading branch information
0pcom committed Apr 2, 2024
1 parent a7d21e7 commit 94a6e0b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 96 deletions.
74 changes: 9 additions & 65 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 32 additions & 31 deletions cmd/transport-setup/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,38 @@
package commands

import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"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() {
Expand Down Expand Up @@ -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,
Expand All @@ -142,22 +143,22 @@ var addTPCmd = &cobra.Command{
if err != nil {
log.Fatalf("Error: ", err)

Check failure on line 144 in cmd/transport-setup/commands/root.go

View workflow job for this annotation

GitHub Actions / linux

log.Fatalf call has arguments but no formatting directives
}
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)

Check failure on line 148 in cmd/transport-setup/commands/root.go

View workflow job for this annotation

GitHub Actions / linux

log.Fatalf call has arguments but no formatting directives
}
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,
Expand All @@ -179,34 +180,34 @@ var rmTPCmd = &cobra.Command{
if err != nil {
log.Fatalf("Error: ", err)

Check failure on line 181 in cmd/transport-setup/commands/root.go

View workflow job for this annotation

GitHub Actions / linux

log.Fatalf call has arguments but no formatting directives
}
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)

Check failure on line 185 in cmd/transport-setup/commands/root.go

View workflow job for this annotation

GitHub Actions / linux

log.Fatalf call has arguments but no formatting directives
}
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)
}
},
}
Expand Down

0 comments on commit 94a6e0b

Please sign in to comment.