We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cd9e46a commit 62ae705Copy full SHA for 62ae705
5 files changed
changelog.md
@@ -4,6 +4,7 @@
4
5
### Changes
6
7
+- [#4880](https://github.com/ignite/cli/pull/4880) Add possibility to scaffold underscore package.
8
- [#4878](https://github.com/ignite/cli/pull/4878) Improve the `xast` package readability.
9
10
## [`v29.8.0`](https://github.com/ignite/cli/releases/tag/v29.8.0)
ignite/pkg/gomodulepath/gomodulepath.go
@@ -154,6 +154,6 @@ func root(path string) string {
154
}
155
156
func stripNonAlphaNumeric(name string) string {
157
- reg := regexp.MustCompile(`[^a-zA-Z0-9]+`)
+ reg := regexp.MustCompile(`[^a-zA-Z0-9_]+`)
158
return strings.ToLower(reg.ReplaceAllString(name, ""))
159
ignite/pkg/gomodulepath/gomodulepath_test.go
@@ -63,7 +63,7 @@ func TestParse(t *testing.T) {
63
{
64
name: "with underscore",
65
rawpath: "github.com/a/b_c",
66
- path: Path{RawPath: "github.com/a/b_c", Root: "b_c", Package: "bc"},
+ path: Path{RawPath: "github.com/a/b_c", Root: "b_c", Package: "b_c"},
67
},
68
69
name: "with mixed case",
@@ -78,7 +78,7 @@ func TestParse(t *testing.T) {
78
79
name: "with a name containing underscore",
80
rawpath: "a_b",
81
- path: Path{RawPath: "a_b", Root: "a_b", Package: "ab"},
+ path: Path{RawPath: "a_b", Root: "a_b", Package: "a_b"},
82
83
84
name: "with a name containing dash",
@@ -93,7 +93,7 @@ func TestParse(t *testing.T) {
93
94
name: "with a path containing underscore",
95
rawpath: "a/b_c",
96
- path: Path{RawPath: "a/b_c", Root: "b_c", Package: "bc"},
+ path: Path{RawPath: "a/b_c", Root: "b_c", Package: "b_c"},
97
98
99
name: "with a path containing dash",
ignite/services/scaffolder/init.go
@@ -9,6 +9,7 @@ import (
"github.com/ignite/cli/v29/ignite/pkg/cliui"
"github.com/ignite/cli/v29/ignite/pkg/errors"
11
"github.com/ignite/cli/v29/ignite/pkg/gomodulepath"
12
+ "github.com/ignite/cli/v29/ignite/pkg/multiformatname"
13
"github.com/ignite/cli/v29/ignite/pkg/xgenny"
14
"github.com/ignite/cli/v29/ignite/templates/app"
15
"github.com/ignite/cli/v29/ignite/templates/field"
@@ -119,8 +120,13 @@ func generate(
119
120
121
122
if !noDefaultModule {
123
+ moduleName, err := multiformatname.NewName(pathInfo.Package, multiformatname.NoNumber)
124
+ if err != nil {
125
+ return smc, err
126
+ }
127
+
128
opts := &modulecreate.CreateOptions{
- ModuleName: pathInfo.Package, // App name
129
+ ModuleName: moduleName.LowerCase, // App module
130
ModulePath: pathInfo.RawPath,
131
AppName: pathInfo.Package,
132
ProtoDir: protoDir,
integration/app/cmd_app_test.go
@@ -216,3 +216,19 @@ func TestGenerateAnAppWithDefaultDenom(t *testing.T) {
216
217
app.EnsureSteady()
218
219
220
+func TestScaffoldModuleWithUnderscoreAppName(t *testing.T) {
221
+ var (
222
+ env = envtest.New(t)
223
+ app = env.ScaffoldApp("github.com/test/space_chain")
224
+ )
225
226
+ app.Scaffold(
227
+ "create a module in app with underscore name",
228
+ false,
229
+ "module",
230
+ "f_o_o",
231
232
233
+ app.EnsureSteady()
234
+}
0 commit comments