diff --git a/.changeset/lazy-rice-dream.md b/.changeset/lazy-rice-dream.md new file mode 100644 index 0000000000..fe91f85b2e --- /dev/null +++ b/.changeset/lazy-rice-dream.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-gerrit': patch +--- + +Migrating to use new format for actions diff --git a/plugins/scaffolder-backend-module-gerrit/report.api.md b/plugins/scaffolder-backend-module-gerrit/report.api.md index 937df6f435..1e82303b1e 100644 --- a/plugins/scaffolder-backend-module-gerrit/report.api.md +++ b/plugins/scaffolder-backend-module-gerrit/report.api.md @@ -5,7 +5,6 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; import { Config } from '@backstage/config'; -import { JsonObject } from '@backstage/types'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; @@ -17,15 +16,19 @@ export function createPublishGerritAction(options: { { repoUrl: string; description: string; - defaultBranch?: string; - gitCommitMessage?: string; - gitAuthorName?: string; - gitAuthorEmail?: string; - sourcePath?: string; - signCommit?: boolean; + defaultBranch?: string | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + sourcePath?: string | undefined; + signCommit?: boolean | undefined; }, - JsonObject, - 'v1' + { + remoteUrl?: string | undefined; + repoContentsUrl?: string | undefined; + commitHash?: string | undefined; + }, + 'v2' >; // @public @@ -35,15 +38,18 @@ export function createPublishGerritReviewAction(options: { }): TemplateAction< { repoUrl: string; - branch?: string; - sourcePath?: string; - gitCommitMessage?: string; - gitAuthorName?: string; - gitAuthorEmail?: string; - signCommit?: boolean; + branch?: string | undefined; + sourcePath?: string | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + signCommit?: boolean | undefined; }, - JsonObject, - 'v1' + { + reviewUrl?: string | undefined; + repoContentsUrl?: string | undefined; + }, + 'v2' >; // @public diff --git a/plugins/scaffolder-backend-module-gerrit/src/actions/gerrit.ts b/plugins/scaffolder-backend-module-gerrit/src/actions/gerrit.ts index 23f28ae934..3cc3c47cd1 100644 --- a/plugins/scaffolder-backend-module-gerrit/src/actions/gerrit.ts +++ b/plugins/scaffolder-backend-module-gerrit/src/actions/gerrit.ts @@ -91,16 +91,7 @@ export function createPublishGerritAction(options: { }) { const { integrations, config } = options; - return createTemplateAction<{ - repoUrl: string; - description: string; - defaultBranch?: string; - gitCommitMessage?: string; - gitAuthorName?: string; - gitAuthorEmail?: string; - sourcePath?: string; - signCommit?: boolean; - }>({ + return createTemplateAction({ id: 'publish:gerrit', supportsDryRun: true, description: @@ -108,65 +99,70 @@ export function createPublishGerritAction(options: { examples, schema: { input: { - type: 'object', - required: ['repoUrl'], - properties: { - repoUrl: { - title: 'Repository Location', - type: 'string', - }, - description: { - title: 'Repository Description', - type: 'string', - }, - defaultBranch: { - title: 'Default Branch', - type: 'string', - description: `Sets the default branch on the repository. The default value is 'master'`, - }, - gitCommitMessage: { - title: 'Git Commit Message', - type: 'string', - description: `Sets the commit message on the repository. The default value is 'initial commit'`, - }, - gitAuthorName: { - title: 'Default Author Name', - type: 'string', - description: `Sets the default author name for the commit. The default value is 'Scaffolder'`, - }, - gitAuthorEmail: { - title: 'Default Author Email', - type: 'string', - description: `Sets the default author email for the commit.`, - }, - sourcePath: { - title: 'Source Path', - type: 'string', - description: `Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.`, - }, - signCommit: { - title: 'Sign commit', - type: 'boolean', - description: 'Sign commit with configured PGP private key', - }, - }, + repoUrl: z => + z.string({ + description: 'Repository Location', + }), + description: z => + z.string({ + description: 'Repository Description', + }), + defaultBranch: z => + z + .string({ + description: `Sets the default branch on the repository. The default value is 'master'`, + }) + .optional(), + gitCommitMessage: z => + z + .string({ + description: `Sets the commit message on the repository. The default value is 'initial commit'`, + }) + .optional(), + gitAuthorName: z => + z + .string({ + description: `Sets the default author name for the commit. The default value is 'Scaffolder'`, + }) + .optional(), + gitAuthorEmail: z => + z + .string({ + description: `Sets the default author email for the commit.`, + }) + .optional(), + sourcePath: z => + z + .string({ + description: `Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.`, + }) + .optional(), + signCommit: z => + z + .boolean({ + description: 'Sign commit with configured PGP private key', + }) + .optional(), }, output: { - type: 'object', - properties: { - remoteUrl: { - title: 'A URL to the repository with the provider', - type: 'string', - }, - repoContentsUrl: { - title: 'A URL to the root of the repository', - type: 'string', - }, - commitHash: { - title: 'The git commit hash of the initial commit', - type: 'string', - }, - }, + remoteUrl: z => + z + .string({ + description: 'A URL to the repository with the provider', + }) + .optional(), + repoContentsUrl: z => + z + .string({ + description: 'A URL to the root of the repository', + }) + .optional(), + commitHash: z => + z + .string({ + description: 'The git commit hash of the initial commit', + }) + .optional(), }, }, async handler(ctx) { diff --git a/plugins/scaffolder-backend-module-gerrit/src/actions/gerritReview.ts b/plugins/scaffolder-backend-module-gerrit/src/actions/gerritReview.ts index b4ab3afef7..5688ba8b7f 100644 --- a/plugins/scaffolder-backend-module-gerrit/src/actions/gerritReview.ts +++ b/plugins/scaffolder-backend-module-gerrit/src/actions/gerritReview.ts @@ -41,73 +41,68 @@ export function createPublishGerritReviewAction(options: { }) { const { integrations, config } = options; - return createTemplateAction<{ - repoUrl: string; - branch?: string; - sourcePath?: string; - gitCommitMessage?: string; - gitAuthorName?: string; - gitAuthorEmail?: string; - signCommit?: boolean; - }>({ + return createTemplateAction({ id: 'publish:gerrit:review', description: 'Creates a new Gerrit review.', examples, schema: { input: { - type: 'object', - required: ['repoUrl', 'gitCommitMessage'], - properties: { - repoUrl: { - title: 'Repository Location', - type: 'string', - }, - branch: { - title: 'Repository branch', - type: 'string', - description: - 'Branch of the repository the review will be created on', - }, - sourcePath: { - type: 'string', - title: 'Working Subdirectory', - description: - 'Subdirectory of working directory containing the repository', - }, - gitCommitMessage: { - title: 'Git Commit Message', - type: 'string', - description: `Sets the commit message on the repository.`, - }, - gitAuthorName: { - title: 'Default Author Name', - type: 'string', - description: `Sets the default author name for the commit. The default value is 'Scaffolder'`, - }, - gitAuthorEmail: { - title: 'Default Author Email', - type: 'string', - description: `Sets the default author email for the commit.`, - }, - signCommit: { - title: 'Sign commit', - type: 'boolean', - description: 'Sign commit with configured PGP private key', - }, - }, + repoUrl: z => + z.string({ + description: 'Repository Location', + }), + branch: z => + z + .string({ + description: + 'Branch of the repository the review will be created on', + }) + .optional(), + sourcePath: z => + z + .string({ + description: + 'Subdirectory of working directory containing the repository', + }) + .optional(), + gitCommitMessage: z => + z + .string({ + description: `Sets the commit message on the repository.`, + }) + .optional(), + gitAuthorName: z => + z + .string({ + description: `Sets the default author name for the commit. The default value is 'Scaffolder'`, + }) + .optional(), + gitAuthorEmail: z => + z + .string({ + description: `Sets the default author email for the commit.`, + }) + .optional(), + signCommit: z => + z + .boolean({ + description: 'Sign commit with configured PGP private key', + }) + .optional(), }, output: { - type: 'object', - properties: { - reviewUrl: { - title: 'A URL to the review', - type: 'string', - }, - repoContentsUrl: { - title: 'A URL to the root of the repository', - type: 'string', - }, - }, + reviewUrl: z => + z + .string({ + description: 'A URL to the review', + }) + .optional(), + repoContentsUrl: z => + z + .string({ + description: 'A URL to the root of the repository', + }) + .optional(), }, }, async handler(ctx) {