Skip to content

Commit f2d9a5f

Browse files
author
Jerónimo Albi
authored
docs: change docs to use "apps" instead of "plugins" (#3651)
* docs: change docs to use "apps" instead of "plugins" * chore: correct plugin reference * chore: change app examples to use `app` as the type name * chore: restore apps config name references back to `plugins.yml`
1 parent be5deaf commit f2d9a5f

4 files changed

Lines changed: 118 additions & 115 deletions

File tree

docs/docs/apps/01-using-apps.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
description: Using and Developing Ignite Apps
3+
---
4+
5+
# Using Ignite Apps
6+
7+
Apps offer a way to extend the functionality of the Ignite CLI. There are two
8+
core concepts within apps: `Commands` and `Hooks`. `Commands` extend the CLI's
9+
functionality and `Hooks` extend existing CLI command functionality.
10+
11+
Apps are registered in an Ignite scaffolded blockchain project through the
12+
`plugins.yml`, or globally through `$HOME/.ignite/plugins/plugins.yml`.
13+
14+
To use an app within your project execute the following command inside the
15+
project directory:
16+
17+
```sh
18+
ignite app install github.com/project/cli-app
19+
```
20+
21+
The app will be available only when running `ignite` inside the project
22+
directory.
23+
24+
To use an app globally on the other hand, execute the following command:
25+
26+
```sh
27+
ignite app install -g github.com/project/cli-app
28+
```
29+
30+
The command will compile the app and make it immediately available to the
31+
`ignite` command lists.
32+
33+
## Listing installed apps
34+
35+
When in an ignite scaffolded blockchain you can use the command `ignite app
36+
list` to list all Ignite Apps and there statuses.
37+
38+
## Updating apps
39+
40+
When an app in a remote repository releases updates, running `ignite app
41+
update <path/to/app>` will update an specific app declared in your
42+
project's `config.yml`.
Lines changed: 75 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
11
---
2-
description: Using and Developing plugins
2+
description: Using and Developing Ignite Apps
33
---
44

5-
# Developing Plugins
5+
# Developing Ignite Apps
66

7-
It's easy to create a plugin and use it immediately in your project. First
8-
choose a directory outside your project and run :
7+
It's easy to create an app and use it immediately in your project. First
8+
choose a directory outside your project and run:
99

1010
```sh
11-
$ ignite plugin scaffold my-plugin
11+
$ ignite app scaffold my-app
1212
```
1313

14-
This will create a new directory `my-plugin` that contains the plugin's code,
15-
and will output some instructions about how to use your plugin with the
16-
`ignite` command. Indeed, a plugin path can be a local directory, which has
17-
several benefits:
14+
This will create a new directory `my-app` that contains the app's code
15+
and will output some instructions about how to use your app with the
16+
`ignite` command. An app path can be a local directory which has several
17+
benefits:
1818

19-
- you don't need to use a git repository during the development of your plugin.
20-
- the plugin is recompiled each time you run the `ignite` binary in your
21-
project, if the source files are older than the plugin binary.
19+
- You don't need to use a Git repository during the development of your app.
20+
- The app is recompiled each time you run the `ignite` binary in your
21+
project if the source files are older than the app binary.
2222

23-
Thus, the plugin development workflow is as simple as :
23+
Thus, app development workflow is as simple as:
2424

25-
1. scaffold a plugin with `ignite plugin scaffold my-plugin`
26-
2. add it to your config via `ignite plugin add -g /path/to/my-plugin`
27-
3. update plugin code
28-
4. run `ignite my-plugin` binary to compile and run the plugin.
29-
5. go back to 3.
25+
1. Scaffold an app with `ignite app scaffold my-app`
26+
2. Add it to your config via `ignite app install -g /path/to/my-app`
27+
3. Update app code
28+
4. Run `ignite my-app` binary to compile and run the app
29+
5. Go back to 3
3030

31-
Once your plugin is ready, you can publish it to a git repository, and the
32-
community can use it by calling `ignite plugin add github.com/foo/my-plugin`.
31+
Once your app is ready you can publish it to a Git repository and the
32+
community can use it by calling `ignite app install github.com/foo/my-app`.
3333

34-
Now let's detail how to update your plugin's code.
34+
Now let's detail how to update your app's code.
3535

36-
## The plugin interface
36+
## App interface
3737

38-
The `ignite` plugin system uses `github.com/hashicorp/go-plugin` under the hood,
39-
which implies to implement a predefined interface:
38+
Under the hood Ignite Apps are implemented using a plugin system based on
39+
`github.com/hashicorp/go-plugin`.
40+
41+
All apps must implement a predefined interface:
4042

4143
```go title=ignite/services/plugin/interface.go
42-
// An ignite plugin must implements the Plugin interface.
4344
type Interface interface {
44-
// Manifest declares the plugin's Command(s) and Hook(s).
45+
// Manifest declares app's Command(s) and Hook(s).
4546
Manifest() (Manifest, error)
4647

47-
// Execute will be invoked by ignite when a plugin Command is executed.
48+
// Execute will be invoked by ignite when an app Command is executed.
4849
// It is global for all commands declared in Manifest, if you have declared
4950
// multiple commands, use cmd.Path to distinguish them.
5051
Execute(cmd ExecutedCommand) error
@@ -70,66 +71,68 @@ type Interface interface {
7071
}
7172
```
7273

73-
The code scaffolded already implements this interface, you just need to update
74-
the methods' body.
75-
74+
The scaffolded code already implements this interface, you just need to update
75+
the method's body.
7676

77-
## Defining plugin's manifest
77+
## Defining app's manifest
7878

79-
Here is the `Manifest` struct :
79+
Here is the `Manifest` struct:
8080

8181
```go title=ignite/services/plugin/interface.go
8282
type Manifest struct {
8383
Name string
84+
8485
// Commands contains the commands that will be added to the list of ignite
8586
// commands. Each commands are independent, for nested commands use the
8687
// inner Commands field.
8788
Commands []Command
89+
8890
// Hooks contains the hooks that will be attached to the existing ignite
8991
// commands.
9092
Hooks []Hook
91-
// SharedHost enables sharing a single plugin server across all running instances
92-
// of a plugin. Useful if a plugin adds or extends long running commands
93+
94+
// SharedHost enables sharing a single app server across all running instances
95+
// of an app. Useful if an app adds or extends long running commands
9396
//
94-
// Example: if a plugin defines a hook on `ignite chain serve`, a plugin server is instanciated
97+
// Example: if an app defines a hook on `ignite chain serve`, a server is instanciated
9598
// when the command is run. Now if you want to interact with that instance from commands
96-
// defined in that plugin, you need to enable `SharedHost`, or else the commands will just
97-
// instantiate separate plugin servers.
99+
// defined in that app, you need to enable `SharedHost`, or else the commands will just
100+
// instantiate separate app servers.
98101
//
99-
// When enabled, all plugins of the same `Path` loaded from the same configuration will
100-
// attach it's rpc client to a an existing rpc server.
102+
// When enabled, all apps of the same `Path` loaded from the same configuration will
103+
// attach it's gRPC client to a an existing gRPC server.
101104
//
102-
// If a plugin instance has no other running plugin servers, it will create one and it will be the host.
105+
// If an app instance has no other running app servers, it will create one and it
106+
// will be the host.
103107
SharedHost bool `yaml:"shared_host"`
104108
}
105109
```
106110

107-
In your plugin's code, the `Manifest` method already returns a predefined
108-
`Manifest` struct as an example. Adapt it according to your need.
111+
In your app's code the `Manifest` method already returns a predefined
112+
`Manifest` struct as an example. You must adapt it according to your need.
109113

110-
If your plugin adds one or more new commands to `ignite`, feeds the `Commands`
111-
field.
114+
If your app adds one or more new commands to `ignite`, add them to the
115+
`Commands` field.
112116

113-
If your plugin adds features to existing commands, feeds the `Hooks` field.
117+
If your app adds features to existing commands, add them to the `Hooks` field.
114118

115-
Of course a plugin can declare `Commands` *and* `Hooks`.
119+
Of course an app can declare both, `Commands` *and* `Hooks`.
116120

117-
A plugin may also share a host process by setting `SharedHost` to `true`.
118-
`SharedHost` is desirable if a plugin hooks into, or declares long running commands.
119-
Commands executed from the same plugin context interact with the same plugin server.
121+
An app may also share a host process by setting `SharedHost` to `true`.
122+
`SharedHost` is desirable if an app hooks into, or declares long running commands.
123+
Commands executed from the same app context interact with the same app server.
120124
Allowing all executing commands to share the same server instance, giving shared execution context.
121125

122-
## Adding new command
126+
## Adding new commands
123127

124-
Plugin commands are custom commands added to the ignite cli by a registered
125-
plugin. Commands can be of any path not defined already by ignite. All plugin
126-
commands will extend of the command root `ignite`.
128+
App commands are custom commands added to Ignite CLI by an installed app.
129+
Commands can use any path not defined already by the CLI.
127130

128-
For instance, let's say your plugin adds a new `oracle` command to `ignite
129-
scaffold`, the `Manifest()` method will look like :
131+
For instance, let's say your app adds a new `oracle` command to `ignite
132+
scaffold`, then the `Manifest` method will look like :
130133

131134
```go
132-
func (p) Manifest() (plugin.Manifest, error) {
135+
func (app) Manifest() (plugin.Manifest, error) {
133136
return plugin.Manifest{
134137
Name: "oracle",
135138
Commands: []plugin.Command{
@@ -149,11 +152,11 @@ func (p) Manifest() (plugin.Manifest, error) {
149152
}
150153
```
151154

152-
To update the plugin execution, you have to change the plugin `Execute` command,
153-
for instance :
155+
To update the app execution, you have to change the `Execute` command. For
156+
example:
154157

155158
```go
156-
func (p) Execute(cmd plugin.ExecutedCommand) error {
159+
func (app) Execute(cmd plugin.ExecutedCommand) error {
157160
if len(cmd.Args) == 0 {
158161
return fmt.Errorf("oracle name missing")
159162
}
@@ -171,31 +174,32 @@ func (p) Execute(cmd plugin.ExecutedCommand) error {
171174
}
172175
```
173176

174-
Then, run `ignite scaffold oracle` to execute the plugin.
177+
Then, run `ignite scaffold oracle` to execute the app.
175178

176179
## Adding hooks
177180

178-
Plugin `Hooks` allow existing ignite commands to be extended with new
181+
App `Hooks` allow existing CLI commands to be extended with new
179182
functionality. Hooks are useful when you want to streamline functionality
180183
without needing to run custom scripts after or before a command has been run.
181-
this can streamline processes that where once error prone or forgotten all
184+
This can streamline processes that where once error prone or forgotten all
182185
together.
183186

184-
The following are hooks defined which will run on a registered `ignite` commands
187+
The following are hooks defined which will run on a registered `ignite`
188+
command:
185189

186190
| Name | Description |
187191
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
188192
| Pre | Runs before a commands main functionality is invoked in the `PreRun` scope |
189193
| Post | Runs after a commands main functionality is invoked in the `PostRun` scope |
190-
| Clean Up | Runs after a commands main functionality is invoked. if the command returns an error it will run before the error is returned to guarantee execution. |
194+
| Clean Up | Runs after a commands main functionality is invoked. If the command returns an error it will run before the error is returned to guarantee execution. |
191195

192196
*Note*: If a hook causes an error in the pre step the command will not run
193197
resulting in `post` and `clean up` not executing.
194198

195199
The following is an example of a `hook` definition.
196200

197201
```go
198-
func (p) Manifest() (plugin.Manifest, error) {
202+
func (app) Manifest() (plugin.Manifest, error) {
199203
return plugin.Manifest{
200204
Name: "oracle",
201205
Hooks: []plugin.Hook{
@@ -207,7 +211,7 @@ func (p) Manifest() (plugin.Manifest, error) {
207211
}, nil
208212
}
209213

210-
func (p) ExecuteHookPre(hook plugin.ExecutedHook) error {
214+
func (app) ExecuteHookPre(hook plugin.ExecutedHook) error {
211215
switch hook.Name {
212216
case "my-hook":
213217
fmt.Println("I'm executed before ignite chain build")
@@ -217,7 +221,7 @@ func (p) ExecuteHookPre(hook plugin.ExecutedHook) error {
217221
return nil
218222
}
219223

220-
func (p) ExecuteHookPost(hook plugin.ExecutedHook) error {
224+
func (app) ExecuteHookPost(hook plugin.ExecutedHook) error {
221225
switch hook.Name {
222226
case "my-hook":
223227
fmt.Println("I'm executed after ignite chain build (if no error)")
@@ -227,7 +231,7 @@ func (p) ExecuteHookPost(hook plugin.ExecutedHook) error {
227231
return nil
228232
}
229233

230-
func (p) ExecuteHookCleanUp(hook plugin.ExecutedHook) error {
234+
func (app) ExecuteHookCleanUp(hook plugin.ExecutedHook) error {
231235
switch hook.Name {
232236
case "my-hook":
233237
fmt.Println("I'm executed after ignite chain build (regardless errors)")
@@ -238,7 +242,7 @@ func (p) ExecuteHookCleanUp(hook plugin.ExecutedHook) error {
238242
}
239243
```
240244

241-
Above we can see a similar definition to `Command` where a hook has a `Name` and
242-
a `PlaceHookOn`. You'll notice that the `Execute*` methods map directly to each
243-
life cycle of the hook. All hooks defined within the plugin will invoke these
245+
Above we can see a similar definition to `Command` where a hook has a `Name`
246+
and a `PlaceHookOn`. You'll notice that the `Execute*` methods map directly to
247+
each life cycle of the hook. All hooks defined within the app will invoke these
244248
methods.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"label": "Plugins",
2+
"label": "Ignite Apps",
33
"position": 7,
44
"link": null
55
}

docs/docs/plugins/01-using-plugins.md

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)