From 9189c23b65cb44ceb9a32d452d05a8c67bd56922 Mon Sep 17 00:00:00 2001 From: Alan Serhan Date: Fri, 17 May 2024 16:52:39 +0100 Subject: [PATCH 1/4] From: Alan Serhan Date: Fri, 17 May 2024 16:56:00 IST Subject: [Feature] Update Backstage docs to include information how to leverage backstage-cli Signed-off-by: Alan Serhan --- .../writing-custom-actions.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index 92ff092948..8dbca8b1c9 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -13,6 +13,25 @@ by writing custom actions which can be used alongside our > If you want to continue using the builtin actions, include them in the actions > array when registering your custom actions, as seen below. +## Streamlining Custom Action Creation with Backstage CLI + +The creation of custom actions in Backstage has never been easier thanks to the Backstage CLI. This tool streamlines the setup process, allowing you to focus on your actions' unique functionality. + +Start by using the `yarn backstage-cli new` command to generate a scaffolder module. This command sets up the necessary boilerplate code, providing a smooth start: + +``` +$ yarn backstage-cli new +? What do you want to create? + plugin-common - A new isomorphic common plugin package + plugin-node - A new Node.js library plugin package + plugin-react - A new web library plugin package +> 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. + +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 From 22dd53f42b90354218b5dfa9346db0d9a8bb60c7 Mon Sep 17 00:00:00 2001 From: Alan Serhan Date: Wed, 5 Jun 2024 14:41:21 +0100 Subject: [PATCH 2/4] 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'; From 00e77ed3226740f95a4948e1903c6cd78f82381c Mon Sep 17 00:00:00 2001 From: Alan Serhan Date: Thu, 6 Jun 2024 17:34:13 +0100 Subject: [PATCH 3/4] Signed-off-by: Alan Serhan - Fix broken link to cli --- docs/features/software-templates/writing-custom-actions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index d937d9ea54..a24cf428fa 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -32,7 +32,7 @@ $ yarn backstage-cli new > scaffolder-module - An module exporting custom actions for @backstage/plugin-scaffolder-backend ``` -You can find a [list](../../local-dev/cli-commands.md) of all commands provided by the Backstage CLI. +You can find a [list](../../tooling/cli/03-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. From 599f1c98c6b65b9b60d85784a57098e43ab3745d Mon Sep 17 00:00:00 2001 From: The Serhan Date: Mon, 10 Jun 2024 14:08:11 +0100 Subject: [PATCH 4/4] Update docs/features/software-templates/writing-custom-actions.md Co-authored-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com> Signed-off-by: The Serhan --- docs/features/software-templates/writing-custom-actions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index a24cf428fa..71e4e75b40 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -38,7 +38,7 @@ When prompted, select the option to generate a scaffolder module. This creates a ## Writing your Custom Action -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. +After running the command, the CLI will create a new directory with your new scaffolder module. 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. 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: