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

Commit

Permalink
v0.16.4 (#1955)
Browse files Browse the repository at this point in the history
* merge changes from buffalo-cli into main repo

* cache deps before building and copying source (#1884)

cache deps before building and copying source so that we don't need to re-download as much
and so that source changes don't invalidate our downloaded layer

* Generator resource action test breaks with unused imports fixes #1893 (#1894)

* Generator resource action test breaks with unused imports fixes #1893

* break packr cache

* fix broken test

* update deps (#1896)

* update deps

* update envy

* update meta

* switch to tags/v3 for consistency (#1901)

* update helpers/tags

* update validate

* try to fix mismatched imports (#1921)

* fixes more broken semantic import paths (#1925)

* adding a few packages to replace

* Replace Azure badge with Github actions badge (#1920)

Co-authored-by: Antonio Pagano <[email protected]>

* changing the packages to be replaced (#1928)

* changing the packages to be replaced

* adding back gobuffalo/uuid change

* Merging master (#1936)

* v0.16.1 (#1929)

* merge changes from buffalo-cli into main repo

* cache deps before building and copying source (#1884)

cache deps before building and copying source so that we don't need to re-download as much
and so that source changes don't invalidate our downloaded layer

* Generator resource action test breaks with unused imports fixes #1893 (#1894)

* Generator resource action test breaks with unused imports fixes #1893

* break packr cache

* fix broken test

* update deps (#1896)

* update deps

* update envy

* update meta

* switch to tags/v3 for consistency (#1901)

* update helpers/tags

* update validate

* try to fix mismatched imports (#1921)

* fixes more broken semantic import paths (#1925)

* adding a few packages to replace

* Replace Azure badge with Github actions badge (#1920)

Co-authored-by: Antonio Pagano <[email protected]>

* changing the packages to be replaced (#1928)

* changing the packages to be replaced

* adding back gobuffalo/uuid change

Co-authored-by: Mark Bates <[email protected]>
Co-authored-by: Dr Nic Williams <[email protected]>
Co-authored-by: HD Moore <[email protected]>
Co-authored-by: Stanislas Michalak <[email protected]>

* Add stack trace to ErrPanic event for easier debugging and monitoring (#1930)

Co-authored-by: Canh Nguyen <[email protected]>

* Modifies our docker file to pull buffalo binary from releases. (#1935)

* fixing docker image to use github binary

Co-authored-by: Mark Bates <[email protected]>
Co-authored-by: Dr Nic Williams <[email protected]>
Co-authored-by: HD Moore <[email protected]>
Co-authored-by: Stanislas Michalak <[email protected]>
Co-authored-by: xuancanh <[email protected]>
Co-authored-by: Canh Nguyen <[email protected]>

* Update js template to support font awesome (#1933)

* v0.16.1 (#1929)

* merge changes from buffalo-cli into main repo

* cache deps before building and copying source (#1884)

cache deps before building and copying source so that we don't need to re-download as much
and so that source changes don't invalidate our downloaded layer

* Generator resource action test breaks with unused imports fixes #1893 (#1894)

* Generator resource action test breaks with unused imports fixes #1893

* break packr cache

* fix broken test

* update deps (#1896)

* update deps

* update envy

* update meta

* switch to tags/v3 for consistency (#1901)

* update helpers/tags

* update validate

* try to fix mismatched imports (#1921)

* fixes more broken semantic import paths (#1925)

* adding a few packages to replace

* Replace Azure badge with Github actions badge (#1920)

Co-authored-by: Antonio Pagano <[email protected]>

* changing the packages to be replaced (#1928)

* changing the packages to be replaced

* adding back gobuffalo/uuid change

Co-authored-by: Mark Bates <[email protected]>
Co-authored-by: Dr Nic Williams <[email protected]>
Co-authored-by: HD Moore <[email protected]>
Co-authored-by: Stanislas Michalak <[email protected]>

* Add stack trace to ErrPanic event for easier debugging and monitoring (#1930)

Co-authored-by: Canh Nguyen <[email protected]>

* Update js template to support font awesome

The latest version of font-awesome requires the js file to also be present for a glyph to work.  To see this work, add this code to any page template:

```html
<h3>
<a href=#" target="_blank"><i class="fab fa-twitter-square share" aria-hidden="true"></i></a>
</h3>
```

Without this JS file, the glyph will not render.

Co-authored-by: Antonio Pagano <[email protected]>
Co-authored-by: Mark Bates <[email protected]>
Co-authored-by: Dr Nic Williams <[email protected]>
Co-authored-by: HD Moore <[email protected]>
Co-authored-by: Stanislas Michalak <[email protected]>
Co-authored-by: xuancanh <[email protected]>
Co-authored-by: Canh Nguyen <[email protected]>

* Fixes generated package.json and resources generator (#1944)

* v0.16.1 (#1929)

* merge changes from buffalo-cli into main repo

* cache deps before building and copying source (#1884)

cache deps before building and copying source so that we don't need to re-download as much
and so that source changes don't invalidate our downloaded layer

* Generator resource action test breaks with unused imports fixes #1893 (#1894)

* Generator resource action test breaks with unused imports fixes #1893

* break packr cache

* fix broken test

* update deps (#1896)

* update deps

* update envy

* update meta

* switch to tags/v3 for consistency (#1901)

* update helpers/tags

* update validate

* try to fix mismatched imports (#1921)

* fixes more broken semantic import paths (#1925)

* adding a few packages to replace

* Replace Azure badge with Github actions badge (#1920)

Co-authored-by: Antonio Pagano <[email protected]>

* changing the packages to be replaced (#1928)

* changing the packages to be replaced

* adding back gobuffalo/uuid change

Co-authored-by: Mark Bates <[email protected]>
Co-authored-by: Dr Nic Williams <[email protected]>
Co-authored-by: HD Moore <[email protected]>
Co-authored-by: Stanislas Michalak <[email protected]>

* Add stack trace to ErrPanic event for easier debugging and monitoring (#1930)

Co-authored-by: Canh Nguyen <[email protected]>

* Modifies our docker file to pull buffalo binary from releases. (#1935)

* fixing docker image to use github binary

* Bump pop version (#1937)

* adding resource and new app generator fixes

* fixing buffalo generator to use v5 of pop

* updating popper and removing repeated version of webpack-manifest

* updating old tooling on the JS side

* updating webpack version

* updating node dependencies on fixture to remove github warnings

Co-authored-by: Mark Bates <[email protected]>
Co-authored-by: Dr Nic Williams <[email protected]>
Co-authored-by: HD Moore <[email protected]>
Co-authored-by: Stanislas Michalak <[email protected]>
Co-authored-by: xuancanh <[email protected]>
Co-authored-by: Canh Nguyen <[email protected]>

* updating dockerfile to use v0.16.3

* packing

* Adding new template for codeclimate code analysis (#1946)

* adding new template for codeclimate code analysis

* packing

* Updates our coke app package.json and Yarn (#1947)

* updating package.lock on the lock sample

* removing old pop plugin

* adding task to the fixers

* removing the fixer part

* Removes old buffalo-pop plugin (#1948)

* removes old buffalo-pop plugin

* naming change

* using filepath for auto render files (#1951)

* Bugfix c.Error http code (#1952)

* fixes error code not being logged

* adding tests for the status code when error handled fires

* Allows to set test timeout (#1953)

* allowing to pass timeout to the test command

* packing

* Fixes plush to use now plush/v4 (#1954)

* Adding packr files (#1956)

* Missing comments on the Plugins struct (#1958)

* Adding packr files

* adding a couple of comments missing

Co-authored-by: Mark Bates <[email protected]>
Co-authored-by: Dr Nic Williams <[email protected]>
Co-authored-by: HD Moore <[email protected]>
Co-authored-by: Stanislas Michalak <[email protected]>
Co-authored-by: xuancanh <[email protected]>
Co-authored-by: Canh Nguyen <[email protected]>
Co-authored-by: Cory LaNou <[email protected]>
  • Loading branch information
8 people authored Apr 13, 2020
1 parent c39246a commit 1bf4d58
Show file tree
Hide file tree
Showing 15 changed files with 645 additions and 598 deletions.
5 changes: 4 additions & 1 deletion buffalo/cmd/fix/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var replace = map[string]string{
"github.com/gobuffalo/suite": "github.com/gobuffalo/suite/v3",
"github.com/gobuffalo/buffalo-pop/": "github.com/gobuffalo/buffalo-pop/v2",
"github.com/gobuffalo/buffalo-pop/pop/popmw": "github.com/gobuffalo/buffalo-pop/v2/pop/popmw",
"github.com/gobuffalo/plush": "github.com/gobuffalo/plush/v4",
}

var ic = ImportConverter{
Expand Down Expand Up @@ -66,7 +67,9 @@ var checks = []Check{
DeprecrationsCheck,
fixDocker,
encodeApp,
Plugins,
Plugins{}.RemoveOld,
Plugins{}.CleanCache,
Plugins{}.Reinstall,
Plush,
}

Expand Down
42 changes: 40 additions & 2 deletions buffalo/cmd/fix/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,31 @@ import (
"context"
"fmt"
"os"
"path"
"strings"

cmdPlugins "github.com/gobuffalo/buffalo/buffalo/cmd/plugins"
"github.com/gobuffalo/buffalo/genny/plugins/install"
"github.com/gobuffalo/buffalo/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/buffalo/plugins"
"github.com/gobuffalo/buffalo/plugins/plugdeps"
"github.com/gobuffalo/genny/v2"
"github.com/gobuffalo/meta"
)

// Plugins will fix plugins between releases
func Plugins(r *Runner) error {
//Plugins fixes the plugin configuration of the project by
//manipulating the plugins .toml file.
type Plugins struct{}

//CleanCache cleans the plugins cache folder by removing it
func (pf Plugins) CleanCache(r *Runner) error {
fmt.Println("~~~ Cleaning plugins cache ~~~")
os.RemoveAll(plugins.CachePath)
return nil
}

//Reinstall installs latest versions of the plugins
func (pf Plugins) Reinstall(r *Runner) error {
plugs, err := plugdeps.List(r.App)
if err != nil && (errx.Unwrap(err) != plugdeps.ErrMissingConfig) {
return err
Expand All @@ -32,3 +45,28 @@ func Plugins(r *Runner) error {
fmt.Println("~~~ Reinstalling plugins ~~~")
return run.Run()
}

//RemoveOld removes old and deprecated plugins
func (pf Plugins) RemoveOld(r *Runner) error {
fmt.Println("~~~ Removing old plugins ~~~")

run := genny.WetRunner(context.Background())
app := meta.New(".")
plugs, err := plugdeps.List(app)
if err != nil && (errx.Unwrap(err) != plugdeps.ErrMissingConfig) {
return err
}

a := strings.TrimSpace("github.com/gobuffalo/buffalo-pop")
bin := path.Base(a)
plugs.Remove(plugdeps.Plugin{
Binary: bin,
GoGet: a,
})

fmt.Println("~~~ Removing github.com/gobuffalo/buffalo-pop plugin ~~~")

run.WithRun(cmdPlugins.NewEncodePluginsRunner(app, plugs))

return run.Run()
}
22 changes: 22 additions & 0 deletions buffalo/cmd/plugins/encode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package plugins

import (
"bytes"

"github.com/gobuffalo/buffalo/plugins/plugdeps"
"github.com/gobuffalo/genny/v2"
"github.com/gobuffalo/meta"
)

// NewEncodePluginsRunner will return a runner that will encode the plugins file
func NewEncodePluginsRunner(app meta.App, plugs *plugdeps.Plugins) func(r *genny.Runner) error {
return func(r *genny.Runner) error {
p := plugdeps.ConfigPath(app)
bb := &bytes.Buffer{}
if err := plugs.Encode(bb); err != nil {
return err
}

return r.File(genny.NewFile(p, bb))
}
}
14 changes: 1 addition & 13 deletions buffalo/cmd/plugins/remove.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package plugins

import (
"bytes"
"context"
"fmt"
"path"
Expand Down Expand Up @@ -46,18 +45,7 @@ var removeCmd = &cobra.Command{
})
}

run.WithRun(func(r *genny.Runner) error {
p := plugdeps.ConfigPath(app)
bb := &bytes.Buffer{}
if err := plugs.Encode(bb); err != nil {
return err
}
return r.File(genny.NewFile(p, bb))
})
if err != nil {
return err
}

run.WithRun(NewEncodePluginsRunner(app, plugs))
return run.Run()
},
}
Expand Down
45 changes: 28 additions & 17 deletions buffalo/cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,38 +101,43 @@ func findSchema() io.Reader {
func testRunner(args []string) error {
var mFlag bool
var query string
cargs := []string{}
pargs := []string{}

var larg string
for i, a := range args {
switch a {
case "-run", "-m", "-timeout":
query = args[i+1]

commandArgs := []string{}
packageArgs := []string{}

var lastArg string
for index, arg := range args {
switch arg {
case "-run", "-m":
query = args[index+1]
mFlag = true
case "-v":
cargs = append(cargs, "-v")
case "-v", "-timeout":
commandArgs = append(commandArgs, arg)
default:
if larg != "-run" && larg != "-m" && larg != "-timeout" {
pargs = append(pargs, a)
if lastArg == "-timeout" {
commandArgs = append(commandArgs, arg)
} else if lastArg != "-run" && lastArg != "-m" {
packageArgs = append(packageArgs, arg)
}
}
larg = a

lastArg = arg
}

cmd := newTestCmd(cargs)
cmd := newTestCmd(commandArgs)
if mFlag {
return mFlagRunner{
query: query,
args: cargs,
pargs: pargs,
args: commandArgs,
pargs: packageArgs,
}.Run()
}

pkgs, err := testPackages(pargs)
pkgs, err := testPackages(packageArgs)
if err != nil {
return err
}

cmd.Args = append(cmd.Args, pkgs...)
logrus.Info(strings.Join(cmd.Args, " "))
return cmd.Run()
Expand All @@ -153,12 +158,15 @@ func (m mFlagRunner) Run() error {
if err != nil {
return err
}

var errs bool
for _, p := range pkgs {
os.Chdir(pwd)

if p == app.PackagePkg {
continue
}

p = strings.TrimPrefix(p, app.PackagePkg+string(filepath.Separator))
os.Chdir(p)

Expand All @@ -168,7 +176,9 @@ func (m mFlagRunner) Run() error {
} else {
cmd.Args = append(cmd.Args, "-run", m.query)
}

logrus.Info(strings.Join(cmd.Args, " "))

if err := cmd.Run(); err != nil {
errs = true
}
Expand All @@ -193,6 +203,7 @@ func testPackages(givenArgs []string) ([]string, error) {
if len(givenArgs) > 0 {
return givenArgs, nil
}

args := []string{}
out, err := exec.Command(envy.Get("GO_BIN", "go"), "list", "./...").Output()
if err != nil {
Expand Down
13 changes: 9 additions & 4 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func defaultErrorHandler(status int, origErr error, c Context) error {
env := c.Value("env")
requestCT := defaults.String(httpx.ContentType(c.Request()), defaultErrorCT)

c.LogField("status", status)
c.Logger().Error(origErr)
c.Response().WriteHeader(status)

Expand All @@ -170,7 +171,9 @@ func defaultErrorHandler(status int, origErr error, c Context) error {
c.Response().Write(responseBody)
return nil
}

trace := origErr.Error()

switch strings.ToLower(requestCT) {
case "application/json", "text/json", "json":
c.Response().Header().Set("content-type", "application/json")
Expand All @@ -197,14 +200,13 @@ func defaultErrorHandler(status int, origErr error, c Context) error {
if err := c.Request().ParseForm(); err != nil {
trace = fmt.Sprintf("%s\n%s", err.Error(), trace)
}
routes := c.Value("routes")

routes := c.Value("routes")
cd := c.Data()
// if cd, ok := c.(*DefaultContext); ok {
// data := cd.Data()

delete(cd, "app")
delete(cd, "routes")
// }

data := map[string]interface{}{
"routes": routes,
"error": trace,
Expand All @@ -218,13 +220,16 @@ func defaultErrorHandler(status int, origErr error, c Context) error {
return fmt.Sprintf("%+v", v)
},
}

ctx := plush.NewContextWith(data)
t, err := plush.Render(devErrorTmpl, ctx)
if err != nil {
return err
}

res := c.Response()
_, err = res.Write([]byte(t))

return err
}
return nil
Expand Down
41 changes: 41 additions & 0 deletions errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,32 @@ package buffalo
import (
"fmt"
"net/http"
"os"
"testing"

"github.com/gobuffalo/httptest"
"github.com/gobuffalo/logger"
"github.com/sirupsen/logrus"

"github.com/stretchr/testify/require"
)

//testLoggerHook is useful to test whats being logged.
type testLoggerHook struct {
errors []*logrus.Entry
}

func (lh *testLoggerHook) Fire(entry *logrus.Entry) error {
lh.errors = append(lh.errors, entry)
return nil
}

func (lh *testLoggerHook) Levels() []logrus.Level {
return []logrus.Level{
logrus.ErrorLevel,
}
}

func Test_defaultErrorHandler_SetsContentType(t *testing.T) {
r := require.New(t)
app := New(Options{})
Expand All @@ -24,6 +43,28 @@ func Test_defaultErrorHandler_SetsContentType(t *testing.T) {
r.Equal("text/html; charset=utf-8", ct)
}

func Test_defaultErrorHandler_Logger(t *testing.T) {
r := require.New(t)
app := New(Options{})
app.GET("/", func(c Context) error {
return c.Error(http.StatusUnauthorized, fmt.Errorf("boom"))
})

testHook := &testLoggerHook{}
l := logrus.New()
l.SetOutput(os.Stdout)
l.AddHook(testHook)
log := logger.Logrus{
FieldLogger: l,
}
app.Logger = log

w := httptest.New(app)
res := w.HTML("/").Get()
r.Equal(http.StatusUnauthorized, res.Code)
r.Equal(http.StatusUnauthorized, testHook.errors[0].Data["status"])
}

func Test_defaultErrorHandler_JSON(t *testing.T) {
r := require.New(t)
app := New(Options{})
Expand Down
8 changes: 0 additions & 8 deletions genny/assets/webpack/webpack-packr.go

This file was deleted.

3 changes: 1 addition & 2 deletions genny/build/_fixtures/coke/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"jquery-ujs": "~1.2.2"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",

Expand All @@ -37,7 +36,7 @@
"copy-webpack-plugin": "~5.1.1",

"webpack": "~4.42.1",
"webpack-cli": "^3.3.10",
"webpack-cli": "^4.0.0-beta.8",
"webpack-livereload-plugin": "~2.3.0",
"webpack-manifest-plugin": "~2.2.0"
}
Expand Down
Loading

0 comments on commit 1bf4d58

Please sign in to comment.