From 22dd53f42b90354218b5dfa9346db0d9a8bb60c7 Mon Sep 17 00:00:00 2001 From: Alan Serhan Date: Wed, 5 Jun 2024 14:41:21 +0100 Subject: [PATCH] Signed-off-by: Alan Serhan - Replace hardcoded cli-commands link with local one - Add more context in 'Writing your Custom Actions' to follow up on previous docs section --- .../software-templates/writing-custom-actions.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index 8dbca8b1c9..789b8a8122 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -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';