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

Replace packr and packd in gobuffalo cli with embed.FS #48

Merged
merged 20 commits into from
Nov 20, 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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
bin/
dist/
*-packr.go
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ require (
github.com/gobuffalo/envy v1.10.1
github.com/gobuffalo/events v1.4.2
github.com/gobuffalo/flect v0.2.4
github.com/gobuffalo/genny/v2 v2.0.6
github.com/gobuffalo/genny/v2 v2.0.7
github.com/gobuffalo/logger v1.0.6
github.com/gobuffalo/meta v0.3.1
github.com/gobuffalo/packd v1.0.1
github.com/gobuffalo/packr/v2 v2.8.1
github.com/gobuffalo/plush/v4 v4.1.8
github.com/gobuffalo/pop/v5 v5.3.4
github.com/google/go-cmp v0.5.6
Expand Down
10 changes: 3 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ github.com/gobuffalo/genny v0.4.1/go.mod h1:dpded+KBgICFciAb+6R5Lo+1VxzofjqHgKqF
github.com/gobuffalo/genny v0.6.0 h1:d7c6d66ZrTHHty01hDX1/TcTWvAJQxRZl885KWX5kHY=
github.com/gobuffalo/genny v0.6.0/go.mod h1:Vigx9VDiNscYpa/LwrURqGXLSIbzTfapt9+K6gF1kTA=
github.com/gobuffalo/genny/v2 v2.0.5/go.mod h1:kRkJuAw9mdI37AiEYjV4Dl+TgkBDYf8HZVjLkqe5eBg=
github.com/gobuffalo/genny/v2 v2.0.6 h1:5M1Cl4pkS3mIl/X5s27nhq/o/2S8e5cPXmlcGwSDBI4=
github.com/gobuffalo/genny/v2 v2.0.6/go.mod h1:3tUHnhxSOSe1wmx669WaBtIA3OSvtVkwRTvJFsH+d9o=
github.com/gobuffalo/genny/v2 v2.0.7 h1:s9+3FaOGXGv/2Q6lVIOjrd8N+XXgSABDf7GDqxOrNDc=
github.com/gobuffalo/genny/v2 v2.0.7/go.mod h1:2sqy72YzmN2FtERGntPX3FnSFV7O9Zx/FfJmgmcYQfE=
github.com/gobuffalo/gitgen v0.0.0-20190219185555-91c2c5f0aad5/go.mod h1:ZzGIrxBvCJEluaU4i3CN0GFlu1Qmb3yK8ziV02evJ1E=
github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw=
github.com/gobuffalo/github_flavored_markdown v1.0.4/go.mod h1:uRowCdK+q8d/RF0Kt3/DSalaIXbb0De/dmTqMQdkQ4I=
Expand Down Expand Up @@ -569,9 +569,8 @@ github.com/gobuffalo/packr/v2 v2.5.2/go.mod h1:sgEE1xNZ6G0FNN5xn9pevVu4nywaxHvgu
github.com/gobuffalo/packr/v2 v2.5.3/go.mod h1:sgEE1xNZ6G0FNN5xn9pevVu4nywaxHvgup67xisti08=
github.com/gobuffalo/packr/v2 v2.6.0/go.mod h1:sgEE1xNZ6G0FNN5xn9pevVu4nywaxHvgup67xisti08=
github.com/gobuffalo/packr/v2 v2.7.1/go.mod h1:qYEvAazPaVxy7Y7KR0W8qYEE+RymX74kETFqjFoFlOc=
github.com/gobuffalo/packr/v2 v2.8.0 h1:IULGd15bQL59ijXLxEvA5wlMxsmx/ZkQv9T282zNVIY=
github.com/gobuffalo/packr/v2 v2.8.0/go.mod h1:PDk2k3vGevNE3SwVyVRgQCCXETC9SaONCNSXT1Q8M1g=
github.com/gobuffalo/packr/v2 v2.8.1 h1:tkQpju6i3EtMXJ9uoF5GT6kB+LMTimDWD8Xvbz6zDVA=
github.com/gobuffalo/packr/v2 v2.8.1/go.mod h1:c/PLlOuTU+p3SybaJATW3H6lX/iK7xEz5OeMf+NnJpg=
github.com/gobuffalo/plush v3.7.16+incompatible/go.mod h1:rQ4zdtUUyZNqULlc6bqd5scsPfLKfT0+TGMChgduDvI=
github.com/gobuffalo/plush v3.7.20+incompatible/go.mod h1:rQ4zdtUUyZNqULlc6bqd5scsPfLKfT0+TGMChgduDvI=
github.com/gobuffalo/plush v3.7.21+incompatible/go.mod h1:rQ4zdtUUyZNqULlc6bqd5scsPfLKfT0+TGMChgduDvI=
Expand Down Expand Up @@ -928,7 +927,6 @@ github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0L
github.com/karrick/godirwalk v1.12.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
github.com/karrick/godirwalk v1.15.2/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/karrick/godirwalk v1.15.3/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/karrick/godirwalk v1.15.8/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw=
github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
Expand Down Expand Up @@ -1207,7 +1205,6 @@ github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
Expand Down Expand Up @@ -1707,7 +1704,6 @@ golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapK
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/tools v0.0.0-20200323192200-8849913b6971/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var buildOptions = struct {
var xbuildCmd = &cobra.Command{
Use: "build",
Aliases: []string{"b", "bill", "install"},
Short: "Build the application binary, including bundling of assets (packr & webpack)",
Short: "Build the application binary, including bundling of webpack assets",
RunE: func(cmd *cobra.Command, args []string) error {
ctx, cancel := sigtx.WithCancel(context.Background(), os.Interrupt)
defer cancel()
Expand Down
8 changes: 3 additions & 5 deletions internal/cmd/destroy/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
//ActionCmd destroys passed action file
var ActionCmd = &cobra.Command{
Use: "action [name]",
//Example: "resource cars",
// Example: "resource cars",
Aliases: []string{"a"},
Short: "Destroy action files",
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -20,10 +20,8 @@ var ActionCmd = &cobra.Command{

name := args[0]

//Generated actions keep the same name (not plural).
// Generated actions keep the same name (not plural).
fileName := flect.Underscore(name)

removeActions(fileName)
return nil
return removeActions(fileName)
},
}
4 changes: 1 addition & 3 deletions internal/cmd/fix/deprecations.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ func DeprecrationsCheck(r *Runner) error {
if bytes.Contains(b, []byte("T.LanguageFinder=")) || bytes.Contains(b, []byte("T.LanguageFinder ")) {
r.Warnings = append(r.Warnings, fmt.Sprintf("i18n.Translator#LanguageFinder has been deprecated in v0.11.1, and has been removed in v0.12.0. Use i18n.Translator#LanguageExtractors instead. [%s]", path))
}
ioutil.WriteFile(path, b, 0664)

return nil
return ioutil.WriteFile(path, b, 0664)
})
}
5 changes: 3 additions & 2 deletions internal/cmd/fix/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ var mr = MiddlewareTransformer{
}

var checks = []Check{
PackrClean,
ic.Process,
mr.transformPackages,
WebpackCheck,
Expand All @@ -78,7 +77,9 @@ func encodeApp(r *Runner) error {
if _, err := os.Stat(p); err == nil {
return nil
}
os.MkdirAll(filepath.Dir(p), 0755)
if err := os.MkdirAll(filepath.Dir(p), 0755); err != nil {
return err
}
f, err := os.Create(p)
if err != nil {
return err
Expand Down
12 changes: 6 additions & 6 deletions internal/cmd/fix/npm.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ func AddPackageJSONScripts(r *Runner) error {
if needRewrite {
b, err = json.MarshalIndent(packageJSON, "", " ")
if err != nil {
return fmt.Errorf("could not rewrite package.json: %s", err.Error())
return fmt.Errorf("could not rewrite package.json: %w", err)
}

ioutil.WriteFile("package.json", b, 0644)
if err := ioutil.WriteFile("package.json", b, 0644); err != nil {
return fmt.Errorf("could not rewrite package.json: %w", err)
}
} else {
fmt.Println("~~~ package.json doesn't need to be patched, skipping. ~~~")
}
Expand All @@ -81,14 +83,12 @@ func PackageJSONCheck(r *Runner) error {
return nil
}

box := webpack.Templates

f, err := box.FindString("package.json.tmpl")
templates, err := webpack.Templates()
if err != nil {
return err
}

tmpl, err := template.New("package.json").Parse(f)
tmpl, err := template.New("package.json").ParseFS(templates, "package.json.tmpl")
if err != nil {
return err
}
Expand Down
9 changes: 0 additions & 9 deletions internal/cmd/fix/packr.go

This file was deleted.

6 changes: 3 additions & 3 deletions internal/cmd/fix/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fix

import (
"context"
"errors"
"fmt"
"os"
"path"
Expand All @@ -12,7 +13,6 @@ import (
cmdPlugins "github.com/gobuffalo/cli/internal/cmd/plugins"
"github.com/gobuffalo/cli/internal/plugins"
"github.com/gobuffalo/cli/internal/plugins/plugdeps"
"github.com/gobuffalo/cli/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/genny/v2"
"github.com/gobuffalo/meta"
)
Expand All @@ -31,7 +31,7 @@ func (pf Plugins) CleanCache(r *Runner) error {
//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) {
if err != nil && !errors.Is(err, plugdeps.ErrMissingConfig) {
return err
}

Expand All @@ -57,7 +57,7 @@ func (pf Plugins) RemoveOld(r *Runner) error {
run := genny.WetRunner(context.Background())
app := meta.New(".")
plugs, err := plugdeps.List(app)
if err != nil && (errx.Unwrap(err) != plugdeps.ErrMissingConfig) {
if err != nil && !errors.Is(err, plugdeps.ErrMissingConfig) {
return err
}

Expand Down
4 changes: 3 additions & 1 deletion internal/cmd/fix/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func installTools(r *Runner) error {
for _, t := range rTools {
g.Command(exec.Command("go", "get", t))
}
run.With(g)
if err := run.With(g); err != nil {
return err
}
return run.Run()
}
6 changes: 2 additions & 4 deletions internal/cmd/fix/webpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ func WebpackCheck(r *Runner) error {
return nil
}

box := webpack.Templates

f, err := box.FindString("webpack.config.js.tmpl")
templates, err := webpack.Templates()
if err != nil {
return err
}

tmpl, err := template.New("webpack").Parse(f)
tmpl, err := template.New("webpack").ParseFS(templates, "webpack.config.js.tmpl")
if err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion internal/cmd/generate/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ var ActionCmd = &cobra.Command{
}

opts := actionOptions.Options
run.WithNew(actions.New(opts))
if err := run.WithNew(actions.New(opts)); err != nil {
return err
}
return run.Run()
},
}
Expand Down
4 changes: 3 additions & 1 deletion internal/cmd/generate/mailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ var MailCmd = &cobra.Command{
if err != nil {
return err
}
run.With(g)
if err := run.With(g); err != nil {
return err
}

gg.With(run)
return run.Run()
Expand Down
67 changes: 0 additions & 67 deletions internal/cmd/internal/integration/integration_test.go

This file was deleted.

8 changes: 2 additions & 6 deletions internal/cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"context"
"errors"
"fmt"
"os"
"os/exec"
Expand All @@ -22,14 +23,12 @@ import (
"github.com/gobuffalo/cli/internal/genny/vcs"

pop "github.com/gobuffalo/buffalo-pop/v2/genny/newapp"
"github.com/gobuffalo/cli/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/envy"
fname "github.com/gobuffalo/flect/name"
"github.com/gobuffalo/genny/v2"
"github.com/gobuffalo/genny/v2/gogen"
"github.com/gobuffalo/logger"
"github.com/gobuffalo/meta"
"github.com/gobuffalo/packr/v2/plog"
"github.com/gobuffalo/plush/v4"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -167,9 +166,6 @@ var newCmd = &cobra.Command{
run := genny.WetRunner(ctx)
lg := logger.New(logger.DebugLevel)
run.Logger = lg
if nopts.Verbose {
plog.Logger = lg
}

if nopts.DryRun {
run = genny.DryRunner(ctx)
Expand Down Expand Up @@ -197,7 +193,7 @@ var newCmd = &cobra.Command{
gg, err = web.New(wo)
}
if err != nil {
if errx.Unwrap(err) == core.ErrNotInGoPath {
if errors.Is(err, core.ErrNotInGoPath) {
return notInGoPath(app)
}
return err
Expand Down
8 changes: 5 additions & 3 deletions internal/cmd/plugins/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package plugins

import (
"context"
"errors"
"os"
"path"
"strings"

"github.com/gobuffalo/cli/internal/genny/add"

"github.com/gobuffalo/cli/internal/plugins/plugdeps"
"github.com/gobuffalo/cli/internal/takeon/github.com/markbates/errx"
"github.com/gobuffalo/genny/v2"
"github.com/gobuffalo/meta"
"github.com/spf13/cobra"
Expand All @@ -31,7 +31,7 @@ var addCmd = &cobra.Command{

app := meta.New(".")
plugs, err := plugdeps.List(app)
if err != nil && (errx.Unwrap(err) != plugdeps.ErrMissingConfig) {
if err != nil && !errors.Is(err, plugdeps.ErrMissingConfig) {
return err
}

Expand All @@ -57,7 +57,9 @@ var addCmd = &cobra.Command{
if err != nil {
return err
}
run.With(g)
if err := run.With(g); err != nil {
return err
}

return run.Run()
},
Expand Down
Loading