@backstage/plugin-scaffolder-backend-module-gitlab 0.9.4-next.1 → 0.9.5-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 +20 -0
- package/dist/actions/gitlab.cjs.js.map +1 -1
- package/dist/actions/gitlab.examples.cjs.js.map +1 -1
- package/dist/actions/gitlabGroupEnsureExists.cjs.js.map +1 -1
- package/dist/actions/gitlabGroupEnsureExists.examples.cjs.js.map +1 -1
- package/dist/actions/gitlabIssueCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabIssueCreate.examples.cjs.js.map +1 -1
- package/dist/actions/gitlabIssueEdit.cjs.js.map +1 -1
- package/dist/actions/gitlabIssueEdit.examples.cjs.js.map +1 -1
- package/dist/actions/gitlabMergeRequest.cjs.js.map +1 -1
- package/dist/actions/gitlabMergeRequest.examples.cjs.js.map +1 -1
- package/dist/actions/gitlabPipelineTrigger.cjs.js +5 -2
- package/dist/actions/gitlabPipelineTrigger.cjs.js.map +1 -1
- package/dist/actions/gitlabPipelineTrigger.examples.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectAccessTokenCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectAccessTokenCreate.examples.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectDeployTokenCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectDeployTokenCreate.examples.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectMigrate.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectVariableCreate.cjs.js.map +1 -1
- package/dist/actions/gitlabProjectVariableCreate.examples.cjs.js.map +1 -1
- package/dist/actions/gitlabRepoPush.cjs.js.map +1 -1
- package/dist/actions/gitlabRepoPush.examples.cjs.js.map +1 -1
- package/dist/actions/helpers.cjs.js.map +1 -1
- package/dist/autocomplete/autocomplete.cjs.js.map +1 -1
- package/dist/commonGitlabConfig.cjs.js.map +1 -1
- package/dist/module.cjs.js.map +1 -1
- package/dist/util.cjs.js.map +1 -1
- package/package.json +7 -7
|
@@ -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\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,QAA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I,GAAA,CAAA,MAAA,CAAO,eAAe,MAAM,CAAA;AAChC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,QAAkB,CAAA;AAAA;AAClD,GACD,CAAA;AACH;;;;"}
|
|
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\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,IAAA,EAA8B;AACnD,EAAA,MAAM,IAAA,GAAOA,kBAAW,QAAQ,CAAA;AAChC,EAAA,IAAA,CAAK,MAAA,CAAO,KAAK,OAAO,CAAA;AACxB,EAAA,OAAO,IAAA,CAAK,OAAO,KAAK,CAAA;AAC1B;AAEA,eAAe,cACb,QAAA,EACA,MAAA,EACA,KACA,MAAA,EACA,WAAA,EACA,sBAKa,MAAA,EACqC;AAClD,EAAA,IAAI,wBAAwB,MAAA,EAAQ;AAClC,IAAA,MAAM,QAAA,GAAWC,sBAAK,IAAA,CAAK,QAAA,CAAS,cAAc,EAAA,EAAI,QAAA,CAAS,KAAK,IAAI,CAAA;AAExE,IAAA,IAAI,aAAa,IAAA,CAAK,CAAA,UAAA,KAAc,UAAA,CAAW,IAAA,KAAS,QAAQ,CAAA,EAAG;AACjE,MAAA,IAAI;AACF,QAAA,MAAM,UAAA,GAAa,MAAM,GAAA,CAAI,eAAA,CAAgB,IAAA;AAAA,UAC3C,MAAA,CAAO,MAAA;AAAA,UACP,QAAA;AAAA,UACA,MAAA,CAAO;AAAA,SACT;AACA,QAAA,IAAI,aAAA,CAAc,QAAA,CAAS,IAAI,CAAA,KAAM,WAAW,cAAA,EAAgB;AAC9D,UAAA,OAAO,MAAA;AAAA,QACT;AAAA,MACF,SAAS,KAAA,EAAO;AACd,QAAA,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A,gDAAA,EAAmDA,uBAAA;AAAA,kBACjD;AAAA,iBACD,CAAA,CAAA;AAAA,eACH;AAAA,YACF;AAAA,UACF;AACA,UAAA,OAAO,EAAE,QAAA,EAAS;AAAA,QACpB;AAAA,OACD,CAAA;AAED,MAAA,GAAA,CAAI,MAAA,CAAO,aAAa,MAAM,CAAA;AAC9B,MAAA,GAAA,CAAI,MAAA,CAAO,oBAAoB,YAAY,CAAA;AAC3C,MAAA,GAAA,CAAI,MAAA,CAAO,eAAe,MAAM,CAAA;AAChC,MAAA,GAAA,CAAI,MAAA,CAAO,mBAAmB,QAAkB,CAAA;AAAA,IAClD;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabMergeRequest.examples.cjs.js","sources":["../../src/actions/gitlabMergeRequest.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a merge request with a specific assignee',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n description: 'This MR is really good',\n sourcePath: './path/to/my/changes',\n branchName: 'new-mr',\n assignee: 'my-assignee',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a merge request with removal of source branch after merge',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n description: 'This MR is really good',\n sourcePath: './path/to/my/changes',\n branchName: 'new-mr',\n removeSourceBranch: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a merge request with a target branch',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n description: 'This MR is really good',\n sourcePath: './path/to/my/changes',\n branchName: 'new-mr',\n targetBranchName: 'test',\n targetPath: 'Subdirectory',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a merge request with a commit action as create',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n branchName: 'new-mr',\n description: 'MR description',\n commitAction: 'create',\n targetPath: 'source',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a merge request with a commit action as delete',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n branchName: 'new-mr',\n description: 'MR description',\n commitAction: 'delete',\n targetPath: 'source',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a merge request with a commit action as update',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n branchName: 'new-mr',\n description: 'MR description',\n commitAction: 'update',\n targetPath: 'source',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,
|
|
1
|
+
{"version":3,"file":"gitlabMergeRequest.examples.cjs.js","sources":["../../src/actions/gitlabMergeRequest.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a merge request with a specific assignee',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n description: 'This MR is really good',\n sourcePath: './path/to/my/changes',\n branchName: 'new-mr',\n assignee: 'my-assignee',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a merge request with removal of source branch after merge',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n description: 'This MR is really good',\n sourcePath: './path/to/my/changes',\n branchName: 'new-mr',\n removeSourceBranch: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a merge request with a target branch',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n description: 'This MR is really good',\n sourcePath: './path/to/my/changes',\n branchName: 'new-mr',\n targetBranchName: 'test',\n targetPath: 'Subdirectory',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a merge request with a commit action as create',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n branchName: 'new-mr',\n description: 'MR description',\n commitAction: 'create',\n targetPath: 'source',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a merge request with a commit action as delete',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n branchName: 'new-mr',\n description: 'MR description',\n commitAction: 'delete',\n targetPath: 'source',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a merge request with a commit action as update',\n example: yaml.stringify({\n steps: [\n {\n id: 'createMergeRequest',\n action: 'publish:gitlab:merge-request',\n name: 'Create a Merge Request',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n title: 'Create my new MR',\n branchName: 'new-mr',\n description: 'MR description',\n commitAction: 'update',\n targetPath: 'source',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,iDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,oBAAA;AAAA,UACJ,MAAA,EAAQ,8BAAA;AAAA,UACR,IAAA,EAAM,wBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,KAAA,EAAO,kBAAA;AAAA,YACP,WAAA,EAAa,wBAAA;AAAA,YACb,UAAA,EAAY,sBAAA;AAAA,YACZ,UAAA,EAAY,QAAA;AAAA,YACZ,QAAA,EAAU;AAAA;AACZ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AAO,kBAAA;AAAA,YACP,UAAA,EAAY,QAAA;AAAA,YACZ,WAAA,EAAa,gBAAA;AAAA,YACb,YAAA,EAAc,QAAA;AAAA,YACd,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,uDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,oBAAA;AAAA,UACJ,MAAA,EAAQ,8BAAA;AAAA,UACR,IAAA,EAAM,wBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,KAAA,EAAO,kBAAA;AAAA,YACP,UAAA,EAAY,QAAA;AAAA,YACZ,WAAA,EAAa,gBAAA;AAAA,YACb,YAAA,EAAc,QAAA;AAAA,YACd,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,uDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,oBAAA;AAAA,UACJ,MAAA,EAAQ,8BAAA;AAAA,UACR,IAAA,EAAM,wBAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,KAAA,EAAO,kBAAA;AAAA,YACP,UAAA,EAAY,QAAA;AAAA,YACZ,WAAA,EAAa,gBAAA;AAAA,YACb,YAAA,EAAc,QAAA;AAAA,YACd,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -103,11 +103,14 @@ const createTriggerGitlabPipelineAction = (options) => {
|
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
ctx.logger.info(
|
|
106
|
-
|
|
106
|
+
// in version 18.0 of gitlab this was also deleting the pipeline
|
|
107
|
+
// this is a problem in gitlab which is fixed in version 18.1
|
|
108
|
+
// https://gitlab.com/gitlab-org/gitlab/-/issues/546669
|
|
109
|
+
`Deleted pipeline trigger token with token id: ${pipelineTriggerId}.`
|
|
107
110
|
);
|
|
108
111
|
} catch (error) {
|
|
109
112
|
ctx.logger.error(
|
|
110
|
-
`Failed to delete pipeline with token id ${pipelineTriggerId}.`
|
|
113
|
+
`Failed to delete pipeline trigger token with token id: ${pipelineTriggerId}.`
|
|
111
114
|
);
|
|
112
115
|
}
|
|
113
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabPipelineTrigger.cjs.js","sources":["../../src/actions/gitlabPipelineTrigger.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport {\n ExpandedPipelineSchema,\n PipelineTriggerTokenSchema,\n} from '@gitbeaker/rest';\nimport { getClient, parseRepoUrl } from '../util';\nimport { examples } from './gitlabPipelineTrigger.examples';\nimport { getErrorMessage } from './helpers';\n\n/**\n * Creates a `gitlab:pipeline:trigger` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createTriggerGitlabPipelineAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:pipeline:trigger',\n description: 'Triggers a GitLab Pipeline.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `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`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.number({\n description: 'Project Id',\n }),\n tokenDescription: z =>\n z.string({\n description: 'Pipeline token description',\n }),\n branch: z =>\n z.string({\n description: 'Project branch',\n }),\n variables: z =>\n z\n .record(z.string(), z.string(), {\n description:\n 'A object/record of key-valued strings containing the pipeline variables.',\n })\n .optional(),\n },\n output: {\n pipelineUrl: z =>\n z.string({\n description: 'Pipeline Url',\n }),\n },\n },\n async handler(ctx) {\n let pipelineTriggerToken: string | undefined = undefined;\n let pipelineTriggerId: number | undefined = undefined;\n\n const { repoUrl, projectId, tokenDescription, token, branch, variables } =\n ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n const api = getClient({ host, integrations, token });\n\n try {\n ({ pipelineTriggerToken, pipelineTriggerId } = await ctx.checkpoint({\n key: `create.pipeline.token.${projectId}`,\n fn: async () => {\n const res = (await api.PipelineTriggerTokens.create(\n projectId,\n tokenDescription,\n )) as PipelineTriggerTokenSchema;\n return {\n pipelineTriggerToken: res.token,\n pipelineTriggerId: res.id,\n };\n },\n }));\n\n if (!pipelineTriggerToken) {\n ctx.logger.error(\n `Failed to create pipeline token for project ${projectId}.`,\n );\n return;\n }\n ctx.logger.info(\n `Pipeline token id ${pipelineTriggerId} created for project ${projectId}.`,\n );\n\n // Use the pipeline token to trigger the pipeline in the project\n const pipelineTriggerResponse =\n (await api.PipelineTriggerTokens.trigger(\n projectId,\n branch,\n pipelineTriggerToken,\n { variables },\n )) as ExpandedPipelineSchema;\n\n if (!pipelineTriggerResponse.id) {\n ctx.logger.error(\n `Failed to trigger pipeline for project ${projectId}.`,\n );\n return;\n }\n\n ctx.logger.info(\n `Pipeline id ${pipelineTriggerResponse.id} for project ${projectId} triggered.`,\n );\n\n ctx.output('pipelineUrl', pipelineTriggerResponse.web_url);\n } catch (error: any) {\n // Handling other errors\n throw new InputError(\n `Failed to trigger Pipeline: ${getErrorMessage(error)}`,\n );\n } finally {\n // Delete the pipeline token if it was created\n if (pipelineTriggerId) {\n try {\n await ctx.checkpoint({\n key: `create.delete.token.${projectId}`,\n fn: async () => {\n if (pipelineTriggerId) {\n // to make the current version of TypeScript happy\n await api.PipelineTriggerTokens.remove(\n projectId,\n pipelineTriggerId,\n );\n }\n },\n });\n ctx.logger.info(\n `Deleted pipeline with token id ${pipelineTriggerId}.`,\n );\n } catch (error: any) {\n ctx.logger.error(\n `Failed to delete pipeline with token id ${pipelineTriggerId}.`,\n );\n }\n }\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","getClient","InputError","getErrorMessage"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"gitlabPipelineTrigger.cjs.js","sources":["../../src/actions/gitlabPipelineTrigger.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport {\n ExpandedPipelineSchema,\n PipelineTriggerTokenSchema,\n} from '@gitbeaker/rest';\nimport { getClient, parseRepoUrl } from '../util';\nimport { examples } from './gitlabPipelineTrigger.examples';\nimport { getErrorMessage } from './helpers';\n\n/**\n * Creates a `gitlab:pipeline:trigger` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createTriggerGitlabPipelineAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:pipeline:trigger',\n description: 'Triggers a GitLab Pipeline.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `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`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.number({\n description: 'Project Id',\n }),\n tokenDescription: z =>\n z.string({\n description: 'Pipeline token description',\n }),\n branch: z =>\n z.string({\n description: 'Project branch',\n }),\n variables: z =>\n z\n .record(z.string(), z.string(), {\n description:\n 'A object/record of key-valued strings containing the pipeline variables.',\n })\n .optional(),\n },\n output: {\n pipelineUrl: z =>\n z.string({\n description: 'Pipeline Url',\n }),\n },\n },\n async handler(ctx) {\n let pipelineTriggerToken: string | undefined = undefined;\n let pipelineTriggerId: number | undefined = undefined;\n\n const { repoUrl, projectId, tokenDescription, token, branch, variables } =\n ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n const api = getClient({ host, integrations, token });\n\n try {\n ({ pipelineTriggerToken, pipelineTriggerId } = await ctx.checkpoint({\n key: `create.pipeline.token.${projectId}`,\n fn: async () => {\n const res = (await api.PipelineTriggerTokens.create(\n projectId,\n tokenDescription,\n )) as PipelineTriggerTokenSchema;\n return {\n pipelineTriggerToken: res.token,\n pipelineTriggerId: res.id,\n };\n },\n }));\n\n if (!pipelineTriggerToken) {\n ctx.logger.error(\n `Failed to create pipeline token for project ${projectId}.`,\n );\n return;\n }\n ctx.logger.info(\n `Pipeline token id ${pipelineTriggerId} created for project ${projectId}.`,\n );\n\n // Use the pipeline token to trigger the pipeline in the project\n const pipelineTriggerResponse =\n (await api.PipelineTriggerTokens.trigger(\n projectId,\n branch,\n pipelineTriggerToken,\n { variables },\n )) as ExpandedPipelineSchema;\n\n if (!pipelineTriggerResponse.id) {\n ctx.logger.error(\n `Failed to trigger pipeline for project ${projectId}.`,\n );\n return;\n }\n\n ctx.logger.info(\n `Pipeline id ${pipelineTriggerResponse.id} for project ${projectId} triggered.`,\n );\n\n ctx.output('pipelineUrl', pipelineTriggerResponse.web_url);\n } catch (error: any) {\n // Handling other errors\n throw new InputError(\n `Failed to trigger Pipeline: ${getErrorMessage(error)}`,\n );\n } finally {\n // Delete the pipeline token if it was created\n if (pipelineTriggerId) {\n try {\n await ctx.checkpoint({\n key: `create.delete.token.${projectId}`,\n fn: async () => {\n if (pipelineTriggerId) {\n // to make the current version of TypeScript happy\n await api.PipelineTriggerTokens.remove(\n projectId,\n pipelineTriggerId,\n );\n }\n },\n });\n ctx.logger.info(\n // in version 18.0 of gitlab this was also deleting the pipeline\n // this is a problem in gitlab which is fixed in version 18.1\n // https://gitlab.com/gitlab-org/gitlab/-/issues/546669\n `Deleted pipeline trigger token with token id: ${pipelineTriggerId}.`,\n );\n } catch (error: any) {\n ctx.logger.error(\n `Failed to delete pipeline trigger token with token id: ${pipelineTriggerId}.`,\n );\n }\n }\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","getClient","InputError","getErrorMessage"],"mappings":";;;;;;;;AAiCO,MAAM,iCAAA,GAAoC,CAAC,OAAA,KAE5C;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AACzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,yBAAA;AAAA,IACJ,WAAA,EAAa,6BAAA;AAAA,cACbC,uCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CAAE,MAAA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A,cACrC,IAAI,YAAY;AACd,gBAAA,IAAI,iBAAA,EAAmB;AAErB,kBAAA,MAAM,IAAI,qBAAA,CAAsB,MAAA;AAAA,oBAC9B,SAAA;AAAA,oBACA;AAAA,mBACF;AAAA,gBACF;AAAA,cACF;AAAA,aACD,CAAA;AACD,YAAA,GAAA,CAAI,MAAA,CAAO,IAAA;AAAA;AAAA;AAAA;AAAA,cAIT,iDAAiD,iBAAiB,CAAA,CAAA;AAAA,aACpE;AAAA,UACF,SAAS,KAAA,EAAY;AACnB,YAAA,GAAA,CAAI,MAAA,CAAO,KAAA;AAAA,cACT,0DAA0D,iBAAiB,CAAA,CAAA;AAAA,aAC7E;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabPipelineTrigger.examples.cjs.js","sources":["../../src/actions/gitlabPipelineTrigger.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\nimport { commonGitlabConfigExample } from '../commonGitlabConfig';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Trigger a GitLab Project Pipeline',\n example: yaml.stringify({\n steps: [\n {\n id: 'triggerPipeline',\n name: 'Trigger Project Pipeline',\n action: 'gitlab:pipeline:trigger',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n tokenDescription:\n 'This is the text that will appear in the pipeline token',\n token: 'glpt-xxxxxxxxxxxx',\n branch: 'main',\n variables: { var_one: 'one', var_two: 'two' },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a GitLab Project Pipeline with No Variables',\n example: yaml.stringify({\n steps: [\n {\n id: 'triggerPipeline',\n name: 'Trigger Project Pipeline',\n action: 'gitlab:pipeline:trigger',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n tokenDescription:\n 'This is the text that will appear in the pipeline token',\n token: 'glpt-xxxxxxxxxxxx',\n branch: 'main',\n variables: {},\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a GitLab Project Pipeline with Single Variables',\n example: yaml.stringify({\n steps: [\n {\n id: 'triggerPipeline',\n name: 'Trigger Project Pipeline',\n action: 'gitlab:pipeline:trigger',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n tokenDescription:\n 'This is the text that will appear in the pipeline token',\n token: 'glpt-xxxxxxxxxxxx',\n branch: 'main',\n variables: { var_one: 'one' },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a GitLab Project Pipeline with Multiple Variables',\n example: yaml.stringify({\n steps: [\n {\n id: 'triggerPipeline',\n name: 'Trigger Project Pipeline',\n action: 'gitlab:pipeline:trigger',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n tokenDescription:\n 'This is the text that will appear in the pipeline token',\n token: 'glpt-xxxxxxxxxxxx',\n branch: 'main',\n variables: { var_one: 'one', var_two: 'two', var_three: 'three' },\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml","commonGitlabConfigExample"],"mappings":";;;;;;;;;AAmBO,MAAM,
|
|
1
|
+
{"version":3,"file":"gitlabPipelineTrigger.examples.cjs.js","sources":["../../src/actions/gitlabPipelineTrigger.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\nimport { commonGitlabConfigExample } from '../commonGitlabConfig';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Trigger a GitLab Project Pipeline',\n example: yaml.stringify({\n steps: [\n {\n id: 'triggerPipeline',\n name: 'Trigger Project Pipeline',\n action: 'gitlab:pipeline:trigger',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n tokenDescription:\n 'This is the text that will appear in the pipeline token',\n token: 'glpt-xxxxxxxxxxxx',\n branch: 'main',\n variables: { var_one: 'one', var_two: 'two' },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a GitLab Project Pipeline with No Variables',\n example: yaml.stringify({\n steps: [\n {\n id: 'triggerPipeline',\n name: 'Trigger Project Pipeline',\n action: 'gitlab:pipeline:trigger',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n tokenDescription:\n 'This is the text that will appear in the pipeline token',\n token: 'glpt-xxxxxxxxxxxx',\n branch: 'main',\n variables: {},\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a GitLab Project Pipeline with Single Variables',\n example: yaml.stringify({\n steps: [\n {\n id: 'triggerPipeline',\n name: 'Trigger Project Pipeline',\n action: 'gitlab:pipeline:trigger',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n tokenDescription:\n 'This is the text that will appear in the pipeline token',\n token: 'glpt-xxxxxxxxxxxx',\n branch: 'main',\n variables: { var_one: 'one' },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a GitLab Project Pipeline with Multiple Variables',\n example: yaml.stringify({\n steps: [\n {\n id: 'triggerPipeline',\n name: 'Trigger Project Pipeline',\n action: 'gitlab:pipeline:trigger',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n tokenDescription:\n 'This is the text that will appear in the pipeline token',\n token: 'glpt-xxxxxxxxxxxx',\n branch: 'main',\n variables: { var_one: 'one', var_two: 'two', var_three: 'three' },\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml","commonGitlabConfigExample"],"mappings":";;;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,mCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,iBAAA;AAAA,UACJ,IAAA,EAAM,0BAAA;AAAA,UACN,MAAA,EAAQ,yBAAA;AAAA,UACR,KAAA,EAAO;AAAA,YACL,GAAGC,4CAAA;AAAA,YACH,SAAA,EAAW,EAAA;AAAA,YACX,gBAAA,EACE,yDAAA;AAAA,YACF,KAAA,EAAO,mBAAA;AAAA,YACP,MAAA,EAAQ,MAAA;AAAA,YACR,SAAA,EAAW,EAAE,OAAA,EAAS,KAAA,EAAO,SAAS,KAAA;AAAM;AAC9C;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,qDAAA;AAAA,IACb,OAAA,EAASD,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,iBAAA;AAAA,UACJ,IAAA,EAAM,0BAAA;AAAA,UACN,MAAA,EAAQ,yBAAA;AAAA,UACR,KAAA,EAAO;AAAA,YACL,GAAGC,4CAAA;AAAA,YACH,SAAA,EAAW,EAAA;AAAA,YACX,gBAAA,EACE,yDAAA;AAAA,YACF,KAAA,EAAO,mBAAA;AAAA,YACP,MAAA,EAAQ,MAAA;AAAA,YACR,WAAW;AAAC;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,yDAAA;AAAA,IACb,OAAA,EAASD,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,iBAAA;AAAA,UACJ,IAAA,EAAM,0BAAA;AAAA,UACN,MAAA,EAAQ,yBAAA;AAAA,UACR,KAAA,EAAO;AAAA,YACL,GAAGC,4CAAA;AAAA,YACH,SAAA,EAAW,EAAA;AAAA,YACX,gBAAA,EACE,yDAAA;AAAA,YACF,KAAA,EAAO,mBAAA;AAAA,YACP,MAAA,EAAQ,MAAA;AAAA,YACR,SAAA,EAAW,EAAE,OAAA,EAAS,KAAA;AAAM;AAC9B;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,2DAAA;AAAA,IACb,OAAA,EAASD,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,iBAAA;AAAA,UACJ,IAAA,EAAM,0BAAA;AAAA,UACN,MAAA,EAAQ,yBAAA;AAAA,UACR,KAAA,EAAO;AAAA,YACL,GAAGC,4CAAA;AAAA,YACH,SAAA,EAAW,EAAA;AAAA,YACX,gBAAA,EACE,yDAAA;AAAA,YACF,KAAA,EAAO,mBAAA;AAAA,YACP,MAAA,EAAQ,MAAA;AAAA,YACR,WAAW,EAAE,OAAA,EAAS,OAAO,OAAA,EAAS,KAAA,EAAO,WAAW,OAAA;AAAQ;AAClE;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabProjectAccessTokenCreate.cjs.js","sources":["../../src/actions/gitlabProjectAccessTokenCreate.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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { AccessTokenScopes, Gitlab } from '@gitbeaker/rest';\nimport { DateTime } from 'luxon';\nimport { getToken } from '../util';\nimport { examples } from './gitlabProjectAccessTokenCreate.examples';\n\n/**\n * Creates a `gitlab:projectAccessToken:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\n\nexport const createGitlabProjectAccessTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectAccessToken:create',\n examples,\n schema: {\n input: {\n projectId: z =>\n z.union([z.number(), z.string()], {\n description: 'Project ID/Name(slug) of the Gitlab Project',\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n name: z =>\n z\n .string({\n description: 'Name of Access Key',\n })\n .optional(),\n repoUrl: z =>\n z.string({\n description: 'URL to gitlab instance',\n }),\n accessLevel: z =>\n z\n .number({\n description:\n 'Access Level of the Token, 10 (Guest), 20 (Reporter), 30 (Developer), 40 (Maintainer), and 50 (Owner)',\n })\n .optional(),\n scopes: z =>\n z\n .string({\n description: 'Scopes for a project access token',\n })\n .array()\n .optional(),\n expiresAt: z =>\n z\n .string({\n description:\n 'Expiration date of the access token in ISO format (YYYY-MM-DD). If Empty, it will set to the maximum of 365 days.',\n })\n .optional(),\n },\n output: {\n access_token: z =>\n z.string({\n description: 'Access Token',\n }),\n },\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const {\n projectId,\n name = 'tokenname',\n accessLevel = 40,\n scopes = ['read_repository'],\n expiresAt,\n } = ctx.input;\n\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n if (!integrationConfig.config.token && token) {\n throw new InputError(\n `No token available for host ${integrationConfig.config.baseUrl}`,\n );\n }\n\n let api;\n\n if (!ctx.input.token) {\n api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n } else {\n api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n oauthToken: token,\n });\n }\n\n const projectAccessToken = await ctx.checkpoint({\n key: `project.access.token.${projectId}.${name}`,\n fn: async () => {\n const response = await api.ProjectAccessTokens.create(\n projectId,\n name,\n scopes as AccessTokenScopes[],\n expiresAt || DateTime.now().plus({ days: 365 }).toISODate()!,\n {\n accessLevel,\n },\n );\n return response.token;\n },\n });\n\n if (!projectAccessToken) {\n throw new Error('Could not create project access token');\n }\n\n ctx.output('access_token', projectAccessToken);\n },\n });\n};\n"],"names":["createTemplateAction","examples","getToken","InputError","Gitlab","DateTime"],"mappings":";;;;;;;;;AA+
|
|
1
|
+
{"version":3,"file":"gitlabProjectAccessTokenCreate.cjs.js","sources":["../../src/actions/gitlabProjectAccessTokenCreate.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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { AccessTokenScopes, Gitlab } from '@gitbeaker/rest';\nimport { DateTime } from 'luxon';\nimport { getToken } from '../util';\nimport { examples } from './gitlabProjectAccessTokenCreate.examples';\n\n/**\n * Creates a `gitlab:projectAccessToken:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\n\nexport const createGitlabProjectAccessTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectAccessToken:create',\n examples,\n schema: {\n input: {\n projectId: z =>\n z.union([z.number(), z.string()], {\n description: 'Project ID/Name(slug) of the Gitlab Project',\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n name: z =>\n z\n .string({\n description: 'Name of Access Key',\n })\n .optional(),\n repoUrl: z =>\n z.string({\n description: 'URL to gitlab instance',\n }),\n accessLevel: z =>\n z\n .number({\n description:\n 'Access Level of the Token, 10 (Guest), 20 (Reporter), 30 (Developer), 40 (Maintainer), and 50 (Owner)',\n })\n .optional(),\n scopes: z =>\n z\n .string({\n description: 'Scopes for a project access token',\n })\n .array()\n .optional(),\n expiresAt: z =>\n z\n .string({\n description:\n 'Expiration date of the access token in ISO format (YYYY-MM-DD). If Empty, it will set to the maximum of 365 days.',\n })\n .optional(),\n },\n output: {\n access_token: z =>\n z.string({\n description: 'Access Token',\n }),\n },\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const {\n projectId,\n name = 'tokenname',\n accessLevel = 40,\n scopes = ['read_repository'],\n expiresAt,\n } = ctx.input;\n\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n if (!integrationConfig.config.token && token) {\n throw new InputError(\n `No token available for host ${integrationConfig.config.baseUrl}`,\n );\n }\n\n let api;\n\n if (!ctx.input.token) {\n api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n } else {\n api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n oauthToken: token,\n });\n }\n\n const projectAccessToken = await ctx.checkpoint({\n key: `project.access.token.${projectId}.${name}`,\n fn: async () => {\n const response = await api.ProjectAccessTokens.create(\n projectId,\n name,\n scopes as AccessTokenScopes[],\n expiresAt || DateTime.now().plus({ days: 365 }).toISODate()!,\n {\n accessLevel,\n },\n );\n return response.token;\n },\n });\n\n if (!projectAccessToken) {\n throw new Error('Could not create project access token');\n }\n\n ctx.output('access_token', projectAccessToken);\n },\n });\n};\n"],"names":["createTempl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d,UAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CAAI,mBAAA,CAAoB,MAAA;AAAA,YAC7C,SAAA;AAAA,YACA,IAAA;AAAA,YACA,MAAA;AAAA,YACA,SAAA,IAAaC,cAAA,CAAS,GAAA,EAAI,CAAE,IAAA,CAAK,EAAE,IAAA,EAAM,GAAA,EAAK,CAAA,CAAE,SAAA,EAAU;AAAA,YAC1D;AAAA,cACE;AAAA;AACF,WACF;AACA,UAAA,OAAO,QAAA,CAAS,KAAA;AAAA,QAClB;AAAA,OACD,CAAA;AAED,MAAA,IAAI,CAAC,kBAAA,EAAoB;AACvB,QAAA,MAAM,IAAI,MAAM,uCAAuC,CAAA;AAAA,MACzD;AAEA,MAAA,GAAA,CAAI,MAAA,CAAO,gBAAgB,kBAAkB,CAAA;AAAA,IAC/C;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabProjectAccessTokenCreate.examples.cjs.js","sources":["../../src/actions/gitlabProjectAccessTokenCreate.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a GitLab project access token with minimal options.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with custom scopes.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '789',\n scopes: ['read_registry', 'write_repository'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with a specified name.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n name: 'my-custom-token',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with a numeric project ID.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: 42,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with a specified expired Date.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n expiresAt: '2024-06-25',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with an access level',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n accessLevel: 30,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with multiple options',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n accessLevel: 40,\n name: 'full-access-token',\n expiresAt: '2024-12-31',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with a token for authorization',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n token: 'personal-access-token',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with read-only scopes',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n scopes: ['read_repository', 'read_api'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with guest access level',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n accessLevel: 10,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with maintainer access level',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n accessLevel: 40,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with owner access level',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n accessLevel: 50,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with a specified name and no expiration date',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n name: 'no-expiry-token',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token for a specific gitlab instance',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.example.com?repo=repo&owner=owner',\n projectId: '101112',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,4DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,mBAAA;AAAA,UACJ,MAAQ,EAAA,kCAAA;AAAA,UACR,IAAM,EAAA,oCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,SAAW,EAAA;AAAA;AACb;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,0DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,mBAAA;AAAA,UACJ,MAAQ,EAAA,kCAAA;AAAA,UACR,IAAM,EAAA,oCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,SAAW,EAAA,KAAA;AAAA,YACX,MAAA,EAAQ,CAAC,eAAA,EAAiB,kBAAkB;AAAA;AAC9C;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,6DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,mBAAA;AAAA,UACJ,MAAQ,EAAA,kCA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M,EAAA;AAAA;AACR;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,qEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,mBAAA;AAAA,UACJ,MAAQ,EAAA,kCAAA;AAAA,UACR,IAAM,EAAA,oCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,0CAAA;AAAA,YACT,SAAW,EAAA;AAAA;AACb;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"gitlabProjectAccessTokenCreate.examples.cjs.js","sources":["../../src/actions/gitlabProjectAccessTokenCreate.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a GitLab project access token with minimal options.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with custom scopes.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '789',\n scopes: ['read_registry', 'write_repository'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with a specified name.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n name: 'my-custom-token',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with a numeric project ID.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: 42,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with a specified expired Date.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n expiresAt: '2024-06-25',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with an access level',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n accessLevel: 30,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with multiple options',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n accessLevel: 40,\n name: 'full-access-token',\n expiresAt: '2024-12-31',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with a token for authorization',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n token: 'personal-access-token',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with read-only scopes',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n scopes: ['read_repository', 'read_api'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with guest access level',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n accessLevel: 10,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with maintainer access level',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n accessLevel: 40,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project access token with owner access level',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n accessLevel: 50,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token with a specified name and no expiration date',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n name: 'no-expiry-token',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project access token for a specific gitlab instance',\n example: yaml.stringify({\n steps: [\n {\n id: 'createAccessToken',\n action: 'gitlab:projectAccessToken:create',\n name: 'Create GitLab Project Access Token',\n input: {\n repoUrl: 'gitlab.example.com?repo=repo&owner=owner',\n projectId: '101112',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,4DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,mBAAA;AAAA,UACJ,MAAA,EAAQ,kCAAA;AAAA,UACR,IAAA,EAAM,oCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW;AAAA;AACb;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,0DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,mBAAA;AAAA,UACJ,MAAA,EAAQ,kCAAA;AAAA,UACR,IAAA,EAAM,oCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,KAAA;AAAA,YACX,MAAA,EAAQ,CAAC,eAAA,EAAiB,kBAAkB;AAAA;AAC9C;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,6DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,mBAAA;AAAA,UACJ,MAAA,EAAQ,kCAAA;AAAA,UACR,IAAA,EAAM,oCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,QAAA;AAAA,YACX,IAAA,EAAM;AAAA;AACR;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA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mBAAA;AAAA,UACJ,MAAA,EAAQ,kCAAA;AAAA,UACR,IAAA,EAAM,oCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,0CAAA;AAAA,YACT,SAAA,EAAW;AAAA;AACb;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabProjectDeployTokenCreate.cjs.js","sources":["../../src/actions/gitlabProjectDeployTokenCreate.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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { DeployTokenScope, Gitlab } from '@gitbeaker/rest';\nimport { getToken } from '../util';\nimport { examples } from './gitlabProjectDeployTokenCreate.examples';\n\n/**\n * Creates a `gitlab:projectDeployToken:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectDeployTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectDeployToken:create',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `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`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n name: z =>\n z.string({\n description: 'Deploy Token Name',\n }),\n username: z =>\n z\n .string({\n description: 'Deploy Token Username',\n })\n .optional(),\n scopes: z =>\n z.array(z.string(), {\n description: 'Scopes',\n }),\n },\n output: {\n deploy_token: z =>\n z.string({\n description: 'Deploy Token',\n }),\n user: z =>\n z.string({\n description: 'User',\n }),\n },\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const { projectId, name, username, scopes } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n if (scopes.length === 0) {\n throw new InputError(\n `Could not create token for project \"${ctx.input.projectId}\": scopes cannot be empty.`,\n );\n }\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n const { deployToken, deployUsername } = await ctx.checkpoint({\n key: `create.deploy.token.${projectId}.${name}`,\n fn: async () => {\n const res = await api.DeployTokens.create(\n name,\n scopes as DeployTokenScope[],\n {\n projectId,\n username,\n },\n );\n\n if (!res.hasOwnProperty('token')) {\n throw new InputError(`No deploy_token given from gitlab instance`);\n }\n\n return {\n deployToken: res.token as string,\n deployUsername: res.username,\n };\n },\n });\n\n ctx.output('deploy_token', deployToken);\n ctx.output('user', deployUsername);\n },\n });\n};\n"],"names":["createTemplateAction","examples","getToken","InputError","Gitlab"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"gitlabProjectDeployTokenCreate.cjs.js","sources":["../../src/actions/gitlabProjectDeployTokenCreate.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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { DeployTokenScope, Gitlab } from '@gitbeaker/rest';\nimport { getToken } from '../util';\nimport { examples } from './gitlabProjectDeployTokenCreate.examples';\n\n/**\n * Creates a `gitlab:projectDeployToken:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectDeployTokenAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectDeployToken:create',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `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`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n name: z =>\n z.string({\n description: 'Deploy Token Name',\n }),\n username: z =>\n z\n .string({\n description: 'Deploy Token Username',\n })\n .optional(),\n scopes: z =>\n z.array(z.string(), {\n description: 'Scopes',\n }),\n },\n output: {\n deploy_token: z =>\n z.string({\n description: 'Deploy Token',\n }),\n user: z =>\n z.string({\n description: 'User',\n }),\n },\n },\n async handler(ctx) {\n ctx.logger.info(`Creating Token for Project \"${ctx.input.projectId}\"`);\n const { projectId, name, username, scopes } = ctx.input;\n const { token, integrationConfig } = getToken(ctx.input, integrations);\n\n if (scopes.length === 0) {\n throw new InputError(\n `Could not create token for project \"${ctx.input.projectId}\": scopes cannot be empty.`,\n );\n }\n\n const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n const { deployToken, deployUsername } = await ctx.checkpoint({\n key: `create.deploy.token.${projectId}.${name}`,\n fn: async () => {\n const res = await api.DeployTokens.create(\n name,\n scopes as DeployTokenScope[],\n {\n projectId,\n username,\n },\n );\n\n if (!res.hasOwnProperty('token')) {\n throw new InputError(`No deploy_token given from gitlab instance`);\n }\n\n return {\n deployToken: res.token as string,\n deployUsername: res.username,\n };\n },\n });\n\n ctx.output('deploy_token', deployToken);\n ctx.output('user', deployUsername);\n },\n });\n};\n"],"names":["createTemplateAction","examples","getToken","InputError","Gitlab"],"mappings":";;;;;;;;AA6BO,MAAM,oCAAA,GAAuC,CAAC,OAAA,KAE/C;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AACzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,kCAAA;AAAA,cACJC,gDAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,CAAE,MAAA,EAAO,EAAG,CAAA,CAAE,MAAA,EAAQ,CAAA,EAAG;AAAA,UAChC,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,IAAA,EAAM,CAAA,CAAA,KACJ,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,QAAA,EAAU,CAAA,CAAA,KACR,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,QAAQ,CAAA,CAAA,KACN,CAAA,CAAE,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UAClB,WAAA,EAAa;AAAA,SACd;AAAA,OACL;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,YAAA,EAAc,CAAA,CAAA,KACZ,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EA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AA,CAA4C,CAAA;AAAA,UACnE;AAEA,UAAA,OAAO;AAAA,YACL,aAAa,GAAA,CAAI,KAAA;AAAA,YACjB,gBAAgB,GAAA,CAAI;AAAA,WACtB;AAAA,QACF;AAAA,OACD,CAAA;AAED,MAAA,GAAA,CAAI,MAAA,CAAO,gBAAgB,WAAW,CAAA;AACtC,MAAA,GAAA,CAAI,MAAA,CAAO,QAAQ,cAAc,CAAA;AAAA,IACnC;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabProjectDeployTokenCreate.examples.cjs.js","sources":["../../src/actions/gitlabProjectDeployTokenCreate.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a GitLab project deploy token with minimal options.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createDeployToken',\n action: 'gitlab:projectDeployToken:create',\n name: 'Create GitLab Project Deploy Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n name: 'tokenname',\n scopes: ['read_registry'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project deploy token with many custom scopes.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createDeployToken',\n action: 'gitlab:projectDeployToken:create',\n name: 'Create GitLab Project Deploy Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '789',\n name: 'tokenname',\n scopes: ['read_registry', 'write_repository'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project deploy token with a specified name.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createDeployToken',\n action: 'gitlab:projectDeployToken:create',\n name: 'Create GitLab Project Deploy Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n name: 'my-custom-token',\n scopes: ['read_registry'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project deploy token with a numeric project ID.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createDeployToken',\n action: 'gitlab:projectDeployToken:create',\n name: 'Create GitLab Project Deploy Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: 42,\n name: 'tokenname',\n scopes: ['read_registry'],\n },\n },\n ],\n }),\n },\n\n {\n description: 'Create a GitLab project deploy token with a custom username',\n example: yaml.stringify({\n steps: [\n {\n id: 'createDeployToken',\n action: 'gitlab:projectDeployToken:create',\n name: 'Create GitLab Project Deploy Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: 42,\n name: 'tokenname',\n username: 'tokenuser',\n scopes: ['read_registry'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,
|
|
1
|
+
{"version":3,"file":"gitlabProjectDeployTokenCreate.examples.cjs.js","sources":["../../src/actions/gitlabProjectDeployTokenCreate.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a GitLab project deploy token with minimal options.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createDeployToken',\n action: 'gitlab:projectDeployToken:create',\n name: 'Create GitLab Project Deploy Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n name: 'tokenname',\n scopes: ['read_registry'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project deploy token with many custom scopes.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createDeployToken',\n action: 'gitlab:projectDeployToken:create',\n name: 'Create GitLab Project Deploy Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '789',\n name: 'tokenname',\n scopes: ['read_registry', 'write_repository'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project deploy token with a specified name.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createDeployToken',\n action: 'gitlab:projectDeployToken:create',\n name: 'Create GitLab Project Deploy Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '101112',\n name: 'my-custom-token',\n scopes: ['read_registry'],\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project deploy token with a numeric project ID.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createDeployToken',\n action: 'gitlab:projectDeployToken:create',\n name: 'Create GitLab Project Deploy Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: 42,\n name: 'tokenname',\n scopes: ['read_registry'],\n },\n },\n ],\n }),\n },\n\n {\n description: 'Create a GitLab project deploy token with a custom username',\n example: yaml.stringify({\n steps: [\n {\n id: 'createDeployToken',\n action: 'gitlab:projectDeployToken:create',\n name: 'Create GitLab Project Deploy Token',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: 42,\n name: 'tokenname',\n username: 'tokenuser',\n scopes: ['read_registry'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;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,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,iEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,mBAAA;AAAA,UACJ,MAAA,EAAQ,kCAAA;AAAA,UACR,IAAA,EAAM,oCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,EAAA;AAAA,YACX,IAAA,EAAM,WAAA;AAAA,YACN,MAAA,EAAQ,CAAC,eAAe;AAAA;AAC1B;AACF;AACF,KACD;AAAA,GACH;AAAA,EAEA;AAAA,IACE,WAAA,EAAa,6DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,mBAAA;AAAA,UACJ,MAAA,EAAQ,kCAAA;AAAA,UACR,IAAA,EAAM,oCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,EAAA;AAAA,YACX,IAAA,EAAM,WAAA;AAAA,YACN,QAAA,EAAU,WAAA;AAAA,YACV,MAAA,EAAQ,CAAC,eAAe;AAAA;AAC1B;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabProjectMigrate.cjs.js","sources":["../../src/actions/gitlabProjectMigrate.ts"],"sourcesContent":["/*\n * Copyright 2024 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} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport { createGitlabApi } from './helpers';\nimport { examples } from './gitlabRepoPush.examples';\nimport { MigrationEntityOptions } from '@gitbeaker/rest';\n\n/**\n * Create a new action that imports a gitlab project into another gitlab project (potentially from another gitlab instance).\n *\n * @public\n */\nexport const createGitlabProjectMigrateAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'gitlab:group:migrate',\n examples,\n schema: {\n input: {\n destinationAccessToken: z =>\n z.string({\n description: `The token to use for authorization to the target GitLab'`,\n }),\n destinationUrl: z =>\n z.string({\n description: `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`,\n }),\n sourceAccessToken: z =>\n z.string({\n description: `The token to use for authorization to the source GitLab'`,\n }),\n sourceFullPath: z =>\n z.string({\n description:\n 'Full path to the project in the source Gitlab instance',\n }),\n sourceUrl: z =>\n z.string({\n description: `Accepts the format 'https://gitlab.com/'`,\n }),\n },\n output: {\n importedRepoUrl: z =>\n z.string({\n description: 'URL to the newly imported repo',\n }),\n migrationId: z =>\n z.number({\n description: 'Id of the migration that imports the project',\n }),\n },\n },\n\n async handler(ctx) {\n const {\n destinationAccessToken,\n destinationUrl,\n sourceAccessToken,\n sourceFullPath,\n sourceUrl,\n } = ctx.input;\n\n const {\n host: destinationHost,\n repo: destinationSlug,\n owner: destinationNamespace,\n } = parseRepoUrl(destinationUrl, integrations);\n\n if (!destinationNamespace) {\n throw new InputError(\n `Failed to determine target repository to migrate to. Make sure destinationUrl matches the format 'gitlab.myorg.com?repo=project_name&owner=group_name'`,\n );\n }\n\n const api = createGitlabApi({\n integrations,\n token: destinationAccessToken,\n repoUrl: destinationUrl,\n });\n\n const migrationEntity: MigrationEntityOptions[] = [\n {\n sourceType: 'project_entity',\n sourceFullPath: sourceFullPath,\n destinationSlug: destinationSlug,\n destinationNamespace: destinationNamespace,\n },\n ];\n\n const sourceConfig = {\n url: sourceUrl,\n access_token: sourceAccessToken,\n };\n\n try {\n const migrationId = await ctx.checkpoint({\n key: `create.migration.${sourceUrl}`,\n fn: async () => {\n const migrationStatus = await api.Migrations.create(\n sourceConfig,\n migrationEntity,\n );\n return migrationStatus.id;\n },\n });\n\n ctx.output(\n 'importedRepoUrl',\n `${destinationHost}/${destinationNamespace}/${destinationSlug}`,\n );\n ctx.output('migrationId', migrationId);\n } catch (e: any) {\n throw new InputError(\n `Failed to transfer repo ${sourceFullPath}. Make sure that ${sourceFullPath} exists in ${sourceUrl}, and token has enough rights.\\nError: ${e}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","createGitlabApi"],"mappings":";;;;;;;AA+
|
|
1
|
+
{"version":3,"file":"gitlabProjectMigrate.cjs.js","sources":["../../src/actions/gitlabProjectMigrate.ts"],"sourcesContent":["/*\n * Copyright 2024 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} from '@backstage/plugin-scaffolder-node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport { createGitlabApi } from './helpers';\nimport { examples } from './gitlabRepoPush.examples';\nimport { MigrationEntityOptions } from '@gitbeaker/rest';\n\n/**\n * Create a new action that imports a gitlab project into another gitlab project (potentially from another gitlab instance).\n *\n * @public\n */\nexport const createGitlabProjectMigrateAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'gitlab:group:migrate',\n examples,\n schema: {\n input: {\n destinationAccessToken: z =>\n z.string({\n description: `The token to use for authorization to the target GitLab'`,\n }),\n destinationUrl: z =>\n z.string({\n description: `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`,\n }),\n sourceAccessToken: z =>\n z.string({\n description: `The token to use for authorization to the source GitLab'`,\n }),\n sourceFullPath: z =>\n z.string({\n description:\n 'Full path to the project in the source Gitlab instance',\n }),\n sourceUrl: z =>\n z.string({\n description: `Accepts the format 'https://gitlab.com/'`,\n }),\n },\n output: {\n importedRepoUrl: z =>\n z.string({\n description: 'URL to the newly imported repo',\n }),\n migrationId: z =>\n z.number({\n description: 'Id of the migration that imports the project',\n }),\n },\n },\n\n async handler(ctx) {\n const {\n destinationAccessToken,\n destinationUrl,\n sourceAccessToken,\n sourceFullPath,\n sourceUrl,\n } = ctx.input;\n\n const {\n host: destinationHost,\n repo: destinationSlug,\n owner: destinationNamespace,\n } = parseRepoUrl(destinationUrl, integrations);\n\n if (!destinationNamespace) {\n throw new InputError(\n `Failed to determine target repository to migrate to. Make sure destinationUrl matches the format 'gitlab.myorg.com?repo=project_name&owner=group_name'`,\n );\n }\n\n const api = createGitlabApi({\n integrations,\n token: destinationAccessToken,\n repoUrl: destinationUrl,\n });\n\n const migrationEntity: MigrationEntityOptions[] = [\n {\n sourceType: 'project_entity',\n sourceFullPath: sourceFullPath,\n destinationSlug: destinationSlug,\n destinationNamespace: destinationNamespace,\n },\n ];\n\n const sourceConfig = {\n url: sourceUrl,\n access_token: sourceAccessToken,\n };\n\n try {\n const migrationId = await ctx.checkpoint({\n key: `create.migration.${sourceUrl}`,\n fn: async () => {\n const migrationStatus = await api.Migrations.create(\n sourceConfig,\n migrationEntity,\n );\n return migrationStatus.id;\n },\n });\n\n ctx.output(\n 'importedRepoUrl',\n `${destinationHost}/${destinationNamespace}/${destinationSlug}`,\n );\n ctx.output('migrationId', migrationId);\n } catch (e: any) {\n throw new InputError(\n `Failed to transfer repo ${sourceFullPath}. Make sure that ${sourceFullPath} exists in ${sourceUrl}, and token has enough rights.\\nError: ${e}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","createGitlabApi"],"mappings":";;;;;;;AA+BO,MAAM,gCAAA,GAAmC,CAAC,OAAA,KAE3C;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AAEzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,sBAAA;AAAA,cACJC,gCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,sBAAA,EAAwB,CAAA,CAAA,KACtB,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,wDAAA;AAAA,SACd,CAAA;AAAA,QACH,cAAA,EAAgB,CAAA,CAAA,KACd,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,iBAAA,EAAmB,CAAA,CAAA,KACjB,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,wDAAA;AAAA,SACd,CAAA;AAAA,QACH,cAAA,EAAgB,CAAA,CAAA,KACd,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,wCAAA;AAAA,SACd;AAAA,OACL;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,eAAA,EAAiB,CAAA,CAAA,KACf,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,WAAA,EAAa,CAAA,CAAA,KACX,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa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AA,EAAI,oBAAoB,IAAI,eAAe,CAAA;AAAA,SAC/D;AACA,QAAA,GAAA,CAAI,MAAA,CAAO,eAAe,WAAW,CAAA;AAAA,MACvC,SAAS,CAAA,EAAQ;AACf,QAAA,MAAM,IAAID,iBAAA;AAAA,UACR,CAAA,wBAAA,EAA2B,cAAc,CAAA,iBAAA,EAAoB,cAAc,cAAc,SAAS,CAAA;AAAA,OAAA,EAA0C,CAAC,CAAA;AAAA,SAC/I;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabProjectVariableCreate.cjs.js","sources":["../../src/actions/gitlabProjectVariableCreate.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 { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { VariableType } from '@gitbeaker/rest';\nimport { getClient, parseRepoUrl } from '../util';\nimport { examples } from './gitlabProjectVariableCreate.examples';\n\n/**\n * Creates a `gitlab:projectVariable:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectVariableAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectVariable:create',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `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`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n key: z =>\n z\n .string({\n description:\n 'The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed',\n })\n .regex(/^[A-Za-z0-9_]{1,255}$/),\n value: z =>\n z.string({\n description: 'The value of a variable',\n }),\n variableType: z =>\n z.string({\n description: 'Variable Type (env_var or file)',\n }),\n variableProtected: z =>\n z\n .boolean({\n description: 'Whether the variable is protected',\n })\n .default(false)\n .optional(),\n masked: z =>\n z\n .boolean({\n description: 'Whether the variable is masked',\n })\n .default(false)\n .optional(),\n raw: z =>\n z\n .boolean({\n description: 'Whether the variable is expandable',\n })\n .default(false)\n .optional(),\n environmentScope: z =>\n z\n .string({\n description: 'The environment_scope of the variable',\n })\n .default('*')\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n projectId,\n key,\n value,\n variableType,\n variableProtected = false,\n masked = false,\n raw = false,\n environmentScope = '*',\n token,\n } = ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n\n const api = getClient({ host, integrations, token });\n\n await ctx.checkpoint({\n key: `create.project.variables.${projectId}.${key}.${value}`,\n fn: async () => {\n await api.ProjectVariables.create(projectId, key, value, {\n variableType: variableType as VariableType,\n protected: variableProtected,\n masked,\n raw,\n environmentScope,\n });\n },\n });\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","getClient"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"gitlabProjectVariableCreate.cjs.js","sources":["../../src/actions/gitlabProjectVariableCreate.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 { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { VariableType } from '@gitbeaker/rest';\nimport { getClient, parseRepoUrl } from '../util';\nimport { examples } from './gitlabProjectVariableCreate.examples';\n\n/**\n * Creates a `gitlab:projectVariable:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabProjectVariableAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:projectVariable:create',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `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`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n key: z =>\n z\n .string({\n description:\n 'The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed',\n })\n .regex(/^[A-Za-z0-9_]{1,255}$/),\n value: z =>\n z.string({\n description: 'The value of a variable',\n }),\n variableType: z =>\n z.string({\n description: 'Variable Type (env_var or file)',\n }),\n variableProtected: z =>\n z\n .boolean({\n description: 'Whether the variable is protected',\n })\n .default(false)\n .optional(),\n masked: z =>\n z\n .boolean({\n description: 'Whether the variable is masked',\n })\n .default(false)\n .optional(),\n raw: z =>\n z\n .boolean({\n description: 'Whether the variable is expandable',\n })\n .default(false)\n .optional(),\n environmentScope: z =>\n z\n .string({\n description: 'The environment_scope of the variable',\n })\n .default('*')\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n projectId,\n key,\n value,\n variableType,\n variableProtected = false,\n masked = false,\n raw = false,\n environmentScope = '*',\n token,\n } = ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n\n const api = getClient({ host, integrations, token });\n\n await ctx.checkpoint({\n key: `create.project.variables.${projectId}.${key}.${value}`,\n fn: async () => {\n await api.ProjectVariables.create(projectId, key, value, {\n variableType: variableType as VariableType,\n protected: variableProtected,\n masked,\n raw,\n environmentScope,\n });\n },\n });\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","getClient"],"mappings":";;;;;;AA4BO,MAAM,iCAAA,GAAoC,CAAC,OAAA,KAE5C;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AACzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,+BAAA;AAAA,cACJC,6CAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,CAAE,MAAA,EAAO,EAAG,CAAA,CAAE,MAAA,EAAQ,CAAA,EAAG;AAAA,UAChC,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,GAAA,EAAK,CAAA,CAAA,KACH,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,CAAA,CACA,KAAA,CAAM,uBAAuB,CAAA;AAAA,QAClC,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,YAAA,EAAc,CAAA,CAAA,KACZ,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,iBAAA,EAAmB,CAAA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