Skip to content

Commit

Permalink
fix packr2 (ignite#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgooz authored Sep 29, 2020
1 parent deb6060 commit 9852765
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 16 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ require (
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/sys v0.0.0-20200929083018-4d22bbb62b3c // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/tools v0.0.0-20200928201943-a0ef9b62deab // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ github.com/gobuffalo/logger v1.0.3/go.mod h1:SoeejUwldiS7ZsyCBphOGURmWdwUFXs0J7T
github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q=
github.com/gobuffalo/packd v1.0.0 h1:6ERZvJHfe24rfFmA9OaoKBdC7+c9sydrytMg8SdFGBM=
github.com/gobuffalo/packd v1.0.0/go.mod h1:6VTc4htmJRFB7u1m/4LeMTWjFoYrUiBkU9Fdec9hrhI=
github.com/gobuffalo/packr v1.30.1 h1:hu1fuVR3fXEZR7rXNW3h8rqSML8EVAf6KNm0NKO/wKg=
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=
Expand Down Expand Up @@ -299,7 +298,6 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c h1:3lbZUMbMiGUW/LMkfsEABsc5zNT9+b1CvsJx47JzJ8g=
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c/go.mod h1:UrdRz5enIKZ63MEE3IF9l2/ebyx59GyGgPi+tICQdmM=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
Expand Down Expand Up @@ -365,10 +363,6 @@ golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200926100807-9d91bd62050c h1:38q6VNPWR010vN82/SB121GujZNIfAUb4YttE2rhGuc=
golang.org/x/sys v0.0.0-20200926100807-9d91bd62050c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200928205150-006507a75852 h1:sXxgOAXy8JwHhZnPuItAlUtwIlxrlEqi28mKhUR+zZY=
golang.org/x/sys v0.0.0-20200928205150-006507a75852/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200929083018-4d22bbb62b3c h1:/h0vtH0PyU0xAoZJVcRw1k0Ng+U0JAy3QDiFmppIlIE=
golang.org/x/sys v0.0.0-20200929083018-4d22bbb62b3c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -386,8 +380,6 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191224055732-dd894d0a8a40/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41 h1:9Di9iYgOt9ThCipBxChBVhgNipDoE5mxO84rQV7D0FE=
golang.org/x/tools v0.0.0-20200308013534-11ec41452d41/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/tools v0.0.0-20200928201943-a0ef9b62deab h1:CyH2SDm5ATQiX9gtbMYfvNNed97A9v+TJFnUX/fTaJY=
golang.org/x/tools v0.0.0-20200928201943-a0ef9b62deab/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
2 changes: 1 addition & 1 deletion starport/services/scaffolder/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (s *Scaffolder) Init(name string) (path string, err error) {
}

func (s *Scaffolder) generate(pathInfo gomodulepath.Path, absRoot string) error {
g, err := app.New(string(s.options.sdkVersion), &app.Options{
g, err := app.New(s.options.sdkVersion, &app.Options{
ModulePath: pathInfo.RawPath,
AppName: pathInfo.Package,
BinaryNamePrefix: pathInfo.Root,
Expand Down
12 changes: 10 additions & 2 deletions starport/templates/app/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ import (
"github.com/gobuffalo/packr/v2"
"github.com/gobuffalo/plush"
"github.com/gobuffalo/plushgen"
"github.com/tendermint/starport/starport/pkg/cosmosver"
)

// these needs to be created in the compiler time, otherwise packr2 won't be
// able to find boxes.
var templates = map[cosmosver.MajorVersion]*packr.Box{
cosmosver.Launchpad: packr.New("app/templates/launchpad", "./launchpad"),
cosmosver.Stargate: packr.New("app/templates/stargate", "./stargate"),
}

// New ...
func New(sdkVersion string, opts *Options) (*genny.Generator, error) {
func New(sdkVersion cosmosver.MajorVersion, opts *Options) (*genny.Generator, error) {
g := genny.New()
if err := g.Box(packr.New("app/templates", "./"+sdkVersion)); err != nil {
if err := g.Box(templates[sdkVersion]); err != nil {
return g, err
}
ctx := plush.NewContext()
Expand Down
2 changes: 1 addition & 1 deletion starport/templates/typed/new_launchpad.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewLaunchpad(opts *Options) (*genny.Generator, error) {
g.RunFn(t.keeperQuerierModify(opts))
g.RunFn(t.clientRestRestModify(opts))
g.RunFn(frontendSrcStoreAppModify(opts))
return g, box(string(cosmosver.Launchpad), opts, g)
return g, box(cosmosver.Launchpad, opts, g)
}

func (t *typedLaunchpad) handlerModify(opts *Options) genny.RunFn {
Expand Down
2 changes: 1 addition & 1 deletion starport/templates/typed/new_stargate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewStargate(opts *Options) (*genny.Generator, error) {
g.RunFn(t.typesQuerierModify(opts))
g.RunFn(t.keeperQuerierModify(opts))
g.RunFn(t.clientRestRestModify(opts))
return g, box(string(cosmosver.Stargate), opts, g)
return g, box(cosmosver.Stargate, opts, g)
}

func (t *typedStargate) handlerModify(opts *Options) genny.RunFn {
Expand Down
12 changes: 10 additions & 2 deletions starport/templates/typed/typed.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/gobuffalo/packr/v2"
"github.com/gobuffalo/plush"
"github.com/gobuffalo/plushgen"
"github.com/tendermint/starport/starport/pkg/cosmosver"
)

const placeholder = "// this line is used by starport scaffolding # 1"
Expand All @@ -16,8 +17,15 @@ const placeholder3 = "// this line is used by starport scaffolding # 3"
const placeholder4 = "<!-- this line is used by starport scaffolding # 4 -->"
const placeholder44 = "// this line is used by starport scaffolding # 4"

func box(sdkVersion string, opts *Options, g *genny.Generator) error {
if err := g.Box(packr.New("typed/templates", "./"+sdkVersion)); err != nil {
// these needs to be created in the compiler time, otherwise packr2 won't be
// able to find boxes.
var templates = map[cosmosver.MajorVersion]*packr.Box{
cosmosver.Launchpad: packr.New("typed/templates/launchpad", "./launchpad"),
cosmosver.Stargate: packr.New("typed/templates/stargate", "./stargate"),
}

func box(sdkVersion cosmosver.MajorVersion, opts *Options, g *genny.Generator) error {
if err := g.Box(templates[sdkVersion]); err != nil {
return err
}
ctx := plush.NewContext()
Expand Down

0 comments on commit 9852765

Please sign in to comment.