diff --git a/changelog.md b/changelog.md index 8feba76535..68d0d52a1d 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,8 @@ ## Unreleased +## [`v28.5.0`](https://github.com/ignite/cli/releases/tag/v28.5.0) + ### Features - [#4183](https://github.com/ignite/cli/pull/4183) Set `chain-id` in the client.toml @@ -27,6 +29,7 @@ If you are uprading manually, check out the recommended changes in `root.go` from the above PR. - [#4210](https://github.com/ignite/cli/pull/4210) Improve default home wiring - [#4077](https://github.com/ignite/cli/pull/4077) Merge the swagger files manually instead use nodetime `swagger-combine` +- [#4249](https://github.com/ignite/cli/pull/4249) Prevent creating a chain with number in the name - [#4253](https://github.com/ignite/cli/pull/4253) Bump cosmos-sdk to `v0.50.8` ### Fixes diff --git a/ignite/services/scaffolder/init.go b/ignite/services/scaffolder/init.go index 096917512d..092ac7b520 100644 --- a/ignite/services/scaffolder/init.go +++ b/ignite/services/scaffolder/init.go @@ -10,6 +10,7 @@ import ( "github.com/ignite/cli/v28/ignite/pkg/cache" "github.com/ignite/cli/v28/ignite/pkg/cosmosgen" + "github.com/ignite/cli/v28/ignite/pkg/errors" "github.com/ignite/cli/v28/ignite/pkg/gomodulepath" "github.com/ignite/cli/v28/ignite/pkg/placeholder" "github.com/ignite/cli/v28/ignite/pkg/xgit" @@ -33,6 +34,13 @@ func Init( return "", err } + // Check if the module name is valid (no numbers) + for _, r := range pathInfo.Package { + if r >= '0' && r <= '9' { + return "", errors.Errorf("invalid app name %s: cannot contain numbers", pathInfo.Package) + } + } + // Create a new folder named as the blockchain when a custom path is not specified var appFolder string if root == "" { diff --git a/integration/app/cmd_app_test.go b/integration/app/cmd_app_test.go index 373e9f6116..ac15562d74 100644 --- a/integration/app/cmd_app_test.go +++ b/integration/app/cmd_app_test.go @@ -3,6 +3,7 @@ package app_test import ( + "bytes" "os" "path/filepath" "testing" @@ -52,6 +53,23 @@ func TestGenerateAnAppWithName(t *testing.T) { app.EnsureSteady() } +// TestGenerateAnAppWithInvalidName tests scaffolding a new chain using an invalid name. +func TestGenerateAnAppWithInvalidName(t *testing.T) { + buf := new(bytes.Buffer) + + env := envtest.New(t) + env.Must(env.Exec("should prevent creating an app with an invalid name", + step.NewSteps(step.New( + step.Exec(envtest.IgniteApp, "s", "chain", "blog2"), + step.Stdout(buf), + step.Stderr(buf), + )), + envtest.ExecShouldError(), + )) + + require.Contains(t, buf.String(), "Invalid app name blog2: cannot contain numbers") +} + func TestGenerateAnAppWithNoDefaultModule(t *testing.T) { var ( env = envtest.New(t) diff --git a/integration/chain/cmd_serve_test.go b/integration/chain/cmd_serve_test.go index 0c818e691c..46b6a5cefb 100644 --- a/integration/chain/cmd_serve_test.go +++ b/integration/chain/cmd_serve_test.go @@ -46,7 +46,7 @@ func TestServeWithWasm(t *testing.T) { func TestServeWithCustomHome(t *testing.T) { var ( env = envtest.New(t) - app = env.Scaffold("github.com/test/sgblog2") + app = env.Scaffold("github.com/test/sgbloga") servers = app.RandomizeServerPorts() ) @@ -66,7 +66,7 @@ func TestServeWithCustomHome(t *testing.T) { func TestServeWithConfigHome(t *testing.T) { var ( env = envtest.New(t) - app = env.Scaffold("github.com/test/sgblog3") + app = env.Scaffold("github.com/test/sgblogb") servers = app.RandomizeServerPorts() ) @@ -88,7 +88,7 @@ func TestServeWithCustomConfigFile(t *testing.T) { var ( env = envtest.New(t) - app = env.Scaffold("github.com/test/sgblog4") + app = env.Scaffold("github.com/test/sgblogc") ) // Move config newConfig := "new_config.yml" @@ -116,7 +116,7 @@ func TestServeWithCustomConfigFile(t *testing.T) { func TestServeWithName(t *testing.T) { var ( env = envtest.New(t) - app = env.Scaffold("sgblog5") + app = env.Scaffold("sgblogd") servers = app.RandomizeServerPorts() ) diff --git a/integration/ibc/cmd_ibc_test.go b/integration/ibc/cmd_ibc_test.go index e9c65d33b4..393dea2d5e 100644 --- a/integration/ibc/cmd_ibc_test.go +++ b/integration/ibc/cmd_ibc_test.go @@ -189,7 +189,7 @@ func TestCreateIBCOracle(t *testing.T) { func TestCreateIBCPacket(t *testing.T) { var ( env = envtest.New(t) - app = env.Scaffold("github.com/test/blogibc2") + app = env.Scaffold("github.com/test/blogibcb") ) env.Must(env.Exec("create an IBC module",