Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Make GoGet and GoInstall useable from generators #74

Merged
merged 1 commit into from
Dec 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions buffalo/cmd/app_generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ func newAppGenerator(data gentronics.Data) *gentronics.Generator {
RemotePath: "https://raw.githubusercontent.com/gobuffalo/buffalo/master/logo.svg",
})
g.Add(gentronics.NewFile(".gitignore", nGitignore))
g.Add(gentronics.NewCommand(goGet("github.com/markbates/refresh/...")))
g.Add(gentronics.NewCommand(goInstall("github.com/markbates/refresh")))
g.Add(gentronics.NewCommand(goGet("github.com/markbates/grift/...")))
g.Add(gentronics.NewCommand(goInstall("github.com/markbates/grift")))
g.Add(gentronics.NewCommand(goGet("github.com/motemen/gore")))
g.Add(gentronics.NewCommand(goInstall("github.com/motemen/gore")))
g.Add(gentronics.NewCommand(generate.GoGet("github.com/markbates/refresh/...")))
g.Add(gentronics.NewCommand(generate.GoInstall("github.com/markbates/refresh")))
g.Add(gentronics.NewCommand(generate.GoGet("github.com/markbates/grift/...")))
g.Add(gentronics.NewCommand(generate.GoInstall("github.com/markbates/grift")))
g.Add(gentronics.NewCommand(generate.GoGet("github.com/motemen/gore")))
g.Add(gentronics.NewCommand(generate.GoInstall("github.com/motemen/gore")))
g.Add(generate.NewWebpackGenerator(data))
g.Add(newSodaGenerator())
g.Add(gentronics.NewCommand(appGoGet()))
Expand Down
1 change: 1 addition & 0 deletions buffalo/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ func init() {
generateCmd.AddCommand(generate.WebpackCmd)
RootCmd.AddCommand(generateCmd)
}

17 changes: 17 additions & 0 deletions buffalo/cmd/generate/gocmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package generate

import "os/exec"

// GoInstall compiles and installs packages and dependencies
func GoInstall(pkg string) *exec.Cmd {
args := []string{"install"}
args = append(args, pkg)
return exec.Command("go", args...)
}

// GoGet downloads and installs packages and dependencies
func GoGet(pkg string) *exec.Cmd {
args := []string{"get"}
args = append(args, pkg)
return exec.Command("go", args...)
}
19 changes: 0 additions & 19 deletions buffalo/cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"

Expand Down Expand Up @@ -77,24 +76,6 @@ func packagePath(rootPath string) string {
return strings.Replace(rootPath, filepath.Join(os.Getenv("GOPATH"), "src")+"/", "", 1)
}

func goInstall(pkg string) *exec.Cmd {
args := []string{"install"}
if verbose {
args = append(args, "-v")
}
args = append(args, pkg)
return exec.Command("go", args...)
}

func goGet(pkg string) *exec.Cmd {
args := []string{"get"}
if verbose {
args = append(args, "-v")
}
args = append(args, pkg)
return exec.Command("go", args...)
}

func genNewFiles(name, rootPath string) error {
packagePath := packagePath(rootPath)

Expand Down
10 changes: 10 additions & 0 deletions buffalo/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ package cmd
import (
"fmt"
"os"
"os/exec"

"github.com/gobuffalo/buffalo/buffalo/cmd/generate"
"github.com/spf13/cobra"
)

Expand All @@ -47,6 +49,14 @@ func Execute() {
}
}

func goInstall(pkg string) *exec.Cmd {
return generate.GoInstall(pkg)
}

func goGet(pkg string) *exec.Cmd {
return generate.GoGet(pkg)
}

// func init() {
// cobra.OnInitialize(initConfig)
// RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.buffalo.yaml)")
Expand Down