@backstage/plugin-scaffolder-backend-module-gitlab 0.9.3-next.2 → 0.9.4-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-gitlab
2
2
 
3
+ ## 0.9.4-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - df2bfab: The `description` property in `publish:gitlab:merge-request` has been made optional again to comply with the GitLab API.
8
+ - Updated dependencies
9
+ - @backstage/plugin-scaffolder-node@0.11.0-next.0
10
+ - @backstage/backend-plugin-api@1.4.2-next.0
11
+ - @backstage/config@1.3.3
12
+ - @backstage/errors@1.2.7
13
+ - @backstage/integration@1.17.1
14
+
15
+ ## 0.9.3
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+ - @backstage/config@1.3.3
21
+ - @backstage/plugin-scaffolder-node@0.10.0
22
+ - @backstage/integration@1.17.1
23
+ - @backstage/backend-plugin-api@1.4.1
24
+
3
25
  ## 0.9.3-next.2
4
26
 
5
27
  ### Patch Changes
@@ -79,7 +79,7 @@ const createPublishGitlabMergeRequestAction = (options) => {
79
79
  input: {
80
80
  repoUrl: (z) => z.string().describe(`Accepts the format \`gitlab.com?repo=project_name&owner=group_name\` where \`project_name\` is the repository name and \`group_name\` is a group or username`),
81
81
  title: (z) => z.string().describe("The name for the merge request"),
82
- description: (z) => z.string().describe("The description of the merge request"),
82
+ description: (z) => z.string().optional().describe("The description of the merge request"),
83
83
  branchName: (z) => z.string().describe("The source branch name of the merge request"),
84
84
  targetBranchName: (z) => z.string().optional().describe(
85
85
  "The target branch name of the merge request (defaults to _default branch of repository_)"
@@ -1 +1 @@
1
- {"version":3,"file":"gitlabMergeRequest.cjs.js","sources":["../../src/actions/gitlabMergeRequest.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createTemplateAction,\n parseRepoUrl,\n SerializedFile,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport {\n Camelize,\n CommitAction,\n ExpandedMergeRequestSchema,\n Gitlab,\n RepositoryTreeSchema,\n SimpleUserSchema,\n} from '@gitbeaker/rest';\nimport path from 'path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport {\n LoggerService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { createGitlabApi, getErrorMessage } from './helpers';\nimport { examples } from './gitlabMergeRequest.examples';\nimport { createHash } from 'crypto';\n\nfunction computeSha256(file: SerializedFile): string {\n const hash = createHash('sha256');\n hash.update(file.content);\n return hash.digest('hex');\n}\n\nasync function getFileAction(\n fileInfo: { file: SerializedFile; targetPath?: string },\n target: { repoID: string; branch: string },\n api: InstanceType<typeof Gitlab>,\n logger: LoggerService,\n remoteFiles: RepositoryTreeSchema[],\n defaultCommitAction:\n | 'create'\n | 'delete'\n | 'update'\n | 'skip'\n | 'auto' = 'auto',\n): Promise<'create' | 'delete' | 'update' | 'skip'> {\n if (defaultCommitAction === 'auto') {\n const filePath = path.join(fileInfo.targetPath ?? '', fileInfo.file.path);\n\n if (remoteFiles?.some(remoteFile => remoteFile.path === filePath)) {\n try {\n const targetFile = await api.RepositoryFiles.show(\n target.repoID,\n filePath,\n target.branch,\n );\n if (computeSha256(fileInfo.file) === targetFile.content_sha256) {\n return 'skip';\n }\n } catch (error) {\n logger.warn(\n `Unable to retrieve detailed information for remote file ${filePath}`,\n );\n }\n return 'update';\n }\n return 'create';\n }\n return defaultCommitAction;\n}\n\nasync function getReviewersFromApprovalRules(\n api: InstanceType<typeof Gitlab>,\n mergerequestIId: number,\n repoID: string,\n ctx: any,\n): Promise<number[]> {\n try {\n // Because we don't know the code owners before the MR is created, we can't check the approval rules beforehand.\n // Getting the approval rules beforehand is very difficult, especially, because of the inheritance rules for groups.\n // Code owners take a moment to be processed and added to the approval rules after the MR is created.\n\n let mergeRequest:\n | ExpandedMergeRequestSchema\n | Camelize<ExpandedMergeRequestSchema> = await api.MergeRequests.show(\n repoID,\n mergerequestIId,\n );\n\n while (\n mergeRequest.detailed_merge_status === 'preparing' ||\n mergeRequest.detailed_merge_status === 'approvals_syncing' ||\n mergeRequest.detailed_merge_status === 'checking'\n ) {\n mergeRequest = await api.MergeRequests.show(repoID, mergeRequest.iid);\n ctx.logger.info(`${mergeRequest.detailed_merge_status}`);\n }\n\n const approvalRules = await api.MergeRequestApprovals.allApprovalRules(\n repoID,\n {\n mergerequestIId: mergeRequest.iid,\n },\n );\n\n return approvalRules\n .filter(rule => rule.eligible_approvers !== undefined)\n .map(rule => {\n return rule.eligible_approvers as SimpleUserSchema[];\n })\n .flat()\n .map(user => user.id);\n } catch (e) {\n ctx.logger.warn(\n `Failed to retrieve approval rules for MR ${mergerequestIId}: ${getErrorMessage(\n e,\n )}. Proceeding with MR creation without reviewers from approval rules.`,\n );\n return [];\n }\n}\n\nconst commitActions = ['create', 'delete', 'update', 'skip', 'auto'] as const;\n\n/**\n * Create a new action that creates a GitLab merge request.\n *\n * @public\n */\nexport const createPublishGitlabMergeRequestAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'publish:gitlab:merge-request',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string().describe(`\\\nAccepts the format \\`gitlab.com?repo=project_name&owner=group_name\\` where \\\n\\`project_name\\` is the repository name and \\`group_name\\` is a group or username`),\n title: z => z.string().describe('The name for the merge request'),\n description: z =>\n z.string().describe('The description of the merge request'),\n branchName: z =>\n z.string().describe('The source branch name of the merge request'),\n targetBranchName: z =>\n z\n .string()\n .optional()\n .describe(\n 'The target branch name of the merge request (defaults to _default branch of repository_)',\n ),\n sourcePath: z =>\n z.string().optional().describe(`\\\nSubdirectory of working directory to copy changes from. \\\nFor reasons of backward compatibility, any specified \\`targetPath\\` input will \\\nbe applied in place of an absent/falsy value for this input. \\\nCircumvent this behavior using \\`.\\``),\n targetPath: z =>\n z\n .string()\n .optional()\n .describe('Subdirectory of repository to apply changes to'),\n token: z =>\n z\n .string()\n .optional()\n .describe('The token to use for authorization to GitLab'),\n commitAction: z =>\n z.enum(commitActions).optional().describe(`\\\nThe action to be used for \\`git\\` commit. Defaults to the custom \\`auto\\` action provided by Backstage,\nwhich uses additional API calls in order to detect whether to \\`create\\`, \\`update\\` or \\`skip\\` each source file.`),\n /** @deprecated projectID passed as query parameters in the repoUrl */\n projectid: z =>\n z\n .string()\n .optional()\n .describe(\n `\\\nProject ID/Name(slug) of the GitLab Project\n_deprecated_: \\`projectid\\` passed as query parameters in the \\`repoUrl\\``,\n ),\n removeSourceBranch: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'Option to delete source branch once the MR has been merged. Default: `false`',\n ),\n assignee: z =>\n z\n .string()\n .optional()\n .describe('User this merge request will be assigned to'),\n reviewers: z =>\n z\n .string()\n .array()\n .optional()\n .describe('Users that will be assigned as reviewers'),\n assignReviewersFromApprovalRules: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'Automatically assign reviewers from the approval rules of the MR. Includes `CODEOWNERS`',\n ),\n labels: z =>\n z\n .string()\n .or(z.string().array())\n .optional()\n .describe('Labels with which to tag the created merge request'),\n },\n output: {\n targetBranchName: z =>\n z.string().describe('Target branch name of the merge request'),\n projectid: z => z.string().describe('GitLab Project id/Name(slug)'),\n projectPath: z => z.string().describe('GitLab Project path'),\n mergeRequestUrl: z =>\n z.string().describe('Link to the merge request in GitLab'),\n },\n },\n async handler(ctx) {\n const {\n assignee,\n reviewers,\n branchName,\n targetBranchName,\n description,\n repoUrl,\n removeSourceBranch,\n targetPath,\n sourcePath,\n title,\n token,\n labels,\n } = ctx.input;\n\n const { owner, repo, project } = parseRepoUrl(repoUrl, integrations);\n const repoID = project ? project : `${owner}/${repo}`;\n\n const api = createGitlabApi({\n integrations,\n token,\n repoUrl,\n });\n\n let assigneeId: number | undefined = undefined;\n\n if (assignee !== undefined) {\n try {\n const assigneeUser = await api.Users.all({ username: assignee });\n assigneeId = assigneeUser[0].id;\n } catch (e) {\n ctx.logger.warn(\n `Failed to find gitlab user id for ${assignee}: ${getErrorMessage(\n e,\n )}. Proceeding with MR creation without an assignee.`,\n );\n }\n }\n\n let reviewerIds: number[] | undefined = undefined; // Explicitly set to undefined. Strangely, passing an empty array to the API will result the other options being undefined also being explicitly passed to the Gitlab API call (e.g. assigneeId)\n if (reviewers !== undefined) {\n reviewerIds = (\n await Promise.all(\n reviewers.map(async reviewer => {\n try {\n const reviewerUser = await api.Users.all({\n username: reviewer,\n });\n return reviewerUser[0].id;\n } catch (e) {\n ctx.logger.warn(\n `Failed to find gitlab user id for ${reviewer}: ${e}. Proceeding with MR creation without reviewer.`,\n );\n return undefined;\n }\n }),\n )\n ).filter(id => id !== undefined) as number[];\n }\n\n let fileRoot: string;\n if (sourcePath) {\n fileRoot = resolveSafeChildPath(ctx.workspacePath, sourcePath);\n } else if (targetPath) {\n // for backward compatibility\n fileRoot = resolveSafeChildPath(ctx.workspacePath, targetPath);\n } else {\n fileRoot = ctx.workspacePath;\n }\n\n const fileContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n let targetBranch = targetBranchName;\n if (!targetBranch) {\n const projects = await api.Projects.show(repoID);\n const defaultBranch = projects.default_branch ?? projects.defaultBranch;\n if (typeof defaultBranch !== 'string' || !defaultBranch) {\n throw new InputError(\n `The branch creation failed. Target branch was not provided, and could not find default branch from project settings. Project: ${JSON.stringify(\n project,\n )}`,\n );\n }\n targetBranch = defaultBranch;\n }\n\n let remoteFiles: RepositoryTreeSchema[] = [];\n if ((ctx.input.commitAction ?? 'auto') === 'auto') {\n try {\n remoteFiles = await api.Repositories.allRepositoryTrees(repoID, {\n ref: targetBranch,\n recursive: true,\n path: targetPath ?? undefined,\n });\n } catch (e) {\n ctx.logger.warn(\n `Could not retrieve the list of files for ${repoID} (branch: ${targetBranch}) : ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n const actions: CommitAction[] =\n ctx.input.commitAction === 'skip'\n ? []\n : (\n (\n await Promise.all(\n fileContents.map(async file => {\n const action = await getFileAction(\n { file, targetPath },\n { repoID, branch: targetBranch! },\n api,\n ctx.logger,\n remoteFiles,\n ctx.input.commitAction,\n );\n return { file, action };\n }),\n )\n ).filter(o => o.action !== 'skip') as {\n file: SerializedFile;\n action: CommitAction['action'];\n }[]\n ).map(({ file, action }) => ({\n action,\n filePath: targetPath\n ? path.posix.join(targetPath, file.path)\n : file.path,\n encoding: 'base64',\n content: file.content.toString('base64'),\n execute_filemode: file.executable,\n }));\n\n let createBranch = actions.length > 0;\n\n try {\n const branch = await api.Branches.show(repoID, branchName);\n if (createBranch) {\n const mergeRequests = await api.MergeRequests.all({\n projectId: repoID,\n source_branch: branchName,\n });\n\n if (mergeRequests.length > 0) {\n // If an open MR exists, include the MR link in the error message\n throw new InputError(\n `The branch creation failed because the branch already exists at: ${branch.web_url}. Additionally, there is a Merge Request for this branch: ${mergeRequests[0].web_url}`,\n );\n } else {\n // If no open MR, just notify about the existing branch\n throw new InputError(\n `The branch creation failed because the branch already exists at: ${branch.web_url}.`,\n );\n }\n }\n\n ctx.logger.info(\n `Using existing branch ${branchName} without modification.`,\n );\n } catch (e) {\n if (e instanceof InputError) {\n throw e;\n }\n createBranch = true;\n }\n\n if (createBranch) {\n try {\n await api.Branches.create(repoID, branchName, String(targetBranch));\n } catch (e) {\n throw new InputError(\n `The branch creation failed. Please check that your repo does not already contain a branch named '${branchName}'. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n\n await ctx.checkpoint({\n key: `commit.to.${repoID}.${branchName}`,\n fn: async () => {\n if (actions.length) {\n try {\n const commit = await api.Commits.create(\n repoID,\n branchName,\n title,\n actions,\n );\n return commit.id;\n } catch (e) {\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n return null;\n },\n });\n\n const { mrId, mrWebUrl } = await ctx.checkpoint({\n key: `create.mr.${repoID}.${branchName}`,\n fn: async () => {\n try {\n const mergeRequest = await api.MergeRequests.create(\n repoID,\n branchName,\n String(targetBranch),\n title,\n {\n description,\n removeSourceBranch: removeSourceBranch\n ? removeSourceBranch\n : false,\n assigneeId,\n reviewerIds,\n labels,\n },\n );\n return {\n mrId: mergeRequest.iid,\n mrWebUrl: mergeRequest.web_url ?? mergeRequest.webUrl,\n };\n } catch (e) {\n throw new InputError(\n `Merge request creation failed. ${getErrorMessage(e)}`,\n );\n }\n },\n });\n\n await ctx.checkpoint({\n key: `create.mr.assign.reviewers.${repoID}.${branchName}`,\n fn: async () => {\n if (ctx.input.assignReviewersFromApprovalRules) {\n try {\n const reviewersFromApprovalRules =\n await getReviewersFromApprovalRules(api, mrId, repoID, ctx);\n if (reviewersFromApprovalRules.length > 0) {\n const eligibleUserIds = new Set([\n ...reviewersFromApprovalRules,\n ...(reviewerIds ?? []),\n ]);\n\n const mergeRequest = await api.MergeRequests.edit(\n repoID,\n mrId,\n {\n reviewerIds: Array.from(eligibleUserIds),\n },\n );\n return {\n mrWebUrl: mergeRequest.web_url ?? mergeRequest.webUrl,\n };\n }\n } catch (e) {\n ctx.logger.warn(\n `Failed to assign reviewers from approval rules: ${getErrorMessage(\n e,\n )}.`,\n );\n }\n }\n return { mrWebUrl };\n },\n });\n\n ctx.output('projectid', repoID);\n ctx.output('targetBranchName', targetBranch);\n ctx.output('projectPath', repoID);\n ctx.output('mergeRequestUrl', mrWebUrl as string);\n },\n });\n};\n"],"names":["createHash","path","getErrorMessage","createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","InputError"],"mappings":";;;;;;;;;;;;;;AAyCA,SAAS,cAAc,IAA8B,EAAA;AACnD,EAAM,MAAA,IAAA,GAAOA,kBAAW,QAAQ,CAAA;AAChC,EAAK,IAAA,CAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AACxB,EAAO,OAAA,IAAA,CAAK,OAAO,KAAK,CAAA;AAC1B;AAEA,eAAe,cACb,QACA,EAAA,MAAA,EACA,KACA,MACA,EAAA,WAAA,EACA,sBAKa,MACqC,EAAA;AAClD,EAAA,IAAI,wBAAwB,MAAQ,EAAA;AAClC,IAAM,MAAA,QAAA,GAAWC,sBAAK,IAAK,CAAA,QAAA,CAAS,cAAc,EAAI,EAAA,QAAA,CAAS,KAAK,IAAI,CAAA;AAExE,IAAA,IAAI,aAAa,IAAK,CAAA,CAAA,UAAA,KAAc,UAAW,CAAA,IAAA,KAAS,QAAQ,CAAG,EAAA;AACjE,MAAI,IAAA;AACF,QAAM,MAAA,UAAA,GAAa,MAAM,GAAA,CAAI,eAAgB,CAAA,IAAA;AAAA,UAC3C,MAAO,CAAA,MAAA;AAAA,UACP,QAAA;AAAA,UACA,MAAO,CAAA;AAAA,SACT;AACA,QAAA,IAAI,aAAc,CAAA,QAAA,CAAS,IAAI,CAAA,KAAM,WAAW,cAAgB,EAAA;AAC9D,UAAO,OAAA,MAAA;AAAA;AACT,eACO,KAAO,EAAA;AACd,QAAO,MAAA,CAAA,IAAA;AAAA,UACL,2DAA2D,QAAQ,CAAA;AAAA,SACrE;AAAA;AAEF,MAAO,OAAA,QAAA;AAAA;AAET,IAAO,OAAA,QAAA;AAAA;AAET,EAAO,OAAA,mBAAA;AACT;AAEA,eAAe,6BACb,CAAA,GAAA,EACA,eACA,EAAA,MAAA,EACA,GACmB,EAAA;AACnB,EAAI,IAAA;AAKF,IAAI,IAAA,YAAA,GAEuC,MAAM,GAAA,CAAI,aAAc,CAAA,IAAA;AAA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yright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createTemplateAction,\n parseRepoUrl,\n SerializedFile,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport {\n Camelize,\n CommitAction,\n ExpandedMergeRequestSchema,\n Gitlab,\n RepositoryTreeSchema,\n SimpleUserSchema,\n} from '@gitbeaker/rest';\nimport path from 'path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport {\n LoggerService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { createGitlabApi, getErrorMessage } from './helpers';\nimport { examples } from './gitlabMergeRequest.examples';\nimport { createHash } from 'crypto';\n\nfunction computeSha256(file: SerializedFile): string {\n const hash = createHash('sha256');\n hash.update(file.content);\n return hash.digest('hex');\n}\n\nasync function getFileAction(\n fileInfo: { file: SerializedFile; targetPath?: string },\n target: { repoID: string; branch: string },\n api: InstanceType<typeof Gitlab>,\n logger: LoggerService,\n remoteFiles: RepositoryTreeSchema[],\n defaultCommitAction:\n | 'create'\n | 'delete'\n | 'update'\n | 'skip'\n | 'auto' = 'auto',\n): Promise<'create' | 'delete' | 'update' | 'skip'> {\n if (defaultCommitAction === 'auto') {\n const filePath = path.join(fileInfo.targetPath ?? '', fileInfo.file.path);\n\n if (remoteFiles?.some(remoteFile => remoteFile.path === filePath)) {\n try {\n const targetFile = await api.RepositoryFiles.show(\n target.repoID,\n filePath,\n target.branch,\n );\n if (computeSha256(fileInfo.file) === targetFile.content_sha256) {\n return 'skip';\n }\n } catch (error) {\n logger.warn(\n `Unable to retrieve detailed information for remote file ${filePath}`,\n );\n }\n return 'update';\n }\n return 'create';\n }\n return defaultCommitAction;\n}\n\nasync function getReviewersFromApprovalRules(\n api: InstanceType<typeof Gitlab>,\n mergerequestIId: number,\n repoID: string,\n ctx: any,\n): Promise<number[]> {\n try {\n // Because we don't know the code owners before the MR is created, we can't check the approval rules beforehand.\n // Getting the approval rules beforehand is very difficult, especially, because of the inheritance rules for groups.\n // Code owners take a moment to be processed and added to the approval rules after the MR is created.\n\n let mergeRequest:\n | ExpandedMergeRequestSchema\n | Camelize<ExpandedMergeRequestSchema> = await api.MergeRequests.show(\n repoID,\n mergerequestIId,\n );\n\n while (\n mergeRequest.detailed_merge_status === 'preparing' ||\n mergeRequest.detailed_merge_status === 'approvals_syncing' ||\n mergeRequest.detailed_merge_status === 'checking'\n ) {\n mergeRequest = await api.MergeRequests.show(repoID, mergeRequest.iid);\n ctx.logger.info(`${mergeRequest.detailed_merge_status}`);\n }\n\n const approvalRules = await api.MergeRequestApprovals.allApprovalRules(\n repoID,\n {\n mergerequestIId: mergeRequest.iid,\n },\n );\n\n return approvalRules\n .filter(rule => rule.eligible_approvers !== undefined)\n .map(rule => {\n return rule.eligible_approvers as SimpleUserSchema[];\n })\n .flat()\n .map(user => user.id);\n } catch (e) {\n ctx.logger.warn(\n `Failed to retrieve approval rules for MR ${mergerequestIId}: ${getErrorMessage(\n e,\n )}. Proceeding with MR creation without reviewers from approval rules.`,\n );\n return [];\n }\n}\n\nconst commitActions = ['create', 'delete', 'update', 'skip', 'auto'] as const;\n\n/**\n * Create a new action that creates a GitLab merge request.\n *\n * @public\n */\nexport const createPublishGitlabMergeRequestAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'publish:gitlab:merge-request',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string().describe(`\\\nAccepts the format \\`gitlab.com?repo=project_name&owner=group_name\\` where \\\n\\`project_name\\` is the repository name and \\`group_name\\` is a group or username`),\n title: z => z.string().describe('The name for the merge request'),\n description: z =>\n z\n .string()\n .optional()\n .describe('The description of the merge request'),\n branchName: z =>\n z.string().describe('The source branch name of the merge request'),\n targetBranchName: z =>\n z\n .string()\n .optional()\n .describe(\n 'The target branch name of the merge request (defaults to _default branch of repository_)',\n ),\n sourcePath: z =>\n z.string().optional().describe(`\\\nSubdirectory of working directory to copy changes from. \\\nFor reasons of backward compatibility, any specified \\`targetPath\\` input will \\\nbe applied in place of an absent/falsy value for this input. \\\nCircumvent this behavior using \\`.\\``),\n targetPath: z =>\n z\n .string()\n .optional()\n .describe('Subdirectory of repository to apply changes to'),\n token: z =>\n z\n .string()\n .optional()\n .describe('The token to use for authorization to GitLab'),\n commitAction: z =>\n z.enum(commitActions).optional().describe(`\\\nThe action to be used for \\`git\\` commit. Defaults to the custom \\`auto\\` action provided by Backstage,\nwhich uses additional API calls in order to detect whether to \\`create\\`, \\`update\\` or \\`skip\\` each source file.`),\n /** @deprecated projectID passed as query parameters in the repoUrl */\n projectid: z =>\n z\n .string()\n .optional()\n .describe(\n `\\\nProject ID/Name(slug) of the GitLab Project\n_deprecated_: \\`projectid\\` passed as query parameters in the \\`repoUrl\\``,\n ),\n removeSourceBranch: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'Option to delete source branch once the MR has been merged. Default: `false`',\n ),\n assignee: z =>\n z\n .string()\n .optional()\n .describe('User this merge request will be assigned to'),\n reviewers: z =>\n z\n .string()\n .array()\n .optional()\n .describe('Users that will be assigned as reviewers'),\n assignReviewersFromApprovalRules: z =>\n z\n .boolean()\n .optional()\n .describe(\n 'Automatically assign reviewers from the approval rules of the MR. Includes `CODEOWNERS`',\n ),\n labels: z =>\n z\n .string()\n .or(z.string().array())\n .optional()\n .describe('Labels with which to tag the created merge request'),\n },\n output: {\n targetBranchName: z =>\n z.string().describe('Target branch name of the merge request'),\n projectid: z => z.string().describe('GitLab Project id/Name(slug)'),\n projectPath: z => z.string().describe('GitLab Project path'),\n mergeRequestUrl: z =>\n z.string().describe('Link to the merge request in GitLab'),\n },\n },\n async handler(ctx) {\n const {\n assignee,\n reviewers,\n branchName,\n targetBranchName,\n description,\n repoUrl,\n removeSourceBranch,\n targetPath,\n sourcePath,\n title,\n token,\n labels,\n } = ctx.input;\n\n const { owner, repo, project } = parseRepoUrl(repoUrl, integrations);\n const repoID = project ? project : `${owner}/${repo}`;\n\n const api = createGitlabApi({\n integrations,\n token,\n repoUrl,\n });\n\n let assigneeId: number | undefined = undefined;\n\n if (assignee !== undefined) {\n try {\n const assigneeUser = await api.Users.all({ username: assignee });\n assigneeId = assigneeUser[0].id;\n } catch (e) {\n ctx.logger.warn(\n `Failed to find gitlab user id for ${assignee}: ${getErrorMessage(\n e,\n )}. Proceeding with MR creation without an assignee.`,\n );\n }\n }\n\n let reviewerIds: number[] | undefined = undefined; // Explicitly set to undefined. Strangely, passing an empty array to the API will result the other options being undefined also being explicitly passed to the Gitlab API call (e.g. assigneeId)\n if (reviewers !== undefined) {\n reviewerIds = (\n await Promise.all(\n reviewers.map(async reviewer => {\n try {\n const reviewerUser = await api.Users.all({\n username: reviewer,\n });\n return reviewerUser[0].id;\n } catch (e) {\n ctx.logger.warn(\n `Failed to find gitlab user id for ${reviewer}: ${e}. Proceeding with MR creation without reviewer.`,\n );\n return undefined;\n }\n }),\n )\n ).filter(id => id !== undefined) as number[];\n }\n\n let fileRoot: string;\n if (sourcePath) {\n fileRoot = resolveSafeChildPath(ctx.workspacePath, sourcePath);\n } else if (targetPath) {\n // for backward compatibility\n fileRoot = resolveSafeChildPath(ctx.workspacePath, targetPath);\n } else {\n fileRoot = ctx.workspacePath;\n }\n\n const fileContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n let targetBranch = targetBranchName;\n if (!targetBranch) {\n const projects = await api.Projects.show(repoID);\n const defaultBranch = projects.default_branch ?? projects.defaultBranch;\n if (typeof defaultBranch !== 'string' || !defaultBranch) {\n throw new InputError(\n `The branch creation failed. Target branch was not provided, and could not find default branch from project settings. Project: ${JSON.stringify(\n project,\n )}`,\n );\n }\n targetBranch = defaultBranch;\n }\n\n let remoteFiles: RepositoryTreeSchema[] = [];\n if ((ctx.input.commitAction ?? 'auto') === 'auto') {\n try {\n remoteFiles = await api.Repositories.allRepositoryTrees(repoID, {\n ref: targetBranch,\n recursive: true,\n path: targetPath ?? undefined,\n });\n } catch (e) {\n ctx.logger.warn(\n `Could not retrieve the list of files for ${repoID} (branch: ${targetBranch}) : ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n const actions: CommitAction[] =\n ctx.input.commitAction === 'skip'\n ? []\n : (\n (\n await Promise.all(\n fileContents.map(async file => {\n const action = await getFileAction(\n { file, targetPath },\n { repoID, branch: targetBranch! },\n api,\n ctx.logger,\n remoteFiles,\n ctx.input.commitAction,\n );\n return { file, action };\n }),\n )\n ).filter(o => o.action !== 'skip') as {\n file: SerializedFile;\n action: CommitAction['action'];\n }[]\n ).map(({ file, action }) => ({\n action,\n filePath: targetPath\n ? path.posix.join(targetPath, file.path)\n : file.path,\n encoding: 'base64',\n content: file.content.toString('base64'),\n execute_filemode: file.executable,\n }));\n\n let createBranch = actions.length > 0;\n\n try {\n const branch = await api.Branches.show(repoID, branchName);\n if (createBranch) {\n const mergeRequests = await api.MergeRequests.all({\n projectId: repoID,\n source_branch: branchName,\n });\n\n if (mergeRequests.length > 0) {\n // If an open MR exists, include the MR link in the error message\n throw new InputError(\n `The branch creation failed because the branch already exists at: ${branch.web_url}. Additionally, there is a Merge Request for this branch: ${mergeRequests[0].web_url}`,\n );\n } else {\n // If no open MR, just notify about the existing branch\n throw new InputError(\n `The branch creation failed because the branch already exists at: ${branch.web_url}.`,\n );\n }\n }\n\n ctx.logger.info(\n `Using existing branch ${branchName} without modification.`,\n );\n } catch (e) {\n if (e instanceof InputError) {\n throw e;\n }\n createBranch = true;\n }\n\n if (createBranch) {\n try {\n await api.Branches.create(repoID, branchName, String(targetBranch));\n } catch (e) {\n throw new InputError(\n `The branch creation failed. Please check that your repo does not already contain a branch named '${branchName}'. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n\n await ctx.checkpoint({\n key: `commit.to.${repoID}.${branchName}`,\n fn: async () => {\n if (actions.length) {\n try {\n const commit = await api.Commits.create(\n repoID,\n branchName,\n title,\n actions,\n );\n return commit.id;\n } catch (e) {\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n return null;\n },\n });\n\n const { mrId, mrWebUrl } = await ctx.checkpoint({\n key: `create.mr.${repoID}.${branchName}`,\n fn: async () => {\n try {\n const mergeRequest = await api.MergeRequests.create(\n repoID,\n branchName,\n String(targetBranch),\n title,\n {\n description,\n removeSourceBranch: removeSourceBranch\n ? removeSourceBranch\n : false,\n assigneeId,\n reviewerIds,\n labels,\n },\n );\n return {\n mrId: mergeRequest.iid,\n mrWebUrl: mergeRequest.web_url ?? mergeRequest.webUrl,\n };\n } catch (e) {\n throw new InputError(\n `Merge request creation failed. ${getErrorMessage(e)}`,\n );\n }\n },\n });\n\n await ctx.checkpoint({\n key: `create.mr.assign.reviewers.${repoID}.${branchName}`,\n fn: async () => {\n if (ctx.input.assignReviewersFromApprovalRules) {\n try {\n const reviewersFromApprovalRules =\n await getReviewersFromApprovalRules(api, mrId, repoID, ctx);\n if (reviewersFromApprovalRules.length > 0) {\n const eligibleUserIds = new Set([\n ...reviewersFromApprovalRules,\n ...(reviewerIds ?? []),\n ]);\n\n const mergeRequest = await api.MergeRequests.edit(\n repoID,\n mrId,\n {\n reviewerIds: Array.from(eligibleUserIds),\n },\n );\n return {\n mrWebUrl: mergeRequest.web_url ?? mergeRequest.webUrl,\n };\n }\n } catch (e) {\n ctx.logger.warn(\n `Failed to assign reviewers from approval rules: ${getErrorMessage(\n e,\n )}.`,\n );\n }\n }\n return { mrWebUrl };\n },\n });\n\n ctx.output('projectid', repoID);\n ctx.output('targetBranchName', targetBranch);\n ctx.output('projectPath', repoID);\n ctx.output('mergeRequestUrl', mrWebUrl as string);\n },\n });\n};\n"],"names":["createHash","path","getErrorMessage","createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","InputError"],"mappings":";;;;;;;;;;;;;;AAyCA,SAAS,cAAc,IAA8B,EAAA;AACnD,EAAM,MAAA,IAAA,GAAOA,kBAAW,QAAQ,CAAA;AAChC,EAAK,IAAA,CAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AACxB,EAAO,OAAA,IAAA,CAAK,OAAO,KAAK,CAAA;AAC1B;AAEA,eAAe,cACb,QACA,EAAA,MAAA,EACA,KACA,MACA,EAAA,WAAA,EACA,sBAKa,MACqC,EAAA;AAClD,EAAA,IAAI,wBAAwB,MAAQ,EAAA;AAClC,IAAM,MAAA,QAAA,GAAWC,sBAAK,IAAK,CAAA,QAAA,CAAS,cAAc,EAAI,EAAA,QAAA,CAAS,KAAK,IAAI,CAAA;AAExE,IAAA,IAAI,aAAa,IAAK,CAAA,CAAA,UAAA,KAAc,UAAW,CAAA,IAAA,KAAS,QAAQ,CAAG,EAAA;AACjE,MAAI,IAAA;AACF,QAAM,MAAA,UAAA,GAAa,MAAM,GAAA,CAAI,eAAgB,CAAA,IAAA;AAAA,UAC3C,MAAO,CAAA,MAAA;AAAA,UACP,QAAA;AAAA,UACA,MAAO,CAAA;AAAA,SACT;AACA,QAAA,IAAI,aAAc,CAAA,QAAA,CAAS,IAAI,CAAA,KAAM,WAAW,cAAgB,EAAA;AAC9D,UAAO,OAAA,MAAA;AAAA;AACT,eACO,KAAO,EAAA;AACd,QAAO,MAAA,CAAA,IAAA;AAAA,UACL,2DAA2D,QAAQ,CAAA;AAAA,SACrE;AAAA;AAEF,MAAO,OAAA,QAAA;AAAA;AAET,IAAO,OAAA,QAAA;AAAA;AAET,EAAO,OAAA,mBAAA;AACT;AAEA,eAAe,6BACb,CAAA,GAAA,EACA,eACA,EAAA,MAAA,EACA,GACmB,EAAA;AACnB,EAAI,IAAA;A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GED
@@ -180,8 +180,8 @@ declare const createPublishGitlabMergeRequestAction: (options: {
180
180
  }) => _backstage_plugin_scaffolder_node.TemplateAction<{
181
181
  repoUrl: string;
182
182
  title: string;
183
- description: string;
184
183
  branchName: string;
184
+ description?: string | undefined;
185
185
  targetBranchName?: string | undefined;
186
186
  sourcePath?: string | undefined;
187
187
  targetPath?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-gitlab",
3
- "version": "0.9.3-next.2",
3
+ "version": "0.9.4-next.0",
4
4
  "backstage": {
5
5
  "role": "backend-plugin-module",
6
6
  "pluginId": "scaffolder",
@@ -53,11 +53,11 @@
53
53
  "test": "backstage-cli package test"
54
54
  },
55
55
  "dependencies": {
56
- "@backstage/backend-plugin-api": "1.4.1-next.0",
57
- "@backstage/config": "1.3.3-next.0",
56
+ "@backstage/backend-plugin-api": "1.4.2-next.0",
57
+ "@backstage/config": "1.3.3",
58
58
  "@backstage/errors": "1.2.7",
59
- "@backstage/integration": "1.17.1-next.1",
60
- "@backstage/plugin-scaffolder-node": "0.10.0-next.2",
59
+ "@backstage/integration": "1.17.1",
60
+ "@backstage/plugin-scaffolder-node": "0.11.0-next.0",
61
61
  "@gitbeaker/rest": "^41.2.0",
62
62
  "luxon": "^3.0.0",
63
63
  "winston": "^3.2.1",
@@ -65,8 +65,8 @@
65
65
  "zod": "^3.22.4"
66
66
  },
67
67
  "devDependencies": {
68
- "@backstage/backend-test-utils": "1.7.0-next.1",
69
- "@backstage/cli": "0.33.1-next.2",
70
- "@backstage/plugin-scaffolder-node-test-utils": "0.3.1-next.2"
68
+ "@backstage/backend-test-utils": "1.7.1-next.0",
69
+ "@backstage/cli": "0.33.2-next.0",
70
+ "@backstage/plugin-scaffolder-node-test-utils": "0.3.2-next.0"
71
71
  }
72
72
  }