@backstage/plugin-scaffolder-backend-module-gitlab 0.9.4-next.1 → 0.9.4

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/actions/gitlab.cjs.js.map +1 -1
  3. package/dist/actions/gitlab.examples.cjs.js.map +1 -1
  4. package/dist/actions/gitlabGroupEnsureExists.cjs.js.map +1 -1
  5. package/dist/actions/gitlabGroupEnsureExists.examples.cjs.js.map +1 -1
  6. package/dist/actions/gitlabIssueCreate.cjs.js.map +1 -1
  7. package/dist/actions/gitlabIssueCreate.examples.cjs.js.map +1 -1
  8. package/dist/actions/gitlabIssueEdit.cjs.js.map +1 -1
  9. package/dist/actions/gitlabIssueEdit.examples.cjs.js.map +1 -1
  10. package/dist/actions/gitlabMergeRequest.cjs.js.map +1 -1
  11. package/dist/actions/gitlabMergeRequest.examples.cjs.js.map +1 -1
  12. package/dist/actions/gitlabPipelineTrigger.cjs.js.map +1 -1
  13. package/dist/actions/gitlabPipelineTrigger.examples.cjs.js.map +1 -1
  14. package/dist/actions/gitlabProjectAccessTokenCreate.cjs.js.map +1 -1
  15. package/dist/actions/gitlabProjectAccessTokenCreate.examples.cjs.js.map +1 -1
  16. package/dist/actions/gitlabProjectDeployTokenCreate.cjs.js.map +1 -1
  17. package/dist/actions/gitlabProjectDeployTokenCreate.examples.cjs.js.map +1 -1
  18. package/dist/actions/gitlabProjectMigrate.cjs.js.map +1 -1
  19. package/dist/actions/gitlabProjectVariableCreate.cjs.js.map +1 -1
  20. package/dist/actions/gitlabProjectVariableCreate.examples.cjs.js.map +1 -1
  21. package/dist/actions/gitlabRepoPush.cjs.js.map +1 -1
  22. package/dist/actions/gitlabRepoPush.examples.cjs.js.map +1 -1
  23. package/dist/actions/helpers.cjs.js.map +1 -1
  24. package/dist/autocomplete/autocomplete.cjs.js.map +1 -1
  25. package/dist/commonGitlabConfig.cjs.js.map +1 -1
  26. package/dist/module.cjs.js.map +1 -1
  27. package/dist/util.cjs.js.map +1 -1
  28. package/package.json +9 -9
@@ -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,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ACE,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
+ {"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,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,oDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,gBAAA;AAAA,UACJ,MAAA,EAAQ,0CAAA;AAAA,UACR,IAAA,EAAM,gCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,KAAA;AAAA,YACX,GAAA,EAAK,aAAA;AAAA,YACL,KAAA,EAAO,UAAA;AAAA,YACP,YAAA,EAAc;AAAA;AAChB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,iDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,gBAAA;AAAA,UACJ,MAAA,EAAQ,0CAAA;AAAA,UACR,IAAA,EAAM,gCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,KAAA;AAAA,YACX,GAAA,EAAK,aAAA;AAAA,YACL,KAAA,EAAO,iBAAA;AAAA,YACP,YAAA,EAAc;AAAA;AAChB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,qDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,gBAAA;AAAA,UACJ,MAAA,EAAQ,0CAAA;AAAA,UACR,IAAA,EAAM,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AAAA,UACE,EAAA,EAAI,gBAAA;AAAA,UACJ,MAAA,EAAQ,+BAAA;AAAA,UACR,IAAA,EAAM,gCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,KAAA;AAAA,YACX,GAAA,EAAK,aAAA;AAAA,YACL,KAAA,EAAO,UAAA;AAAA,YACP,YAAA,EAAc,SAAA;AAAA,YACd,gBAAA,EAAkB;AAAA;AACpB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,qEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,gBAAA;AAAA,UACJ,MAAA,EAAQ,+BAAA;AAAA,UACR,IAAA,EAAM,gCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,SAAA,EAAW,KAAA;AAAA,YACX,GAAA,EAAK,aAAA;AAAA,YACL,KAAA,EAAO,UAAA;AAAA,YACP,YAAA,EAAc,SAAA;AAAA,YACd,gBAAA,EAAkB;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 path from 'path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport {\n createTemplateAction,\n parseRepoUrl,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { CommitAction } from '@gitbeaker/rest';\nimport { createGitlabApi, getErrorMessage } 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 id: 'gitlab:repo:push',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n branchName: z =>\n z.string({\n description: 'The branch name for the commit',\n }),\n commitMessage: z =>\n z.string({\n description: `The commit message`,\n }),\n sourcePath: z =>\n z\n .string({\n description:\n 'Subdirectory of working directory to copy changes from',\n })\n .optional(),\n targetPath: z =>\n z\n .string({\n description: 'Subdirectory of repository to apply changes to',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n commitAction: z =>\n z\n .enum(['create', 'update', 'delete'], {\n description:\n 'The action to be used for git commit. Defaults to create, but can be set to update or delete',\n })\n .optional(),\n },\n output: {\n projectid: z =>\n z.string({\n description: 'Gitlab Project id/Name(slug)',\n }),\n projectPath: z =>\n z.string({\n description: 'Gitlab Project path',\n }),\n commitHash: z =>\n z.string({\n description: 'The git commit hash of the commit',\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: 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 const branchExists = await ctx.checkpoint({\n key: `branch.exists.${repoID}.${branchName}`,\n fn: async () => {\n try {\n await api.Branches.show(repoID, branchName);\n return true;\n } catch (e: any) {\n if (e.cause?.response?.status !== 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. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n return false;\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. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n\n try {\n const commitId = await ctx.checkpoint({\n key: `commit.create.${repoID}.${branchName}`,\n fn: async () => {\n const commit = await api.Commits.create(\n repoID,\n branchName,\n ctx.input.commitMessage,\n actions,\n );\n return commit.id;\n },\n });\n\n ctx.output('projectid', repoID);\n ctx.output('projectPath', repoID);\n ctx.output('commitHash', commitId);\n } catch (e) {\n if (commitAction !== 'create') {\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please verify that all files you're trying to modify exist in the repository. ${getErrorMessage(\n e,\n )}`,\n );\n }\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${getErrorMessage(\n e,\n )}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","path","InputError","getErrorMessage"],"mappings":";;;;;;;;;;;;;AAkC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C,GAAK,EAAA,CAAA,cAAA,EAAiB,MAAM,CAAA,CAAA,EAAI,UAAU,CAAA,CAAA;AAAA,UAC1C,IAAI,YAAY;AACd,YAAM,MAAA,MAAA,GAAS,MAAM,GAAA,CAAI,OAAQ,CAAA,MAAA;AAAA,cAC/B,MAAA;AAAA,cACA,UAAA;AAAA,cACA,IAAI,KAAM,CAAA,aAAA;AAAA,cACV;AAAA,aACF;AACA,YAAA,OAAO,MAAO,CAAA,EAAA;AAAA;AAChB,SACD,CAAA;AAED,QAAI,GAAA,CAAA,MAAA,CAAO,aAAa,MAAM,CAAA;AAC9B,QAAI,GAAA,CAAA,MAAA,CAAO,eAAe,MAAM,CAAA;AAChC,QAAI,GAAA,CAAA,MAAA,CAAO,cAAc,QAAQ,CAAA;AAAA,eAC1B,CAAG,EAAA;AACV,QAAA,IAAI,iBAAiB,QAAU,EAAA;AAC7B,UAAA,MAAM,IAAID,iBAAA;AAAA,YACR,CAAA,0BAAA,EAA6B,UAAU,CAA0F,uFAAA,EAAAC,uBAAA;AAAA,cAC/H;AAAA,aACD,CAAA;AAAA,WACH;AAAA;AAEF,QAAA,MAAM,IAAID,iBAAA;AAAA,UACR,CAAA,0BAAA,EAA6B,UAAU,CAAwF,qFAAA,EAAAC,uBAAA;AAAA,YAC7H;AAAA,WACD,CAAA;AAAA,SACH;AAAA;AACF;AACF,GACD,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 path from 'path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { InputError } from '@backstage/errors';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport {\n createTemplateAction,\n parseRepoUrl,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { CommitAction } from '@gitbeaker/rest';\nimport { createGitlabApi, getErrorMessage } 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 id: 'gitlab:repo:push',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n branchName: z =>\n z.string({\n description: 'The branch name for the commit',\n }),\n commitMessage: z =>\n z.string({\n description: `The commit message`,\n }),\n sourcePath: z =>\n z\n .string({\n description:\n 'Subdirectory of working directory to copy changes from',\n })\n .optional(),\n targetPath: z =>\n z\n .string({\n description: 'Subdirectory of repository to apply changes to',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n commitAction: z =>\n z\n .enum(['create', 'update', 'delete'], {\n description:\n 'The action to be used for git commit. Defaults to create, but can be set to update or delete',\n })\n .optional(),\n },\n output: {\n projectid: z =>\n z.string({\n description: 'Gitlab Project id/Name(slug)',\n }),\n projectPath: z =>\n z.string({\n description: 'Gitlab Project path',\n }),\n commitHash: z =>\n z.string({\n description: 'The git commit hash of the commit',\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: 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 const branchExists = await ctx.checkpoint({\n key: `branch.exists.${repoID}.${branchName}`,\n fn: async () => {\n try {\n await api.Branches.show(repoID, branchName);\n return true;\n } catch (e: any) {\n if (e.cause?.response?.status !== 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. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n return false;\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. ${getErrorMessage(\n e,\n )}`,\n );\n }\n }\n\n try {\n const commitId = await ctx.checkpoint({\n key: `commit.create.${repoID}.${branchName}`,\n fn: async () => {\n const commit = await api.Commits.create(\n repoID,\n branchName,\n ctx.input.commitMessage,\n actions,\n );\n return commit.id;\n },\n });\n\n ctx.output('projectid', repoID);\n ctx.output('projectPath', repoID);\n ctx.output('commitHash', commitId);\n } catch (e) {\n if (commitAction !== 'create') {\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please verify that all files you're trying to modify exist in the repository. ${getErrorMessage(\n e,\n )}`,\n );\n }\n throw new InputError(\n `Committing the changes to ${branchName} failed. Please check that none of the files created by the template already exists. ${getErrorMessage(\n e,\n )}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","parseRepoUrl","createGitlabApi","resolveSafeChildPath","serializeDirectoryContents","path","InputError","getErrorMessage"],"mappings":";;;;;;;;;;;;;AAkCO,MAAM,0BAAA,GAA6B,CAAC,OAAA,KAErC;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AAEzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,kBAAA;AAAA,cACJC,gCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,aAAA,EAAe,CAAA,CAAA,KACb,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,kBAAA;AAAA,SACd,CAAA;AAAA,QACH,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,UAAA,EAAY,CAAA,CAAA,KACV,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,YAAA,EAAc,OACZ,CAAA,CACG,IAAA,CAAK,CAAC,QAAA,EAAU,QAAA,EAAU,QAAQ,CAAA,EAAG;AAAA,UACpC,WAAA,EACE;AAAA,SACH,EACA,QAAA;AAAS,OAChB;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAA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,CAAA;AAAA,WACH;AAAA,QACF;AAAA,MACF;AAEA,MAAA,IAAI;AACF,QAAA,MAAM,QAAA,GAAW,MAAM,GAAA,CAAI,UAAA,CAAW;AAAA,UACpC,GAAA,EAAK,CAAA,cAAA,EAAiB,MAAM,CAAA,CAAA,EAAI,UAAU,CAAA,CAAA;AAAA,UAC1C,IAAI,YAAY;AACd,YAAA,MAAM,MAAA,GAAS,MAAM,GAAA,CAAI,OAAA,CAAQ,MAAA;AAAA,cAC/B,MAAA;AAAA,cACA,UAAA;AAAA,cACA,IAAI,KAAA,CAAM,aAAA;AAAA,cACV;AAAA,aACF;AACA,YAAA,OAAO,MAAA,CAAO,EAAA;AAAA,UAChB;AAAA,SACD,CAAA;AAED,QAAA,GAAA,CAAI,MAAA,CAAO,aAAa,MAAM,CAAA;AAC9B,QAAA,GAAA,CAAI,MAAA,CAAO,eAAe,MAAM,CAAA;AAChC,QAAA,GAAA,CAAI,MAAA,CAAO,cAAc,QAAQ,CAAA;AAAA,MACnC,SAAS,CAAA,EAAG;AACV,QAAA,IAAI,iBAAiB,QAAA,EAAU;AAC7B,UAAA,MAAM,IAAID,iBAAA;AAAA,YACR,CAAA,0BAAA,EAA6B,UAAU,CAAA,uFAAA,EAA0FC,uBAAA;AAAA,cAC/H;AAAA,aACD,CAAA;AAAA,WACH;AAAA,QACF;AACA,QAAA,MAAM,IAAID,iBAAA;AAAA,UACR,CAAA,0BAAA,EAA6B,UAAU,CAAA,qFAAA,EAAwFC,uBAAA;AAAA,YAC7H;AAAA,WACD,CAAA;AAAA,SACH;AAAA,MACF;AAAA,IACF;AAAA,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;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
+ {"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,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,wDAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,aAAA;AAAA,UACJ,MAAA,EAAQ,kBAAA;AAAA,UACR,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,aAAA,EAAe,gBAAA;AAAA,YACf,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,0EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,aAAA;AAAA,UACJ,MAAA,EAAQ,kBAAA;AAAA,UACR,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,aAAA,EAAe,gBAAA;AAAA,YACf,UAAA,EAAY,gBAAA;AAAA,YACZ,UAAA,EAAY,KAAA;AAAA,YACZ,UAAA,EAAY;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,iEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,aAAA;AAAA,UACJ,MAAA,EAAQ,kBAAA;AAAA,UACR,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EAAS,kCAAA;AAAA,YACT,aAAA,EAAe,gBAAA;AAAA,YACf,UAAA,EAAY,gBAAA;AAAA,YACZ,YAAA,EAAc;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 { ErrorLike, InputError, isError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Gitlab } from '@gitbeaker/rest';\nimport { GitbeakerRequestError } from '@gitbeaker/requester-utils';\n\nexport function createGitlabApi(options: {\n integrations: ScmIntegrationRegistry;\n token?: string;\n repoUrl: string;\n}): InstanceType<typeof 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\ninterface GitlabError extends ErrorLike {\n // Errors from Gitlab may also include a description field that contains additional info\n description: string;\n}\n\nfunction isGitlabError(e: unknown): e is GitlabError {\n return isError(e) && 'description' in e && typeof e.description === 'string';\n}\n\nfunction isGitbeakerRequestError(e: unknown): e is GitbeakerRequestError {\n return isError(e) && e.name === 'GitbeakerRequestError';\n}\n\nexport function getErrorMessage(e: unknown): string {\n if (isGitbeakerRequestError(e) && e.cause)\n return `${e} - ${e.cause.description}`;\n if (isGitlabError(e)) return `${e} - ${e.description}`;\n return String(e);\n}\n"],"names":["parseRepoUrl","InputError","Gitlab","isError"],"mappings":";;;;;;AAqBO,SAAS,gBAAgB,OAIA,EAAA;AAC9B,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,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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 { ErrorLike, InputError, isError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Gitlab } from '@gitbeaker/rest';\nimport { GitbeakerRequestError } from '@gitbeaker/requester-utils';\n\nexport function createGitlabApi(options: {\n integrations: ScmIntegrationRegistry;\n token?: string;\n repoUrl: string;\n}): InstanceType<typeof 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\ninterface GitlabError extends ErrorLike {\n // Errors from Gitlab may also include a description field that contains additional info\n description: string;\n}\n\nfunction isGitlabError(e: unknown): e is GitlabError {\n return isError(e) && 'description' in e && typeof e.description === 'string';\n}\n\nfunction isGitbeakerRequestError(e: unknown): e is GitbeakerRequestError {\n return isError(e) && e.name === 'GitbeakerRequestError';\n}\n\nexport function getErrorMessage(e: unknown): string {\n if (isGitbeakerRequestError(e) && e.cause)\n return `${e} - ${e.cause.description}`;\n if (isGitlabError(e)) return `${e} - ${e.description}`;\n return String(e);\n}\n"],"names":["parseRepoUrl","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CAAE,KAAA;AAClC,IAAA,OAAO,CAAA,EAAG,CAAC,CAAA,GAAA,EAAM,CAAA,CAAE,MAAM,WAAW,CAAA,CAAA;AACtC,EAAA,IAAI,aAAA,CAAc,CAAC,CAAA,EAAG,OAAO,GAAG,CAAC,CAAA,GAAA,EAAM,EAAE,WAAW,CAAA,CAAA;AACpD,EAAA,OAAO,OAAO,CAAC,CAAA;AACjB;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.cjs.js","sources":["../../src/autocomplete/autocomplete.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getClient } from '../util';\n\nexport function createHandleAutocompleteRequest(options: {\n integrations: ScmIntegrationRegistry;\n}) {\n return async function handleAutocompleteRequest({\n resource,\n token,\n context,\n }: {\n resource: string;\n token: string;\n context: Record<string, string>;\n }): Promise<{\n results: {\n title?: string;\n id: string;\n }[];\n }> {\n const { integrations } = options;\n const client = getClient({\n host: context.host ?? 'gitlab.com',\n integrations,\n token,\n });\n\n switch (resource) {\n case 'groups': {\n let groups: any[] = [];\n let page = 1;\n const perPage = 100;\n let response = [];\n let continueFetch = true;\n while (continueFetch) {\n response = await client.Groups.all({\n pagination: 'offset',\n page,\n perPage,\n });\n\n groups = groups.concat(response);\n if (response.length < perPage) continueFetch = false;\n page++;\n }\n\n const result: {\n results: {\n title: string;\n id: string;\n }[];\n } = {\n results: groups.map(group => ({\n title: group.full_path,\n id: group.id.toString(),\n })),\n };\n // append also user context\n const user = await client.Users.showCurrentUser();\n result.results.push({\n title: user.username,\n id: user.id.toString(),\n });\n\n return result;\n }\n case 'repositories': {\n if (!context.id)\n throw new InputError('Missing groupId and userId context parameter');\n\n let response;\n if (\n context.id === (await client.Users.showCurrentUser())?.id.toString()\n ) {\n response = await client.Users.allProjects(context.id);\n } else {\n response = await client.Groups.allProjects(context.id);\n }\n\n return {\n results: response.map(project => ({\n title: project.name.trim(),\n id: project.path,\n })),\n };\n }\n default:\n throw new InputError(`Invalid resource: ${resource}`);\n }\n };\n}\n"],"names":["getClient","InputError"],"mappings":";;;;;AAoBO,SAAS,gCAAgC,OAE7C,EAAA;AACD,EAAA,OAAO,eAAe,yBAA0B,CAAA;AAAA,IAC9C,QAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GAUC,EAAA;AACD,IAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AACzB,IAAA,MAAM,SAASA,cAAU,CAAA;AAAA,MACvB,IAAA,EAAM,QAAQ,IAAQ,IAAA,YAAA;AAAA,MACtB,YAAA;AAAA,MACA;AAAA,KACD,CAAA;AAED,IAAA,QAAQ,QAAU;AAAA,MAChB,KAAK,QAAU,EAAA;AACb,QAAA,IAAI,SAAgB,EAAC;AACrB,QAAA,IAAI,IAAO,GAAA,CAAA;AACX,QAAA,MAAM,OAAU,GAAA,GAAA;AAChB,QAAA,IAAI,WAAW,EAAC;AAChB,QAAA,IAAI,aAAgB,GAAA,IAAA;AACpB,QAAA,OAAO,aAAe,EAAA;AACpB,UAAW,QAAA,GAAA,MAAM,MAAO,CAAA,MAAA,CAAO,GAAI,CAAA;AAAA,YACjC,UAAY,EAAA,QAAA;AAAA,YACZ,IAAA;AAAA,YACA;AAAA,WACD,CAAA;AAED,UAAS,MAAA,GAAA,MAAA,CAAO,OAAO,QAAQ,CAAA;AAC/B,UAAI,IAAA,QAAA,CAAS,MAAS,GAAA,OAAA,EAAyB,aAAA,GAAA,KAAA;AAC/C,UAAA,IAAA,EAAA;AA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AACxD,GACF;AACF;;;;"}
1
+ {"version":3,"file":"autocomplete.cjs.js","sources":["../../src/autocomplete/autocomplete.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getClient } from '../util';\n\nexport function createHandleAutocompleteRequest(options: {\n integrations: ScmIntegrationRegistry;\n}) {\n return async function handleAutocompleteRequest({\n resource,\n token,\n context,\n }: {\n resource: string;\n token: string;\n context: Record<string, string>;\n }): Promise<{\n results: {\n title?: string;\n id: string;\n }[];\n }> {\n const { integrations } = options;\n const client = getClient({\n host: context.host ?? 'gitlab.com',\n integrations,\n token,\n });\n\n switch (resource) {\n case 'groups': {\n let groups: any[] = [];\n let page = 1;\n const perPage = 100;\n let response = [];\n let continueFetch = true;\n while (continueFetch) {\n response = await client.Groups.all({\n pagination: 'offset',\n page,\n perPage,\n });\n\n groups = groups.concat(response);\n if (response.length < perPage) continueFetch = false;\n page++;\n }\n\n const result: {\n results: {\n title: string;\n id: string;\n }[];\n } = {\n results: groups.map(group => ({\n title: group.full_path,\n id: group.id.toString(),\n })),\n };\n // append also user context\n const user = await client.Users.showCurrentUser();\n result.results.push({\n title: user.username,\n id: user.id.toString(),\n });\n\n return result;\n }\n case 'repositories': {\n if (!context.id)\n throw new InputError('Missing groupId and userId context parameter');\n\n let response;\n if (\n context.id === (await client.Users.showCurrentUser())?.id.toString()\n ) {\n response = await client.Users.allProjects(context.id);\n } else {\n response = await client.Groups.allProjects(context.id);\n }\n\n return {\n results: response.map(project => ({\n title: project.name.trim(),\n id: project.path,\n })),\n };\n }\n default:\n throw new InputError(`Invalid resource: ${resource}`);\n }\n };\n}\n"],"names":["getClient","InputError"],"mappings":";;;;;AAoBO,SAAS,gCAAgC,OAAA,EAE7C;AACD,EAAA,OAAO,eAAe,yBAAA,CAA0B;AAAA,IAC9C,QAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF,EASG;AACD,IAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AACzB,IAAA,MAAM,SAASA,cAAA,CAAU;AAAA,MACvB,IAAA,EAAM,QAAQ,IAAA,IAAQ,YAAA;AAAA,MACtB,YAAA;AAAA,MACA;AAAA,KACD,CAAA;AAED,IAAA,QAAQ,QAAA;AAAU,MAChB,KAAK,QAAA,EAAU;AACb,QAAA,IAAI,SAAgB,EAAC;AACrB,QAAA,IAAI,IAAA,GAAO,CAAA;AACX,QAAA,MAAM,OAAA,GAAU,GAAA;AAChB,QAAA,IAAI,WAAW,EAAC;AAChB,QAAA,IAAI,aAAA,GAAgB,IAAA;AACpB,QAAA,OAAO,aAAA,EAAe;AACpB,UAAA,QAAA,GAAW,MAAM,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI;AAAA,YACjC,UAAA,EAAY,QAAA;AAAA,YACZ,IAAA;AAAA,YACA;AAAA,WACD,CAAA;AAED,UAAA,MAAA,GAAS,MAAA,CAAO,OAAO,QAAQ,CAAA;AAC/B,UAAA,IAAI,QAAA,CAAS,MAAA,GAAS,OAAA,EAAS,aAAA,GAAgB,KAAA;AAC/C,UAAA,IAAA,EAAA;AAAA,QACF;AAEA,QAAA,MAAM,MAAA,GAKF;AAAA,UACF,OAAA,EAAS,MAAA,CAAO,GAAA,CAAI,CAAA,KAAA,MAAU;AAAA,YAC5B,OAAO,KAAA,CAAM,SAAA;AAAA,YACb,EAAA,EAAI,KAAA,CAAM,EAAA,CAAG,QAAA;AAAS,WACxB,CAAE;AAAA,SACJ;AAEA,QAAA,MAAM,IAAA,GAAO,MAAM,MAAA,CAAO,KAAA,CAAM,eAAA,EAAgB;AAChD,QAAA,MAAA,CAAO,QAAQ,IAAA,CAAK;AAAA,UAClB,OAAO,IAAA,CAAK,QAAA;AAAA,UACZ,EAAA,EAAI,IAAA,CAAK,EAAA,CAAG,QAAA;AAAS,SACtB,CAAA;AAED,QAAA,OAAO,MAAA;AAAA,MACT;AAAA,MACA,KAAK,cAAA,EAAgB;AACnB,QAAA,IAAI,CAAC,OAAA,CAAQ,EAAA;AACX,UAAA,MAAM,IAAIC,kBAAW,8CAA8C,CAAA;AAErE,QAAA,IAAI,QAAA;AACJ,QAAA,IACE,OAAA,CAAQ,QAAQ,MAAM,MAAA,CAAO,MAAM,eAAA,EAAgB,GAAI,EAAA,CAAG,QAAA,EAAS,EACnE;AACA,UAAA,QAAA,GAAW,MAAM,MAAA,CAAO,KAAA,CAAM,WAAA,CAAY,QAAQ,EAAE,CAAA;AAAA,QACtD,CAAA,MAAO;AACL,UAAA,QAAA,GAAW,MAAM,MAAA,CAAO,MAAA,CAAO,WAAA,CAAY,QAAQ,EAAE,CAAA;AAAA,QACvD;AAEA,QAAA,OAAO;AAAA,UACL,OAAA,EAAS,QAAA,CAAS,GAAA,CAAI,CAAA,OAAA,MAAY;AAAA,YAChC,KAAA,EAAO,OAAA,CAAQ,IAAA,CAAK,IAAA,EAAK;AAAA,YACzB,IAAI,OAAA,CAAQ;AAAA,WACd,CAAE;AAAA,SACJ;AAAA,MACF;AAAA,MACA;AACE,QAAA,MAAM,IAAIA,iBAAA,CAAW,CAAA,kBAAA,EAAqB,QAAQ,CAAA,CAAE,CAAA;AAAA;AACxD,EACF,CAAA;AACF;;;;"}
@@ -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":";;;;AAkB2BA,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;;;;;;"}
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":";;;;AAkB2BA,MAAE,MAAA,CAAO;AAAA,EAClC,SAASA,KAAA,CAAE,MAAA,CAAO,EAAE,WAAA,EAAa,uBAAuB,CAAA;AAAA,EACxD,KAAA,EAAOA,MACJ,MAAA,CAAO,EAAE,aAAa,8CAAA,EAAgD,EACtE,QAAA;AACL,CAAC;AAIM,MAAM,yBAAA,GAA4B;AAAA,EACvC,OAAA,EAAS,uDAAA;AAAA,EACT,KAAA,EAAO;AACT;AAOO,IAAK,SAAA,qBAAAC,UAAAA,KAAL;AACL,EAAAA,WAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,WAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,WAAA,MAAA,CAAA,GAAO,WAAA;AACP,EAAAA,WAAA,MAAA,CAAA,GAAO,MAAA;AAJG,EAAA,OAAAA,UAAAA;AAAA,CAAA,EAAA,SAAA,IAAA,EAAA;AAYL,IAAK,eAAA,qBAAAC,gBAAAA,KAAL;AACL,EAAAA,iBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,iBAAA,QAAA,CAAA,GAAS,QAAA;AAFC,EAAA,OAAAA,gBAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA;;;;;;"}
@@ -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 {\n scaffolderActionsExtensionPoint,\n scaffolderAutocompleteExtensionPoint,\n} 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';\nimport { createGitlabProjectMigrateAction } from './actions/gitlabProjectMigrate';\nimport { createHandleAutocompleteRequest } from './autocomplete/autocomplete';\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 autocomplete: scaffolderAutocompleteExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, autocomplete, config }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createGitlabGroupEnsureExistsAction({ integrations }),\n createGitlabProjectMigrateAction({ 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 autocomplete.addAutocompleteProvider({\n id: 'gitlab',\n handler: createHandleAutocompleteRequest({ integrations }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","scaffolderAutocompleteExtensionPoint","coreServices","autocomplete","ScmIntegrations","createGitlabGroupEnsureExistsAction","createGitlabProjectMigrateAction","createGitlabIssueAction","createGitlabProjectAccessTokenAction","createGitlabProjectDeployTokenAction","createGitlabProjectVariableAction","createGitlabRepoPushAction","editGitlabIssueAction","createPublishGitlabAction","createPublishGitlabMergeRequestAction","createTriggerGitlabPipelineAction","createHandleAutocompleteRequest"],"mappings":";;;;;;;;;;;;;;;;;;;AA2CO,MAAM,eAAeA,oCAAoB,CAAA;AAAA,EAC9C,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EA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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 {\n scaffolderActionsExtensionPoint,\n scaffolderAutocompleteExtensionPoint,\n} 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';\nimport { createGitlabProjectMigrateAction } from './actions/gitlabProjectMigrate';\nimport { createHandleAutocompleteRequest } from './autocomplete/autocomplete';\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 autocomplete: scaffolderAutocompleteExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, autocomplete, config }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createGitlabGroupEnsureExistsAction({ integrations }),\n createGitlabProjectMigrateAction({ 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 autocomplete.addAutocompleteProvider({\n id: 'gitlab',\n handler: createHandleAutocompleteRequest({ integrations }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","scaffolderAutocompleteExtensionPoint","coreServices","autocomplete","ScmIntegrations","createGitlabGroupEnsureExistsAction","createGitlabProjectMigrateAction","createGitlabIssueAction","createGitlabProjectAccessTokenAction","createGitlabProjectDeployTokenAction","createGitlabProjectVariableAction","createGitlabRepoPushAction","editGitlabIssueAction","createPublishGitlabAction","createPublishGitlabMergeRequestAction","createTriggerGitlabPipelineAction","createHandleAutocompleteRequest"],"mappings":";;;;;;;;;;;;;;;;;;;AA2CO,MAAM,eAAeA,oCAAA,CAAoB;AAAA,EAC9C,QAAA,EAAU,YAAA;AAAA,EACV,QAAA,EAAU,QAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAa,EAAG;AACzB,IAAA,YAAA,CAAa;AAAA,MACX,IAAA,EAAM;AAAA,QACJ,UAAA,EAAYC,qCAAA;AAAA,QACZ,YAAA,EAAcC,0CAAA;AAAA,QACd,QAAQC,6BAAA,CAAa;AAAA,OACvB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,gBAAYC,cAAA,EAAc,QAAO,EAAG;AAC/C,QAAA,MAAM,YAAA,GAAeC,2BAAA,CAAgB,UAAA,CAAW,MAAM,CAAA;AAEtD,QAAA,UAAA,CAAW,UAAA;AAAA,UACTC,2DAAA,CAAoC,EAAE,YAAA,EAAc,CAAA;AAAA,UACpDC,qDAAA,CAAiC,EAAE,YAAA,EAAc,CAAA;AAAA,UACjDC,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,gCAAA,CAA0B,EAAE,MAAA,EAAQ,YAAA,EAAc,CAAA;AAAA,UAClDC,wDAAA,CAAsC,EAAE,YAAA,EAAc,CAAA;AAAA,UACtDC,uDAAA,CAAkC,EAAE,YAAA,EAAc;AAAA,SACpD;AAEA,QAAAZ,cAAA,CAAa,uBAAA,CAAwB;AAAA,UACnC,EAAA,EAAI,QAAA;AAAA,UACJ,OAAA,EAASa,4CAAA,CAAgC,EAAE,YAAA,EAAc;AAAA,SAC1D,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"util.cjs.js","sources":["../src/util.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 {\n GitLabIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Gitlab, GroupSchema } from '@gitbeaker/rest';\nimport { z } from 'zod';\nimport commonGitlabConfig from './commonGitlabConfig';\n\nexport const parseRepoHost = (repoUrl: string): string => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n return parsed.host;\n};\n\nexport const getToken = (\n config: z.infer<typeof commonGitlabConfig>,\n integrations: ScmIntegrationRegistry,\n): { token: string; integrationConfig: GitLabIntegration } => {\n const host = parseRepoHost(config.repoUrl);\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 const token = config.token || integrationConfig.config.token!;\n\n return { token: token, integrationConfig: integrationConfig };\n};\n\nexport type RepoSpec = {\n repo: string;\n host: string;\n owner?: string;\n};\n\nexport const parseRepoUrl = (\n repoUrl: string,\n integrations: ScmIntegrationRegistry,\n): RepoSpec => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n const host = parsed.host;\n const owner = parsed.searchParams.get('owner') ?? undefined;\n const repo: string = parsed.searchParams.get('repo')!;\n\n const type = integrations.byHost(host)?.type;\n\n if (!type) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n return { host, owner, repo };\n};\n\nexport function getClient(props: {\n host: string;\n token?: string;\n integrations: ScmIntegrationRegistry;\n}): InstanceType<typeof Gitlab> {\n const { host, token, integrations } = props;\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 const { config } = integrationConfig;\n\n if (!config.token && !token) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const requestToken = token || config.token!;\n const tokenType = token ? 'oauthToken' : 'token';\n\n const gitlabOptions: any = {\n host: config.baseUrl,\n };\n\n gitlabOptions[tokenType] = requestToken;\n return new Gitlab(gitlabOptions);\n}\n\nexport function convertDate(\n inputDate: string | undefined,\n defaultDate: string,\n) {\n try {\n return inputDate\n ? new Date(inputDate).toISOString()\n : new Date(defaultDate).toISOString();\n } catch (error) {\n throw new InputError(`Error converting input date - ${error}`);\n }\n}\n\nexport async function getTopLevelParentGroup(\n client: InstanceType<typeof Gitlab>,\n groupId: number,\n): Promise<GroupSchema> {\n try {\n const topParentGroup = await client.Groups.show(groupId);\n if (topParentGroup.parent_id) {\n return getTopLevelParentGroup(client, topParentGroup.parent_id as number);\n }\n return topParentGroup as GroupSchema;\n } catch (error: any) {\n throw new InputError(\n `Error finding top-level parent group ID: ${error.message}`,\n );\n }\n}\n\nexport async function checkEpicScope(\n client: InstanceType<typeof Gitlab>,\n projectId: number,\n epicId: number,\n) {\n try {\n // If project exists, get the top level group id\n const project = await client.Projects.show(projectId);\n if (!project) {\n throw new InputError(\n `Project with id ${projectId} not found. Check your GitLab instance.`,\n );\n }\n const topParentGroup = await getTopLevelParentGroup(\n client,\n project.namespace.id,\n );\n if (!topParentGroup) {\n throw new InputError(`Couldn't find a suitable top-level parent group.`);\n }\n // Get the epic\n const epic = (await client.Epics.all(topParentGroup.id)).find(\n (x: any) => x.id === epicId,\n );\n if (!epic) {\n throw new InputError(\n `Epic with id ${epicId} not found in the top-level parent group ${topParentGroup.name}.`,\n );\n }\n\n const epicGroup = await client.Groups.show(epic.group_id as number);\n const projectNamespace: string = project.path_with_namespace as string;\n return projectNamespace.startsWith(epicGroup.full_path as string);\n } catch (error: any) {\n throw new InputError(`Could not find epic scope: ${error.message}`);\n }\n}\n"],"names":["InputError","Gitlab"],"mappings":";;;;;AAyBa,MAAA,aAAA,GAAgB,CAAC,OAA4B,KAAA;AACxD,EAAI,IAAA,MAAA;AACJ,EAAI,IAAA;AACF,IAAA,MAAA,GAAS,IAAI,GAAA,CAAI,CAAW,QAAA,EAAA,OAAO,CAAE,CAAA,CAAA;AAAA,WAC9B,KAAO,EAAA;AACd,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR,CAAA,0CAAA,EAA6C,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA;AAAA,KAChE;AAAA;AAEF,EAAA,OAAO,MAAO,CAAA,IAAA;AAChB;AAEa,MAAA,QAAA,GAAW,CACtB,MAAA,EACA,YAC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;AACzC,IAAO,OAAA,gBAAA,CAAiB,UAAW,CAAA,SAAA,CAAU,SAAmB,CAAA;AAAA,WACzD,KAAY,EAAA;AACnB,IAAA,MAAM,IAAIA,iBAAA,CAAW,CAA8B,2BAAA,EAAA,KAAA,CAAM,OAAO,CAAE,CAAA,CAAA;AAAA;AAEtE;;;;;;;;;;"}
1
+ {"version":3,"file":"util.cjs.js","sources":["../src/util.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 {\n GitLabIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { Gitlab, GroupSchema } from '@gitbeaker/rest';\nimport { z } from 'zod';\nimport commonGitlabConfig from './commonGitlabConfig';\n\nexport const parseRepoHost = (repoUrl: string): string => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n return parsed.host;\n};\n\nexport const getToken = (\n config: z.infer<typeof commonGitlabConfig>,\n integrations: ScmIntegrationRegistry,\n): { token: string; integrationConfig: GitLabIntegration } => {\n const host = parseRepoHost(config.repoUrl);\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 const token = config.token || integrationConfig.config.token!;\n\n return { token: token, integrationConfig: integrationConfig };\n};\n\nexport type RepoSpec = {\n repo: string;\n host: string;\n owner?: string;\n};\n\nexport const parseRepoUrl = (\n repoUrl: string,\n integrations: ScmIntegrationRegistry,\n): RepoSpec => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n const host = parsed.host;\n const owner = parsed.searchParams.get('owner') ?? undefined;\n const repo: string = parsed.searchParams.get('repo')!;\n\n const type = integrations.byHost(host)?.type;\n\n if (!type) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n return { host, owner, repo };\n};\n\nexport function getClient(props: {\n host: string;\n token?: string;\n integrations: ScmIntegrationRegistry;\n}): InstanceType<typeof Gitlab> {\n const { host, token, integrations } = props;\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 const { config } = integrationConfig;\n\n if (!config.token && !token) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const requestToken = token || config.token!;\n const tokenType = token ? 'oauthToken' : 'token';\n\n const gitlabOptions: any = {\n host: config.baseUrl,\n };\n\n gitlabOptions[tokenType] = requestToken;\n return new Gitlab(gitlabOptions);\n}\n\nexport function convertDate(\n inputDate: string | undefined,\n defaultDate: string,\n) {\n try {\n return inputDate\n ? new Date(inputDate).toISOString()\n : new Date(defaultDate).toISOString();\n } catch (error) {\n throw new InputError(`Error converting input date - ${error}`);\n }\n}\n\nexport async function getTopLevelParentGroup(\n client: InstanceType<typeof Gitlab>,\n groupId: number,\n): Promise<GroupSchema> {\n try {\n const topParentGroup = await client.Groups.show(groupId);\n if (topParentGroup.parent_id) {\n return getTopLevelParentGroup(client, topParentGroup.parent_id as number);\n }\n return topParentGroup as GroupSchema;\n } catch (error: any) {\n throw new InputError(\n `Error finding top-level parent group ID: ${error.message}`,\n );\n }\n}\n\nexport async function checkEpicScope(\n client: InstanceType<typeof Gitlab>,\n projectId: number,\n epicId: number,\n) {\n try {\n // If project exists, get the top level group id\n const project = await client.Projects.show(projectId);\n if (!project) {\n throw new InputError(\n `Project with id ${projectId} not found. Check your GitLab instance.`,\n );\n }\n const topParentGroup = await getTopLevelParentGroup(\n client,\n project.namespace.id,\n );\n if (!topParentGroup) {\n throw new InputError(`Couldn't find a suitable top-level parent group.`);\n }\n // Get the epic\n const epic = (await client.Epics.all(topParentGroup.id)).find(\n (x: any) => x.id === epicId,\n );\n if (!epic) {\n throw new InputError(\n `Epic with id ${epicId} not found in the top-level parent group ${topParentGroup.name}.`,\n );\n }\n\n const epicGroup = await client.Groups.show(epic.group_id as number);\n const projectNamespace: string = project.path_with_namespace as string;\n return projectNamespace.startsWith(epicGroup.full_path as string);\n } catch (error: any) {\n throw new InputError(`Could not find epic scope: ${error.message}`);\n }\n}\n"],"names":["InputError","Gitlab"],"mappings":";;;;;AAyBO,MAAM,aAAA,GAAgB,CAAC,OAAA,KAA4B;AACxD,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAA,GAAS,IAAI,GAAA,CAAI,CAAA,QAAA,EAAW,OAAO,CAAA,CAAE,CAAA;AAAA,EACvC,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR,CAAA,0CAAA,EAA6C,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA;AAAA,KAChE;AAAA,EACF;AACA,EAAA,OAAO,MAAA,CAAO,IAAA;AAChB;AAEO,MAAM,QAAA,GAAW,CACtB,MAAA,EACA,YAAA,KAC4D;AAC5D,EAAA,MAAM,IAAA,GAAO,aAAA,CAAc,MAAA,CAAO,OAAO,CAAA;AACzC,EAAA,MAAM,iBAAA,GAAoB,YAAA,CAAa,MAAA,CAAO,MAAA,CAAO,IAAI,CAAA;AAEzD,EAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR,kDAAkD,IAAI,CAAA,uCAAA;AAAA,KACxD;AAAA,EACF;AAEA,EAAA,MAAM,KAAA,GAAQ,M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
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-gitlab",
3
- "version": "0.9.4-next.1",
3
+ "version": "0.9.4",
4
4
  "backstage": {
5
5
  "role": "backend-plugin-module",
6
6
  "pluginId": "scaffolder",
@@ -53,11 +53,11 @@
53
53
  "test": "backstage-cli package test"
54
54
  },
55
55
  "dependencies": {
56
- "@backstage/backend-plugin-api": "1.4.2-next.0",
57
- "@backstage/config": "1.3.3",
58
- "@backstage/errors": "1.2.7",
59
- "@backstage/integration": "1.17.1",
60
- "@backstage/plugin-scaffolder-node": "0.11.0-next.0",
56
+ "@backstage/backend-plugin-api": "^1.4.2",
57
+ "@backstage/config": "^1.3.3",
58
+ "@backstage/errors": "^1.2.7",
59
+ "@backstage/integration": "^1.17.1",
60
+ "@backstage/plugin-scaffolder-node": "^0.11.0",
61
61
  "@gitbeaker/requester-utils": "^41.2.0",
62
62
  "@gitbeaker/rest": "^41.2.0",
63
63
  "luxon": "^3.0.0",
@@ -66,8 +66,8 @@
66
66
  "zod": "^3.22.4"
67
67
  },
68
68
  "devDependencies": {
69
- "@backstage/backend-test-utils": "1.7.1-next.0",
70
- "@backstage/cli": "0.34.0-next.2",
71
- "@backstage/plugin-scaffolder-node-test-utils": "0.3.2-next.0"
69
+ "@backstage/backend-test-utils": "^1.8.0",
70
+ "@backstage/cli": "^0.34.0",
71
+ "@backstage/plugin-scaffolder-node-test-utils": "^0.3.2"
72
72
  }
73
73
  }