diff --git a/.changeset/curvy-peaches-relate.md b/.changeset/curvy-peaches-relate.md new file mode 100644 index 0000000000..9fafc77abb --- /dev/null +++ b/.changeset/curvy-peaches-relate.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-azure': patch +--- + +Migrating `azure` actions to using the new `zod` schema format diff --git a/.changeset/famous-streets-stay.md b/.changeset/famous-streets-stay.md new file mode 100644 index 0000000000..d517b889c5 --- /dev/null +++ b/.changeset/famous-streets-stay.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-node': patch +--- + +Use `LoggerService` instead of `Logger`. This is a non-breaking change, as the `LoggerService` is a subset of the `Logger` interface. diff --git a/plugins/scaffolder-backend-module-azure/report.api.md b/plugins/scaffolder-backend-module-azure/report.api.md index 159bf02a00..dcd33d36e8 100644 --- a/plugins/scaffolder-backend-module-azure/report.api.md +++ b/plugins/scaffolder-backend-module-azure/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'; @@ -20,16 +19,21 @@ export function createPublishAzureAction(options: { }): TemplateAction< { repoUrl: string; - description?: string; - defaultBranch?: string; - sourcePath?: string; - token?: string; - gitCommitMessage?: string; - gitAuthorName?: string; - gitAuthorEmail?: string; - signCommit?: boolean; + description?: string | undefined; + defaultBranch?: string | undefined; + sourcePath?: string | undefined; + token?: string | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + signCommit?: boolean | undefined; }, - JsonObject, - 'v1' + { + remoteUrl?: string | undefined; + repoContentsUrl?: string | undefined; + repositoryId?: string | undefined; + commitHash?: string | undefined; + }, + 'v2' >; ``` diff --git a/plugins/scaffolder-backend-module-azure/src/actions/azure.ts b/plugins/scaffolder-backend-module-azure/src/actions/azure.ts index 8c1f5afec8..0b806fdb2d 100644 --- a/plugins/scaffolder-backend-module-azure/src/actions/azure.ts +++ b/plugins/scaffolder-backend-module-azure/src/actions/azure.ts @@ -45,92 +45,92 @@ export function createPublishAzureAction(options: { }) { const { integrations, config } = options; - return createTemplateAction<{ - repoUrl: string; - description?: string; - defaultBranch?: string; - sourcePath?: string; - token?: string; - gitCommitMessage?: string; - gitAuthorName?: string; - gitAuthorEmail?: string; - signCommit?: boolean; - }>({ + return createTemplateAction({ id: 'publish:azure', examples, description: 'Initializes a git repository of the content in the workspace, and publishes it to Azure.', 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', - description: - 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.', - type: 'string', - }, - token: { - title: 'Authentication Token', - type: 'string', - description: 'The token to use for authorization to Azure', - }, - 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', + }) + .optional(), + defaultBranch: z => + z + .string({ + description: `Sets the default branch on the repository. The default value is 'master'`, + }) + .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(), + token: z => + z + .string({ + description: 'The token to use for authorization to Azure', + }) + .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(), + 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', - }, - repositoryId: { - title: 'The Id of the created 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(), + repositoryId: z => + z + .string({ + description: 'The Id of the created repository', + }) + .optional(), + commitHash: z => + z + .string({ + description: 'The git commit hash of the initial commit', + }) + .optional(), }, }, async handler(ctx) { diff --git a/plugins/scaffolder-node/report.api.md b/plugins/scaffolder-node/report.api.md index 9a1c856573..08fc2ddb12 100644 --- a/plugins/scaffolder-node/report.api.md +++ b/plugins/scaffolder-node/report.api.md @@ -95,7 +95,7 @@ export function addFiles(options: { | { token: string; }; - logger?: Logger | undefined; + logger?: LoggerService | undefined; }): Promise; // @public (undocumented) @@ -110,7 +110,7 @@ export function cloneRepo(options: { | { token: string; }; - logger?: Logger | undefined; + logger?: LoggerService | undefined; ref?: string | undefined; depth?: number | undefined; noCheckout?: boolean | undefined; @@ -127,7 +127,7 @@ export function commitAndPushBranch(options: { | { token: string; }; - logger?: Logger | undefined; + logger?: LoggerService | undefined; commitMessage: string; gitAuthorInfo?: { name?: string; @@ -152,7 +152,7 @@ export function commitAndPushRepo(input: { | { token: string; }; - logger: Logger; + logger: LoggerService; commitMessage: string; gitAuthorInfo?: { name?: string; @@ -177,7 +177,7 @@ export function createBranch(options: { | { token: string; }; - logger?: Logger | undefined; + logger?: LoggerService | undefined; }): Promise; // @public @deprecated (undocumented) @@ -304,7 +304,7 @@ export function initRepoAndPush(input: { | { token: string; }; - logger: Logger; + logger: LoggerService; defaultBranch?: string; commitMessage?: string; gitAuthorInfo?: { diff --git a/plugins/scaffolder-node/src/actions/gitHelpers.ts b/plugins/scaffolder-node/src/actions/gitHelpers.ts index 8922975274..49650de92e 100644 --- a/plugins/scaffolder-node/src/actions/gitHelpers.ts +++ b/plugins/scaffolder-node/src/actions/gitHelpers.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { Logger } from 'winston'; import { Git } from '../scm'; +import { LoggerService } from '@backstage/backend-plugin-api'; /** * @public @@ -27,7 +27,7 @@ export async function initRepoAndPush(input: { // it has to be provided as password together with a username // which may be a fixed value defined by the provider. auth: { username: string; password: string } | { token: string }; - logger: Logger; + logger: LoggerService; defaultBranch?: string; commitMessage?: string; gitAuthorInfo?: { name?: string; email?: string }; @@ -87,7 +87,7 @@ export async function commitAndPushRepo(input: { // it has to be provided as password together with a username // which may be a fixed value defined by the provider. auth: { username: string; password: string } | { token: string }; - logger: Logger; + logger: LoggerService; commitMessage: string; gitAuthorInfo?: { name?: string; email?: string }; branch?: string; @@ -147,7 +147,7 @@ export async function cloneRepo(options: { // it has to be provided as password together with a username // which may be a fixed value defined by the provider. auth: { username: string; password: string } | { token: string }; - logger?: Logger | undefined; + logger?: LoggerService | undefined; ref?: string | undefined; depth?: number | undefined; noCheckout?: boolean | undefined; @@ -172,7 +172,7 @@ export async function createBranch(options: { // it has to be provided as password together with a username // which may be a fixed value defined by the provider. auth: { username: string; password: string } | { token: string }; - logger?: Logger | undefined; + logger?: LoggerService | undefined; }): Promise { const { dir, ref, auth, logger } = options; const git = Git.fromAuth({ @@ -193,7 +193,7 @@ export async function addFiles(options: { // it has to be provided as password together with a username // which may be a fixed value defined by the provider. auth: { username: string; password: string } | { token: string }; - logger?: Logger | undefined; + logger?: LoggerService | undefined; }): Promise { const { dir, filepath, auth, logger } = options; const git = Git.fromAuth({ @@ -213,7 +213,7 @@ export async function commitAndPushBranch(options: { // it has to be provided as password together with a username // which may be a fixed value defined by the provider. auth: { username: string; password: string } | { token: string }; - logger?: Logger | undefined; + logger?: LoggerService | undefined; commitMessage: string; gitAuthorInfo?: { name?: string; email?: string }; branch?: string;