From 5b9d1291f73366af41cc5494a693d41f3ed07f86 Mon Sep 17 00:00:00 2001 From: Anthony Ikeda Date: Mon, 8 Nov 2021 14:21:44 -0800 Subject: [PATCH 1/6] Placed the Custom Actions pre-requisites at the top of the document instead of the middle. These **pre-requisites** are easily missed if developers are writing custom actions. Signed-off-by: Anthony Ikeda --- .../writing-custom-actions.md | 64 ++++++++++--------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index 07c4891a6c..ff43339ff0 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -8,6 +8,40 @@ 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). +--- +**NOTE** + +When adding custom actions, the actions array will **replace the built-in actions too**, so if you +want to have those as well as your new one, you'll need to do the following: + +```ts +import { createBuiltinActions } from '@backstage/plugin-scaffolder-backend'; +import { ScmIntegrations } from '@backstage/integration'; + +const integrations = ScmIntegrations.fromConfig(config); + +const builtInActions = createBuiltinActions({ + containerRunner, + integrations, + config, + catalogClient, + reader, +}); + +const actions = [...builtInActions, createNewFileAction()]; + +return await createRouter({ + containerRunner, + logger, + config, + database, + catalogClient, + reader, + actions, +}); +``` +--- + ### Writing your Custom Action Your custom action can live where you choose, but simplest is to include it @@ -126,36 +160,6 @@ return await createRouter({ }); ``` -**NOTE** - the actions array will replace the built-in actions too, so if you -want to have those as well as your new one, you'll need to do the following: - -```ts -import { createBuiltinActions } from '@backstage/plugin-scaffolder-backend'; -import { ScmIntegrations } from '@backstage/integration'; - -const integrations = ScmIntegrations.fromConfig(config); - -const builtInActions = createBuiltinActions({ - containerRunner, - integrations, - config, - catalogClient, - reader, -}); - -const actions = [...builtInActions, createNewFileAction()]; - -return await createRouter({ - containerRunner, - logger, - config, - database, - catalogClient, - reader, - actions, -}); -``` - ### List of custom action packages Here is a list of Open Source custom actions that you can add to your Backstage From 677da179d83a014573062230c54768449320cd46 Mon Sep 17 00:00:00 2001 From: Anthony Ikeda Date: Tue, 9 Nov 2021 11:07:14 -0800 Subject: [PATCH 2/6] More consistent formatting of the Note block Signed-off-by: Anthony Ikeda --- docs/features/software-templates/writing-custom-actions.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index ff43339ff0..93cd2a7db1 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -8,11 +8,9 @@ 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). ---- -**NOTE** -When adding custom actions, the actions array will **replace the built-in actions too**, so if you -want to have those as well as your new one, you'll need to do the following: +> Note: When adding custom actions, the actions array will **replace the built-in actions too**, +> so if you want to have those as well as your new one, you'll need to do the following: ```ts import { createBuiltinActions } from '@backstage/plugin-scaffolder-backend'; @@ -40,7 +38,6 @@ return await createRouter({ actions, }); ``` ---- ### Writing your Custom Action From 02ebae6ffd559a5a2ceb82fcf678f97ddf76fc98 Mon Sep 17 00:00:00 2001 From: Anthony Ikeda Date: Tue, 9 Nov 2021 11:58:58 -0800 Subject: [PATCH 3/6] Removed code block at top and altered the main registration code block to include the builtInActions registration Signed-off-by: Anthony Ikeda --- .../writing-custom-actions.md | 41 ++++++------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index 93cd2a7db1..4663b2abb6 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -10,34 +10,9 @@ by writing custom actions which can be used along side our > Note: When adding custom actions, the actions array will **replace the built-in actions too**, -> so if you want to have those as well as your new one, you'll need to do the following: +> so if you want to have those as well as your new one. +> See below to include `builtInActions` during registration of your action. -```ts -import { createBuiltinActions } from '@backstage/plugin-scaffolder-backend'; -import { ScmIntegrations } from '@backstage/integration'; - -const integrations = ScmIntegrations.fromConfig(config); - -const builtInActions = createBuiltinActions({ - containerRunner, - integrations, - config, - catalogClient, - reader, -}); - -const actions = [...builtInActions, createNewFileAction()]; - -return await createRouter({ - containerRunner, - logger, - config, - database, - catalogClient, - reader, - actions, -}); -``` ### Writing your Custom Action @@ -145,7 +120,17 @@ There's another property you can pass here, which is an array of `actions` which will set the available actions that the scaffolder has access to. ```ts -const actions = [createNewFileAction()]; +const integrations = ScmIntegrations.fromConfig(config); + +const builtInActions = createBuiltinActions({ + containerRunner, + integrations, + config, + catalogClient, + reader, +}); + +const actions = [...builtInActions, createNewFileAction()]; return await createRouter({ containerRunner, logger, From ac4eeb710259b9216c19e48ee5fb3faa7aa7c122 Mon Sep 17 00:00:00 2001 From: Anthony Ikeda Date: Tue, 9 Nov 2021 11:07:14 -0800 Subject: [PATCH 4/6] More consistent formatting of the Note block Signed-off-by: Anthony Ikeda --- .../writing-custom-actions.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index 4663b2abb6..d3dff2b4e8 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -10,9 +10,40 @@ by writing custom actions which can be used along side our > Note: When adding custom actions, the actions array will **replace the built-in actions too**, +<<<<<<< HEAD > so if you want to have those as well as your new one. > See below to include `builtInActions` during registration of your action. +======= +> so if you want to have those as well as your new one, you'll need to do the following: + +```ts +import { createBuiltinActions } from '@backstage/plugin-scaffolder-backend'; +import { ScmIntegrations } from '@backstage/integration'; + +const integrations = ScmIntegrations.fromConfig(config); + +const builtInActions = createBuiltinActions({ + containerRunner, + integrations, + config, + catalogClient, + reader, +}); + +const actions = [...builtInActions, createNewFileAction()]; + +return await createRouter({ + containerRunner, + logger, + config, + database, + catalogClient, + reader, + actions, +}); +``` +>>>>>>> a72c8bf39a (More consistent formatting of the Note block) ### Writing your Custom Action From 69f06b7db5ee87498ae2dc9bba0047418b8875b3 Mon Sep 17 00:00:00 2001 From: Anthony Ikeda Date: Tue, 9 Nov 2021 11:58:58 -0800 Subject: [PATCH 5/6] Ran Prettier and reformatted the file Signed-off-by: Anthony Ikeda --- .../writing-custom-actions.md | 39 ++----------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index d3dff2b4e8..76bf9a4d66 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -8,42 +8,9 @@ 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). - -> Note: When adding custom actions, the actions array will **replace the built-in actions too**, -<<<<<<< HEAD -> so if you want to have those as well as your new one. -> See below to include `builtInActions` during registration of your action. - -======= -> so if you want to have those as well as your new one, you'll need to do the following: - -```ts -import { createBuiltinActions } from '@backstage/plugin-scaffolder-backend'; -import { ScmIntegrations } from '@backstage/integration'; - -const integrations = ScmIntegrations.fromConfig(config); - -const builtInActions = createBuiltinActions({ - containerRunner, - integrations, - config, - catalogClient, - reader, -}); - -const actions = [...builtInActions, createNewFileAction()]; - -return await createRouter({ - containerRunner, - logger, - config, - database, - catalogClient, - reader, - actions, -}); -``` ->>>>>>> a72c8bf39a (More consistent formatting of the Note block) +> Note: When adding custom actions, the actions array will **replace the +> built-in actions too**. To ensure you can continue to include he builtin +> actions, see below to include them during registration of your action. ### Writing your Custom Action From a648d763d77ed7d35b0b4ce0fcb5e2a9056efea0 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 17 Nov 2021 20:17:08 +0100 Subject: [PATCH 6/6] chore: fixing pr comments Signed-off-by: blam --- docs/features/software-templates/writing-custom-actions.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index 76bf9a4d66..fc12d1691c 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -118,6 +118,9 @@ There's another property you can pass here, which is an array of `actions` which will set the available actions that the scaffolder has access to. ```ts +import { createBuiltinActions } from '@backstage/plugin-scaffolder-backend'; +import { ScmIntegrations } from '@backstage/integration'; + const integrations = ScmIntegrations.fromConfig(config); const builtInActions = createBuiltinActions({