chore: migrate to using new actions format
Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend-module-cookiecutter': patch
|
||||
---
|
||||
|
||||
Migrate using new actions format
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
```ts
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { ScmIntegrations } from '@backstage/integration';
|
||||
import { TemplateAction } from '@backstage/plugin-scaffolder-node';
|
||||
import { UrlReaderService } from '@backstage/backend-plugin-api';
|
||||
@@ -48,13 +47,15 @@ export function createFetchCookiecutterAction(options: {
|
||||
}): TemplateAction<
|
||||
{
|
||||
url: string;
|
||||
targetPath?: string;
|
||||
values: JsonObject;
|
||||
copyWithoutRender?: string[];
|
||||
extensions?: string[];
|
||||
imageName?: string;
|
||||
values: Record<string, unknown>;
|
||||
targetPath?: string | undefined;
|
||||
copyWithoutRender?: string[] | undefined;
|
||||
extensions?: string[] | undefined;
|
||||
imageName?: string | undefined;
|
||||
},
|
||||
JsonObject,
|
||||
'v1'
|
||||
{
|
||||
[x: string]: any;
|
||||
},
|
||||
'v2'
|
||||
>;
|
||||
```
|
||||
|
||||
@@ -149,65 +149,50 @@ export function createFetchCookiecutterAction(options: {
|
||||
}) {
|
||||
const { reader, containerRunner, integrations } = options;
|
||||
|
||||
return createTemplateAction<{
|
||||
url: string;
|
||||
targetPath?: string;
|
||||
values: JsonObject;
|
||||
copyWithoutRender?: string[];
|
||||
extensions?: string[];
|
||||
imageName?: string;
|
||||
}>({
|
||||
return createTemplateAction({
|
||||
id: 'fetch:cookiecutter',
|
||||
description:
|
||||
'Downloads a template from the given URL into the workspace, and runs cookiecutter on it.',
|
||||
examples,
|
||||
schema: {
|
||||
input: {
|
||||
type: 'object',
|
||||
required: ['url'],
|
||||
properties: {
|
||||
url: {
|
||||
title: 'Fetch URL',
|
||||
url: z =>
|
||||
z.string({
|
||||
description:
|
||||
'Relative path or absolute URL pointing to the directory tree to fetch',
|
||||
type: 'string',
|
||||
},
|
||||
targetPath: {
|
||||
title: 'Target Path',
|
||||
description:
|
||||
'Target path within the working directory to download the contents to.',
|
||||
type: 'string',
|
||||
},
|
||||
values: {
|
||||
title: 'Template Values',
|
||||
}),
|
||||
targetPath: z =>
|
||||
z
|
||||
.string({
|
||||
description:
|
||||
'Target path within the working directory to download the contents to.',
|
||||
})
|
||||
.optional(),
|
||||
values: z =>
|
||||
z.record(z.unknown(), {
|
||||
description: 'Values to pass on to cookiecutter for templating',
|
||||
type: 'object',
|
||||
},
|
||||
copyWithoutRender: {
|
||||
title: 'Copy Without Render',
|
||||
description:
|
||||
'Avoid rendering directories and files in the template',
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
extensions: {
|
||||
title: 'Template Extensions',
|
||||
description:
|
||||
"Jinja2 extensions to add filters, tests, globals or extend the parser. Extensions must be installed in the container or on the host where Cookiecutter executes. See the contrib directory in Backstage's repo for more information",
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
imageName: {
|
||||
title: 'Cookiecutter Docker image',
|
||||
description:
|
||||
"Specify a custom Docker image to run cookiecutter, to override the default: 'spotify/backstage-cookiecutter'. This can be used to execute cookiecutter with Template Extensions. Used only when a local cookiecutter is not found.",
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
}),
|
||||
copyWithoutRender: z =>
|
||||
z
|
||||
.array(z.string(), {
|
||||
description:
|
||||
'Avoid rendering directories and files in the template',
|
||||
})
|
||||
.optional(),
|
||||
extensions: z =>
|
||||
z
|
||||
.array(z.string(), {
|
||||
description:
|
||||
"Jinja2 extensions to add filters, tests, globals or extend the parser. Extensions must be installed in the container or on the host where Cookiecutter executes. See the contrib directory in Backstage's repo for more information",
|
||||
})
|
||||
.optional(),
|
||||
imageName: z =>
|
||||
z
|
||||
.string({
|
||||
description:
|
||||
"Specify a custom Docker image to run cookiecutter, to override the default: 'spotify/backstage-cookiecutter'. This can be used to execute cookiecutter with Template Extensions. Used only when a local cookiecutter is not found.",
|
||||
})
|
||||
.optional(),
|
||||
},
|
||||
},
|
||||
async handler(ctx) {
|
||||
|
||||
Reference in New Issue
Block a user