diff --git a/plugins/scaffolder-backend-module-azure/api-report.md b/plugins/scaffolder-backend-module-azure/api-report.md new file mode 100644 index 0000000000..427ed2d1bf --- /dev/null +++ b/plugins/scaffolder-backend-module-azure/api-report.md @@ -0,0 +1,28 @@ +## API Report File for "@backstage/plugin-scaffolder-backend-module-azure" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { Config } from '@backstage/config'; +import { JsonObject } from '@backstage/types'; +import { ScmIntegrationRegistry } from '@backstage/integration'; +import { TemplateAction } from '@backstage/plugin-scaffolder-node'; + +// @public +export function createPublishAzureAction(options: { + integrations: ScmIntegrationRegistry; + config: Config; +}): TemplateAction< + { + repoUrl: string; + description?: string | undefined; + defaultBranch?: string | undefined; + sourcePath?: string | undefined; + token?: string | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + }, + JsonObject +>; +``` diff --git a/plugins/scaffolder-backend-module-azure/src/index.ts b/plugins/scaffolder-backend-module-azure/src/index.ts index d64ca54077..e804f1a504 100644 --- a/plugins/scaffolder-backend-module-azure/src/index.ts +++ b/plugins/scaffolder-backend-module-azure/src/index.ts @@ -15,7 +15,7 @@ */ /** - * The azure module for @backstage/plugin-scaffolder-backend. + * A module for the scaffolder backend that lets you interact with azure * * @packageDocumentation */ diff --git a/plugins/scaffolder-backend-module-bitbucket/api-report.md b/plugins/scaffolder-backend-module-bitbucket/api-report.md new file mode 100644 index 0000000000..8e58c5fe7e --- /dev/null +++ b/plugins/scaffolder-backend-module-bitbucket/api-report.md @@ -0,0 +1,82 @@ +## API Report File for "@backstage/plugin-scaffolder-backend-module-bitbucket" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { Config } from '@backstage/config'; +import { JsonObject } from '@backstage/types'; +import { ScmIntegrationRegistry } from '@backstage/integration'; +import { TemplateAction } from '@backstage/plugin-scaffolder-node'; + +// @public @deprecated +export function createPublishBitbucketAction(options: { + integrations: ScmIntegrationRegistry; + config: Config; +}): TemplateAction< + { + repoUrl: string; + description?: string | undefined; + defaultBranch?: string | undefined; + repoVisibility?: 'private' | 'public' | undefined; + sourcePath?: string | undefined; + enableLFS?: boolean | undefined; + token?: string | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + }, + JsonObject +>; + +// @public +export function createPublishBitbucketCloudAction(options: { + integrations: ScmIntegrationRegistry; + config: Config; +}): TemplateAction< + { + repoUrl: string; + description?: string | undefined; + defaultBranch?: string | undefined; + repoVisibility?: 'private' | 'public' | undefined; + sourcePath?: string | undefined; + token?: string | undefined; + }, + JsonObject +>; + +// @public +export function createPublishBitbucketServerAction(options: { + integrations: ScmIntegrationRegistry; + config: Config; +}): TemplateAction< + { + repoUrl: string; + description?: string | undefined; + defaultBranch?: string | undefined; + repoVisibility?: 'private' | 'public' | undefined; + sourcePath?: string | undefined; + enableLFS?: boolean | undefined; + token?: string | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + }, + JsonObject +>; + +// @public +export function createPublishBitbucketServerPullRequestAction(options: { + integrations: ScmIntegrationRegistry; + config: Config; +}): TemplateAction< + { + repoUrl: string; + title: string; + description?: string | undefined; + targetBranch?: string | undefined; + sourceBranch: string; + token?: string | undefined; + }, + JsonObject +>; +``` diff --git a/plugins/scaffolder-backend-module-bitbucket/src/index.ts b/plugins/scaffolder-backend-module-bitbucket/src/index.ts index 6448b82c8b..38d973efb8 100644 --- a/plugins/scaffolder-backend-module-bitbucket/src/index.ts +++ b/plugins/scaffolder-backend-module-bitbucket/src/index.ts @@ -15,7 +15,7 @@ */ /** - * The bitbucket module for @backstage/plugin-scaffolder-backend. + * A module for the scaffolder backend that lets you interact with bitbucket * * @packageDocumentation */ diff --git a/plugins/scaffolder-backend-module-gerrit/api-report.md b/plugins/scaffolder-backend-module-gerrit/api-report.md new file mode 100644 index 0000000000..309de08574 --- /dev/null +++ b/plugins/scaffolder-backend-module-gerrit/api-report.md @@ -0,0 +1,43 @@ +## API Report File for "@backstage/plugin-scaffolder-backend-module-gerrit" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { Config } from '@backstage/config'; +import { JsonObject } from '@backstage/types'; +import { ScmIntegrationRegistry } from '@backstage/integration'; +import { TemplateAction } from '@backstage/plugin-scaffolder-node'; + +// @public +export function createPublishGerritAction(options: { + integrations: ScmIntegrationRegistry; + config: Config; +}): TemplateAction< + { + repoUrl: string; + description: string; + defaultBranch?: string | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + sourcePath?: string | undefined; + }, + JsonObject +>; + +// @public +export function createPublishGerritReviewAction(options: { + integrations: ScmIntegrationRegistry; + config: Config; +}): TemplateAction< + { + repoUrl: string; + branch?: string | undefined; + sourcePath?: string | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + }, + JsonObject +>; +``` diff --git a/plugins/scaffolder-backend-module-gerrit/package.json b/plugins/scaffolder-backend-module-gerrit/package.json index f3797accb3..9502d9967d 100644 --- a/plugins/scaffolder-backend-module-gerrit/package.json +++ b/plugins/scaffolder-backend-module-gerrit/package.json @@ -23,10 +23,10 @@ "postpack": "backstage-cli package postpack" }, "dependencies": { - "@backstage/plugin-scaffolder-node": "workspace:^", + "@backstage/config": "workspace:^", "@backstage/errors": "workspace:^", "@backstage/integration": "workspace:^", - "@backstage/config": "workspace:^", + "@backstage/plugin-scaffolder-node": "workspace:^", "node-fetch": "^2.6.7", "yaml": "^2.0.0" }, diff --git a/plugins/scaffolder-backend-module-gerrit/src/index.ts b/plugins/scaffolder-backend-module-gerrit/src/index.ts index 21fdd116e7..b00c307fa5 100644 --- a/plugins/scaffolder-backend-module-gerrit/src/index.ts +++ b/plugins/scaffolder-backend-module-gerrit/src/index.ts @@ -15,7 +15,7 @@ */ /** - * The gerrit module for @backstage/plugin-scaffolder-backend. + * A module for the scaffolder backend that lets you interact with gerrit * * @packageDocumentation */ diff --git a/plugins/scaffolder-backend-module-github/api-report.md b/plugins/scaffolder-backend-module-github/api-report.md new file mode 100644 index 0000000000..bb3ec4e7c4 --- /dev/null +++ b/plugins/scaffolder-backend-module-github/api-report.md @@ -0,0 +1,365 @@ +## API Report File for "@backstage/plugin-scaffolder-backend-module-github" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { Config } from '@backstage/config'; +import { createPullRequest } from 'octokit-plugin-create-pull-request'; +import { GithubCredentialsProvider } from '@backstage/integration'; +import { JsonObject } from '@backstage/types'; +import { Octokit } from 'octokit'; +import { ScmIntegrationRegistry } from '@backstage/integration'; +import { ScmIntegrations } from '@backstage/integration'; +import { TemplateAction } from '@backstage/plugin-scaffolder-node'; + +// @public +export function createGithubActionsDispatchAction(options: { + integrations: ScmIntegrations; + githubCredentialsProvider?: GithubCredentialsProvider; +}): TemplateAction< + { + repoUrl: string; + workflowId: string; + branchOrTagName: string; + workflowInputs?: + | { + [key: string]: string; + } + | undefined; + token?: string | undefined; + }, + JsonObject +>; + +// @public +export function createGithubDeployKeyAction(options: { + integrations: ScmIntegrationRegistry; +}): TemplateAction< + { + repoUrl: string; + publicKey: string; + privateKey: string; + deployKeyName: string; + privateKeySecretName?: string | undefined; + token?: string | undefined; + }, + JsonObject +>; + +// @public +export function createGithubEnvironmentAction(options: { + integrations: ScmIntegrationRegistry; +}): TemplateAction< + { + repoUrl: string; + name: string; + deploymentBranchPolicy?: + | { + protected_branches: boolean; + custom_branch_policies: boolean; + } + | undefined; + customBranchPolicyNames?: string[] | undefined; + environmentVariables?: + | { + [key: string]: string; + } + | undefined; + secrets?: + | { + [key: string]: string; + } + | undefined; + token?: string | undefined; + }, + JsonObject +>; + +// @public +export function createGithubIssuesLabelAction(options: { + integrations: ScmIntegrationRegistry; + githubCredentialsProvider?: GithubCredentialsProvider; +}): TemplateAction< + { + repoUrl: string; + number: number; + labels: string[]; + token?: string | undefined; + }, + JsonObject +>; + +// @public +export interface CreateGithubPullRequestActionOptions { + clientFactory?: (input: { + integrations: ScmIntegrationRegistry; + githubCredentialsProvider?: GithubCredentialsProvider; + host: string; + owner: string; + repo: string; + token?: string; + }) => Promise< + Octokit & { + createPullRequest(options: createPullRequest.Options): Promise<{ + data: { + html_url: string; + number: number; + base: { + ref: string; + }; + }; + } | null>; + } + >; + githubCredentialsProvider?: GithubCredentialsProvider; + integrations: ScmIntegrationRegistry; +} + +// @public +export function createGithubRepoCreateAction(options: { + integrations: ScmIntegrationRegistry; + githubCredentialsProvider?: GithubCredentialsProvider; +}): TemplateAction< + { + repoUrl: string; + description?: string | undefined; + homepage?: string | undefined; + access?: string | undefined; + deleteBranchOnMerge?: boolean | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + allowRebaseMerge?: boolean | undefined; + allowSquashMerge?: boolean | undefined; + squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE' | undefined; + squashMergeCommitMessage?: + | 'PR_BODY' + | 'COMMIT_MESSAGES' + | 'BLANK' + | undefined; + allowMergeCommit?: boolean | undefined; + allowAutoMerge?: boolean | undefined; + requireCodeOwnerReviews?: boolean | undefined; + bypassPullRequestAllowances?: + | { + users?: string[] | undefined; + teams?: string[] | undefined; + apps?: string[] | undefined; + } + | undefined; + requiredApprovingReviewCount?: number | undefined; + restrictions?: + | { + users: string[]; + teams: string[]; + apps?: string[] | undefined; + } + | undefined; + requiredStatusCheckContexts?: string[] | undefined; + requireBranchesToBeUpToDate?: boolean | undefined; + requiredConversationResolution?: boolean | undefined; + repoVisibility?: 'internal' | 'private' | 'public' | undefined; + collaborators?: + | ( + | { + user: string; + access: string; + } + | { + team: string; + access: string; + } + | { + username: string; + access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage'; + } + )[] + | undefined; + hasProjects?: boolean | undefined; + hasWiki?: boolean | undefined; + hasIssues?: boolean | undefined; + token?: string | undefined; + topics?: string[] | undefined; + repoVariables?: + | { + [key: string]: string; + } + | undefined; + secrets?: + | { + [key: string]: string; + } + | undefined; + requireCommitSigning?: boolean | undefined; + }, + JsonObject +>; + +// @public +export function createGithubRepoPushAction(options: { + integrations: ScmIntegrationRegistry; + config: Config; + githubCredentialsProvider?: GithubCredentialsProvider; +}): TemplateAction< + { + repoUrl: string; + description?: string | undefined; + defaultBranch?: string | undefined; + protectDefaultBranch?: boolean | undefined; + protectEnforceAdmins?: boolean | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + requireCodeOwnerReviews?: boolean | undefined; + dismissStaleReviews?: boolean | undefined; + bypassPullRequestAllowances?: + | { + users?: string[]; + teams?: string[]; + apps?: string[]; + } + | undefined; + requiredApprovingReviewCount?: number | undefined; + restrictions?: + | { + users: string[]; + teams: string[]; + apps?: string[]; + } + | undefined; + requiredStatusCheckContexts?: string[] | undefined; + requireBranchesToBeUpToDate?: boolean | undefined; + requiredConversationResolution?: boolean | undefined; + sourcePath?: string | undefined; + token?: string | undefined; + requiredCommitSigning?: boolean | undefined; + }, + JsonObject +>; + +// @public +export function createGithubWebhookAction(options: { + integrations: ScmIntegrationRegistry; + defaultWebhookSecret?: string; + githubCredentialsProvider?: GithubCredentialsProvider; +}): TemplateAction< + { + repoUrl: string; + webhookUrl: string; + webhookSecret?: string | undefined; + events?: string[] | undefined; + active?: boolean | undefined; + contentType?: 'form' | 'json' | undefined; + insecureSsl?: boolean | undefined; + token?: string | undefined; + }, + JsonObject +>; + +// @public +export function createPublishGithubAction(options: { + integrations: ScmIntegrationRegistry; + config: Config; + githubCredentialsProvider?: GithubCredentialsProvider; +}): TemplateAction< + { + repoUrl: string; + description?: string | undefined; + homepage?: string | undefined; + access?: string | undefined; + defaultBranch?: string | undefined; + protectDefaultBranch?: boolean | undefined; + protectEnforceAdmins?: boolean | undefined; + deleteBranchOnMerge?: boolean | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + allowRebaseMerge?: boolean | undefined; + allowSquashMerge?: boolean | undefined; + squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE' | undefined; + squashMergeCommitMessage?: + | 'PR_BODY' + | 'COMMIT_MESSAGES' + | 'BLANK' + | undefined; + allowMergeCommit?: boolean | undefined; + allowAutoMerge?: boolean | undefined; + sourcePath?: string | undefined; + bypassPullRequestAllowances?: + | { + users?: string[]; + teams?: string[]; + apps?: string[]; + } + | undefined; + requiredApprovingReviewCount?: number | undefined; + restrictions?: + | { + users: string[]; + teams: string[]; + apps?: string[]; + } + | undefined; + requireCodeOwnerReviews?: boolean | undefined; + dismissStaleReviews?: boolean | undefined; + requiredStatusCheckContexts?: string[] | undefined; + requireBranchesToBeUpToDate?: boolean | undefined; + requiredConversationResolution?: boolean | undefined; + repoVisibility?: 'internal' | 'private' | 'public' | undefined; + collaborators?: + | ( + | { + user: string; + access: string; + } + | { + team: string; + access: string; + } + | { + username: string; + access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage'; + } + )[] + | undefined; + hasProjects?: boolean | undefined; + hasWiki?: boolean | undefined; + hasIssues?: boolean | undefined; + token?: string | undefined; + topics?: string[] | undefined; + repoVariables?: + | { + [key: string]: string; + } + | undefined; + secrets?: + | { + [key: string]: string; + } + | undefined; + requiredCommitSigning?: boolean | undefined; + }, + JsonObject +>; + +// @public +export const createPublishGithubPullRequestAction: ( + options: CreateGithubPullRequestActionOptions, +) => TemplateAction< + { + title: string; + branchName: string; + targetBranchName?: string | undefined; + description: string; + repoUrl: string; + draft?: boolean | undefined; + targetPath?: string | undefined; + sourcePath?: string | undefined; + token?: string | undefined; + reviewers?: string[] | undefined; + teamReviewers?: string[] | undefined; + commitMessage?: string | undefined; + update?: boolean | undefined; + }, + JsonObject +>; +``` diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.test.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.test.ts index 3f13f2ab67..7e5d107026 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.examples.test.ts @@ -23,10 +23,7 @@ import { ScmIntegrations, } from '@backstage/integration'; import { PassThrough } from 'stream'; -import { - OctokitWithPullRequestPluginClient, - createPublishGithubPullRequestAction, -} from './githubPullRequest'; +import { createPublishGithubPullRequestAction } from './githubPullRequest'; import yaml from 'yaml'; import { examples } from './githubPullRequest.examples'; import { createMockDirectory } from '@backstage/backend-test-utils'; @@ -103,9 +100,7 @@ describe('publish:github:pull-request examples', () => { }, }; - const clientFactory = jest.fn( - async () => fakeClient as unknown as OctokitWithPullRequestPluginClient, - ); + const clientFactory = jest.fn(async () => fakeClient as any); mockDir.setContent({ [workspacePath]: { 'file.txt': 'Hello there!' }, diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.test.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.test.ts index a1f3712a9d..23ac4bda45 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.test.ts @@ -26,10 +26,7 @@ import { } from '@backstage/plugin-scaffolder-node'; import fs from 'fs-extra'; import { Writable } from 'stream'; -import { - createPublishGithubPullRequestAction, - OctokitWithPullRequestPluginClient, -} from './githubPullRequest'; +import { createPublishGithubPullRequestAction } from './githubPullRequest'; import { createMockDirectory } from '@backstage/backend-test-utils'; // Make sure root logger is initialized ahead of FS mock @@ -78,9 +75,7 @@ describe('createPublishGithubPullRequestAction', () => { }, }, }; - const clientFactory = jest.fn( - async () => fakeClient as unknown as OctokitWithPullRequestPluginClient, - ); + const clientFactory = jest.fn(async () => fakeClient as any); const githubCredentialsProvider: GithubCredentialsProvider = { getCredentials: jest.fn(), }; diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts index 00e584226f..0763d4a474 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPullRequest.ts @@ -37,57 +37,32 @@ export type Encoding = 'utf-8' | 'base64'; class GithubResponseError extends CustomErrorBase {} -/** @public */ -export type OctokitWithPullRequestPluginClient = Octokit & { - createPullRequest(options: createPullRequest.Options): Promise<{ - data: { - html_url: string; - number: number; - base: { - ref: string; - }; - }; - } | null>; -}; - -/** - * The options passed to the client factory function. - * @public - */ -export type CreateGithubPullRequestClientFactoryInput = { - integrations: ScmIntegrationRegistry; - githubCredentialsProvider?: GithubCredentialsProvider; - host: string; - owner: string; - repo: string; - token?: string; -}; - -export const defaultClientFactory = async ({ - integrations, - githubCredentialsProvider, - owner, - repo, - host = 'github.com', - token: providedToken, -}: CreateGithubPullRequestClientFactoryInput): Promise => { - const [encodedHost, encodedOwner, encodedRepo] = [host, owner, repo].map( - encodeURIComponent, - ); - - const octokitOptions = await getOctokitOptions({ +export const defaultClientFactory: CreateGithubPullRequestActionOptions['clientFactory'] = + async ({ integrations, - credentialsProvider: githubCredentialsProvider, - repoUrl: `${encodedHost}?owner=${encodedOwner}&repo=${encodedRepo}`, + githubCredentialsProvider, + owner, + repo, + host = 'github.com', token: providedToken, - }); + }) => { + const [encodedHost, encodedOwner, encodedRepo] = [host, owner, repo].map( + encodeURIComponent, + ); - const OctokitPR = Octokit.plugin(createPullRequest); - return new OctokitPR({ - ...octokitOptions, - ...{ throttle: { enabled: false } }, - }); -}; + const octokitOptions = await getOctokitOptions({ + integrations, + credentialsProvider: githubCredentialsProvider, + repoUrl: `${encodedHost}?owner=${encodedOwner}&repo=${encodedRepo}`, + token: providedToken, + }); + + const OctokitPR = Octokit.plugin(createPullRequest); + return new OctokitPR({ + ...octokitOptions, + ...{ throttle: { enabled: false } }, + }); + }; /** * The options passed to {@link createPublishGithubPullRequestAction} method @@ -105,9 +80,26 @@ export interface CreateGithubPullRequestActionOptions { /** * A method to return the Octokit client with the Pull Request Plugin. */ - clientFactory?: ( - input: CreateGithubPullRequestClientFactoryInput, - ) => Promise; + clientFactory?: (input: { + integrations: ScmIntegrationRegistry; + githubCredentialsProvider?: GithubCredentialsProvider; + host: string; + owner: string; + repo: string; + token?: string; + }) => Promise< + Octokit & { + createPullRequest(options: createPullRequest.Options): Promise<{ + data: { + html_url: string; + number: number; + base: { + ref: string; + }; + }; + } | null>; + } + >; } type GithubPullRequest = { diff --git a/plugins/scaffolder-backend-module-github/src/actions/index.ts b/plugins/scaffolder-backend-module-github/src/actions/index.ts index 9c3927f31d..ebcda41d93 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/index.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/index.ts @@ -22,5 +22,8 @@ export { createGithubWebhookAction } from './githubWebhook'; export { createGithubDeployKeyAction } from './githubDeployKey'; export { createGithubEnvironmentAction } from './githubEnvironment'; -export { createPublishGithubPullRequestAction } from './githubPullRequest'; +export { + createPublishGithubPullRequestAction, + type CreateGithubPullRequestActionOptions, +} from './githubPullRequest'; export { createPublishGithubAction } from './github'; diff --git a/plugins/scaffolder-backend-module-github/src/index.ts b/plugins/scaffolder-backend-module-github/src/index.ts index b4d8dbcb6d..948a79d957 100644 --- a/plugins/scaffolder-backend-module-github/src/index.ts +++ b/plugins/scaffolder-backend-module-github/src/index.ts @@ -15,7 +15,7 @@ */ /** - * The github module for @backstage/plugin-scaffolder-backend. + * A module for the scaffolder backend that lets you interact with github * * @packageDocumentation */ diff --git a/plugins/scaffolder-backend-module-gitlab/api-report.md b/plugins/scaffolder-backend-module-gitlab/api-report.md index eccada5d51..debc31412a 100644 --- a/plugins/scaffolder-backend-module-gitlab/api-report.md +++ b/plugins/scaffolder-backend-module-gitlab/api-report.md @@ -3,6 +3,7 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { Config } from '@backstage/config'; import { JsonObject } from '@backstage/types'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; @@ -74,4 +75,75 @@ export const createGitlabProjectVariableAction: (options: { }, JsonObject >; + +// @public +export function createPublishGitlabAction(options: { + integrations: ScmIntegrationRegistry; + config: Config; +}): TemplateAction< + { + repoUrl: string; + defaultBranch?: string | undefined; + repoVisibility?: 'internal' | 'private' | 'public' | undefined; + sourcePath?: string | undefined; + token?: string | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; + setUserAsOwner?: boolean | undefined; + topics?: string[] | undefined; + settings?: + | { + path?: string | undefined; + auto_devops_enabled?: boolean | undefined; + ci_config_path?: string | undefined; + description?: string | undefined; + topics?: string[] | undefined; + visibility?: 'internal' | 'private' | 'public' | undefined; + } + | undefined; + branches?: + | { + name: string; + protect?: boolean | undefined; + create?: boolean | undefined; + ref?: string | undefined; + }[] + | undefined; + projectVariables?: + | { + key: string; + value: string; + description?: string | undefined; + variable_type?: string | undefined; + protected?: boolean | undefined; + masked?: boolean | undefined; + raw?: boolean | undefined; + environment_scope?: string | undefined; + }[] + | undefined; + }, + JsonObject +>; + +// @public +export const createPublishGitlabMergeRequestAction: (options: { + integrations: ScmIntegrationRegistry; +}) => TemplateAction< + { + repoUrl: string; + title: string; + description: string; + branchName: string; + targetBranchName?: string | undefined; + sourcePath?: string | undefined; + targetPath?: string | undefined; + token?: string | undefined; + commitAction?: 'update' | 'delete' | 'create' | undefined; + projectid?: string | undefined; + removeSourceBranch?: boolean | undefined; + assignee?: string | undefined; + }, + JsonObject +>; ``` diff --git a/plugins/scaffolder-backend-module-gitlab/src/index.ts b/plugins/scaffolder-backend-module-gitlab/src/index.ts index 844f753344..11d4247569 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/index.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/index.ts @@ -1,5 +1,5 @@ /* - * Copyright 2021 The Backstage Authors + * Copyright 2023 The Backstage Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,4 +19,5 @@ * * @packageDocumentation */ + export * from './actions'; diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index b92b883767..72af83aa6b 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -6,19 +6,16 @@ import { ActionContext as ActionContext_2 } from '@backstage/plugin-scaffolder-node'; import { CatalogApi } from '@backstage/catalog-client'; import { Config } from '@backstage/config'; -import { createPullRequest } from 'octokit-plugin-create-pull-request'; import { Duration } from 'luxon'; import { executeShellCommand as executeShellCommand_2 } from '@backstage/plugin-scaffolder-node'; import { ExecuteShellCommandOptions } from '@backstage/plugin-scaffolder-node'; import express from 'express'; import { fetchContents as fetchContents_2 } from '@backstage/plugin-scaffolder-node'; -import { GithubCredentialsProvider } from '@backstage/integration'; import { HumanDuration } from '@backstage/types'; import { IdentityApi } from '@backstage/plugin-auth-node'; import { JsonObject } from '@backstage/types'; import { Knex } from 'knex'; import { Logger } from 'winston'; -import { Octokit } from 'octokit'; import { PermissionEvaluator } from '@backstage/plugin-permission-common'; import { PermissionRule } from '@backstage/plugin-permission-node'; import { PermissionRuleParams } from '@backstage/plugin-permission-common'; @@ -28,7 +25,6 @@ import { RESOURCE_TYPE_SCAFFOLDER_ACTION } from '@backstage/plugin-scaffolder-co import { RESOURCE_TYPE_SCAFFOLDER_TEMPLATE } from '@backstage/plugin-scaffolder-common/alpha'; import { ScaffolderEntitiesProcessor as ScaffolderEntitiesProcessor_2 } from '@backstage/plugin-catalog-backend-module-scaffolder-entity-model'; import { Schema } from 'jsonschema'; -import { ScmIntegrationRegistry } from '@backstage/integration'; import { ScmIntegrations } from '@backstage/integration'; import { SerializedTask as SerializedTask_2 } from '@backstage/plugin-scaffolder-node'; import { SerializedTaskEvent as SerializedTaskEvent_2 } from '@backstage/plugin-scaffolder-node'; @@ -197,544 +193,6 @@ export const createFilesystemRenameAction: () => TemplateAction_2< JsonObject >; -// @public -export function createGithubActionsDispatchAction(options: { - integrations: ScmIntegrations; - githubCredentialsProvider?: GithubCredentialsProvider; -}): TemplateAction_2< - { - repoUrl: string; - workflowId: string; - branchOrTagName: string; - workflowInputs?: - | { - [key: string]: string; - } - | undefined; - token?: string | undefined; - }, - JsonObject ->; - -// @public -export function createGithubDeployKeyAction(options: { - integrations: ScmIntegrationRegistry; -}): TemplateAction_2< - { - repoUrl: string; - publicKey: string; - privateKey: string; - deployKeyName: string; - privateKeySecretName?: string | undefined; - token?: string | undefined; - }, - JsonObject ->; - -// @public -export function createGithubEnvironmentAction(options: { - integrations: ScmIntegrationRegistry; -}): TemplateAction_2< - { - repoUrl: string; - name: string; - deploymentBranchPolicy?: - | { - protected_branches: boolean; - custom_branch_policies: boolean; - } - | undefined; - customBranchPolicyNames?: string[] | undefined; - environmentVariables?: - | { - [key: string]: string; - } - | undefined; - secrets?: - | { - [key: string]: string; - } - | undefined; - token?: string | undefined; - }, - JsonObject ->; - -// @public -export function createGithubIssuesLabelAction(options: { - integrations: ScmIntegrationRegistry; - githubCredentialsProvider?: GithubCredentialsProvider; -}): TemplateAction_2< - { - repoUrl: string; - number: number; - labels: string[]; - token?: string | undefined; - }, - JsonObject ->; - -// @public -export interface CreateGithubPullRequestActionOptions { - clientFactory?: ( - input: CreateGithubPullRequestClientFactoryInput, - ) => Promise; - githubCredentialsProvider?: GithubCredentialsProvider; - integrations: ScmIntegrationRegistry; -} - -// @public -export type CreateGithubPullRequestClientFactoryInput = { - integrations: ScmIntegrationRegistry; - githubCredentialsProvider?: GithubCredentialsProvider; - host: string; - owner: string; - repo: string; - token?: string; -}; - -// @public -export function createGithubRepoCreateAction(options: { - integrations: ScmIntegrationRegistry; - githubCredentialsProvider?: GithubCredentialsProvider; -}): TemplateAction_2< - { - repoUrl: string; - description?: string | undefined; - homepage?: string | undefined; - access?: string | undefined; - deleteBranchOnMerge?: boolean | undefined; - gitAuthorName?: string | undefined; - gitAuthorEmail?: string | undefined; - allowRebaseMerge?: boolean | undefined; - allowSquashMerge?: boolean | undefined; - squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE' | undefined; - squashMergeCommitMessage?: - | 'PR_BODY' - | 'COMMIT_MESSAGES' - | 'BLANK' - | undefined; - allowMergeCommit?: boolean | undefined; - allowAutoMerge?: boolean | undefined; - requireCodeOwnerReviews?: boolean | undefined; - bypassPullRequestAllowances?: - | { - users?: string[] | undefined; - teams?: string[] | undefined; - apps?: string[] | undefined; - } - | undefined; - requiredApprovingReviewCount?: number | undefined; - restrictions?: - | { - users: string[]; - teams: string[]; - apps?: string[] | undefined; - } - | undefined; - requiredStatusCheckContexts?: string[] | undefined; - requireBranchesToBeUpToDate?: boolean | undefined; - requiredConversationResolution?: boolean | undefined; - repoVisibility?: 'internal' | 'private' | 'public' | undefined; - collaborators?: - | ( - | { - user: string; - access: string; - } - | { - team: string; - access: string; - } - | { - username: string; - access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage'; - } - )[] - | undefined; - hasProjects?: boolean | undefined; - hasWiki?: boolean | undefined; - hasIssues?: boolean | undefined; - token?: string | undefined; - topics?: string[] | undefined; - repoVariables?: - | { - [key: string]: string; - } - | undefined; - secrets?: - | { - [key: string]: string; - } - | undefined; - requireCommitSigning?: boolean | undefined; - }, - JsonObject ->; - -// @public -export function createGithubRepoPushAction(options: { - integrations: ScmIntegrationRegistry; - config: Config; - githubCredentialsProvider?: GithubCredentialsProvider; -}): TemplateAction_2< - { - repoUrl: string; - description?: string | undefined; - defaultBranch?: string | undefined; - protectDefaultBranch?: boolean | undefined; - protectEnforceAdmins?: boolean | undefined; - gitCommitMessage?: string | undefined; - gitAuthorName?: string | undefined; - gitAuthorEmail?: string | undefined; - requireCodeOwnerReviews?: boolean | undefined; - dismissStaleReviews?: boolean | undefined; - bypassPullRequestAllowances?: - | { - users?: string[]; - teams?: string[]; - apps?: string[]; - } - | undefined; - requiredApprovingReviewCount?: number | undefined; - restrictions?: - | { - users: string[]; - teams: string[]; - apps?: string[]; - } - | undefined; - requiredStatusCheckContexts?: string[] | undefined; - requireBranchesToBeUpToDate?: boolean | undefined; - requiredConversationResolution?: boolean | undefined; - sourcePath?: string | undefined; - token?: string | undefined; - requiredCommitSigning?: boolean | undefined; - }, - JsonObject ->; - -// @public -export function createGithubWebhookAction(options: { - integrations: ScmIntegrationRegistry; - defaultWebhookSecret?: string; - githubCredentialsProvider?: GithubCredentialsProvider; -}): TemplateAction_2< - { - repoUrl: string; - webhookUrl: string; - webhookSecret?: string | undefined; - events?: string[] | undefined; - active?: boolean | undefined; - contentType?: 'form' | 'json' | undefined; - insecureSsl?: boolean | undefined; - token?: string | undefined; - }, - JsonObject ->; - -// @public -export function createPublishAzureAction(options: { - integrations: ScmIntegrationRegistry; - config: Config; -}): TemplateAction_2< - { - repoUrl: string; - description?: string | undefined; - defaultBranch?: string | undefined; - sourcePath?: string | undefined; - token?: string | undefined; - gitCommitMessage?: string | undefined; - gitAuthorName?: string | undefined; - gitAuthorEmail?: string | undefined; - }, - JsonObject ->; - -// @public @deprecated -export function createPublishBitbucketAction(options: { - integrations: ScmIntegrationRegistry; - config: Config; -}): TemplateAction_2< - { - repoUrl: string; - description?: string | undefined; - defaultBranch?: string | undefined; - repoVisibility?: 'private' | 'public' | undefined; - sourcePath?: string | undefined; - enableLFS?: boolean | undefined; - token?: string | undefined; - gitCommitMessage?: string | undefined; - gitAuthorName?: string | undefined; - gitAuthorEmail?: string | undefined; - }, - JsonObject ->; - -// @public -export function createPublishBitbucketCloudAction(options: { - integrations: ScmIntegrationRegistry; - config: Config; -}): TemplateAction_2< - { - repoUrl: string; - description?: string | undefined; - defaultBranch?: string | undefined; - repoVisibility?: 'private' | 'public' | undefined; - sourcePath?: string | undefined; - token?: string | undefined; - }, - JsonObject ->; - -// @public -export function createPublishBitbucketServerAction(options: { - integrations: ScmIntegrationRegistry; - config: Config; -}): TemplateAction_2< - { - repoUrl: string; - description?: string | undefined; - defaultBranch?: string | undefined; - repoVisibility?: 'private' | 'public' | undefined; - sourcePath?: string | undefined; - enableLFS?: boolean | undefined; - token?: string | undefined; - gitCommitMessage?: string | undefined; - gitAuthorName?: string | undefined; - gitAuthorEmail?: string | undefined; - }, - JsonObject ->; - -// @public -export function createPublishBitbucketServerPullRequestAction(options: { - integrations: ScmIntegrationRegistry; - config: Config; -}): TemplateAction_2< - { - repoUrl: string; - title: string; - description?: string | undefined; - targetBranch?: string | undefined; - sourceBranch: string; - token?: string | undefined; - }, - JsonObject ->; - -// @public -export function createPublishGerritAction(options: { - integrations: ScmIntegrationRegistry; - config: Config; -}): TemplateAction_2< - { - repoUrl: string; - description: string; - defaultBranch?: string | undefined; - gitCommitMessage?: string | undefined; - gitAuthorName?: string | undefined; - gitAuthorEmail?: string | undefined; - sourcePath?: string | undefined; - }, - JsonObject ->; - -// @public -export function createPublishGerritReviewAction(options: { - integrations: ScmIntegrationRegistry; - config: Config; -}): TemplateAction_2< - { - repoUrl: string; - branch?: string | undefined; - sourcePath?: string | undefined; - gitCommitMessage?: string | undefined; - gitAuthorName?: string | undefined; - gitAuthorEmail?: string | undefined; - }, - JsonObject ->; - -// @public -export function createPublishGithubAction(options: { - integrations: ScmIntegrationRegistry; - config: Config; - githubCredentialsProvider?: GithubCredentialsProvider; -}): TemplateAction_2< - { - repoUrl: string; - description?: string | undefined; - homepage?: string | undefined; - access?: string | undefined; - defaultBranch?: string | undefined; - protectDefaultBranch?: boolean | undefined; - protectEnforceAdmins?: boolean | undefined; - deleteBranchOnMerge?: boolean | undefined; - gitCommitMessage?: string | undefined; - gitAuthorName?: string | undefined; - gitAuthorEmail?: string | undefined; - allowRebaseMerge?: boolean | undefined; - allowSquashMerge?: boolean | undefined; - squashMergeCommitTitle?: 'PR_TITLE' | 'COMMIT_OR_PR_TITLE' | undefined; - squashMergeCommitMessage?: - | 'PR_BODY' - | 'COMMIT_MESSAGES' - | 'BLANK' - | undefined; - allowMergeCommit?: boolean | undefined; - allowAutoMerge?: boolean | undefined; - sourcePath?: string | undefined; - bypassPullRequestAllowances?: - | { - users?: string[]; - teams?: string[]; - apps?: string[]; - } - | undefined; - requiredApprovingReviewCount?: number | undefined; - restrictions?: - | { - users: string[]; - teams: string[]; - apps?: string[]; - } - | undefined; - requireCodeOwnerReviews?: boolean | undefined; - dismissStaleReviews?: boolean | undefined; - requiredStatusCheckContexts?: string[] | undefined; - requireBranchesToBeUpToDate?: boolean | undefined; - requiredConversationResolution?: boolean | undefined; - repoVisibility?: 'internal' | 'private' | 'public' | undefined; - collaborators?: - | ( - | { - user: string; - access: string; - } - | { - team: string; - access: string; - } - | { - username: string; - access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage'; - } - )[] - | undefined; - hasProjects?: boolean | undefined; - hasWiki?: boolean | undefined; - hasIssues?: boolean | undefined; - token?: string | undefined; - topics?: string[] | undefined; - repoVariables?: - | { - [key: string]: string; - } - | undefined; - secrets?: - | { - [key: string]: string; - } - | undefined; - requiredCommitSigning?: boolean | undefined; - }, - JsonObject ->; - -// @public -export const createPublishGithubPullRequestAction: ( - options: CreateGithubPullRequestActionOptions, -) => TemplateAction_2< - { - title: string; - branchName: string; - targetBranchName?: string | undefined; - description: string; - repoUrl: string; - draft?: boolean | undefined; - targetPath?: string | undefined; - sourcePath?: string | undefined; - token?: string | undefined; - reviewers?: string[] | undefined; - teamReviewers?: string[] | undefined; - commitMessage?: string | undefined; - update?: boolean | undefined; - }, - JsonObject ->; - -// @public -export function createPublishGitlabAction(options: { - integrations: ScmIntegrationRegistry; - config: Config; -}): TemplateAction_2< - { - repoUrl: string; - defaultBranch?: string | undefined; - repoVisibility?: 'internal' | 'private' | 'public' | undefined; - sourcePath?: string | undefined; - token?: string | undefined; - gitCommitMessage?: string | undefined; - gitAuthorName?: string | undefined; - gitAuthorEmail?: string | undefined; - setUserAsOwner?: boolean | undefined; - topics?: string[] | undefined; - settings?: - | { - path?: string | undefined; - auto_devops_enabled?: boolean | undefined; - ci_config_path?: string | undefined; - description?: string | undefined; - topics?: string[] | undefined; - visibility?: 'internal' | 'private' | 'public' | undefined; - } - | undefined; - branches?: - | { - name: string; - protect?: boolean | undefined; - create?: boolean | undefined; - ref?: string | undefined; - }[] - | undefined; - projectVariables?: - | { - key: string; - value: string; - description?: string | undefined; - variable_type?: string | undefined; - protected?: boolean | undefined; - masked?: boolean | undefined; - raw?: boolean | undefined; - environment_scope?: string | undefined; - }[] - | undefined; - }, - JsonObject ->; - -// @public -export const createPublishGitlabMergeRequestAction: (options: { - integrations: ScmIntegrationRegistry; -}) => TemplateAction_2< - { - repoUrl: string; - title: string; - description: string; - branchName: string; - targetBranchName?: string | undefined; - sourcePath?: string | undefined; - targetPath?: string | undefined; - token?: string | undefined; - commitAction?: 'update' | 'delete' | 'create' | undefined; - projectid?: string | undefined; - removeSourceBranch?: boolean | undefined; - assignee?: string | undefined; - }, - JsonObject ->; - // @public export function createRouter(options: RouterOptions): Promise; @@ -858,19 +316,6 @@ export const executeShellCommand: typeof executeShellCommand_2; // @public @deprecated export const fetchContents: typeof fetchContents_2; -// @public (undocumented) -export type OctokitWithPullRequestPluginClient = Octokit & { - createPullRequest(options: createPullRequest.Options): Promise<{ - data: { - html_url: string; - number: number; - base: { - ref: string; - }; - }; - } | null>; -}; - // @public export interface RouterOptions { // (undocumented) diff --git a/plugins/scaffolder-node/api-report.md b/plugins/scaffolder-node/api-report.md index 08caf36812..ca1b9e8b4e 100644 --- a/plugins/scaffolder-node/api-report.md +++ b/plugins/scaffolder-node/api-report.md @@ -10,6 +10,7 @@ import { JsonValue } from '@backstage/types'; import { Logger } from 'winston'; import { Observable } from '@backstage/types'; import { Schema } from 'jsonschema'; +import { ScmIntegrationRegistry } from '@backstage/integration'; import { ScmIntegrations } from '@backstage/integration'; import { SpawnOptionsWithoutStdio } from 'child_process'; import { TaskSpec } from '@backstage/plugin-scaffolder-common'; @@ -44,6 +45,37 @@ export type ActionContext< each?: JsonObject; }; +// @public (undocumented) +export function commitAndPushRepo({ + dir, + auth, + logger, + commitMessage, + gitAuthorInfo, + branch, + remoteRef, +}: { + dir: string; + auth: + | { + username: string; + password: string; + } + | { + token: string; + }; + logger: Logger; + commitMessage: string; + gitAuthorInfo?: { + name?: string; + email?: string; + }; + branch?: string; + remoteRef?: string; +}): Promise<{ + commitHash: string; +}>; + // @public export const createTemplateAction: < TInputParams extends JsonObject = JsonObject, @@ -73,6 +105,12 @@ export const createTemplateAction: < >, ) => TemplateAction; +// @public +export function deserializeDirectoryContents( + targetPath: string, + files: SerializedFile[], +): Promise; + // @public export function executeShellCommand( options: ExecuteShellCommandOptions, @@ -104,6 +142,77 @@ export function fetchFile(options: { outputPath: string; }): Promise; +// @public (undocumented) +export const getRepoSourceDirectory: ( + workspacePath: string, + sourcePath: string | undefined, +) => string; + +// @public (undocumented) +export function initRepoAndPush({ + dir, + remoteUrl, + auth, + logger, + defaultBranch, + commitMessage, + gitAuthorInfo, +}: { + dir: string; + remoteUrl: string; + auth: + | { + username: string; + password: string; + } + | { + token: string; + }; + logger: Logger; + defaultBranch?: string; + commitMessage?: string; + gitAuthorInfo?: { + name?: string; + email?: string; + }; +}): Promise<{ + commitHash: string; +}>; + +// @public (undocumented) +export const parseRepoUrl: ( + repoUrl: string, + integrations: ScmIntegrationRegistry, +) => { + repo: string; + host: string; + owner?: string | undefined; + organization?: string | undefined; + workspace?: string | undefined; + project?: string | undefined; +}; + +// @public (undocumented) +export interface SerializedFile { + // (undocumented) + content: Buffer; + // (undocumented) + executable?: boolean; + // (undocumented) + path: string; + // (undocumented) + symlink?: boolean; +} + +// @public (undocumented) +export function serializeDirectoryContents( + sourcePath: string, + options?: { + gitignore?: boolean; + globPatterns?: string[]; + }, +): Promise; + // @public export type SerializedTask = { id: string; diff --git a/plugins/scaffolder-node/src/actions/repoHelpers.ts b/plugins/scaffolder-node/src/actions/gitHelpers.ts similarity index 98% rename from plugins/scaffolder-node/src/actions/repoHelpers.ts rename to plugins/scaffolder-node/src/actions/gitHelpers.ts index a814ca38ed..770440dba3 100644 --- a/plugins/scaffolder-node/src/actions/repoHelpers.ts +++ b/plugins/scaffolder-node/src/actions/gitHelpers.ts @@ -17,6 +17,9 @@ import { Git } from '@backstage/backend-common'; import { Logger } from 'winston'; +/** + * @public + */ export async function initRepoAndPush({ dir, remoteUrl, @@ -75,6 +78,9 @@ export async function initRepoAndPush({ return { commitHash }; } +/** + * @public + */ export async function commitAndPushRepo({ dir, auth, diff --git a/plugins/scaffolder-node/src/actions/index.ts b/plugins/scaffolder-node/src/actions/index.ts index 27046bebaf..74a0bb61f9 100644 --- a/plugins/scaffolder-node/src/actions/index.ts +++ b/plugins/scaffolder-node/src/actions/index.ts @@ -25,5 +25,5 @@ export { } from './executeShellCommand'; export { fetchContents, fetchFile } from './fetch'; export { type ActionContext, type TemplateAction } from './types'; -export { initRepoAndPush, commitAndPushRepo } from './repoHelpers'; +export { initRepoAndPush, commitAndPushRepo } from './gitHelpers'; export { parseRepoUrl, getRepoSourceDirectory } from './util'; diff --git a/plugins/scaffolder-node/src/actions/util.ts b/plugins/scaffolder-node/src/actions/util.ts index cdd8512e63..327cfa9c2f 100644 --- a/plugins/scaffolder-node/src/actions/util.ts +++ b/plugins/scaffolder-node/src/actions/util.ts @@ -19,6 +19,9 @@ import { isChildPath } from '@backstage/backend-common'; import { join as joinPath, normalize as normalizePath } from 'path'; import { ScmIntegrationRegistry } from '@backstage/integration'; +/** + * @public + */ export const getRepoSourceDirectory = ( workspacePath: string, sourcePath: string | undefined, @@ -37,6 +40,9 @@ export const getRepoSourceDirectory = ( return workspacePath; }; +/** + * @public + */ export const parseRepoUrl = ( repoUrl: string, integrations: ScmIntegrationRegistry, diff --git a/plugins/scaffolder-node/src/files/deserializeDirectoryContents.ts b/plugins/scaffolder-node/src/files/deserializeDirectoryContents.ts index cb567eed9d..bdcecd99f1 100644 --- a/plugins/scaffolder-node/src/files/deserializeDirectoryContents.ts +++ b/plugins/scaffolder-node/src/files/deserializeDirectoryContents.ts @@ -25,7 +25,7 @@ import { SerializedFile } from './types'; * This method uses `resolveSafeChildPath` to make sure that files are * not written outside of the target directory. * - * @internal + * @public */ export async function deserializeDirectoryContents( targetPath: string, diff --git a/plugins/scaffolder-node/src/files/serializeDirectoryContents.ts b/plugins/scaffolder-node/src/files/serializeDirectoryContents.ts index 1197db000a..7e52f6323b 100644 --- a/plugins/scaffolder-node/src/files/serializeDirectoryContents.ts +++ b/plugins/scaffolder-node/src/files/serializeDirectoryContents.ts @@ -41,6 +41,9 @@ async function asyncFilter( return array.filter((_value, index) => filterMap[index]); } +/** + * @public + */ export async function serializeDirectoryContents( sourcePath: string, options?: { diff --git a/plugins/scaffolder-node/src/files/types.ts b/plugins/scaffolder-node/src/files/types.ts index d3a1eaa008..cd471a7881 100644 --- a/plugins/scaffolder-node/src/files/types.ts +++ b/plugins/scaffolder-node/src/files/types.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +/** + * @public + */ export interface SerializedFile { path: string; content: Buffer; diff --git a/plugins/scaffolder-react/src/components/types.ts b/plugins/scaffolder-react/src/components/types.ts index e9ec3bf711..597998bac4 100644 --- a/plugins/scaffolder-react/src/components/types.ts +++ b/plugins/scaffolder-react/src/components/types.ts @@ -23,7 +23,6 @@ import { JsonObject } from '@backstage/types'; export type TemplateGroupFilter = { title?: React.ReactNode; filter: (entity: TemplateEntityV1beta3) => boolean; - sort?: (a: TemplateEntityV1beta3, b: TemplateEntityV1beta3) => number; }; /**