Skip to content

Commit

Permalink
refactor folder structure for main & cli (#57)
Browse files Browse the repository at this point in the history
* refactor folder structure for main & cli

* introduced a new package called `interface` as a single bridge to expose Starport's features to possibly multiple targets e.g. cli, grpc, http.
* cmd and main packages are moved under `interface/cli/starport`.
  * `starport` package name for the `main` program is chosen to enable easy, named installations with `go get github.com/tendermint/starport/...` which should produce the binary with `starport` name by default.
* simplifed the `Makefile` regarding to other changes.

* fix ui and app template paths

* change ./scripts/dev as ./scripts/starport

* fix typed template path

* templates: revert template paths for packr
  • Loading branch information
ilgooz authored Jul 28, 2020
1 parent 37e152c commit 612c736
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod:
build: mod
@go get -u github.com/gobuffalo/packr/v2/packr2
@packr2
@go build -mod=readonly -o build/starport main.go
@go build -mod=readonly -o build/ ./interface/cli/...
@packr2 clean
@go mod tidy

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ require (
golang.org/x/mod v0.3.0
golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 // indirect
golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6 // indirect
golang.org/x/sys v0.0.0-20200727154430-2d971f7391a4 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6 h1:X9xIZ1YU8bLZA3l6gqDUHSFiD0GFI9S548h6C8nDtOY=
golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200727154430-2d971f7391a4 h1:gtF+PUC1CD1a9ocwQHbVNXuTp6RQsAYt6tpi6zjT81Y=
golang.org/x/sys v0.0.0-20200727154430-2d971f7391a4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/serve.go → interface/cli/starport/cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func startServe(path string, verbose bool) (*exec.Cmd, *exec.Cmd) {
fmt.Printf("🔧 Running dev interface at http://localhost:12345\n\n")
}
router := mux.NewRouter()
devUI := packr.New("ui/dist", "../ui/dist")
devUI := packr.New("ui/dist", "../../../../ui/dist")
router.HandleFunc("/env", func(w http.ResponseWriter, r *http.Request) {
env := Env{appName, isCommandAvailable("node")}
js, err := json.Marshal(env)
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions interface/cli/starport/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/tendermint/starport/interface/cli/starport/cmd"

func main() {
cmd.Execute()
}
7 changes: 0 additions & 7 deletions main.go

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/dev

This file was deleted.

4 changes: 4 additions & 0 deletions scripts/starport
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# a development mode entrypoint to Starport cli.
go run ./interface/cli/starport "$@"

0 comments on commit 612c736

Please sign in to comment.