From 6ce4a13bf473649d5c981a6c9d292666de610600 Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Sun, 8 Feb 2026 12:39:13 -0600 Subject: [PATCH] docs - Writing Custom Actions Corrections Signed-off-by: Andre Wanlin --- .changeset/famous-phones-chew.md | 5 ++ .../writing-custom-actions.md | 53 ++++--------------- .../scaffolder-backend-module/src/module.ts | 2 +- 3 files changed, 17 insertions(+), 43 deletions(-) create mode 100644 .changeset/famous-phones-chew.md diff --git a/.changeset/famous-phones-chew.md b/.changeset/famous-phones-chew.md new file mode 100644 index 0000000000..29c9056743 --- /dev/null +++ b/.changeset/famous-phones-chew.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Removed `/alpha` from `scaffolderActionsExtensionPoint` import diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index 7e0ee1c5a9..f5ed9e4854 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -28,13 +28,17 @@ boilerplate code, providing a smooth start: ```sh $ 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 + web-library - A library package, exporting shared functionality for web environments + node-library - A library package, exporting shared functionality for Node.js environments + catalog-provider-module - An Entity Provider module for the Software Catalog +> scaffolder-backend-module - A module exporting custom actions for @backstage/plugin-scaffolder-backend + frontend-plugin - A new frontend plugin + backend-plugin - A new backend plugin + backend-plugin-module - A new backend module that extends an existing backend plugin +(Move up and down to reveal more choices) ``` -When prompted, select the option to generate a scaffolder module. This creates a solid foundation for your custom +When prompted, select the option to generate a `scaffolder-backend-module` using the down arrow key. 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. @@ -205,47 +209,12 @@ argument. It looks like the following: - `ctx.metadata` - an object containing a `name` field, indicating the template name. More metadata fields may be added later. -## Registering Custom Actions - -To register your new custom action in the Backend System, you will need to create a backend module. Here is a very -simplified example of how to do that: - -```ts title="packages/backend/src/index.ts" -/* highlight-add-start */ -import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha'; -import { createBackendModule } from '@backstage/backend-plugin-api'; -/* highlight-add-end */ - -/* highlight-add-start */ -const scaffolderModuleCustomExtensions = createBackendModule({ - pluginId: 'scaffolder', // name of the plugin that the module is targeting - moduleId: 'custom-extensions', - register(env) { - env.registerInit({ - deps: { - scaffolder: scaffolderActionsExtensionPoint, - // ... and other dependencies as needed - }, - async init({ scaffolder /* ..., other dependencies */ }) { - // Here you have the opportunity to interact with the extension - // point before the plugin itself gets instantiated - scaffolder.addActions(createNewFileAction()); // just an example - }, - }); - }, -}); -/* highlight-add-end */ - -const backend = createBackend(); -backend.add(import('@backstage/plugin-scaffolder-backend')); -/* highlight-add-next-line */ -backend.add(scaffolderModuleCustomExtensions); -``` +### Using Core Services in Custom Actions If your custom action requires core services such as `config` or `cache` they can be imported in the dependencies and passed to the custom action function. -```ts title="packages/backend/src/index.ts" +```ts title="module.ts" import { coreServices, createBackendModule, diff --git a/packages/cli/templates/scaffolder-backend-module/src/module.ts b/packages/cli/templates/scaffolder-backend-module/src/module.ts index 56ec38ac33..214926ff35 100644 --- a/packages/cli/templates/scaffolder-backend-module/src/module.ts +++ b/packages/cli/templates/scaffolder-backend-module/src/module.ts @@ -1,5 +1,5 @@ import { createBackendModule } from "@backstage/backend-plugin-api"; -import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha'; +import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node'; import { createExampleAction } from "./actions/example"; /**