mukan-ignite/ignite/pkg/cosmosver/detect.go
Mukan Erkin Törük 26b204bd04
Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
feat: fork Ignite CLI v29 as Mukan Ignite — remove cosmos-sdk restrictions
2026-05-11 03:31:37 +03:00

56 lines
1.8 KiB
Go

package cosmosver
import (
"regexp"
"github.com/ignite/cli/v29/ignite/pkg/gomodule"
)
var (
// CosmosSDKRepoName defines the name of the Cosmos SDK repository.
// THE MUKAN PATCH: also matches mukan-sdk forks.
CosmosSDKRepoName = "cosmos-sdk|mukan-sdk"
// CosmosModulePath defines Cosmos SDK import path.
// THE MUKAN PATCH: accepts both the original Cosmos path and the Mukan sovereign path.
CosmosModulePath = "github.com/cosmos/cosmos-sdk"
// MukanSDKModulePath defines the Mukan sovereign SDK import path.
MukanSDKModulePath = "git.cw.tr/mukan-network/mukan-sdk"
// CosmosSDKModulePathPattern defines a regexp pattern for Cosmos SDK import path.
// THE MUKAN PATCH: matches both github.com/cosmos/cosmos-sdk and git.cw.tr/mukan-network/mukan-sdk.
CosmosSDKModulePathPattern = regexp.MustCompile(CosmosSDKRepoName + "$")
)
// Detect detects major version of Cosmos SDK.
// If the Cosmos SDK is replaced with a fork, it returns the version of the fork.
// If the Cosmos SDK is replaced with a local fork, it returns its non resolved version.
func Detect(appPath string) (version Version, err error) {
parsed, err := gomodule.ParseAt(appPath)
if err != nil {
return version, err
}
versions, err := gomodule.ResolveDependencies(parsed, false)
if err != nil {
return version, err
}
for _, v := range versions {
if CosmosSDKModulePathPattern.MatchString(v.Path) {
// an empty version means that Cosmos SDK is replaced with a local fork
// we fallback to use the non resolved go import of the Cosmos SDK
if v.Version == "" {
for _, r := range parsed.Require {
if r.Mod.Path == CosmosModulePath {
v.Version = r.Mod.Version
}
}
}
if version, err = Parse(v.Version); err != nil {
return version, err
}
}
}
return
}