Signed-off-by: Alan Serhan <alan.serhan@fmr.com>

- Replace hardcoded cli-commands link with local one
- Add more context in 'Writing your Custom Actions' to follow up on previous docs section
This commit is contained in:
Alan Serhan
2024-06-05 14:41:21 +01:00
parent 9189c23b65
commit 22dd53f42b
@@ -28,20 +28,15 @@ $ yarn backstage-cli new
> scaffolder-module - An module exporting custom actions for @backstage/plugin-scaffolder-backend
```
You can find a [list](https://backstage.io/docs/local-dev/cli-commands/) of all commands provided by the Backstage CLI.
You can find a [list](../../local-dev/cli-commands.md) of all commands provided by the Backstage CLI.
When prompted, select the option to generate a scaffolder module. This creates a solid foundation for your custom action. Enter the name of the module you wish to create, and the CLI will generate the required files and directory structure.
## Writing your Custom Action
Your custom action can live where you choose, but simplest is to include it
alongside your `backend` package in `packages/backend`.
After running the command, the CLI will create a new directory with the name you provided. This directory will be the working directory for creating the custom action. It will contain all the necessary files and boilerplate code to get started.
Let's create a simple action that adds a new file and some contents that are
passed as `input` to the function.
In `packages/backend/src/plugins/scaffolder/actions/custom.ts` we can create a
new action.
Let's create a simple action that adds a new file and some contents that are passed as `input` to the function. Within the generated directory, locate the file at `src/actions/example/example.ts`. Feel free to rename this file along with its generated unit test. We will replace the existing placeholder code with our custom action code as follows:
```ts title="With Zod"
import { createTemplateAction } from '@backstage/plugin-scaffolder-node';