Skip to content
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

refactor: rename plugins config file to igniteapps #3669

Merged
merged 17 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [#3658](https://github.com/ignite/cli/pull/3658) Rename Marshaler to Codec in EncodingConfig
- [#3653](https://github.com/ignite/cli/pull/3653) Add "app" extension to plugin binaries
- [#3656](https://github.com/ignite/cli/pull/3656) Disable Go toolchain download
- [#3669](https://github.com/ignite/cli/pull/3669) Rename `plugins` config file to `igniteapps`

### Fixes

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/06-migration/v0.19.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ official Ignite CLI repo which introduces breaking changes.
To migrate your chain that was scaffolded with Ignite CLI versions lower than v0.19.2:

1. IBC upgrade: Use
the [IBC migration documents](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v1-to-v2.md)
the [IBC migration documents](https://github.com/cosmos/ibc-go/blob/v6.2.0/docs/migrations/v1-to-v2.md)

2. In your chain's `go.mod` file, remove `tendermint/spm` and add the v0.19.2 version of `tendermint/starport`. If your
chain uses these packages, change the import paths as shown:
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/06-migration/v0.26.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ their tooling to the latest version.

Chains that are newly scaffolded with Ignite CLI `v0.26.0` now use `ibc-go/v6` for ibc functionality. It is not
necessary, but recommended to upgrade to the newest version of `ibc-go`. Most migrations can be done by following the
`ibc-go` [migration guide](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v5-to-v6.md), but there are some
`ibc-go` [migration guide](https://github.com/cosmos/ibc-go/blob/v6.2.0/docs/migrations/v5-to-v6.md), but there are some
specific changes that will need to be followed for Ignite scaffolded chains.

### Removing `cosmosibckeeper`
Expand Down Expand Up @@ -215,7 +215,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {

### Remaining migration

After all uses of `cosmosibckeeper` have been removed, you can follow any remaining steps in the`ibc-go`[migration guide](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v5-to-v6.md).
After all uses of `cosmosibckeeper` have been removed, you can follow any remaining steps in the`ibc-go`[migration guide](https://github.com/cosmos/ibc-go/blob/v6.2.0/docs/migrations/v5-to-v6.md).

## Scaffolded Release Workflow

Expand Down
17 changes: 17 additions & 0 deletions docs/docs/06-migration/v0.28.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
sidebar_position: 990
title: v0.28.0
description: For chains that were scaffolded with Ignite CLI versions lower than v0.28.0. changes are required to use Ignite CLI v0.28.0.
---

## Upgrading legacy plugins configuration files

Ignite `v0.28.0` changes the plugin system which is now called Ignite Apps. This version includes changes
to the CLI command names and the plugin configuration file.

The plugins configuration file is now called `igniteapps.yml` and the "plugins" section is now called "apps".

The global plugins directory is now `$HOME/.ignite/apps` instead `$HOME/.ignite/plugins`.

Updates can be automatically applied by running `ignite doctor` in your blockchain application directory.
Running the command outside your blockchain application directory will only update the global plugins.
2 changes: 1 addition & 1 deletion docs/docs/apps/01-using-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ core concepts within apps: `Commands` and `Hooks`. `Commands` extend the CLI's
functionality and `Hooks` extend existing CLI command functionality.

Apps are registered in an Ignite scaffolded blockchain project through the
`plugins.yml`, or globally through `$HOME/.ignite/plugins/plugins.yml`.
`igniteapps.yml`, or globally through `$HOME/.ignite/apps/igniteapps.yml`.

To use an app within your project execute the following command inside the
project directory:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ To ensure you have a successful experience working with our Developer Tutorials

## Setting up Visual Studio Code

1. Install [Visual Studio Code](https://vscode-docs.readthedocs.io/en/latest/editor/setup).
1. Install [Visual Studio Code](https://vscode-docs.readthedocs.io/en/latest/editor/setup/).
1. Click **Extensions** in the sidebar.
1. Install this extension:
- Go for VS Code The official Go extension for Visual Studio Code
Expand Down
2 changes: 1 addition & 1 deletion docs/versioned_docs/version-v0.25.2/migration/v0.19.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ With Ignite CLI v0.19.2, the contents of the deprecated Ignite CLI Modules `tend

To migrate your chain that was scaffolded with Ignite CLI versions lower than v0.19.2:

1. IBC upgrade: Use the [IBC migration documents](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v1-to-v2.md)
1. IBC upgrade: Use the [IBC migration documents](https://github.com/cosmos/ibc-go/blob/v6.2.0/docs/migrations/v1-to-v2.md)

2. In your chain's `go.mod` file, remove `tendermint/spm` and add the v0.19.2 version of `tendermint/starport`. If your chain uses these packages, change the import paths as shown:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ official Ignite CLI repo which introduces breaking changes.
To migrate your chain that was scaffolded with Ignite CLI versions lower than v0.19.2:

1. IBC upgrade: Use
the [IBC migration documents](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v1-to-v2.md)
the [IBC migration documents](https://github.com/cosmos/ibc-go/blob/v6.2.0/docs/migrations/v1-to-v2.md)

2. In your chain's `go.mod` file, remove `tendermint/spm` and add the v0.19.2 version of `tendermint/starport`. If your
chain uses these packages, change the import paths as shown:
Expand Down
4 changes: 2 additions & 2 deletions docs/versioned_docs/version-v0.26.1/06-migration/v0.26.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ their tooling to the latest version.

Chains that are newly scaffolded with Ignite CLI `v0.26.0` now use `ibc-go/v6` for ibc functionality. It is not
necessary, but recommended to upgrade to the newest version of `ibc-go`. Most migrations can be done by following the
`ibc-go` [migration guide](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v5-to-v6.md), but there are some
`ibc-go` [migration guide](https://github.com/cosmos/ibc-go/blob/v6.2.0/docs/migrations/v5-to-v6.md), but there are some
specific changes that will need to be followed for Ignite scaffolded chains.

### Removing `cosmosibckeeper`
Expand Down Expand Up @@ -215,7 +215,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {

### Remaining migration

After all uses of `cosmosibckeeper` have been removed, you can follow any remaining steps in the`ibc-go`[migration guide](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v5-to-v6.md).
After all uses of `cosmosibckeeper` have been removed, you can follow any remaining steps in the`ibc-go`[migration guide](https://github.com/cosmos/ibc-go/blob/v6.2.0/docs/migrations/v5-to-v6.md).

## Scaffolded Release Workflow

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ official Ignite CLI repo which introduces breaking changes.
To migrate your chain that was scaffolded with Ignite CLI versions lower than v0.19.2:

1. IBC upgrade: Use
the [IBC migration documents](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v1-to-v2.md)
the [IBC migration documents](https://github.com/cosmos/ibc-go/blob/v6.2.0/docs/migrations/v1-to-v2.md)

2. In your chain's `go.mod` file, remove `tendermint/spm` and add the v0.19.2 version of `tendermint/starport`. If your
chain uses these packages, change the import paths as shown:
Expand Down
4 changes: 2 additions & 2 deletions docs/versioned_docs/version-v0.27.1/06-migration/v0.26.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ their tooling to the latest version.

Chains that are newly scaffolded with Ignite CLI `v0.26.0` now use `ibc-go/v6` for ibc functionality. It is not
necessary, but recommended to upgrade to the newest version of `ibc-go`. Most migrations can be done by following the
`ibc-go` [migration guide](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v5-to-v6.md), but there are some
`ibc-go` [migration guide](https://github.com/cosmos/ibc-go/blob/v6.2.0/docs/migrations/v5-to-v6.md), but there are some
specific changes that will need to be followed for Ignite scaffolded chains.

### Removing `cosmosibckeeper`
Expand Down Expand Up @@ -215,7 +215,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {

### Remaining migration

After all uses of `cosmosibckeeper` have been removed, you can follow any remaining steps in the`ibc-go`[migration guide](https://github.com/cosmos/ibc-go/blob/main/docs/migrations/v5-to-v6.md).
After all uses of `cosmosibckeeper` have been removed, you can follow any remaining steps in the`ibc-go`[migration guide](https://github.com/cosmos/ibc-go/blob/v6.2.0/docs/migrations/v5-to-v6.md).

## Scaffolded Release Workflow

Expand Down
4 changes: 4 additions & 0 deletions ignite/cmd/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
return err
}

if err := doc.MigratePluginsConfig(); err != nil {
return err
}

Check warning on line 27 in ignite/cmd/doctor.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/doctor.go#L25-L27

Added lines #L25 - L27 were not covered by tests

return doc.FixDependencyTools(cmd.Context())
},
}
Expand Down
19 changes: 9 additions & 10 deletions ignite/cmd/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
if err != nil && !errors.As(err, &cosmosanalysis.ErrPathNotChain{}) {
return err
} else if err == nil {
pluginsConfigs = append(pluginsConfigs, localCfg.Plugins...)
pluginsConfigs = append(pluginsConfigs, localCfg.Apps...)

Check warning on line 42 in ignite/cmd/plugin.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/plugin.go#L42

Added line #L42 was not covered by tests
}

globalCfg, err := parseGlobalPlugins()
if err == nil {
pluginsConfigs = append(pluginsConfigs, globalCfg.Plugins...)
pluginsConfigs = append(pluginsConfigs, globalCfg.Apps...)

Check warning on line 47 in ignite/cmd/plugin.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/plugin.go#L47

Added line #L47 was not covered by tests
}
ensureDefaultPlugins(cmd, globalCfg)

Expand Down Expand Up @@ -97,8 +97,8 @@
return &pluginsconfig.Config{}, nil
}

for i := range cfg.Plugins {
cfg.Plugins[i].Global = true
for i := range cfg.Apps {
cfg.Apps[i].Global = true

Check warning on line 101 in ignite/cmd/plugin.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/plugin.go#L100-L101

Added lines #L100 - L101 were not covered by tests
}
return
}
Expand Down Expand Up @@ -436,7 +436,7 @@
return err
}

for _, p := range conf.Plugins {
for _, p := range conf.Apps {

Check warning on line 439 in ignite/cmd/plugin.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/plugin.go#L439

Added line #L439 was not covered by tests
if p.Path == args[0] {
return fmt.Errorf("cannot add duplicate plugin %s", args[0])
}
Expand Down Expand Up @@ -476,7 +476,7 @@
return fmt.Errorf("error while loading plugin %q: %w", args[0], plugins[0].Error)
}
session.Println("Done loading plugin")
conf.Plugins = append(conf.Plugins, p)
conf.Apps = append(conf.Apps, p)

Check warning on line 479 in ignite/cmd/plugin.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/plugin.go#L479

Added line #L479 was not covered by tests

if err := conf.Save(); err != nil {
return err
Expand Down Expand Up @@ -517,9 +517,9 @@
}

removed := false
for i, cp := range conf.Plugins {
for i, cp := range conf.Apps {

Check warning on line 520 in ignite/cmd/plugin.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/plugin.go#L520

Added line #L520 was not covered by tests
if cp.Path == args[0] {
conf.Plugins = append(conf.Plugins[:i], conf.Plugins[i+1:]...)
conf.Apps = append(conf.Apps[:i], conf.Apps[i+1:]...)

Check warning on line 522 in ignite/cmd/plugin.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/plugin.go#L522

Added line #L522 was not covered by tests
removed = true
break
}
Expand Down Expand Up @@ -658,8 +658,7 @@

func flagSetPluginsGlobal() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.BoolP(flagPluginsGlobal, "g", false, "use global plugins configuration"+
" ($HOME/.ignite/plugins/plugins.yml)")
fs.BoolP(flagPluginsGlobal, "g", false, "use global plugins configuration ($HOME/.ignite/apps/igniteapps.yml)")

Check warning on line 661 in ignite/cmd/plugin.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/plugin.go#L661

Added line #L661 was not covered by tests
return fs
}

Expand Down
2 changes: 1 addition & 1 deletion ignite/cmd/plugin_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
pluginCfg := pluginsconfig.Plugin{
Path: dp.path,
}
cfg.Plugins = append(cfg.Plugins, pluginCfg)
cfg.Apps = append(cfg.Apps, pluginCfg)

Check warning on line 77 in ignite/cmd/plugin_default.go

View check run for this annotation

Codecov / codecov/patch

ignite/cmd/plugin_default.go#L77

Added line #L77 was not covered by tests
if err := cfg.Save(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion ignite/cmd/plugin_default_test.go
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestEnsureDefaultPlugins(t *testing.T) {
{
name: "should not add because already present in config",
cfg: &pluginsconfig.Config{
Plugins: []pluginsconfig.Plugin{{
Apps: []pluginsconfig.Plugin{{
Path: "github.com/ignite/cli-plugin-network@v42",
}},
},
Expand Down
2 changes: 1 addition & 1 deletion ignite/config/chain/v1/testdata/config2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ validators:
address: 0.0.0.0:8545
ws-address: 0.0.0.0:8546
home: $HOME/.evmosd
plugins:
apps:
- name: plugin1
path: /path/to/plugin1
- name: plugin2
Expand Down
10 changes: 7 additions & 3 deletions ignite/config/plugins/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ type Config struct {
// path to the config file
path string

Plugins []Plugin `yaml:"plugins"`
// Apps holds the list of installed Ignite Apps.
// Ignite Apps are implemented as plugins.
Apps []Plugin `yaml:"apps"`
jeronimoalbi marked this conversation as resolved.
Show resolved Hide resolved
}

// Plugin keeps plugin name and location.
Expand All @@ -38,10 +40,12 @@ type Plugin struct {
//
// path: github.com/foo/bar/plugin1@v42
Path string `yaml:"path"`

// With holds arguments passed to the plugin interface
With map[string]string `yaml:"with,omitempty"`

// Global holds whether the plugin is installed globally
// (default: $HOME/.ignite/plugins/plugins.yml) or locally for a chain.
// (default: $HOME/.ignite/apps/igniteapps.yml) or locally for a chain.
Global bool `yaml:"-"`
}

Expand Down Expand Up @@ -134,7 +138,7 @@ func (c *Config) Save() error {
// Returns also true if there's a local plugin with the module name equal to
// that path.
func (c Config) HasPlugin(path string) bool {
return slices.ContainsFunc(c.Plugins, func(cp Plugin) bool {
return slices.ContainsFunc(c.Apps, func(cp Plugin) bool {
if cp.HasPath(path) {
return true
}
Expand Down
22 changes: 11 additions & 11 deletions ignite/config/plugins/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,30 +268,30 @@ func TestConfigSave(t *testing.T) {
require.NoError(t, err)
return cfg
},
expectedContent: "plugins: []\n",
expectedContent: "apps: []\n",
},
{
name: "ok: config path is an existing file",
buildConfig: func(t *testing.T) *pluginsconfig.Config {
// copy testdata/plugins.yml to tmp because it will be modified
// copy testdata/igniteapps.yml to tmp because it will be modified
dir := t.TempDir()
bz, err := os.ReadFile("testdata/plugins.yml")
bz, err := os.ReadFile("testdata/igniteapps.yml")
require.NoError(t, err)
err = os.WriteFile(path.Join(dir, "plugins.yml"), bz, 0o666)
err = os.WriteFile(path.Join(dir, "igniteapps.yml"), bz, 0o666)
require.NoError(t, err)
// load from tmp
cfg, _ := pluginsconfig.ParseDir(dir)
// add a new plugin
cfg.Plugins = append(cfg.Plugins, pluginsconfig.Plugin{
cfg.Apps = append(cfg.Apps, pluginsconfig.Plugin{
Path: "/path/to/plugin3",
With: map[string]string{"key": "val"},
})
// update a plugin
cfg.Plugins[1].Path = "/path/to/plugin22"
cfg.Plugins[1].With["key"] = "val"
cfg.Apps[1].Path = "/path/to/plugin22"
cfg.Apps[1].With["key"] = "val"
return cfg
},
expectedContent: `plugins:
expectedContent: `apps:
- path: /path/to/plugin1
- path: /path/to/plugin22
with:
Expand Down Expand Up @@ -338,7 +338,7 @@ func TestConfigHasPlugin(t *testing.T) {
{
name: "not found in config",
cfg: pluginsconfig.Config{
Plugins: []pluginsconfig.Plugin{
Apps: []pluginsconfig.Plugin{
{Path: "github.com/ignite/example2"},
},
},
Expand All @@ -347,7 +347,7 @@ func TestConfigHasPlugin(t *testing.T) {
{
name: "found in config",
cfg: pluginsconfig.Config{
Plugins: []pluginsconfig.Plugin{
Apps: []pluginsconfig.Plugin{
{Path: "github.com/ignite/example2"},
{Path: "github.com/ignite/example@master"},
},
Expand All @@ -357,7 +357,7 @@ func TestConfigHasPlugin(t *testing.T) {
{
name: "found in config but from a local plugin",
cfg: pluginsconfig.Config{
Plugins: []pluginsconfig.Plugin{
Apps: []pluginsconfig.Plugin{
{Path: "github.com/ignite/example2"},
{Path: path.Join(wd, "testdata", "localplugin", "example")},
},
Expand Down
10 changes: 5 additions & 5 deletions ignite/config/plugins/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

// ParseDir expects to find a plugin config file in dir. If dir is not a folder,
// an error is returned.
// The plugin config file format can be `plugins.yml` or `plugins.yaml`. If
// The plugin config file format can be `igniteapps.yml` or `igniteapps.yaml`. If
// found, the file is parsed into a Config and returned. If no file from the
// given names above are found, then an empty config is returned, w/o errors.
func ParseDir(dir string) (*Config, error) {
Expand Down Expand Up @@ -53,13 +53,13 @@ func ParseDir(dir string) (*Config, error) {
}

var (
// filenames is a list of recognized names as Ignite's plugins config file.
filenames = []string{"plugins.yml", "plugins.yaml"}
defaultFilename = filenames[0]
Filenames = []string{"igniteapps.yml", "igniteapps.yaml"}
jeronimoalbi marked this conversation as resolved.
Show resolved Hide resolved

defaultFilename = Filenames[0]
)

func locateFile(root string) (string, error) {
for _, name := range filenames {
for _, name := range Filenames {
path := filepath.Join(root, name)
_, err := os.Stat(path)
if err == nil {
Expand Down
Loading