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
49 lines
923 B
Go
49 lines
923 B
Go
package chain
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"github.com/ignite/cli/v29/ignite/pkg/gomodulepath"
|
|
"github.com/ignite/cli/v29/ignite/pkg/xstrings"
|
|
)
|
|
|
|
// App keeps info about chain.
|
|
type App struct {
|
|
Name string
|
|
Path string
|
|
ImportPath string
|
|
}
|
|
|
|
// NewAppAt creates an App from the blockchain source code located at path.
|
|
func NewAppAt(path string) (App, error) {
|
|
p, appPath, err := gomodulepath.Find(path)
|
|
if err != nil {
|
|
return App{}, err
|
|
}
|
|
return App{
|
|
Path: appPath,
|
|
Name: p.Root,
|
|
ImportPath: p.RawPath,
|
|
}, nil
|
|
}
|
|
|
|
// N returns app name without dashes.
|
|
func (a App) N() string {
|
|
return xstrings.NoDash(a.Name)
|
|
}
|
|
|
|
// D returns appd name.
|
|
func (a App) D() string {
|
|
return a.Name + "d"
|
|
}
|
|
|
|
// ND returns no-dash appd name.
|
|
func (a App) ND() string {
|
|
return a.N() + "d"
|
|
}
|
|
|
|
// Root returns the root path of app.
|
|
func (a App) Root() string {
|
|
path, _ := filepath.Abs(a.Path)
|
|
return path
|
|
}
|