Skip to content

Commit

Permalink
Merge pull request #18 from gobuffalo/task/moving-to-genny
Browse files Browse the repository at this point in the history
Moving it to use genny
  • Loading branch information
paganotoni authored Oct 2, 2018
2 parents 0722a64 + 3a41332 commit 778caa6
Show file tree
Hide file tree
Showing 480 changed files with 76,404 additions and 2,492 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gobuffalo/buffalo:v0.12.0
FROM gobuffalo/buffalo:latest

RUN rm -rf $GOPATH/src/github.com/gobuffalo/buffalo-auth
ADD . $GOPATH/src/github.com/gobuffalo/buffalo-auth
Expand Down
19 changes: 0 additions & 19 deletions auth/auth-packr.go

This file was deleted.

149 changes: 0 additions & 149 deletions auth/auth.go

This file was deleted.

48 changes: 15 additions & 33 deletions cmd/auth.go
Original file line number Diff line number Diff line change
@@ -1,57 +1,39 @@
package cmd

import (
"os"
"path/filepath"
"strings"
"context"

"github.com/pkg/errors"

"github.com/gobuffalo/buffalo-auth/auth"
"github.com/gobuffalo/envy"
"github.com/gobuffalo/makr"
"github.com/gobuffalo/buffalo-auth/genny/auth"
"github.com/gobuffalo/genny"
"github.com/gobuffalo/genny/movinglater/gotools"
"github.com/spf13/cobra"
)

var dryRun bool

// authCmd generates a actions/auth.go file configured to the specified providers.
var authCmd = &cobra.Command{
Use: "auth",
Short: "Generates a full auth implementation",
RunE: func(cmd *cobra.Command, args []string) error {
pwd, err := os.Getwd()
if err != nil {
return errors.WithStack(err)
r := genny.WetRunner(context.Background())
if dryRun {
r = genny.DryRunner(context.Background())
}

g, err := auth.New(args)
if err != nil {
if err := r.WithNew(auth.New(args)); err != nil {
return err
}
return g.Run(".", makr.Data{
"packagePath": packagePath(pwd),
})
},
}

func goPath(root string) string {
gpMultiple := envy.GoPaths()
path := ""

for i := 0; i < len(gpMultiple); i++ {
if strings.HasPrefix(root, filepath.Join(gpMultiple[i], "src")) {
path = gpMultiple[i]
break
if err := r.WithNew(gotools.GoFmt(r.Root)); err != nil {
return err
}
}
return path
}

func packagePath(rootPath string) string {
gosrcpath := strings.Replace(filepath.Join(goPath(rootPath), "src"), "\\", "/", -1)
rootPath = strings.Replace(rootPath, "\\", "/", -1)
return strings.Replace(rootPath, gosrcpath+"/", "", 2)
return r.Run()
},
}

func init() {
authCmd.Flags().BoolVarP(&dryRun, "dry-run", "d", false, "run the generator without creating files or running commands")
RootCmd.AddCommand(authCmd)
}
Loading

0 comments on commit 778caa6

Please sign in to comment.