Some checks failed
Docs Deploy / build_and_deploy (push) Has been cancelled
Generate Docs / cli (push) Has been cancelled
Generate Config Doc / cli (push) Has been cancelled
Go formatting / go-formatting (push) Has been cancelled
Check links / markdown-link-check (push) Has been cancelled
Integration / pre-test (push) Has been cancelled
Integration / test on (push) Has been cancelled
Integration / status (push) Has been cancelled
Lint / Lint Go code (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package ignitecmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
chainconfig "git.cw.tr/mukan-network/mukan-ignite/ignite/config/chain"
|
|
"git.cw.tr/mukan-network/mukan-ignite/ignite/pkg/cliui"
|
|
"git.cw.tr/mukan-network/mukan-ignite/ignite/services/doctor"
|
|
)
|
|
|
|
func NewDoctor() *cobra.Command {
|
|
c := &cobra.Command{
|
|
Use: "doctor",
|
|
Short: "Fix chain configuration",
|
|
Hidden: true,
|
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
|
session := cliui.New(
|
|
cliui.WithoutUserInteraction(getYes(cmd)),
|
|
)
|
|
defer session.End()
|
|
appPath := flagGetPath(cmd)
|
|
|
|
doc := doctor.New(doctor.CollectEvents(session.EventBus()))
|
|
|
|
cacheStorage, err := newCache(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := doc.MigrateToolsGo(appPath); err != nil {
|
|
return err
|
|
}
|
|
|
|
configPath, err := chainconfig.LocateDefault(appPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := doc.MigrateChainConfig(configPath); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := doc.MigrateBufConfig(cmd.Context(), cacheStorage, appPath, configPath); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := doc.MigratePluginsConfig(); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
},
|
|
}
|
|
|
|
flagSetPath(c)
|
|
return c
|
|
}
|