Skip to content

Commit

Permalink
Merge branch 'main' into duong/in-place-testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani authored Aug 29, 2024
2 parents fc295c9 + 7ff4b5d commit 5130a8c
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [#4131](https://github.com/ignite/cli/pull/4131) Support `bytes` as data type in the `scaffold` commands
- [#4297](https://github.com/ignite/cli/pull/4297) Add in-place testnet creation command for apps.
- [#4300](https://github.com/ignite/cli/pull/4300) Only panics the module in the most top function level
- [#4326](https://github.com/ignite/cli/pull/4326) fAdd `buf.build` version to `ignite version` command

### Changes

Expand All @@ -38,6 +39,8 @@
- [#4189](https://github.com/ignite/cli/pull/4189) Deprecate `ignite node` for `ignite connect` app
- [#4290](https://github.com/ignite/cli/pull/4290) Remove ignite ics logic from ignite cli (this functionality will be in the `consumer` app)
- [#4295](https://github.com/ignite/cli/pull/4295) Stop scaffolding `pulsar` files
- [#4322](https://github.com/ignite/cli/pull/4322) Create a message for authenticate buf for generate ts-client
- [#4319](https://github.com/ignite/cli/pull/4319) Remove fee abstraction module from open api code generation
- [#4317](https://github.com/ignite/cli/pull/4317) Remove xchisel dependency

### Fixes
Expand Down
10 changes: 10 additions & 0 deletions ignite/cmd/generate_typescript_client.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package ignitecmd

import (
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"

"github.com/ignite/cli/v29/ignite/pkg/cliui"
"github.com/ignite/cli/v29/ignite/pkg/cliui/icons"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/services/chain"
)

const (
flagUseCache = "use-cache"
msgBufAuth = "Generate ts-client depends on a 'buf.build' remote plugin, and as of August 1, 2024, Buf will begin limiting remote plugin requests from unauthenticated users on 'buf.build'. If you send more than ten unauthenticated requests per hour using remote plugins, you’ll start to see rate limit errors. Please authenticate before running ts-client command using 'buf registry login' command and follow the instructions. For more info, check https://buf.build/docs/generate/auth-required."
)

func NewGenerateTSClient() *cobra.Command {
Expand Down Expand Up @@ -48,6 +51,13 @@ func generateTSClientHandler(cmd *cobra.Command, _ []string) error {
session := cliui.New(cliui.StartSpinnerWithText(statusGenerating))
defer session.End()

if err := session.AskConfirm(msgBufAuth); err != nil {
if errors.Is(err, promptui.ErrAbort) {
return errors.New("buf not auth")
}
return err
}

c, err := chain.NewWithHomeFlags(
cmd,
chain.WithOutputer(session),
Expand Down
6 changes: 4 additions & 2 deletions ignite/internal/analytics/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ func SendMetric(wg *sync.WaitGroup, cmd *cobra.Command) {
// checkDNT check if the user allow to track data or if the DO_NOT_TRACK
// env var is set https://consoledonottrack.com/
func checkDNT() (anonIdentity, error) {
if dnt, err := strconv.ParseBool(os.Getenv(envDoNotTrack)); err != nil || dnt {
return anonIdentity{DoNotTrack: true}, nil
if dnt := os.Getenv(envDoNotTrack); dnt != "" {
if dnt, err := strconv.ParseBool(dnt); err != nil || dnt {
return anonIdentity{DoNotTrack: true}, nil
}
}

globalPath, err := config.DirPath()
Expand Down
26 changes: 24 additions & 2 deletions ignite/pkg/cosmosbuf/buf.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package cosmosbuf

import (
"bytes"
"context"
"fmt"
"path/filepath"
"strings"

"github.com/gobwas/glob"
"golang.org/x/sync/errgroup"

"github.com/ignite/cli/v29/ignite/pkg/cache"
"github.com/ignite/cli/v29/ignite/pkg/cmdrunner/exec"
"github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step"
"github.com/ignite/cli/v29/ignite/pkg/dircache"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/pkg/goenv"
Expand Down Expand Up @@ -124,7 +127,7 @@ func FileByFile() GenOption {

// New creates a new Buf based on the installed binary.
func New(cacheStorage cache.Storage, goModPath string) (Buf, error) {
path, err := xexec.ResolveAbsPath(filepath.Join(goenv.Bin(), binaryName))
p, err := path()
if err != nil {
return Buf{}, err
}
Expand All @@ -136,7 +139,7 @@ func New(cacheStorage cache.Storage, goModPath string) (Buf, error) {
}

return Buf{
path: path,
path: p,
cache: c,
}, nil
}
Expand Down Expand Up @@ -309,3 +312,22 @@ func (b Buf) command(
}
return command, nil
}

func path() (string, error) {
return xexec.ResolveAbsPath(filepath.Join(goenv.Bin(), binaryName))
}

// Version runs the buf Version command.
func Version(ctx context.Context) (string, error) {
p, err := path()
if err != nil {
return "", err
}

bufOut := &bytes.Buffer{}
if err := exec.Exec(ctx, []string{p, "--version"}, exec.StepOption(step.Stdout(bufOut))); err != nil {
return "", err
}

return strings.TrimSpace(bufOut.String()), nil
}
1 change: 1 addition & 0 deletions ignite/pkg/cosmosgen/generate_openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (g *generator) generateOpenAPISpec(ctx context.Context) error {
dir,
g.openAPITemplate(),
cosmosbuf.ExcludeFiles(
"*/osmosis-labs/fee-abstraction/*",
"*/module.proto",
"*/testutil/*",
"*/testdata/*",
Expand Down
9 changes: 9 additions & 0 deletions ignite/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
chainconfig "github.com/ignite/cli/v29/ignite/config/chain"
"github.com/ignite/cli/v29/ignite/pkg/cmdrunner/exec"
"github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step"
"github.com/ignite/cli/v29/ignite/pkg/cosmosbuf"
"github.com/ignite/cli/v29/ignite/pkg/cosmosver"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/pkg/gitpod"
Expand All @@ -40,6 +41,7 @@ type Info struct {
CLIVersion string
GoVersion string
SDKVersion string
BufVersion string
BuildDate string
SourceHash string
ConfigVersion string
Expand Down Expand Up @@ -150,6 +152,7 @@ func Long(ctx context.Context) (string, error) {
write("Ignite CLI source hash", info.SourceHash)
write("Ignite CLI config version", info.ConfigVersion)
write("Cosmos SDK version", info.SDKVersion)
write("Buf.Build version", info.BufVersion)

write("Your OS", info.OS)
write("Your arch", info.Arch)
Expand Down Expand Up @@ -221,9 +224,15 @@ func GetInfo(ctx context.Context) (Info, error) {
uname = strings.TrimSpace(unameBuf.String())
}

bufVersion, err := cosmosbuf.Version(ctx)
if err != nil {
return info, err
}

info.Uname = uname
info.CLIVersion = resolveDevVersion(ctx)
info.BuildDate = date
info.BufVersion = bufVersion
info.SourceHash = head
info.ConfigVersion = fmt.Sprintf("v%d", chainconfig.LatestVersion)
info.SDKVersion = sdkVersion
Expand Down
2 changes: 2 additions & 0 deletions integration/cosmosgen/cosmosgen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
)

func TestCosmosGenScaffold(t *testing.T) {
t.Skip("skip till we add a buf token into the CI")

var (
env = envtest.New(t)
app = env.Scaffold("github.com/test/blog")
Expand Down

0 comments on commit 5130a8c

Please sign in to comment.