Merge branch 'backstage:master' into jjung/fix-techdocs-extensions-docs
This commit is contained in:
@@ -527,6 +527,8 @@ spec:
|
||||
system: artist-engagement-portal
|
||||
dependsOn:
|
||||
- resource:default/artists-db
|
||||
dependencyOf:
|
||||
- component:default/artist-web-lookup
|
||||
providesApis:
|
||||
- artist-api
|
||||
```
|
||||
@@ -636,6 +638,17 @@ field is optional.
|
||||
| [`Component`](#kind-component) | Same as this entity, typically `default` | [`dependsOn`, and reverse `dependencyOf`](well-known-relations.md#dependson-and-dependencyof) |
|
||||
| [`Resource`](#kind-resource) | Same as this entity, typically `default` | [`dependsOn`, and reverse `dependencyOf`](well-known-relations.md#dependson-and-dependencyof) |
|
||||
|
||||
### `spec.dependencyOf` [optional]
|
||||
|
||||
An array of [entity references](references.md#string-references) to the
|
||||
components and resources that the component is a dependency of, e.g. `artist-web-lookup`.
|
||||
This field is optional.
|
||||
|
||||
| [`kind`](#apiversion-and-kind-required) | Default [`namespace`](#namespace-optional) | Generated [relation](well-known-relations.md) type |
|
||||
| --------------------------------------- | ------------------------------------------ | --------------------------------------------------------------------------------------------- |
|
||||
| [`Component`](#kind-component) | Same as this entity, typically `default` | [`dependencyOf`, and reverse `dependsOn`](well-known-relations.md#dependson-and-dependencyof) |
|
||||
| [`Resource`](#kind-resource) | Same as this entity, typically `default` | [`dependencyOf`, and reverse `dependsOn`](well-known-relations.md#dependson-and-dependencyof) |
|
||||
|
||||
## Kind: Template
|
||||
|
||||
The following describes the following entity kind:
|
||||
|
||||
@@ -43,6 +43,7 @@ After running the command, the CLI will create a new directory with your new sca
|
||||
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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';
|
||||
import { createTemplateAction } from '@backstage/plugin-scaffolder-node';
|
||||
import fs from 'fs-extra';
|
||||
import { z } from 'zod';
|
||||
@@ -62,7 +63,7 @@ export const createNewFileAction = () => {
|
||||
|
||||
async handler(ctx) {
|
||||
await fs.outputFile(
|
||||
`${ctx.workspacePath}/${ctx.input.filename}`,
|
||||
resolveSafeChildPath(ctx.workspacePath, ctx.input.filename),
|
||||
ctx.input.contents,
|
||||
);
|
||||
},
|
||||
@@ -90,6 +91,7 @@ The `createTemplateAction` takes an object which specifies the following:
|
||||
You can also choose to define your custom action using JSON schema instead of `zod`:
|
||||
|
||||
```ts title="With JSON Schema"
|
||||
import { resolveSafeChildPath } from '@backstage/backend-plugin-api';
|
||||
import { createTemplateAction } from '@backstage/plugin-scaffolder-node';
|
||||
import { writeFile } from 'fs';
|
||||
|
||||
@@ -118,7 +120,7 @@ export const createNewFileAction = () => {
|
||||
async handler(ctx) {
|
||||
const { signal } = ctx;
|
||||
await writeFile(
|
||||
`${ctx.workspacePath}/${ctx.input.filename}`,
|
||||
resolveSafeChildPath(ctx.workspacePath, ctx.input.filename),
|
||||
ctx.input.contents,
|
||||
{ signal },
|
||||
_ => {},
|
||||
|
||||
Reference in New Issue
Block a user