Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecating packr #43

Merged
merged 4 commits into from
Dec 17, 2021
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
14 changes: 5 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@ on:
release:
types:
- published

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
-
name: Set up Go 1.13
uses: actions/setup-go@v1
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.13
go-version: 1.16
id: go
-
name: Checkout Code
- name: Checkout Code
uses: actions/checkout@master
-
name: Run GoReleaser
- name: Run GoReleaser
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
uses: goreleaser/goreleaser-action@v1
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
name: Tests
on: [push]
on: [push, pull_request]
jobs:

tests-on:
name: ${{matrix.go-version}} ${{matrix.os}}
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.12.x, 1.13.x]
go-version: [1.16.x, 1.17.x]
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout Code
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Test
run: |
go mod tidy -v
go test -race ./...
go test -race -cover -v ./...


2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ builds:
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X "github.com/gobuffalo/buffalo-goth/main.Version={{.Tag}}"
- -s -w -X "github.com/gobuffalo/buffalo-goth/goth.Version={{.Tag}}"
goos:
- darwin
- linux
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ TAGS ?= "sqlite"
GO_BIN ?= go

install:
packr2
$(GO_BIN) install -tags ${TAGS} -v ./.
make tidy

tidy:
$(GO_BIN) mod tidy

build:
packr2
$(GO_BIN) build -v .
make tidy

test:
packr2 clean
$(GO_BIN) test -tags ${TAGS} ./...
make tidy
packr2
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
<p align="center"><img src="https://github.com/gobuffalo/buffalo/blob/master/logo.svg" width="360"></p>

<p align="center">
<a href="https://godoc.org/github.com/gobuffalo/buffalo-goth"><img src="https://godoc.org/github.com/gobuffalo/buffalo-goth?status.svg" alt="GoDoc" /></a>
<a href="https://travis-ci.org/gobuffalo/buffalo-goth"><img src="https://travis-ci.org/gobuffalo/buffalo-goth.svg?branch=master" alt="Build Status" /></a>
<a href="https://goreportcard.com/report/github.com/gobuffalo/buffalo-goth"><img src="https://goreportcard.com/badge/github.com/gobuffalo/buffalo-goth" alt="Go Report Card" /></a>
</p>

# Goth Generator for Buffalo

[![Tests](https://github.com/gobuffalo/buffalo-goth/actions/workflows/tests.yml/badge.svg)](https://github.com/gobuffalo/buffalo-goth/actions/workflows/tests.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/gobuffalo/buffalo-goth.svg)](https://pkg.go.dev/github.com/gobuffalo/buffalo-goth)
[![Go Report Card](https://goreportcard.com/badge/github.com/gobuffalo/buffalo-goth)](https://goreportcard.com/report/github.com/gobuffalo/buffalo-goth)

Buffalo-goth is a plugin for [buffalo cli](https://github.com/gobuffalo/cli)
that makes it easy to integrate [goth](https://github.com/markbates/goth)
into your Buffalo application.

In Buffalo `v0.9.4` the built in generator for [github.com/markbates/goth](https://github.com/markbates/goth) was removed in favor of this plugin.

## Installation

```bash
```console
$ buffalo plugins install github.com/gobuffalo/buffalo-goth
```

## Usage

Generate Users, Routes

```bash
```console
$ buffalo generate goth-auth facebook twitter linkedin etc...
```

Generate Routes only

```bash
```console
$ buffalo generate goth facebook twitter linkedin etc...
```

Expand Down
7 changes: 6 additions & 1 deletion cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"context"
"os/exec"

"github.com/gobuffalo/buffalo-goth/genny/auth"
"github.com/gobuffalo/genny/v2"
Expand Down Expand Up @@ -42,12 +43,16 @@ var authCmd = &cobra.Command{
}
r.With(g)

g = genny.New()
gomodtidy := exec.Command("go", "mod", "tidy")
g.Command(gomodtidy)
r.With(g)

return r.Run()
},
}

func init() {
authCmd.Flags().BoolVarP(&authOptions.dryRun, "dry-run", "d", false, "run the generator without creating files or running commands")
gothCmd.AddCommand(authCmd)
rootCmd.AddCommand(authCmd)
}
10 changes: 8 additions & 2 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"context"
"os/exec"

"github.com/gobuffalo/buffalo-goth/genny/goth"
"github.com/gobuffalo/genny/v2"
Expand All @@ -17,7 +18,8 @@ var generateOptions = struct {
Options: &goth.Options{},
}

// generateCmd represents the generate command
// generateCmd represents the goth command
// TODO: rename it, rename the file
var generateCmd = &cobra.Command{
Use: "goth",
Short: "generates a actions/auth.go file configured to the specified providers.",
Expand All @@ -42,12 +44,16 @@ var generateCmd = &cobra.Command{
}
r.With(g)

g = genny.New()
gomodtidy := exec.Command("go", "mod", "tidy")
g.Command(gomodtidy)
r.With(g)

return r.Run()
},
}

func init() {
generateCmd.Flags().BoolVarP(&generateOptions.dryRun, "dry-run", "d", false, "run the generator without creating files or running commands")
gothCmd.AddCommand(generateCmd)
rootCmd.AddCommand(generateCmd)
}
18 changes: 0 additions & 18 deletions cmd/goth.go

This file was deleted.

5 changes: 3 additions & 2 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package cmd
import (
"fmt"

"github.com/gobuffalo/buffalo-goth/goth"
"github.com/spf13/cobra"

"github.com/gobuffalo/buffalo-goth/goth"
)

// versionCmd represents the version command
Expand All @@ -18,5 +19,5 @@ var versionCmd = &cobra.Command{
}

func init() {
gothCmd.AddCommand(versionCmd)
rootCmd.AddCommand(versionCmd)
}
8 changes: 0 additions & 8 deletions genny/auth/auth-packr.go

This file was deleted.

16 changes: 13 additions & 3 deletions genny/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ package auth

import (
"bytes"
"embed"
"io/fs"
"os/exec"
"strings"
"text/template"

"github.com/gobuffalo/buffalo-goth/genny/goth"
"github.com/gobuffalo/genny/v2"
"github.com/gobuffalo/genny/v2/gogen"
"github.com/gobuffalo/meta"
"github.com/gobuffalo/packr/v2"
"github.com/pkg/errors"

"github.com/gobuffalo/buffalo-goth/genny/goth"
)

//go:embed templates
var templates embed.FS

func New(opts *Options) (*genny.Group, error) {
gg := &genny.Group{}
g, err := goth.New(&goth.Options{
Expand All @@ -24,9 +29,14 @@ func New(opts *Options) (*genny.Group, error) {
}
gg.Add(g)

sub, err := fs.Sub(templates, "templates")
if err != nil {
return gg, errors.WithStack(err)
}

g = genny.New()

if err := g.Box(packr.New("", "../auth/templates")); err != nil {
if err := g.FS(sub); err != nil {
return gg, errors.WithStack(err)
}

Expand Down
4 changes: 2 additions & 2 deletions genny/auth/templates/actions/auth.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
{{range .providers -}}
"github.com/markbates/goth/providers/{{ downcase . }}"
{{end -}}
"github.com/gobuffalo/pop"
"github.com/gobuffalo/pop/nulls"
"github.com/gobuffalo/pop/v6"
"github.com/gobuffalo/nulls"
"github.com/pkg/errors"
)

Expand Down
8 changes: 0 additions & 8 deletions genny/goth/goth-packr.go

This file was deleted.

12 changes: 10 additions & 2 deletions genny/goth/goth.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
package goth

import (
"embed"
"io/fs"
"strings"
"text/template"

"github.com/gobuffalo/genny/v2"
"github.com/gobuffalo/genny/v2/gogen"
"github.com/gobuffalo/packr/v2"
"github.com/pkg/errors"
)

//go:embed templates
var templates embed.FS

func New(opts *Options) (*genny.Generator, error) {
g := genny.New()

if len(opts.Providers) == 0 {
return g, errors.New("you must specify at least one provider")
}

if err := g.Box(packr.New("", "../goth/templates")); err != nil {
sub, err := fs.Sub(templates, "templates")
if err != nil {
return g, errors.WithStack(err)
}
if err := g.FS(sub); err != nil {
return g, errors.WithStack(err)
}

Expand Down
17 changes: 5 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
module github.com/gobuffalo/buffalo-goth

go 1.13
go 1.16

require (
github.com/gobuffalo/envy v1.8.1 // indirect
github.com/gobuffalo/genny/v2 v2.0.5
github.com/gobuffalo/meta v0.2.1
github.com/gobuffalo/packr/v2 v2.7.1
github.com/gobuffalo/genny/v2 v2.0.8
github.com/gobuffalo/meta v0.3.1
github.com/pkg/errors v0.9.1
github.com/rogpeppe/go-internal v1.5.2 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.4.0
golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d // indirect
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 // indirect
golang.org/x/tools v0.0.0-20200131161117-97da75b46c2a // indirect
github.com/spf13/cobra v1.2.1
github.com/stretchr/testify v1.7.0
)
Loading