From 1a0dc5cf216fa9ddf37852f9a2ddc97e7e928122 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Tue, 30 Jun 2020 01:43:52 +0500 Subject: [PATCH] Remove frontend from main cmd --- cmd/serve.go | 22 ++++++++-------------- readme.md | 4 ++++ ui/src/views/Start.vue | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/cmd/serve.go b/cmd/serve.go index 7eaa594a3a..99666d2e65 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -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 { @@ -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{ @@ -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: @@ -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 { diff --git a/readme.md b/readme.md index 5a0acc37e4..927c765077 100644 --- a/readme.md +++ b/readme.md @@ -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`. diff --git a/ui/src/views/Start.vue b/ui/src/views/Start.vue index 489736cd99..6387402cfe 100644 --- a/ui/src/views/Start.vue +++ b/ui/src/views/Start.vue @@ -21,7 +21,7 @@
User interface
The front-end of your app. A Vue application is running on port 8080 - Loading... + To start the app, run: cd frontend && npm run dev