Skip to content

Commit

Permalink
Remove frontend from main cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Jun 29, 2020
1 parent dcd8f8f commit 1a0dc5c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
22 changes: 8 additions & 14 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ type Env struct {
NodeJS bool `json:"node_js"`
}

func startServe(verbose bool) (*exec.Cmd, *exec.Cmd, *exec.Cmd) {
func startServe(verbose bool) (*exec.Cmd, *exec.Cmd) {
appName, _ := getAppAndModule()
cmdNpm := exec.Command("npm", "run", "dev")
cmdNpm.Dir = "frontend"
if verbose {
cmdNpm.Stdout = os.Stdout
}
cmdNpm.Start()
fmt.Printf("\n📦 Installing dependencies...\n")
cmdMod := exec.Command("/bin/sh", "-c", "go mod tidy")
if verbose {
Expand Down Expand Up @@ -123,7 +117,7 @@ func startServe(verbose bool) (*exec.Cmd, *exec.Cmd, *exec.Cmd) {
if !verbose {
fmt.Printf("\n🚀 Get started: http://localhost:12345/\n\n")
}
return cmdTendermint, cmdREST, cmdNpm
return cmdTendermint, cmdREST
}

var serveCmd = &cobra.Command{
Expand All @@ -132,19 +126,16 @@ var serveCmd = &cobra.Command{
Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
verbose, _ := cmd.Flags().GetBool("verbose")
cmdt, cmdr, cmdn := startServe(verbose)
cmdt, cmdr := startServe(verbose)
w := watcher.New()
w.SetMaxEvents(1)
go func() {
for {
select {
case <-w.Event:
// TODO: Find a better way to kill a node server
// exec.Command("/bin/sh", "-c", "kill -9 $(lsof -i:8080 -t)").Run()
cmdn.Process.Kill()
cmdr.Process.Kill()
cmdt.Process.Kill()
cmdt, cmdr, cmdn = startServe(verbose)
cmdt, cmdr = startServe(verbose)
case err := <-w.Error:
log.Fatalln(err)
case <-w.Closed:
Expand All @@ -155,7 +146,10 @@ var serveCmd = &cobra.Command{
if err := w.AddRecursive("."); err != nil {
log.Fatalln(err)
}
if err := w.Ignore("./frontend", "./.git"); err != nil {
if err := w.Ignore("./frontend"); err != nil {
log.Fatalln(err)
}
if err := w.Ignore("./.git"); err != nil {
log.Fatalln(err)
}
if err := w.Start(time.Millisecond * 100); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ starport type post title body
This command generates a type `Post` with two fields: `title` and `body`.

To add a post run `blogcli tx blog create-post "My title" "This is a blog" --from=me`.

## Front-end application

By default the generator creates a front-end application in `frontend` directory. If you have Node.js installed, run `cd frontend && npm run dev` to launch the app. With this app you can generate accounts, request tokens from a faucet, list and create objects generated with `starport type`.
2 changes: 1 addition & 1 deletion ui/src/views/Start.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="card__desc__h1">User interface</div>
<div class="card__desc__p">
<span v-if="running.frontend">The front-end of your app. A Vue application is running on port <span class="card__desc__tag">8080</span></span>
<span v-else>Loading...</span>
<span v-else>To start the app, run: <code>cd frontend && npm run dev</code></span>
</div>
</div>
</a>
Expand Down

0 comments on commit 1a0dc5c

Please sign in to comment.