-
Notifications
You must be signed in to change notification settings - Fork 575
feat: add scaffold configs and scaffold params commands and start remove placeholders
#3770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
5cd468e
add parameters placeholders and modifier
6752e7b
add scaffold params command
2ae4256
Merge branch 'main' into feat/add-params
Pantani b862349
add changelog
aef509a
check if the parameter already exist
58ece42
add integration tests and fix some import issues
452187c
improve the scaffolder logic
cb73d70
improve the log message
600e0e9
fix the log message
b8dc81a
Merge branch 'main' into feat/add-params
Pantani 0e516fd
Merge branch 'main' into feat/add-params
Pantani 57693a7
Merge branch 'main' into feat/add-params
Pantani 8457c5e
Merge branch 'main' into feat/add-params
Pantani a62fa47
Merge branch 'main' into feat/add-params
Pantani 81bffd0
Merge branch 'main' into feat/add-params
Pantani efac026
Merge branch 'main' into feat/add-params
Pantani 0ef6666
Merge branch 'main' into feat/add-params
Pantani d659e38
Merge branch 'main' into feat/add-params
Pantani 278f547
Merge branch 'main' into feat/add-params
Pantani 3742073
Merge remote-tracking branch 'origin/main' into feat/add-params
e9a64ff
fix changelog
d1a79ec
fix 28 imports
758457b
remove params module
039cd89
add module configs command
b30cdce
Merge branch 'main' into feat/add-params
Pantani a6a3f93
rollbak empty line for proto
8564b7d
improve code readbility and add unit tests
a227249
Merge branch 'main' into feat/add-params
Pantani bdc1234
Merge branch 'main' into feat/add-params
Pantani 94d4fca
Merge branch 'main' into feat/add-params
Pantani e07fa93
Merge remote-tracking branch 'origin/main' into feat/add-params
ba0a50e
fix changelog
594db1f
Merge branch 'main' into feat/add-params
Pantani ad4b093
Merge branch 'main' into feat/add-params
Pantani 0fb1ce8
Merge branch 'main' into feat/add-params
Pantani bfbb581
Merge branch 'main' into feat/add-params
Pantani cef9405
use cli error package
c2dfbb3
Merge branch 'main' into feat/add-params
Pantani 839867a
Update ignite/cmd/scaffold_configs.go
Pantani 4cfc2af
Merge remote-tracking branch 'origin/main' into feat/add-params
557eed3
apply pr suggestions
52f7239
fix some typos
d650546
remove unused vars and casting
f8d1ab9
Merge remote-tracking branch 'origin/main' into feat/add-params
d9030ec
add replacer pkg for goanalysis
272986e
add TODO comment
1c0e63a
Merge remote-tracking branch 'origin/main' into feat/add-params
8c8499f
add modify call function
c14f9c5
test readbility
62864db
improve organization
951de5e
fix the function modifier logic
35c8487
fix the arg idente for caller replace
98064b1
add more test cases and last fixes
e0d5796
start replace the params template to the xast
f56bdf5
Merge remote-tracking branch 'origin/main' into feat/add-params
6b10809
add append struct param option
f229ede
add support to add new struct params
75cf0f8
fix some lint issues
e797634
add small fixes and improve code readbility
df6f165
fix append code parser
5798289
fix changelog
ffade6c
Merge branch 'main' into feat/add-params
Pantani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package ignitecmd | ||
|
|
||
| import ( | ||
| "strings" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/ignite/cli/v28/ignite/pkg/cliui" | ||
| "github.com/ignite/cli/v28/ignite/pkg/placeholder" | ||
| "github.com/ignite/cli/v28/ignite/services/scaffolder" | ||
| ) | ||
|
|
||
| // NewScaffoldConfigs returns the command to scaffold a Cosmos SDK configs into a module. | ||
| func NewScaffoldConfigs() *cobra.Command { | ||
| c := &cobra.Command{ | ||
| Use: "configs [configs]...", | ||
| Short: "Configs for a custom Cosmos SDK module", | ||
| Long: `Scaffold a new config for a Cosmos SDK module. | ||
|
|
||
| A Cosmos SDK module can have configurations. An example of a config is "address prefix" of the | ||
| "auth" module. A config can be scaffolded into a module using the "--module-configs" into | ||
| the scaffold module command or using the "scaffold configs" command. By default | ||
| configs are of type "string", but you can specify a type for each config. For example: | ||
|
|
||
| ignite scaffold configs foo baz:uint bar:bool | ||
|
|
||
| Refer to Cosmos SDK documentation to learn more about modules, dependencies and | ||
| configs. | ||
| `, | ||
| Args: cobra.MinimumNArgs(1), | ||
| PreRunE: migrationPreRunHandler, | ||
| RunE: scaffoldConfigsHandler, | ||
| } | ||
|
|
||
| flagSetPath(c) | ||
| flagSetClearCache(c) | ||
|
|
||
| c.Flags().AddFlagSet(flagSetYes()) | ||
|
|
||
| c.Flags().String(flagModule, "", "module to add the query into (default: app's main module)") | ||
|
|
||
| return c | ||
| } | ||
|
|
||
| func scaffoldConfigsHandler(cmd *cobra.Command, args []string) error { | ||
| var ( | ||
| configs = args[0:] | ||
| appPath = flagGetPath(cmd) | ||
| moduleName = flagGetModule(cmd) | ||
| ) | ||
|
|
||
| session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) | ||
| defer session.End() | ||
|
|
||
| cacheStorage, err := newCache(cmd) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| sc, err := scaffolder.New(appPath) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| sm, err := sc.CreateConfigs(cmd.Context(), cacheStorage, placeholder.New(), moduleName, configs...) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| modificationsStr, err := sourceModificationToString(sm) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| session.Println(modificationsStr) | ||
| session.Printf("\n🎉 New configs added to the module:\n\n- %s\n\n", strings.Join(configs, "\n- ")) | ||
|
|
||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package ignitecmd | ||
|
|
||
| import ( | ||
| "strings" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/ignite/cli/v28/ignite/pkg/cliui" | ||
| "github.com/ignite/cli/v28/ignite/pkg/placeholder" | ||
| "github.com/ignite/cli/v28/ignite/services/scaffolder" | ||
| ) | ||
|
|
||
| // NewScaffoldParams returns the command to scaffold a Cosmos SDK parameters into a module. | ||
| func NewScaffoldParams() *cobra.Command { | ||
| c := &cobra.Command{ | ||
| Use: "params [param]...", | ||
| Short: "Parameters for a custom Cosmos SDK module", | ||
| Long: `Scaffold a new parameter for a Cosmos SDK module. | ||
|
|
||
| A Cosmos SDK module can have parameters (or "params"). Params are values that | ||
| can be set at the genesis of the blockchain and can be modified while the | ||
| blockchain is running. An example of a param is "Inflation rate change" of the | ||
| "mint" module. A params can be scaffolded into a module using the "--params" into | ||
| the scaffold module command or using the "scaffold params" command. By default | ||
| params are of type "string", but you can specify a type for each param. For example: | ||
|
|
||
| ignite scaffold params foo baz:uint bar:bool | ||
|
|
||
| Refer to Cosmos SDK documentation to learn more about modules, dependencies and | ||
| params. | ||
| `, | ||
| Args: cobra.MinimumNArgs(1), | ||
| PreRunE: migrationPreRunHandler, | ||
| RunE: scaffoldParamsHandler, | ||
| } | ||
|
|
||
| flagSetPath(c) | ||
| flagSetClearCache(c) | ||
|
|
||
| c.Flags().AddFlagSet(flagSetYes()) | ||
|
|
||
| c.Flags().String(flagModule, "", "module to add the query into. Default: app's main module") | ||
|
|
||
| return c | ||
| } | ||
|
|
||
| func scaffoldParamsHandler(cmd *cobra.Command, args []string) error { | ||
| var ( | ||
| params = args[0:] | ||
| appPath = flagGetPath(cmd) | ||
| moduleName = flagGetModule(cmd) | ||
| ) | ||
|
|
||
| session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) | ||
| defer session.End() | ||
|
|
||
| cacheStorage, err := newCache(cmd) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| sc, err := scaffolder.New(appPath) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| sm, err := sc.CreateParams(cmd.Context(), cacheStorage, placeholder.New(), moduleName, params...) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| modificationsStr, err := sourceModificationToString(sm) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| session.Println(modificationsStr) | ||
| session.Printf("\n🎉 New parameters added to the module:\n\n- %s\n\n", strings.Join(params, "\n- ")) | ||
|
|
||
| return nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.