@backstage/plugin-scaffolder-backend-module-gitlab 0.6.1-next.0 → 0.6.1-next.2
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 +22 -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.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/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/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 +6 -6
|
@@ -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 { Gitlab, Types } from '@gitbeaker/core';\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 } 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: Gitlab,\n logger: LoggerService,\n remoteFiles: Types.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\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 repoUrl: string;\n title: string;\n description: string;\n branchName: string;\n targetBranchName?: string;\n sourcePath?: string;\n targetPath?: string;\n token?: string;\n commitAction?: 'create' | 'delete' | 'update' | 'skip' | 'auto';\n /** @deprecated projectID passed as query parameters in the repoUrl */\n projectid?: string;\n removeSourceBranch?: boolean;\n assignee?: string;\n }>({\n id: 'publish:gitlab:merge-request',\n examples,\n schema: {\n input: {\n required: ['repoUrl', 'branchName'],\n type: 'object',\n properties: {\n repoUrl: {\n type: 'string',\n title: 'Repository Location',\n description: `\\\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 },\n /** @deprecated projectID is passed as query parameters in the repoUrl */\n projectid: {\n type: 'string',\n title: 'projectid',\n description: 'Project ID/Name(slug) of the Gitlab Project',\n },\n title: {\n type: 'string',\n title: 'Merge Request Name',\n description: 'The name for the merge request',\n },\n description: {\n type: 'string',\n title: 'Merge Request Description',\n description: 'The description of the merge request',\n },\n branchName: {\n type: 'string',\n title: 'Source Branch Name',\n description: 'The source branch name of the merge request',\n },\n targetBranchName: {\n type: 'string',\n title: 'Target Branch Name',\n description: 'The target branch name of the merge request',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description: `\\\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 },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitLab',\n },\n commitAction: {\n title: 'Commit action',\n type: 'string',\n enum: ['create', 'update', 'delete', 'auto'],\n description: `\\\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 },\n removeSourceBranch: {\n title: 'Delete source branch',\n type: 'boolean',\n description:\n 'Option to delete source branch once the MR has been merged. Default: false',\n },\n assignee: {\n title: 'Merge Request Assignee',\n type: 'string',\n description: 'User this merge request will be assigned to',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n targetBranchName: {\n title: 'Target branch name of the merge request',\n type: 'string',\n },\n projectid: {\n title: 'Gitlab Project id/Name(slug)',\n type: 'string',\n },\n projectPath: {\n title: 'Gitlab Project path',\n type: 'string',\n },\n mergeRequestUrl: {\n title: 'MergeRequest(MR) URL',\n type: 'string',\n description: 'Link to the merge request in GitLab',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n assignee,\n branchName,\n targetBranchName,\n description,\n repoUrl,\n removeSourceBranch,\n targetPath,\n sourcePath,\n title,\n token,\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 = undefined;\n\n if (assignee !== undefined) {\n try {\n const assigneeUser = await api.Users.username(assignee);\n assigneeId = assigneeUser[0].id;\n } catch (e) {\n ctx.logger.warn(\n `Failed to find gitlab user id for ${assignee}: ${e}. Proceeding with MR creation without an assignee.`,\n );\n }\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\n const { default_branch: defaultBranch } = projects;\n targetBranch = defaultBranch!;\n }\n\n let remoteFiles: Types.RepositoryTreeSchema[] = [];\n if ((ctx.input.commitAction ?? 'auto') === 'auto') {\n try {\n remoteFiles = await api.Repositories.tree(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}) : ${e}`,\n );\n }\n }\n const actions: Types.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: Types.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: boolean;\n if (actions.length) {\n createBranch = true;\n } else {\n try {\n await api.Branches.show(repoID, branchName);\n createBranch = false;\n ctx.logger.info(\n `Using existing branch ${branchName} without modification.`,\n );\n } catch (e) {\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}'. ${e}`,\n );\n }\n }\n if (actions.length) {\n try {\n await api.Commits.create(repoID, branchName, title, actions);\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. ${e}`,\n );\n }\n }\n try {\n const mergeRequestUrl = await api.MergeRequests.create(\n repoID,\n branchName,\n String(targetBranch),\n title,\n {\n description,\n removeSourceBranch: removeSourceBranch ? removeSourceBranch : false,\n assigneeId,\n },\n ).then((mergeRequest: { web_url: string }) => {\n return mergeRequest.web_url;\n });\n ctx.output('projectid', repoID);\n ctx.output('targetBranchName', targetBranch);\n ctx.output('projectPath', repoID);\n ctx.output('mergeRequestUrl', mergeRequestUrl);\n } catch (e) {\n throw new InputError(`Merge request creation failed${e}`);\n }\n },\n });\n};\n"],"names":["createHash","path","createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","InputError"],"mappings":";;;;;;;;;;;;;;AAkCA,SAAS,cAAc,IAA8B,EAAA;AACnD,EAAM,MAAA,IAAA,GAAOA,kBAAW,QAAQ,CAAA,CAAA;AAChC,EAAK,IAAA,CAAA,MAAA,CAAO,KAAK,OAAO,CAAA,CAAA;AACxB,EAAO,OAAA,IAAA,CAAK,OAAO,KAAK,CAAA,CAAA;AAC1B,CAAA;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,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,MAAA;AAAA,SACT,CAAA;AACA,QAAA,IAAI,aAAc,CAAA,QAAA,CAAS,IAAI,CAAA,KAAM,WAAW,cAAgB,EAAA;AAC9D,UAAO,OAAA,MAAA,CAAA;AAAA,SACT;AAAA,eACO,KAAO,EAAA;AACd,QAAO,MAAA,CAAA,IAAA;AAAA,UACL,2DAA2D,QAAQ,CAAA,CAAA;AAAA,SACrE,CAAA;AAAA,OACF;AACA,MAAO,OAAA,QAAA,CAAA;AAA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AAA,CAAA,MAAA,CAAO,eAAe,MAAM,CAAA,CAAA;AAChC,QAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA,CAAA;AAAA,eACtC,CAAG,EAAA;AACV,QAAA,MAAM,IAAIA,iBAAA,CAAW,CAAgC,6BAAA,EAAA,CAAC,CAAE,CAAA,CAAA,CAAA;AAAA,OAC1D;AAAA,KACF;AAAA,GACD,CAAA,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 { Gitlab, Types } from '@gitbeaker/core';\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 } 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: Gitlab,\n logger: LoggerService,\n remoteFiles: Types.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\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 repoUrl: string;\n title: string;\n description: string;\n branchName: string;\n targetBranchName?: string;\n sourcePath?: string;\n targetPath?: string;\n token?: string;\n commitAction?: 'create' | 'delete' | 'update' | 'skip' | 'auto';\n /** @deprecated projectID passed as query parameters in the repoUrl */\n projectid?: string;\n removeSourceBranch?: boolean;\n assignee?: string;\n }>({\n id: 'publish:gitlab:merge-request',\n examples,\n schema: {\n input: {\n required: ['repoUrl', 'branchName'],\n type: 'object',\n properties: {\n repoUrl: {\n type: 'string',\n title: 'Repository Location',\n description: `\\\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 },\n /** @deprecated projectID is passed as query parameters in the repoUrl */\n projectid: {\n type: 'string',\n title: 'projectid',\n description: 'Project ID/Name(slug) of the Gitlab Project',\n },\n title: {\n type: 'string',\n title: 'Merge Request Name',\n description: 'The name for the merge request',\n },\n description: {\n type: 'string',\n title: 'Merge Request Description',\n description: 'The description of the merge request',\n },\n branchName: {\n type: 'string',\n title: 'Source Branch Name',\n description: 'The source branch name of the merge request',\n },\n targetBranchName: {\n type: 'string',\n title: 'Target Branch Name',\n description: 'The target branch name of the merge request',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description: `\\\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 },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitLab',\n },\n commitAction: {\n title: 'Commit action',\n type: 'string',\n enum: ['create', 'update', 'delete', 'auto'],\n description: `\\\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 },\n removeSourceBranch: {\n title: 'Delete source branch',\n type: 'boolean',\n description:\n 'Option to delete source branch once the MR has been merged. Default: false',\n },\n assignee: {\n title: 'Merge Request Assignee',\n type: 'string',\n description: 'User this merge request will be assigned to',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n targetBranchName: {\n title: 'Target branch name of the merge request',\n type: 'string',\n },\n projectid: {\n title: 'Gitlab Project id/Name(slug)',\n type: 'string',\n },\n projectPath: {\n title: 'Gitlab Project path',\n type: 'string',\n },\n mergeRequestUrl: {\n title: 'MergeRequest(MR) URL',\n type: 'string',\n description: 'Link to the merge request in GitLab',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n assignee,\n branchName,\n targetBranchName,\n description,\n repoUrl,\n removeSourceBranch,\n targetPath,\n sourcePath,\n title,\n token,\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 = undefined;\n\n if (assignee !== undefined) {\n try {\n const assigneeUser = await api.Users.username(assignee);\n assigneeId = assigneeUser[0].id;\n } catch (e) {\n ctx.logger.warn(\n `Failed to find gitlab user id for ${assignee}: ${e}. Proceeding with MR creation without an assignee.`,\n );\n }\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\n const { default_branch: defaultBranch } = projects;\n targetBranch = defaultBranch!;\n }\n\n let remoteFiles: Types.RepositoryTreeSchema[] = [];\n if ((ctx.input.commitAction ?? 'auto') === 'auto') {\n try {\n remoteFiles = await api.Repositories.tree(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}) : ${e}`,\n );\n }\n }\n const actions: Types.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: Types.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: boolean;\n if (actions.length) {\n createBranch = true;\n } else {\n try {\n await api.Branches.show(repoID, branchName);\n createBranch = false;\n ctx.logger.info(\n `Using existing branch ${branchName} without modification.`,\n );\n } catch (e) {\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}'. ${e}`,\n );\n }\n }\n if (actions.length) {\n try {\n await api.Commits.create(repoID, branchName, title, actions);\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. ${e}`,\n );\n }\n }\n try {\n const mergeRequestUrl = await api.MergeRequests.create(\n repoID,\n branchName,\n String(targetBranch),\n title,\n {\n description,\n removeSourceBranch: removeSourceBranch ? removeSourceBranch : false,\n assigneeId,\n },\n ).then((mergeRequest: { web_url: string }) => {\n return mergeRequest.web_url;\n });\n ctx.output('projectid', repoID);\n ctx.output('targetBranchName', targetBranch);\n ctx.output('projectPath', repoID);\n ctx.output('mergeRequestUrl', mergeRequestUrl);\n } catch (e) {\n throw new InputError(`Merge request creation failed${e}`);\n }\n },\n });\n};\n"],"names":["createHash","path","createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","InputError"],"mappings":";;;;;;;;;;;;;;AAkCA,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,UAC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
-
{"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,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,iDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,oBAAA;AAAA,UACJ,MAAQ,EAAA,8BAAA;AAAA,UACR,IAAM,EAAA,wBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,KAAO,EAAA,kBAAA;AAAA,YACP,WAAa,EAAA,wBAAA;AAAA,YACb,UAAY,EAAA,sBAAA;AAAA,YACZ,UAAY,EAAA,QAAA;AAAA,YACZ,QAAU,EAAA
|
|
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,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,iDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,oBAAA;AAAA,UACJ,MAAQ,EAAA,8BAAA;AAAA,UACR,IAAM,EAAA,wBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,KAAO,EAAA,kBAAA;AAAA,YACP,WAAa,EAAA,wBAAA;AAAA,YACb,UAAY,EAAA,sBAAA;AAAA,YACZ,UAAY,EAAA,QAAA;AAAA,YACZ,QAAU,EAAA;AAAA;AACZ;AACF;AACF,KACD;AAAA,GACH;AAAA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A,QAAA;AAAA,YACZ,WAAa,EAAA,gBAAA;AAAA,YACb,YAAc,EAAA,QAAA;AAAA,YACd,UAAY,EAAA;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,uDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,oBAAA;AAAA,UACJ,MAAQ,EAAA,8BAAA;AAAA,UACR,IAAM,EAAA,wBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,KAAO,EAAA,kBAAA;AAAA,YACP,UAAY,EAAA,QAAA;AAAA,YACZ,WAAa,EAAA,gBAAA;AAAA,YACb,YAAc,EAAA,QAAA;AAAA,YACd,UAAY,EAAA;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,uDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,oBAAA;AAAA,UACJ,MAAQ,EAAA,8BAAA;AAAA,UACR,IAAM,EAAA,wBAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,KAAO,EAAA,kBAAA;AAAA,YACP,UAAY,EAAA,QAAA;AAAA,YACZ,WAAa,EAAA,gBAAA;AAAA,YACb,YAAc,EAAA,QAAA;AAAA,YACd,UAAY,EAAA;AAAA;AACd;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -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 { z } from 'zod';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getClient, parseRepoUrl } from '../util';\nimport { examples } from './gitlabPipelineTrigger.examples';\n\nconst pipelineInputProperties = z.object({\n projectId: z.number().describe('Project Id'),\n tokenDescription: z.string().describe('Pipeline token description'),\n branch: z.string().describe('Project branch'),\n variables: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'A object/record of key-valued strings containing the pipeline variables.',\n ),\n});\n\nconst pipelineOutputProperties = z.object({\n pipelineUrl: z.string({ description: 'Pipeline Url' }),\n});\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: commonGitlabConfig.merge(pipelineInputProperties),\n output: pipelineOutputProperties,\n },\n async handler(ctx) {\n let pipelineTokenResponse: PipelineTriggerTokenSchema | null = null;\n\n const { repoUrl, projectId, tokenDescription, token, branch, variables } =\n commonGitlabConfig.merge(pipelineInputProperties).parse(ctx.input);\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n const api = getClient({ host, integrations, token });\n\n try {\n // Create a pipeline token\n pipelineTokenResponse = (await api.PipelineTriggerTokens.create(\n projectId,\n tokenDescription,\n )) as PipelineTriggerTokenSchema;\n\n if (!pipelineTokenResponse.token) {\n ctx.logger.error('Failed to create pipeline token.');\n return;\n }\n ctx.logger.info(\n `Pipeline token id ${pipelineTokenResponse.id} created.`,\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 pipelineTokenResponse.token,\n { variables },\n )) as ExpandedPipelineSchema;\n\n if (!pipelineTriggerResponse.id) {\n ctx.logger.error('Failed to trigger pipeline.');\n return;\n }\n\n ctx.logger.info(`Pipeline id ${pipelineTriggerResponse.id} triggered.`);\n\n ctx.output('pipelineUrl', pipelineTriggerResponse.web_url);\n } catch (error: any) {\n if (error instanceof z.ZodError) {\n // Handling Zod validation errors\n throw new InputError(`Validation error: ${error.message}`, {\n validationErrors: error.errors,\n });\n }\n // Handling other errors\n throw new InputError(`Failed to trigger Pipeline: ${error.message}`);\n } finally {\n // Delete the pipeline token if it was created\n if (pipelineTokenResponse && pipelineTokenResponse.id) {\n try {\n await api.PipelineTriggerTokens.remove(\n projectId,\n pipelineTokenResponse.id,\n );\n ctx.logger.info(\n `Deleted pipeline token ${pipelineTokenResponse.id}.`,\n );\n } catch (error: any) {\n ctx.logger.error(\n `Failed to delete pipeline token id ${pipelineTokenResponse.id}.`,\n );\n }\n }\n }\n },\n });\n};\n"],"names":["z","createTemplateAction","examples","commonGitlabConfig","parseRepoUrl","getClient","InputError"],"mappings":";;;;;;;;;AA4BA,MAAM,uBAAA,GAA0BA,MAAE,MAAO,CAAA;AAAA,EACvC,SAAW,EAAAA,KAAA,CAAE,MAAO,EAAA,CAAE,SAAS,YAAY,CAAA;AAAA,EAC3C,gBAAkB,EAAAA,KAAA,CAAE,MAAO,EAAA,CAAE,SAAS,4BAA4B,CAAA;AAAA,EAClE,MAAQ,EAAAA,KAAA,CAAE,MAAO,EAAA,CAAE,SAAS,gBAAgB,CAAA;AAAA,EAC5C,SAAA,EAAWA,KACR,CAAA,MAAA,CAAOA,KAAE,CAAA,MAAA,EAAU,EAAAA,KAAA,CAAE,MAAO,EAAC,CAC7B,CAAA,QAAA,EACA,CAAA,QAAA;AAAA,IACC
|
|
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 { z } from 'zod';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getClient, parseRepoUrl } from '../util';\nimport { examples } from './gitlabPipelineTrigger.examples';\n\nconst pipelineInputProperties = z.object({\n projectId: z.number().describe('Project Id'),\n tokenDescription: z.string().describe('Pipeline token description'),\n branch: z.string().describe('Project branch'),\n variables: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'A object/record of key-valued strings containing the pipeline variables.',\n ),\n});\n\nconst pipelineOutputProperties = z.object({\n pipelineUrl: z.string({ description: 'Pipeline Url' }),\n});\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: commonGitlabConfig.merge(pipelineInputProperties),\n output: pipelineOutputProperties,\n },\n async handler(ctx) {\n let pipelineTokenResponse: PipelineTriggerTokenSchema | null = null;\n\n const { repoUrl, projectId, tokenDescription, token, branch, variables } =\n commonGitlabConfig.merge(pipelineInputProperties).parse(ctx.input);\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n const api = getClient({ host, integrations, token });\n\n try {\n // Create a pipeline token\n pipelineTokenResponse = (await api.PipelineTriggerTokens.create(\n projectId,\n tokenDescription,\n )) as PipelineTriggerTokenSchema;\n\n if (!pipelineTokenResponse.token) {\n ctx.logger.error('Failed to create pipeline token.');\n return;\n }\n ctx.logger.info(\n `Pipeline token id ${pipelineTokenResponse.id} created.`,\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 pipelineTokenResponse.token,\n { variables },\n )) as ExpandedPipelineSchema;\n\n if (!pipelineTriggerResponse.id) {\n ctx.logger.error('Failed to trigger pipeline.');\n return;\n }\n\n ctx.logger.info(`Pipeline id ${pipelineTriggerResponse.id} triggered.`);\n\n ctx.output('pipelineUrl', pipelineTriggerResponse.web_url);\n } catch (error: any) {\n if (error instanceof z.ZodError) {\n // Handling Zod validation errors\n throw new InputError(`Validation error: ${error.message}`, {\n validationErrors: error.errors,\n });\n }\n // Handling other errors\n throw new InputError(`Failed to trigger Pipeline: ${error.message}`);\n } finally {\n // Delete the pipeline token if it was created\n if (pipelineTokenResponse && pipelineTokenResponse.id) {\n try {\n await api.PipelineTriggerTokens.remove(\n projectId,\n pipelineTokenResponse.id,\n );\n ctx.logger.info(\n `Deleted pipeline token ${pipelineTokenResponse.id}.`,\n );\n } catch (error: any) {\n ctx.logger.error(\n `Failed to delete pipeline token id ${pipelineTokenResponse.id}.`,\n );\n }\n }\n }\n },\n });\n};\n"],"names":["z","createTemplateAction","examples","commonGitlabConfig","parseRepoUrl","getClient","InputError"],"mappings":";;;;;;;;;AA4BA,MA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AAA;AAAA,OACnE,SAAA;AAEA,QAAI,IAAA,qBAAA,IAAyB,sBAAsB,EAAI,EAAA;AACrD,UAAI,IAAA;AACF,YAAA,MAAM,IAAI,qBAAsB,CAAA,MAAA;AAAA,cAC9B,SAAA;AAAA,cACA,qBAAsB,CAAA;AAAA,aACxB;AACA,YAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,cACT,CAAA,uBAAA,EAA0B,sBAAsB,EAAE,CAAA,CAAA;AAAA,aACpD;AAAA,mBACO,KAAY,EAAA;AACnB,YAAA,GAAA,CAAI,MAAO,CAAA,KAAA;AAAA,cACT,CAAA,mCAAA,EAAsC,sBAAsB,EAAE,CAAA,CAAA;AAAA,aAChE;AAAA;AACF;AACF;AACF;AACF,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,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,mCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,iBAAA;AAAA,UACJ,IAAM,EAAA,0BAAA;AAAA,UACN,MAAQ,EAAA,yBAAA;AAAA,UACR,KAAO,EAAA;AAAA,YACL,GAAGC,4CAAA;AAAA,YACH,SAAW,EAAA,EAAA;AAAA,YACX,gBACE,EAAA,yDAAA;AAAA,YACF,KAAO,EAAA,mBAAA;AAAA,YACP,MAAQ,EAAA,MAAA;AAAA,YACR,SAAW,EAAA,EAAE,OAAS,EAAA,KAAA,EAAO,SAAS,KAAM
|
|
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,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,mCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,iBAAA;AAAA,UACJ,IAAM,EAAA,0BAAA;AAAA,UACN,MAAQ,EAAA,yBAAA;AAAA,UACR,KAAO,EAAA;AAAA,YACL,GAAGC,4CAAA;AAAA,YACH,SAAW,EAAA,EAAA;AAAA,YACX,gBACE,EAAA,yDAAA;AAAA,YACF,KAAO,EAAA,mBAAA;AAAA,YACP,MAAQ,EAAA,MAAA;AAAA,YACR,SAAW,EAAA,EAAE,OAAS,EAAA,KAAA,EAAO,SAAS,KAAM;AAAA;AAC9C;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,qDAAA;AAAA,IACb,OAAA,EAASD,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA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;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 { z } from 'zod';\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: z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID/Name(slug) of the Gitlab Project',\n }),\n token: z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n name: z.string({ description: 'Name of Access Key' }).optional(),\n repoUrl: z.string({ description: 'URL to gitlab instance' }),\n accessLevel: 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 .string({\n description: 'Scopes for a project access token',\n })\n .array()\n .optional(),\n expiresAt: 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: z.object({\n access_token: z.string({ description: 'Access Token' }),\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 response = await api.ProjectAccessTokens.create(\n projectId,\n name,\n scopes as AccessTokenScopes[],\n {\n expiresAt:\n expiresAt || DateTime.now().plus({ days: 365 }).toISODate()!,\n accessLevel,\n },\n );\n\n if (!response.token) {\n throw new Error('Could not create project access token');\n }\n\n ctx.output('access_token', response.token);\n },\n });\n};\n"],"names":["createTemplateAction","examples","z","getToken","InputError","Gitlab","DateTime"],"mappings":";;;;;;;;;;AAgCa,MAAA,oCAAA,GAAuC,CAAC,OAE/C,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA
|
|
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 { z } from 'zod';\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: z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID/Name(slug) of the Gitlab Project',\n }),\n token: z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n name: z.string({ description: 'Name of Access Key' }).optional(),\n repoUrl: z.string({ description: 'URL to gitlab instance' }),\n accessLevel: 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 .string({\n description: 'Scopes for a project access token',\n })\n .array()\n .optional(),\n expiresAt: 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: z.object({\n access_token: z.string({ description: 'Access Token' }),\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 response = await api.ProjectAccessTokens.create(\n projectId,\n name,\n scopes as AccessTokenScopes[],\n {\n expiresAt:\n expiresAt || DateTime.now().plus({ days: 365 }).toISODate()!,\n accessLevel,\n },\n );\n\n if (!response.token) {\n throw new Error('Could not create project access token');\n }\n\n ctx.output('access_token', response.token);\n },\n });\n};\n"],"names":["createTemplateAction","examples","z","getToken","InputError","Gitlab","DateTime"],"mappings":";;;;;;;;;;AAgCa,MAAA,oCAAA,GAAuC,CAAC,OAE/C,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AACzB,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,kCAAA;AAAA,cACJC,gDAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAA,EAAOC,MAAE,MAAO,CAAA;AAAA,QACd,SAAA,EAAWA,KAAE,CAAA,KAAA,CAAM,CAACA,KAAA,CAAE,QAAU,EAAAA,KAAA,CAAE,MAAO,EAAC,CAAG,EAAA;AAAA,UAC3C,WAAa,EAAA;AAAA,SACd,CAAA;AAAA,QACD,KAAA,EAAOA,MACJ,MAAO,CAAA;AAAA,UACN,WAAa,EAAA;AAAA,SACd,EACA,QAAS,EAAA;AAAA,QACZ,IAAA,EAAMA,MAAE,MAAO,CAAA,EAAE,aAAa,oBAAqB,EAAC,EAAE,QAAS,EAAA;AAAA,QAC/D,SAASA,KAAE,CAAA,MAAA,CAAO,EAAE,WAAA,EAAa,0BAA0B,CAAA;AAAA,QAC3D,WAAA,EAAaA,MACV,MAAO,CAAA;AAAA,UACN,WACE,EAAA;AAAA,SACH,EACA,QAAS,EAAA;AAAA,QACZ,MAAA,EAAQA,MACL,MAAO,CAAA;AAAA,UACN,WAAa,EAAA;AAAA,SACd,CAAA,CACA,KAAM,EAAA,CACN,QAAS,EAAA;AAAA,QAC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AAA,GAAW,MAAM,GAAA,CAAI,mBAAoB,CAAA,MAAA;AAAA,QAC7C,SAAA;AAAA,QACA,IAAA;AAAA,QACA,MAAA;AAAA,QACA;AAAA,UACE,SAAA,EACE,SAAa,IAAAC,cAAA,CAAS,GAAI,EAAA,CAAE,IAAK,CAAA,EAAE,IAAM,EAAA,GAAA,EAAK,CAAA,CAAE,SAAU,EAAA;AAAA,UAC5D;AAAA;AACF,OACF;AAEA,MAAI,IAAA,CAAC,SAAS,KAAO,EAAA;AACnB,QAAM,MAAA,IAAI,MAAM,uCAAuC,CAAA;AAAA;AAGzD,MAAI,GAAA,CAAA,MAAA,CAAO,cAAgB,EAAA,QAAA,CAAS,KAAK,CAAA;AAAA;AAC3C,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,KAAA;AAAA,WACb;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;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,CAAA;AAAA,WAC9C;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;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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AA,EACA;AAAA,IACE,WACE,EAAA,mFAAA;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,kCAAA;AAAA,YACT,SAAW,EAAA,QAAA;AAAA,YACX,IAAM,EAAA,iBAAA;AAAA,WACR;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;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,QAAA;AAAA,WACb;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AACF;;;;"}
|
|
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;AAA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,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,QAAA;AAAA,YACX,IAAM,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 +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 } from '@gitbeaker/core/dist/types/templates/ResourceDeployTokens';\nimport { Gitlab } from '@gitbeaker/node';\nimport { z } from 'zod';\nimport commonGitlabConfig from '../commonGitlabConfig';\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: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n name: z.string({ description: 'Deploy Token Name' }),\n username: z\n .string({ description: 'Deploy Token Username' })\n .optional(),\n scopes: z.array(z.string(), { description: 'Scopes' }).optional(),\n }),\n ),\n output: z.object({\n deploy_token: z.string({ description: 'Deploy Token' }),\n user: z.string({ description: 'User' }),\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 const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n const deployToken = await api.ProjectDeployTokens.add(\n projectId,\n name,\n scopes as DeployTokenScope[],\n {\n username: username,\n },\n );\n\n if (!deployToken.hasOwnProperty('token')) {\n throw new InputError(`No deploy_token given from gitlab instance`);\n }\n\n ctx.output('deploy_token', deployToken.token as string);\n ctx.output('user', deployToken.username);\n },\n });\n};\n"],"names":["createTemplateAction","examples","commonGitlabConfig","z","getToken","Gitlab","InputError"],"mappings":";;;;;;;;;;AAgCa,MAAA,oCAAA,GAAuC,CAAC,OAE/C,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA
|
|
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 } from '@gitbeaker/core/dist/types/templates/ResourceDeployTokens';\nimport { Gitlab } from '@gitbeaker/node';\nimport { z } from 'zod';\nimport commonGitlabConfig from '../commonGitlabConfig';\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: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n name: z.string({ description: 'Deploy Token Name' }),\n username: z\n .string({ description: 'Deploy Token Username' })\n .optional(),\n scopes: z.array(z.string(), { description: 'Scopes' }).optional(),\n }),\n ),\n output: z.object({\n deploy_token: z.string({ description: 'Deploy Token' }),\n user: z.string({ description: 'User' }),\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 const api = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: token,\n });\n\n const deployToken = await api.ProjectDeployTokens.add(\n projectId,\n name,\n scopes as DeployTokenScope[],\n {\n username: username,\n },\n );\n\n if (!deployToken.hasOwnProperty('token')) {\n throw new InputError(`No deploy_token given from gitlab instance`);\n }\n\n ctx.output('deploy_token', deployToken.token as string);\n ctx.output('user', deployToken.username);\n },\n });\n};\n"],"names":["createTemplateAction","examples","commonGitlabConfig","z","getToken","Gitlab","InputError"],"mappings":";;;;;;;;;;AAgCa,MAAA,oCAAA,GAAuC,CAAC,OAE/C,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AACzB,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,kCAAA;AAAA,cACJC,gDAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,OAAOC,0BAAmB,CAAA,KAAA;AAAA,QACxBC,MAAE,MAAO,CAAA;AAAA,UACP,SAAA,EAAWA,KAAE,CAAA,KAAA,CAAM,CAACA,KAAA,CAAE,QAAU,EAAAA,KAAA,CAAE,MAAO,EAAC,CAAG,EAAA;AAAA,YAC3C,WAAa,EAAA;AAAA,WACd,CAAA;AAAA,UACD,MAAMA,KAAE,CAAA,MAAA,CAAO,EAAE,WAAA,EAAa,qBAAqB,CAAA;AAAA,UACnD,QAAA,EAAUA,MACP,MAAO,CAAA,EAAE,aAAa,uBAAwB,EAAC,EAC/C,QAAS,EAAA;AAAA,UACZ,MAAA,EAAQA,KAAE,CAAA,KAAA,CAAMA,KAAE,CAAA,MAAA,EAAU,EAAA,EAAE,WAAa,EAAA,QAAA,EAAU,CAAA,CAAE,QAAS;AAAA,SACjE;AAAA,OACH;AAAA,MACA,MAAA,EAAQA,MAAE,MAAO,CAAA;AAAA,QACf,cAAcA,KAAE,CAAA,MAAA,CAAO,EAAE,WAAA,EAAa,gBAAgB,CAAA;AAAA,QACtD,MAAMA,KAAE,CAAA,MAAA,CAAO,EAAE,WAAA,EAAa,QAAQ;AAAA,OACvC;AAAA,KACH;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,GAAA,CAAI,OAAO,IAAK,CAAA,CAAA,4BAAA,EAA+B,GAAI,CAAA,KAAA,CAAM,SAAS,CAAG,CAAA,CAAA,CAAA;AACrE,MAAA,MAAM,EAAE,SAAW,EAAA,IAAA,EAAM,QAAU,EAAA,MAAA,KAAW,GAAI,CAAA,KAAA;AAClD,MAAA,MAAM,EAAE,KAAO,EAAA,iBAAA,KAAsBC,aAAS,CAAA,GAAA,CAAI,OAAO,YAAY,CAAA;AAErE,MAAM,MAAA,GAAA,GAAM,IAAIC,WAAO,CAAA;AAAA,QACrB,IAAA,EAAM,kBAAkB,MAAO,CAAA,OAAA;AAAA,QAC/B;AAAA,OACD,CAAA;AAED,MAAM,MAAA,WAAA,GAAc,MAAM,GAAA,CAAI,mBAAoB,CAAA,GAAA;AAAA,QAChD,SAAA;AAAA,QACA,IAAA;AAAA,QACA,MAAA;AAAA,QACA;AAAA,UACE;AAAA;AACF,OACF;AAEA,MAAA,IAAI,CAAC,WAAA,CAAY,cAAe,CAAA,OAAO,CAAG,EAAA;AACxC,QAAM,MAAA,IAAIC,kBAAW,CAA4C,0CAAA,CAAA,CAAA;AAAA;AAGnE,MAAI,GAAA,CAAA,MAAA,CAAO,cAAgB,EAAA,WAAA,CAAY,KAAe,CAAA;AACtD,MAAI,GAAA,CAAA,MAAA,CAAO,MAAQ,EAAA,WAAA,CAAY,QAAQ,CAAA;AAAA;AACzC,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 },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project deploy token with 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 },\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 },\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 },\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,KAAA;AAAA,YACX,IAAM,EAAA
|
|
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 },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project deploy token with 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 },\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 },\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 },\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,KAAA;AAAA,YACX,IAAM,EAAA;AAAA;AACR;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,IAA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A,WAAA;AAAA,YACN,QAAU,EAAA;AAAA;AACZ;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -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 { z } from 'zod';\nimport commonGitlabConfig from '../commonGitlabConfig';\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: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n key: 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.string({ description: 'The value of a variable' }),\n variableType: z.string({\n description: 'Variable Type (env_var or file)',\n }),\n variableProtected: z\n .boolean({ description: 'Whether the variable is protected' })\n .default(false)\n .optional(),\n masked: z\n .boolean({ description: 'Whether the variable is masked' })\n .default(false)\n .optional(),\n raw: z\n .boolean({ description: 'Whether the variable is expandable' })\n .default(false)\n .optional(),\n environmentScope: z\n .string({ description: 'The environment_scope of the variable' })\n .default('*')\n .optional(),\n }),\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 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"],"names":["createTemplateAction","examples","commonGitlabConfig","z","parseRepoUrl","getClient"],"mappings":";;;;;;;;AA8Ba,MAAA,iCAAA,GAAoC,CAAC,OAE5C,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA
|
|
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 { z } from 'zod';\nimport commonGitlabConfig from '../commonGitlabConfig';\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: commonGitlabConfig.merge(\n z.object({\n projectId: z.union([z.number(), z.string()], {\n description: 'Project ID',\n }),\n key: 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.string({ description: 'The value of a variable' }),\n variableType: z.string({\n description: 'Variable Type (env_var or file)',\n }),\n variableProtected: z\n .boolean({ description: 'Whether the variable is protected' })\n .default(false)\n .optional(),\n masked: z\n .boolean({ description: 'Whether the variable is masked' })\n .default(false)\n .optional(),\n raw: z\n .boolean({ description: 'Whether the variable is expandable' })\n .default(false)\n .optional(),\n environmentScope: z\n .string({ description: 'The environment_scope of the variable' })\n .default('*')\n .optional(),\n }),\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 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"],"names":["createTemplateAction","examples","commonGitlabConfig","z","parseRepoUrl","getClient"],"mappings":";;;;;;;;AA8Ba,MAAA,iCAAA,GAAoC,CAAC,OAE5C,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AACzB,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,+BAAA;AAAA,cACJC,6CAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,OAAOC,0BAAmB,CAAA,KAAA;AAAA,QACxBC,MAAE,MAAO,CAAA;AAAA,UACP,SAAA,EAAWA,KAAE,CAAA,KAAA,CAAM,CAACA,KA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I,CAAA,KAAA;AAER,MAAA,MAAM,EAAE,IAAA,EAAS,GAAAC,iBAAA,CAAa,SAAS,YAAY,CAAA;AAEnD,MAAA,MAAM,MAAMC,cAAU,CAAA,EAAE,IAAM,EAAA,YAAA,EAAc,OAAO,CAAA;AAEnD,MAAA,MAAM,GAAI,CAAA,gBAAA,CAAiB,MAAO,CAAA,SAAA,EAAW,KAAK,KAAO,EAAA;AAAA,QACvD,YAAA;AAAA,QACA,SAAW,EAAA,iBAAA;AAAA,QACX,MAAA;AAAA,QACA,GAAA;AAAA,QACA;AAAA,OACD,CAAA;AAAA;AACH,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabProjectVariableCreate.examples.cjs.js","sources":["../../src/actions/gitlabProjectVariableCreate.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: 'Creating a GitLab project variable of type env_var',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n },\n },\n ],\n }),\n },\n {\n description: 'Creating a GitLab project variable of type file',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my-file-content',\n variableType: 'file',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable that is protected.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n variableProtected: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable with masked flag as true',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '789',\n key: 'DB_PASSWORD',\n value: 'password123',\n variableType: 'env_var',\n masked: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable that is expandable.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n raw: true,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project variable with a specific environment scope.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n environmentScope: 'production',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project variable with a wildcard environment scope.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n environmentScope: '*',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,oDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,gBAAA;AAAA,UACJ,MAAQ,EAAA,0CAAA;AAAA,UACR,IAAM,EAAA,gCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,SAAW,EAAA,KAAA;AAAA,YACX,GAAK,EAAA,aAAA;AAAA,YACL,KAAO,EAAA,UAAA;AAAA,YACP,YAAc,EAAA
|
|
1
|
+
{"version":3,"file":"gitlabProjectVariableCreate.examples.cjs.js","sources":["../../src/actions/gitlabProjectVariableCreate.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: 'Creating a GitLab project variable of type env_var',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n },\n },\n ],\n }),\n },\n {\n description: 'Creating a GitLab project variable of type file',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my-file-content',\n variableType: 'file',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable that is protected.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '456',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n variableProtected: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable with masked flag as true',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:createGitlabProjectVariableAction',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '789',\n key: 'DB_PASSWORD',\n value: 'password123',\n variableType: 'env_var',\n masked: true,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab project variable that is expandable.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n raw: true,\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project variable with a specific environment scope.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n environmentScope: 'production',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab project variable with a wildcard environment scope.',\n example: yaml.stringify({\n steps: [\n {\n id: 'createVariable',\n action: 'gitlab:projectVariable:create',\n name: 'Create GitLab Project Variable',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n projectId: '123',\n key: 'MY_VARIABLE',\n value: 'my_value',\n variableType: 'env_var',\n environmentScope: '*',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,oDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,gBAAA;AAAA,UACJ,MAAQ,EAAA,0CAAA;AAAA,UACR,IAAM,EAAA,gCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,SAAW,EAAA,KAAA;AAAA,YACX,GAAK,EAAA,aAAA;AAAA,YACL,KAAO,EAAA,UAAA;AAAA,YACP,YAAc,EAAA;AAAA;AAChB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,iDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,gBAAA;AAAA,UACJ,MAAQ,EAAA,0CAAA;AAAA,UACR,IAAM,EAAA,gCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,SAAW,EAAA,KAAA;AAAA,YACX,GAAK,EAAA,aAAA;AAAA,YACL,KAAO,EAAA,iBAAA;AAAA,YACP,YAAc,EAAA;AAAA;AAChB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,qDAAA;AAAA,IAC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;AAAA;AACP;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,gBAAA;AAAA,UACJ,MAAQ,EAAA,+BAAA;AAAA,UACR,IAAM,EAAA,gCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,SAAW,EAAA,KAAA;AAAA,YACX,GAAK,EAAA,aAAA;AAAA,YACL,KAAO,EAAA,UAAA;AAAA,YACP,YAAc,EAAA,SAAA;AAAA,YACd,gBAAkB,EAAA;AAAA;AACpB;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,gBAAA;AAAA,UACJ,MAAQ,EAAA,+BAAA;AAAA,UACR,IAAM,EAAA,gCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,SAAW,EAAA,KAAA;AAAA,YACX,GAAK,EAAA,aAAA;AAAA,YACL,KAAO,EAAA,UAAA;AAAA,YACP,YAAc,EAAA,SAAA;AAAA,YACd,gBAAkB,EAAA;AAAA;AACpB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabRepoPush.cjs.js","sources":["../../src/actions/gitlabRepoPush.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 {\n createTemplateAction,\n parseRepoUrl,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Types } from '@gitbeaker/core';\nimport path from 'path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { createGitlabApi } from './helpers';\nimport { examples } from './gitlabRepoPush.examples';\n\n/**\n * Create a new action that commits into a gitlab repository.\n *\n * @public\n */\nexport const createGitlabRepoPushAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n branchName: string;\n commitMessage: string;\n sourcePath?: string;\n targetPath?: string;\n token?: string;\n commitAction?: 'create' | 'delete' | 'update';\n }>({\n id: 'gitlab:repo:push',\n examples,\n schema: {\n input: {\n required: ['repoUrl', 'branchName', 'commitMessage'],\n type: 'object',\n properties: {\n repoUrl: {\n type: 'string',\n title: 'Repository Location',\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 branchName: {\n type: 'string',\n title: 'Source Branch Name',\n description: 'The branch name for the commit',\n },\n commitMessage: {\n type: 'string',\n title: 'Commit Message',\n description: `The commit message`,\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory to copy changes from',\n },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitLab',\n },\n commitAction: {\n title: 'Commit action',\n type: 'string',\n enum: ['create', 'update', 'delete'],\n description:\n 'The action to be used for git commit. Defaults to create.',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n projectid: {\n title: 'Gitlab Project id/Name(slug)',\n type: 'string',\n },\n projectPath: {\n title: 'Gitlab Project path',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n branchName,\n repoUrl,\n targetPath,\n sourcePath,\n token,\n commitAction,\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 fileRoot: string;\n if (sourcePath) {\n fileRoot = resolveSafeChildPath(ctx.workspacePath, sourcePath);\n } else {\n fileRoot = ctx.workspacePath;\n }\n\n const fileContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const actions: Types.CommitAction[] = fileContents.map(file => ({\n action: commitAction ?? 'create',\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 branchExists = false;\n try {\n await api.Branches.show(repoID, branchName);\n branchExists = true;\n } catch (e: any) {\n if (e.response?.statusCode !== 404) {\n throw new InputError(\n `Failed to check status of branch '${branchName}'. Please make sure that branch already exists or Backstage has permissions to create one. ${e}`,\n );\n }\n }\n\n if (!branchExists) {\n // create a branch using the default branch as ref\n try {\n const projects = await api.Projects.show(repoID);\n const { default_branch: defaultBranch } = projects;\n await api.Branches.create(repoID, branchName, String(defaultBranch));\n } catch (e) {\n throw new InputError(\n `The branch '${branchName}' was not found and creation failed with error. Please make sure that branch already exists or Backstage has permissions to create one. ${e}`,\n );\n }\n }\n\n try {\n const commit = await api.Commits.create(\n repoID,\n branchName,\n ctx.input.commitMessage,\n actions,\n );\n ctx.output('projectid', repoID);\n ctx.output('projectPath', repoID);\n ctx.output('commitHash', 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. ${e}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","path","InputError"],"mappings":";;;;;;;;;;;;;AAkCa,MAAA,0BAAA,GAA6B,CAAC,OAErC,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA,CAAA;AAEzB,EAAA,OAAOA,yCAQJ,CAAA;AAAA,IACD,EAAI,EAAA,kBAAA;AAAA,cACJC,gCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,QAAU,EAAA,CAAC,SAAW,EAAA,YAAA,EAAc,eAAe,CAAA;AAAA,QACnD,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,KAAO,EAAA,qBAAA;AAAA,YACP,WAAa,EAAA,CAAA,sJAAA,CAAA;AAAA,WACf;AAAA,UACA,UAAY,EAAA;AAAA,YACV,IAAM,EAAA,QAAA;AAAA,YACN,KAAO,EAAA,oBAAA;AAAA,YACP,WAAa,EAAA,gCAAA;AAAA,WACf;AAAA,UACA,aAAe,EAAA;AAAA,YACb,IAAM,EAAA,QAAA;AAAA,YACN,KAAO,EAAA,gBAAA;AAAA,YACP,WAAa,EAAA,CAAA,kBAAA,CAAA;AAAA,WACf;AAAA,UACA,UAAY,EAAA;AAAA,YACV,IAAM,EAAA,QAAA;AAAA,YACN,KAAO,EAAA,sBAAA;AAAA,YACP,WACE,EAAA,wDAAA;AAAA,WACJ;AAAA,UACA,UAAY,EAAA;AAAA,YACV,IAAM,EAAA,QAAA;AAAA,YACN,KAAO,EAAA,yBAAA;AAAA,YACP,WAAa,EAAA,gDAAA;AAAA,WACf;AAAA,UACA,KAAO,EAAA;AAAA,YACL,KAAO,EAAA,sBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WAAa,EAAA,8CAAA;AAAA,WACf;AAAA,UACA,YAAc,EAAA;AAAA,YACZ,KAAO,EAAA,eA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AO,QAAQ,UAAY,EAAA,MAAA,CAAO,aAAa,CAAC,CAAA,CAAA;AAAA,iBAC5D,CAAG,EAAA;AACV,UAAA,MAAM,IAAIA,iBAAA;AAAA,YACR,CAAA,YAAA,EAAe,UAAU,CAAA,wIAAA,EAA2I,CAAC,CAAA,CAAA;AAAA,WACvK,CAAA;AAAA,SACF;AAAA,OACF;AAEA,MAAI,IAAA;AACF,QAAM,MAAA,MAAA,GAAS,MAAM,GAAA,CAAI,OAAQ,CAAA,MAAA;AAAA,UAC/B,MAAA;AAAA,UACA,UAAA;AAAA,UACA,IAAI,KAAM,CAAA,aAAA;AAAA,UACV,OAAA;AAAA,SACF,CAAA;AACA,QAAI,GAAA,CAAA,MAAA,CAAO,aAAa,MAAM,CAAA,CAAA;AAC9B,QAAI,GAAA,CAAA,MAAA,CAAO,eAAe,MAAM,CAAA,CAAA;AAChC,QAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,MAAA,CAAO,EAAE,CAAA,CAAA;AAAA,eAC3B,CAAG,EAAA;AACV,QAAA,MAAM,IAAIA,iBAAA;AAAA,UACR,CAAA,0BAAA,EAA6B,UAAU,CAAA,qFAAA,EAAwF,CAAC,CAAA,CAAA;AAAA,SAClI,CAAA;AAAA,OACF;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"gitlabRepoPush.cjs.js","sources":["../../src/actions/gitlabRepoPush.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 {\n createTemplateAction,\n parseRepoUrl,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Types } from '@gitbeaker/core';\nimport path from 'path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { createGitlabApi } from './helpers';\nimport { examples } from './gitlabRepoPush.examples';\n\n/**\n * Create a new action that commits into a gitlab repository.\n *\n * @public\n */\nexport const createGitlabRepoPushAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n branchName: string;\n commitMessage: string;\n sourcePath?: string;\n targetPath?: string;\n token?: string;\n commitAction?: 'create' | 'delete' | 'update';\n }>({\n id: 'gitlab:repo:push',\n examples,\n schema: {\n input: {\n required: ['repoUrl', 'branchName', 'commitMessage'],\n type: 'object',\n properties: {\n repoUrl: {\n type: 'string',\n title: 'Repository Location',\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 branchName: {\n type: 'string',\n title: 'Source Branch Name',\n description: 'The branch name for the commit',\n },\n commitMessage: {\n type: 'string',\n title: 'Commit Message',\n description: `The commit message`,\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory to copy changes from',\n },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitLab',\n },\n commitAction: {\n title: 'Commit action',\n type: 'string',\n enum: ['create', 'update', 'delete'],\n description:\n 'The action to be used for git commit. Defaults to create.',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n projectid: {\n title: 'Gitlab Project id/Name(slug)',\n type: 'string',\n },\n projectPath: {\n title: 'Gitlab Project path',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n branchName,\n repoUrl,\n targetPath,\n sourcePath,\n token,\n commitAction,\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 fileRoot: string;\n if (sourcePath) {\n fileRoot = resolveSafeChildPath(ctx.workspacePath, sourcePath);\n } else {\n fileRoot = ctx.workspacePath;\n }\n\n const fileContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const actions: Types.CommitAction[] = fileContents.map(file => ({\n action: commitAction ?? 'create',\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 branchExists = false;\n try {\n await api.Branches.show(repoID, branchName);\n branchExists = true;\n } catch (e: any) {\n if (e.response?.statusCode !== 404) {\n throw new InputError(\n `Failed to check status of branch '${branchName}'. Please make sure that branch already exists or Backstage has permissions to create one. ${e}`,\n );\n }\n }\n\n if (!branchExists) {\n // create a branch using the default branch as ref\n try {\n const projects = await api.Projects.show(repoID);\n const { default_branch: defaultBranch } = projects;\n await api.Branches.create(repoID, branchName, String(defaultBranch));\n } catch (e) {\n throw new InputError(\n `The branch '${branchName}' was not found and creation failed with error. Please make sure that branch already exists or Backstage has permissions to create one. ${e}`,\n );\n }\n }\n\n try {\n const commit = await api.Commits.create(\n repoID,\n branchName,\n ctx.input.commitMessage,\n actions,\n );\n ctx.output('projectid', repoID);\n ctx.output('projectPath', repoID);\n ctx.output('commitHash', 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. ${e}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","path","InputError"],"mappings":";;;;;;;;;;;;;AAkCa,MAAA,0BAAA,GAA6B,CAAC,OAErC,KAAA;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UACV;AAAA,SACF;AACA,QAAI,GAAA,CAAA,MAAA,CAAO,aAAa,MAAM,CAAA;AAC9B,QAAI,GAAA,CAAA,MAAA,CAAO,eAAe,MAAM,CAAA;AAChC,QAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,MAAA,CAAO,EAAE,CAAA;AAAA,eAC3B,CAAG,EAAA;AACV,QAAA,MAAM,IAAIA,iBAAA;AAAA,UACR,CAAA,0BAAA,EAA6B,UAAU,CAAA,qFAAA,EAAwF,CAAC,CAAA;AAAA,SAClI;AAAA;AACF;AACF,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabRepoPush.examples.cjs.js","sources":["../../src/actions/gitlabRepoPush.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: 'Push changes to gitlab repository with minimal changes',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Push changes to gitlab repository with a specific source and target path',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n sourcePath: 'src',\n targetPath: 'dest',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Push changes to gitlab repository with a specific commit action',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n commitAction: 'update',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,wDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,aAAA;AAAA,UACJ,MAAQ,EAAA,kBAAA;AAAA,UACR,IAAM,EAAA,mCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,aAAe,EAAA,gBAAA;AAAA,YACf,UAAY,EAAA
|
|
1
|
+
{"version":3,"file":"gitlabRepoPush.examples.cjs.js","sources":["../../src/actions/gitlabRepoPush.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: 'Push changes to gitlab repository with minimal changes',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Push changes to gitlab repository with a specific source and target path',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n sourcePath: 'src',\n targetPath: 'dest',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Push changes to gitlab repository with a specific commit action',\n example: yaml.stringify({\n steps: [\n {\n id: 'pushChanges',\n action: 'gitlab:repo:push',\n name: 'Push changes to gitlab repository',\n input: {\n repoUrl: 'gitlab.com?repo=repo&owner=owner',\n commitMessage: 'Initial Commit',\n branchName: 'feature-branch',\n commitAction: 'update',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,wDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,aAAA;AAAA,UACJ,MAAQ,EAAA,kBAAA;AAAA,UACR,IAAM,EAAA,mCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,aAAe,EAAA,gBAAA;AAAA,YACf,UAAY,EAAA;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,0EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,aAAA;AAAA,UACJ,MAAQ,EAAA,kBAAA;AAAA,UACR,IAAM,EAAA,mCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,aAAe,EAAA,gBAAA;AAAA,YACf,UAAY,EAAA,gBAAA;AAAA,YACZ,UAAY,EAAA,KAAA;AAAA,YACZ,UAAY,EAAA;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,iEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,aAAA;AAAA,UACJ,MAAQ,EAAA,kBAAA;AAAA,UACR,IAAM,EAAA,mCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,kCAAA;AAAA,YACT,aAAe,EAAA,gBAAA;AAAA,YACf,UAAY,EAAA,gBAAA;AAAA,YACZ,YAAc,EAAA;AAAA;AAChB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.cjs.js","sources":["../../src/actions/helpers.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 { parseRepoUrl } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { Gitlab } from '@gitbeaker/node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Resources } from '@gitbeaker/core';\n\nexport function createGitlabApi(options: {\n integrations: ScmIntegrationRegistry;\n token?: string;\n repoUrl: string;\n}): Resources.Gitlab {\n const { integrations, token: providedToken, repoUrl } = options;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n if (!integrationConfig.config.token && !providedToken) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const token = providedToken ?? integrationConfig.config.token!;\n const tokenType = providedToken ? 'oauthToken' : 'token';\n\n return new Gitlab({\n host: integrationConfig.config.baseUrl,\n [tokenType]: token,\n });\n}\n"],"names":["parseRepoUrl","InputError","Gitlab"],"mappings":";;;;;;AAqBO,SAAS,gBAAgB,OAIX,EAAA;AACnB,EAAA,MAAM,EAAE,YAAA,EAAc,KAAO,EAAA,aAAA,EAAe,SAAY,GAAA,OAAA
|
|
1
|
+
{"version":3,"file":"helpers.cjs.js","sources":["../../src/actions/helpers.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 { parseRepoUrl } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { Gitlab } from '@gitbeaker/node';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Resources } from '@gitbeaker/core';\n\nexport function createGitlabApi(options: {\n integrations: ScmIntegrationRegistry;\n token?: string;\n repoUrl: string;\n}): Resources.Gitlab {\n const { integrations, token: providedToken, repoUrl } = options;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n if (!integrationConfig.config.token && !providedToken) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const token = providedToken ?? integrationConfig.config.token!;\n const tokenType = providedToken ? 'oauthToken' : 'token';\n\n return new Gitlab({\n host: integrationConfig.config.baseUrl,\n [tokenType]: token,\n });\n}\n"],"names":["parseRepoUrl","InputError","Gitlab"],"mappings":";;;;;;AAqBO,SAAS,gBAAgB,OAIX,EAAA;AACnB,EAAA,MAAM,EAAE,YAAA,EAAc,KAAO,EAAA,aAAA,EAAe,SAAY,GAAA,OAAA;AAExD,EAAA,MAAM,EAAE,IAAA,EAAS,GAAAA,iCAAA,CAAa,SAAS,YAAY,CAAA;AAEnD,EAAA,MAAM,iBAAoB,GAAA,YAAA,CAAa,MAAO,CAAA,MAAA,CAAO,IAAI,CAAA;AAEzD,EAAA,IAAI,CAAC,iBAAmB,EAAA;AACtB,IAAA,MAAM,IAAIC,iBAAA;AAAA,MACR,kDAAkD,IAAI,CAAA,uCAAA;AAAA,KACxD;AAAA;AAGF,EAAA,IAAI,CAAC,iBAAA,CAAkB,MAAO,CAAA,KAAA,IAAS,CAAC,aAAe,EAAA;AACrD,IAAA,MAAM,IAAIA,iBAAA,CAAW,CAA+B,4BAAA,EAAA,IAAI,CAAE,CAAA,CAAA;AAAA;AAG5D,EAAM,MAAA,KAAA,GAAQ,aAAiB,IAAA,iBAAA,CAAkB,MAAO,CAAA,KAAA;AACxD,EAAM,MAAA,SAAA,GAAY,gBAAgB,YAAe,GAAA,OAAA;AAEjD,EAAA,OAAO,IAAIC,WAAO,CAAA;AAAA,IAChB,IAAA,EAAM,kBAAkB,MAAO,CAAA,OAAA;AAAA,IAC/B,CAAC,SAAS,GAAG;AAAA,GACd,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commonGitlabConfig.cjs.js","sources":["../src/commonGitlabConfig.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 { z } from 'zod';\n\nconst commonGitlabConfig = z.object({\n repoUrl: z.string({ description: 'Repository Location' }),\n token: z\n .string({ description: 'The token to use for authorization to GitLab' })\n .optional(),\n});\n\nexport default commonGitlabConfig;\n\nexport const commonGitlabConfigExample = {\n repoUrl: 'gitlab.com?owner=namespace-or-owner&repo=project-name',\n token: '${{ secrets.USER_OAUTH_TOKEN }}',\n};\n\n/**\n * Gitlab issue types as specified by gitlab api\n *\n * @public\n */\nexport enum IssueType {\n ISSUE = 'issue',\n INCIDENT = 'incident',\n TEST = 'test_case',\n TASK = 'task',\n}\n\n/**\n * Gitlab issue state events for modifications\n *\n * @public\n */\nexport enum IssueStateEvent {\n CLOSE = 'close',\n REOPEN = 'reopen',\n}\n"],"names":["z","IssueType","IssueStateEvent"],"mappings":";;;;;;AAkBM,MAAA,kBAAA,GAAqBA,MAAE,MAAO,CAAA;AAAA,EAClC,SAASA,KAAE,CAAA,MAAA,CAAO,EAAE,WAAA,EAAa,uBAAuB,CAAA;AAAA,EACxD,KAAA,EAAOA,MACJ,MAAO,CAAA,EAAE,aAAa,8CAA+C,EAAC,EACtE,QAAS
|
|
1
|
+
{"version":3,"file":"commonGitlabConfig.cjs.js","sources":["../src/commonGitlabConfig.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 { z } from 'zod';\n\nconst commonGitlabConfig = z.object({\n repoUrl: z.string({ description: 'Repository Location' }),\n token: z\n .string({ description: 'The token to use for authorization to GitLab' })\n .optional(),\n});\n\nexport default commonGitlabConfig;\n\nexport const commonGitlabConfigExample = {\n repoUrl: 'gitlab.com?owner=namespace-or-owner&repo=project-name',\n token: '${{ secrets.USER_OAUTH_TOKEN }}',\n};\n\n/**\n * Gitlab issue types as specified by gitlab api\n *\n * @public\n */\nexport enum IssueType {\n ISSUE = 'issue',\n INCIDENT = 'incident',\n TEST = 'test_case',\n TASK = 'task',\n}\n\n/**\n * Gitlab issue state events for modifications\n *\n * @public\n */\nexport enum IssueStateEvent {\n CLOSE = 'close',\n REOPEN = 'reopen',\n}\n"],"names":["z","IssueType","IssueStateEvent"],"mappings":";;;;;;AAkBM,MAAA,kBAAA,GAAqBA,MAAE,MAAO,CAAA;AAAA,EAClC,SAASA,KAAE,CAAA,MAAA,CAAO,EAAE,WAAA,EAAa,uBAAuB,CAAA;AAAA,EACxD,KAAA,EAAOA,MACJ,MAAO,CAAA,EAAE,aAAa,8CAA+C,EAAC,EACtE,QAAS;AACd,CAAC;AAIM,MAAM,yBAA4B,GAAA;AAAA,EACvC,OAAS,EAAA,uDAAA;AAAA,EACT,KAAO,EAAA;AACT;AAOY,IAAA,SAAA,qBAAAC,UAAL,KAAA;AACL,EAAAA,WAAA,OAAQ,CAAA,GAAA,OAAA;AACR,EAAAA,WAAA,UAAW,CAAA,GAAA,UAAA;AACX,EAAAA,WAAA,MAAO,CAAA,GAAA,WAAA;AACP,EAAAA,WAAA,MAAO,CAAA,GAAA,MAAA;AAJG,EAAAA,OAAAA,UAAAA;AAAA,CAAA,EAAA,SAAA,IAAA,EAAA;AAYA,IAAA,eAAA,qBAAAC,gBAAL,KAAA;AACL,EAAAA,iBAAA,OAAQ,CAAA,GAAA,OAAA;AACR,EAAAA,iBAAA,QAAS,CAAA,GAAA,QAAA;AAFC,EAAAA,OAAAA,gBAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA;;;;;;;"}
|
package/dist/module.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.cjs.js","sources":["../src/module.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 */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createGitlabGroupEnsureExistsAction,\n createGitlabIssueAction,\n createGitlabProjectAccessTokenAction,\n createGitlabProjectDeployTokenAction,\n createGitlabProjectVariableAction,\n createGitlabRepoPushAction,\n createPublishGitlabAction,\n createPublishGitlabMergeRequestAction,\n createTriggerGitlabPipelineAction,\n editGitlabIssueAction,\n} from './actions';\n\n/**\n * @public\n * The GitLab Module for the Scaffolder Backend\n */\nexport const gitlabModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'gitlab',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, config }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createGitlabGroupEnsureExistsAction({ integrations }),\n createGitlabIssueAction({ integrations }),\n createGitlabProjectAccessTokenAction({ integrations }),\n createGitlabProjectDeployTokenAction({ integrations }),\n createGitlabProjectVariableAction({ integrations }),\n createGitlabRepoPushAction({ integrations }),\n editGitlabIssueAction({ integrations }),\n createPublishGitlabAction({ config, integrations }),\n createPublishGitlabMergeRequestAction({ integrations }),\n createTriggerGitlabPipelineAction({ integrations }),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","coreServices","ScmIntegrations","createGitlabGroupEnsureExistsAction","createGitlabIssueAction","createGitlabProjectAccessTokenAction","createGitlabProjectDeployTokenAction","createGitlabProjectVariableAction","createGitlabRepoPushAction","editGitlabIssueAction","createPublishGitlabAction","createPublishGitlabMergeRequestAction","createTriggerGitlabPipelineAction"],"mappings":";;;;;;;;;;;;;;;;;AAsCO,MAAM,eAAeA,oCAAoB,CAAA;AAAA,EAC9C,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,QAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAgB,EAAA;AACzB,IAAa,YAAA,CAAA;AAAA,MACX,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC,qCAAA;AAAA,QACZ,QAAQC,6BAAa,CAAA
|
|
1
|
+
{"version":3,"file":"module.cjs.js","sources":["../src/module.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 */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createGitlabGroupEnsureExistsAction,\n createGitlabIssueAction,\n createGitlabProjectAccessTokenAction,\n createGitlabProjectDeployTokenAction,\n createGitlabProjectVariableAction,\n createGitlabRepoPushAction,\n createPublishGitlabAction,\n createPublishGitlabMergeRequestAction,\n createTriggerGitlabPipelineAction,\n editGitlabIssueAction,\n} from './actions';\n\n/**\n * @public\n * The GitLab Module for the Scaffolder Backend\n */\nexport const gitlabModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'gitlab',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, config }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createGitlabGroupEnsureExistsAction({ integrations }),\n createGitlabIssueAction({ integrations }),\n createGitlabProjectAccessTokenAction({ integrations }),\n createGitlabProjectDeployTokenAction({ integrations }),\n createGitlabProjectVariableAction({ integrations }),\n createGitlabRepoPushAction({ integrations }),\n editGitlabIssueAction({ integrations }),\n createPublishGitlabAction({ config, integrations }),\n createPublishGitlabMergeRequestAction({ integrations }),\n createTriggerGitlabPipelineAction({ integrations }),\n );\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","coreServices","ScmIntegrations","createGitlabGroupEnsureExistsAction","createGitlabIssueAction","createGitlabProjectAccessTokenAction","createGitlabProjectDeployTokenAction","createGitlabProjectVariableAction","createGitlabRepoPushAction","editGitlabIssueAction","createPublishGitlabAction","createPublishGitlabMergeRequestAction","createTriggerGitlabPipelineAction"],"mappings":";;;;;;;;;;;;;;;;;AAsCO,MAAM,eAAeA,oCAAoB,CAAA;AAAA,EAC9C,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,QAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAgB,EAAA;AACzB,IAAa,YAAA,CAAA;AAAA,MACX,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC,qCAAA;AAAA,QACZ,QAAQC,6BAAa,CAAA;AAAA,OACvB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,EAAY,QAAU,EAAA;AACjC,QAAM,MAAA,YAAA,GAAeC,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA;AAEtD,QAAW,UAAA,CAAA,UAAA;AAAA,UACTC,2DAAA,CAAoC,EAAE,YAAA,EAAc,CAAA;AAAA,UACpDC,yCAAA,CAAwB,EAAE,YAAA,EAAc,CAAA;AAAA,UACxCC,mEAAA,CAAqC,EAAE,YAAA,EAAc,CAAA;AAAA,UACrDC,mEAAA,CAAqC,EAAE,YAAA,EAAc,CAAA;AAAA,UACrDC,6DAAA,CAAkC,EAAE,YAAA,EAAc,CAAA;AAAA,UAClDC,yCAAA,CAA2B,EAAE,YAAA,EAAc,CAAA;AAAA,UAC3CC,qCAAA,CAAsB,EAAE,YAAA,EAAc,CAAA;AAAA,UACtCC,gCAA0B,CAAA,EAAE,MAAQ,EAAA,YAAA,EAAc,CAAA;AAAA,UAClDC,wDAAA,CAAsC,EAAE,YAAA,EAAc,CAAA;AAAA,UACtDC,uDAAA,CAAkC,EAAE,YAAA,EAAc;AAAA,SACpD;AAAA;AACF,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
|