Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Commit

Permalink
deprecate packr2 build/install
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Jun 3, 2019
1 parent 580fa2f commit 70dc714
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
8 changes: 1 addition & 7 deletions v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ The `--legacy` command is available on all commands that generate `-packr.go` fi

```bash
$ packr2 --legacy
$ packr2 install --legacy
$ packr2 build --legacy
```

## Usage
Expand Down Expand Up @@ -139,11 +137,7 @@ func main() {

---

## Building a Binary (the easy way)

When it comes time to build, or install, your Go binary, simply use `packr2 build` or `packr2 install` just as you would `go build` or `go install`. All flags for the `go` tool are supported and everything works the way you expect, the only difference is your static assets are now bundled in the generated binary. If you want more control over how this happens, looking at the following section on building binaries (the hard way).

## Building a Binary (the hard way)
## Building a Binary

Before you build your Go binary, run the `packr2` command first. It will look for all the boxes in your code and then generate `.go` files that pack the static files into bytes that can be bundled into the Go binary.

Expand Down
5 changes: 5 additions & 0 deletions v2/packr2/cmd/build.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"fmt"

"github.com/gobuffalo/packr/v2/jam"
"github.com/spf13/cobra"
)
Expand All @@ -11,6 +13,9 @@ var buildCmd = &cobra.Command{
DisableFlagParsing: true,
RunE: func(cmd *cobra.Command, args []string) error {
cargs := parseArgs(args)
if globalOptions.Verbose {
fmt.Println(dont)
}
if err := jam.Pack(globalOptions.PackOptions); err != nil {
return err
}
Expand Down
22 changes: 21 additions & 1 deletion v2/packr2/cmd/install.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
package cmd

import (
"fmt"

"github.com/gobuffalo/packr/v2/jam"
"github.com/spf13/cobra"
)

const dont = `Please don't.
The following commands have been deprecated and should not be used:
* packr2 build
* packr2 install
They are, I'll be kind and say, "problematic" and cause more issues
than than the actually solve. Sorry about that. My bad.
It is recommended you use two commands instead:
$ packr2
$ go build/install
`

var installCmd = &cobra.Command{
Use: "install",
Short: "Wraps the go install command with packr",
Short: "Don't. ru",
DisableFlagParsing: true,
RunE: func(cmd *cobra.Command, args []string) error {
cargs := parseArgs(args)
if globalOptions.Verbose {
fmt.Println(dont)
}
if err := jam.Pack(globalOptions.PackOptions); err != nil {
return err
}
Expand Down

0 comments on commit 70dc714

Please sign in to comment.