Skip to content

Commit

Permalink
(v0.15.0) Drop dep support fixes gobuffalo#1545 (gobuffalo#1759)
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates authored Aug 16, 2019
1 parent a06562a commit 86b3700
Show file tree
Hide file tree
Showing 26 changed files with 8 additions and 316 deletions.
3 changes: 1 addition & 2 deletions Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ RUN npm -v
RUN service postgresql start && \
su -c "psql -c \"ALTER USER postgres WITH PASSWORD 'postgres';\"" - postgres

RUN go get -u github.com/golang/dep/cmd/dep \
&& go get -tags sqlite -v -u github.com/gobuffalo/pop \
RUN go get -tags sqlite -v -u github.com/gobuffalo/pop \
&& go get -tags sqlite -v -u github.com/gobuffalo/packr/v2/packr2 \
&& go get -tags sqlite -v -u github.com/gobuffalo/buffalo-pop \
&& rm -rf $GOPATH/src && mkdir -p $BP
Expand Down
97 changes: 0 additions & 97 deletions buffalo/cmd/fix/dep.go

This file was deleted.

1 change: 0 additions & 1 deletion buffalo/cmd/fix/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ var checks = []Check{
WebpackCheck,
PackageJSONCheck,
AddPackageJSONScripts,
DepEnsure,
installTools,
DeprecrationsCheck,
fixDocker,
Expand Down
23 changes: 1 addition & 22 deletions buffalo/cmd/fix/imports.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package fix

import (
"bytes"
"fmt"
"go/ast"
"go/parser"
"go/token"
"io/ioutil"
"os"
"path/filepath"
"strconv"
Expand All @@ -26,27 +24,8 @@ type ImportConverter struct {
func (c ImportConverter) Process(r *Runner) error {
fmt.Println("~~~ Rewriting Imports ~~~")

err := filepath.Walk(".", c.processFile)
if err != nil {
return err
}

if !r.App.WithDep {
return nil
}

b, err := ioutil.ReadFile("Gopkg.toml")
if err != nil {
return err
}

for k := range c.Data {
if bytes.Contains(b, []byte(k)) {
r.Warnings = append(r.Warnings, fmt.Sprintf("Your Gopkg.toml contains the following import that need to be changed MANUALLY: %s", k))
}
}
return filepath.Walk(".", c.processFile)

return nil
}

func (c ImportConverter) processFile(p string, info os.FileInfo, err error) error {
Expand Down
6 changes: 0 additions & 6 deletions buffalo/cmd/fix/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package fix
import (
"context"
"fmt"
"os/exec"

"github.com/gobuffalo/genny"
"github.com/gobuffalo/genny/gogen"
Expand All @@ -16,11 +15,6 @@ func installTools(r *Runner) error {
run := genny.WetRunner(context.Background())
g := genny.New()
app := r.App
if app.WithDep {
if _, err := exec.LookPath("dep"); err != nil {
g.RunFn(gogen.Install("github.com/golang/dep/cmd/dep"))
}
}
if app.WithPop {
rTools = append(rTools, "github.com/gobuffalo/buffalo-pop")
}
Expand Down
2 changes: 0 additions & 2 deletions buffalo/cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func parseNewOptions(args []string) (newAppOptions, error) {

app.AsAPI = viper.GetBool("api")
app.VCS = viper.GetString("vcs")
app.WithDep = viper.GetBool("with-dep")
if app.WithDep {
app.WithModules = false
envy.MustSet("GO111MODULE", "off")
Expand Down Expand Up @@ -273,7 +272,6 @@ func init() {
newCmd.Flags().BoolP("dry-run", "d", false, "dry run")
newCmd.Flags().BoolP("verbose", "v", false, "verbosely print out the go get commands")
newCmd.Flags().Bool("skip-pop", false, "skips adding pop/soda to your app")
newCmd.Flags().Bool("with-dep", false, "adds github.com/golang/dep to your app")
newCmd.Flags().Bool("skip-webpack", false, "skips adding Webpack to your app")
newCmd.Flags().Bool("skip-yarn", false, "use npm instead of yarn for frontend dependencies management")
newCmd.Flags().String("db-type", "postgres", fmt.Sprintf("specify the type of database you want to use [%s]", strings.Join(pop.AvailableDialects, ", ")))
Expand Down
70 changes: 1 addition & 69 deletions buffalo/cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@ package cmd

import (
"bytes"
"context"
"fmt"
"os"
"os/exec"
"strings"

"golang.org/x/sync/errgroup"

"github.com/gobuffalo/envy"
"github.com/gobuffalo/events"
"github.com/gobuffalo/meta"
"github.com/markbates/deplist"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

var setupOptions = struct {
verbose bool
updateGoDeps bool
dropDatabases bool
}{}

Expand All @@ -31,9 +25,6 @@ var setupCmd = &cobra.Command{
Short: "Setup a newly created, or recently checked out application.",
Long: `Setup runs through checklist to make sure dependencies are setup correctly.
Dependencies (if used):
* Runs "dep ensure" to install required Go dependencies.
Asset Pipeline (if used):
* Runs "npm install" or "yarn install" to install asset dependencies.
Expand All @@ -51,7 +42,7 @@ Tests:
"app": app,
}
events.EmitPayload(EvtSetupStarted, payload)
for _, check := range []setupCheck{assetCheck, updateGoDepsCheck, databaseCheck, testCheck} {
for _, check := range []setupCheck{assetCheck, databaseCheck, testCheck} {
err := check(app)
if err != nil {
events.EmitError(EvtSetupErr, err, payload)
Expand All @@ -63,64 +54,6 @@ Tests:
},
}

func updateGoDepsCheck(app meta.App) error {
if app.WithModules {
c := exec.Command(envy.Get("GO_BIN", "go"), "get")
return run(c)
}
if app.WithDep {
if _, err := exec.LookPath("dep"); err != nil {
if err := run(exec.Command(envy.Get("GO_BIN", "go"), "get", "github.com/golang/dep/cmd/dep")); err != nil {
return err
}
}
args := []string{"ensure"}
if setupOptions.verbose {
args = append(args, "-v")
}
if setupOptions.updateGoDeps {
args = append(args, "--update")
}
err := run(exec.Command("dep", args...))
if err != nil {
return err
}
return nil
}

// go old school with the installation
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
wg, _ := errgroup.WithContext(ctx)
deps, err := deplist.List()
if err != nil {
return err
}

deps["github.com/gobuffalo/suite"] = "github.com/gobuffalo/suite"

for dep := range deps {
args := []string{"get"}
if setupOptions.verbose {
args = append(args, "-v")
}
if setupOptions.updateGoDeps {
args = append(args, "-u")
}
args = append(args, dep)
c := exec.Command(envy.Get("GO_BIN", "go"), args...)
f := func() error {
return run(c)
}
wg.Go(f)
}
err = wg.Wait()
if err != nil {
return fmt.Errorf("We encountered the following error trying to install and update the dependencies for this application:\n%s", err)
}
return nil
}

func testCheck(meta.App) error {
err := run(exec.Command("buffalo", "test"))
if err != nil {
Expand Down Expand Up @@ -238,7 +171,6 @@ func run(cmd *exec.Cmd) error {

func init() {
setupCmd.Flags().BoolVarP(&setupOptions.verbose, "verbose", "v", false, "run with verbose output")
setupCmd.Flags().BoolVarP(&setupOptions.updateGoDeps, "update", "u", false, "run go get -u against the application's Go dependencies")
setupCmd.Flags().BoolVarP(&setupOptions.dropDatabases, "drop", "d", false, "drop existing databases")

decorate("setup", setupCmd)
Expand Down
7 changes: 0 additions & 7 deletions buffalo/cmd/updater/dep.go

This file was deleted.

6 changes: 0 additions & 6 deletions buffalo/cmd/updater/deprecations.go

This file was deleted.

6 changes: 0 additions & 6 deletions buffalo/cmd/updater/imports.go

This file was deleted.

9 changes: 0 additions & 9 deletions buffalo/cmd/updater/npm.go

This file was deleted.

12 changes: 0 additions & 12 deletions buffalo/cmd/updater/runner.go

This file was deleted.

7 changes: 0 additions & 7 deletions buffalo/cmd/updater/updater.go

This file was deleted.

9 changes: 0 additions & 9 deletions buffalo/cmd/updater/webpack.go

This file was deleted.

6 changes: 0 additions & 6 deletions genny/build/build_deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package build
import (
"github.com/gobuffalo/envy"
"github.com/gobuffalo/genny"
"github.com/gobuffalo/genny/depgen"
"github.com/gobuffalo/genny/gogen"
)

Expand All @@ -18,11 +17,6 @@ func buildDeps(opts *Options) (*genny.Generator, error) {
return g, nil
}

if opts.App.WithDep {
// mount the dep generator
return depgen.Ensure(false)
}

// mount the go get runner
tf := opts.App.BuildTags(opts.Environment, opts.Tags...)
if len(tf) > 0 {
Expand Down
Loading

0 comments on commit 86b3700

Please sign in to comment.