Merge pull request #7497 from adamdmharvey/editorial-actions

chore(docs): Editorial changes to the actions documentation
This commit is contained in:
Adam Harvey
2021-10-07 13:11:00 -04:00
committed by GitHub
2 changed files with 17 additions and 17 deletions
@@ -6,7 +6,7 @@ description: How to write your own actions
If you're wanting to extend the functionality of the Scaffolder, you can do so
by writing custom actions which can be used along side our
[built-in actions](./builtin-actions.md)
[built-in actions](./builtin-actions.md).
### Writing your Custom Action
@@ -60,7 +60,7 @@ close over the `TemplateAction`. Take a look at our
[built-in actions](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend/src/scaffolder/actions/builtin)
for reference.
We set the type generic to `{ contents: string, filename: string}` which is
We set the type generic to `{ contents: string, filename: string }` which is
there to set the type on the handler `ctx` `inputs` property so we get good type
checking. This could be generated from the next part of this guide, the `input`
schema, but it's not supported right now. Feel free to contribute 🚀 👍.
@@ -68,12 +68,12 @@ schema, but it's not supported right now. Feel free to contribute 🚀 👍.
The `createTemplateAction` takes an object which specifies the following:
- `id` - a unique ID for your custom action. We encourage you to namespace these
in someway so they wont collide with future built-in actions that we may ship
with the `scaffolder-backend` plugin.
in some way so that they won't collide with future built-in actions that we
may ship with the `scaffolder-backend` plugin.
- `schema.input` - A JSON schema for input values to your function
- `schema.output` - A JSON schema for values which are outputted from the
function using `ctx.output`
- `handler` the actual code which is run part of the action, with a context.
- `handler` - the actual code which is run part of the action, with a context
#### The context object
@@ -81,7 +81,7 @@ When the action `handler` is called, we provide you a `context` as the only
argument. It looks like the following:
- `ctx.baseUrl` - a string where the template is located
- `ctx.logger` - a winston logger for additional logging inside your action
- `ctx.logger` - a Winston logger for additional logging inside your action
- `ctx.logStream` - a stream version of the logger if needed
- `ctx.workspacePath` - a string of the working directory of the template run
- `ctx.input` - an object which should match the JSON schema provided in the
@@ -97,7 +97,7 @@ spec:
entityRef: '{{ steps.register.output.entityRef }}'
```
Let's dive in an pick apart what each of these sections do and what they are.
Let's dive in and pick apart what each of these sections do and what they are.
### `spec.parameters` - `FormStep | FormStep[]`
@@ -256,11 +256,11 @@ use `ui:widget: password` or set some properties of `ui:backstage`:
#### The Repository Picker
So in order to make working with repository providers easier, we've built a
custom picker that can be used by overriding the `ui:field` option in the
`uiSchema` for a `string` field. Instead of displaying a text input block it
will render our custom component that we've built which makes it easy to select
a repository provider, and insert a project or owner, and repository name.
In order to make working with repository providers easier, we've built a custom
picker that can be used by overriding the `ui:field` option in the `uiSchema`
for a `string` field. Instead of displaying a text input block it will render
our custom component that we've built which makes it easy to select a repository
provider, and insert a project or owner, and repository name.
You can see it in the above full example which is a separate step and it looks a
little like this:
@@ -323,9 +323,9 @@ template. These follow the same standard format:
name: '{{ parameters.name }}'
```
By default we ship some built in actions that you can take a look at
[here](./builtin-actions.md), or you can create your own custom actions by
looking at the docs [here](./writing-custom-actions.md)
By default we ship some [built in actions](./builtin-actions.md) that you can
take a look at, or you can
[create your own custom actions](./writing-custom-actions.md).
### Outputs
@@ -359,5 +359,5 @@ As you can see above in the `Outputs` section, `actions` and `steps` can also
output things. You can grab that output using `steps.$stepId.output.$property`.
You can read more about all the `inputs` and `outputs` defined in the actions in
code part of the `JSONSchema`, or you can read more about our built in ones
[here](./builtin-actions.md).
code part of the `JSONSchema`, or you can read more about our
[built in actions](./builtin-actions.md).