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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,19 +1,13 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-bitbucket-cloud
2
2
 
3
- ## 0.3.2-next.0
3
+ ## 0.3.2
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 7455dae: Use node prefix on native imports
8
- - 14741e2: Fully enable API token functionality for Bitbucket-Cloud.
9
- - 69d880e: Bump to latest zod to ensure it has the latest features
7
+ - 5683c85: Bump to latest zod to ensure it has the latest features
10
8
  - Updated dependencies
11
- - @backstage/plugin-bitbucket-cloud-common@0.3.7-next.0
12
- - @backstage/backend-plugin-api@1.7.0-next.0
13
- - @backstage/plugin-scaffolder-node@0.12.4-next.0
14
- - @backstage/integration@1.19.3-next.0
15
- - @backstage/config@1.3.6
16
- - @backstage/errors@1.2.7
9
+ - @backstage/backend-plugin-api@1.6.2
10
+ - @backstage/plugin-scaffolder-node@0.12.4
17
11
 
18
12
  ## 0.3.1
19
13
 
@@ -3,6 +3,7 @@
3
3
  var errors = require('@backstage/errors');
4
4
  var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
5
5
  var helpers = require('./helpers.cjs.js');
6
+ var integration = require('@backstage/integration');
6
7
  var bitbucketCloud_examples = require('./bitbucketCloud.examples.cjs.js');
7
8
 
8
9
  const createRepository = async (opts) => {
@@ -148,9 +149,32 @@ function createPublishBitbucketCloudAction(options) {
148
149
  name: config.getOptionalString("scaffolder.defaultAuthor.name"),
149
150
  email: config.getOptionalString("scaffolder.defaultAuthor.email")
150
151
  };
151
- const auth = await helpers.getGitAuth(
152
- ctx.input.token ? { token: ctx.input.token } : integrationConfig.config
153
- );
152
+ let auth;
153
+ if (ctx.input.token) {
154
+ auth = {
155
+ username: "x-token-auth",
156
+ password: ctx.input.token
157
+ };
158
+ } else if (integrationConfig.config.clientId && integrationConfig.config.clientSecret) {
159
+ const token = await integration.getBitbucketCloudOAuthToken(
160
+ integrationConfig.config.clientId,
161
+ integrationConfig.config.clientSecret
162
+ );
163
+ auth = {
164
+ username: "x-token-auth",
165
+ password: token
166
+ };
167
+ } else {
168
+ if (!integrationConfig.config.username || !integrationConfig.config.appPassword) {
169
+ throw new Error(
170
+ "Credentials for Bitbucket Cloud integration required for this action."
171
+ );
172
+ }
173
+ auth = {
174
+ username: integrationConfig.config.username,
175
+ password: integrationConfig.config.appPassword
176
+ };
177
+ }
154
178
  const signingKey = integrationConfig.config.commitSigningKey ?? config.getOptionalString("scaffolder.defaultCommitSigningKey");
155
179
  if (signCommit && !signingKey) {
156
180
  throw new Error(
@@ -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, getGitAuth } 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 = await 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 const auth = await getGitAuth(\n ctx.input.token ? { token: ctx.input.token } : integrationConfig.config,\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","getGitAuth","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;AA6BA,MAAM,gBAAA,GAAmB,OAAO,IAAA,KAS1B;AACJ,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF,GAAI,IAAA;AAEJ,EAAA,MAAM,OAAA,GAAuB;AAAA,IAC3B,MAAA,EAAQ,MAAA;AAAA,IACR,IAAA,EAAM,KAAK,SAAA,CAAU;AAAA,MACnB,GAAA,EAAK,KAAA;AAAA,MACL,WAAA;AAAA,MACA,YAAY,cAAA,KAAmB,SAAA;AAAA,MAC/B,OAAA,EAAS,EAAE,GAAA,EAAK,OAAA;AAAQ,KACzB,CAAA;AAAA,IACD,OAAA,EAAS;AAAA,MACP,aAAA,EAAe,aAAA;AAAA,MACf,cAAA,EAAgB;AAAA;AAClB,GACF;AAEA,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI;AACF,IAAA,QAAA,GAAW,MAAM,KAAA;AAAA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GAAA,CAAI,MAAA;AAAA,YACZ,aAAA,EACE,gBAAA,IACA,MAAA,CAAO,iBAAA,CAAkB,iCAAiC,CAAA;AAAA,YAC5D,aAAA;AAAA,YACA,UAAA,EAAY,aAAa,UAAA,GAAa;AAAA,WACvC,CAAA;AACD,UAAA,OAAO,YAAA,EAAc,UAAA;AAAA,QACvB;AAAA,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
+ {"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 { getBitbucketCloudOAuthToken } from '@backstage/integration';\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 = await 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 if (\n integrationConfig.config.clientId &&\n integrationConfig.config.clientSecret\n ) {\n const token = await getBitbucketCloudOAuthToken(\n integrationConfig.config.clientId,\n integrationConfig.config.clientSecret,\n );\n auth = {\n username: 'x-token-auth',\n password: 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","getBitbucketCloudOAuthToken","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;;AA8BA,MAAM,gBAAA,GAAmB,OAAO,IAAA,KAS1B;AACJ,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF,GAAI,IAAA;AAEJ,EAAA,MAAM,OAAA,GAAuB;AAAA,IAC3B,MAAA,EAAQ,MAAA;AAAA,IACR,IAAA,EAAM,KAAK,SAAA,CAAU;AAA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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;;;;"}
@@ -4,6 +4,7 @@ var errors = require('@backstage/errors');
4
4
  var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
5
5
  var fs = require('fs-extra');
6
6
  var helpers = require('./helpers.cjs.js');
7
+ var integration = require('@backstage/integration');
7
8
  var bitbucketCloudPullRequest_examples = require('./bitbucketCloudPullRequest.examples.cjs.js');
8
9
 
9
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
@@ -246,9 +247,32 @@ function createPublishBitbucketCloudPullRequestAction(options) {
246
247
  startBranch: finalTargetBranch
247
248
  });
248
249
  const remoteUrl = `https://${host}/${workspace}/${repo}.git`;
249
- const auth = await helpers.getGitAuth(
250
- ctx.input.token ? { token: ctx.input.token } : integrationConfig.config
251
- );
250
+ let auth;
251
+ if (ctx.input.token) {
252
+ auth = {
253
+ username: "x-token-auth",
254
+ password: ctx.input.token
255
+ };
256
+ } else if (integrationConfig.config.clientId && integrationConfig.config.clientSecret) {
257
+ const token = await integration.getBitbucketCloudOAuthToken(
258
+ integrationConfig.config.clientId,
259
+ integrationConfig.config.clientSecret
260
+ );
261
+ auth = {
262
+ username: "x-token-auth",
263
+ password: token
264
+ };
265
+ } else {
266
+ if (!integrationConfig.config.username || !integrationConfig.config.appPassword) {
267
+ throw new Error(
268
+ "Credentials for Bitbucket Cloud integration required for this action."
269
+ );
270
+ }
271
+ auth = {
272
+ username: integrationConfig.config.username,
273
+ password: integrationConfig.config.appPassword
274
+ };
275
+ }
252
276
  const gitAuthorInfo = {
253
277
  name: gitAuthorName || config.getOptionalString("scaffolder.defaultAuthor.name"),
254
278
  email: gitAuthorEmail || config.getOptionalString("scaffolder.defaultAuthor.email")
@@ -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, getGitAuth } 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 = await 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 const auth = await getGitAuth(\n ctx.input.token\n ? { token: ctx.input.token }\n : integrationConfig.config,\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","getGitAuth","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,EAAA,IAAI;AACF,IAAA,QAAA,GAAW,MAAM,KAAA;AAAA,MACf,CAAA,EAAG,UAAU,CAAA,cAAA,EAAiB,SAAS,IAAI,IAAI,CAAA,aAAA,CAAA;AAAA,MAC/C;AAAA,KACF;AAAA,EACF,SAAS,CAAA,EAAG;AACV,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,gCAAA,EAAmC,CAAC,CAAA,CAAE,CAAA;AAAA,EACxD;AAEA,EAAA,IAAI,QAAA,CAAS,WAAW,GAAA,EAAK;AAC3B,IAAA,M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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
+ {"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 { getBitbucketCloudOAuthToken } from '@backstage/integration';\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 = await 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 if (\n integrationConfig.config.clientId &&\n integrationConfig.config.clientSecret\n ) {\n const token = await getBitbucketCloudOAuthToken(\n integrationConfig.config.clientId,\n integrationConfig.config.clientSecret,\n );\n auth = {\n username: 'x-token-auth',\n password: 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","getBitbucketCloudOAuthToken","getRepoSourceDirectory","cloneRepo","fs","isNotGitDirectoryOrContents","addFiles","commitAndPushBranch"],"mappings":";;;;;;;;;;;;;AAiCA,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;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E,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;;;;"}
@@ -15,22 +15,13 @@ const getBitbucketClient = async (config) => {
15
15
  }
16
16
  });
17
17
  }
18
- if (config.token && !config.username) {
18
+ if (config.token) {
19
19
  return new bitbucket.Bitbucket({
20
20
  auth: {
21
21
  token: config.token
22
22
  }
23
23
  });
24
- }
25
- if (config.username && config.token) {
26
- return new bitbucket.Bitbucket({
27
- auth: {
28
- username: config.username,
29
- password: config.token
30
- }
31
- });
32
- }
33
- if (config.username && config.appPassword) {
24
+ } else if (config.username && config.appPassword) {
34
25
  return new bitbucket.Bitbucket({
35
26
  auth: {
36
27
  username: config.username,
@@ -64,41 +55,7 @@ const getAuthorizationHeader = async (config) => {
64
55
  `Authorization has not been provided for Bitbucket Cloud. Please provide either OAuth credentials (clientId/clientSecret), username and token, or username and appPassword in the Integrations config`
65
56
  );
66
57
  };
67
- const getGitAuth = async (config) => {
68
- if (config.clientId && config.clientSecret) {
69
- const token = await integration.getBitbucketCloudOAuthToken(
70
- config.clientId,
71
- config.clientSecret
72
- );
73
- return {
74
- username: "x-token-auth",
75
- password: token
76
- };
77
- }
78
- if (config.token && !config.username) {
79
- return {
80
- username: "x-token-auth",
81
- password: config.token
82
- };
83
- }
84
- if (config.username && config.token) {
85
- return {
86
- username: "x-bitbucket-api-token-auth",
87
- password: config.token
88
- };
89
- }
90
- if (config.username && config.appPassword) {
91
- return {
92
- username: config.username,
93
- password: config.appPassword
94
- };
95
- }
96
- throw new Error(
97
- `Authorization has not been provided for Bitbucket Cloud. Please provide either OAuth credentials (clientId/clientSecret), username and token, or username and appPassword in the Integrations config`
98
- );
99
- };
100
58
 
101
59
  exports.getAuthorizationHeader = getAuthorizationHeader;
102
60
  exports.getBitbucketClient = getBitbucketClient;
103
- exports.getGitAuth = getGitAuth;
104
61
  //# sourceMappingURL=helpers.cjs.js.map
@@ -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';\nimport { getBitbucketCloudOAuthToken } from '@backstage/integration';\n\nexport const getBitbucketClient = async (config: {\n token?: string;\n username?: string;\n appPassword?: string;\n clientId?: string;\n clientSecret?: string;\n}) => {\n // If OAuth credentials provided, fetch token\n if (config.clientId && config.clientSecret) {\n const token = await getBitbucketCloudOAuthToken(\n config.clientId,\n config.clientSecret,\n );\n return new Bitbucket({\n auth: {\n token,\n },\n });\n }\n\n // Standalone token (Bearer)\n if (config.token && !config.username) {\n return new Bitbucket({\n auth: {\n token: config.token,\n },\n });\n }\n\n // Username + API token (new method)\n if (config.username && config.token) {\n return new Bitbucket({\n auth: {\n username: config.username,\n password: config.token,\n },\n });\n }\n\n // TODO: appPassword can be removed once fully\n // deprecated by BitBucket on 9th June 2026.\n if (config.username && config.appPassword) {\n return new Bitbucket({\n auth: {\n username: config.username,\n password: config.appPassword,\n },\n });\n }\n\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please provide either OAuth credentials (clientId/clientSecret), username and token, or username and appPassword in the Integrations config`,\n );\n};\n\nexport const getAuthorizationHeader = async (config: {\n username?: string;\n appPassword?: string;\n token?: string;\n clientId?: string;\n clientSecret?: string;\n}): Promise<string> => {\n // OAuth authentication\n if (config.clientId && config.clientSecret) {\n const token = await getBitbucketCloudOAuthToken(\n config.clientId,\n config.clientSecret,\n );\n return `Bearer ${token}`;\n }\n\n // TODO: appPassword can be removed once fully\n // deprecated by BitBucket on 9th June 2026.\n if (config.username && (config.token ?? config.appPassword)) {\n const buffer = Buffer.from(\n `${config.username}:${config.token ?? config.appPassword}`,\n 'utf8',\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 provide either OAuth credentials (clientId/clientSecret), username and token, or username and appPassword in the Integrations config`,\n );\n};\n\nexport const getGitAuth = async (config: {\n username?: string;\n appPassword?: string;\n token?: string;\n clientId?: string;\n clientSecret?: string;\n}): Promise<{ username: string; password: string }> => {\n // OAuth authentication\n if (config.clientId && config.clientSecret) {\n const token = await getBitbucketCloudOAuthToken(\n config.clientId,\n config.clientSecret,\n );\n return {\n username: 'x-token-auth',\n password: token,\n };\n }\n\n // Standalone token (Bearer)\n if (config.token && !config.username) {\n return {\n username: 'x-token-auth',\n password: config.token,\n };\n }\n\n // Username + API token (new method)\n // For git operations, use the static username 'x-bitbucket-api-token-auth'\n // https://support.atlassian.com/bitbucket-cloud/docs/using-api-tokens/\n if (config.username && config.token) {\n return {\n username: 'x-bitbucket-api-token-auth',\n password: config.token,\n };\n }\n\n // TODO: appPassword can be removed once fully\n // deprecated by BitBucket on 9th June 2026.\n if (config.username && config.appPassword) {\n return {\n username: config.username,\n password: config.appPassword,\n };\n }\n\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please provide either OAuth credentials (clientId/clientSecret), username and token, or username and appPassword in the Integrations config`,\n );\n};\n"],"names":["getBitbucketCloudOAuthToken","Bitbucket"],"mappings":";;;;;AAmBO,MAAM,kBAAA,GAAqB,OAAO,MAAA,KAMnC;AAEJ,EAAA,IAAI,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,YAAA,EAAc;AAC1C,IAAA,MAAM,QAAQ,MAAMA,uCAAA;AAAA,MAClB,MAAA,CAAO,QAAA;AAAA,MACP,MAAA,CAAO;AAAA,KACT;AACA,IAAA,OAAO,IAAIC,mBAAA,CAAU;AAAA,MACnB,IAAA,EAAM;AAAA,QACJ;AAAA;AACF,KACD,CAAA;AAAA,EACH;AAGA,EAAA,IAAI,MAAA,CAAO,KAAA,IAAS,CAAC,MAAA,CAAO,QAAA,EAAU;AACpC,IAAA,OAAO,IAAIA,mBAAA,CAAU;AAAA,MACnB,IAAA,EAAM;AAAA,QACJ,OAAO,MAAA,CAAO;AAAA;AAChB,KACD,CAAA;AAAA,EACH;AAGA,EAAA,IAAI,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,KAAA,EAAO;AACnC,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;AAIA,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;AAEA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,oMAAA;AAAA,GACF;AACF;AAEO,MAAM,sBAAA,GAAyB,OAAO,MAAA,KAMtB;AAErB,EAAA,IAAI,MAAA,CAAO,QAA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,MAAA,CAAO,KAAA,EAAO;AACnC,IAAA,OAAO;AAAA,MACL,QAAA,EAAU,4BAAA;AAAA,MACV,UAAU,MAAA,CAAO;AAAA,KACnB;AAAA,EACF;AAIA,EAAA,IAAI,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,WAAA,EAAa;AACzC,IAAA,OAAO;AAAA,MACL,UAAU,MAAA,CAAO,QAAA;AAAA,MACjB,UAAU,MAAA,CAAO;AAAA,KACnB;AAAA,EACF;AAEA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,oMAAA;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';\nimport { getBitbucketCloudOAuthToken } from '@backstage/integration';\n\nexport const getBitbucketClient = async (config: {\n token?: string;\n username?: string;\n appPassword?: string;\n clientId?: string;\n clientSecret?: string;\n}) => {\n // If OAuth credentials provided, fetch token\n if (config.clientId && config.clientSecret) {\n const token = await getBitbucketCloudOAuthToken(\n config.clientId,\n config.clientSecret,\n );\n return new Bitbucket({\n auth: {\n token,\n },\n });\n }\n\n if (config.token) {\n return new Bitbucket({\n auth: {\n token: config.token,\n },\n });\n } else if (config.username && config.appPassword) {\n // TODO: appPassword can be removed once fully\n // deprecated by BitBucket on 9th June 2026.\n return new Bitbucket({\n auth: {\n username: config.username,\n password: config.appPassword,\n },\n });\n }\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please provide either OAuth credentials (clientId/clientSecret), username and token, or username and appPassword in the Integrations config`,\n );\n};\n\nexport const getAuthorizationHeader = async (config: {\n username?: string;\n appPassword?: string;\n token?: string;\n clientId?: string;\n clientSecret?: string;\n}): Promise<string> => {\n // OAuth authentication\n if (config.clientId && config.clientSecret) {\n const token = await getBitbucketCloudOAuthToken(\n config.clientId,\n config.clientSecret,\n );\n return `Bearer ${token}`;\n }\n\n // TODO: appPassword can be removed once fully\n // deprecated by BitBucket on 9th June 2026.\n if (config.username && (config.token ?? config.appPassword)) {\n const buffer = Buffer.from(\n `${config.username}:${config.token ?? config.appPassword}`,\n 'utf8',\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 provide either OAuth credentials (clientId/clientSecret), username and token, or username and appPassword in the Integrations config`,\n );\n};\n"],"names":["getBitbucketCloudOAuthToken","Bitbucket"],"mappings":";;;;;AAmBO,MAAM,kBAAA,GAAqB,OAAO,MAAA,KAMnC;AAEJ,EAAA,IAAI,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,YAAA,EAAc;AAC1C,IAAA,MAAM,QAAQ,MAAMA,uCAAA;AAAA,MAClB,MAAA,CAAO,QAAA;AAAA,MACP,MAAA,CAAO;AAAA,KACT;AACA,IAAA,OAAO,IAAIC,mBAAA,CAAU;AAAA,MACnB,IAAA,EAAM;AAAA,QACJ;AAAA;AACF,KACD,CAAA;AAAA,EACH;AAEA,EAAA,IAAI,OAAO,KAAA,EAAO;AAChB,IAAA,OAAO,IAAIA,mBAAA,CAAU;AAAA,MACnB,IAAA,EAAM;AAAA,QACJ,OAAO,MAAA,CAAO;AAAA;AAChB,KACD,CAAA;AAAA,EACH,CAAA,MAAA,IAAW,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,WAAA,EAAa;AAGhD,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;AACA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,oMAAA;AAAA,GACF;AACF;AAEO,MAAM,sBAAA,GAAyB,OAAO,MAAA,KAMtB;AAErB,EAAA,IAAI,MAAA,CAAO,QAAA,IAAY,MAAA,CAAO,YAAA,EAAc;AAC1C,IAAA,MAAM,QAAQ,MAAMD,uCAAA;AAAA,MAClB,MAAA,CAAO,QAAA;AAAA,MACP,MAAA,CAAO;AAAA,KACT;AACA,IAAA,OAAO,UAAU,KAAK,CAAA,CAAA;AAAA,EACxB;AAIA,EAAA,IAAI,MAAA,CAAO,QAAA,KAAa,MAAA,CAAO,KAAA,IAAS,OAAO,WAAA,CAAA,EAAc;AAC3D,IAAA,MAAM,SAAS,MAAA,CAAO,IAAA;AAAA,MACpB,GAAG,MAAA,CAAO,QAAQ,IAAI,MAAA,CAAO,KAAA,IAAS,OAAO,WAAW,CAAA,CAAA;AAAA,MACxD;AAAA,KACF;AACA,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,oMAAA;AAAA,GACF;AACF;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-bitbucket-cloud",
3
- "version": "0.3.2-next.0",
3
+ "version": "0.3.2",
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.7.0-next.0",
54
- "@backstage/config": "1.3.6",
55
- "@backstage/errors": "1.2.7",
56
- "@backstage/integration": "1.19.3-next.0",
57
- "@backstage/plugin-bitbucket-cloud-common": "0.3.7-next.0",
58
- "@backstage/plugin-scaffolder-node": "0.12.4-next.0",
53
+ "@backstage/backend-plugin-api": "^1.6.2",
54
+ "@backstage/config": "^1.3.6",
55
+ "@backstage/errors": "^1.2.7",
56
+ "@backstage/integration": "^1.19.2",
57
+ "@backstage/plugin-bitbucket-cloud-common": "^0.3.6",
58
+ "@backstage/plugin-scaffolder-node": "^0.12.4",
59
59
  "bitbucket": "^2.12.0",
60
60
  "fs-extra": "^11.2.0",
61
61
  "yaml": "^2.0.0",
62
62
  "zod": "^3.25.76"
63
63
  },
64
64
  "devDependencies": {
65
- "@backstage/backend-test-utils": "1.10.4-next.0",
66
- "@backstage/cli": "0.35.3-next.0",
67
- "@backstage/plugin-scaffolder-node-test-utils": "0.3.8-next.0",
65
+ "@backstage/backend-test-utils": "^1.10.4",
66
+ "@backstage/cli": "^0.35.3",
67
+ "@backstage/plugin-scaffolder-node-test-utils": "^0.3.7",
68
68
  "msw": "^1.0.0"
69
69
  }
70
70
  }