-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9a8a18
commit 8cb99e3
Showing
49 changed files
with
2,001 additions
and
579 deletions.
There are no files selected for viewing
This file contains 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,17 @@ | ||
version: '1.0.0' | ||
apps: | ||
explorer: | ||
description: Easy to use terminal chain explorer for testing your Ignite blockchains | ||
path: ./official/explorer | ||
hello-world: | ||
description: A simple hello world application | ||
path: ./examples/hello-world | ||
hooks: | ||
description: A simple application that demonstrates the use of hooks | ||
path: ./examples/hooks | ||
hermes: | ||
description: A wrapper around the hermes IBC relayer | ||
path: ./official/hermes | ||
marketplace: | ||
description: Explore the world of Ignite applications and more! | ||
path: ./official/marketplace |
This file contains 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,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewHelloWorld creates a new hello-world command. | ||
func NewHelloWorld() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: "hello-world", | ||
Short: "Say hello to the world of ignite!", | ||
SilenceUsage: true, | ||
SilenceErrors: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
fmt.Println("Hello, world!") | ||
return nil | ||
}, | ||
} | ||
|
||
return c | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,71 @@ | ||
package integration_test | ||
|
||
import ( | ||
"bytes" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
pluginsconfig "github.com/ignite/cli/v28/ignite/config/plugins" | ||
"github.com/ignite/cli/v28/ignite/pkg/cmdrunner/step" | ||
"github.com/ignite/cli/v28/ignite/services/plugin" | ||
envtest "github.com/ignite/cli/v28/integration" | ||
) | ||
|
||
func TestHelloWorld(t *testing.T) { | ||
var ( | ||
require = require.New(t) | ||
assert = assert.New(t) | ||
env = envtest.New(t) | ||
app = env.Scaffold("github.com/test/test") | ||
|
||
assertPlugins = func(expectedLocalPlugins, expectedGlobalPlugins []pluginsconfig.Plugin) { | ||
localCfg, err := pluginsconfig.ParseDir(app.SourcePath()) | ||
require.NoError(err) | ||
assert.ElementsMatch(expectedLocalPlugins, localCfg.Apps, "unexpected local apps") | ||
|
||
globalCfgPath, err := plugin.PluginsPath() | ||
require.NoError(err) | ||
globalCfg, err := pluginsconfig.ParseDir(globalCfgPath) | ||
require.NoError(err) | ||
assert.ElementsMatch(expectedGlobalPlugins, globalCfg.Apps, "unexpected global apps") | ||
} | ||
) | ||
|
||
dir, err := os.Getwd() | ||
require.NoError(err) | ||
pluginPath := filepath.Join(filepath.Dir(filepath.Dir(dir)), "hello-world") | ||
|
||
env.Must(env.Exec("add hello-world plugin", | ||
step.NewSteps(step.New( | ||
step.Exec(envtest.IgniteApp, "app", "install", "-g", pluginPath), | ||
step.Workdir(app.SourcePath()), | ||
)), | ||
)) | ||
|
||
// one local plugin expected | ||
assertPlugins( | ||
nil, | ||
[]pluginsconfig.Plugin{ | ||
{ | ||
Path: pluginPath, | ||
}, | ||
}, | ||
) | ||
|
||
buf := &bytes.Buffer{} | ||
env.Must(env.Exec("run hello-world", | ||
step.NewSteps(step.New( | ||
step.Exec( | ||
envtest.IgniteApp, | ||
"hello-world", | ||
), | ||
step.Workdir(app.SourcePath()), | ||
step.Stdout(buf), | ||
)), | ||
)) | ||
assert.Equal("Hello, world!\n", buf.String()) | ||
} |
This file contains 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,53 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
hplugin "github.com/hashicorp/go-plugin" | ||
|
||
"github.com/ignite/apps/examples/hello-world/cmd" | ||
"github.com/ignite/cli/v28/ignite/services/plugin" | ||
) | ||
|
||
type app struct{} | ||
|
||
func (app) Manifest(_ context.Context) (*plugin.Manifest, error) { | ||
m := &plugin.Manifest{ | ||
Name: "hello-world", | ||
} | ||
m.ImportCobraCommand(cmd.NewHelloWorld(), "ignite") | ||
return m, nil | ||
} | ||
|
||
func (app) Execute(_ context.Context, c *plugin.ExecutedCommand, _ plugin.ClientAPI) error { | ||
// Instead of a switch on c.Use, we run the root command like if | ||
// we were in a command line context. This implies to set os.Args | ||
// correctly. | ||
// Remove the first arg "ignite" from OSArgs because our hello-world | ||
// command root is "hello-world" not "ignite". | ||
os.Args = c.OsArgs[1:] | ||
return cmd.NewHelloWorld().Execute() | ||
} | ||
|
||
func (app) ExecuteHookPre(_ context.Context, _ *plugin.ExecutedHook, _ plugin.ClientAPI) error { | ||
return nil | ||
} | ||
|
||
func (app) ExecuteHookPost(_ context.Context, _ *plugin.ExecutedHook, _ plugin.ClientAPI) error { | ||
return nil | ||
} | ||
|
||
func (app) ExecuteHookCleanUp(_ context.Context, _ *plugin.ExecutedHook, _ plugin.ClientAPI) error { | ||
return nil | ||
} | ||
|
||
func main() { | ||
hplugin.Serve(&hplugin.ServeConfig{ | ||
HandshakeConfig: plugin.HandshakeConfig(), | ||
Plugins: map[string]hplugin.Plugin{ | ||
"hello-world": plugin.NewGRPC(&app{}), | ||
}, | ||
GRPCServer: hplugin.DefaultGRPCServer, | ||
}) | ||
} |
This file contains 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,19 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
*.app | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work |
This file contains 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,5 @@ | ||
version: '1.0.0' | ||
apps: | ||
hooks: | ||
description: hooks is an awesome Ignite application! | ||
path: ./ |
This file contains 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,24 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewHooks creates a new hooks command. | ||
func NewHooks() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: "hooks", | ||
Short: "This is a example Ignite App that demonstrates hooks", | ||
Long: "To use either run \"ignite scaffold chain\" or \"ignite chain serve\" and see the output.", | ||
SilenceUsage: true, | ||
SilenceErrors: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
fmt.Println(cmd.Long) | ||
return nil | ||
}, | ||
} | ||
|
||
return c | ||
} |
Oops, something went wrong.