@backstage/plugin-scaffolder-backend-module-bitbucket-cloud 0.2.12-next.0 → 0.2.13-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-bitbucket-cloud
2
2
 
3
+ ## 0.2.13-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/integration@1.18.0-next.0
9
+ - @backstage/plugin-bitbucket-cloud-common@0.3.2-next.0
10
+ - @backstage/plugin-scaffolder-node@0.11.1-next.0
11
+ - @backstage/backend-plugin-api@1.4.3-next.0
12
+
13
+ ## 0.2.12
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+ - @backstage/plugin-scaffolder-node@0.11.0
19
+ - @backstage/backend-plugin-api@1.4.2
20
+
3
21
  ## 0.2.12-next.0
4
22
 
5
23
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucketCloud.cjs.js","sources":["../../src/actions/bitbucketCloud.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 {\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\n\nimport { Config } from '@backstage/config';\nimport { getAuthorizationHeader } from './helpers';\nimport { examples } from './bitbucketCloud.examples';\n\nconst createRepository = async (opts: {\n workspace: string;\n project: string;\n repo: string;\n description?: string;\n repoVisibility: 'private' | 'public';\n mainBranch: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const {\n workspace,\n project,\n repo,\n description,\n repoVisibility,\n mainBranch,\n authorization,\n apiBaseUrl,\n } = opts;\n\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n scm: 'git',\n description: description,\n is_private: repoVisibility === 'private',\n project: { key: project },\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n let response: Response;\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to create repository, ${e}`);\n }\n\n if (response.status !== 200) {\n throw new Error(\n `Unable to create repository, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const r = await response.json();\n let remoteUrl = '';\n for (const link of r.links.clone) {\n if (link.name === 'https') {\n remoteUrl = link.href;\n }\n }\n\n // \"mainbranch.name\" cannot be set neither at create nor update of the repo\n // the first pushed branch will be set as \"main branch\" then\n const repoContentsUrl = `${r.links.html.href}/src/${mainBranch}`;\n return { remoteUrl, repoContentsUrl };\n};\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to Bitbucket Cloud.\n * @public\n */\nexport function createPublishBitbucketCloudAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction({\n id: 'publish:bitbucketCloud',\n examples,\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Bitbucket Cloud.',\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: 'Repository Location',\n }),\n description: z =>\n z\n .string({\n description: 'Repository Description',\n })\n .optional(),\n defaultBranch: z =>\n z\n .string({\n description: `Sets the default branch on the repository. The default value is 'master'`,\n })\n .optional(),\n repoVisibility: z =>\n z\n .enum(['private', 'public'], {\n description: 'Repository Visibility',\n })\n .optional(),\n gitCommitMessage: z =>\n z\n .string({\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n })\n .optional(),\n sourcePath: z =>\n z\n .string({\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'The token to use for authorization to BitBucket Cloud',\n })\n .optional(),\n signCommit: z =>\n z\n .boolean({\n description: 'Sign commit with configured PGP private key',\n })\n .optional(),\n },\n output: {\n remoteUrl: z =>\n z\n .string({\n description: 'A URL to the repository with the provider',\n })\n .optional(),\n repoContentsUrl: z =>\n z\n .string({\n description: 'A URL to the root of the repository',\n })\n .optional(),\n commitHash: z =>\n z\n .string({\n description: 'The git commit hash of the initial commit',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n defaultBranch = 'master',\n gitCommitMessage,\n repoVisibility = 'private',\n signCommit,\n } = ctx.input;\n\n const { workspace, project, repo, host } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n if (!workspace) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`,\n );\n }\n\n if (!project) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing project`,\n );\n }\n\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\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 authorization = getAuthorizationHeader(\n ctx.input.token ? { token: ctx.input.token } : integrationConfig.config,\n );\n\n const apiBaseUrl = integrationConfig.config.apiBaseUrl;\n\n const { remoteUrl, repoContentsUrl } = await ctx.checkpoint({\n key: `create.repo.${host}.${repo}`,\n fn: async () =>\n await createRepository({\n authorization,\n workspace: workspace || '',\n project,\n repo,\n repoVisibility,\n mainBranch: defaultBranch,\n description,\n apiBaseUrl,\n }),\n });\n\n const gitAuthorInfo = {\n name: config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n let auth;\n\n if (ctx.input.token) {\n auth = {\n username: 'x-token-auth',\n password: ctx.input.token,\n };\n } else {\n if (\n !integrationConfig.config.username ||\n !integrationConfig.config.appPassword\n ) {\n throw new Error(\n 'Credentials for Bitbucket Cloud integration required for this action.',\n );\n }\n\n auth = {\n username: integrationConfig.config.username,\n password: integrationConfig.config.appPassword,\n };\n }\n\n const signingKey =\n integrationConfig.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\n\n const commitHash = await ctx.checkpoint({\n key: `init.repo.and.push${host}.${repo}`,\n fn: async () => {\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(\n ctx.workspacePath,\n ctx.input.sourcePath,\n ),\n remoteUrl,\n auth,\n defaultBranch,\n logger: ctx.logger,\n commitMessage:\n gitCommitMessage ||\n config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n signingKey: signCommit ? signingKey : undefined,\n });\n return commitResult?.commitHash;\n },\n });\n\n ctx.output('commitHash', commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getAuthorizationHeader","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;AA6BA,MAAM,gBAAA,GAAmB,OAAO,IAS1B,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACE,GAAA,IAAA;AAEJ,EAAA,MAAM,OAAuB,GAAA;AAAA,IAC3B,MAAQ,EAAA,MAAA;AAAA,IACR,IAAA,EAAM,KAAK,SAAU,CAAA;AAAA,MACnB,GAAK,EAAA,KAA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kB,CAAA,MAAA,CAAO,gBACzB,IAAA,MAAA,CAAO,kBAAkB,oCAAoC,CAAA;AAC/D,MAAI,IAAA,UAAA,IAAc,CAAC,UAAY,EAAA;AAC7B,QAAA,MAAM,IAAI,KAAA;AAAA,UACR;AAAA,SACF;AAAA;AAGF,MAAM,MAAA,UAAA,GAAa,MAAM,GAAA,CAAI,UAAW,CAAA;AAAA,QACtC,GAAK,EAAA,CAAA,kBAAA,EAAqB,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,QACtC,IAAI,YAAY;AACd,UAAM,MAAA,YAAA,GAAe,MAAMC,oCAAgB,CAAA;AAAA,YACzC,GAAK,EAAAC,2CAAA;AAAA,cACH,GAAI,CAAA,aAAA;AAAA,cACJ,IAAI,KAAM,CAAA;AAAA,aACZ;AAAA,YACA,SAAA;AAAA,YACA,IAAA;AAAA,YACA,aAAA;AAAA,YACA,QAAQ,GAAI,CAAA,MAAA;AAAA,YACZ,aACE,EAAA,gBAAA,IACA,MAAO,CAAA,iBAAA,CAAkB,iCAAiC,CAAA;AAAA,YAC5D,aAAA;AAAA,YACA,UAAA,EAAY,aAAa,UAAa,GAAA,KAAA;AAAA,WACvC,CAAA;AACD,UAAA,OAAO,YAAc,EAAA,UAAA;AAAA;AACvB,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,cAAc,UAAU,CAAA;AACnC,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAAA;AAC/C,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"bitbucketCloud.cjs.js","sources":["../../src/actions/bitbucketCloud.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 {\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\n\nimport { Config } from '@backstage/config';\nimport { getAuthorizationHeader } from './helpers';\nimport { examples } from './bitbucketCloud.examples';\n\nconst createRepository = async (opts: {\n workspace: string;\n project: string;\n repo: string;\n description?: string;\n repoVisibility: 'private' | 'public';\n mainBranch: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const {\n workspace,\n project,\n repo,\n description,\n repoVisibility,\n mainBranch,\n authorization,\n apiBaseUrl,\n } = opts;\n\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n scm: 'git',\n description: description,\n is_private: repoVisibility === 'private',\n project: { key: project },\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n let response: Response;\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to create repository, ${e}`);\n }\n\n if (response.status !== 200) {\n throw new Error(\n `Unable to create repository, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const r = await response.json();\n let remoteUrl = '';\n for (const link of r.links.clone) {\n if (link.name === 'https') {\n remoteUrl = link.href;\n }\n }\n\n // \"mainbranch.name\" cannot be set neither at create nor update of the repo\n // the first pushed branch will be set as \"main branch\" then\n const repoContentsUrl = `${r.links.html.href}/src/${mainBranch}`;\n return { remoteUrl, repoContentsUrl };\n};\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to Bitbucket Cloud.\n * @public\n */\nexport function createPublishBitbucketCloudAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction({\n id: 'publish:bitbucketCloud',\n examples,\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Bitbucket Cloud.',\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: 'Repository Location',\n }),\n description: z =>\n z\n .string({\n description: 'Repository Description',\n })\n .optional(),\n defaultBranch: z =>\n z\n .string({\n description: `Sets the default branch on the repository. The default value is 'master'`,\n })\n .optional(),\n repoVisibility: z =>\n z\n .enum(['private', 'public'], {\n description: 'Repository Visibility',\n })\n .optional(),\n gitCommitMessage: z =>\n z\n .string({\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n })\n .optional(),\n sourcePath: z =>\n z\n .string({\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description:\n 'The token to use for authorization to BitBucket Cloud',\n })\n .optional(),\n signCommit: z =>\n z\n .boolean({\n description: 'Sign commit with configured PGP private key',\n })\n .optional(),\n },\n output: {\n remoteUrl: z =>\n z\n .string({\n description: 'A URL to the repository with the provider',\n })\n .optional(),\n repoContentsUrl: z =>\n z\n .string({\n description: 'A URL to the root of the repository',\n })\n .optional(),\n commitHash: z =>\n z\n .string({\n description: 'The git commit hash of the initial commit',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n description,\n defaultBranch = 'master',\n gitCommitMessage,\n repoVisibility = 'private',\n signCommit,\n } = ctx.input;\n\n const { workspace, project, repo, host } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n if (!workspace) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`,\n );\n }\n\n if (!project) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing project`,\n );\n }\n\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\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 authorization = getAuthorizationHeader(\n ctx.input.token ? { token: ctx.input.token } : integrationConfig.config,\n );\n\n const apiBaseUrl = integrationConfig.config.apiBaseUrl;\n\n const { remoteUrl, repoContentsUrl } = await ctx.checkpoint({\n key: `create.repo.${host}.${repo}`,\n fn: async () =>\n await createRepository({\n authorization,\n workspace: workspace || '',\n project,\n repo,\n repoVisibility,\n mainBranch: defaultBranch,\n description,\n apiBaseUrl,\n }),\n });\n\n const gitAuthorInfo = {\n name: config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n let auth;\n\n if (ctx.input.token) {\n auth = {\n username: 'x-token-auth',\n password: ctx.input.token,\n };\n } else {\n if (\n !integrationConfig.config.username ||\n !integrationConfig.config.appPassword\n ) {\n throw new Error(\n 'Credentials for Bitbucket Cloud integration required for this action.',\n );\n }\n\n auth = {\n username: integrationConfig.config.username,\n password: integrationConfig.config.appPassword,\n };\n }\n\n const signingKey =\n integrationConfig.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\n\n const commitHash = await ctx.checkpoint({\n key: `init.repo.and.push${host}.${repo}`,\n fn: async () => {\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(\n ctx.workspacePath,\n ctx.input.sourcePath,\n ),\n remoteUrl,\n auth,\n defaultBranch,\n logger: ctx.logger,\n commitMessage:\n gitCommitMessage ||\n config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n signingKey: signCommit ? signingKey : undefined,\n });\n return commitResult?.commitHash;\n },\n });\n\n ctx.output('commitHash', commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getAuthorizationHeader","initRepoAndPush","getRepo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A,OACD,CAAA;AAED,MAAA,GAAA,CAAI,MAAA,CAAO,cAAc,UAAU,CAAA;AACnC,MAAA,GAAA,CAAI,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAA,GAAA,CAAI,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAAA,IAC/C;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucketCloud.examples.cjs.js","sources":["../../src/actions/bitbucketCloud.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 */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Initializes a git repository with the content in the workspace, and publishes it to Bitbucket Cloud with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Bitbucket Cloud repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with public repo visibility, if not set defaults to private',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n repoVisibility: 'public',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with a default Branch, if not set defaults to master',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n defaultBranch: 'main',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n sourcePath: './repoRoot',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with a custom authentication token',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n token: 'your-custom-auth-token',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with all properties being set',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n description: 'Initialize a git repository',\n repoVisibility: 'public',\n defaultBranch: 'main',\n token: 'your-custom-auth-token',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,qIAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAA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QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,wBAAA;AAAA,UACR,IAAM,EAAA,4BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,UAAY,EAAA;AAAA;AACd;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,6EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,wBAAA;AAAA,UACR,IAAM,EAAA,4BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,KAAO,EAAA;AAAA;AACT;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,wEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,SAAA;AAAA,UACJ,MAAQ,EAAA,wBAAA;AAAA,UACR,IAAM,EAAA,4BAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,WAAa,EAAA,6BAAA;AAAA,YACb,cAAgB,EAAA,QAAA;AAAA,YAChB,aAAe,EAAA,MAAA;AAAA,YACf,KAAO,EAAA;AAAA;AACT;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"bitbucketCloud.examples.cjs.js","sources":["../../src/actions/bitbucketCloud.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 */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Initializes a git repository with the content in the workspace, and publishes it to Bitbucket Cloud with the default configuration.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n },\n },\n ],\n }),\n },\n {\n description: 'Initializes a Bitbucket Cloud repository with a description.',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n description: 'Initialize a git repository',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with public repo visibility, if not set defaults to private',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n repoVisibility: 'public',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with a default Branch, if not set defaults to master',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n defaultBranch: 'main',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n sourcePath: './repoRoot',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with a custom authentication token',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n token: 'your-custom-auth-token',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Initializes a Bitbucket Cloud repository with all properties being set',\n example: yaml.stringify({\n steps: [\n {\n id: 'publish',\n action: 'publish:bitbucketCloud',\n name: 'Publish to Bitbucket Cloud',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n description: 'Initialize a git repository',\n repoVisibility: 'public',\n defaultBranch: 'main',\n token: 'your-custom-auth-token',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,qIAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,wBAAA;AAAA,UACR,IAAA,EAAM,4BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EACE;AAAA;AACJ;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,8DAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,wBAAA;AAAA,UACR,IAAA,EAAM,4BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EACE,6DAAA;AAAA,YACF,WAAA,EAAa;AAAA;AACf;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,sGAAA;AA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GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,wEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,SAAA;AAAA,UACJ,MAAA,EAAQ,wBAAA;AAAA,UACR,IAAA,EAAM,4BAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EACE,6DAAA;AAAA,YACF,WAAA,EAAa,6BAAA;AAAA,YACb,cAAA,EAAgB,QAAA;AAAA,YAChB,aAAA,EAAe,MAAA;AAAA,YACf,KAAA,EAAO;AAAA;AACT;AACF;AACF,KACD;AAAA;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucketCloudBranchRestriction.cjs.js","sources":["../../src/actions/bitbucketCloudBranchRestriction.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { getBitbucketClient } from './helpers';\nimport * as inputProps from './inputProperties';\nimport { examples } from './bitbucketCloudBranchRestriction.examples';\n\nconst createBitbucketCloudBranchRestriction = async (opts: {\n workspace: string;\n repo: string;\n kind: string;\n branchMatchKind?: string;\n branchType?: string;\n pattern?: string;\n value?: number | null;\n users?: { uuid: string; type: string }[];\n groups?: { slug: string; type: string }[];\n authorization: {\n token?: string;\n username?: string;\n appPassword?: string;\n };\n}) => {\n const {\n workspace,\n repo,\n kind,\n branchMatchKind,\n branchType,\n pattern,\n value,\n users,\n groups,\n authorization,\n } = opts;\n\n const bitbucket = getBitbucketClient(authorization);\n return await bitbucket.branchrestrictions.create({\n _body: {\n groups: groups,\n users: users,\n branch_match_kind: branchMatchKind,\n kind: kind,\n type: 'branchrestriction',\n value: kind === 'push' ? null : value,\n pattern: branchMatchKind === 'glob' ? pattern : undefined,\n branch_type:\n branchMatchKind === 'branching_model' ? branchType : undefined,\n },\n repo_slug: repo,\n workspace: workspace,\n });\n};\n\n/**\n * Creates a new action that adds a branch restriction to a Bitbucket Cloud repository.\n * @public\n */\nexport function createBitbucketCloudBranchRestrictionAction(options: {\n integrations: ScmIntegrationRegistry;\n}) {\n const { integrations } = options;\n return createTemplateAction({\n id: 'bitbucketCloud:branchRestriction:create',\n examples,\n description:\n 'Creates branch restrictions for a Bitbucket Cloud repository.',\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n kind: inputProps.restriction.kind,\n branchMatchKind: inputProps.restriction.branchMatchKind,\n branchType: inputProps.restriction.branchType,\n pattern: inputProps.restriction.pattern,\n value: inputProps.restriction.value,\n users: inputProps.restriction.users,\n groups: inputProps.restriction.groups,\n token: inputProps.token,\n },\n output: {\n json: z =>\n z\n .string({\n description: 'The response from bitbucket cloud',\n })\n .optional(),\n statusCode: z =>\n z\n .number({\n description: 'The status code of the response',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n kind,\n branchMatchKind = 'branching_model',\n branchType = 'development',\n pattern = '',\n value = 1,\n users = [],\n groups = [],\n token = '',\n } = ctx.input;\n\n const { workspace, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!workspace) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`,\n );\n }\n\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\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 authorization = token ? { token: token } : integrationConfig.config;\n\n const response = await createBitbucketCloudBranchRestriction({\n workspace: workspace,\n repo,\n kind: kind,\n branchMatchKind: branchMatchKind,\n branchType: branchType,\n pattern: pattern,\n value: value,\n users: users.map(user => ({ uuid: user.uuid, type: 'user' })),\n groups: groups.map(group => ({ slug: group.slug, type: 'group' })),\n authorization,\n });\n if (response.data.errors) {\n ctx.logger.error(\n `Error from Bitbucket Cloud Branch Restrictions: ${JSON.stringify(\n response.data.errors,\n )}`,\n );\n }\n ctx.logger.info(\n `Response from Bitbucket Cloud: ${JSON.stringify(response)}`,\n );\n ctx.output('statusCode', response.status);\n ctx.output('json', JSON.stringify(response));\n },\n });\n}\n"],"names":["getBitbucketClient","createTemplateAction","examples","inputProps.repoUrl","inputProps.restriction","inputProps.token","parseRepoUrl","InputError"],"mappings":";;;;;;;;AAyBA,MAAM,qCAAA,GAAwC,OAAO,IAe/C,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,eAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACE,GAAA,IAAA;AAEJ,EAAM,MAAA,SAAA,GAAYA,2BAAmB,aAAa,CAAA;AAClD,EAAO,OAAA,MAAM,SAAU,CAAA,kBAAA,CAAmB,MAAO,CAAA;AAAA,IAC/C,KAAO,EAAA;AAAA,MACL,MAAA;AAAA,MACA,KAAA;AAAA,MACA,iBAAmB,EAAA,eAAA;AAAA,MACnB,IAAA;AAAA,MACA,IAAM,EAAA,mBAAA;AAAA,MACN,KAAA,EAAO,IAAS,KAAA,MAAA,GAAS,IAAO,GAAA,KAAA;AAAA,MAChC,OAAA,EAAS,eAAoB,KAAA,MAAA,GAAS,OAAU,GAAA,KAAA,CAAA;AAAA,MAChD,WAAA,EACE,eAAoB,KAAA,iBAAA,GAAoB,UAAa,GAAA,KAAA;AAAA,KACzD;AA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AAA;AAEF,MAAA,GAAA,CAAI,MAAO,CAAA,IAAA;AAAA,QACT,CAAkC,+BAAA,EAAA,IAAA,CAAK,SAAU,CAAA,QAAQ,CAAC,CAAA;AAAA,OAC5D;AACA,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,QAAA,CAAS,MAAM,CAAA;AACxC,MAAA,GAAA,CAAI,MAAO,CAAA,MAAA,EAAQ,IAAK,CAAA,SAAA,CAAU,QAAQ,CAAC,CAAA;AAAA;AAC7C,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"bitbucketCloudBranchRestriction.cjs.js","sources":["../../src/actions/bitbucketCloudBranchRestriction.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { getBitbucketClient } from './helpers';\nimport * as inputProps from './inputProperties';\nimport { examples } from './bitbucketCloudBranchRestriction.examples';\n\nconst createBitbucketCloudBranchRestriction = async (opts: {\n workspace: string;\n repo: string;\n kind: string;\n branchMatchKind?: string;\n branchType?: string;\n pattern?: string;\n value?: number | null;\n users?: { uuid: string; type: string }[];\n groups?: { slug: string; type: string }[];\n authorization: {\n token?: string;\n username?: string;\n appPassword?: string;\n };\n}) => {\n const {\n workspace,\n repo,\n kind,\n branchMatchKind,\n branchType,\n pattern,\n value,\n users,\n groups,\n authorization,\n } = opts;\n\n const bitbucket = getBitbucketClient(authorization);\n return await bitbucket.branchrestrictions.create({\n _body: {\n groups: groups,\n users: users,\n branch_match_kind: branchMatchKind,\n kind: kind,\n type: 'branchrestriction',\n value: kind === 'push' ? null : value,\n pattern: branchMatchKind === 'glob' ? pattern : undefined,\n branch_type:\n branchMatchKind === 'branching_model' ? branchType : undefined,\n },\n repo_slug: repo,\n workspace: workspace,\n });\n};\n\n/**\n * Creates a new action that adds a branch restriction to a Bitbucket Cloud repository.\n * @public\n */\nexport function createBitbucketCloudBranchRestrictionAction(options: {\n integrations: ScmIntegrationRegistry;\n}) {\n const { integrations } = options;\n return createTemplateAction({\n id: 'bitbucketCloud:branchRestriction:create',\n examples,\n description:\n 'Creates branch restrictions for a Bitbucket Cloud repository.',\n schema: {\n input: {\n repoUrl: inputProps.repoUrl,\n kind: inputProps.restriction.kind,\n branchMatchKind: inputProps.restriction.branchMatchKind,\n branchType: inputProps.restriction.branchType,\n pattern: inputProps.restriction.pattern,\n value: inputProps.restriction.value,\n users: inputProps.restriction.users,\n groups: inputProps.restriction.groups,\n token: inputProps.token,\n },\n output: {\n json: z =>\n z\n .string({\n description: 'The response from bitbucket cloud',\n })\n .optional(),\n statusCode: z =>\n z\n .number({\n description: 'The status code of the response',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n kind,\n branchMatchKind = 'branching_model',\n branchType = 'development',\n pattern = '',\n value = 1,\n users = [],\n groups = [],\n token = '',\n } = ctx.input;\n\n const { workspace, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!workspace) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`,\n );\n }\n\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\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 authorization = token ? { token: token } : integrationConfig.config;\n\n const response = await createBitbucketCloudBranchRestriction({\n workspace: workspace,\n repo,\n kind: kind,\n branchMatchKind: branchMatchKind,\n branchType: branchType,\n pattern: pattern,\n value: value,\n users: users.map(user => ({ uuid: user.uuid, type: 'user' })),\n groups: groups.map(group => ({ slug: group.slug, type: 'group' })),\n authorization,\n });\n if (response.data.errors) {\n ctx.logger.error(\n `Error from Bitbucket Cloud Branch Restrictions: ${JSON.stringify(\n response.data.errors,\n )}`,\n );\n }\n ctx.logger.info(\n `Response from Bitbucket Cloud: ${JSON.stringify(response)}`,\n );\n ctx.output('statusCode', response.status);\n ctx.output('json', JSON.stringify(response));\n },\n });\n}\n"],"names":["getBitbucketClient","createTemplateAction","examples","inputProps.repoUrl","inputProps.restriction","inputProps.token","parseRepoUrl","InputError"],"mappings":";;;;;;;;AAyBA,MAAM,qCAAA,GAAwC,OAAO,IAAA,KAe/C;AACJ,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,eAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF,GAAI,IAAA;AAEJ,EAAA,MAAM,SAAA,GAAYA,2BAAmB,aAAa,CAAA;AAClD,EAAA,OAAO,MAAM,SAAA,CAAU,kBAAA,CAAmB,MAAA,CAAO;AAAA,IAC/C,KAAA,EAAO;AAAA,MACL,MAAA;AAAA,MACA,KAAA;AAAA,MACA,iBAAA,EAAmB,eAAA;AAAA,MACnB,IAAA;AAAA,MACA,IAAA,EAAM,mBAAA;AAAA,MACN,KAAA,EAAO,IAAA,KAAS,MAAA,GAAS,IAAA,GAAO,KAAA;AAAA,MAChC,OAAA,EAAS,eAAA,KAAoB,MAAA,GAAS,OAAA,GAAU,MAAA;AAAA,MAChD,WAAA,EACE,eAAA,KAAoB,iBAAA,GAAoB,UAAA,GAAa;AAAA,KACzD;AAAA,IACA,SAAA,EAAW,IAAA;AAAA,IACX;AAAA,GACD,CAAA;AACH,CAAA;AAMO,SAAS,4CAA4C,OAAA,EAEzD;AACD,EAAA,MAA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,CAAC,CAAA;AAAA,OAC5D;AACA,MAAA,GAAA,CAAI,MAAA,CAAO,YAAA,EAAc,QAAA,CAAS,MAAM,CAAA;AACxC,MAAA,GAAA,CAAI,MAAA,CAAO,MAAA,EAAQ,IAAA,CAAK,SAAA,CAAU,QAAQ,CAAC,CAAA;AAAA,IAC7C;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucketCloudBranchRestriction.examples.cjs.js","sources":["../../src/actions/bitbucketCloudBranchRestriction.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 */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'restrict push to the main branch, except for alice, bob, and the admins group',\n example: yaml.stringify({\n steps: [\n {\n id: 'createBranchRestriction',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud branch restriction',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'push',\n users: [\n {\n uuid: '{a-b-c-d}',\n },\n {\n uuid: '{e-f-g-h}',\n },\n ],\n groups: [\n {\n slug: 'admins',\n },\n ],\n },\n },\n ],\n }),\n },\n {\n description:\n 'restrict push to the main branch, except for the admins group',\n example: yaml.stringify({\n steps: [\n {\n id: 'restrictPushToFeatureBranches',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud branch restriction by branch type',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'push',\n groups: [\n {\n slug: 'admins',\n },\n ],\n },\n },\n ],\n }),\n },\n {\n description:\n 'require passing builds to merge to branches matching a pattern test-feature/*',\n example: yaml.stringify({\n steps: [\n {\n id: 'requirePassingBuildsToMergeByPattern',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud require passing build to merge to branches matching a pattern',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'require_passing_builds_to_merge',\n branchMatchKind: 'glob',\n pattern: 'test-feature/*',\n },\n },\n ],\n }),\n },\n {\n description:\n 'require approvals to merge to branches matching a pattern test-feature/*',\n example: yaml.stringify({\n steps: [\n {\n id: 'requireApprovalsToMergeByPattern',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud require approvals to merge branch restriction',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'require_approvals_to_merge',\n branchMatchKind: 'glob',\n pattern: 'test-feature/*',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,+EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,yBAAA;AAAA,UACJ,MAAQ,EAAA,yCAAA;AAAA,UACR,IAAM,EAAA,2CAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,IAAM,EAAA,MAAA;AAAA,YACN,KAAO,EAAA;AAAA,cACL;AAAA,gBACE,IAAM,EAAA;AAAA,eACR;AAAA,cACA;AAAA,gBACE,IAAM,EAAA;AAAA;AACR,aACF;AAAA,YACA,MAAQ,EAAA;AAAA,cACN;AAAA,gBACE,IAAM,EAAA;AAAA;AACR;AACF;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,+DAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,+BAAA;AAAA,UACJ,MAAQ,EAAA,yCAAA;AAAA,UACR,IAAM,EAAA,0DAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,IAAM,EAAA,MAAA;AAAA,YACN,MAAQ,EAAA;AAAA,cACN;AAAA,gBACE,IAAM,EAAA;AAAA;AACR;AACF;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,+EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,EAAI,EAAA,sCAAA;AAAA,UACJ,MAAQ,EAAA,yCAAA;AAAA,UACR,IAAM,EAAA,sFAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,IAAM,EAAA,iCAAA;AAAA,YACN,eAAiB,EAAA,MAAA;AAAA,YACjB,OAAS,EAAA;AAAA;AACX;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,kCAAA;AAAA,UACJ,MAAQ,EAAA,yCAAA;AAAA,UACR,IAAM,EAAA,sEAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,IAAM,EAAA,4BAAA;AAAA,YACN,eAAiB,EAAA,MAAA;AAAA,YACjB,OAAS,EAAA;AAAA;AACX;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"bitbucketCloudBranchRestriction.examples.cjs.js","sources":["../../src/actions/bitbucketCloudBranchRestriction.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 */\n\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'restrict push to the main branch, except for alice, bob, and the admins group',\n example: yaml.stringify({\n steps: [\n {\n id: 'createBranchRestriction',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud branch restriction',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'push',\n users: [\n {\n uuid: '{a-b-c-d}',\n },\n {\n uuid: '{e-f-g-h}',\n },\n ],\n groups: [\n {\n slug: 'admins',\n },\n ],\n },\n },\n ],\n }),\n },\n {\n description:\n 'restrict push to the main branch, except for the admins group',\n example: yaml.stringify({\n steps: [\n {\n id: 'restrictPushToFeatureBranches',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud branch restriction by branch type',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'push',\n groups: [\n {\n slug: 'admins',\n },\n ],\n },\n },\n ],\n }),\n },\n {\n description:\n 'require passing builds to merge to branches matching a pattern test-feature/*',\n example: yaml.stringify({\n steps: [\n {\n id: 'requirePassingBuildsToMergeByPattern',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud require passing build to merge to branches matching a pattern',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'require_passing_builds_to_merge',\n branchMatchKind: 'glob',\n pattern: 'test-feature/*',\n },\n },\n ],\n }),\n },\n {\n description:\n 'require approvals to merge to branches matching a pattern test-feature/*',\n example: yaml.stringify({\n steps: [\n {\n id: 'requireApprovalsToMergeByPattern',\n action: 'bitbucketCloud:branchRestriction:create',\n name: 'Create Bitbucket Cloud require approvals to merge branch restriction',\n input: {\n repoUrl:\n 'bitbucket.org?repo=repo&workspace=workspace&project=project',\n kind: 'require_approvals_to_merge',\n branchMatchKind: 'glob',\n pattern: 'test-feature/*',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,+EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,yBAAA;AAAA,UACJ,MAAA,EAAQ,yCAAA;AAAA,UACR,IAAA,EAAM,2CAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EACE,6DAAA;AAAA,YACF,IAAA,EAAM,MAAA;AAAA,YACN,KAAA,EAAO;AAAA,cACL;AAAA,gBACE,IAAA,EAAM;AAAA,eACR;AAAA,cACA;AAAA,gBACE,IAAA,EAAM;AAAA;AACR,aACF;AAAA,YACA,MAAA,EAAQ;AAAA,cACN;AAAA,gBACE,IAAA,EAAM;AAAA;AACR;AACF;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,+DAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,+BAAA;AAAA,UACJ,MAAA,EAAQ,yCAAA;AAAA,UACR,IAAA,EAAM,0DAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EACE,6DAAA;AAAA,YACF,IAAA,EAAM,MAAA;AAAA,YACN,MAAA,EAAQ;AAAA,cACN;AAAA,gBACE,IAAA,EAAM;AAAA;AACR;AACF;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,+EAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,EAAA,EAAI,sCAAA;AAAA,UACJ,MAAA,EAAQ,yCAAA;AAAA,UACR,IAAA,EAAM,sFAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EACE,6DAAA;AAAA,YACF,IAAA,EAAM,iCAAA;AAAA,YACN,eAAA,EAAiB,MAAA;AAAA,YACjB,OAAA,EAAS;AAAA;AACX;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,kCAAA;AAAA,UACJ,MAAA,EAAQ,yCAAA;AAAA,UACR,IAAA,EAAM,sEAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EACE,6DAAA;AAAA,YACF,IAAA,EAAM,4BAAA;AAAA,YACN,eAAA,EAAiB,MAAA;AAAA,YACjB,OAAA,EAAS;AAAA;AACX;AACF;AACF,KACD;AAAA;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucketCloudPipelinesRun.cjs.js","sources":["../../src/actions/bitbucketCloudPipelinesRun.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 { examples } from './bitbucketCloudPipelinesRun.examples';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport * as inputProps from './inputProperties';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getAuthorizationHeader } from './helpers';\n\nconst id = 'bitbucket:pipelines:run';\n/**\n * Creates a new action that triggers a run of a bitbucket pipeline\n *\n * @public\n */\nexport const createBitbucketPipelinesRunAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id,\n description: 'Run a bitbucket cloud pipeline',\n examples,\n schema: {\n input: {\n workspace: inputProps.workspace,\n repo_slug: inputProps.repo_slug,\n body: inputProps.pipelinesRunBody,\n token: inputProps.token,\n },\n output: {\n buildNumber: z =>\n z\n .number({\n description: 'Build number',\n })\n .optional(),\n repoUrl: z =>\n z\n .string({\n description: 'A URL to the pipeline repository',\n })\n .optional(),\n pipelinesUrl: z =>\n z\n .string({\n description: 'A URL to the pipeline',\n })\n .optional(),\n },\n },\n supportsDryRun: false,\n async handler(ctx) {\n const { workspace, repo_slug, body, token } = ctx.input;\n const host = 'bitbucket.org';\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\n\n const authorization = getAuthorizationHeader(\n token ? { token } : integrationConfig!.config,\n );\n let response: Response;\n try {\n response = await fetch(\n `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/pipelines`,\n {\n method: 'POST',\n headers: {\n Authorization: authorization,\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body) ?? {},\n },\n );\n } catch (e) {\n throw new Error(`Unable to run pipeline, ${e}`);\n }\n\n if (response.status !== 201) {\n throw new Error(\n `Unable to run pipeline, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const responseObject = await response.json();\n\n ctx.output('buildNumber', responseObject.build_number);\n ctx.output('repoUrl', responseObject.repository.links.html.href);\n ctx.output(\n 'pipelinesUrl',\n `${responseObject.repository.links.html.href}/pipelines`,\n );\n },\n });\n};\n"],"names":["createTemplateAction","examples","inputProps.workspace","inputProps.repo_slug","inputProps.pipelinesRunBody","inputProps.token","getAuthorizationHeader"],"mappings":";;;;;;;AAsBA,MAAM,EAAK,GAAA,yBAAA;AAME,MAAA,iCAAA,GAAoC,CAAC,OAE5C,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA;AACzB,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAA;AAAA,IACA,WAAa,EAAA,gCAAA;AAAA,cACbC,4CAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,WAAWC,yBAAW;AAAA,QACtB,WAAWC,yBAAW;AAAA,QACtB,MAAMC,gCAAW;AAAA,QACjB,OAAOC;AAAW,OACpB;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,WAAA,EAAa,CACX,CAAA,KAAA,CAAA,CACG,MAAO,CAAA;AAAA,UACN,WAAa,EAAA;AAAA,SACd,EACA,QAAS,EAAA;AAAA,QACd,OAAA,EAAS,CACP,CAAA,KAAA,CAAA,CACG,MAAO,CAAA;AAAA,UACN,WAAa,EAAA;AAAA,SACd,EACA,QAAS,EAAA;AAAA,QACd,YAAA,EAAc,CACZ,CAAA,KAAA,CAAA,CACG,MAAO,CAAA;AAAA,UACN,WAAa,EAAA;AAAA,SACd,EACA,QAAS;AAAA;AAChB,KACF;AAAA,IACA,cAAgB,EAAA,KAAA;AAAA,IAChB,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,MAAM,EAAE,SAAW,EAAA,SAAA,EAAW,IAAM,EAAA,KAAA,KAAU,GAAI,CAAA,KAAA;AAClD,MAAA,MAAM,IAAO,GAAA,eAAA;AACb,MAAA,MAAM,iBAAoB,GAAA,YAAA,CAAa,cAAe,CAAA,MAAA,CAAO,IAAI,CAAA;AAEjE,MAAA,MAAM,aAAgB,GAAAC,8BAAA;AAAA,QACpB,KAAQ,GAAA,EAAE,KAAM,EAAA,GAAI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bitbucketCloudPipelinesRun.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 { examples } from './bitbucketCloudPipelinesRun.examples';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport * as inputProps from './inputProperties';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { getAuthorizationHeader } from './helpers';\n\nconst id = 'bitbucket:pipelines:run';\n/**\n * Creates a new action that triggers a run of a bitbucket pipeline\n *\n * @public\n */\nexport const createBitbucketPipelinesRunAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id,\n description: 'Run a bitbucket cloud pipeline',\n examples,\n schema: {\n input: {\n workspace: inputProps.workspace,\n repo_slug: inputProps.repo_slug,\n body: inputProps.pipelinesRunBody,\n token: inputProps.token,\n },\n output: {\n buildNumber: z =>\n z\n .number({\n description: 'Build number',\n })\n .optional(),\n repoUrl: z =>\n z\n .string({\n description: 'A URL to the pipeline repository',\n })\n .optional(),\n pipelinesUrl: z =>\n z\n .string({\n description: 'A URL to the pipeline',\n })\n .optional(),\n },\n },\n supportsDryRun: false,\n async handler(ctx) {\n const { workspace, repo_slug, body, token } = ctx.input;\n const host = 'bitbucket.org';\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\n\n const authorization = getAuthorizationHeader(\n token ? { token } : integrationConfig!.config,\n );\n let response: Response;\n try {\n response = await fetch(\n `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/pipelines`,\n {\n method: 'POST',\n headers: {\n Authorization: authorization,\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body) ?? {},\n },\n );\n } catch (e) {\n throw new Error(`Unable to run pipeline, ${e}`);\n }\n\n if (response.status !== 201) {\n throw new Error(\n `Unable to run pipeline, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const responseObject = await response.json();\n\n ctx.output('buildNumber', responseObject.build_number);\n ctx.output('repoUrl', responseObject.repository.links.html.href);\n ctx.output(\n 'pipelinesUrl',\n `${responseObject.repository.links.html.href}/pipelines`,\n );\n },\n });\n};\n"],"names":["createTemplateAction","examples","inputProps.workspace","inputProps.repo_slug","inputProps.pipelinesRunBody","inputProps.token","getAuthorizationHeader"],"mappings":";;;;;;;AAsBA,MAAM,EAAA,GAAK,yBAAA;AAMJ,MAAM,iCAAA,GAAoC,CAAC,OAAA,KAE5C;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AACzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA;AAAA,IACA,WAAA,EAAa,gCAAA;AAAA,cACbC,4CAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,WAAWC,yBAAW;AAAA,QACtB,WAAWC,yBAAW;AAAA,QACtB,MAAMC,gCAAW;AAAA,QACjB,OAAOC;AAAW,OACpB;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,WAAA,EAAa,CAAA,CAAA,KACX,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,YAAA,EAAc,CAAA,CAAA,KACZ,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA;AAAS;AAChB,KACF;AAAA,IACA,cAAA,EAAgB,KAAA;AAAA,IA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Y,CAAA;AACrD,MAAA,GAAA,CAAI,OAAO,SAAA,EAAW,cAAA,CAAe,UAAA,CAAW,KAAA,CAAM,KAAK,IAAI,CAAA;AAC/D,MAAA,GAAA,CAAI,MAAA;AAAA,QACF,cAAA;AAAA,QACA,CAAA,EAAG,cAAA,CAAe,UAAA,CAAW,KAAA,CAAM,KAAK,IAAI,CAAA,UAAA;AAAA,OAC9C;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucketCloudPipelinesRun.examples.cjs.js","sources":["../../src/actions/bitbucketCloudPipelinesRun.examples.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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Trigger a pipeline for a branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n ref_type: 'branch',\n type: 'pipeline_ref_target',\n ref_name: 'master',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a pipeline for a commit on a branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'ce5b7431602f7cbba007062eeb55225c6e18e956',\n },\n ref_type: 'branch',\n type: 'pipeline_ref_target',\n ref_name: 'master',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a specific pipeline definition for a commit',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'a3c4e02c9a3755eccdc3764e6ea13facdf30f923',\n },\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n type: 'pipeline_commit_target',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Trigger a specific pipeline definition for a commit on a branch or tag',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'a3c4e02c9a3755eccdc3764e6ea13facdf30f923',\n },\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n type: 'pipeline_ref_target',\n ref_name: 'master',\n ref_type: 'branch',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a custom pipeline with variables',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n type: 'pipeline_ref_target',\n ref_name: 'master',\n ref_type: 'branch',\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n },\n variables: [\n { key: 'var1key', value: 'var1value', secured: true },\n {\n key: 'var2key',\n value: 'var2value',\n },\n ],\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a pull request pipeline',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n type: 'pipeline_pullrequest_target',\n source: 'pull-request-branch',\n destination: 'master',\n destination_commit: {\n hash: '9f848b7',\n },\n commit: {\n hash: '1a372fc',\n },\n pull_request: {\n id: '3',\n },\n selector: {\n type: 'pull-requests',\n pattern: '**',\n },\n },\n },\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,iCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,EAAI,EAAA,wBAAA;AAAA,UACJ,IAAM,EAAA,mCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,SAAW,EAAA,gBAAA;AAAA,YACX,SAAW,EAAA,gBAAA;AAAA,YACX,IAAM,EAAA;AAAA,cACJ,MAAQ,EAAA;AAAA,gBACN,QAAU,EAAA,QAAA;AAAA,gBACV,IAAM,EAAA,qBAAA;AAAA,gBACN,QAAU,EAAA;AAAA;AACZ;AACF;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAa,EAAA,6CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,yBAAA;AAAA,UACR,EAAI,EAAA,wBAAA;AAAA,UACJ,IAAM,EAAA,mCAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,SAAW,EAAA,gBAAA;AAAA,YACX,SAAW,EAAA,gBAAA;AAAA,YACX,IAAM,EAAA;AAAA,cACJ,MAAQ,EAAA;AAAA,gBACN,MAAQ,EAAA;AAAA,kB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SAAW,EAAA,gBAAA;AAAA,YACX,IAAM,EAAA;AAAA,cACJ,MAAQ,EAAA;AAAA,gBACN,IAAM,EAAA,6BAAA;AAAA,gBACN,MAAQ,EAAA,qBAAA;AAAA,gBACR,WAAa,EAAA,QAAA;AAAA,gBACb,kBAAoB,EAAA;AAAA,kBAClB,IAAM,EAAA;AAAA,iBACR;AAAA,gBACA,MAAQ,EAAA;AAAA,kBACN,IAAM,EAAA;AAAA,iBACR;AAAA,gBACA,YAAc,EAAA;AAAA,kBACZ,EAAI,EAAA;AAAA,iBACN;AAAA,gBACA,QAAU,EAAA;AAAA,kBACR,IAAM,EAAA,eAAA;AAAA,kBACN,OAAS,EAAA;AAAA;AACX;AACF;AACF;AACF;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"bitbucketCloudPipelinesRun.examples.cjs.js","sources":["../../src/actions/bitbucketCloudPipelinesRun.examples.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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Trigger a pipeline for a branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n ref_type: 'branch',\n type: 'pipeline_ref_target',\n ref_name: 'master',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a pipeline for a commit on a branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'ce5b7431602f7cbba007062eeb55225c6e18e956',\n },\n ref_type: 'branch',\n type: 'pipeline_ref_target',\n ref_name: 'master',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a specific pipeline definition for a commit',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'a3c4e02c9a3755eccdc3764e6ea13facdf30f923',\n },\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n type: 'pipeline_commit_target',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description:\n 'Trigger a specific pipeline definition for a commit on a branch or tag',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n commit: {\n type: 'commit',\n hash: 'a3c4e02c9a3755eccdc3764e6ea13facdf30f923',\n },\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n type: 'pipeline_ref_target',\n ref_name: 'master',\n ref_type: 'branch',\n },\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a custom pipeline with variables',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n type: 'pipeline_ref_target',\n ref_name: 'master',\n ref_type: 'branch',\n selector: {\n type: 'custom',\n pattern: 'Deploy to production',\n },\n },\n variables: [\n { key: 'var1key', value: 'var1value', secured: true },\n {\n key: 'var2key',\n value: 'var2value',\n },\n ],\n },\n },\n },\n ],\n }),\n },\n {\n description: 'Trigger a pull request pipeline',\n example: yaml.stringify({\n steps: [\n {\n action: 'bitbucket:pipelines:run',\n id: 'run-bitbucket-pipeline',\n name: 'Run an example bitbucket pipeline',\n input: {\n workspace: 'test-workspace',\n repo_slug: 'test-repo-slug',\n body: {\n target: {\n type: 'pipeline_pullrequest_target',\n source: 'pull-request-branch',\n destination: 'master',\n destination_commit: {\n hash: '9f848b7',\n },\n commit: {\n hash: '1a372fc',\n },\n pull_request: {\n id: '3',\n },\n selector: {\n type: 'pull-requests',\n pattern: '**',\n },\n },\n },\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EAAa,iCAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,EAAA,EAAI,wBAAA;AAAA,UACJ,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,SAAA,EAAW,gBAAA;AAAA,YACX,SAAA,EAAW,gBAAA;AAAA,YACX,IAAA,EAAM;AAAA,cACJ,MAAA,EAAQ;AAAA,gBACN,QAAA,EAAU,QAAA;AAAA,gBACV,IAAA,EAAM,qBAAA;AAAA,gBACN,QAAA,EAAU;AAAA;AACZ;AACF;AACF;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EAAa,6CAAA;AAAA,IACb,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,EAAA,EAAI,wBAAA;AAAA,UACJ,I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tB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,yBAAA;AAAA,UACR,EAAA,EAAI,wBAAA;AAAA,UACJ,IAAA,EAAM,mCAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,SAAA,EAAW,gBAAA;AAAA,YACX,SAAA,EAAW,gBAAA;AAAA,YACX,IAAA,EAAM;AAAA,cACJ,MAAA,EAAQ;AAAA,gBACN,IAAA,EAAM,6BAAA;AAAA,gBACN,MAAA,EAAQ,qBAAA;AAAA,gBACR,WAAA,EAAa,QAAA;AAAA,gBACb,kBAAA,EAAoB;AAAA,kBAClB,IAAA,EAAM;AAAA,iBACR;AAAA,gBACA,MAAA,EAAQ;AAAA,kBACN,IAAA,EAAM;AAAA,iBACR;AAAA,gBACA,YAAA,EAAc;AAAA,kBACZ,EAAA,EAAI;AAAA,iBACN;AAAA,gBACA,QAAA,EAAU;AAAA,kBACR,IAAA,EAAM,eAAA;AAAA,kBACN,OAAA,EAAS;AAAA;AACX;AACF;AACF;AACF;AACF;AACF,KACD;AAAA;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucketCloudPullRequest.cjs.js","sources":["../../src/actions/bitbucketCloudPullRequest.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 {\n createTemplateAction,\n getRepoSourceDirectory,\n commitAndPushBranch,\n addFiles,\n cloneRepo,\n parseRepoUrl,\n isNotGitDirectoryOrContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Config } from '@backstage/config';\nimport fs from 'fs-extra';\nimport { getAuthorizationHeader } from './helpers';\nimport { examples } from './bitbucketCloudPullRequest.examples';\n\nconst createPullRequest = async (opts: {\n workspace: string;\n repo: string;\n title: string;\n description?: string;\n targetBranch: string;\n sourceBranch: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const {\n workspace,\n repo,\n title,\n description,\n targetBranch,\n sourceBranch,\n authorization,\n apiBaseUrl,\n } = opts;\n\n let response: Response;\n const data: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n title: title,\n summary: {\n raw: description,\n },\n state: 'OPEN',\n source: {\n branch: {\n name: sourceBranch,\n },\n },\n destination: {\n branch: {\n name: targetBranch,\n },\n },\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}/pullrequests`,\n data,\n );\n } catch (e) {\n throw new Error(`Unable to create pull-requests, ${e}`);\n }\n\n if (response.status !== 201) {\n throw new Error(\n `Unable to create pull requests, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const r = await response.json();\n return r.links.html.href;\n};\n\nconst findBranches = async (opts: {\n workspace: string;\n repo: string;\n branchName: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const { workspace, repo, branchName, authorization, apiBaseUrl } = opts;\n\n let response: Response;\n const options: RequestInit = {\n method: 'GET',\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}/refs/branches?q=${encodeURIComponent(\n `name = \"${branchName}\"`,\n )}`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to get branches, ${e}`);\n }\n\n if (response.status !== 200) {\n throw new Error(\n `Unable to get branches, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const r = await response.json();\n\n return r.values[0];\n};\n\nconst createBranch = async (opts: {\n workspace: string;\n repo: string;\n branchName: string;\n authorization: string;\n apiBaseUrl: string;\n startBranch: string;\n}) => {\n const {\n workspace,\n repo,\n branchName,\n authorization,\n apiBaseUrl,\n startBranch,\n } = opts;\n\n let response: Response;\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n name: branchName,\n target: {\n hash: startBranch,\n },\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}/refs/branches`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to create branch, ${e}`);\n }\n\n if (response.status !== 201) {\n throw new Error(\n `Unable to create branch, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n return await response.json();\n};\n\nconst getDefaultBranch = async (opts: {\n workspace: string;\n repo: string;\n authorization: string;\n apiBaseUrl: string;\n}): Promise<string> => {\n const { workspace, repo, authorization, apiBaseUrl } = opts;\n let response: Response;\n\n const options: RequestInit = {\n method: 'GET',\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}`,\n options,\n );\n } catch (error) {\n throw error;\n }\n\n const { mainbranch } = await response.json();\n const defaultBranch = mainbranch.name;\n if (!defaultBranch) {\n throw new Error(`Could not fetch default branch for ${workspace}/${repo}`);\n }\n return defaultBranch;\n};\n/**\n * Creates a Bitbucket Cloud Pull Request action.\n * @public\n */\nexport function createPublishBitbucketCloudPullRequestAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction({\n id: 'publish:bitbucketCloud:pull-request',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: 'Repository Location',\n }),\n title: z =>\n z.string({\n description: 'The title for the pull request',\n }),\n description: z =>\n z\n .string({\n description: 'The description of the pull request',\n })\n .optional(),\n targetBranch: z =>\n z\n .string({\n description: `Branch of repository to apply changes to. The default value is 'master'`,\n })\n .optional(),\n sourceBranch: z =>\n z.string({\n description: 'Branch of repository to copy changes from',\n }),\n token: z =>\n z\n .string({\n description:\n 'The token to use for authorization to BitBucket Cloud',\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description: `Sets the author name for the commit. The default value is 'Scaffolder'`,\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description: `Sets the author email for the commit.`,\n })\n .optional(),\n },\n output: {\n pullRequestUrl: z =>\n z.string({\n description: 'A URL to the pull request with the provider',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n title,\n description,\n targetBranch,\n sourceBranch,\n gitAuthorName,\n gitAuthorEmail,\n } = ctx.input;\n\n const { workspace, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!workspace) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`,\n );\n }\n\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\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 authorization = getAuthorizationHeader(\n ctx.input.token ? { token: ctx.input.token } : integrationConfig.config,\n );\n\n const apiBaseUrl = integrationConfig.config.apiBaseUrl;\n\n let finalTargetBranch = targetBranch;\n if (!finalTargetBranch) {\n finalTargetBranch = await getDefaultBranch({\n workspace,\n repo,\n authorization,\n apiBaseUrl,\n });\n }\n\n const sourceBranchRef = await findBranches({\n workspace,\n repo,\n branchName: sourceBranch,\n authorization,\n apiBaseUrl,\n });\n\n if (!sourceBranchRef) {\n // create branch\n ctx.logger.info(\n `source branch not found -> creating branch named: ${sourceBranch}`,\n );\n\n await createBranch({\n workspace,\n repo,\n branchName: sourceBranch,\n authorization,\n apiBaseUrl,\n startBranch: finalTargetBranch,\n });\n\n const remoteUrl = `https://${host}/${workspace}/${repo}.git`;\n\n let auth;\n\n if (ctx.input.token) {\n auth = {\n username: 'x-token-auth',\n password: ctx.input.token,\n };\n } else {\n if (\n !integrationConfig.config.username ||\n !integrationConfig.config.appPassword\n ) {\n throw new Error(\n 'Credentials for Bitbucket Cloud integration required for this action.',\n );\n }\n\n auth = {\n username: integrationConfig.config.username,\n password: integrationConfig.config.appPassword,\n };\n }\n\n const gitAuthorInfo = {\n name:\n gitAuthorName ||\n config.getOptionalString('scaffolder.defaultAuthor.name'),\n email:\n gitAuthorEmail ||\n config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n const tempDir = await ctx.createTemporaryDirectory();\n const sourceDir = getRepoSourceDirectory(ctx.workspacePath, undefined);\n await cloneRepo({\n url: remoteUrl,\n dir: tempDir,\n auth,\n logger: ctx.logger,\n ref: sourceBranch,\n });\n\n // copy files\n fs.cpSync(sourceDir, tempDir, {\n recursive: true,\n filter: isNotGitDirectoryOrContents,\n });\n\n await addFiles({\n dir: tempDir,\n auth,\n logger: ctx.logger,\n filepath: '.',\n });\n\n await commitAndPushBranch({\n dir: tempDir,\n auth,\n logger: ctx.logger,\n commitMessage:\n description ??\n config.getOptionalString('scaffolder.defaultCommitMessage') ??\n '',\n gitAuthorInfo,\n branch: sourceBranch,\n });\n }\n\n const pullRequestUrl = await createPullRequest({\n workspace,\n repo,\n title,\n description,\n targetBranch: finalTargetBranch,\n sourceBranch,\n authorization,\n apiBaseUrl,\n });\n\n ctx.output('pullRequestUrl', pullRequestUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getAuthorizationHeader","getRepoSourceDirectory","cloneRepo","fs","isNotGitDirectoryOrContents","addFiles","commitAndPushBranch"],"mappings":";;;;;;;;;;;;AAgCA,MAAM,iBAAA,GAAoB,OAAO,IAS3B,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACE,GAAA,IAAA;AAEJ,EAAI,IAA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AAA,QACA,YAAc,EAAA,iBAAA;AAAA,QACd,YAAA;AAAA,QACA,aAAA;AAAA,QACA;AAAA,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,kBAAkB,cAAc,CAAA;AAAA;AAC7C,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"bitbucketCloudPullRequest.cjs.js","sources":["../../src/actions/bitbucketCloudPullRequest.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 {\n createTemplateAction,\n getRepoSourceDirectory,\n commitAndPushBranch,\n addFiles,\n cloneRepo,\n parseRepoUrl,\n isNotGitDirectoryOrContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Config } from '@backstage/config';\nimport fs from 'fs-extra';\nimport { getAuthorizationHeader } from './helpers';\nimport { examples } from './bitbucketCloudPullRequest.examples';\n\nconst createPullRequest = async (opts: {\n workspace: string;\n repo: string;\n title: string;\n description?: string;\n targetBranch: string;\n sourceBranch: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const {\n workspace,\n repo,\n title,\n description,\n targetBranch,\n sourceBranch,\n authorization,\n apiBaseUrl,\n } = opts;\n\n let response: Response;\n const data: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n title: title,\n summary: {\n raw: description,\n },\n state: 'OPEN',\n source: {\n branch: {\n name: sourceBranch,\n },\n },\n destination: {\n branch: {\n name: targetBranch,\n },\n },\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}/pullrequests`,\n data,\n );\n } catch (e) {\n throw new Error(`Unable to create pull-requests, ${e}`);\n }\n\n if (response.status !== 201) {\n throw new Error(\n `Unable to create pull requests, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const r = await response.json();\n return r.links.html.href;\n};\n\nconst findBranches = async (opts: {\n workspace: string;\n repo: string;\n branchName: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const { workspace, repo, branchName, authorization, apiBaseUrl } = opts;\n\n let response: Response;\n const options: RequestInit = {\n method: 'GET',\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}/refs/branches?q=${encodeURIComponent(\n `name = \"${branchName}\"`,\n )}`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to get branches, ${e}`);\n }\n\n if (response.status !== 200) {\n throw new Error(\n `Unable to get branches, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n const r = await response.json();\n\n return r.values[0];\n};\n\nconst createBranch = async (opts: {\n workspace: string;\n repo: string;\n branchName: string;\n authorization: string;\n apiBaseUrl: string;\n startBranch: string;\n}) => {\n const {\n workspace,\n repo,\n branchName,\n authorization,\n apiBaseUrl,\n startBranch,\n } = opts;\n\n let response: Response;\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n name: branchName,\n target: {\n hash: startBranch,\n },\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}/refs/branches`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to create branch, ${e}`);\n }\n\n if (response.status !== 201) {\n throw new Error(\n `Unable to create branch, ${response.status} ${\n response.statusText\n }, ${await response.text()}`,\n );\n }\n\n return await response.json();\n};\n\nconst getDefaultBranch = async (opts: {\n workspace: string;\n repo: string;\n authorization: string;\n apiBaseUrl: string;\n}): Promise<string> => {\n const { workspace, repo, authorization, apiBaseUrl } = opts;\n let response: Response;\n\n const options: RequestInit = {\n method: 'GET',\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/repositories/${workspace}/${repo}`,\n options,\n );\n } catch (error) {\n throw error;\n }\n\n const { mainbranch } = await response.json();\n const defaultBranch = mainbranch.name;\n if (!defaultBranch) {\n throw new Error(`Could not fetch default branch for ${workspace}/${repo}`);\n }\n return defaultBranch;\n};\n/**\n * Creates a Bitbucket Cloud Pull Request action.\n * @public\n */\nexport function createPublishBitbucketCloudPullRequestAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction({\n id: 'publish:bitbucketCloud:pull-request',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: 'Repository Location',\n }),\n title: z =>\n z.string({\n description: 'The title for the pull request',\n }),\n description: z =>\n z\n .string({\n description: 'The description of the pull request',\n })\n .optional(),\n targetBranch: z =>\n z\n .string({\n description: `Branch of repository to apply changes to. The default value is 'master'`,\n })\n .optional(),\n sourceBranch: z =>\n z.string({\n description: 'Branch of repository to copy changes from',\n }),\n token: z =>\n z\n .string({\n description:\n 'The token to use for authorization to BitBucket Cloud',\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description: `Sets the author name for the commit. The default value is 'Scaffolder'`,\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description: `Sets the author email for the commit.`,\n })\n .optional(),\n },\n output: {\n pullRequestUrl: z =>\n z.string({\n description: 'A URL to the pull request with the provider',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n title,\n description,\n targetBranch,\n sourceBranch,\n gitAuthorName,\n gitAuthorEmail,\n } = ctx.input;\n\n const { workspace, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!workspace) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing workspace`,\n );\n }\n\n const integrationConfig = integrations.bitbucketCloud.byHost(host);\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 authorization = getAuthorizationHeader(\n ctx.input.token ? { token: ctx.input.token } : integrationConfig.config,\n );\n\n const apiBaseUrl = integrationConfig.config.apiBaseUrl;\n\n let finalTargetBranch = targetBranch;\n if (!finalTargetBranch) {\n finalTargetBranch = await getDefaultBranch({\n workspace,\n repo,\n authorization,\n apiBaseUrl,\n });\n }\n\n const sourceBranchRef = await findBranches({\n workspace,\n repo,\n branchName: sourceBranch,\n authorization,\n apiBaseUrl,\n });\n\n if (!sourceBranchRef) {\n // create branch\n ctx.logger.info(\n `source branch not found -> creating branch named: ${sourceBranch}`,\n );\n\n await createBranch({\n workspace,\n repo,\n branchName: sourceBranch,\n authorization,\n apiBaseUrl,\n startBranch: finalTargetBranch,\n });\n\n const remoteUrl = `https://${host}/${workspace}/${repo}.git`;\n\n let auth;\n\n if (ctx.input.token) {\n auth = {\n username: 'x-token-auth',\n password: ctx.input.token,\n };\n } else {\n if (\n !integrationConfig.config.username ||\n !integrationConfig.config.appPassword\n ) {\n throw new Error(\n 'Credentials for Bitbucket Cloud integration required for this action.',\n );\n }\n\n auth = {\n username: integrationConfig.config.username,\n password: integrationConfig.config.appPassword,\n };\n }\n\n const gitAuthorInfo = {\n name:\n gitAuthorName ||\n config.getOptionalString('scaffolder.defaultAuthor.name'),\n email:\n gitAuthorEmail ||\n config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n const tempDir = await ctx.createTemporaryDirectory();\n const sourceDir = getRepoSourceDirectory(ctx.workspacePath, undefined);\n await cloneRepo({\n url: remoteUrl,\n dir: tempDir,\n auth,\n logger: ctx.logger,\n ref: sourceBranch,\n });\n\n // copy files\n fs.cpSync(sourceDir, tempDir, {\n recursive: true,\n filter: isNotGitDirectoryOrContents,\n });\n\n await addFiles({\n dir: tempDir,\n auth,\n logger: ctx.logger,\n filepath: '.',\n });\n\n await commitAndPushBranch({\n dir: tempDir,\n auth,\n logger: ctx.logger,\n commitMessage:\n description ??\n config.getOptionalString('scaffolder.defaultCommitMessage') ??\n '',\n gitAuthorInfo,\n branch: sourceBranch,\n });\n }\n\n const pullRequestUrl = await createPullRequest({\n workspace,\n repo,\n title,\n description,\n targetBranch: finalTargetBranch,\n sourceBranch,\n authorization,\n apiBaseUrl,\n });\n\n ctx.output('pullRequestUrl', pullRequestUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","getAuthorizationHeader","getRepoSourceDirectory","cloneRepo","fs","isNotGitDirectoryOrContents","addFiles","commitAndPushBranch"],"mappings":";;;;;;;;;;;;AAgCA,MAAM,iBAAA,GAAoB,OAAO,IAAA,KAS3B;AACJ,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF,GAAI,IAAA;AAEJ,EAAA,IAAI,QAAA;AACJ,EAAA,MAAM,IAAA,GAAoB;AAAA,IACxB,MAAA,EAAQ,MAAA;AAAA,IACR,IAAA,EAAM,KAAK,SAAA,CAAU;AAAA,MACnB,KAAA;AAAA,MACA,OAAA,EAAS;AAAA,QACP,GAAA,EAAK;AAAA,OACP;AAAA,MACA,KAAA,EAAO,MAAA;AAAA,MACP,MAAA,EAAQ;AAAA,QACN,MAAA,EAAQ;AAAA,UACN,IAAA,EAAM;AAAA;AACR,OACF;AAAA,MACA,WAAA,EAAa;AAAA,QACX,MAAA,EAAQ;AAAA,UACN,IAAA,EAAM;AAAA;AACR;AACF,KACD,CAAA;AAAA,IACD,OAAA,EAAS;AAAA,MACP,aAAA,EAAe,aAAA;AAAA,MACf,cAAA,EAAgB;AAAA;AAClB,GACF;AAEA,EA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UACd,GAAA,EAAK,SAAA;AAAA,UACL,GAAA,EAAK,OAAA;AAAA,UACL,IAAA;AAAA,UACA,QAAQ,GAAA,CAAI,MAAA;AAAA,UACZ,GAAA,EAAK;AAAA,SACN,CAAA;AAGD,QAAAC,mBAAA,CAAG,MAAA,CAAO,WAAW,OAAA,EAAS;AAAA,UAC5B,SAAA,EAAW,IAAA;AAAA,UACX,MAAA,EAAQC;AAAA,SACT,CAAA;AAED,QAAA,MAAMC,6BAAA,CAAS;AAAA,UACb,GAAA,EAAK,OAAA;AAAA,UACL,IAAA;AAAA,UACA,QAAQ,GAAA,CAAI,MAAA;AAAA,UACZ,QAAA,EAAU;AAAA,SACX,CAAA;AAED,QAAA,MAAMC,wCAAA,CAAoB;AAAA,UACxB,GAAA,EAAK,OAAA;AAAA,UACL,IAAA;AAAA,UACA,QAAQ,GAAA,CAAI,MAAA;AAAA,UACZ,aAAA,EACE,WAAA,IACA,MAAA,CAAO,iBAAA,CAAkB,iCAAiC,CAAA,IAC1D,EAAA;AAAA,UACF,aAAA;AAAA,UACA,MAAA,EAAQ;AAAA,SACT,CAAA;AAAA,MACH;AAEA,MAAA,MAAM,cAAA,GAAiB,MAAM,iBAAA,CAAkB;AAAA,QAC7C,SAAA;AAAA,QACA,IAAA;AAAA,QACA,KAAA;AAAA,QACA,WAAA;AAAA,QACA,YAAA,EAAc,iBAAA;AAAA,QACd,YAAA;AAAA,QACA,aAAA;AAAA,QACA;AAAA,OACD,CAAA;AAED,MAAA,GAAA,CAAI,MAAA,CAAO,kBAAkB,cAAc,CAAA;AAAA,IAC7C;AAAA,GACD,CAAA;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucketCloudPullRequest.examples.cjs.js","sources":["../../src/actions/bitbucketCloudPullRequest.examples.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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Creating pull request on bitbucket cloud with required fields',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Creating pull request on bitbucket cloud with custom descriptions',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n description: 'This is a detailed description of my pull request',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Creating pull request on bitbucket cloud with different target branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-target-branch',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n targetBranch: 'development',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Creating pull request on bitbucket cloud with authorization token',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n token: 'my-auth-token',\n },\n },\n ],\n }),\n },\n {\n description: 'Creating pull request on bitbucket cloud with all fields',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n targetBranch: 'development',\n description: 'This is a detailed description of my pull request',\n token: 'my-auth-token',\n gitAuthorName: 'test-user',\n gitAuthorEmail: 'test-user@sample.com',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,+DAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,qCAAA;AAAA,UACR,EAAI,EAAA,8CAAA;AAAA,UACJ,IAAM,EAAA,0CAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,KAAO,EAAA,iBAAA;AAAA,YACP,YAAc,EAAA;AAAA;AAChB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,mEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,qCAAA;AAAA,UACR,EAAI,EAAA,8CAAA;AAAA,UACJ,IAAM,EAAA,0CAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,KAAO,EAAA,iBAAA;AAAA,YACP,YAAc,EAAA,mBAAA;AAAA,YACd,WAAa,EAAA;AAAA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AAAA,YACf,cAAgB,EAAA;AAAA;AAClB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
1
+ {"version":3,"file":"bitbucketCloudPullRequest.examples.cjs.js","sources":["../../src/actions/bitbucketCloudPullRequest.examples.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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Creating pull request on bitbucket cloud with required fields',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Creating pull request on bitbucket cloud with custom descriptions',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n description: 'This is a detailed description of my pull request',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Creating pull request on bitbucket cloud with different target branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-target-branch',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n targetBranch: 'development',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Creating pull request on bitbucket cloud with authorization token',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n token: 'my-auth-token',\n },\n },\n ],\n }),\n },\n {\n description: 'Creating pull request on bitbucket cloud with all fields',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n targetBranch: 'development',\n description: 'This is a detailed description of my pull request',\n token: 'my-auth-token',\n gitAuthorName: 'test-user',\n gitAuthorEmail: 'test-user@sample.com',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAAA,GAA8B;AAAA,EACzC;AAAA,IACE,WAAA,EACE,+DAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAA,CAAU;AAAA,MACtB,KAAA,EAAO;AAAA,QACL;AAAA,UACE,MAAA,EAAQ,qCAAA;AAAA,UACR,EAAA,EAAI,8CAAA;AAAA,UACJ,IAAA,EAAM,0CAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EACE,6DAAA;AAAA,YACF,KAAA,EAAO,iBAAA;AAAA,YACP,YAAA,EAAc;AAAA;AAChB;AACF;AACF,KACD;AAAA,GACH;AAAA,EACA;AAAA,IACE,WAAA,EACE,mEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,S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AAA,EAAI,8CAAA;AAAA,UACJ,IAAA,EAAM,0CAAA;AAAA,UACN,KAAA,EAAO;AAAA,YACL,OAAA,EACE,6DAAA;AAAA,YACF,KAAA,EAAO,iBAAA;AAAA,YACP,YAAA,EAAc,mBAAA;AAAA,YACd,YAAA,EAAc,aAAA;AAAA,YACd,WAAA,EAAa,mDAAA;AAAA,YACb,KAAA,EAAO,eAAA;AAAA,YACP,aAAA,EAAe,WAAA;AAAA,YACf,cAAA,EAAgB;AAAA;AAClB;AACF;AACF,KACD;AAAA;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.cjs.js","sources":["../../src/actions/helpers.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 { Bitbucket } from 'bitbucket';\n\nexport const getBitbucketClient = (config: {\n token?: string;\n username?: string;\n appPassword?: string;\n}) => {\n if (config.username && config.appPassword) {\n return new Bitbucket({\n auth: {\n username: config.username,\n password: config.appPassword,\n },\n });\n } else if (config.token) {\n return new Bitbucket({\n auth: {\n token: config.token,\n },\n });\n }\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`,\n );\n};\n\nexport const getAuthorizationHeader = (config: {\n username?: string;\n appPassword?: string;\n token?: string;\n}) => {\n if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n\n return `Basic ${buffer.toString('base64')}`;\n }\n\n if (config.token) {\n return `Bearer ${config.token}`;\n }\n\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`,\n );\n};\n"],"names":["Bitbucket"],"mappings":";;;;AAkBa,MAAA,kBAAA,GAAqB,CAAC,MAI7B,KAAA;AACJ,EAAI,IAAA,MAAA,CAAO,QAAY,IAAA,MAAA,CAAO,WAAa,EAAA;AACzC,IAAA,OAAO,IAAIA,mBAAU,CAAA;AAAA,MACnB,IAAM,EAAA;AAAA,QACJ,UAAU,MAAO,CAAA,QAAA;AAAA,QACjB,UAAU,MAAO,CAAA;AAAA;AACnB,KACD,CAAA;AAAA,GACH,MAAA,IAAW,OAAO,KAAO,EAAA;AACvB,IAAA,OAAO,IAAIA,mBAAU,CAAA;AAAA,MACnB,IAAM,EAAA;AAAA,QACJ,OAAO,MAAO,CAAA;AAAA;AAChB,KACD,CAAA;AAAA;AAEH,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,uJAAA;AAAA,GACF;AACF;AAEa,MAAA,sBAAA,GAAyB,CAAC,MAIjC,KAAA;AACJ,EAAI,IAAA,MAAA,CAAO,QAAY,IAAA,MAAA,CAAO,WAAa,EAAA;AACzC,IAAA,MAAM,SAAS,MAAO,CAAA,IAAA;AAAA,MACpB,CAAG,EAAA,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,OAAO,WAAW,CAAA,CAAA;AAAA,MACxC;AAAA,KACF;AAEA,IAAA,OAAO,CAAS,MAAA,EAAA,MAAA,CAAO,QAAS,CAAA,QAAQ,CAAC,CAAA,CAAA;AAAA;AAG3C,EAAA,IAAI,OAAO,KAAO,EAAA;AAChB,IAAO,OAAA,CAAA,OAAA,EAAU,OAAO,KAAK,CAAA,CAAA;AAAA;AAG/B,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,uJAAA;AAAA,GACF;AACF;;;;;"}
1
+ {"version":3,"file":"helpers.cjs.js","sources":["../../src/actions/helpers.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 { Bitbucket } from 'bitbucket';\n\nexport const getBitbucketClient = (config: {\n token?: string;\n username?: string;\n appPassword?: string;\n}) => {\n if (config.username && config.appPassword) {\n return new Bitbucket({\n auth: {\n username: config.username,\n password: config.appPassword,\n },\n });\n } else if (config.token) {\n return new Bitbucket({\n auth: {\n token: config.token,\n },\n });\n }\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`,\n );\n};\n\nexport const getAuthorizationHeader = (config: {\n username?: string;\n appPassword?: string;\n token?: string;\n}) => {\n if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n\n return `Basic ${buffer.toString('base64')}`;\n }\n\n if (config.token) {\n return `Bearer ${config.token}`;\n }\n\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`,\n );\n};\n"],"names":["Bitbucket"],"mappings":";;;;AAkBO,MAAM,kBAAA,GAAqB,CAAC,MAAA,KAI7B;AACJ,EAAA,IAAI,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,WAAA,EAAa;AACzC,IAAA,OAAO,IAAIA,mBAAA,CAAU;AAAA,MACnB,IAAA,EAAM;AAAA,QACJ,UAAU,MAAA,CAAO,QAAA;AAAA,QACjB,UAAU,MAAA,CAAO;AAAA;AACnB,KACD,CAAA;AAAA,EACH,CAAA,MAAA,IAAW,OAAO,KAAA,EAAO;AACvB,IAAA,OAAO,IAAIA,mBAAA,CAAU;AAAA,MACnB,IAAA,EAAM;AAAA,QACJ,OAAO,MAAA,CAAO;AAAA;AAChB,KACD,CAAA;AAAA,EACH;AACA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,uJAAA;AAAA,GACF;AACF;AAEO,MAAM,sBAAA,GAAyB,CAAC,MAAA,KAIjC;AACJ,EAAA,IAAI,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,WAAA,EAAa;AACzC,IAAA,MAAM,SAAS,MAAA,CAAO,IAAA;AAAA,MACpB,CAAA,EAAG,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,OAAO,WAAW,CAAA,CAAA;AAAA,MACxC;AAAA,KACF;AAEA,IAAA,OAAO,CAAA,MAAA,EAAS,MAAA,CAAO,QAAA,CAAS,QAAQ,CAAC,CAAA,CAAA;AAAA,EAC3C;AAEA,EAAA,IAAI,OAAO,KAAA,EAAO;AAChB,IAAA,OAAO,CAAA,OAAA,EAAU,OAAO,KAAK,CAAA,CAAA;AAAA,EAC/B;AAEA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,uJAAA;AAAA,GACF;AACF;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"inputProperties.cjs.js","sources":["../../src/actions/inputProperties.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 as zod } from 'zod';\n\nconst repoUrl = (z: typeof zod) =>\n z.string({\n description: `Accepts the format 'bitbucket.org?repo=reponame&workspace=workspace&project=project' where 'reponame' is the new repository name`,\n });\n\nconst workspace = (z: typeof zod) =>\n z.string({\n description: 'The workspace name',\n });\n\nconst repo_slug = (z: typeof zod) =>\n z.string({\n description: 'The repository name',\n });\n\nconst ref_type = (z: typeof zod) =>\n z.string({\n description: 'ref_type',\n });\n\nconst type = (z: typeof zod) =>\n z.string({\n description: 'type',\n });\n\nconst ref_name = (z: typeof zod) =>\n z.string({\n description: 'ref_name',\n });\n\nconst source = (z: typeof zod) =>\n z.string({\n description: 'source',\n });\n\nconst destination = (z: typeof zod) =>\n z.string({\n description: 'destination',\n });\n\nconst hash = (z: typeof zod) =>\n z.string({\n description: 'hash',\n });\n\nconst pattern = (z: typeof zod) =>\n z.string({\n description: 'pattern',\n });\n\nconst id = (z: typeof zod) =>\n z.string({\n description: 'id',\n });\n\nconst key = (z: typeof zod) =>\n z.string({\n description: 'key',\n });\n\nconst value = (z: typeof zod) =>\n z.string({\n description: 'value',\n });\n\nconst secured = (z: typeof zod) =>\n z.boolean({\n description: 'secured',\n });\n\nconst token = (z: typeof zod) =>\n z\n .string({\n description: 'The token to use for authorization to BitBucket Cloud',\n })\n .optional();\n\nconst destination_commit = (z: typeof zod) =>\n z.object({\n hash: hash(z),\n });\n\nconst commit = (z: typeof zod) =>\n z.object({\n type: type(z),\n hash: hash(z),\n });\n\nconst selector = (z: typeof zod) =>\n z.object({\n type: type(z),\n pattern: pattern(z),\n });\n\nconst pull_request = (z: typeof zod) =>\n z.object({\n id: id(z),\n });\n\nconst pipelinesRunBody = (z: typeof zod) =>\n z\n .object(\n {\n target: z\n .object({\n ref_type: ref_type(z).optional(),\n type: type(z).optional(),\n ref_name: ref_name(z).optional(),\n source: source(z).optional(),\n destination: destination(z).optional(),\n destination_commit: destination_commit(z).optional(),\n commit: commit(z).optional(),\n selector: selector(z).optional(),\n pull_request: pull_request(z).optional(),\n })\n .optional(),\n variables: z\n .array(\n z.object({\n key: key(z),\n value: value(z),\n secured: secured(z),\n }),\n )\n .optional(),\n },\n {\n description:\n 'Request body properties: see Bitbucket Cloud Rest API documentation for more details',\n },\n )\n .optional();\n\nconst restriction = {\n kind: (z: typeof zod) =>\n z.enum(\n [\n 'push',\n 'force',\n 'delete',\n 'restrict_merges',\n 'require_tasks_to_be_completed',\n 'require_approvals_to_merge',\n 'require_default_reviewer_approvals_to_merge',\n 'require_no_changes_requested',\n 'require_passing_builds_to_merge',\n 'require_commits_behind',\n 'reset_pullrequest_approvals_on_change',\n 'smart_reset_pullrequest_approvals',\n 'reset_pullrequest_changes_requested_on_change',\n 'require_all_dependencies_merged',\n 'enforce_merge_checks',\n 'allow_auto_merge_when_builds_pass',\n ],\n {\n description: 'The kind of restriction.',\n },\n ),\n branchMatchKind: (z: typeof zod) =>\n z\n .enum(['glob', 'branching_model'], {\n description: 'The branch match kind.',\n })\n .optional(),\n branchType: (z: typeof zod) =>\n z\n .enum(\n ['feature', 'bugfix', 'release', 'hotfix', 'development', 'production'],\n {\n description:\n 'The branch type. When branchMatchKind is set to branching_model, this field is required.',\n },\n )\n .optional(),\n pattern: (z: typeof zod) =>\n z\n .string({\n description:\n 'The pattern to match branches against. This field is required when branchMatchKind is set to glob.',\n })\n .optional(),\n value: (z: typeof zod) =>\n z\n .union([z.number(), z.null()], {\n description:\n 'The value of the restriction. This field is required when kind is one of require_approvals_to_merge / require_default_reviewer_approvals_to_merge / require_passing_builds_to_merge / require_commits_behind.',\n })\n .optional(),\n users: (z: typeof zod) =>\n z\n .array(\n z.object({\n uuid: z.string({\n description: 'The UUID of the user in the format \"{a-b-c-d}\".',\n }),\n }),\n {\n description:\n 'Names of users that can bypass the push / restrict_merges restriction kind. For any other kind, this field will be ignored.',\n },\n )\n .optional(),\n groups: (z: typeof zod) =>\n z\n .array(\n z.object({\n slug: z.string({\n description: 'The name of the group.',\n }),\n }),\n {\n description:\n 'Names of groups that can bypass the push / restrict_merges restriction kind. For any other kind, this field will be ignored.',\n },\n )\n .optional(),\n};\n\nexport { workspace, repo_slug, pipelinesRunBody, token };\nexport { repoUrl, restriction };\n"],"names":[],"mappings":";;AAkBA,MAAM,OAAU,GAAA,CAAC,CACf,KAAA,CAAA,CAAE,MAAO,CAAA;AAAA,EACP,WA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CAAC,CAAA,KACX,CACG,CAAA,IAAA;AAAA,IACC,CAAC,SAAW,EAAA,QAAA,EAAU,SAAW,EAAA,QAAA,EAAU,eAAe,YAAY,CAAA;AAAA,IACtE;AAAA,MACE,WACE,EAAA;AAAA;AACJ,IAED,QAAS,EAAA;AAAA,EACd,OAAS,EAAA,CAAC,CACR,KAAA,CAAA,CACG,MAAO,CAAA;AAAA,IACN,WACE,EAAA;AAAA,GACH,EACA,QAAS,EAAA;AAAA,EACd,KAAO,EAAA,CAAC,CACN,KAAA,CAAA,CACG,KAAM,CAAA,CAAC,CAAE,CAAA,MAAA,EAAU,EAAA,CAAA,CAAE,IAAK,EAAC,CAAG,EAAA;AAAA,IAC7B,WACE,EAAA;AAAA,GACH,EACA,QAAS,EAAA;AAAA,EACd,KAAA,EAAO,CAAC,CAAA,KACN,CACG,CAAA,KAAA;AAAA,IACC,EAAE,MAAO,CAAA;AAAA,MACP,IAAA,EAAM,EAAE,MAAO,CAAA;AAAA,QACb,WAAa,EAAA;AAAA,OACd;AAAA,KACF,CAAA;AAAA,IACD;AAAA,MACE,WACE,EAAA;AAAA;AACJ,IAED,QAAS,EAAA;AAAA,EACd,MAAA,EAAQ,CAAC,CAAA,KACP,CACG,CAAA,KAAA;AAAA,IACC,EAAE,MAAO,CAAA;AAAA,MACP,IAAA,EAAM,EAAE,MAAO,CAAA;AAAA,QACb,WAAa,EAAA;AAAA,OACd;AAAA,KACF,CAAA;AAAA,IACD;AAAA,MACE,WACE,EAAA;AAAA;AACJ,IAED,QAAS;AAChB;;;;;;;;;"}
1
+ {"version":3,"file":"inputProperties.cjs.js","sources":["../../src/actions/inputProperties.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 as zod } from 'zod';\n\nconst repoUrl = (z: typeof zod) =>\n z.string({\n description: `Accepts the format 'bitbucket.org?repo=reponame&workspace=workspace&project=project' where 'reponame' is the new repository name`,\n });\n\nconst workspace = (z: typeof zod) =>\n z.string({\n description: 'The workspace name',\n });\n\nconst repo_slug = (z: typeof zod) =>\n z.string({\n description: 'The repository name',\n });\n\nconst ref_type = (z: typeof zod) =>\n z.string({\n description: 'ref_type',\n });\n\nconst type = (z: typeof zod) =>\n z.string({\n description: 'type',\n });\n\nconst ref_name = (z: typeof zod) =>\n z.string({\n description: 'ref_name',\n });\n\nconst source = (z: typeof zod) =>\n z.string({\n description: 'source',\n });\n\nconst destination = (z: typeof zod) =>\n z.string({\n description: 'destination',\n });\n\nconst hash = (z: typeof zod) =>\n z.string({\n description: 'hash',\n });\n\nconst pattern = (z: typeof zod) =>\n z.string({\n description: 'pattern',\n });\n\nconst id = (z: typeof zod) =>\n z.string({\n description: 'id',\n });\n\nconst key = (z: typeof zod) =>\n z.string({\n description: 'key',\n });\n\nconst value = (z: typeof zod) =>\n z.string({\n description: 'value',\n });\n\nconst secured = (z: typeof zod) =>\n z.boolean({\n description: 'secured',\n });\n\nconst token = (z: typeof zod) =>\n z\n .string({\n description: 'The token to use for authorization to BitBucket Cloud',\n })\n .optional();\n\nconst destination_commit = (z: typeof zod) =>\n z.object({\n hash: hash(z),\n });\n\nconst commit = (z: typeof zod) =>\n z.object({\n type: type(z),\n hash: hash(z),\n });\n\nconst selector = (z: typeof zod) =>\n z.object({\n type: type(z),\n pattern: pattern(z),\n });\n\nconst pull_request = (z: typeof zod) =>\n z.object({\n id: id(z),\n });\n\nconst pipelinesRunBody = (z: typeof zod) =>\n z\n .object(\n {\n target: z\n .object({\n ref_type: ref_type(z).optional(),\n type: type(z).optional(),\n ref_name: ref_name(z).optional(),\n source: source(z).optional(),\n destination: destination(z).optional(),\n destination_commit: destination_commit(z).optional(),\n commit: commit(z).optional(),\n selector: selector(z).optional(),\n pull_request: pull_request(z).optional(),\n })\n .optional(),\n variables: z\n .array(\n z.object({\n key: key(z),\n value: value(z),\n secured: secured(z),\n }),\n )\n .optional(),\n },\n {\n description:\n 'Request body properties: see Bitbucket Cloud Rest API documentation for more details',\n },\n )\n .optional();\n\nconst restriction = {\n kind: (z: typeof zod) =>\n z.enum(\n [\n 'push',\n 'force',\n 'delete',\n 'restrict_merges',\n 'require_tasks_to_be_completed',\n 'require_approvals_to_merge',\n 'require_default_reviewer_approvals_to_merge',\n 'require_no_changes_requested',\n 'require_passing_builds_to_merge',\n 'require_commits_behind',\n 'reset_pullrequest_approvals_on_change',\n 'smart_reset_pullrequest_approvals',\n 'reset_pullrequest_changes_requested_on_change',\n 'require_all_dependencies_merged',\n 'enforce_merge_checks',\n 'allow_auto_merge_when_builds_pass',\n ],\n {\n description: 'The kind of restriction.',\n },\n ),\n branchMatchKind: (z: typeof zod) =>\n z\n .enum(['glob', 'branching_model'], {\n description: 'The branch match kind.',\n })\n .optional(),\n branchType: (z: typeof zod) =>\n z\n .enum(\n ['feature', 'bugfix', 'release', 'hotfix', 'development', 'production'],\n {\n description:\n 'The branch type. When branchMatchKind is set to branching_model, this field is required.',\n },\n )\n .optional(),\n pattern: (z: typeof zod) =>\n z\n .string({\n description:\n 'The pattern to match branches against. This field is required when branchMatchKind is set to glob.',\n })\n .optional(),\n value: (z: typeof zod) =>\n z\n .union([z.number(), z.null()], {\n description:\n 'The value of the restriction. This field is required when kind is one of require_approvals_to_merge / require_default_reviewer_approvals_to_merge / require_passing_builds_to_merge / require_commits_behind.',\n })\n .optional(),\n users: (z: typeof zod) =>\n z\n .array(\n z.object({\n uuid: z.string({\n description: 'The UUID of the user in the format \"{a-b-c-d}\".',\n }),\n }),\n {\n description:\n 'Names of users that can bypass the push / restrict_merges restriction kind. For any other kind, this field will be ignored.',\n },\n )\n .optional(),\n groups: (z: typeof zod) =>\n z\n .array(\n z.object({\n slug: z.string({\n description: 'The name of the group.',\n }),\n }),\n {\n description:\n 'Names of groups that can bypass the push / restrict_merges restriction kind. For any other kind, this field will be ignored.',\n },\n )\n .optional(),\n};\n\nexport { workspace, repo_slug, pipelinesRunBody, token };\nexport { repoUrl, restriction };\n"],"names":[],"mappings":";;AAkBA,MAAM,OAAA,GAAU,CAAC,CAAA,KACf,CAAA,CAAE,MAAA,CAAO;AAAA,EACP,WAAA,EAAa,CAAA,gIAAA;AACf,CAAC;AAEH,MAAM,SAAA,GAAY,CAAC,CAAA,KACjB,CAAA,CAAE,MAAA,CAAO;AAAA,EACP,WAAA,EAAa;AACf,CAAC;AAEH,MAAM,SAAA,GAAY,CAAC,CAAA,KACjB,CAAA,CAAE,MAAA,CAAO;AAAA,EACP,WAAA,EAAa;AACf,CAAC;AAEH,MAAM,QAAA,GAAW,CAAC,CAAA,KAChB,CAAA,CAAE,MAAA,CAAO;AAAA,EACP,WAAA,EAAa;AACf,CAAC,CAAA;AAEH,MAAM,IAAA,GAAO,CAAC,CAAA,KACZ,CAAA,CAAE,MAAA,CAAO;AAAA,EACP,WAAA,EAAa;AACf,CAAC,CAAA;AAEH,MAAM,QAAA,GAAW,CAAC,CAAA,KAChB,CAAA,CAAE,MAAA,CAAO;AAAA,EACP,WAAA,EAAa;AACf,CAAC,CAAA;AAEH,MAAM,MAAA,GAAS,CAAC,CAAA,KACd,CAAA,CAAE,MAAA,CAAO;AAAA,EACP,WAAA,EAAa;AACf,CAAC,CAAA;AAEH,MAAM,WAAA,GAAc,CAAC,CAAA,KACnB,CAAA,CAAE,MAAA,CAAO;AAAA,EACP,WAAA,EAAa;AACf,CAAC,CAAA;AAEH,MAAM,IAAA,GAAO,CAAC,CAAA,KACZ,CAAA,CAAE,MAAA,CAAO;AAAA,EACP,WAAA,EAAa;AACf,CAAC,CAAA;AAEH,MAAM,OAAA,GAAU,CAAC,CAAA,KACf,CAAA,CAAE,MAAA,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AAAA;AACJ,IAED,QAAA;AACP;;;;;;;;;"}
@@ -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 { BitbucketCloudClient } from '@backstage/plugin-bitbucket-cloud-common';\n\nexport async function handleAutocompleteRequest({\n resource,\n token,\n context,\n}: {\n resource: string;\n token: string;\n context: Record<string, string>;\n}): Promise<{ results: { title?: string; id: string }[] }> {\n const client = BitbucketCloudClient.fromConfig({\n host: 'bitbucket.org',\n apiBaseUrl: 'https://api.bitbucket.org/2.0',\n token,\n });\n\n switch (resource) {\n case 'workspaces': {\n const results: { title?: string; id: string }[] = [];\n\n for await (const page of client.listWorkspaces().iteratePages()) {\n const slugs = [...page.values!].map(p => ({\n id: p.slug!,\n }));\n results.push(...slugs);\n }\n\n return { results };\n }\n case 'projects': {\n if (!context.workspace)\n throw new InputError('Missing workspace context parameter');\n\n const results: { title?: string; id: string }[] = [];\n\n for await (const page of client\n .listProjectsByWorkspace(context.workspace)\n .iteratePages()) {\n const keys = [...page.values!].map(p => ({\n id: p.key!,\n }));\n results.push(...keys);\n }\n\n return { results };\n }\n case 'repositories': {\n if (!context.workspace || !context.project)\n throw new InputError(\n 'Missing workspace and/or project context parameter',\n );\n\n const results: { title?: string; id: string }[] = [];\n\n for await (const page of client\n .listRepositoriesByWorkspace(context.workspace, {\n q: `project.key=\"${context.project}\"`,\n })\n .iteratePages()) {\n const slugs = [...page.values!].map(p => ({\n id: p.slug!,\n }));\n results.push(...slugs);\n }\n\n return { results };\n }\n case 'branches': {\n if (!context.workspace || !context.repository)\n throw new InputError(\n 'Missing workspace and/or repository context parameter',\n );\n\n const results: { title?: string; id: string }[] = [];\n\n for await (const page of client\n .listBranchesByRepository(context.repository, context.workspace)\n .iteratePages()) {\n const names = [...page.values!].map(p => ({\n id: p.name!,\n }));\n results.push(...names);\n }\n\n return { results };\n }\n default:\n throw new InputError(`Invalid resource: ${resource}`);\n }\n}\n"],"names":["BitbucketCloudClient","InputError"],"mappings":";;;;;AAmBA,eAAsB,yBAA0B,CAAA;AAAA,EAC9C,QAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAI2D,EAAA;AACzD,EAAM,MAAA,MAAA,GAASA,gDAAqB,UAAW,CAAA;AAAA,IAC7C,IAAM,EAAA,eAAA;AAAA,IACN,UAAY,EAAA,+BAAA;AAAA,IACZ;AAAA,GACD,CAAA;AAED,EAAA,QAAQ,QAAU;AAAA,IAChB,KAAK,YAAc,EAAA;AACjB,MAAA,MAAM,UAA4C,EAAC;AAEnD,MAAA,WAAA,MAAiB,IAAQ,IAAA,MAAA,CAAO,cAAe,EAAA,CAAE,cAAgB,EAAA;AAC/D,QAAA,MAAM,QAAQ,CAAC,GAAG,KAAK,MAAO,CAAA,CAAE,IAAI,CAAM,CAAA,MAAA;AAAA,UACxC,IAAI,CAAE,CAAA;AAAA,SACN,CAAA,CAAA;AACF,QAAQ,OAAA,CAAA,IAAA,CAAK,GAAG,KAAK,CAAA;AAAA;AAGvB,MAAA,OAAO,EAAE,OAAQ,EAAA;AAAA;AACnB,IACA,KAAK,UAAY,EAAA;AACf,MAAA,IAAI,CAAC,OAAQ,CAAA,SAAA;AACX,QAAM,MAAA,IAAIC,kBAAW,qCAAqC,CAAA;AAE5D,MAAA,MAAM,UAA4C,EAAC;AAEnD,MAAA,WAAA,MAAiB,QAAQ,MACtB,CAAA,uBAAA,CAAwB,QAAQ,SAAS,CAAA,CACzC,cAAgB,EA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CAAC,GAAG,KAAK,MAAO,CAAA,CAAE,IAAI,CAAM,CAAA,MAAA;AAAA,UACxC,IAAI,CAAE,CAAA;AAAA,SACN,CAAA,CAAA;AACF,QAAQ,OAAA,CAAA,IAAA,CAAK,GAAG,KAAK,CAAA;AAAA;AAGvB,MAAA,OAAO,EAAE,OAAQ,EAAA;AAAA;AACnB,IACA;AACE,MAAA,MAAM,IAAIA,iBAAA,CAAW,CAAqB,kBAAA,EAAA,QAAQ,CAAE,CAAA,CAAA;AAAA;AAE1D;;;;"}
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 { BitbucketCloudClient } from '@backstage/plugin-bitbucket-cloud-common';\n\nexport async function handleAutocompleteRequest({\n resource,\n token,\n context,\n}: {\n resource: string;\n token: string;\n context: Record<string, string>;\n}): Promise<{ results: { title?: string; id: string }[] }> {\n const client = BitbucketCloudClient.fromConfig({\n host: 'bitbucket.org',\n apiBaseUrl: 'https://api.bitbucket.org/2.0',\n token,\n });\n\n switch (resource) {\n case 'workspaces': {\n const results: { title?: string; id: string }[] = [];\n\n for await (const page of client.listWorkspaces().iteratePages()) {\n const slugs = [...page.values!].map(p => ({\n id: p.slug!,\n }));\n results.push(...slugs);\n }\n\n return { results };\n }\n case 'projects': {\n if (!context.workspace)\n throw new InputError('Missing workspace context parameter');\n\n const results: { title?: string; id: string }[] = [];\n\n for await (const page of client\n .listProjectsByWorkspace(context.workspace)\n .iteratePages()) {\n const keys = [...page.values!].map(p => ({\n id: p.key!,\n }));\n results.push(...keys);\n }\n\n return { results };\n }\n case 'repositories': {\n if (!context.workspace || !context.project)\n throw new InputError(\n 'Missing workspace and/or project context parameter',\n );\n\n const results: { title?: string; id: string }[] = [];\n\n for await (const page of client\n .listRepositoriesByWorkspace(context.workspace, {\n q: `project.key=\"${context.project}\"`,\n })\n .iteratePages()) {\n const slugs = [...page.values!].map(p => ({\n id: p.slug!,\n }));\n results.push(...slugs);\n }\n\n return { results };\n }\n case 'branches': {\n if (!context.workspace || !context.repository)\n throw new InputError(\n 'Missing workspace and/or repository context parameter',\n );\n\n const results: { title?: string; id: string }[] = [];\n\n for await (const page of client\n .listBranchesByRepository(context.repository, context.workspace)\n .iteratePages()) {\n const names = [...page.values!].map(p => ({\n id: p.name!,\n }));\n results.push(...names);\n }\n\n return { results };\n }\n default:\n throw new InputError(`Invalid resource: ${resource}`);\n }\n}\n"],"names":["BitbucketCloudClient","InputError"],"mappings":";;;;;AAmBA,eAAsB,yBAAA,CAA0B;AAAA,EAC9C,QAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,EAI2D;AACzD,EAAA,MAAM,MAAA,GAASA,gDAAqB,UAAA,CAAW;AAAA,IAC7C,IAAA,EAAM,eAAA;AAAA,IACN,UAAA,EAAY,+BAAA;AAAA,IACZ;AAAA,GACD,CAAA;AAED,EAAA,QAAQ,QAAA;AAAU,IAChB,KAAK,YAAA,EAAc;AACjB,MAAA,MAAM,UAA4C,EAAC;AAEnD,MAAA,WAAA,MAAiB,IAAA,IAAQ,MAAA,CAAO,cAAA,EAAe,CAAE,cAAa,EAAG;AAC/D,QAAA,MAAM,QAAQ,CAAC,GAAG,KAAK,MAAO,CAAA,CAAE,IAAI,CAAA,CAAA,MAAM;AAAA,UACxC,IAAI,CAAA,CAAE;AAAA,SACR,CAAE,CAAA;AACF,QAAA,OAAA,CAAQ,IAAA,CAAK,GAAG,KAAK,CAAA;AAAA,MACvB;AAEA,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A,IAAI,CAAC,OAAA,CAAQ,SAAA,IAAa,CAAC,OAAA,CAAQ,UAAA;AACjC,QAAA,MAAM,IAAIA,iBAAA;AAAA,UACR;AAAA,SACF;AAEF,MAAA,MAAM,UAA4C,EAAC;AAEnD,MAAA,WAAA,MAAiB,IAAA,IAAQ,OACtB,wBAAA,CAAyB,OAAA,CAAQ,YAAY,OAAA,CAAQ,SAAS,CAAA,CAC9D,YAAA,EAAa,EAAG;AACjB,QAAA,MAAM,QAAQ,CAAC,GAAG,KAAK,MAAO,CAAA,CAAE,IAAI,CAAA,CAAA,MAAM;AAAA,UACxC,IAAI,CAAA,CAAE;AAAA,SACR,CAAE,CAAA;AACF,QAAA,OAAA,CAAQ,IAAA,CAAK,GAAG,KAAK,CAAA;AAAA,MACvB;AAEA,MAAA,OAAO,EAAE,OAAA,EAAQ;AAAA,IACnB;AAAA,IACA;AACE,MAAA,MAAM,IAAIA,iBAAA,CAAW,CAAA,kBAAA,EAAqB,QAAQ,CAAA,CAAE,CAAA;AAAA;AAE1D;;;;"}
@@ -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 {\n scaffolderActionsExtensionPoint,\n scaffolderAutocompleteExtensionPoint,\n} from '@backstage/plugin-scaffolder-node/alpha';\nimport { createBitbucketCloudBranchRestrictionAction } from './actions/bitbucketCloudBranchRestriction';\nimport {\n createBitbucketPipelinesRunAction,\n createPublishBitbucketCloudAction,\n createPublishBitbucketCloudPullRequestAction,\n} from './actions';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { handleAutocompleteRequest } from './autocomplete/autocomplete';\n\n/**\n * @public\n * The Bitbucket Cloud Module for the Scaffolder Backend\n */\nexport const bitbucketCloudModule = createBackendModule({\n moduleId: 'bitbucketCloud',\n pluginId: 'scaffolder',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n autocomplete: scaffolderAutocompleteExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, config, autocomplete }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createPublishBitbucketCloudAction({ integrations, config }),\n createBitbucketPipelinesRunAction({ integrations }),\n createPublishBitbucketCloudPullRequestAction({\n integrations,\n config,\n }),\n createBitbucketCloudBranchRestrictionAction({\n integrations,\n }),\n );\n\n autocomplete.addAutocompleteProvider({\n id: 'bitbucket-cloud',\n handler: handleAutocompleteRequest,\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","scaffolderAutocompleteExtensionPoint","coreServices","autocomplete","ScmIntegrations","createPublishBitbucketCloudAction","createBitbucketPipelinesRunAction","createPublishBitbucketCloudPullRequestAction","createBitbucketCloudBranchRestrictionAction","handleAutocompleteRequest"],"mappings":";;;;;;;;;;;AAoCO,MAAM,uBAAuBA,oCAAoB,CAAA;AAAA,EACtD,QAAU,EAAA,gBAAA;AAAA,EACV,QAAU,EAAA,YAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAgB,EAAA;AACzB,IAAa,YAAA,CAAA;AAAA,MACX,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC,qCAAA;AAAA,QACZ,YAAc,EAAAC,0CAAA;AAAA,QACd,QAAQC,6BAAa,CAAA;AAAA,OACvB;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,UAAY,EAAA,MAAA,gBAAQC,gBAAgB,EAAA;AAC/C,QAAM,MAAA,YAAA,GAAeC,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA;AAEtD,QAAW,UAAA,CAAA,UAAA;AAAA,UACTC,gDAAkC,CAAA,EAAE,YAAc,EAAA,MAAA,EAAQ,CAAA;AAAA,UAC1DC,4DAAA,CAAkC,EAAE,YAAA,EAAc,CAAA;AAAA,UAClDC,sEAA6C,CAAA;AAAA,YAC3C,YAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,2EAA4C,CAAA;AAAA,YAC1C;AAAA,WACD;AAAA,SACH;AAEA,QAAAL,cAAA,CAAa,uBAAwB,CAAA;AAAA,UACnC,EAAI,EAAA,iBAAA;AAAA,UACJ,OAAS,EAAAM;AAAA,SACV,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
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 {\n scaffolderActionsExtensionPoint,\n scaffolderAutocompleteExtensionPoint,\n} from '@backstage/plugin-scaffolder-node/alpha';\nimport { createBitbucketCloudBranchRestrictionAction } from './actions/bitbucketCloudBranchRestriction';\nimport {\n createBitbucketPipelinesRunAction,\n createPublishBitbucketCloudAction,\n createPublishBitbucketCloudPullRequestAction,\n} from './actions';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { handleAutocompleteRequest } from './autocomplete/autocomplete';\n\n/**\n * @public\n * The Bitbucket Cloud Module for the Scaffolder Backend\n */\nexport const bitbucketCloudModule = createBackendModule({\n moduleId: 'bitbucketCloud',\n pluginId: 'scaffolder',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n autocomplete: scaffolderAutocompleteExtensionPoint,\n config: coreServices.rootConfig,\n },\n async init({ scaffolder, config, autocomplete }) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n scaffolder.addActions(\n createPublishBitbucketCloudAction({ integrations, config }),\n createBitbucketPipelinesRunAction({ integrations }),\n createPublishBitbucketCloudPullRequestAction({\n integrations,\n config,\n }),\n createBitbucketCloudBranchRestrictionAction({\n integrations,\n }),\n );\n\n autocomplete.addAutocompleteProvider({\n id: 'bitbucket-cloud',\n handler: handleAutocompleteRequest,\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","scaffolderAutocompleteExtensionPoint","coreServices","autocomplete","ScmIntegrations","createPublishBitbucketCloudAction","createBitbucketPipelinesRunAction","createPublishBitbucketCloudPullRequestAction","createBitbucketCloudBranchRestrictionAction","handleAutocompleteRequest"],"mappings":";;;;;;;;;;;AAoCO,MAAM,uBAAuBA,oCAAA,CAAoB;AAAA,EACtD,QAAA,EAAU,gBAAA;AAAA,EACV,QAAA,EAAU,YAAA;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,EAAY,MAAA,gBAAQC,gBAAa,EAAG;AAC/C,QAAA,MAAM,YAAA,GAAeC,2BAAA,CAAgB,UAAA,CAAW,MAAM,CAAA;AAEtD,QAAA,UAAA,CAAW,UAAA;AAAA,UACTC,gDAAA,CAAkC,EAAE,YAAA,EAAc,MAAA,EAAQ,CAAA;AAAA,UAC1DC,4DAAA,CAAkC,EAAE,YAAA,EAAc,CAAA;AAAA,UAClDC,sEAAA,CAA6C;AAAA,YAC3C,YAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,2EAAA,CAA4C;AAAA,YAC1C;AAAA,WACD;AAAA,SACH;AAEA,QAAAL,cAAA,CAAa,uBAAA,CAAwB;AAAA,UACnC,EAAA,EAAI,iBAAA;AAAA,UACJ,OAAA,EAASM;AAAA,SACV,CAAA;AAAA,MACH;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-bitbucket-cloud",
3
- "version": "0.2.12-next.0",
3
+ "version": "0.2.13-next.0",
4
4
  "description": "The Bitbucket Cloud module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -50,21 +50,21 @@
50
50
  "test": "backstage-cli package test"
51
51
  },
52
52
  "dependencies": {
53
- "@backstage/backend-plugin-api": "1.4.2-next.0",
53
+ "@backstage/backend-plugin-api": "1.4.3-next.0",
54
54
  "@backstage/config": "1.3.3",
55
55
  "@backstage/errors": "1.2.7",
56
- "@backstage/integration": "1.17.1",
57
- "@backstage/plugin-bitbucket-cloud-common": "0.3.1",
58
- "@backstage/plugin-scaffolder-node": "0.11.0-next.0",
56
+ "@backstage/integration": "1.18.0-next.0",
57
+ "@backstage/plugin-bitbucket-cloud-common": "0.3.2-next.0",
58
+ "@backstage/plugin-scaffolder-node": "0.11.1-next.0",
59
59
  "bitbucket": "^2.12.0",
60
60
  "fs-extra": "^11.2.0",
61
61
  "yaml": "^2.0.0",
62
62
  "zod": "^3.22.4"
63
63
  },
64
64
  "devDependencies": {
65
- "@backstage/backend-test-utils": "1.7.1-next.0",
66
- "@backstage/cli": "0.33.2-next.0",
67
- "@backstage/plugin-scaffolder-node-test-utils": "0.3.2-next.0",
65
+ "@backstage/backend-test-utils": "1.9.0-next.1",
66
+ "@backstage/cli": "0.34.2-next.1",
67
+ "@backstage/plugin-scaffolder-node-test-utils": "0.3.3-next.1",
68
68
  "msw": "^1.0.0"
69
69
  }
70
70
  }